]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
1. Changing PVGUI_Module design
authorsan <san@opencascade.com>
Wed, 19 Nov 2008 15:19:38 +0000 (15:19 +0000)
committersan <san@opencascade.com>
Wed, 19 Nov 2008 15:19:38 +0000 (15:19 +0000)
2. Add test menu command for standard ParaView action

resources/LightApp.xml
src/PVGUI/Makefile.am
src/PVGUI/PVGUI_Module.cxx
src/PVGUI/PVGUI_Module.h
src/PVGUI/PVGUI_ViewWindow.cxx
src/PVGUI/PVGUI_ViewWindow.h

index db2b2768b1df57b8f6e6168f45878962cdb0494a..e03cbab9bcc2593a317755e4a8d7ba59170620dc 100644 (file)
@@ -7,5 +7,7 @@
   <section name="resources">
     <!-- Module resources -->
     <parameter name="PARAVIS" value="${PARAVIS_ROOT_DIR}/share/salome/resources/paravis"/>
+    <!-- ParaView pixmaps -->
+    <parameter name="ParaView" value="${PVHOME}/src/Qt/Components/Resources/Icons"/>
   </section>
 </document>
index ce2b9c4c507311a6ffb76e3a6dcb11c51ef17936..5cf4e90dd0d3defd97009c833e2c8bb442b9cf95 100644 (file)
@@ -68,11 +68,3 @@ libPARAVIS_la_LDFLAGS = \
 nodist_salomeres_DATA = \
            PARAVIS_images.qm \
            PARAVIS_msg_en.qm
-
-# Copying ParaView icons to a convenient location
-install-data-local:
-       @echo
-       @echo "Copying ParaView icons to $(salomeresdir)..."
-       @cp -f $(PVHOME)/src/Qt/Components/Resources/Icons/*.png $(salomeresdir)
-       @echo "Copying done"
-       @echo
index 6b18f554b8f703646215ddd11b692c7c83dc3a09..9cdc4c1b5e2e34bb640467e0c650391ae8e29d36 100644 (file)
@@ -27,6 +27,7 @@
 #include "PVGUI_ProcessModuleHelper.h"
 #include "PVGUI_ViewModel.h"
 #include "PVGUI_ViewManager.h"
+#include "PVGUI_ViewWindow.h"
 
 #include <SUIT_MessageBox.h>
 #include <SUIT_Desktop.h>
@@ -44,6 +45,7 @@
 #include <pqOptions.h>
 #include <pqApplicationCore.h>
 #include <pqActiveServer.h>
+#include <pqMainWindowCore.h>
 #include <pqObjectBuilder.h>
 #include <pqServer.h>
 #include <pqServerManagerModel.h>
@@ -118,9 +120,52 @@ void ParaViewInitializeInterpreter(vtkProcessModule* pm)
   vtkXdmfCS_Initialize(pm->GetInterpreter());
 }
 
-vtkPVMain*                 PVGUI_Module::myPVMain = 0;
-pqOptions*                 PVGUI_Module::myPVOptions = 0;
-PVGUI_ProcessModuleHelper* PVGUI_Module::myPVHelper = 0;
+//////////////////////////////////////////////////////////////////////////////
+// PVGUI_Module::pqImplementation
+
+class PVGUI_Module::pqImplementation
+{
+public:
+  pqImplementation(QWidget* parent) :
+    //AssistantClient(0),
+    Core(parent)//,
+    //RecentFilesMenu(0),
+    //ViewMenu(0),
+    //ToolbarsMenu(0)
+  {
+  }
+
+  ~pqImplementation()
+  {
+    //delete this->ViewMenu;
+    //delete this->ToolbarsMenu;
+    //if(this->AssistantClient)
+    //  {
+    //  this->AssistantClient->closeAssistant();
+    //  delete this->AssistantClient;
+    //  }
+  }
+
+  //QPointer<QAssistantClient> AssistantClient;
+  //Ui::MainWindow UI;
+  pqMainWindowCore Core;
+  //pqRecentFilesMenu* RecentFilesMenu;
+  //pqViewMenu* ViewMenu;
+  //pqViewMenu* ToolbarsMenu;
+  //QLineEdit* CurrentTimeWidget;
+  //QSpinBox* CurrentTimeIndexWidget;
+  QPointer<pqServer> ActiveServer;
+  QString DocumentationDir;
+
+  static vtkPVMain* myPVMain;
+  static pqOptions* myPVOptions;
+  static PVGUI_ProcessModuleHelper* myPVHelper;
+};
+
+
+vtkPVMain*                 PVGUI_Module::pqImplementation::myPVMain = 0;
+pqOptions*                 PVGUI_Module::pqImplementation::myPVOptions = 0;
+PVGUI_ProcessModuleHelper* PVGUI_Module::pqImplementation::myPVHelper = 0;
 
 /*!
   \class PVGUI_Module
@@ -133,7 +178,7 @@ PVGUI_ProcessModuleHelper* PVGUI_Module::myPVHelper = 0;
 */
 PVGUI_Module::PVGUI_Module()
   : LightApp_Module( "PARAVIS" ),
-    myActiveServer( 0 )
+    Implementation( 0 )
 {
 }
 
@@ -152,8 +197,6 @@ void PVGUI_Module::initialize( CAM_Application* app )
 {
   LightApp_Module::initialize( app );
 
-  SUIT_Desktop* desk = application()->desktop();
-
   /*
   int i = 1;
   while( i ){
@@ -161,9 +204,8 @@ void PVGUI_Module::initialize( CAM_Application* app )
   }
   */
 
-  if ( pvInit() ) {
-    pvCreateActions();
-  }
+  pvInit();
+
   /*
   createAction( lgLoadFile, tr( "TOP_LOAD_FILE" ), QIcon(), tr( "MEN_LOAD_FILE" ),
                 tr( "STB_LOAD_FILE" ), 0, desk, false, this, SLOT( onLoadFile() ) );
@@ -258,7 +300,7 @@ void PVGUI_Module::windows( QMap<int, int>& m ) const
 */
 bool PVGUI_Module::pvInit()
 {
-  if ( !myPVMain ){
+  if ( !pqImplementation::myPVMain ){
     // Obtain command-line arguments
     int argc = 0;
     QStringList args = QApplication::arguments();
@@ -272,22 +314,24 @@ bool PVGUI_Module::pvInit()
     // TODO: Set plugin dir from preferences
     //QApplication::setLibraryPaths(QStringList(dir.absolutePath()));
 
-    myPVMain = vtkPVMain::New();
-    if ( !myPVOptions )
-      myPVOptions = pqOptions::New();
-    if ( !myPVHelper )
-      myPVHelper = PVGUI_ProcessModuleHelper::New();
+    pqImplementation::myPVMain = vtkPVMain::New();
+    if ( !pqImplementation::myPVOptions )
+      pqImplementation::myPVOptions = pqOptions::New();
+    if ( !pqImplementation::myPVHelper )
+      pqImplementation::myPVHelper = PVGUI_ProcessModuleHelper::New();
 
-    myPVOptions->SetProcessType(vtkPVOptions::PVCLIENT);
+    pqImplementation::myPVOptions->SetProcessType(vtkPVOptions::PVCLIENT);
 
     // This creates the Process Module and initializes it.
-    int ret = myPVMain->Initialize(myPVOptions, myPVHelper, ParaViewInitializeInterpreter,
-                                   argc, argv);
+    int ret = pqImplementation::myPVMain->Initialize(pqImplementation::myPVOptions, 
+                                                     pqImplementation::myPVHelper, 
+                                                     ParaViewInitializeInterpreter,
+                                                     argc, argv);
     if (!ret){
       // Tell process module that we support Multiple connections.
       // This must be set before starting the event loop.
       vtkProcessModule::GetProcessModule()->SupportMultipleConnectionsOn();
-      ret = myPVHelper->Run(myPVOptions);
+      ret = pqImplementation::myPVHelper->Run(pqImplementation::myPVOptions);
     }
 
     delete[] argv;
@@ -311,15 +355,25 @@ void PVGUI_Module::pvShutdown()
 void PVGUI_Module::showView( bool toShow )
 {
   // TODO: check if ParaView view already exists
-  LightApp_Application* anApp = getApp();
-  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-  PVGUI_ViewManager* viewMgr = new PVGUI_ViewManager( anApp->activeStudy(), anApp->desktop() );
-  anApp->addViewManager( viewMgr );
-  connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
-          anApp, SLOT( onCloseView( SUIT_ViewManager* ) ) );
-  //connect( viewMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), vm, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
-  //connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ), this, SLOT( onViewDeleted( SUIT_ViewWindow* ) ) );
-  SUIT_ViewWindow* wnd = viewMgr->createViewWindow();  
+  if ( !Implementation ){
+    LightApp_Application* anApp = getApp();
+    SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+    PVGUI_ViewManager* viewMgr = new PVGUI_ViewManager( anApp->activeStudy(), anApp->desktop() );
+    anApp->addViewManager( viewMgr );
+    connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+             anApp, SLOT( onCloseView( SUIT_ViewManager* ) ) );
+    //connect( viewMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), vm, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
+    //connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ), this, SLOT( onViewDeleted( SUIT_ViewWindow* ) ) );
+    SUIT_ViewWindow* wnd = viewMgr->createViewWindow();  
+
+    // Simulate ParaView client main window
+    Implementation = new pqImplementation( wnd );
+    PVGUI_ViewWindow* pvWnd = dynamic_cast<PVGUI_ViewWindow*>( wnd );
+    pvWnd->setMultiViewManager( &Implementation->Core.multiViewManager() );
+
+    pvCreateActions();
+    setupDockWidgets();
+  }
 }
  
 /*!
@@ -329,14 +383,22 @@ void PVGUI_Module::showView( bool toShow )
 void PVGUI_Module::pvCreateActions()
 {
   // TODO...
+  SUIT_Desktop* desk = application()->desktop();
+
+  // TEST
+  int actionManagePlugins = 999;
+  createAction( actionManagePlugins, tr( "TOP_MANAGE_PLUGINS" ), QIcon(), tr( "MEN_MANAGE_PLUGINS" ),
+                tr( "STB_MANAGE_PLUGINS" ), 0, desk, false, &Implementation->Core, SLOT( onManagePlugins() ) );
+  int aPVMnu = createMenu( tr( "MEN_TEST_PARAVIEW" ), -1, -1, 50 );
+  createMenu( actionManagePlugins, aPVMnu, 10 );
 }
 
+
 /*!
-  \brief Returns the active ParaView server connection.
+  \brief Create dock widgets for ParaView widgets such as object inspector, pipeline browser, etc.
 */
-pqServer* PVGUI_Module::getActiveServer() const
+void PVGUI_Module::setupDockWidgets()
 {
-  return myActiveServer->current();
 }
 
 /*!
@@ -345,35 +407,11 @@ pqServer* PVGUI_Module::getActiveServer() const
 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();
+  if ( Implementation )
+    aMVM = &Implementation->Core.multiViewManager();
   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.
@@ -391,14 +429,8 @@ 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();
+  if ( Implementation )
+    Implementation->Core.makeDefaultConnectionIfNoneExists();
 
   return isDone;
 }
index 8f1c26180c0ed9dba5a10773f2c6d418ea57a8dd..3b9de1455e0646b80253b545dab67c9cec5b6934 100644 (file)
@@ -63,7 +63,6 @@ public:
 
   //virtual LightApp_Selection* createSelection() const;
 
-  pqServer*              getActiveServer() const;
   pqViewManager*         getMultiViewManager() const;
 
 protected:
@@ -79,22 +78,19 @@ private:
   //! duplicating menus and toolbars in pqMainWindow ParaView class
   void                   pvCreateActions();  
 
+  //! Create dock widgets for ParaView widgets
+  void                   setupDockWidgets();
+
   //! Shows or hides ParaView view window
   void                   showView( bool );         
 
-  void                   makeDefaultConnectionIfNoneExists();
-
 public slots:
   virtual bool           activateModule( SUIT_Study* );
   virtual bool           deactivateModule( SUIT_Study* );
 
 private:
-  static vtkPVMain*                 myPVMain;
-  static pqOptions*                 myPVOptions;
-  static PVGUI_ProcessModuleHelper* myPVHelper;
-
-  //! pqMainWindowCore stuff
-  pqActiveServer*                   myActiveServer;
+  class pqImplementation;
+  pqImplementation*                 Implementation;
 };
 
 #endif // PVGUI_Module_H
index d146a322e3358af4398bfe180da92633bd72a21f..b186eeef44134306af358cb1022147c58c64704d 100644 (file)
@@ -44,11 +44,6 @@ PVGUI_ViewWindow::PVGUI_ViewWindow( SUIT_Desktop* theDesktop, PVGUI_Viewer* theM
   : SUIT_ViewWindow( theDesktop ), myPVMgr( 0 )
 {
   myModel = theModel;
-  myPVMgr = new pqViewManager( this );
-
-  setCentralWidget( myPVMgr );
-
-  myPVMgr->installEventFilter( this );
 }
 
 /*!
@@ -89,7 +84,18 @@ void PVGUI_ViewWindow::setVisualParameters( const QString& parameters )
 }
 
 /*!
-  \brief Returns the ParaView multi-view manager for this view window
+  \brief Sets the ParaView multi-view manager for this view window
+*/
+void PVGUI_ViewWindow::setMultiViewManager( pqViewManager* viewMgr )
+{
+  myPVMgr = viewMgr;
+  myPVMgr->setParent( this );
+  setCentralWidget( myPVMgr );
+  myPVMgr->installEventFilter( this );
+}
+
+/*!
+  \brief Returns the ParaView multi-view manager previously set with setMultiViewManager()
 */
 pqViewManager* PVGUI_ViewWindow::getMultiViewManager() const
 {
index 820924a68d19fd5cdb51e76e6f145fb6398b1bc6..a18d5f51b784d14c02b8552d0b73bb288592d372 100644 (file)
@@ -44,6 +44,7 @@ public:
   virtual QString   getVisualParameters();
   virtual void      setVisualParameters( const QString& );
   
+  void              setMultiViewManager( pqViewManager* );
   pqViewManager*    getMultiViewManager() const;
 
 private: