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