From: san Date: Fri, 14 Nov 2008 11:23:13 +0000 (+0000) Subject: Wrapping pqViewManager in SALOME view manager - part 2: create a built-in server... X-Git-Tag: PARAVIS_TEST~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0976ef5de189d261d8bbdc6820b2b7aa66995ce8;p=modules%2Fparavis.git Wrapping pqViewManager in SALOME view manager - part 2: create a built-in server connection --- diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index fe416645..6b18f554 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -42,6 +42,13 @@ #include #include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -125,7 +132,8 @@ PVGUI_ProcessModuleHelper* PVGUI_Module::myPVHelper = 0; \brief Constructor. Sets the default name for the module. */ PVGUI_Module::PVGUI_Module() -: LightApp_Module( "PARAVIS" ) + : LightApp_Module( "PARAVIS" ), + myActiveServer( 0 ) { } @@ -282,8 +290,7 @@ bool PVGUI_Module::pvInit() ret = myPVHelper->Run(myPVOptions); } - //delete[] argv; - cout << "*** ParaView client initalized!!!" << endl; + delete[] argv; return !ret; } @@ -324,6 +331,50 @@ void PVGUI_Module::pvCreateActions() // TODO... } +/*! + \brief Returns the active ParaView server connection. +*/ +pqServer* PVGUI_Module::getActiveServer() const +{ + return myActiveServer->current(); +} + +/*! + \brief Returns the ParaView multi-view manager. +*/ +pqViewManager* PVGUI_Module::getMultiViewManager() const +{ + pqViewManager* aMVM = 0; + LightApp_Application* anApp = getApp(); + PVGUI_ViewManager* aPVMgr = dynamic_cast( anApp->activeViewManager() ); + if ( aPVMgr ) + aMVM = aPVMgr->getMultiViewManager(); + return aMVM; +} + +/*! + \brief Creates a built-in server connection. +*/ +void PVGUI_Module::makeDefaultConnectionIfNoneExists() +{ + if (this->getActiveServer()) + { + return ; + } + + pqApplicationCore* core = pqApplicationCore::instance(); + if (core->getServerManagerModel()->getNumberOfItems() != 0) + { + // cannot really happen, however, if no active server, yet + // server connection exists, we don't try to make a new server connection. + return ; + } + + pqServerResource resource = pqServerResource("builtin:"); + core->getObjectBuilder()->createServer(resource); +} + + /*! \brief Activate module. \param study current study @@ -339,9 +390,20 @@ bool PVGUI_Module::activateModule( SUIT_Study* study ) showView( true ); + // Make default server connection + // see pqMainWindowCore::makeDefaultConnectionIfNoneExists() + if ( !myActiveServer && getMultiViewManager() ) { + myActiveServer = new pqActiveServer( this ); + QObject::connect ( myActiveServer, SIGNAL(changed(pqServer*)), + getMultiViewManager(), SLOT(setActiveServer(pqServer*)) ); + } + + makeDefaultConnectionIfNoneExists(); + return isDone; } + /*! \brief Deactivate module. \param study current study diff --git a/src/PVGUI/PVGUI_Module.h b/src/PVGUI/PVGUI_Module.h index 6e562fe0..8f1c2618 100644 --- a/src/PVGUI/PVGUI_Module.h +++ b/src/PVGUI/PVGUI_Module.h @@ -34,8 +34,11 @@ class LightApp_SelectionMgr; class PVGUI_ProcessModuleHelper; class vtkPVMain; class pqOptions; +class pqServer; +class pqActiveServer; +class pqViewManager; -class PVGUI_Module: public LightApp_Module +class PVGUI_Module : public LightApp_Module { Q_OBJECT @@ -60,6 +63,9 @@ public: //virtual LightApp_Selection* createSelection() const; + pqServer* getActiveServer() const; + pqViewManager* getMultiViewManager() const; + protected: //virtual CAM_DataModel* createDataModel(); @@ -76,6 +82,8 @@ private: //! Shows or hides ParaView view window void showView( bool ); + void makeDefaultConnectionIfNoneExists(); + public slots: virtual bool activateModule( SUIT_Study* ); virtual bool deactivateModule( SUIT_Study* ); @@ -84,6 +92,9 @@ private: static vtkPVMain* myPVMain; static pqOptions* myPVOptions; static PVGUI_ProcessModuleHelper* myPVHelper; + + //! pqMainWindowCore stuff + pqActiveServer* myActiveServer; }; #endif // PVGUI_Module_H diff --git a/src/PVGUI/PVGUI_ViewManager.cxx b/src/PVGUI/PVGUI_ViewManager.cxx index 3cfb15da..ef884197 100644 --- a/src/PVGUI/PVGUI_ViewManager.cxx +++ b/src/PVGUI/PVGUI_ViewManager.cxx @@ -18,6 +18,7 @@ // #include #include +#include /*! @@ -36,3 +37,14 @@ PVGUI_ViewManager::~PVGUI_ViewManager() { } +/*! + \brief Returns the ParaView multi-view manager for the active view window +*/ +pqViewManager* PVGUI_ViewManager::getMultiViewManager() +{ + pqViewManager* aMVM = 0; + PVGUI_ViewWindow* aVW = dynamic_cast( getActiveView() ); + if ( aVW ) + aMVM = aVW->getMultiViewManager(); + return aMVM; +} diff --git a/src/PVGUI/PVGUI_ViewManager.h b/src/PVGUI/PVGUI_ViewManager.h index a802c5bc..dc8be9fc 100644 --- a/src/PVGUI/PVGUI_ViewManager.h +++ b/src/PVGUI/PVGUI_ViewManager.h @@ -23,6 +23,7 @@ class SUIT_Desktop; class SUIT_Study; +class pqViewManager; class PVGUI_ViewManager : public SUIT_ViewManager { @@ -31,6 +32,8 @@ class PVGUI_ViewManager : public SUIT_ViewManager public: PVGUI_ViewManager( SUIT_Study*, SUIT_Desktop* ); ~PVGUI_ViewManager(); + + pqViewManager* getMultiViewManager(); }; #endif diff --git a/src/PVGUI/PVGUI_ViewWindow.cxx b/src/PVGUI/PVGUI_ViewWindow.cxx index 6d8cd608..d146a322 100644 --- a/src/PVGUI/PVGUI_ViewWindow.cxx +++ b/src/PVGUI/PVGUI_ViewWindow.cxx @@ -87,3 +87,11 @@ void PVGUI_ViewWindow::setVisualParameters( const QString& parameters ) { SUIT_ViewWindow::setVisualParameters( parameters ); } + +/*! + \brief Returns the ParaView multi-view manager for this view window +*/ +pqViewManager* PVGUI_ViewWindow::getMultiViewManager() const +{ + return myPVMgr; +} diff --git a/src/PVGUI/PVGUI_ViewWindow.h b/src/PVGUI/PVGUI_ViewWindow.h index 9ea3f967..820924a6 100644 --- a/src/PVGUI/PVGUI_ViewWindow.h +++ b/src/PVGUI/PVGUI_ViewWindow.h @@ -44,6 +44,7 @@ public: virtual QString getVisualParameters(); virtual void setVisualParameters( const QString& ); + pqViewManager* getMultiViewManager() const; private: PVGUI_Viewer* myModel;