Salome HOME
Merge branch 'OCCT780'
[modules/paravis.git] / src / PVGUI / PVGUI_Module_widgets.cxx
1 // PARAVIS : ParaView wrapper SALOME module
2 //
3 // Copyright (C) 2010-2024  CEA, EDF
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 //
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21 // File   : PVGUI_Module_MenuActions.cxx
22 // Author : Margarita KARPUNINA
23 //
24
25 #include "PVGUI_Module.h"
26 #include "PVViewer_ViewManager.h"
27 #include "PVViewer_GUIElements.h"
28
29 #include <QtxActionToolMgr.h>
30 #include <LightApp_Application.h>
31 #include <SUIT_Desktop.h>
32
33 #include <QApplication>
34 #include <QAction>
35 #include <QDockWidget>
36 #include <QToolBar>
37 #include <QStatusBar>
38 #include <QShortcut>
39 #include <QScrollArea>
40 #include <QVBoxLayout>
41 #include <QShowEvent>
42 #include <QToolButton>
43
44 #include <pqAnimationViewWidget.h> 
45 #include <pqAnimationWidget.h> 
46
47 #include <pqApplicationCore.h>
48 #include <pqComparativeVisPanel.h>
49 #include <pqPipelineBrowserWidget.h>
50 #include <pqProxyInformationWidget.h>
51 #include <pqDataInformationWidget.h>
52 #include <pqPVAnimationWidget.h>
53 #include <pqFindDataSelectionDisplayFrame.h>
54 #include <pqMultiBlockInspectorWidget.h>
55 #include <pqProgressWidget.h>
56 #include <pqProgressManager.h>
57 #include <pqPropertiesPanel.h>
58 #include <pqPVApplicationCore.h>
59 #include <pqAnimationManager.h>
60
61 #include <pqApplicationCore.h>
62 #include <pqPluginManager.h>
63 #include <pqParaViewMenuBuilders.h>
64 #include <pqCollaborationPanel.h>
65 #include <pqMemoryInspectorPanel.h>
66 #include <pqColorMapEditor.h>
67 #include <pqFindDataWidget.h>
68 #include <pqDeleteReaction.h>
69
70 #include <vtkPVGeneralSettings.h>
71 #include <vtkSMSettings.h>
72 #include <vtkPVConfig.h>
73
74 class ResizeHelper : public pqPVAnimationWidget
75 {
76   // TEMPORARY WORKAROUND AROUND PARAVIEW 3.14 BUG:
77   // WHEN ANIMATION VIEW IS RESIZED, ITS CONTENTS IS NOT PREPERLY RE-ARRANGED
78   // CAUSING SOME CONTROLS TO STAY NON-VISIBLE
79   // THIS BUG IS NATURALLY FIXED BY ADDING
80   //      this->updateGeometries();
81   // TO THE
82   //     void pqAnimationWidget::resizeEvent(QResizeEvent* e);
83   // BUT THIS CANNOT BE DONE DIRECTLY, SINCE CORRESPONDING API IS NOT PUBLIC
84   // THE ONLY WAY TO DO THIS BY SENDING SHOW EVENT TO THE WIDGET
85
86 public:
87   ResizeHelper( QWidget* parent ) : pqPVAnimationWidget( parent ) {}
88 protected:
89   void resizeEvent(QResizeEvent* e)
90   {
91     pqAnimationWidget* w = findChild<pqAnimationWidget*>( "pqAnimationWidget" );
92     if ( w ) {
93       QShowEvent e;
94       QApplication::sendEvent( w, &e );
95     }
96     pqPVAnimationWidget::resizeEvent( e );
97   }
98 };
99
100 /*!
101   \brief Create dock widgets for ParaView widgets such as object inspector, pipeline browser, etc.
102   ParaView pqMainWindowCore class is fully responsible for these dock widgets' contents.
103   ==> To update this function, see the reference set up of ParaView in Application/Paraview/ParaviewMainWindow.ui
104 */
105 void PVGUI_Module::setupDockWidgets()
106 {
107   SUIT_Desktop* desk = application()->desktop();
108   PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance(desk);
109  
110   desk->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
111   desk->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
112   desk->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::North);
113
114   // Pipeline
115   QDockWidget* pipelineBrowserDock = new QDockWidget( tr( "TTL_PIPELINE_BROWSER" ), desk );
116   pipelineBrowserDock->setObjectName("pipelineBrowserDock");
117   pipelineBrowserDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
118   desk->addDockWidget( Qt::LeftDockWidgetArea, pipelineBrowserDock );
119   pqPipelineBrowserWidget* browser = guiElements->getPipelineBrowserWidget();
120   pipelineBrowserDock->setWidget(browser);
121   myDockWidgets[pipelineBrowserDock] = true;
122   pipelineBrowserDock->hide();
123
124   // PROPERTIES, DISPLAY and VIEW:
125   // See ParaViewMainWindow.cxx - those three panels can be separated or grouped.
126   vtkSMSettings* settings = vtkSMSettings::GetInstance();
127
128   //    Properties dock (previously called OBJECT_INSPECTOR)
129   QDockWidget* propertiesDock = new QDockWidget( tr( "TTL_OBJECT_INSPECTOR" ), desk );
130   propertiesDock->setObjectName("propertiesDock");
131   propertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea );
132   desk->addDockWidget( Qt::LeftDockWidgetArea, propertiesDock );
133
134   pqPropertiesPanel* propertiesPanel = guiElements->getPropertiesPanel();
135   propertiesDock->setWidget(propertiesPanel);
136   connect( propertiesPanel, SIGNAL( helpRequested(const QString&, const QString&) ),  this, SLOT( showHelpForProxy(const QString&, const QString&) ) );
137   //            hook delete to pqDeleteReaction.
138   QAction* tempDeleteAction = new QAction(this);
139   pqDeleteReaction* handler = new pqDeleteReaction(tempDeleteAction);
140 #if PARAVIEW_VERSION_MAJOR==5 && PARAVIEW_VERSION_MINOR<9
141   handler->connect(propertiesPanel, SIGNAL(deleteRequested(pqPipelineSource*)), SLOT(deleteSource(pqPipelineSource*)));
142 #else
143   handler->connect(propertiesPanel, SIGNAL(deleteRequested(pqProxy*)), SLOT(deleteSource(pqProxy*)));
144 #endif
145   myDockWidgets[propertiesDock] = true;
146   propertiesDock->hide();
147
148   int propertiesPanelMode = settings->GetSettingAsInt(
149       ".settings.GeneralSettings.PropertiesPanelMode", vtkPVGeneralSettings::ALL_IN_ONE);
150
151   // Display dock
152   QDockWidget* displayPropertiesDock = 0;
153   if (propertiesPanelMode == vtkPVGeneralSettings::SEPARATE_DISPLAY_PROPERTIES ||
154       propertiesPanelMode == vtkPVGeneralSettings::ALL_SEPARATE )
155   {
156     displayPropertiesDock = new QDockWidget( tr( "TTL_DISPLAY" ), desk );
157     displayPropertiesDock->setObjectName("displayPropertiesDock");
158     displayPropertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea );
159     desk->addDockWidget( Qt::LeftDockWidgetArea, displayPropertiesDock );
160     
161     pqPropertiesPanel* displayPropertiesPanel = new pqPropertiesPanel();
162     displayPropertiesPanel->setObjectName("displayPropertiesPanel");
163     displayPropertiesPanel->setProperty("panelMode", QVariant(2));  // probably to have only the Display part
164     displayPropertiesDock->setWidget(displayPropertiesPanel);
165     myDockWidgets[displayPropertiesDock] = false;
166     displayPropertiesDock->hide();
167   }
168
169   // View dock
170   QDockWidget* viewPropertiesDock = 0;
171   if (propertiesPanelMode == vtkPVGeneralSettings::SEPARATE_VIEW_PROPERTIES ||
172       propertiesPanelMode == vtkPVGeneralSettings::ALL_SEPARATE )
173   {
174     viewPropertiesDock = new QDockWidget( tr( "TTL_VIEW_PANEL" ), desk );
175     viewPropertiesDock->setObjectName("viewPropertiesDock");
176     viewPropertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea );
177     desk->addDockWidget( Qt::LeftDockWidgetArea, viewPropertiesDock );
178     
179     pqPropertiesPanel* viewPropertiesPanel = new pqPropertiesPanel();
180     viewPropertiesPanel->setObjectName("viewPropertiesPanel");
181     viewPropertiesPanel->setProperty("panelMode", QVariant(4)); // probably to have only the View part
182     viewPropertiesDock->setWidget(viewPropertiesPanel);
183     myDockWidgets[viewPropertiesDock] = false;
184     viewPropertiesDock->hide();
185   }
186
187   switch (propertiesPanelMode)
188   {
189     case vtkPVGeneralSettings::SEPARATE_DISPLAY_PROPERTIES:
190       propertiesPanel->setPanelMode(
191           pqPropertiesPanel::SOURCE_PROPERTIES|pqPropertiesPanel::VIEW_PROPERTIES);
192       break;
193
194     case vtkPVGeneralSettings::SEPARATE_VIEW_PROPERTIES:
195       propertiesPanel->setPanelMode(
196           pqPropertiesPanel::SOURCE_PROPERTIES|pqPropertiesPanel::DISPLAY_PROPERTIES);
197       break;
198
199     case vtkPVGeneralSettings::ALL_SEPARATE:
200       propertiesPanel->setPanelMode(pqPropertiesPanel::SOURCE_PROPERTIES);
201       break;
202
203     case vtkPVGeneralSettings::ALL_IN_ONE:
204     default:
205       propertiesPanel->setPanelMode(
206                 pqPropertiesPanel::SOURCE_PROPERTIES|pqPropertiesPanel::VIEW_PROPERTIES|pqPropertiesPanel::DISPLAY_PROPERTIES);
207       break;
208   }
209
210   // Information dock
211   QDockWidget* informationDock = new QDockWidget(tr( "TTL_INFORMATION" ), desk);
212   informationDock->setObjectName("informationDock");
213
214   QWidget* informationWidgetFrame = new QWidget(informationDock);
215   informationWidgetFrame->setObjectName("informationWidgetFrame");
216
217   QVBoxLayout* verticalLayout_2 = new QVBoxLayout(informationWidgetFrame);
218   verticalLayout_2->setSpacing(0);
219   verticalLayout_2->setContentsMargins(0, 0, 0, 0);
220
221   QScrollArea* informationScrollArea = new QScrollArea(informationWidgetFrame);
222   informationScrollArea->setObjectName("informationScrollArea") ;
223   informationScrollArea->setWidgetResizable(true);
224
225   pqProxyInformationWidget* informationWidget = new pqProxyInformationWidget();
226   informationWidget->setObjectName("informationWidget");
227   informationWidget->setGeometry(QRect(0, 0, 77, 214));
228   informationScrollArea->setWidget(informationWidget);
229
230   verticalLayout_2->addWidget(informationScrollArea);
231   informationDock->setWidget(informationWidgetFrame);
232
233   myDockWidgets[informationDock] = true;
234
235   if ( viewPropertiesDock )
236   desk->tabifyDockWidget(propertiesDock, viewPropertiesDock);
237   if ( displayPropertiesDock )
238     desk->tabifyDockWidget(propertiesDock, displayPropertiesDock);
239   desk->tabifyDockWidget(propertiesDock, informationDock);
240   propertiesDock->raise();
241
242   // Statistic View
243   QDockWidget* statisticsViewDock  = new QDockWidget( tr( "TTL_STATISTICS_VIEW" ), desk );
244   statisticsViewDock->setObjectName("statisticsViewDock");
245   statisticsViewDock->setAllowedAreas(Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|
246                                       Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
247   desk->addDockWidget( Qt::BottomDockWidgetArea, statisticsViewDock );
248   pqDataInformationWidget* aStatWidget = new pqDataInformationWidget(statisticsViewDock);
249   statisticsViewDock->setWidget(aStatWidget);
250   myDockWidgets[statisticsViewDock] = false; // hidden by default
251
252   //Animation view
253   QDockWidget* animationViewDock     = new QDockWidget( tr( "TTL_ANIMATION_VIEW" ), desk );
254   animationViewDock->setObjectName("animationViewDock");
255   desk->addDockWidget( Qt::BottomDockWidgetArea, animationViewDock );
256   pqPVAnimationWidget* animation_panel = new ResizeHelper(animationViewDock); // [ABN] was resizeHelper
257
258   // RNV: Emit signal in order to make sure that animation scene is set
259   QMetaObject::invokeMethod( pqPVApplicationCore::instance()->animationManager(),
260                              "activeSceneChanged",
261                              Q_ARG( pqAnimationScene*, pqPVApplicationCore::instance()->animationManager()->getActiveScene() ) );
262
263   animationViewDock->setWidget(animation_panel);
264   myDockWidgets[animationViewDock] = false; // hidden by default
265
266   desk->tabifyDockWidget(animationViewDock,  statisticsViewDock);
267
268   // Selection inspector
269   QDockWidget* selectionDisplayDock = new QDockWidget( tr( "TTL_SELECTION_INSPECTOR" ), desk );
270   selectionDisplayDock->setObjectName("selectionInspectorDock");
271   selectionDisplayDock->setAllowedAreas( Qt::AllDockWidgetAreas );
272   desk->addDockWidget( Qt::LeftDockWidgetArea, selectionDisplayDock );
273   pqFindDataSelectionDisplayFrame* aSelInspector = new pqFindDataSelectionDisplayFrame(selectionDisplayDock);
274   selectionDisplayDock->setWidget(aSelInspector);
275   myDockWidgets[selectionDisplayDock] = false; // hidden by default
276
277   // Multi-block inspector
278   QDockWidget* multiBlockInspectorPanelDock  = new QDockWidget( tr( "TTL_MUTLI_BLOCK_INSPECTOR" ), desk );
279   multiBlockInspectorPanelDock->setObjectName("multiBlockInspectorPanelDock");
280   desk->addDockWidget( Qt::LeftDockWidgetArea, multiBlockInspectorPanelDock );
281   pqMultiBlockInspectorWidget* mbi_panel = new pqMultiBlockInspectorWidget( multiBlockInspectorPanelDock );
282   multiBlockInspectorPanelDock->setWidget(mbi_panel);
283   myDockWidgets[multiBlockInspectorPanelDock] = false; // hidden by default
284
285   // Comparative View
286   QDockWidget* comparativePanelDock  = new QDockWidget( tr( "TTL_COMPARATIVE_VIEW_INSPECTOR" ), desk );
287   comparativePanelDock->setObjectName("comparativePanelDock");
288   desk->addDockWidget( Qt::LeftDockWidgetArea, comparativePanelDock );
289   pqComparativeVisPanel* cv_panel = new pqComparativeVisPanel( comparativePanelDock );
290   comparativePanelDock->setWidget(cv_panel);
291   myDockWidgets[comparativePanelDock] = false; // hidden by default
292
293   // Collaboration view
294   QDockWidget* collaborationPanelDock = new QDockWidget(tr( "TTL_COLLABORATIVE_DOCK" ), desk);
295   collaborationPanelDock->setObjectName("collaborationPanelDock");
296   pqCollaborationPanel* collaborationPanel = new pqCollaborationPanel();
297   collaborationPanel->setObjectName("collaborationPanel");
298   collaborationPanelDock->setWidget(collaborationPanel);
299   desk->addDockWidget(Qt::RightDockWidgetArea, collaborationPanelDock);
300   myDockWidgets[collaborationPanelDock] = false; // hidden by default
301
302   // Color map editor
303   QDockWidget* colorMapEditorDock  = new QDockWidget( tr( "TTL_COLOR_MAP_EDITOR" ), desk );
304   colorMapEditorDock->setObjectName("colorMapEditorDock");
305   desk->addDockWidget( Qt::LeftDockWidgetArea, colorMapEditorDock );
306   pqColorMapEditor* cmed_panel = new pqColorMapEditor( colorMapEditorDock );
307   colorMapEditorDock->setWidget(cmed_panel);
308   myDockWidgets[colorMapEditorDock] = false; // hidden by default
309
310   // Provide access to the color-editor panel for the application.
311   pqApplicationCore::instance()->registerManager(
312     "COLOR_EDITOR_PANEL", colorMapEditorDock);
313
314   // Find data dock
315   QDockWidget* findDataDock = new QDockWidget(tr( "TTL_FIND_DATA" ), desk);
316   findDataDock->setObjectName("findDataDock");
317   pqFindDataWidget* findDataWidget = new pqFindDataWidget();
318   findDataWidget->setObjectName("findDataWidget");
319   findDataDock->setWidget(findDataWidget);
320   desk->addDockWidget(Qt::RightDockWidgetArea, findDataDock);
321   myDockWidgets[findDataDock] = false; // hidden by default
322
323   // Provide access to the find data panel for the application
324   // (through the menu Edit > Find data).
325   pqApplicationCore::instance()->registerManager("FIND_DATA_PANEL", findDataDock);
326
327   // Memory inspector dock
328   QDockWidget* memoryInspectorDock = new QDockWidget(tr( "TTL_MEMORY_INSPECTOR" ), desk);
329   memoryInspectorDock->setObjectName("memoryInspectorDock");
330 #ifndef WIN32
331   pqMemoryInspectorPanel* dockWidgetContents = new pqMemoryInspectorPanel();
332   dockWidgetContents->setObjectName("dockWidgetContents");
333   memoryInspectorDock->setWidget(dockWidgetContents);
334 #endif
335   desk->addDockWidget(Qt::RightDockWidgetArea, memoryInspectorDock);
336   myDockWidgets[memoryInspectorDock] = false; // hidden by default
337
338   // Setup the statusbar ...
339   pqProgressManager* progress_manager =
340     pqApplicationCore::instance()->getProgressManager();
341
342   // Progress bar/button management
343   pqProgressWidget* aProgress = new pqProgressWidget(desk->statusBar());
344   progress_manager->addNonBlockableObject(aProgress);
345   progress_manager->addNonBlockableObject(aProgress->getAbortButton());
346   
347   QObject::connect( progress_manager, SIGNAL(enableProgress(bool)),
348                     aProgress,        SLOT(enableProgress(bool)));
349
350   QObject::connect( progress_manager, SIGNAL(progress(const QString&, int)),
351                     aProgress,        SLOT(setProgress(const QString&, int)));
352
353   QObject::connect( progress_manager, SIGNAL(enableAbort(bool)),
354                     aProgress,        SLOT(enableAbort(bool)));
355
356   QObject::connect( aProgress,        SIGNAL(abortPressed()),
357                     progress_manager, SLOT(triggerAbort()));
358
359   desk->statusBar()->addPermanentWidget(aProgress);
360   aProgress->setEnabled(true);
361
362   // Set up the dock window corners to give the vertical docks more room.
363 //  desk->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
364 //  desk->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
365
366   // Setup the default dock configuration ...
367   statisticsViewDock->hide();
368   comparativePanelDock->hide();
369   animationViewDock->hide();
370   multiBlockInspectorPanelDock->hide();
371   selectionDisplayDock->hide();
372   collaborationPanelDock->hide();
373   memoryInspectorDock->hide();
374   colorMapEditorDock->hide();
375 }
376
377 /*!
378   \brief Save states of dockable ParaView widgets.
379 */
380 void PVGUI_Module::saveDockWidgetsState(bool hideWidgets)
381 {
382   SUIT_Desktop* desk = application()->desktop();
383
384   // VSR: 19/06/2011: do not use Paraview's methods, since it conflicts with SALOME GUI architecture
385   // ... the following code is commented...
386   // Save the state of the window ...
387   // pqApplicationCore::instance()->settings()->saveState(*desk, "MainWindow");
388   //
389   //for (int i = 0; i < myDockWidgets.size(); ++i)
390   //  myDockWidgets.at(i)->setParent(0);
391   // ... and replaced - manually hide dock windows
392
393   // store dock widgets visibility state and hide'em all
394   QMapIterator<QWidget*, bool> it1( myDockWidgets );
395   while( it1.hasNext() ) {
396     it1.next();
397     QDockWidget* dw = qobject_cast<QDockWidget*>( it1.key() );
398     myDockWidgets[dw] = dw->isVisible();
399     if ( hideWidgets ) {
400       dw->setVisible( false );
401       dw->toggleViewAction()->setVisible( false );
402     }
403   }
404   // store toolbar breaks state and remove all tollbar breaks 
405   QMapIterator<QWidget*, bool> it2( myToolbarBreaks );
406   while( it2.hasNext() ) {
407     it2.next();
408     QToolBar* tb = qobject_cast<QToolBar*>( it2.key() );
409     myToolbarBreaks[tb] = desk->toolBarBreak( tb );
410     if ( myToolbarBreaks[tb] && hideWidgets )
411       desk->removeToolBarBreak( tb );
412   }
413   // store toolbars visibility state and hide'em all
414   QMapIterator<QWidget*, bool> it3( myToolbars );
415   while( it3.hasNext() ) {
416     it3.next();
417     QToolBar* tb = qobject_cast<QToolBar*>( it3.key() );
418     myToolbars[tb] = tb->isVisible();
419     if ( hideWidgets ) {
420       tb->setVisible( false );
421       tb->toggleViewAction()->setVisible( false );
422     }
423   }
424 }
425
426 /*!
427   \brief Restore states of dockable ParaView widgets.
428 */
429 void PVGUI_Module::restoreDockWidgetsState()
430 {
431   SUIT_Desktop* desk = application()->desktop();
432
433   // VSR: 19/06/2011: do not use Paraview's methods, since it conflicts with SALOME GUI architecture
434   // ... the following code is commented...
435   //for (int i = 0; i < myDockWidgets.size(); ++i)
436   //  myDockWidgets.at(i)->setParent(desk);
437   //
438   // Restore the state of the window ...
439   //pqApplicationCore::instance()->settings()->restoreState("MainWindow", *desk);
440   // ... and replaced - manually hide dock windows
441
442   // restore dock widgets visibility state
443   QMapIterator<QWidget*, bool> it1( myDockWidgets );
444   while( it1.hasNext() ) {
445     it1.next();
446     QDockWidget* dw = qobject_cast<QDockWidget*>( it1.key() );
447     dw->setVisible( it1.value() );
448     dw->toggleViewAction()->setVisible( true );
449   }
450
451   // restore toolbar breaks state
452   QMapIterator<QWidget*, bool> it2( myToolbarBreaks );
453   while( it2.hasNext() ) {
454     it2.next();
455     QToolBar* tb = qobject_cast<QToolBar*>( it2.key() );
456     if ( myToolbarBreaks[tb] )
457       desk->insertToolBarBreak( tb );
458   }
459   
460   // restore toolbar visibility state
461   QMapIterator<QWidget*, bool> it3( myToolbars );
462   while( it3.hasNext() ) {
463     it3.next();
464     QToolBar* tb = qobject_cast<QToolBar*>( it3.key() );
465     tb->setVisible( it3.value() );
466     tb->toggleViewAction()->setVisible( true );
467   }
468 }
469
470
471
472 /*!
473   \brief Store visibility of the common dockable windows (OB, PyConsole, ... etc.)
474 */
475 void PVGUI_Module::storeCommonWindowsState() {  
476   //rnv: Make behaviour of the dockable windows and toolbars coherent with others
477   //     modules: if 'Save position of the windows' or 'Save position of the toolbars' 
478   //     in the General SALOME preferences are cheked, then properties of the windows and/or toolbars
479   //     are stored/restored using standard Qt saveState(...) and restoreState(...) methods.
480   //     Otherwise to the windows and toolbars applied default settins stored int the SalomeApp.xml
481   //     configuration file.
482   //
483   //     But in contrast to others modules ParaVis module default settings hide some dockable
484   //     windows, so to restore it at the moment of the ParaVis de-activation we call 
485   //     restoreCommonWindowsState() method, and at the moment of the ParaVis activation we call 
486   //     this method.
487
488   LightApp_Application* anApp = getApp();
489   if(!anApp)
490     return;
491
492   int begin = LightApp_Application::WT_ObjectBrowser;
493   int end = LightApp_Application::WT_User;
494   for( int i = begin; i <= end; i++ ) {
495     QWidget* wg = anApp->getWindow(i);
496     if(wg) {
497       QDockWidget* dock = 0;
498       QWidget* w = wg->parentWidget();
499       while ( w && !dock ) {
500         dock = ::qobject_cast<QDockWidget*>( w );
501         w = w->parentWidget();
502       }
503       if(dock){
504         if(!myCommonMap.contains(i)){
505           myCommonMap.insert(i,dock->isVisible());
506         } else {
507           myCommonMap[i] = dock->isVisible();
508         }
509       }
510     }
511   }
512 }
513
514 /*!
515   \brief Restore visibility of the common dockable windows (OB, PyConsole, ... etc.)
516 */
517 void PVGUI_Module::restoreCommonWindowsState() {
518   LightApp_Application* anApp = getApp();
519   if(!anApp)
520     return;
521   DockWindowMap::const_iterator it = myCommonMap.begin();
522   for( ;it != myCommonMap.end(); it++ ) {
523     QWidget* wg = anApp->getWindow(it.key());
524     if(wg) {
525       QDockWidget* dock = 0;
526       QWidget* w = wg->parentWidget();
527       while ( w && !dock ) {
528         dock = ::qobject_cast<QDockWidget*>( w );
529         w = w->parentWidget();
530       }
531       if(dock) {
532         dock->setVisible(it.value());
533       }
534     }
535   }
536 }