Salome HOME
Merge branch 'origin/abn/openfile_fix'
[modules/paravis.git] / src / PVGUI / PVGUI_Module_widgets.cxx
index 3f5265637f6a1ce80810de1bc5aea08bf5a95d2a..617680f41d466b59e7c75066ecdda1e8778b02d5 100644 (file)
@@ -1,6 +1,6 @@
 // PARAVIS : ParaView wrapper SALOME module
 //
-// Copyright (C) 2010-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2010-2013  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
@@ -26,6 +26,7 @@
 
 #include <QtxActionToolMgr.h>
 #include <LightApp_Application.h>
+#include <SalomeApp_Application.h>
 #include <SUIT_Desktop.h>
 
 #include <QApplication>
 
 #include <pqApplicationCore.h>
 #include <pqComparativeVisPanel.h>
-#include <pqObjectInspectorWidget.h>
 #include <pqPipelineBrowserWidget.h>
-//#include <pqProxyTabWidget.h>
-#include <pqObjectInspectorWidget.h>
 #include <pqProxyInformationWidget.h>
-#include <pqDisplayProxyEditorWidget.h>
 #include <pqSettings.h>
 #include <pqDataInformationWidget.h>
 #include <pqPVAnimationWidget.h>
-#include <pqSelectionInspectorWidget.h>
+#include <pqFindDataSelectionDisplayFrame.h>
+#include <pqMultiBlockInspectorPanel.h>
 #include <pqProgressWidget.h>
 #include <pqProgressManager.h>
+#include <pqObjectInspectorWidget.h>
+#include <pqDisplayProxyEditorWidget.h>
 
 #include <pqAlwaysConnectedBehavior.h>
 #include <pqApplicationCore.h>
@@ -77,6 +77,7 @@
 #include <pqParaViewMenuBuilders.h>
 #include <pqCollaborationPanel.h>
 #include <pqMemoryInspectorPanel.h>
+#include <pqColorMapEditor.h>
 
 class ResizeHelper : public pqPVAnimationWidget
 {
@@ -125,9 +126,6 @@ void PVGUI_Module::setupDockWidgets()
   pipelineBrowserDock->setWidget(browser);
   myDockWidgets[pipelineBrowserDock] = true;
 
-
-  
-
   //Object inspector
   QDockWidget* objectInspectorDock = new QDockWidget( tr( "TTL_OBJECT_INSPECTOR" ), desk );
   objectInspectorDock->setObjectName("objectInspectorDock");
@@ -193,6 +191,7 @@ void PVGUI_Module::setupDockWidgets()
   desk->tabifyDockWidget(objectInspectorDock, informationDock);
   objectInspectorDock->raise();
 
+
   // Statistic View
   QDockWidget* statisticsViewDock  = new QDockWidget( tr( "TTL_STATISTICS_VIEW" ), desk );
   statisticsViewDock->setObjectName("statisticsViewDock");
@@ -213,14 +212,22 @@ void PVGUI_Module::setupDockWidgets()
 
   desk->tabifyDockWidget(animationViewDock,  statisticsViewDock);
 
-  // Selection view
-  QDockWidget* selectionInspectorDock = new QDockWidget( tr( "TTL_SELECTION_INSPECTOR" ), desk );
-  selectionInspectorDock->setObjectName("selectionInspectorDock");
-  selectionInspectorDock->setAllowedAreas( Qt::AllDockWidgetAreas );
-  desk->addDockWidget( Qt::LeftDockWidgetArea, selectionInspectorDock );
-  pqSelectionInspectorPanel* aSelInspector = new pqSelectionInspectorWidget(selectionInspectorDock);
-  selectionInspectorDock->setWidget(aSelInspector);
-  myDockWidgets[selectionInspectorDock] = false; // hidden by default
+  // Selection inspector
+  QDockWidget* selectionDisplayDock = new QDockWidget( tr( "TTL_SELECTION_INSPECTOR" ), desk );
+  selectionDisplayDock->setObjectName("selectionInspectorDock");
+  selectionDisplayDock->setAllowedAreas( Qt::AllDockWidgetAreas );
+  desk->addDockWidget( Qt::LeftDockWidgetArea, selectionDisplayDock );
+  pqFindDataSelectionDisplayFrame* aSelInspector = new pqFindDataSelectionDisplayFrame(selectionDisplayDock);
+  selectionDisplayDock->setWidget(aSelInspector);
+  myDockWidgets[selectionDisplayDock] = false; // hidden by default
+
+  // Multi-block inspector
+  QDockWidget* multiBlockInspectorPanelDock  = new QDockWidget( tr( "TTL_MUTLI_BLOCK_INSPECTOR" ), desk );
+  multiBlockInspectorPanelDock->setObjectName("multiBlockInspectorPanelDock");
+  desk->addDockWidget( Qt::LeftDockWidgetArea, multiBlockInspectorPanelDock );
+  pqMultiBlockInspectorPanel* mbi_panel = new pqMultiBlockInspectorPanel( multiBlockInspectorPanelDock );
+  multiBlockInspectorPanelDock->setWidget(mbi_panel);
+  myDockWidgets[multiBlockInspectorPanelDock] = false; // hidden by default
 
   // Comparative View
   QDockWidget* comparativePanelDock  = new QDockWidget( tr( "TTL_COMPARATIVE_VIEW_INSPECTOR" ), desk );
@@ -238,13 +245,24 @@ void PVGUI_Module::setupDockWidgets()
   collaborationPanelDock->setWidget(collaborationPanel);
   desk->addDockWidget(Qt::RightDockWidgetArea, collaborationPanelDock);
   myDockWidgets[collaborationPanelDock] = false; // hidden by default
+
+  // Color map editor
+  QDockWidget* colorMapEditorDock  = new QDockWidget( tr( "TTL_COLOR_MAP_EDITOR" ), desk );
+  colorMapEditorDock->setObjectName("colorMapEditorDock");
+  desk->addDockWidget( Qt::LeftDockWidgetArea, colorMapEditorDock );
+  pqColorMapEditor* cmed_panel = new pqColorMapEditor( colorMapEditorDock );
+  colorMapEditorDock->setWidget(cmed_panel);
+  myDockWidgets[colorMapEditorDock] = false; // hidden by default
+
   
   // Memory inspector dock
   QDockWidget* memoryInspectorDock = new QDockWidget(tr( "TTL_MEMORY_INSPECTOR" ), desk);
   memoryInspectorDock->setObjectName("memoryInspectorDock");
+#ifndef WIN32
   pqMemoryInspectorPanel* dockWidgetContents = new pqMemoryInspectorPanel();
   dockWidgetContents->setObjectName("dockWidgetContents");
   memoryInspectorDock->setWidget(dockWidgetContents);
+#endif
   desk->addDockWidget(Qt::RightDockWidgetArea, memoryInspectorDock);
   myDockWidgets[memoryInspectorDock] = false; // hidden by default
 
@@ -280,16 +298,11 @@ void PVGUI_Module::setupDockWidgets()
   statisticsViewDock->hide();
   comparativePanelDock->hide();
   animationViewDock->hide();
-  selectionInspectorDock->hide();
+  multiBlockInspectorPanelDock->hide();
+  selectionDisplayDock->hide();
   collaborationPanelDock->hide();
   memoryInspectorDock->hide();
-
-  // Setup quick-launch shortcuts.
-  QShortcut *ctrlSpace = new QShortcut(Qt::CTRL + Qt::Key_Space, desk);
-  QObject::connect(ctrlSpace, SIGNAL(activated()), pqApplicationCore::instance(), SLOT(quickLaunch()));
-  QShortcut *altSpace = new QShortcut(Qt::ALT + Qt::Key_Space, desk);
-  QObject::connect(altSpace, SIGNAL(activated()), pqApplicationCore::instance(), SLOT(quickLaunch()));
-
+  colorMapEditorDock->hide();
 }
 
 /*!
@@ -378,3 +391,71 @@ void PVGUI_Module::restoreDockWidgetsState()
     tb->toggleViewAction()->setVisible( true );
   }
 }
+
+
+
+/*!
+  \brief Store visibility of the common dockable windows (OB, PyConsole, ... etc.)
+*/
+void PVGUI_Module::storeCommonWindowsState() {  
+  //rnv: Make behaviour of the dockable windows and toolbars coherent with others
+  //     modules: if 'Save position of the windows' or 'Save position of the toolbars' 
+  //     in the General SALOME preferences are cheked, then properties of the windows and/or toolbars
+  //     are stored/restored using standard Qt saveState(...) and restoreState(...) methods.
+  //     Otherwise to the windows and toolbars applied default settins stored int the SalomeApp.xml
+  //     configuration file.
+  //
+  //     But in contrast to others modules ParaVis module default settings hide some dockable
+  //     windows, so to restore it at the moment of the ParaVis de-activation we call 
+  //     restoreCommonWindowsState() method, and at the moment of the ParaVis activation we call 
+  //     this method.
+
+  SalomeApp_Application* anApp = getApp();
+  if(!anApp)
+    return;
+
+  int begin = SalomeApp_Application::WT_ObjectBrowser;
+  int end = SalomeApp_Application::WT_NoteBook;
+  for( int i = begin; i <= end; i++ ) {
+    QWidget* wg = anApp->getWindow(i);
+    if(wg) {
+      QDockWidget* dock = 0;
+      QWidget* w = wg->parentWidget();
+      while ( w && !dock ) {
+       dock = ::qobject_cast<QDockWidget*>( w );
+       w = w->parentWidget();
+      }
+      if(dock){
+       if(!myCommonMap.contains(i)){
+         myCommonMap.insert(i,dock->isVisible());
+       } else {
+         myCommonMap[i] = dock->isVisible();
+       }
+      }
+    }
+  }
+}
+
+/*!
+  \brief Restore visibility of the common dockable windows (OB, PyConsole, ... etc.)
+*/
+void PVGUI_Module::restoreCommonWindowsState() {
+  SalomeApp_Application* anApp = getApp();
+  if(!anApp)
+    return;
+  DockWindowMap::const_iterator it = myCommonMap.begin();
+  for( ;it != myCommonMap.end(); it++ ) {
+    QWidget* wg = anApp->getWindow(it.key());
+    if(wg) {
+      QDockWidget* dock = 0;
+      QWidget* w = wg->parentWidget();
+      while ( w && !dock ) {
+       dock = ::qobject_cast<QDockWidget*>( w );
+       w = w->parentWidget();
+      }
+      if(dock) {
+       dock->setVisible(it.value());
+      }
+    }
+  }
+}