DumpPython working again. Better handling of the connection from script part.
Still a big crash when trying to replay a script ... to be continued.
##
## From GUI: part 2
##
-FIND_PACKAGE(SalomeCAS REQUIRED)
+FIND_PACKAGE(SalomeCAS REQUIRED) # [ABN] I wish I could avoid that ...
##
## From MED
*/
void PutPythonTraceStringToEngine(in string trace);
+ /*! Indicates if the GUI process is already connected to the pvserver.
+ * This avoids multiple attempts to connect from a single thread (makes ParaView crash). */
+ void SetGUIConnected(in boolean isConnected);
+
+ boolean GetGUIConnected();
+
};
};
self.pvserverPort = -1
self.pvserverPop = None # Popen object from subprocess module
self.lastTrace = ""
+ self.isGUIConnected = False # whether there is an active connection from the GUI.
"""
Private. Identify a free port to launch the PVServer.
def PutPythonTraceStringToEngine( self, t ):
self.lastTrace = t
- def GetPythonTraceString (self):
+ def GetPythonTraceString(self):
return self.lastTrace
+
+ def SetGUIConnected( self, isConnected ):
+ self.isGUIConnected = isConnected
+
+ def GetGUIConnected( self ):
+ return self.isGUIConnected
class PARAVIS(PARAVIS_ORB__POA.PARAVIS_Gen,
SALOME_ComponentPy.SALOME_ComponentPy_i,
Create object.
"""
def createObject( self, study, name ):
+ MESSAGE("createObject()")
self._createdNew = True # used for getModifiedData method
builder = study.NewBuilder()
father = findOrCreateComponent( study )
attr = builder.FindOrCreateAttribute( object, "AttributeName" )
attr.SetValue( name )
attr = builder.FindOrCreateAttribute( object, "AttributeLocalID" )
- attr.SetValue( objectID() )
+ attr.SetValue( PARAVIS_utils.objectID() )
pass
"""
Dump module data to the Python script.
"""
- def DumpPython( self, study, isPublished ):
- print "@@@@ DumpPython"
- abuffer = []
- abuffer.append( "def RebuildData( theStudy ):" )
- names = []
- father = study.FindComponent( moduleName() )
- if father:
- iter = study.NewChildIterator( father )
- while iter.More():
- name = iter.Value().GetName()
- if name: names.append( name )
- iter.Next()
- pass
- pass
- if names:
- abuffer += [ " from batchmode_salome import lcc" ]
- abuffer += [ " import PARAVIS_ORB" ]
- abuffer += [ " " ]
- abuffer += [ " pyhello = lcc.FindOrLoadComponent( 'FactoryServerPy', '%s' )" % moduleName() ]
- abuffer += [ " " ]
- abuffer += [ " pyhello.createObject( theStudy, '%s' )" % name for name in names ]
- pass
- abuffer += [ " " ]
- abuffer.append( " pass" )
- abuffer.append( "\0" )
+ def DumpPython( self, study, isPublished, isMultiFile ):
+ MESSAGE("dumpPython()")
+ abuffer = self.GetPythonTraceString().split("\n")
+ if isMultiFile:
+ abuffer = [ " " + s for s in abuffer ]
+ abuffer[0:0] = [ "def RebuildData( theStudy ):" ]
+ abuffer += [ " pass" ]
+ abuffer += [ "\0" ]
return ("\n".join( abuffer ), 1)
"""
Import file to restore module data
"""
def importData(self, studyId, dataContainer, options):
- print "@@@@ ImportData"
+ MESSAGE("importData()")
# get study by Id
obj = self._naming_service.Resolve("myStudyManager")
myStudyManager = obj._narrow(SALOMEDS.StudyManager)
return ["objects"] # identifier what is in this file
def getModifiedData(self, studyId):
- print "@@@@ GetModifiedData"
+ MESSAGE("getModifiedData()")
if self._createdNew:
# get study by Id
obj = self._naming_service.Resolve("myStudyManager")
# additional preprocessor / compiler flags
ADD_DEFINITIONS(${CAS_DEFINITIONS})
-ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
ADD_DEFINITIONS(${OMNIORB_DEFINITIONS})
+ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
# libraries to link to
SET(_PARAVIEW_APP_COMPO_LIB
SET(_link_LIBRARIES
${OMNIORB_LIBRARIES}
${QT_LIBRARIES}
-# ${CAS_KERNEL}
${PYTHON_LIBS}
- ${KERNEL_LDFLAGS} ${KERNEL_SalomeDS} ${KERNEL_SALOMELocalTrace} ${KERNEL_SalomeIDLKernel}
- ${KERNEL_SalomeNS} ${KERNEL_SalomeLifeCycleCORBA} ${KERNEL_SalomeContainer} ${KERNEL_TOOLSDS}
- ${GUI_LDFLAGS} ${GUI_SalomeApp} ${GUI_LightApp} ${GUI_CAM} ${GUI_qtx} ${GUI_suit} ${GUI_Event} ${GUI_PyInterp}
+ ${KERNEL_LDFLAGS}
+ ${GUI_LDFLAGS} ${GUI_SalomeApp} ${GUI_LightApp} ${GUI_CAM} ${GUI_qtx} ${GUI_suit} ${GUI_Event}
${GUI_SalomeObject} ${GUI_vtkTools}
${MED_SalomeIDLMED}
${_PARAVIEW_APP_COMPO_LIB}
- SalomeIDLPARAVIS
PVViewer
)
#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
#include CORBA_SERVER_HEADER(SALOMEDS)
-#include "PVGUI_ViewModel.h"
#include "PVGUI_ViewManager.h"
#include "PVGUI_ViewWindow.h"
+#include "PVGUI_ViewModel.h"
#include "PVGUI_Tools.h"
#include "PVGUI_ParaViewSettingsPane.h"
-#include "PVGUI_OutputWindowAdapter.h"
-#include "PVGUI_Behaviors.h"
// SALOME Includes
#include <SUIT_DataBrowser.h>
#include <vtkSMParaViewPipelineController.h>
#include <pqApplicationCore.h>
-//#include <pqPVApplicationCore.h>
+#include <pqPVApplicationCore.h>
#include <pqActiveView.h>
#include <pqObjectBuilder.h>
#include <pqOptions.h>
#include <pqScalarBarVisibilityReaction.h>
#include <pqServerResource.h>
#include <pqServerConnectReaction.h>
-#include <pqServerDisconnectReaction.h>
//----------------------------------------------------------------------------
PVGUI_Module* ParavisModule = 0;
SALOME module wrapping ParaView GUI.
*/
+_PTR(SComponent)
+ClientFindOrCreateParavisComponent(_PTR(Study) theStudyDocument)
+{
+ _PTR(SComponent) aSComponent = theStudyDocument->FindComponent("PARAVIS");
+ if (!aSComponent) {
+ _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
+ aStudyBuilder->NewCommand();
+ int aLocked = theStudyDocument->GetProperties()->IsLocked();
+ if (aLocked) theStudyDocument->GetProperties()->SetLocked(false);
+ aSComponent = aStudyBuilder->NewComponent("PARAVIS");
+ _PTR(GenericAttribute) anAttr =
+ aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
+ _PTR(AttributeName) aName (anAttr);
+
+ ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
+ CORBA::ORB_var anORB = init( qApp->argc(), qApp->argv() );
+
+ SALOME_NamingService *NamingService = new SALOME_NamingService( anORB );
+ CORBA::Object_var objVarN = NamingService->Resolve("/Kernel/ModulCatalog");
+ SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
+ SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
+ SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "PARAVIS" );
+ if (!Comp->_is_nil()) {
+ aName->SetValue(Comp->componentusername());
+ }
+
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributePixMap");
+ _PTR(AttributePixMap) aPixmap (anAttr);
+ aPixmap->SetPixMap( "pqAppIcon16.png" );
+
+ // Create Attribute parameters for future using
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeParameter");
+
+ aStudyBuilder->DefineComponentInstance(aSComponent, PVGUI_Module::GetEngine()->GetIOR());
+ if (aLocked) theStudyDocument->GetProperties()->SetLocked(true);
+ aStudyBuilder->CommitCommand();
+ }
+ return aSComponent;
+}
+
/*!
Clean up function; used to stop ParaView progress events when
exception is caught by global exception handler.
delete myPushTraceTimer;
if (myInitTimer)
delete myInitTimer;
- // Disconnect from server
- pqServer* server = pqActiveObjects::instance().activeServer();
- if (server && server->isRemote())
- {
- MESSAGE("~PVGUI_Module(): Disconnecting from remote server ...");
- pqServerDisconnectReaction::disconnectFromServer();
- }
}
PARAVIS_ORB::PARAVIS_Gen_var PVGUI_Module::GetEngine()
{
- return PVGUI_ViewerModel::GetEngine();
+ return PVGUI_ViewManager::GetEngine();
+}
+
+pqPVApplicationCore * PVGUI_Module::GetPVApplication()
+{
+ return PVGUI_ViewManager::GetPVApplication();
}
/*!
aa = aa;
}
*/
-
- // Initialize ParaView client
- pvInit();
- // Create GUI elements (menus, toolbars, dock widgets)
SalomeApp_Application* anApp = getApp();
SUIT_Desktop* aDesktop = anApp->desktop();
+ // Initialize ParaView client and associated behaviors
+ // and connect to externally launched pvserver
+ PVGUI_ViewManager::ParaviewInitApp(aDesktop);
+
// Remember current state of desktop toolbars
QList<QToolBar*> foreignToolbars = aDesktop->findChildren<QToolBar*>();
setupDockWidgets();
+ // Behaviors and connection must be instanciated *after* widgets are in place:
+ PVGUI_ViewManager::ParaviewInitBehaviors(true, aDesktop);
+ PVGUI_ViewManager::ConnectToExternalPVServer(aDesktop);
+
pvCreateActions();
pvCreateToolBars();
pvCreateMenus();
QList<QDockWidget*> activeDocks = aDesktop->findChildren<QDockWidget*>();
QList<QMenu*> activeMenus = aDesktop->findChildren<QMenu*>();
- PVGUI_Behaviors * behav = new PVGUI_Behaviors(this);
- behav->instanciateAllBehaviors(aDesktop);
-
// Setup quick-launch shortcuts.
QShortcut *ctrlSpace = new QShortcut(Qt::CTRL + Qt::Key_Space, aDesktop);
QObject::connect(ctrlSpace, SIGNAL(activated()),
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
QString aPath = resMgr->stringValue("resources", "PARAVIS", QString());
if (!aPath.isNull()) {
- MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewFilters.xml");
- MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewReaders.xml");
- MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewSources.xml");
- MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewWriters.xml");
+ pqPVApplicationCore * pvApp = GetPVApplication();
+ pvApp->loadConfiguration(aPath + QDir::separator() + "ParaViewFilters.xml");
+ pvApp->loadConfiguration(aPath + QDir::separator() + "ParaViewReaders.xml");
+ pvApp->loadConfiguration(aPath + QDir::separator() + "ParaViewSources.xml");
+ pvApp->loadConfiguration(aPath + QDir::separator() + "ParaViewWriters.xml");
}
- // Force creation of the PARAVIS engine
- GetEngine();
updateObjBrowser();
// Find created toolbars
void PVGUI_Module::onInitTimer()
{
#ifndef PARAVIS_WITH_FULL_CORBA
- connectToExternalPVServer();
+// connectToExternalPVServer();
#endif
startTrace();
}
*/
void PVGUI_Module::showView( bool toShow )
{
- PVGUI_ViewManager
SalomeApp_Application* anApp = getApp();
PVGUI_ViewManager* viewMgr =
dynamic_cast<PVGUI_ViewManager*>( anApp->getViewManager( PVGUI_Viewer::Type(), false ) );
if ( myRecentMenuId != -1 ) menuMgr()->show(myRecentMenuId);
-// ClientFindOrCreateParavisComponent(PARAVIS::GetCStudy(this));
+ ClientFindOrCreateParavisComponent(PARAVIS::GetCStudy(this));
return isDone;
}
*/
void PVGUI_Module::onApplicationClosed( SUIT_Application* theApp )
{
- pqApplicationCore::instance()->settings()->sync();
+ PVGUI_ViewManager::ParaviewCleanup();
+
int aAppsNb = SUIT_Session::session()->applications().size();
if (aAppsNb == 1) {
deleteTemporaryFiles();
- MyCoreApp->deleteLater();
}
CAM_Module::onApplicationClosed(theApp);
}
virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
- inline static PARAVIS_ORB::PARAVIS_Gen_var GetEngine() { return PVGUI_ViewerModel::GetEngine(); }
+ inline static PARAVIS_ORB::PARAVIS_Gen_var GetEngine();
+ inline static pqPVApplicationCore * GetPVApplication();
public slots:
//void onImportFromVisu(QString theEntry);
#include <pqColorMapEditor.h>
#include <pqDeleteReaction.h>
-class ResizeHelper : public pqPVAnimationWidget
-{
- // TEMPORARILY WORKAROUND AROUND PARAVIEW 3.14 BUG:
- // WHEN ANIMATION VIEW IS RESIZED, ITS CONTENTS IS NOT PREPERLY RE-ARRANGED
- // CAUSING SOME CONTROLS TO STAY NON-VISIBLE
- // THIS BUG IS NATURALLY FIXED BY ADDING
- // this->updateGeometries();
- // TO THE
- // void pqAnimationWidget::resizeEvent(QResizeEvent* e);
- // BUT THIS CANNOT BE DONE DIRECTLY, SINCE CORRESPONDING API IS NOT PUBLIC
- // THE ONLY WAY TO DO THIS BY SENDING SHOW EVENT TO THE WIDGET
-
-public:
- ResizeHelper( QWidget* parent ) : pqPVAnimationWidget( parent ) {}
-protected:
- void resizeEvent(QResizeEvent* e)
- {
- pqAnimationWidget* w = findChild<pqAnimationWidget*>( "pqAnimationWidget" );
- if ( w ) {
- QShowEvent e;
- QApplication::sendEvent( w, &e );
- }
- pqPVAnimationWidget::resizeEvent( e );
- }
-};
+//class ResizeHelper : public pqPVAnimationWidget
+//{
+// // TEMPORARILY WORKAROUND AROUND PARAVIEW 3.14 BUG:
+// // WHEN ANIMATION VIEW IS RESIZED, ITS CONTENTS IS NOT PREPERLY RE-ARRANGED
+// // CAUSING SOME CONTROLS TO STAY NON-VISIBLE
+// // THIS BUG IS NATURALLY FIXED BY ADDING
+// // this->updateGeometries();
+// // TO THE
+// // void pqAnimationWidget::resizeEvent(QResizeEvent* e);
+// // BUT THIS CANNOT BE DONE DIRECTLY, SINCE CORRESPONDING API IS NOT PUBLIC
+// // THE ONLY WAY TO DO THIS BY SENDING SHOW EVENT TO THE WIDGET
+//
+//public:
+// ResizeHelper( QWidget* parent ) : pqPVAnimationWidget( parent ) {}
+//protected:
+// void resizeEvent(QResizeEvent* e)
+// {
+// pqAnimationWidget* w = findChild<pqAnimationWidget*>( "pqAnimationWidget" );
+// if ( w ) {
+// QShowEvent e;
+// QApplication::sendEvent( w, &e );
+// }
+// pqPVAnimationWidget::resizeEvent( e );
+// }
+//};
/*!
\brief Create dock widgets for ParaView widgets such as object inspector, pipeline browser, etc.
QDockWidget* animationViewDock = new QDockWidget( tr( "TTL_ANIMATION_VIEW" ), desk );
animationViewDock->setObjectName("animationViewDock");
desk->addDockWidget( Qt::BottomDockWidgetArea, animationViewDock );
- pqPVAnimationWidget* animation_panel = new ResizeHelper(animationViewDock); //pqPVAnimationWidget
+ pqPVAnimationWidget* animation_panel = new pqPVAnimationWidget(animationViewDock); // [ABN] was resizeHelper
animationViewDock->setWidget(animation_panel);
myDockWidgets[animationViewDock] = false; // hidden by default
pqApplicationComponents
)
+ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
+ADD_DEFINITIONS(${OMNIORB_DEFINITIONS})
+
SET(_link_LIBRARIES
- ${KERNEL_LDFLAGS} ${KERNEL_SALOMELocalTrace}
- ${GUI_LDFLAGS} ${GUI_LightApp} ${GUI_suit} ${GUI_Event} ${_PARAVIEW_APP_COMPO_LIB}
+ ${KERNEL_LDFLAGS} ${KERNEL_SALOMELocalTrace} ${KERNEL_SalomeLifeCycleCORBA}
+ ${GUI_LDFLAGS} ${GUI_SalomeApp} ${GUI_LightApp} ${GUI_suit} ${GUI_Event}
+ ${_PARAVIEW_APP_COMPO_LIB}
+ SalomeIDLPARAVIS
)
# --- headers ---
# header files / no moc processing
SET(_other_HEADERS
- PVGUI_OutputWindowAdapter.h
+ PVGUI_LogWindowAdapter.h
)
# header files / to install
SET(PVViewer_HEADERS ${_moc_HEADERS} ${_other_HEADERS})
PVGUI_ViewManager.cxx
PVGUI_ViewModel.cxx
PVGUI_ViewWindow.cxx
- PVGUI_OutputWindowAdapter.cxx
+ PVGUI_LogWindowAdapter.cxx
PVGUI_Behaviors.cxx
)
bool PVGUI_Behaviors::hasMinimalInstanciated = false;
-PVGUI_Behaviors::PVGUI_Behaviors(SalomeApp_Module * parent)
+PVGUI_Behaviors::PVGUI_Behaviors(SUIT_Desktop * parent)
: QObject(static_cast<QObject *>(parent))
{
}
Q_OBJECT
public:
- PVGUI_Behaviors(SalomeApp_Module * parent);
+ PVGUI_Behaviors(SUIT_Desktop * parent);
void instanciateMinimalBehaviors(SUIT_Desktop * desk);
--- /dev/null
+// Copyright (C) 2010-2014 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "PVGUI_LogWindowAdapter.h"
+
+#include <vtkObjectFactory.h>
+
+#include <LightApp_Application.h>
+#include <LogWindow.h>
+#include <SUIT_Session.h>
+#include <SALOME_Event.h>
+
+vtkStandardNewMacro(PVGUI_LogWindowAdapter);
+
+
+
+/*!
+ * Put the message in the log window.
+ */
+class TEvent: public SALOME_Event {
+ LogWindow* myWindow;
+ QString myMsg;
+ QColor myColor;
+ int myFlags;
+ public:
+ TEvent( LogWindow* theWindow, const QString theMsg, const QColor theColor, const int flags) :
+ myWindow ( theWindow ),
+ myMsg ( theMsg ),
+ myColor ( theColor ),
+ myFlags (flags)
+ {}
+
+ virtual void Execute() {
+ if(myWindow)
+ myWindow->putMessage(myMsg, myColor, myFlags);
+ }
+};
+
+
+PVGUI_LogWindowAdapter::PVGUI_LogWindowAdapter() :
+ TextCount(0),
+ ErrorCount(0),
+ WarningCount(0),
+ GenericWarningCount(0)
+{
+}
+
+PVGUI_LogWindowAdapter::~PVGUI_LogWindowAdapter()
+{
+}
+
+const unsigned int PVGUI_LogWindowAdapter::getTextCount()
+{
+ return this->TextCount;
+}
+
+const unsigned int PVGUI_LogWindowAdapter::getErrorCount()
+{
+ return this->ErrorCount;
+}
+
+const unsigned int PVGUI_LogWindowAdapter::getWarningCount()
+{
+ return this->WarningCount;
+}
+
+const unsigned int PVGUI_LogWindowAdapter::getGenericWarningCount()
+{
+ return this->GenericWarningCount;
+}
+
+static LogWindow* getLogWindow()
+{
+ LogWindow* wnd = 0;
+ LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
+ if ( anApp )
+ wnd = anApp->logWindow();
+ return wnd;
+}
+
+void PVGUI_LogWindowAdapter::DisplayText(const char* text)
+{
+ ++this->TextCount;
+ ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkGreen, LogWindow::DisplayNormal ));
+}
+
+void PVGUI_LogWindowAdapter::DisplayErrorText(const char* text)
+{
+ ++this->ErrorCount;
+ ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkRed, LogWindow::DisplayNormal ));
+}
+
+void PVGUI_LogWindowAdapter::DisplayWarningText(const char* text)
+{
+ ++this->WarningCount;
+ ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::black, LogWindow::DisplayNormal ));
+}
+
+void PVGUI_LogWindowAdapter::DisplayGenericWarningText(const char* text)
+{
+ ++this->GenericWarningCount;
+ ProcessVoidEvent( new TEvent( getLogWindow() , text, Qt::black, LogWindow::DisplayNormal ));
+}
--- /dev/null
+// Copyright (C) 2010-2014 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _PVGUI_LogWindowAdapter_h
+#define _PVGUI_LogWindowAdapter_h
+
+#include <vtkOutputWindow.h>
+
+/*!
+vtkOutputWindow implementation that puts VTK output messages to SALOME log window.
+
+To use, create an instance of PVGUI_LogWindowAdapter and pass it to the
+vtkOutputWindow::setInstance() static method.
+
+This class is based on pqOutputWindow ParaView class.
+*/
+class PVGUI_LogWindowAdapter : public vtkOutputWindow
+{
+public:
+ static PVGUI_LogWindowAdapter *New();
+ vtkTypeMacro(PVGUI_LogWindowAdapter, vtkOutputWindow);
+
+ //! Returns the number of text messages received
+ const unsigned int getTextCount();
+ //! Returns the number of error messages received
+ const unsigned int getErrorCount();
+ //! Returns the number of warning messages received
+ const unsigned int getWarningCount();
+ //! Returns the number of generic warning messages received
+ const unsigned int getGenericWarningCount();
+
+private:
+ PVGUI_LogWindowAdapter();
+ PVGUI_LogWindowAdapter(const PVGUI_LogWindowAdapter&);
+ PVGUI_LogWindowAdapter& operator=(const PVGUI_LogWindowAdapter&);
+ ~PVGUI_LogWindowAdapter();
+
+ unsigned int TextCount;
+ unsigned int ErrorCount;
+ unsigned int WarningCount;
+ unsigned int GenericWarningCount;
+
+ virtual void DisplayText(const char*);
+ virtual void DisplayErrorText(const char*);
+ virtual void DisplayWarningText(const char*);
+ virtual void DisplayGenericWarningText(const char*);
+};
+
+#endif // !_PVGUI_LogWindowAdapter_h
+++ /dev/null
-// Copyright (C) 2010-2014 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "PVGUI_OutputWindowAdapter.h"
-
-#include <vtkObjectFactory.h>
-
-#include <LightApp_Application.h>
-#include <LogWindow.h>
-#include <SUIT_Session.h>
-#include <SALOME_Event.h>
-
-vtkStandardNewMacro(PVGUI_OutputWindowAdapter);
-
-
-
-/*!
- * Put the message in the log window.
- */
-class TEvent: public SALOME_Event {
- LogWindow* myWindow;
- QString myMsg;
- QColor myColor;
- int myFlags;
- public:
- TEvent( LogWindow* theWindow, const QString theMsg, const QColor theColor, const int flags) :
- myWindow ( theWindow ),
- myMsg ( theMsg ),
- myColor ( theColor ),
- myFlags (flags)
- {}
-
- virtual void Execute() {
- if(myWindow)
- myWindow->putMessage(myMsg, myColor, myFlags);
- }
-};
-
-
-PVGUI_OutputWindowAdapter::PVGUI_OutputWindowAdapter() :
- TextCount(0),
- ErrorCount(0),
- WarningCount(0),
- GenericWarningCount(0)
-{
-}
-
-PVGUI_OutputWindowAdapter::~PVGUI_OutputWindowAdapter()
-{
-}
-
-const unsigned int PVGUI_OutputWindowAdapter::getTextCount()
-{
- return this->TextCount;
-}
-
-const unsigned int PVGUI_OutputWindowAdapter::getErrorCount()
-{
- return this->ErrorCount;
-}
-
-const unsigned int PVGUI_OutputWindowAdapter::getWarningCount()
-{
- return this->WarningCount;
-}
-
-const unsigned int PVGUI_OutputWindowAdapter::getGenericWarningCount()
-{
- return this->GenericWarningCount;
-}
-
-static LogWindow* getLogWindow()
-{
- LogWindow* wnd = 0;
- LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
- if ( anApp )
- wnd = anApp->logWindow();
- return wnd;
-}
-
-void PVGUI_OutputWindowAdapter::DisplayText(const char* text)
-{
- ++this->TextCount;
- ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkGreen, LogWindow::DisplayNormal ));
-}
-
-void PVGUI_OutputWindowAdapter::DisplayErrorText(const char* text)
-{
- ++this->ErrorCount;
- ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkRed, LogWindow::DisplayNormal ));
-}
-
-void PVGUI_OutputWindowAdapter::DisplayWarningText(const char* text)
-{
- ++this->WarningCount;
- ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::black, LogWindow::DisplayNormal ));
-}
-
-void PVGUI_OutputWindowAdapter::DisplayGenericWarningText(const char* text)
-{
- ++this->GenericWarningCount;
- ProcessVoidEvent( new TEvent( getLogWindow() , text, Qt::black, LogWindow::DisplayNormal ));
-}
+++ /dev/null
-// Copyright (C) 2010-2014 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _PVGUI_OutputWindowAdapter_h
-#define _PVGUI_OutputWindowAdapter_h
-
-#include <vtkOutputWindow.h>
-
-/*!
-vtkOutputWindow implementation that puts VTK output messages to SALOME log window.
-
-To use, create an instance of PVGUI_OutputWindowAdapter and pass it to the
-vtkOutputWindow::setInstance() static method.
-
-This class is based on pqOutputWindow ParaView class.
-*/
-class PVGUI_OutputWindowAdapter : public vtkOutputWindow
-{
-public:
- static PVGUI_OutputWindowAdapter *New();
- vtkTypeMacro(PVGUI_OutputWindowAdapter, vtkOutputWindow);
-
- //! Returns the number of text messages received
- const unsigned int getTextCount();
- //! Returns the number of error messages received
- const unsigned int getErrorCount();
- //! Returns the number of warning messages received
- const unsigned int getWarningCount();
- //! Returns the number of generic warning messages received
- const unsigned int getGenericWarningCount();
-
-private:
- PVGUI_OutputWindowAdapter();
- PVGUI_OutputWindowAdapter(const PVGUI_OutputWindowAdapter&);
- PVGUI_OutputWindowAdapter& operator=(const PVGUI_OutputWindowAdapter&);
- ~PVGUI_OutputWindowAdapter();
-
- unsigned int TextCount;
- unsigned int ErrorCount;
- unsigned int WarningCount;
- unsigned int GenericWarningCount;
-
- virtual void DisplayText(const char*);
- virtual void DisplayErrorText(const char*);
- virtual void DisplayWarningText(const char*);
- virtual void DisplayGenericWarningText(const char*);
-};
-
-#endif // !_PVGUI_OutputWindowAdapter_h
#include <PVGUI_ViewManager.h>
#include <PVGUI_ViewModel.h>
#include <PVGUI_ViewWindow.h>
-#include <pqApplicationCore.h>
+#include <PVGUI_Behaviors.h>
+#include <PVGUI_LogWindowAdapter.h>
+#include <utilities.h>
+#include <SalomeApp_Application.h>
+#include <SALOMEconfig.h>
+#include <SALOME_LifeCycleCORBA.hxx>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_Session.h>
+#include <PyInterp_Interp.h>
+#include <PyConsole_Interp.h>
+#include <PyConsole_Console.h>
+
+#include <QApplication>
+#include <QStringList>
+#include <string>
+
+#include <pqOptions.h>
+#include <pqServer.h>
+#include <pqSettings.h>
+#include <pqServerDisconnectReaction.h>
+#include <pqPVApplicationCore.h>
#include <pqTabbedMultiViewWidget.h>
+#include <pqActiveObjects.h>
+#include <pqServerConnectReaction.h>
+
+//---------- Static init -----------------
+pqPVApplicationCore* PVGUI_ViewManager::MyCoreApp = 0;
+PARAVIS_ORB::PARAVIS_Gen_var PVGUI_ViewManager::MyEngine;
+
/*!
Constructor
PVGUI_ViewManager::PVGUI_ViewManager( SUIT_Study* study, SUIT_Desktop* desk )
: SUIT_ViewManager( study, desk, new PVGUI_Viewer() )
{
+ MESSAGE("PARAVIS - view manager created ...")
setTitle( tr( "PARAVIEW_VIEW_TITLE" ) );
}
+pqPVApplicationCore * PVGUI_ViewManager::GetPVApplication()
+{
+ return MyCoreApp;
+}
+
/*!
- \brief Returns the ParaView multi-view manager for the active view window
+ \brief Static method, performs initialization of ParaView session.
+ \param fullSetup whether to instanciate all behaviors or just the minimal ones.
+ \return \c true if ParaView has been initialized successfully, otherwise false
*/
-pqTabbedMultiViewWidget* PVGUI_ViewManager::getMultiViewManager()
+bool PVGUI_ViewManager::ParaviewInitApp(SUIT_Desktop * aDesktop)
+{
+ if ( ! MyCoreApp) {
+ // Obtain command-line arguments
+ int argc = 0;
+ char** argv = 0;
+ QString aOptions = getenv("PARAVIS_OPTIONS");
+ QStringList aOptList = aOptions.split(":", QString::SkipEmptyParts);
+ argv = new char*[aOptList.size() + 1];
+ QStringList args = QApplication::arguments();
+ argv[0] = (args.size() > 0)? strdup(args[0].toLatin1().constData()) : strdup("paravis");
+ argc++;
+
+ foreach (QString aStr, aOptList) {
+ argv[argc] = strdup( aStr.toLatin1().constData() );
+ argc++;
+ }
+ MyCoreApp = new pqPVApplicationCore (argc, argv);
+ if (MyCoreApp->getOptions()->GetHelpSelected() ||
+ MyCoreApp->getOptions()->GetUnknownArgument() ||
+ MyCoreApp->getOptions()->GetErrorMessage() ||
+ MyCoreApp->getOptions()->GetTellVersion()) {
+ return false;
+ }
+
+ // Direct VTK log messages to our SALOME window - TODO: review this
+ vtkOutputWindow::SetInstance(PVGUI_LogWindowAdapter::New());
+
+ new pqTabbedMultiViewWidget(); // registers a "MULTIVIEW_WIDGET" on creation
+
+ // At this stage, the pqPythonManager has been initialized, i.e. the current process has
+ // activated the embedded Python interpreter. "paraview" package has also been imported once already.
+ // Make sure the current process executes paraview's Python command with the "fromGUI" flag.
+ // This is used in pvsimple.py to avoid reconnecting the GUI thread to the pvserver (when
+ // user types "import pvsimple" in SALOME's console).
+ SalomeApp_Application* app =
+ dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication());
+ PyConsole_Interp* pyInterp = app->pythonConsole()->getInterp();
+ {
+ PyLockWrapper aGil;
+ std::string cmd = "import paraview; paraview.fromGUI = True;";
+ pyInterp->run(cmd.c_str());
+ }
+
+ for (int i = 0; i < argc; i++)
+ free(argv[i]);
+ delete[] argv;
+ }
+
+ return true;
+}
+
+void PVGUI_ViewManager::ParaviewInitBehaviors(bool fullSetup, SUIT_Desktop* aDesktop)
{
- return qobject_cast<pqTabbedMultiViewWidget*>(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET"));
+ PVGUI_Behaviors * behav = new PVGUI_Behaviors(aDesktop);
+ if(fullSetup)
+ behav->instanciateAllBehaviors(aDesktop);
+ else
+ behav->instanciateMinimalBehaviors(aDesktop);
+}
+
+void PVGUI_ViewManager::ParaviewCleanup()
+{
+ // Disconnect from server
+ pqServer* server = pqActiveObjects::instance().activeServer();
+ if (server && server->isRemote())
+ {
+ MESSAGE("~PVGUI_Module(): Disconnecting from remote server ...");
+ pqServerDisconnectReaction::disconnectFromServer();
+ }
+
+ pqApplicationCore::instance()->settings()->sync();
+
+ pqPVApplicationCore * app = GetPVApplication();
+ // Schedule destruction of PVApplication singleton:
+ if (app)
+ app->deleteLater();
+}
+
+PARAVIS_ORB::PARAVIS_Gen_var PVGUI_ViewManager::GetEngine()
+{
+ // initialize PARAVIS module engine (load, if necessary)
+ if ( CORBA::is_nil( MyEngine ) ) {
+ Engines::EngineComponent_var comp =
+ SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "PARAVIS" );
+ MyEngine = PARAVIS_ORB::PARAVIS_Gen::_narrow( comp );
+ }
+ return MyEngine;
+}
+
+bool PVGUI_ViewManager::ConnectToExternalPVServer(SUIT_Desktop* aDesktop)
+{
+ pqServer* server = pqActiveObjects::instance().activeServer();
+ if (server && server->isRemote())
+ {
+ // Already connected to an external server, do nothing
+ MESSAGE("connectToExternalPVServer(): Already connected to an external PVServer, won't reconnect.");
+ return false;
+ }
+
+ if (GetEngine()->GetGUIConnected())
+ {
+ // Should never be there as the above should already tell us that we are connected.
+ std::stringstream msg2;
+ msg2 << "Internal error while connecting to the pvserver.";
+ msg2 << "ParaView doesn't see a connection, but PARAVIS engine tells us there is already one!" << std::endl;
+ qWarning(msg2.str().c_str()); // will go to the ParaView console (see ParavisMessageOutput below)
+ SUIT_MessageBox::warning( aDesktop,
+ QString("Error connecting to PVServer"), QString(msg2.str().c_str()));
+ return false;
+ }
+
+ std::stringstream msg;
+
+ // Try to connect to the external PVServer - gives priority to an externally specified URL:
+ QString serverUrlEnv = getenv("PARAVIS_PVSERVER_URL");
+ std::string serverUrl;
+ if (!serverUrlEnv.isEmpty())
+ serverUrl = serverUrlEnv.toStdString();
+ else
+ {
+ // Get the URL from the engine (possibly starting the pvserver)
+ CORBA::String_var url = GetEngine()->FindOrStartPVServer(0); // take the first free port
+ serverUrl = (char *)url;
+ }
+
+ msg << "connectToExternalPVServer(): Trying to connect to the external PVServer '" << serverUrl << "' ...";
+ MESSAGE(msg.str());
+
+ if (!pqServerConnectReaction::connectToServer(pqServerResource(serverUrl.c_str())))
+ {
+ std::stringstream msg2;
+ msg2 << "Error while connecting to the requested pvserver '" << serverUrl;
+ msg2 << "'. Might use default built-in connection instead!" << std::endl;
+ qWarning(msg2.str().c_str()); // will go to the ParaView console (see ParavisMessageOutput below)
+ SUIT_MessageBox::warning( aDesktop,
+ QString("Error connecting to PVServer"), QString(msg2.str().c_str()));
+ return false;
+ }
+ else
+ {
+ MESSAGE("connectToExternalPVServer(): Connected!");
+ GetEngine()->SetGUIConnected(true);
+ }
+ return true;
}
#define PVGUI_VIEWMANAGER_H
#include <SUIT_ViewManager.h>
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(PARAVIS_Gen)
class SUIT_Desktop;
class SUIT_Study;
class pqTabbedMultiViewWidget;
+class pqPVApplicationCore;
class PVGUI_ViewManager : public SUIT_ViewManager
{
PVGUI_ViewManager( SUIT_Study*, SUIT_Desktop* );
~PVGUI_ViewManager() {}
- pqTabbedMultiViewWidget* getMultiViewManager();
+ static pqPVApplicationCore * GetPVApplication();
+ static PARAVIS_ORB::PARAVIS_Gen_var GetEngine();
+
+ //! Initialize ParaView if not yet done (once per session)
+ static bool ParaviewInitApp(SUIT_Desktop* aDesktop);
+ static void ParaviewInitBehaviors(bool fullSetup=false, SUIT_Desktop* aDesktop=0);
+
+ static void ParaviewCleanup();
+
+ //! Connect to the external PVServer, using the PARAVIS engine to launch it if it is not
+ //! already up.
+ static bool ConnectToExternalPVServer(SUIT_Desktop* aDesktop);
+
+private:
+ static pqPVApplicationCore* MyCoreApp;
+ static PARAVIS_ORB::PARAVIS_Gen_var MyEngine;
+
};
#endif
#include "PVGUI_ViewModel.h"
#include "PVGUI_ViewWindow.h"
-#include "PVGUI_OutputWindowAdapter.h"
-#include "utilities.h"
-#include <SalomeApp_Application.h>
-
-#include <pqPVApplicationCore.h>
-#include <pqTabbedMultiViewWidget.h>
+#include <utilities.h>
+#include <SUIT_Desktop.h>
-//---------- Static init -----------------
-pqPVApplicationCore* PVGUI_Viewer::MyCoreApp = 0;
-PARAVIS_ORB::PARAVIS_Gen_var PVGUI_Viewer::MyEngine;
+#include <SalomeApp_Application.h>
//----------------------------------------
PVGUI_Viewer::PVGUI_Viewer()
:SUIT_ViewModel()
{
- MESSAGE("PVGUI_Viewer: creating view ...");
+ MESSAGE("PVGUI_Viewer: creating view model ...");
}
-pqPVApplicationCore* PVGUI_Viewer::GetPVApplication()
-{
- if(!MyCoreApp)
- pvInit();
- return MyCoreApp;
-}
-
-/*!
- \brief Static method, performs initialization of ParaView session.
- \return \c true if ParaView has been initialized successfully, otherwise false
-*/
-bool PVGUI_Viewer::pvInit()
-{
- // if ( !pqImplementation::Core ){
- if ( ! MyCoreApp) {
- // Obtain command-line arguments
- int argc = 0;
- char** argv = 0;
- QString aOptions = getenv("PARAVIS_OPTIONS");
- QStringList aOptList = aOptions.split(":", QString::SkipEmptyParts);
- argv = new char*[aOptList.size() + 1];
- QStringList args = QApplication::arguments();
- argv[0] = (args.size() > 0)? strdup(args[0].toLatin1().constData()) : strdup("paravis");
- argc++;
-
- foreach (QString aStr, aOptList) {
- argv[argc] = strdup( aStr.toLatin1().constData() );
- argc++;
- }
- MyCoreApp = new pqPVApplicationCore (argc, argv);
- if (MyCoreApp->getOptions()->GetHelpSelected() ||
- MyCoreApp->getOptions()->GetUnknownArgument() ||
- MyCoreApp->getOptions()->GetErrorMessage() ||
- MyCoreApp->getOptions()->GetTellVersion()) {
- return false;
- }
-
- /* VTN: Looks like trash. For porting see branded_paraview_initializer.cxx.in
- // Not sure why this is needed. Andy added this ages ago with comment saying
- // needed for Mac apps. Need to check that it's indeed still required.
- QDir dir(QApplication::applicationDirPath());
- dir.cdUp();
- dir.cd("Plugins");
- QApplication::addLibraryPath(dir.absolutePath());
- // Load required application plugins.
- QString plugin_string = "";
- QStringList plugin_list = plugin_string.split(';',QString::SkipEmptyParts);
- pqBrandPluginsLoader loader;
- if (loader.loadPlugins(plugin_list) == false) {
- printf("Failed to load required plugins for this application\n");
- return false;
- }
-
- // Load optional plugins.
- plugin_string = "";
- plugin_list = plugin_string.split(';',QString::SkipEmptyParts);
- loader.loadPlugins(plugin_list, true); //quietly skip not-found plugins.
- */
- // End of Initializer code
-
- vtkOutputWindow::SetInstance(PVGUI_OutputWindowAdapter::New());
-
- new pqTabbedMultiViewWidget(); // it registers as "MULTIVIEW_WIDGET" on creation
-
- for (int i = 0; i < argc; i++)
- free(argv[i]);
- delete[] argv;
- }
-
- return true;
-}
-
-
-PARAVIS_ORB::PARAVIS_Gen_var PVGUI_Viewer::GetEngine()
-{
- // initialize PARAVIS module engine (load, if necessary)
- if ( CORBA::is_nil( myEngine ) ) {
- Engines::EngineComponent_var comp =
- SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "PARAVIS" );
- myEngine = PARAVIS_ORB::PARAVIS_Gen::_narrow( comp );
- }
- return myEngine;
-}
/*!
Create new instance of view window on desktop \a theDesktop.
return aPVView;
}
-bool PVGUI_Viewer::connectToExternalPVServer()
-{
- pqServer* server = pqActiveObjects::instance().activeServer();
- if (server && server->isRemote())
- {
- // Already connected to an external server, do nothing
- MESSAGE("connectToExternalPVServer(): Already connected to an external PVServer, won't reconnect.");
- return false;
- }
-
- std::stringstream msg;
-
- // Try to connect to the external PVServer - gives priority to an externally specified URL:
- QString serverUrlEnv = getenv("PARAVIS_PVSERVER_URL");
- std::string serverUrl;
- if (!serverUrlEnv.isEmpty())
- serverUrl = serverUrlEnv.toStdString();
- else
- {
- // Get the URL from the engine (possibly starting the pvserver)
- CORBA::String_var url = GetEngine()->FindOrStartPVServer(0); // take the first free port
- serverUrl = (char *)url;
- }
-
- msg << "connectToExternalPVServer(): Trying to connect to the external PVServer '" << serverUrl << "' ...";
- MESSAGE(msg.str());
-
- if (!pqServerConnectReaction::connectToServer(pqServerResource(serverUrl.c_str())))
- {
- std::stringstream msg2;
- msg2 << "Error while connecting to the requested pvserver '" << serverUrl;
- msg2 << "'. Might use default built-in connection instead!" << std::endl;
- qWarning(msg2.str().c_str()); // will go to the ParaView console (see ParavisMessageOutput below)
- SUIT_MessageBox::warning( getApp()->desktop(),
- QString("Error connecting to PVServer"), QString(msg2.str().c_str()));
- return false;
- }
- else
- MESSAGE("connectToExternalPVServer(): Connected!");
- return true;
-}
#define _PVGUI_VIEWMODEL_H
#include <SUIT_ViewModel.h>
-#include CORBA_SERVER_HEADER(PARAVIS_Gen)
class SUIT_ViewWindow;
class SUIT_Desktop;
-class pqPVApplicationCore;
+class SUIT_Desktop;
class PVGUI_Viewer: public SUIT_ViewModel
{
virtual QString getType() const { return Type(); }
static QString Type() { return "ParaView"; }
- pqPVApplicationCore * getPVApplication();
- static PARAVIS_ORB::PARAVIS_Gen_var GetEngine();
-
- //! Initialize ParaView if not yet done (once per session)
- static bool pvInit();
-
- //! Connect to the external PVServer, using the PARAVIS engine to launch it if it is not
- //! already up.
- bool connectToExternalPVServer();
-
-private:
- static pqPVApplicationCore* MyCoreApp;
- static PARAVIS_ORB::PARAVIS_Gen_var MyEngine;
-
};
#endif // !defined(_PVGUI_VIEWMODEL_H)
#
r""" This module is a direct forward to the initial
-'servermanager' module of ParaView.
+'servermanager' module of ParaView. We keep it for backward compatibility only.
"""
-from paraview.servermanager import *
+from paraview import servermanager
-# for name in dir(servermanager):
-# if name != "__file__":
-# globals()[name] = getattr(servermanager, name)
-# del servermanager
-#
+for name in dir(servermanager):
+ if not name.startswith("__"):
+ globals()[name] = getattr(servermanager, name)
+del servermanager
+
is provided by the PARAVIS engine.
"""
-from paraview.simple import *
-import paraview.servermanager # local import - see test on 'fromGUI' below
-import paravis ## Triggers the "FindOrLoadCompo(PARAVIS)"
+import paraview
+import paravis
+
+# Forward namespace of simple into current pvsimple:
+from paraview import simple
+for name in dir(simple):
+ if not name.startswith("__"):
+ globals()[name] = getattr(simple, name)
+del simple
def __my_log(msg):
print "[PARAVIS] %s" % msg
def SalomeConnectToPVServer():
+ """
+ Automatically connect to the right PVServer when not ("inside SALOME GUI" and "already connected").
+ """
__my_log("Connecting to PVServer ...")
server_url = ""
try:
+ isGUIConnected = paravis.myParavisEngine.GetGUIConnected()
+ if isGUIConnected and paraview.fromGUI:
+ __my_log("Importing pvsimple from GUI and already connected. Won't reconnect.")
+ return
server_url = paravis.myParavisEngine.FindOrStartPVServer(0)
# Extract host and port from URL:
a = server_url.split(':')
b = a[1].split('//')
host, port = b[-1], int(a[-1])
Connect(host, port)
+ __my_log("Connected to %s!" % server_url)
except Exception as e:
__my_log("*******************************************")
__my_log("** Could not connect to a running PVServer!")
__my_log("*******************************************")
raise e
- __my_log("Connected to %s!" % server_url)
+ pass
-# Automatically connect to the right PVServer when not inside SALOME GUI:
-if not paraview.fromGUI:
- SalomeConnectToPVServer()
+SalomeConnectToPVServer()