From 179eb0dadfaa1b19d5591513f4b08694eb3c9608 Mon Sep 17 00:00:00 2001 From: abn Date: Thu, 23 Apr 2015 11:58:23 +0200 Subject: [PATCH] Turning PARAVIS into a Light module --- idl/PVSERVER_Gen.idl | 10 - resources/SalomeApp.xml.in | 11 - src/ENGINE/PVSERVER.py | 85 +--- src/ENGINE/PVSERVER_utils.py | 70 --- src/PVGUI/CMakeLists.txt | 15 +- src/PVGUI/PVGUI_DataModel.cxx | 49 +- src/PVGUI/PVGUI_DataModel.h | 4 + src/PVGUI/PVGUI_Module.cxx | 717 ++++++----------------------- src/PVGUI/PVGUI_Module.h | 273 ++++------- src/PVGUI/PVGUI_Module_actions.cxx | 126 +---- src/PVGUI/PVGUI_Module_widgets.cxx | 47 +- src/PVGUI/PVGUI_Tools.cxx | 49 -- src/PVGUI/PVGUI_Tools.h | 39 -- 13 files changed, 312 insertions(+), 1183 deletions(-) delete mode 100644 src/PVGUI/PVGUI_Tools.cxx delete mode 100644 src/PVGUI/PVGUI_Tools.h diff --git a/idl/PVSERVER_Gen.idl b/idl/PVSERVER_Gen.idl index 54911b78..fffe78bc 100644 --- a/idl/PVSERVER_Gen.idl +++ b/idl/PVSERVER_Gen.idl @@ -59,16 +59,6 @@ module PVSERVER_ORB { */ boolean StopPVServer(); - /*! Gets the last trace string pushed by the GUI onto the engine. - */ - string GetPythonTraceString(); - - /*! HACK!! For now ParaView's trace mechanism is implemented in such away that asking the trace - * outside the GUI provides an incomplete script. Hence the GUI regularly pushes to the engine - * the latest status of the trace which is then returned by GetPythonTraceString(). - */ - 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); diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in index 01efa098..e33817d4 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -26,8 +26,6 @@ - -
@@ -36,15 +34,6 @@
-
- - - -
- -
- -
diff --git a/src/ENGINE/PVSERVER.py b/src/ENGINE/PVSERVER.py index 6b906013..46ca5ab1 100644 --- a/src/ENGINE/PVSERVER.py +++ b/src/ENGINE/PVSERVER.py @@ -21,7 +21,6 @@ import PVSERVER_ORB__POA import SALOME_ComponentPy -import SALOME_DriverPy import SALOMEDS import SALOME import PVSERVER_utils @@ -46,7 +45,6 @@ class PVSERVER_Impl: def __init__(self): 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. try: import paraview @@ -133,12 +131,6 @@ class PVSERVER_Impl: return True MESSAGE("[PVSERVER] Nothing to kill.") return False - - def PutPythonTraceStringToEngine( self, t ): - self.lastTrace = t - - def GetPythonTraceString(self): - return self.lastTrace def SetGUIConnected( self, isConnected ): self.isGUIConnected = isConnected @@ -148,20 +140,17 @@ class PVSERVER_Impl: class PVSERVER(PVSERVER_ORB__POA.PVSERVER_Gen, SALOME_ComponentPy.SALOME_ComponentPy_i, - SALOME_DriverPy.SALOME_DriverPy_i, PVSERVER_Impl): """ Construct an instance of PVSERVER module engine. The class PVSERVER implements CORBA interface PVSERVER_Gen (see PVSERVER_Gen.idl). It is inherited from the classes SALOME_ComponentPy_i (implementation of - Engines::EngineComponent CORBA interface - SALOME component) and SALOME_DriverPy_i - (implementation of SALOMEDS::Driver CORBA interface - SALOME module's engine). + Engines::EngineComponent CORBA interface - SALOME component). """ def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ): SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa, contID, containerName, instanceName, interfaceName, 0) - SALOME_DriverPy.SALOME_DriverPy_i.__init__(self, interfaceName) PVSERVER_Impl.__init__(self) # self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb ) @@ -170,7 +159,7 @@ class PVSERVER(PVSERVER_ORB__POA.PVSERVER_Gen, """ Override base class destroy to make sure we try to kill the pvserver before leaving. """ - def destroy(self): + def destroy(self): self.StopPVServer() # Invokes super(): SALOME_ComponentPy.destroy(self) @@ -182,72 +171,8 @@ class PVSERVER(PVSERVER_ORB__POA.PVSERVER_Gen, import salome_version return salome_version.getVersion("PARAVIS", True) - def GetIOR(self): - return PVSERVER_utils.getEngineIOR() - - """ - Create object. """ - def createObject( self, study, name ): - MESSAGE("createObject()") - self._createdNew = True # used for getModifiedData method - builder = study.NewBuilder() - father = findOrCreateComponent( study ) - object = builder.NewObject( father ) - attr = builder.FindOrCreateAttribute( object, "AttributeName" ) - attr.SetValue( name ) - attr = builder.FindOrCreateAttribute( object, "AttributeLocalID" ) - attr.SetValue( PVSERVER_utils.objectID() ) - pass - + Get engine IOR """ - Dump module data to the Python script. - """ - 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): - MESSAGE("importData()") - # get study by Id - obj = self._naming_service.Resolve("myStudyManager") - myStudyManager = obj._narrow(SALOMEDS.StudyManager) - study = myStudyManager.GetStudyByID(studyId) - # create all objects from the imported stream - stream = dataContainer.get() - for objname in stream.split("\n"): - if len(objname) != 0: - self.createObject(study, objname) - self._createdNew = False # to store the modification of the study information later - return ["objects"] # identifier what is in this file - - def getModifiedData(self, studyId): - MESSAGE("getModifiedData()") - if self._createdNew: - # get study by Id - obj = self._naming_service.Resolve("myStudyManager") - myStudyManager = obj._narrow(SALOMEDS.StudyManager) - study = myStudyManager.GetStudyByID(studyId) - # iterate all objects to get their names and store this information in stream - stream="" - father = study.FindComponent( moduleName() ) - if father: - iter = study.NewChildIterator( father ) - while iter.More(): - name = iter.Value().GetName() - stream += name + "\n" - iter.Next() - # store stream to the temporary file to send it in DataContainer - dataContainer = SALOME_DataContainerPy_i(stream, "", "objects", False, True) - aVar = dataContainer._this() - return [aVar] - return [] + def GetIOR(self): + return PVSERVER_utils.getEngineIOR() diff --git a/src/ENGINE/PVSERVER_utils.py b/src/ENGINE/PVSERVER_utils.py index c16e41f3..85f20323 100644 --- a/src/ENGINE/PVSERVER_utils.py +++ b/src/ENGINE/PVSERVER_utils.py @@ -23,11 +23,7 @@ # --- # __all__ = [ - "moduleID", - "objectID", - "unknownID", "moduleName", - "modulePixmap", "verbose", "getORB", "getNS", @@ -35,8 +31,6 @@ __all__ = [ "getStudyManager", "getEngine", "getEngineIOR", - "findOrCreateComponent", - "getObjectID", ] from omniORB import CORBA @@ -47,39 +41,12 @@ import SALOMEDS_Attributes_idl import PVSERVER_ORB import os -### -# Get PVSERVER module's ID -### -def moduleID(): - MODULE_ID = 1000 - return MODULE_ID - -### -# Get PVSERVER object's ID -### -def objectID(): - OBJECT_ID = 1010 - return OBJECT_ID - -### -# Get unknown ID -### -def unknownID(): - FOREIGN_ID = -1 - return FOREIGN_ID - ### # Get PVSERVER module's name ### def moduleName(): return "PVSERVER" -### -# Get module's pixmap name -### -def modulePixmap(): - return "PVSERVER_small.png" - ### # Get verbose level ### @@ -160,40 +127,3 @@ def getEngineIOR(): IOR = getORB().object_to_string( getEngine() ) pass return IOR - -### -# Find or create PVSERVER component object in a study -### -def findOrCreateComponent( study ): - father = study.FindComponent( moduleName() ) - if father is None: - builder = study.NewBuilder() - father = builder.NewComponent( moduleName() ) - attr = builder.FindOrCreateAttribute( father, "AttributeName" ) - attr.SetValue( moduleName() ) - attr = builder.FindOrCreateAttribute( father, "AttributePixMap" ) - attr.SetPixMap( modulePixmap() ) - attr = builder.FindOrCreateAttribute( father, "AttributeLocalID" ) - attr.SetValue( moduleID() ) - try: - builder.DefineComponentInstance( father, getEngine() ) - pass - except: - pass - pass - return father - -### -# Get object's ID -### -def getObjectID( study, entry ): - ID = unknownID() - if study and entry: - sobj = study.FindObjectID( entry ) - if sobj is not None: - test, anAttr = sobj.FindAttribute( "AttributeLocalID" ) - if test: ID = anAttr._narrow( SALOMEDS.AttributeLocalID ).Value() - pass - pass - return ID - diff --git a/src/PVGUI/CMakeLists.txt b/src/PVGUI/CMakeLists.txt index ae428bd9..f38ac615 100644 --- a/src/PVGUI/CMakeLists.txt +++ b/src/PVGUI/CMakeLists.txt @@ -30,7 +30,6 @@ INCLUDE_DIRECTORIES(${OMNIORB_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/view ${CMAKE_CURRENT_BINARY_DIR} ) @@ -48,13 +47,11 @@ SET(_link_LIBRARIES ${OMNIORB_LIBRARIES} ${QT_LIBRARIES} ${PYTHON_LIBS} - ${KERNEL_LDFLAGS} ${KERNEL_SalomeDS} - ${GUI_LDFLAGS} ${GUI_SalomeApp} ${GUI_LightApp} ${GUI_CAM} ${GUI_qtx} ${GUI_suit} + ${KERNEL_LDFLAGS} + ${GUI_LDFLAGS} ${GUI_LightApp} ${GUI_CAM} ${GUI_qtx} ${GUI_suit} ${GUI_SalomeObject} ${GUI_vtkTools} - ${MED_SalomeIDLMED} ${_PARAVIEW_APP_COMPO_LIB} ${GUI_PVViewer} - SalomeIDLPVServer ) # --- headers --- @@ -72,13 +69,8 @@ SET(_moc_HEADERS PVGUI_ParaViewSettingsPane.h ) -# header files / no moc processing -SET(_other_HEADERS - PVGUI_Tools.h -) - # header files / to install -SET(PVGUI_HEADERS ${_moc_HEADERS} ${_other_HEADERS} ${_ui_FORMS_HEADERS}) +SET(PVGUI_HEADERS ${_moc_HEADERS} ${_ui_FORMS_HEADERS}) # --- resources --- @@ -126,7 +118,6 @@ SET(_other_SOURCES PVGUI_Module.cxx PVGUI_Module_actions.cxx PVGUI_Module_widgets.cxx - PVGUI_Tools.cxx PVGUI_ParaViewSettingsPane.cxx PVGUI_DataModel.cxx ) diff --git a/src/PVGUI/PVGUI_DataModel.cxx b/src/PVGUI/PVGUI_DataModel.cxx index 1d90214f..6c563e8d 100644 --- a/src/PVGUI/PVGUI_DataModel.cxx +++ b/src/PVGUI/PVGUI_DataModel.cxx @@ -19,9 +19,15 @@ // Author : Adrien Bruneton (CEA) // +//Local includes #include "PVGUI_DataModel.h" #include "PVGUI_Module.h" +// GUI includes +#include +#include + +// Qt includes #include #include @@ -33,19 +39,27 @@ PVGUI_DataModel::~PVGUI_DataModel() {} bool PVGUI_DataModel::dumpPython( const QString& path, CAM_Study* std, - bool multiFile, QStringList& listOfFiles) + bool isMultiFile, QStringList& listOfFiles) { - QString tmpFile("/tmp/kikou.py"); - listOfFiles.push_back(tmpFile); - QFile file(tmpFile); + + LightApp_Study* study = dynamic_cast( std ); + if(!study) + return false; + + std::string aTmpDir = study->GetTmpDir( path.toLatin1().constData(), isMultiFile ); + std::string aFile = aTmpDir + "paravis_dump.tmp"; + + listOfFiles.append(aTmpDir.c_str()); + listOfFiles.append("paravis_dump.tmp"); + + QFile file(aFile.c_str()); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return false; - //MESSAGE("[PARAVIS] dumpPython()") PVGUI_Module * mod = (PVGUI_Module *) getModule(); QString trace(mod->getTraceString()); - if (multiFile) + if (isMultiFile) { QStringList abuffer; abuffer.push_back(QString("def RebuildData( theStudy ):")); @@ -66,3 +80,26 @@ bool PVGUI_DataModel::dumpPython( const QString& path, CAM_Study* std, return true; } +/*-----------------------------------------------------------------------------------------*/ +bool PVGUI_DataModel::open( const QString& theName, CAM_Study* theStudy, QStringList theList) { + bool res = LightApp_DataModel::open(theName, theStudy, theList); + publishComponent(theStudy); + return res; +} + +/*-----------------------------------------------------------------------------------------*/ +bool PVGUI_DataModel::create( CAM_Study* theStudy) { + bool res = LightApp_DataModel::create(theStudy); + publishComponent(theStudy); + return res; +} +/*-----------------------------------------------------------------------------------------*/ +void PVGUI_DataModel::publishComponent( CAM_Study* theStudy ) { + LightApp_Study* study = dynamic_cast( theStudy ); + CAM_ModuleObject *aModelRoot = dynamic_cast( root()); + if( study && aModelRoot == NULL ) { + aModelRoot = createModuleObject( theStudy->root() ); + aModelRoot->setDataModel( this ); + setRoot(aModelRoot); + } +} diff --git a/src/PVGUI/PVGUI_DataModel.h b/src/PVGUI/PVGUI_DataModel.h index 7bd0f93e..755e0e28 100644 --- a/src/PVGUI/PVGUI_DataModel.h +++ b/src/PVGUI/PVGUI_DataModel.h @@ -40,7 +40,11 @@ public: virtual ~PVGUI_DataModel(); virtual bool dumpPython( const QString&, CAM_Study*, bool, QStringList& ); + virtual bool open( const QString&, CAM_Study*, QStringList ); + virtual bool create( CAM_Study* ); +private: + void publishComponent(CAM_Study*); }; #endif /* PVGUIDATAMODEL_H_ */ diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index 0010354d..a2c63548 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -27,15 +27,12 @@ #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined #endif #include // Python first -#include "PVGUI_Module.h" -#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) -#include CORBA_SERVER_HEADER(SALOMEDS) +#include "PVGUI_Module.h" #include "PVViewer_ViewManager.h" #include "PVViewer_ViewWindow.h" #include "PVViewer_ViewModel.h" -#include "PVGUI_Tools.h" #include "PVGUI_ParaViewSettingsPane.h" #include "PVViewer_GUIElements.h" #include "PVViewer_EngineWrapper.h" @@ -51,18 +48,11 @@ #include #include -#include -#include - #include #include #include -#include // should ultimately be a LightApp only -#include +#include #include -#include -#include -#include #include #include @@ -105,6 +95,7 @@ #include #include #include +#include #include #include @@ -135,7 +126,6 @@ //---------------------------------------------------------------------------- PVGUI_Module* ParavisModule = 0; -PVSERVER_ORB::PVSERVER_Gen_var PVGUI_Module::MyEngine; /*! \mainpage @@ -154,46 +144,6 @@ PVSERVER_ORB::PVSERVER_Gen_var PVGUI_Module::MyEngine; SALOME module wrapping ParaView GUI. */ -_PTR(SComponent) -ClientFindOrCreateParavisComponent(_PTR(Study) theStudyDocument) -{ - _PTR(SComponent) aSComponent = theStudyDocument->FindComponent("PVSERVER"); - if (!aSComponent) { - _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); - aStudyBuilder->NewCommand(); - int aLocked = theStudyDocument->GetProperties()->IsLocked(); - if (aLocked) theStudyDocument->GetProperties()->SetLocked(false); - aSComponent = aStudyBuilder->NewComponent("PVSERVER"); - _PTR(GenericAttribute) anAttr = - aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName"); - _PTR(AttributeName) aName (anAttr); - - ORB_INIT& init = *SINGLETON_::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( "PVSERVER" ); - 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::GetCPPEngine()->GetIOR()); - if (aLocked) theStudyDocument->GetProperties()->SetLocked(true); - aStudyBuilder->CommitCommand(); - } - return aSComponent; -} - /*! \brief Clean up function @@ -212,18 +162,14 @@ void paravisCleanUp() \brief Constructor. Sets the default name for the module. */ PVGUI_Module::PVGUI_Module() - : SalomeApp_Module( PARAVIS_MODULE_NAME ), - mySelectionControlsTb( -1 ), + : LightApp_Module( PARAVIS_MODULE_NAME ), mySourcesMenuId( -1 ), myFiltersMenuId( -1 ), myMacrosMenuId(-1), - myToolbarsMenuId(-1), myRecentMenuId(-1), myOldMsgHandler(0), myTraceWindow(0), - myStateCounter(0), myInitTimer(0), - myPushTraceTimer(0), myGuiElements(0) { #ifdef HAS_PV_DOC @@ -251,40 +197,21 @@ PVGUI_Module::PVGUI_Module() */ PVGUI_Module::~PVGUI_Module() { - if (myPushTraceTimer) - delete myPushTraceTimer; if (myInitTimer) delete myInitTimer; } /*! - * \brief Retrieve the PVSERVER CORBA engine. - * This uses the Python wrapper provided - * by the PVViewer code in GUI (class PVViewer_EngineWrapper). - * \sa GetCPPEngine() - */ -PVViewer_EngineWrapper * PVGUI_Module::GetEngine() + \brief Retrieve the PVSERVER CORBA engine. + This uses the Python wrapper provided + by the PVViewer code in GUI (class PVViewer_EngineWrapper). + \sa GetCPPEngine() +*/ +PVViewer_EngineWrapper* PVGUI_Module::GetEngine() { return PVViewer_EngineWrapper::GetInstance(); } -/*! - * \brief Retrieve the PVSERVER CORBA engine. - * Uses directly the standard Salome C++ mechanisms - * (LifeCycleCorba). - * \sa GetEngine() - */ -PVSERVER_ORB::PVSERVER_Gen_var PVGUI_Module::GetCPPEngine() -{ - // initialize PARAVIS module engine (load, if necessary) - if ( CORBA::is_nil( MyEngine ) ) { - Engines::EngineComponent_var comp = - SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "PVSERVER" ); - MyEngine = PVSERVER_ORB::PVSERVER_Gen::_narrow( comp ); - } - return MyEngine; -} - /*! \brief Create data model. \return module specific data model @@ -295,9 +222,9 @@ CAM_DataModel* PVGUI_Module::createDataModel() } /*! - * \brief Get the ParaView application singleton. - */ -pqPVApplicationCore * PVGUI_Module::GetPVApplication() + \brief Get the ParaView application singleton. +*/ +pqPVApplicationCore* PVGUI_Module::GetPVApplication() { return PVViewer_ViewManager::GetPVApplication(); } @@ -310,9 +237,6 @@ void PVGUI_Module::initialize( CAM_Application* app ) { LightApp_Module::initialize( app ); - createActions(); - createMenus(); - // Uncomment to debug ParaView initialization // "aa" used instead of "i" as GDB doesn't like "i" variables :) /* @@ -418,12 +342,6 @@ void PVGUI_Module::initialize( CAM_Application* app ) QObject::connect(myInitTimer, SIGNAL(timeout()), this, SLOT(onInitTimer()) ); myInitTimer->setSingleShot(true); myInitTimer->start(0); - - // Another timer to regularly push the trace onto the engine: - myPushTraceTimer = new QTimer(aDesktop); - QObject::connect(myPushTraceTimer, SIGNAL(timeout()), this, SLOT(onPushTraceTimer()) ); - myPushTraceTimer->setSingleShot(false); - myPushTraceTimer->start(500); } this->VTKConnect = vtkEventQtSlotConnect::New(); @@ -466,7 +384,7 @@ void PVGUI_Module::onEndProgress() } void PVGUI_Module::onDataRepresentationUpdated() { - SalomeApp_Study* activeStudy = dynamic_cast(application()->activeStudy()); + LightApp_Study* activeStudy = dynamic_cast(application()->activeStudy()); if(!activeStudy) return; activeStudy->Modified(); @@ -534,6 +452,9 @@ void PVGUI_Module::windows( QMap& m ) const */ void PVGUI_Module::showView( bool toShow ) { + // VSR: TODO: all below is not needed, if we use standard approach + // that consists in implementing viewManagers() function properly + // This should be done after we decide what to do with Log window. LightApp_Application* anApp = getApp(); PVViewer_ViewManager* viewMgr = dynamic_cast( anApp->getViewManager( PVViewer_Viewer::Type(), false ) ); @@ -562,7 +483,6 @@ void PVGUI_Module::showHelpForProxy( const QString& groupname, const QString& pr pqHelpReaction::showProxyHelp(groupname, proxyname); } - /*! \brief Slot to show the waiting state. */ @@ -632,7 +552,6 @@ bool PVGUI_Module::activateModule( SUIT_Study* study ) if ( mySourcesMenuId != -1 ) menuMgr()->show(mySourcesMenuId); if ( myFiltersMenuId != -1 ) menuMgr()->show(myFiltersMenuId); if ( myMacrosMenuId != -1 ) menuMgr()->show(myMacrosMenuId); - if ( myToolbarsMenuId != -1 ) menuMgr()->show(myToolbarsMenuId); // Update the various menus with the content pre-loaded in myGuiElements // QMenu* srcMenu = menuMgr()->findMenu( mySourcesMenuId ); @@ -665,9 +584,7 @@ bool PVGUI_Module::activateModule( SUIT_Study* study ) } if ( myRecentMenuId != -1 ) menuMgr()->show(myRecentMenuId); - - ClientFindOrCreateParavisComponent(PARAVIS::GetCStudy(this)); - + return isDone; } @@ -713,7 +630,6 @@ bool PVGUI_Module::deactivateModule( SUIT_Study* study ) menuMgr()->hide(mySourcesMenuId); menuMgr()->hide(myFiltersMenuId); menuMgr()->hide(myMacrosMenuId); - menuMgr()->hide(myToolbarsMenuId); setMenuShown( false ); setToolShown( false ); @@ -741,28 +657,9 @@ bool PVGUI_Module::deactivateModule( SUIT_Study* study ) void PVGUI_Module::onApplicationClosed( SUIT_Application* theApp ) { PVViewer_ViewManager::ParaviewCleanup(); - - int aAppsNb = SUIT_Session::session()->applications().size(); - if (aAppsNb == 1) { - deleteTemporaryFiles(); - } CAM_Module::onApplicationClosed(theApp); } - -/*! - \brief Deletes temporary files created during import operation from VISU -*/ -void PVGUI_Module::deleteTemporaryFiles() -{ - foreach(QString aFile, myTemporaryFiles) { - if (QFile::exists(aFile)) { - QFile::remove(aFile); - } - } -} - - /*! \brief Called when study is closed. @@ -772,110 +669,71 @@ void PVGUI_Module::deleteTemporaryFiles() */ void PVGUI_Module::studyClosed(SUIT_Study* study) { - showView(false); + showView(false); // VSR: this seems to be not needed (all views are automatically closed) clearParaviewState(); + //Re-start trace + onRestartTrace(); LightApp_Module::studyClosed(study); } -/*! - \brief Called when study is opened. -*/ -void PVGUI_Module::onModelOpened() -{ - _PTR(Study) studyDS = PARAVIS::GetCStudy(this); - if(!studyDS) { - return; - } - - _PTR(SComponent) paravisComp = - studyDS->FindComponent(PARAVIS_MODULE_NAME); - if(!paravisComp) { - return; - } - - _PTR(ChildIterator) anIter(studyDS->NewChildIterator(paravisComp)); - for (; anIter->More(); anIter->Next()) { - _PTR(SObject) aSObj = anIter->Value(); - _PTR(GenericAttribute) anAttr; - if (!aSObj->FindAttribute(anAttr, "AttributeLocalID")) { - continue; - } - _PTR(AttributeLocalID) anID(anAttr); - if (anID->Value() == PVSTATEID) { - myStateCounter++; - } - } -} - -/*! -\brief Returns IOR of current engine -*/ -QString PVGUI_Module::engineIOR() const -{ - CORBA::String_var anIOR = GetCPPEngine()->GetIOR(); - return QString(anIOR.in()); -} - /*! \brief Open file of format supported by ParaView */ -void PVGUI_Module::openFile(const char* theName) +void PVGUI_Module::openFile( const char* theName ) { QStringList aFiles; - aFiles<proxyManager(); vtkSmartPointer proxy; - proxy.TakeReference(pxm->NewProxy("pythontracing", "PythonTraceOptions")); - if (proxy) - { - vtkNew controller; - controller->InitializeProxy(proxy); - } + proxy.TakeReference( pxm->NewProxy( "pythontracing", "PythonTraceOptions" ) ); + if ( proxy ) { + vtkNew controller; + controller->InitializeProxy( proxy ); + } vtkSMTrace* trace = vtkSMTrace::StartTrace(); - if (proxy) - { - // Set manually the properties entered via the dialog box poping-up when requiring - // a trace start in PV4.2 (trace options) - trace->SetPropertiesToTraceOnCreate(vtkSMTrace::RECORD_USER_MODIFIED_PROPERTIES); - trace->SetFullyTraceSupplementalProxies(false); - } + if ( proxy ) { + // Set manually the properties entered via the dialog box poping-up when requiring + // a trace start in PV4.2 (trace options) + trace->SetPropertiesToTraceOnCreate( vtkSMTrace::RECORD_USER_MODIFIED_PROPERTIES ); + trace->SetFullyTraceSupplementalProxies( false ); + } } -/**! - * \brief Stops Python trace. - */ +/*! + \brief Stops Python trace. +*/ void PVGUI_Module::stopTrace() { vtkSMTrace::StopTrace(); } -/**! - * \brief Execute a Python script. - */ -void PVGUI_Module::executeScript(const char *script) +/*! + \brief Execute a Python script. +*/ +void PVGUI_Module::executeScript( const char* script ) { #ifndef WNT pqPythonManager* manager = qobject_cast( - pqApplicationCore::instance()->manager("PYTHON_MANAGER")); - if (manager) { + pqApplicationCore::instance()->manager( "PYTHON_MANAGER" ) ); + if ( manager ) { pqPythonDialog* pyDiag = manager->pythonShellDialog(); - if (pyDiag) { + if ( pyDiag ) { pyDiag->runString(script); - } } + } #endif } @@ -905,44 +763,67 @@ void PVGUI_Module::executeScript(const char *script) /*! \brief Returns trace string */ -static const QString MYReplaceStr("paraview.simple"); QString PVGUI_Module::getTraceString() { - vtkSMTrace *tracer = vtkSMTrace::GetActiveTracer(); - if (!tracer) // trace is not started - return QString(""); - - QString traceString(tracer->GetCurrentTrace()); - std::stringstream nl; nl << std::endl; // surely there is some Qt trick to do that in a portable way?? - QString end_line(nl.str().c_str()); - // 'import pvsimple' is necessary to fix the first call to DisableFirstRenderCamera in the paraview trace - // 'ShowParaviewView()' ensure there is an opened viewing window (otherwise SEGFAULT!) - traceString = "import pvsimple" + end_line + - "pvsimple.ShowParaviewView()" + end_line + traceString; - - // Replace import "paraview.simple" by "pvsimple" - if ((!traceString.isNull()) && traceString.length() != 0) { - int aPos = traceString.indexOf(MYReplaceStr); - while (aPos != -1) { - traceString = traceString.replace(aPos, MYReplaceStr.length(), "pvsimple"); - aPos = traceString.indexOf(MYReplaceStr, aPos); + QString traceString = ""; + + static const QString replaceStr( "paraview.simple" ); + std::stringstream nl; + nl << std::endl; // surely there is some Qt trick to do that in a portable way?? + QString end_line( nl.str().c_str() ); + + vtkSMTrace* tracer = vtkSMTrace::GetActiveTracer(); + if ( tracer ) { + traceString = tracer->GetCurrentTrace(); + // 'import pvsimple' is necessary to fix the first call to DisableFirstRenderCamera in the paraview trace + // 'ShowParaviewView()' ensure there is an opened viewing window (otherwise SEGFAULT!) + traceString = "import pvsimple" + end_line + + "pvsimple.ShowParaviewView()" + end_line + traceString; + + // Replace import "paraview.simple" by "pvsimple" + if ( !traceString.isEmpty() ) { + int aPos = traceString.indexOf( replaceStr ); + while ( aPos != -1 ) { + traceString = traceString.replace( aPos, replaceStr.length(), "pvsimple" ); + aPos = traceString.indexOf( replaceStr, aPos ); + } } } + // Save camera position to, which is no longer output by the tracer ... + VTK_PY_GIL_ENSURE + PyObject * mods(PySys_GetObject(const_cast("modules"))); + PyObject * trace_mod(PyDict_GetItemString(mods, "paraview.smtrace")); // module was already (really) imported by vtkSMTrace + if (PyModule_Check(trace_mod)) { + vtkSmartPyObject save_cam(PyObject_GetAttrString(trace_mod, const_cast("SaveCameras"))); + vtkSmartPyObject camera_trace(PyObject_CallMethod(save_cam, const_cast("get_trace"), NULL)); + // Convert to a single string + vtkSmartPyObject ret(PyString_FromString(end_line.toStdString().c_str())); + vtkSmartPyObject final_string(PyObject_CallMethod(ret, const_cast("join"), + const_cast("O"), (PyObject*)camera_trace)); + if (PyString_CheckExact(final_string)) + { + QString camera_qs(PyString_AsString(final_string)); // deep copy + traceString = traceString + end_line + end_line + QString("#### saving camera placements for all active views") + + end_line + end_line + camera_qs + end_line; + } + } + VTK_PY_GIL_RELEASE + return traceString; } /*! \brief Saves trace string to disk file */ -void PVGUI_Module::saveTrace(const char* theName) +void PVGUI_Module::saveTrace( const char* theName ) { - QFile file(theName); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + QFile file( theName ); + if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) ) { MESSAGE( "Could not open file:" << theName ); return; } - QTextStream out(&file); + QTextStream out( &file ); out << getTraceString(); file.close(); } @@ -950,9 +831,9 @@ void PVGUI_Module::saveTrace(const char* theName) /*! \brief Saves ParaView state to a disk file */ -void PVGUI_Module::saveParaviewState(const char* theFileName) +void PVGUI_Module::saveParaviewState( const char* theFileName ) { - pqApplicationCore::instance()->saveState(theFileName); + pqApplicationCore::instance()->saveState( theFileName ); } /*! @@ -960,20 +841,18 @@ void PVGUI_Module::saveParaviewState(const char* theFileName) */ void PVGUI_Module::clearParaviewState() { - QAction* deleteAllAction = action(DeleteAllId); - if (deleteAllAction) { - deleteAllAction->activate(QAction::Trigger); + QAction* deleteAllAction = action( DeleteAllId ); + if ( deleteAllAction ) { + deleteAllAction->activate( QAction::Trigger ); } } /*! \brief Restores ParaView state from a disk file - - If toClear == true, the current ojects will be deleted */ -void PVGUI_Module::loadParaviewState(const char* theFileName) +void PVGUI_Module::loadParaviewState( const char* theFileName ) { - pqApplicationCore::instance()->loadState(theFileName, getActiveServer()); + pqApplicationCore::instance()->loadState( theFileName, getActiveServer() ); } /*! @@ -994,97 +873,30 @@ void PVGUI_Module::createPreferences() int aParaViewSettingsTab = addPreference( tr( "TIT_PVIEWSETTINGS" ) ); setPreferenceProperty(aParaViewSettingsTab, "stretch", false ); - int aPanel = addPreference(QString(), aParaViewSettingsTab, LightApp_Preferences::UserDefined, PARAVIS_MODULE_NAME, ""); + int aPanel = addPreference( QString(), aParaViewSettingsTab, + LightApp_Preferences::UserDefined, PARAVIS_MODULE_NAME, "" ); - setPreferenceProperty(aPanel, "content", (qint64)(new PVGUI_ParaViewSettingsPane(0, getApp()))); + setPreferenceProperty( aPanel, "content", (qint64)( new PVGUI_ParaViewSettingsPane( 0, getApp() ) ) ); // Paravis settings tab int aParaVisSettingsTab = addPreference( tr( "TIT_PVISSETTINGS" ) ); - addPreference( tr( "PREF_STOP_TRACE" ), aParaVisSettingsTab, LightApp_Preferences::Bool, PARAVIS_MODULE_NAME, "stop_trace"); + addPreference( tr( "PREF_STOP_TRACE" ), aParaVisSettingsTab, + LightApp_Preferences::Bool, PARAVIS_MODULE_NAME, "stop_trace" ); - addPreference( tr( "PREF_NO_EXT_PVSERVER" ), aParaVisSettingsTab, LightApp_Preferences::Bool, PARAVIS_MODULE_NAME, "no_ext_pv_server"); + addPreference( tr( "PREF_NO_EXT_PVSERVER" ), aParaVisSettingsTab, + LightApp_Preferences::Bool, PARAVIS_MODULE_NAME, "no_ext_pv_server" ); - int aSaveType = addPreference(tr( "PREF_SAVE_TYPE_LBL" ), aParaVisSettingsTab, - LightApp_Preferences::Selector, - PARAVIS_MODULE_NAME, "savestate_type"); + int aSaveType = addPreference( tr( "PREF_SAVE_TYPE_LBL" ), aParaVisSettingsTab, + LightApp_Preferences::Selector, + PARAVIS_MODULE_NAME, "savestate_type" ); QList aIndices; QStringList aStrings; - aIndices<<0<<1<<2; - aStrings<objectBrowser(); - bool isOBClient = (ob && theClient == ob->popupClientType()); - if (!isOBClient) { - return; - } - - // Get list of selected objects - LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr(); - SALOME_ListIO aListIO; - aSelectionMgr->selectedObjects(aListIO); - if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) { - QString entry = QString(aListIO.First()->getEntry()); - - // Get active study - SalomeApp_Study* activeStudy = - dynamic_cast(getApp()->activeStudy()); - if(!activeStudy) { - return; - } - - // Get SALOMEDS client study - _PTR(Study) studyDS = activeStudy->studyDS(); - if(!studyDS) { - return; - } - - QString paravisDataType(PARAVIS_MODULE_NAME); - if(activeStudy && activeStudy->isComponent(entry) && - activeStudy->componentDataType(entry) == paravisDataType) { - // ParaViS module object - theMenu->addSeparator(); - theMenu->addAction(action(SaveStatePopupId)); - } - else { - // Try to get state object - _PTR(SObject) stateSObj = - studyDS->FindObjectID(entry.toLatin1().constData()); - if (!stateSObj) { - return; - } - - // Check local id - _PTR(GenericAttribute) anAttr; - if (!stateSObj->FindAttribute(anAttr, "AttributeLocalID")) { - return; - } - - _PTR(AttributeLocalID) anID(anAttr); - - if (anID->Value() == PVSTATEID) { - // Paraview state object - theMenu->addSeparator(); - theMenu->addAction(action(AddStatePopupId)); - theMenu->addAction(action(CleanAndAddStatePopupId)); - theMenu->addSeparator(); - theMenu->addAction(action(ParaVisRenameId)); - theMenu->addAction(action(ParaVisDeleteId)); - } - } - } + aIndices << 0 << 1 << 2; + aStrings << tr("PREF_SAVE_TYPE_0"); + aStrings << tr("PREF_SAVE_TYPE_1"); + aStrings << tr("PREF_SAVE_TYPE_2"); + setPreferenceProperty( aSaveType, "strings", aStrings ); + setPreferenceProperty( aSaveType, "indexes", aIndices ); } /*! @@ -1112,294 +924,43 @@ void PVGUI_Module::onRestartTrace() } /*! - \brief Save state under the module root object. + \brief Called when view manager is added */ -void PVGUI_Module::onSaveMultiState() -{ - // Create state study object - - // Get SALOMEDS client study - _PTR(Study) studyDS = PARAVIS::GetCStudy(this); - if(!studyDS) { - return; - } - - _PTR(SComponent) paravisComp = - studyDS->FindComponent(PARAVIS_MODULE_NAME); - if(!paravisComp) { - return; - } - - // Unlock the study if it is locked - bool isLocked = studyDS->GetProperties()->IsLocked(); - if (isLocked) { - studyDS->GetProperties()->SetLocked(false); - } - - QString stateName = tr("SAVED_PARAVIEW_STATE_NAME") + - QString::number(myStateCounter + 1); - - _PTR(StudyBuilder) studyBuilder = studyDS->NewBuilder(); - _PTR(SObject) newSObj = studyBuilder->NewObject(paravisComp); - - // Set name - _PTR(GenericAttribute) anAttr; - anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeName"); - _PTR(AttributeName) nameAttr(anAttr); - - nameAttr->SetValue(stateName.toLatin1().constData()); - - // Set local id - anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeLocalID"); - _PTR(AttributeLocalID) localIdAttr(anAttr); - - localIdAttr->SetValue(PVSTATEID); - - // Set file name - QString stateEntry = QString::fromStdString(newSObj->GetID()); - - // File name for state saving - QString tmpDir = QString::fromStdString(SALOMEDS_Tool::GetTmpDir()); - QString fileName = QString("%1_paravisstate:%2").arg(tmpDir, stateEntry); - - anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeString"); - _PTR(AttributeString) stringAttr(anAttr); - - stringAttr->SetValue(fileName.toLatin1().constData()); - - // Lock the study back if necessary - if (isLocked) { - studyDS->GetProperties()->SetLocked(true); - } - - // Save state - saveParaviewState(fileName.toLatin1().constData()); - myTemporaryFiles.append(fileName); - - // Increment the counter - myStateCounter++; - - updateObjBrowser(); -} - -/*! - \brief Restore the selected state by merging with the current one. -*/ -void PVGUI_Module::onAddState() -{ - loadSelectedState(false); -} - -/*! - \brief Clean the current state and restore the selected one. -*/ -void PVGUI_Module::onCleanAddState() -{ - loadSelectedState(true); -} - -/*! - \brief Rename the selected object. -*/ -void PVGUI_Module::onRename() -{ - LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr(); - SALOME_ListIO aListIO; - aSelectionMgr->selectedObjects(aListIO); - - if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) { - std::string entry = aListIO.First()->getEntry(); - - // Get SALOMEDS client study - _PTR(Study) studyDS = PARAVIS::GetCStudy(this); - if(!studyDS) { - return; - } - - // Unlock the study if it is locked - bool isLocked = studyDS->GetProperties()->IsLocked(); - if (isLocked) { - studyDS->GetProperties()->SetLocked(false); - } - - // Rename the selected state object - _PTR(SObject) stateSObj = studyDS->FindObjectID(entry); - if (!stateSObj) { - return; - } - - _PTR(GenericAttribute) anAttr; - if (stateSObj->FindAttribute(anAttr, "AttributeName")) { - _PTR(AttributeName) nameAttr (anAttr); - QString newName = - LightApp_NameDlg::getName(getApp()->desktop(), nameAttr->Value().c_str()); - if (!newName.isEmpty()) { - nameAttr->SetValue(newName.toLatin1().constData()); - aListIO.First()->setName(newName.toLatin1().constData()); - } - } - - // Lock the study back if necessary - if (isLocked) { - studyDS->GetProperties()->SetLocked(true); - } - - // Update object browser - updateObjBrowser(); - - } -} - -/*! - \brief Delete the selected objects. -*/ -void PVGUI_Module::onDelete() -{ - LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr(); - SALOME_ListIO aListIO; - aSelectionMgr->selectedObjects(aListIO); - - if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) { - std::string entry = aListIO.First()->getEntry(); - - // Get SALOMEDS client study - _PTR(Study) studyDS = PARAVIS::GetCStudy(this); - if(!studyDS) { - return; - } - - // Unlock the study if it is locked - bool isLocked = studyDS->GetProperties()->IsLocked(); - if (isLocked) { - studyDS->GetProperties()->SetLocked(false); - } - - // Remove the selected state from the study - _PTR(StudyBuilder) studyBuilder = studyDS->NewBuilder(); - _PTR(SObject) stateSObj = studyDS->FindObjectID(entry); - studyBuilder->RemoveObject(stateSObj); - - // Lock the study back if necessary - if (isLocked) { - studyDS->GetProperties()->SetLocked(true); - } - - // Update object browser - updateObjBrowser(); - } -} - -/*! - * \brief Slot called everytime the Python trace is pushed onto the CORBA engine. - */ -void PVGUI_Module::onPushTraceTimer() +void PVGUI_Module::onViewManagerAdded( SUIT_ViewManager* vm ) { - //MESSAGE("onPushTraceTimer(): Pushing trace to engine..."); - GetEngine()->PutPythonTraceStringToEngine(getTraceString().toStdString().c_str()); -} - -/*! - \brief Discover help project files from the resources. - \return name of the help file. -*/ -QString PVGUI_Module::getHelpFileName() { - QString aPVHome(getenv("PVHOME")); - if (aPVHome.isNull()) { - qWarning("Variable PVHOME is not defined"); - return QString(); + if ( PVViewer_ViewManager* pvvm = dynamic_cast( vm ) ) { + connect( pvvm, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), + this, SLOT( onPVViewCreated( SUIT_ViewWindow* ) ) ); + connect( pvvm, SIGNAL( deleteView( SUIT_ViewWindow* ) ), + this, SLOT( onPVViewDelete( SUIT_ViewWindow* ) ) ); } - QChar aSep = QDir::separator(); - //PARAVIEW_VERSION from the vtkPVConfig.h file - QString aFileName = aPVHome + aSep + "share" + aSep + "doc" + aSep + "paraview-"+ PARAVIEW_VERSION + aSep + "paraview.qch"; - return aFileName; } - /*! - \brief Load selected paraview state - - If toClear == true, the current state will be cleared + \brief Called when view manager is removed */ -void PVGUI_Module::loadSelectedState(bool toClear) -{ - QString fileName; - - LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr(); - SALOME_ListIO aListIO; - aSelectionMgr->selectedObjects(aListIO); - - if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) { - std::string entry = aListIO.First()->getEntry(); - - // Get SALOMEDS client study - _PTR(Study) studyDS = PARAVIS::GetCStudy(this); - if(!studyDS) { - return; - } - - // Check local id - _PTR(SObject) stateSObj = studyDS->FindObjectID(entry); - _PTR(GenericAttribute) anAttr; - if (!stateSObj->FindAttribute(anAttr, "AttributeLocalID")) { - return; - } - _PTR(AttributeLocalID) anID(anAttr); - if (!anID->Value() == PVSTATEID) { - return; - } - - // Get state file name - if (stateSObj->FindAttribute(anAttr, "AttributeString")) { - _PTR(AttributeString) aStringAttr(anAttr); - QString stringValue(aStringAttr->Value().c_str()); - - if (QFile::exists(stringValue)) { - fileName = stringValue; - } - } - } - - if (!fileName.isEmpty()) { - if (toClear) { - clearParaviewState(); - } - - loadParaviewState(fileName.toLatin1().constData()); - } - else { - SUIT_MessageBox::critical(getApp()->desktop(), - tr("ERR_ERROR"), - tr("ERR_STATE_CANNOT_BE_RESTORED")); - } -} - -void PVGUI_Module::onViewManagerAdded( SUIT_ViewManager* vm ) -{ - if (PVViewer_ViewManager* pvvm = dynamic_cast(vm)) { - connect(pvvm, SIGNAL(viewCreated(SUIT_ViewWindow*)), this, SLOT(onPVViewCreated(SUIT_ViewWindow*))); - connect(pvvm, SIGNAL(deleteView(SUIT_ViewWindow*)), this, SLOT(onPVViewDelete(SUIT_ViewWindow*))); - } -} - void PVGUI_Module::onViewManagerRemoved( SUIT_ViewManager* vm ) { - if (PVViewer_ViewManager* pvvm = dynamic_cast(vm)) - disconnect(pvvm, SIGNAL(viewCreated(SUIT_ViewWindow*)), this, SLOT(onPVViewCreated(SUIT_ViewWindow*))); + if ( PVViewer_ViewManager* pvvm = dynamic_cast( vm ) ) + disconnect( pvvm, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), + this, SLOT( onPVViewCreated( SUIT_ViewWindow* ) ) ); } -/*!Show toolbars at \a vw PV view window creating when PARAVIS is active. +/*! + \brief Show toolbars at \a vw PV view window creating when PARAVIS is active. */ void PVGUI_Module::onPVViewCreated( SUIT_ViewWindow* vw ) { - myGuiElements->setToolBarVisible(true); + myGuiElements->setToolBarVisible( true ); restoreDockWidgetsState(); } -/*!Save toolbars state at \a view view closing. +/*! + \brief Save toolbars state at \a view view closing. */ -void PVGUI_Module::onPVViewDelete(SUIT_ViewWindow* view) +void PVGUI_Module::onPVViewDelete( SUIT_ViewWindow* view ) { - if (dynamic_cast(view)) + if ( dynamic_cast( view ) ) saveDockWidgetsState( false ); } diff --git a/src/PVGUI/PVGUI_Module.h b/src/PVGUI/PVGUI_Module.h index 64340d5f..fec72619 100644 --- a/src/PVGUI/PVGUI_Module.h +++ b/src/PVGUI/PVGUI_Module.h @@ -26,193 +26,141 @@ #ifndef PVGUI_Module_H #define PVGUI_Module_H -#include -#include -#include CORBA_SERVER_HEADER(PVSERVER_Gen) - -#include -#include -#include - -#include +#include class QMenu; -class QDockWidget; -class QToolBar; -class vtkPVMain; -class pqOptions; -class pqServer; -class pqMainWindowCore; +class QTimer; class vtkEventQtSlotConnect; +class pqServer; class pqPythonScriptEditor; class pqPVApplicationCore; -class pqDataRepresentation; -class pqRepresentation; class PVViewer_GUIElements; class PVViewer_EngineWrapper; class SUIT_ViewWindow; -class PVGUI_Module : public SalomeApp_Module +class PVGUI_Module: public LightApp_Module { Q_OBJECT //! Menu actions - enum { // Menu "File" - OpenFileId, - - LoadStateId, - SaveStateId, - - SaveDataId, - SaveScreenshotId, - ExportId, - - SaveAnimationId, - SaveGeometryId, - - ConnectId, - DisconnectId, - - // Menu "Edit" - UndoId, - RedoId, - - CameraUndoId, - CameraRedoId, - - FindDataId, - ChangeInputId, - IgnoreTimeId, - DeleteId, - DeleteAllId, - - SettingsId, - ViewSettingsId, - - // Menu "View" - FullScreenId, - - // Menu "Animation" - FirstFrameId, - PreviousFrameId, - PlayId, - NextFrameId, - LastFrameId, - LoopId, - - // Menu "Tools" - CreateCustomFilterId, - ManageCustomFiltersId, - CreateLookmarkId, - ManageLinksId, - AddCameraLinkId, - ManagePluginsExtensionsId, - DumpWidgetNamesId, - RecordTestId, - RecordTestScreenshotId, - PlayTestId, - MaxWindowSizeId, - CustomWindowSizeId, - TimerLogId, - OutputWindowId, - PythonShellId, - ShowTraceId, - RestartTraceId, - - // Menu "Help" - AboutParaViewId, - ParaViewHelpId, - EnableTooltipsId, - - // Menu "Window" - "New Window" - ParaViewNewWindowId, - - // "Save state" ParaVis module root object popup - SaveStatePopupId, - - // "Add state" and "Reload state" popups - AddStatePopupId, - CleanAndAddStatePopupId, - - // "Rename" and "Delete" popups (Object Browser) - ParaVisRenameId, - ParaVisDeleteId + enum { + //----------- + // Menu "File" + OpenFileId, + //- + LoadStateId, + SaveStateId, + //- + SaveDataId, + SaveScreenshotId, + ExportId, + //- + SaveAnimationId, + SaveGeometryId, + //- + ConnectId, + DisconnectId, + //----------- + // Menu "Edit" + UndoId, + RedoId, + //- + CameraUndoId, + CameraRedoId, + //- + FindDataId, + ChangeInputId, + IgnoreTimeId, + DeleteId, + DeleteAllId, + //- + SettingsId, // not used + ViewSettingsId, // not used + //----------- + // Menu "View" + FullScreenId, // not used + //----------- + // Menu "Animation" + FirstFrameId, // not used + PreviousFrameId, // not used + PlayId, // not used + NextFrameId, // not used + LastFrameId, // not used + LoopId, // not used + //----------- + // Menu "Tools" + CreateCustomFilterId, + ManageCustomFiltersId, + CreateLookmarkId, // not used + ManageLinksId, + AddCameraLinkId, + ManagePluginsExtensionsId, + DumpWidgetNamesId, // not used + RecordTestId, + RecordTestScreenshotId, // not used + PlayTestId, + MaxWindowSizeId, + CustomWindowSizeId, + TimerLogId, + OutputWindowId, + PythonShellId, + ShowTraceId, + RestartTraceId, + //----------- + // Menu "Help" + AboutParaViewId, + ParaViewHelpId, + EnableTooltipsId, // not used }; public: PVGUI_Module(); ~PVGUI_Module(); - virtual void initialize( CAM_Application* ); - virtual void windows( QMap& ) const; - - virtual QString engineIOR() const; // to be removed when becoming Light + virtual void initialize( CAM_Application* ); + virtual void windows( QMap& ) const; - void openFile(const char* theName); - void executeScript(const char *script); - void saveParaviewState(const char* theFileName); - void loadParaviewState(const char* theFileName); + void openFile( const char* ); // not used inside PARAVIS + void executeScript( const char* ); // not used inside PARAVIS + void saveParaviewState( const char* ); // not used inside PARAVIS + void loadParaviewState( const char* ); // not used inside PARAVIS void clearParaviewState(); QString getTraceString(); void startTrace(); void stopTrace(); - void saveTrace(const char* theName); + void saveTrace( const char* ); pqServer* getActiveServer(); virtual void createPreferences(); - virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle); - - inline static PVViewer_EngineWrapper * GetEngine(); - inline static PVSERVER_ORB::PVSERVER_Gen_var GetCPPEngine(); // to be removed once light! - inline static pqPVApplicationCore * GetPVApplication(); + inline static PVViewer_EngineWrapper* GetEngine(); + inline static pqPVApplicationCore* GetPVApplication(); // not used inside PARAVIS virtual CAM_DataModel* createDataModel(); - void fixAnimationScene(); - -public slots: - //void onImportFromVisu(QString theEntry); private: - void deleteTemporaryFiles(); - //! Create actions for ParaView GUI operations - void pvCreateActions(); + void pvCreateActions(); //! Create menus for ParaView GUI operations duplicating menus in pqMainWindow ParaView class - void pvCreateMenus(); + void pvCreateMenus(); //! Create toolbars for ParaView GUI operations duplicating toolbars in pqMainWindow ParaView class - void pvCreateToolBars(); + void pvCreateToolBars(); //! Create dock widgets for ParaView widgets - void setupDockWidgets(); + void setupDockWidgets(); //! Save states of dockable ParaView widgets - void saveDockWidgetsState( bool hideWidgets = true ); + void saveDockWidgetsState( bool = true ); //! Restore states of dockable ParaView widgets - void restoreDockWidgetsState(); + void restoreDockWidgetsState(); //! Shows or hides ParaView view window - void showView( bool ); - - //! Returns QMenu object for a given menu id - QMenu* getMenu( const int ); - - //! Discover help project files from the resources. - QString getHelpFileName(); - - //! Create actions for ParaViS - void createActions(); - - //! Create menus for ParaViS - void createMenus(); - - //! Load selected state - void loadSelectedState(bool toClear); + void showView( bool ); //! Get list of embedded macros files QStringList getEmbeddedMacrosList(); @@ -227,17 +175,11 @@ private: void restoreCommonWindowsState(); private slots: - void showHelpForProxy( const QString&, const QString& ); - void onPreAccept(); - void onPostAccept(); - void endWaitCursor(); - - // void buildToolbarsMenu(); - - //void showParaViewHelp(); - //void showHelp(const QString& url); + void onPreAccept(); // not used inside PARAVIS + void onPostAccept(); // not used inside PARAVIS + void endWaitCursor(); // not used inside PARAVIS void onDataRepresentationUpdated(); @@ -246,15 +188,6 @@ private slots: void onShowTrace(); void onRestartTrace(); -// void onNewParaViewWindow(); - - void onSaveMultiState(); - void onAddState(); - void onCleanAddState(); - - void onRename(); - void onDelete(); - public slots: virtual bool activateModule( SUIT_Study* ); virtual bool deactivateModule( SUIT_Study* ); @@ -262,8 +195,6 @@ public slots: virtual void studyClosed( SUIT_Study* ); protected slots: - virtual void onModelOpened(); - virtual void onPushTraceTimer(); virtual void onInitTimer(); virtual void onViewManagerAdded( SUIT_ViewManager* ); virtual void onViewManagerRemoved( SUIT_ViewManager* ); @@ -271,10 +202,8 @@ protected slots: virtual void onPVViewDelete( SUIT_ViewWindow* ); private: - int mySelectionControlsTb; int mySourcesMenuId; int myFiltersMenuId; - int myToolbarsMenuId; int myMacrosMenuId; int myRecentMenuId; @@ -287,26 +216,16 @@ private: typedef QMap DockWindowMap; DockWindowMap myCommonMap; - QStringList myTemporaryFiles; - - QtMsgHandler myOldMsgHandler; - - vtkEventQtSlotConnect *VTKConnect; + QtMsgHandler myOldMsgHandler; - pqPythonScriptEditor* myTraceWindow; + vtkEventQtSlotConnect* VTKConnect; - int myStateCounter; + pqPythonScriptEditor* myTraceWindow; //! Single shot timer used to connect to the PVServer, and start the trace. - QTimer * myInitTimer; - - //! Timer used to regularly push the Python trace to the engine. - QTimer * myPushTraceTimer; - - PVViewer_GUIElements * myGuiElements; - - static PVSERVER_ORB::PVSERVER_Gen_var MyEngine; + QTimer* myInitTimer; + PVViewer_GUIElements* myGuiElements; }; #endif // PVGUI_Module_H diff --git a/src/PVGUI/PVGUI_Module_actions.cxx b/src/PVGUI/PVGUI_Module_actions.cxx index c15332f0..67f3d6ce 100644 --- a/src/PVGUI/PVGUI_Module_actions.cxx +++ b/src/PVGUI/PVGUI_Module_actions.cxx @@ -32,7 +32,6 @@ #include #include #include -#include // should ultimately be a LightApp only #include #include @@ -366,7 +365,7 @@ void PVGUI_Module::pvCreateActions() connect(anAction, SIGNAL(triggered()), this, SLOT(onShowTrace())); registerAction(ShowTraceId, anAction); - //Show Trace + //Restart Trace anAction = new QAction(tr("MEN_RESTART_TRACE"), this); anAction->setToolTip(tr("TOP_RESTART_TRACE")); anAction->setStatusTip(tr("STB_RESTART_TRACE")); @@ -461,13 +460,6 @@ void PVGUI_Module::pvCreateMenus() // --- Menu "View" aPVMnu = createMenu( tr( "MEN_DESK_VIEW" ), -1, -1 ); - /*myToolbarsMenuId = createMenu( "Toolbars", aPVMnu ); - aMenu = getMenu( myToolbarsMenuId ); - if (aMenu) { - buildToolbarsMenu(); - connect(aMenu, SIGNAL(aboutToShow()), this, SLOT(buildToolbarsMenu())); - } - createMenu( separator(), aPVMnu );*/ createMenu( FullScreenId, aPVMnu ); @@ -539,119 +531,3 @@ void PVGUI_Module::pvCreateToolBars() PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance(desk); guiElements->setToolBarVisible(true); } - -/*! - \brief Returns QMenu by its id. -*/ -QMenu* PVGUI_Module::getMenu( const int id ) -{ - QMenu* res = 0; - //SalomeApp_Application* anApp = getApp(); - LightApp_Application* anApp = getApp(); - SUIT_Desktop* desk = anApp->desktop(); - if ( desk ){ - QtxActionMenuMgr* menuMgr = desk->menuMgr(); - res = menuMgr->findMenu( id ); - } - return res; -} - -/*! - \brief Returns list of ParaView toolbars -*/ -/*QList PVGUI_Module::getParaViewToolbars() -{ - QList all_toolbars = application()->desktop()->findChildren(); - // First two toolbars has to be ignored because they are not from ParaView - if (all_toolbars.size() > 2) { - all_toolbars.removeFirst(); - all_toolbars.removeFirst(); - } - return all_toolbars; - }*/ - - - -/*! - \brief Builds a menu which referred to toolbars -*/ -/*void PVGUI_Module::buildToolbarsMenu() -{ - SUIT_Desktop* desk = application()->desktop(); - QMenu* aMenu = menuMgr()->findMenu( myToolbarsMenuId ); - if (aMenu) { - aMenu->clear(); - QList child_menus = aMenu->findChildren(); - foreach (QMenu* menu, child_menus) { - delete menu; - } - QList all_toolbars = getParaViewToolbars(); - - // Add menus for all toolbars and actions from them. - // This puts menu actions for all toolbars making it possible to access all - // toolbar actions even when the toolbar are not visible. - // I wonder if I should ignore the pqMainControlsToolbar since those actions - // are already placed at other places. - foreach (QToolBar* toolbar, all_toolbars) { - QMenu* sub_menu = new QMenu(aMenu) << pqSetName(toolbar->windowTitle()); - bool added = false; - foreach (QAction* action, toolbar->actions()) { - if (!action->text().isEmpty()) { - added = true; - sub_menu->addAction(action); - } - } - if (added) { - QAction* menu_action = aMenu->addMenu(sub_menu); - menu_action->setText(toolbar->windowTitle()); - } else { - delete sub_menu; - } - } - disconnect(aMenu, SIGNAL(aboutToShow()), this, SLOT(buildToolbarsMenu())); - } - }*/ - -/*! - \brief Create actions for ParaViS -*/ -void PVGUI_Module::createActions() -{ - QAction* anAction; - - // Save state under the module root object - anAction = new QAction(tr("MEN_SAVE_MULTI_STATE"), this); - connect(anAction, SIGNAL(triggered()), this, SLOT(onSaveMultiState())); - registerAction(SaveStatePopupId, anAction); - - // Restore the selected state by merging with the current one - anAction = new QAction(tr("MEN_ADD_STATE"), this); - connect(anAction, SIGNAL(triggered()), this, SLOT(onAddState())); - registerAction(AddStatePopupId, anAction); - - // Clean the current state and restore the selected one - anAction = new QAction(tr("MEN_CLEAN_ADD_STATE"), this); - connect(anAction, SIGNAL(triggered()), this, SLOT(onCleanAddState())); - registerAction(CleanAndAddStatePopupId, anAction); - - // Rename the selected object (Object Browser) - anAction = new QAction(tr("MEN_PARAVIS_RENAME"), this); - connect(anAction, SIGNAL(triggered()), this, SLOT(onRename())); - registerAction(ParaVisRenameId, anAction); - - // Delete the selected object (Object Browser) - anAction = new QAction(tr("MEN_PARAVIS_DELETE"), this); - connect(anAction, SIGNAL(triggered()), this, SLOT(onDelete())); - registerAction(ParaVisDeleteId, anAction); -} - -/*! - \brief Create actions for ParaViS -*/ -void PVGUI_Module::createMenus() -{ - // "Window" - "New Window" - "ParaView view" menu - int aWindowMenu = createMenu(tr( "MEN_DESK_WINDOW" ), -1, -1); - int aNewWindowMenu = createMenu(tr( "MEN_DESK_NEWWINDOW"), aWindowMenu, -1, -1); - createMenu(ParaViewNewWindowId, aNewWindowMenu); -} diff --git a/src/PVGUI/PVGUI_Module_widgets.cxx b/src/PVGUI/PVGUI_Module_widgets.cxx index a20a3af4..90898f24 100644 --- a/src/PVGUI/PVGUI_Module_widgets.cxx +++ b/src/PVGUI/PVGUI_Module_widgets.cxx @@ -28,7 +28,6 @@ #include #include -#include // // should ultimately be a LightApp only #include #include @@ -414,15 +413,15 @@ void PVGUI_Module::restoreDockWidgetsState() dw->toggleViewAction()->setVisible( true ); } - // restore toolbar breaks state - QMapIterator it2( myToolbarBreaks ); - while( it2.hasNext() ) { - it2.next(); - QToolBar* tb = qobject_cast( it2.key() ); - if ( myToolbarBreaks[tb] ) - desk->insertToolBarBreak( tb ); - } - + // restore toolbar breaks state + QMapIterator it2( myToolbarBreaks ); + while( it2.hasNext() ) { + it2.next(); + QToolBar* tb = qobject_cast( it2.key() ); + if ( myToolbarBreaks[tb] ) + desk->insertToolBarBreak( tb ); + } + // restore toolbar visibility state QMapIterator it3( myToolbars ); while( it3.hasNext() ) { @@ -451,13 +450,10 @@ void PVGUI_Module::storeCommonWindowsState() { // restoreCommonWindowsState() method, and at the moment of the ParaVis activation we call // this method. - //LightApp_Application* anApp = getApp(); - SalomeApp_Application* anApp = getApp(); + LightApp_Application* anApp = getApp(); if(!anApp) return; -// int begin = SalomeApp_Application::WT_ObjectBrowser; -// int end = SalomeApp_Application::WT_NoteBook; int begin = LightApp_Application::WT_ObjectBrowser; int end = LightApp_Application::WT_User; for( int i = begin; i <= end; i++ ) { @@ -466,15 +462,15 @@ void PVGUI_Module::storeCommonWindowsState() { QDockWidget* dock = 0; QWidget* w = wg->parentWidget(); while ( w && !dock ) { - dock = ::qobject_cast( w ); - w = w->parentWidget(); + dock = ::qobject_cast( w ); + w = w->parentWidget(); } if(dock){ - if(!myCommonMap.contains(i)){ - myCommonMap.insert(i,dock->isVisible()); - } else { - myCommonMap[i] = dock->isVisible(); - } + if(!myCommonMap.contains(i)){ + myCommonMap.insert(i,dock->isVisible()); + } else { + myCommonMap[i] = dock->isVisible(); + } } } } @@ -484,8 +480,7 @@ void PVGUI_Module::storeCommonWindowsState() { \brief Restore visibility of the common dockable windows (OB, PyConsole, ... etc.) */ void PVGUI_Module::restoreCommonWindowsState() { - SalomeApp_Application* anApp = getApp(); -// LightApp_Application* anApp = getApp(); + LightApp_Application* anApp = getApp(); if(!anApp) return; DockWindowMap::const_iterator it = myCommonMap.begin(); @@ -495,11 +490,11 @@ void PVGUI_Module::restoreCommonWindowsState() { QDockWidget* dock = 0; QWidget* w = wg->parentWidget(); while ( w && !dock ) { - dock = ::qobject_cast( w ); - w = w->parentWidget(); + dock = ::qobject_cast( w ); + w = w->parentWidget(); } if(dock) { - dock->setVisible(it.value()); + dock->setVisible(it.value()); } } } diff --git a/src/PVGUI/PVGUI_Tools.cxx b/src/PVGUI/PVGUI_Tools.cxx deleted file mode 100644 index f7764b6f..00000000 --- a/src/PVGUI/PVGUI_Tools.cxx +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2010-2015 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 -// -// File : PVGUI_Tools.cxx -// Author : Vitaly Smetannikov -// Module : PARAVIS - -#include "PVGUI_Tools.h" -#include "CAM_Module.h" -#include "SALOME_LifeCycleCORBA.hxx" -#include "SalomeApp_Application.h" -#include "SalomeApp_Study.h" - -using namespace std; - -//============================================================================= -namespace PARAVIS -{ - /** - * Get current study. - */ - _PTR(Study) GetCStudy(const CAM_Module* theModule) - { - if (theModule && theModule->application()) { - SalomeApp_Study* activeStudy = - dynamic_cast(theModule->application()->activeStudy()); - if (activeStudy) { - return activeStudy->studyDS(); - } - } - - return _PTR(Study)(); - } -} diff --git a/src/PVGUI/PVGUI_Tools.h b/src/PVGUI/PVGUI_Tools.h deleted file mode 100644 index f5ed5fc0..00000000 --- a/src/PVGUI/PVGUI_Tools.h +++ /dev/null @@ -1,39 +0,0 @@ -// PARAVIS : ParaView wrapper SALOME module -// -// Copyright (C) 2010-2015 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 -// -// File : PVGUI_Tools.h -// Author : Vitaly Smetannikov -// - -#ifndef PVGUI_Tools_H -#define PVGUI_Tools_H - -#include "SALOMEDSClient_Study.hxx" - -#define PVSTATEID 15555 - -class CAM_Module; - -namespace PARAVIS -{ - _PTR(Study) GetCStudy(const CAM_Module* theModule); -}; - -#endif // PVGUI_Tools_H -- 2.39.2