#include <QString>
#include <pqOptions.h>
+#include <pqApplicationCore.h>
+#include <pqActiveServer.h>
+#include <pqObjectBuilder.h>
+#include <pqServer.h>
+#include <pqServerManagerModel.h>
+#include <pqServerResource.h>
+#include <pqViewManager.h>
#include <vtkPVMain.h>
#include <vtkProcessModule.h>
\brief Constructor. Sets the default name for the module.
*/
PVGUI_Module::PVGUI_Module()
-: LightApp_Module( "PARAVIS" )
+ : LightApp_Module( "PARAVIS" ),
+ myActiveServer( 0 )
{
}
ret = myPVHelper->Run(myPVOptions);
}
- //delete[] argv;
- cout << "*** ParaView client initalized!!!" << endl;
+ delete[] argv;
return !ret;
}
// 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<PVGUI_ViewManager*>( 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<pqServer*>() != 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
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
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
//virtual LightApp_Selection* createSelection() const;
+ pqServer* getActiveServer() const;
+ pqViewManager* getMultiViewManager() const;
+
protected:
//virtual CAM_DataModel* createDataModel();
//! Shows or hides ParaView view window
void showView( bool );
+ void makeDefaultConnectionIfNoneExists();
+
public slots:
virtual bool activateModule( SUIT_Study* );
virtual bool deactivateModule( SUIT_Study* );
static vtkPVMain* myPVMain;
static pqOptions* myPVOptions;
static PVGUI_ProcessModuleHelper* myPVHelper;
+
+ //! pqMainWindowCore stuff
+ pqActiveServer* myActiveServer;
};
#endif // PVGUI_Module_H