]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Implementation of the "0023270: [CEA 1822] PARAVIS GUI widgets should be instanciated...
authorrnv <rnv@opencascade.com>
Thu, 9 Jun 2016 15:04:08 +0000 (18:04 +0300)
committerrnv <rnv@opencascade.com>
Thu, 9 Jun 2016 15:04:08 +0000 (18:04 +0300)
src/PVViewer/PVViewer_Behaviors.cxx
src/PVViewer/PVViewer_Core.cxx
src/PVViewer/PVViewer_GUIElements.cxx
src/PVViewer/PVViewer_GUIElements.h

index e83ad8c1767d1bf10475af286849f775004495f7..f31a6dfd6b39533e9fe8f69b1ecdbcf2ecd33392 100644 (file)
@@ -120,11 +120,15 @@ void PVViewer_Behaviors::instanciateAllBehaviors(QMainWindow * desk)
       new pqViewStreamingBehavior(this);
       new pqStandardArrayColorMapsBehavior(this);
 
+      // Move instantiation of the pqApplyBehavior to the PVViewer_GUIElements::buildPVWidgets(),
+      // because without pqPropertiesPanel it doesn't make sense.      
+      /*
       pqApplyBehavior* applyBehavior = new pqApplyBehavior(this);
       foreach (pqPropertiesPanel* ppanel, desk->findChildren<pqPropertiesPanel*>())
       {
         applyBehavior->registerPanel(ppanel);
       }
+      */
       BehaviorLoadingLevel = 2;
     }
 }
index 7b9621847a39bcb4ac1cf73635bb7096b78ba581..8f9abaafc193d6f6ffddc06ee47182c3900d3c3e 100644 (file)
@@ -93,9 +93,11 @@ bool PVViewer_Core::ParaviewInitApp(QMainWindow * aDesktop, LogWindow * logWindo
         free(argv[i]);
       delete[] argv;
   }
-  // Initialize GUI elements if needed:
-  PVViewer_GUIElements::GetInstance(aDesktop);
-  return true;
+   // Initialization of ParaView GUI widgets will be done when these widgets are
+   // really needed.
+   // PVViewer_GUIElements* inst = PVViewer_GUIElements::GetInstance(aDesktop);
+   // inst->getPropertiesPanel();
+   return true;
 }
 
 void PVViewer_Core::ParaviewInitBehaviors(bool fullSetup, QMainWindow* aDesktop)
index 46eb7fcc2de4ef4582c29d1db693f0d6d9722df7..9e795dc55e7728725a872f2bef38eb73701f73d8 100644 (file)
 // Author: Adrien Bruneton (CEA)
 
 #include "PVViewer_GUIElements.h"
+#include "PVServer_ServiceWrapper.h"
+#include "PVViewer_Core.h"
+#include "PVViewer_ViewManager.h"
 
-#include <pqPropertiesPanel.h>
-#include <pqPipelineBrowserWidget.h>
-#include <pqParaViewMenuBuilders.h>
-#include <pqMainControlsToolbar.h>
-#include <pqVCRToolbar.h>
+#include <pqActiveObjects.h>
+#include <pqAnimationManager.h>
 #include <pqAnimationTimeToolbar.h>
+#include <pqApplicationCore.h>
+#include <pqApplyBehavior.h>
+#include <pqAxesToolbar.h>
+#include <pqCameraToolbar.h>
 #include <pqColorToolbar.h>
+#include <pqMainControlsToolbar.h>
+#include <pqPVApplicationCore.h>
+#include <pqParaViewMenuBuilders.h>
+#include <pqPipelineBrowserWidget.h>
+#include <pqPipelineModel.h>
+#include <pqPropertiesPanel.h>
+#include <pqPythonManager.h>
 #include <pqRepresentationToolbar.h>
-#include <pqCameraToolbar.h>
-#include <pqAxesToolbar.h>
+#include <pqServerConnectReaction.h>
+#include <pqServerManagerModel.h>
+#include <pqServerResource.h>
 #include <pqSetName.h>
+#include <pqVCRToolbar.h>
 
-#include <pqPythonManager.h>
-#include <pqApplicationCore.h>
-
+#include <QAction>
+#include <QCoreApplication>
+#include <QLayout>
+#include <QList>
 #include <QMainWindow>
 #include <QMenu>
-#include <QList>
-#include <QAction>
 #include <QToolBar>
-#include <QLayout>
 
-#include <QCoreApplication>
 
 PVViewer_GUIElements * PVViewer_GUIElements::theInstance = 0;
 
 PVViewer_GUIElements::PVViewer_GUIElements(QMainWindow* desk) :
-  propertiesPanel(0), pipelineBrowserWidget(0),
-  sourcesMenu(0)
+  myDesktop(desk),
+  propertiesPanel(0),
+  pipelineBrowserWidget(0),
+  sourcesMenu(0),
+  filtersMenu(0),
+  macrosMenu(0),
+  myPVWidgetsFlag(false)
 {
-  propertiesPanel = new pqPropertiesPanel(desk);
-  propertiesPanel->hide();
-  pipelineBrowserWidget  = new pqPipelineBrowserWidget(desk);
-  pipelineBrowserWidget->hide();
-
-  sourcesMenu = new QMenu(0);
-  pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, desk);
-  filtersMenu = new QMenu(0);
-  pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk);
-  macrosMenu = new QMenu(0);
-  pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
-
-  myBuildToolbars(desk);
 }
 
 PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(QMainWindow* desk)
@@ -76,56 +78,135 @@ PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(QMainWindow* desk)
  * See ParaView source code: pqParaViewMenuBuilders::buildToolbars()
  * to keep this function up to date:
  */
-void PVViewer_GUIElements::myBuildToolbars(QMainWindow* mainWindow)
+void PVViewer_GUIElements::buildPVWidgets()
 {
-  mainToolBar = new pqMainControlsToolbar(mainWindow)
-    << pqSetName("MainControlsToolbar");
-  mainToolBar->layout()->setSpacing(0);
+  if (!myPVWidgetsFlag) {
 
-  vcrToolbar = new pqVCRToolbar(mainWindow)
-    << pqSetName("VCRToolbar");
-  vcrToolbar->layout()->setSpacing(0);
+    //Pipeline Browser
+    if ( !pipelineBrowserWidget ) {
+      pipelineBrowserWidget  = new pqPipelineBrowserWidget(myDesktop);
+    }
 
-  timeToolbar = new pqAnimationTimeToolbar(mainWindow)
-    << pqSetName("currentTimeToolbar");
-  timeToolbar->layout()->setSpacing(0);
+    // Properties panel
+    if ( !propertiesPanel ) {
+      propertiesPanel = new pqPropertiesPanel(myDesktop);
+    }
+    
+    // Sources Menu
+    if (!sourcesMenu) {
+      sourcesMenu = new QMenu(0);
+      pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, myDesktop);
+    }
 
-  colorToolbar = new pqColorToolbar(mainWindow)
-    << pqSetName("variableToolbar");
-  colorToolbar->layout()->setSpacing(0);
+    //Filer Menu
+    if (!filtersMenu) {
+      filtersMenu = new QMenu(0);
+      pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, myDesktop);
+    }
 
-  reprToolbar = new pqRepresentationToolbar(mainWindow)
-    << pqSetName("representationToolbar");
-  reprToolbar->layout()->setSpacing(0);
+    // Macros Menu
+    if (!macrosMenu) {
+      macrosMenu = new QMenu(0);
+      pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
+    }
 
-  cameraToolbar = new pqCameraToolbar(mainWindow)
-    << pqSetName("cameraToolbar");
-  cameraToolbar->layout()->setSpacing(0);
+    mainToolBar = new pqMainControlsToolbar(myDesktop)
+      << pqSetName("MainControlsToolbar");
+    mainToolBar->layout()->setSpacing(0);
 
-  axesToolbar = new pqAxesToolbar(mainWindow)
-    << pqSetName("axesToolbar");
-  axesToolbar->layout()->setSpacing(0);
+    vcrToolbar = new pqVCRToolbar(myDesktop)
+      << pqSetName("VCRToolbar");
+    vcrToolbar->layout()->setSpacing(0);
 
-  // Give the macros menu to the pqPythonMacroSupervisor
-  pqPythonManager* manager = qobject_cast<pqPythonManager*>(
+    timeToolbar = new pqAnimationTimeToolbar(myDesktop)
+      << pqSetName("currentTimeToolbar");
+    timeToolbar->layout()->setSpacing(0);
+
+    colorToolbar = new pqColorToolbar(myDesktop)
+      << pqSetName("variableToolbar");
+    colorToolbar->layout()->setSpacing(0);
+
+    reprToolbar = new pqRepresentationToolbar(myDesktop)
+      << pqSetName("representationToolbar");
+    reprToolbar->layout()->setSpacing(0);
+
+    cameraToolbar = new pqCameraToolbar(myDesktop)
+      << pqSetName("cameraToolbar");
+    cameraToolbar->layout()->setSpacing(0);
+    
+    axesToolbar = new pqAxesToolbar(myDesktop)
+      << pqSetName("axesToolbar");
+    axesToolbar->layout()->setSpacing(0);
+    
+    // Give the macros menu to the pqPythonMacroSupervisor
+    pqPythonManager* manager = qobject_cast<pqPythonManager*>(
     pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
 
-  macrosToolbar = new QToolBar("Macros Toolbars", mainWindow)
+    macrosToolbar = new QToolBar("Macros Toolbars", myDesktop)
       << pqSetName("MacrosToolbar");
-  manager->addWidgetForRunMacros(macrosToolbar);
+    manager->addWidgetForRunMacros(macrosToolbar);
+    
+    commonToolbar = new QToolBar("Common", myDesktop) << pqSetName("Common");
+    commonToolbar->layout()->setSpacing(0);
+    
+    dataToolbar = new QToolBar("DataAnalysis", myDesktop) << pqSetName("DataAnalysis");
+    dataToolbar->layout()->setSpacing(0);
+    
+    // add Toolbars    
+    myDesktop->addToolBar(Qt::TopToolBarArea, mainToolBar);
+    myDesktop->addToolBar(Qt::TopToolBarArea, vcrToolbar);
+    myDesktop->addToolBar(Qt::TopToolBarArea, timeToolbar);
+    myDesktop->addToolBar(Qt::TopToolBarArea, colorToolbar);
+    myDesktop->insertToolBarBreak(colorToolbar);
+    myDesktop->addToolBar(Qt::TopToolBarArea, reprToolbar);
+    myDesktop->addToolBar(Qt::TopToolBarArea, cameraToolbar);
+    myDesktop->addToolBar(Qt::TopToolBarArea, axesToolbar);
+    myDesktop->addToolBar(Qt::TopToolBarArea, macrosToolbar);
+    myDesktop->addToolBar(Qt::TopToolBarArea, commonToolbar);
+    myDesktop->addToolBar(Qt::TopToolBarArea, dataToolbar);
+    
+    mainAction = mainToolBar->toggleViewAction();
+    vcrAction = vcrToolbar->toggleViewAction();
+    timeAction = timeToolbar->toggleViewAction();
+    colorAction = colorToolbar->toggleViewAction();
+    reprAction = reprToolbar->toggleViewAction();
+    cameraAction = cameraToolbar->toggleViewAction();
+    axesAction = axesToolbar->toggleViewAction();
+    macrosAction = macrosToolbar->toggleViewAction();
+    commonAction = commonToolbar->toggleViewAction();
+    dataAction = dataToolbar->toggleViewAction();
+
+    // The piece od the code below is neccessary to correct update "Pipeline Browser",
+    // "Properties Panel", toolbars and menus
+    
+    // Initilaize pqApplyBehavior here because witout pqPropertiesPanel instance it doesn't make sence
+    pqApplyBehavior* applyBehavior = new pqApplyBehavior(this);
+    foreach (pqPropertiesPanel* ppanel, myDesktop->findChildren<pqPropertiesPanel*>())
+      {
+        applyBehavior->registerPanel(ppanel);
+      }
+    
+    emit pqActiveObjects::instance().portChanged(pqActiveObjects::instance().activePort());
+    emit pqActiveObjects::instance().viewChanged(pqActiveObjects::instance().activeView()); 
 
-  commonToolbar = new QToolBar("Common", mainWindow) << pqSetName("Common");
-  commonToolbar->layout()->setSpacing(0);
+    pqServerManagerModel *smModel = pqApplicationCore::instance()->getServerManagerModel();
+    pqServer* serv = pqActiveObjects::instance().activeServer();    
 
-  dataToolbar = new QToolBar("DataAnalysis", mainWindow) << pqSetName("DataAnalysis");
-  dataToolbar->layout()->setSpacing(0);
+    if (serv) {
+      emit smModel->serverAdded(serv);
+      emit serv->nameChanged(NULL);
+    }
 
-  addToolbars(mainWindow);
+    myPVWidgetsFlag = true;
+  }
 }
 
 void PVViewer_GUIElements::setToolBarVisible(bool show)
-{
+{  
   QCoreApplication::processEvents();
+  if (!myPVWidgetsFlag)
+    return;
+  
   mainAction->setChecked(!show);
   mainAction->setVisible(show);
   mainAction->trigger();
@@ -158,34 +239,9 @@ void PVViewer_GUIElements::setToolBarVisible(bool show)
   dataAction->trigger();
 }
 
-void PVViewer_GUIElements::addToolbars(QMainWindow* desk)
-{
-  desk->addToolBar(Qt::TopToolBarArea, mainToolBar);
-  desk->addToolBar(Qt::TopToolBarArea, vcrToolbar);
-  desk->addToolBar(Qt::TopToolBarArea, timeToolbar);
-  desk->addToolBar(Qt::TopToolBarArea, colorToolbar);
-  desk->insertToolBarBreak(colorToolbar);
-  desk->addToolBar(Qt::TopToolBarArea, reprToolbar);
-  desk->addToolBar(Qt::TopToolBarArea, cameraToolbar);
-  desk->addToolBar(Qt::TopToolBarArea, axesToolbar);
-  desk->addToolBar(Qt::TopToolBarArea, macrosToolbar);
-  desk->addToolBar(Qt::TopToolBarArea, commonToolbar);
-  desk->addToolBar(Qt::TopToolBarArea, dataToolbar);
-
-  mainAction = mainToolBar->toggleViewAction();
-  vcrAction = vcrToolbar->toggleViewAction();
-  timeAction = timeToolbar->toggleViewAction();
-  colorAction = colorToolbar->toggleViewAction();
-  reprAction = reprToolbar->toggleViewAction();
-  cameraAction = cameraToolbar->toggleViewAction();
-  axesAction = axesToolbar->toggleViewAction();
-  macrosAction = macrosToolbar->toggleViewAction();
-  commonAction = commonToolbar->toggleViewAction();
-  dataAction = dataToolbar->toggleViewAction();
-}
-
 QList<QToolBar*> PVViewer_GUIElements::getToolbars()
 {
+  buildPVWidgets();
   QList<QToolBar*> l;
   l << mainToolBar << vcrToolbar << timeToolbar << colorToolbar
     << reprToolbar << cameraToolbar << axesToolbar << macrosToolbar
@@ -195,6 +251,9 @@ QList<QToolBar*> PVViewer_GUIElements::getToolbars()
 
 void PVViewer_GUIElements::setToolBarEnabled(bool enabled)
 {
+  if (!myPVWidgetsFlag)
+    return;
+  
   mainToolBar  ->setEnabled(enabled);
   vcrToolbar   ->setEnabled(enabled);
   timeToolbar  ->setEnabled(enabled);
@@ -206,3 +265,43 @@ void PVViewer_GUIElements::setToolBarEnabled(bool enabled)
   commonToolbar->setEnabled(enabled);
   dataToolbar  ->setEnabled(enabled);
 }
+
+
+pqPropertiesPanel* PVViewer_GUIElements::getPropertiesPanel()
+{
+  buildPVWidgets();
+  return propertiesPanel;
+}
+
+pqPipelineBrowserWidget* PVViewer_GUIElements::getPipelineBrowserWidget()
+{
+  buildPVWidgets();
+  return pipelineBrowserWidget;   
+}
+
+
+pqVCRToolbar* PVViewer_GUIElements::getVCRToolbar()
+{
+  buildPVWidgets();
+  return vcrToolbar;
+}
+
+pqAnimationTimeToolbar* PVViewer_GUIElements::getTimeToolbar()
+{
+  buildPVWidgets();
+  return timeToolbar;
+}
+
+QMenu* PVViewer_GUIElements::getFiltersMenu() {
+  buildPVWidgets();
+  return filtersMenu;
+}
+QMenu* PVViewer_GUIElements::getSourcesMenu() {
+  buildPVWidgets();
+  return sourcesMenu;
+}
+
+QMenu* PVViewer_GUIElements::getMacrosMenu()  {
+  buildPVWidgets();
+  return macrosMenu;
+}
index add85a7c25340b9a7d7af86726079f63928a7350..41a05831469f70d58daff394e6e7c75d8e34632b 100644 (file)
@@ -46,18 +46,16 @@ class PVVIEWER_EXPORT PVViewer_GUIElements: public QObject
 public:
   static PVViewer_GUIElements * GetInstance(QMainWindow * desk);
 
-  pqPropertiesPanel * getPropertiesPanel() { return propertiesPanel; }
-  pqPipelineBrowserWidget * getPipelineBrowserWidget() { return pipelineBrowserWidget; }
+  pqPropertiesPanel * getPropertiesPanel();
+  pqPipelineBrowserWidget * getPipelineBrowserWidget();
 
-  QMenu* getFiltersMenu() { return filtersMenu; }
-  QMenu* getSourcesMenu() { return sourcesMenu; }
-  QMenu* getMacrosMenu()  { return macrosMenu; }
+  QMenu* getFiltersMenu();
+  QMenu* getSourcesMenu();
+  QMenu* getMacrosMenu();
 
-  pqVCRToolbar* getVCRToolbar() { return vcrToolbar; }
-  pqAnimationTimeToolbar* getTimeToolbar() { return timeToolbar; }
+  pqVCRToolbar* getVCRToolbar();
+  pqAnimationTimeToolbar* getTimeToolbar();
 
-  void myBuildToolbars(QMainWindow* desk);
-  void addToolbars(QMainWindow* desk);
   void setToolBarVisible(bool show);
   void setToolBarEnabled(bool enabled);
   QList<QToolBar*> getToolbars();
@@ -68,6 +66,8 @@ private:
 
   static PVViewer_GUIElements* theInstance;
 
+  void buildPVWidgets();
+
   // Widgets
   pqPropertiesPanel* propertiesPanel;
   pqPipelineBrowserWidget* pipelineBrowserWidget;
@@ -88,6 +88,9 @@ private:
   QToolBar* macrosToolbar;
   QToolBar* commonToolbar;
   QToolBar* dataToolbar;
+  
+  QMainWindow* myDesktop;
+  bool    myPVWidgetsFlag;
 
 public:
   QAction* mainAction;