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