1 // PARAVIS : ParaView wrapper SALOME module
3 // Copyright (C) 2010-2014 CEA/DEN, EDF R&D
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.
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.
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
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : PVGUI_Module_MenuActions.cxx
22 // Author : Margarita KARPUNINA
25 #include "PVGUI_Module.h"
26 #include "PVViewer_ViewManager.h"
27 #include "PVViewer_GUIElements.h"
29 #include <QtxActionToolMgr.h>
30 #include <LightApp_Application.h>
31 #include <SalomeApp_Application.h> // // should ultimately be a LightApp only
32 #include <SUIT_Desktop.h>
34 #include <QApplication>
36 #include <QDockWidget>
40 #include <QScrollArea>
41 #include <QVBoxLayout>
43 #include <QToolButton>
45 #include <pqAnimationViewWidget.h>
46 #include <pqAnimationWidget.h>
48 #include <pqApplicationCore.h>
49 #include <pqComparativeVisPanel.h>
50 #include <pqPipelineBrowserWidget.h>
51 #include <pqProxyInformationWidget.h>
52 #include <pqSettings.h>
53 #include <pqDataInformationWidget.h>
54 #include <pqPVAnimationWidget.h>
55 #include <pqFindDataSelectionDisplayFrame.h>
56 #include <pqMultiBlockInspectorPanel.h>
57 #include <pqProgressWidget.h>
58 #include <pqProgressManager.h>
59 //#include <pqDisplayProxyEditorWidget.h>
60 #include <pqPropertiesPanel.h>
62 #include <pqApplicationCore.h>
63 #include <pqPluginManager.h>
64 #include <pqParaViewMenuBuilders.h>
65 #include <pqCollaborationPanel.h>
66 #include <pqMemoryInspectorPanel.h>
67 #include <pqColorMapEditor.h>
68 #include <pqDeleteReaction.h>
70 #include <vtkPVGeneralSettings.h>
73 \brief Create dock widgets for ParaView widgets such as object inspector, pipeline browser, etc.
74 ParaView pqMainWindowCore class is fully responsible for these dock widgets' contents.
75 ==> To update this function, see the reference set up of ParaView in Application/Paraview/ParaviewMainWindow.ui
77 void PVGUI_Module::setupDockWidgets()
79 SUIT_Desktop* desk = application()->desktop();
80 PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance(desk);
82 desk->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
83 desk->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
84 desk->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::North);
87 QDockWidget* pipelineBrowserDock = new QDockWidget( tr( "TTL_PIPELINE_BROWSER" ), desk );
88 pipelineBrowserDock->setObjectName("pipelineBrowserDock");
89 pipelineBrowserDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
90 desk->addDockWidget( Qt::LeftDockWidgetArea, pipelineBrowserDock );
91 pqPipelineBrowserWidget* browser = guiElements->getPipelineBrowserWidget();
92 pipelineBrowserDock->setWidget(browser);
93 myDockWidgets[pipelineBrowserDock] = true;
94 pipelineBrowserDock->hide();
96 // PROPERTIES, DISPLAY and VIEW:
97 // See ParaViewMainWindow.cxx - those three panels can be separated or grouped.
98 pqSettings *settings = pqApplicationCore::instance()->settings();
100 // Properties dock (previously called OBJECT_INSPECTOR)
101 QDockWidget* propertiesDock = new QDockWidget( tr( "TTL_OBJECT_INSPECTOR" ), desk );
102 propertiesDock->setObjectName("propertiesDock");
103 propertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea );
104 desk->addDockWidget( Qt::LeftDockWidgetArea, propertiesDock );
106 pqPropertiesPanel* propertiesPanel = guiElements->getPropertiesPanel();
107 propertiesDock->setWidget(propertiesPanel);
108 connect( propertiesPanel, SIGNAL( helpRequested(const QString&, const QString&) ), this, SLOT( showHelpForProxy(const QString&, const QString&) ) );
109 // hook delete to pqDeleteReaction.
110 QAction* tempDeleteAction = new QAction(this);
111 pqDeleteReaction* handler = new pqDeleteReaction(tempDeleteAction);
112 handler->connect(propertiesPanel, SIGNAL(deleteRequested(pqPipelineSource*)), SLOT(deleteSource(pqPipelineSource*)));
113 myDockWidgets[propertiesDock] = true;
114 propertiesDock->hide();
117 QDockWidget* displayPropertiesDock = new QDockWidget( tr( "TTL_DISPLAY" ), desk );
118 displayPropertiesDock->setObjectName("displayPropertiesDock");
119 displayPropertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea );
120 desk->addDockWidget( Qt::LeftDockWidgetArea, displayPropertiesDock );
122 pqPropertiesPanel* displayPropertiesPanel = new pqPropertiesPanel();
123 displayPropertiesPanel->setObjectName("displayPropertiesPanel");
124 displayPropertiesPanel->setProperty("panelMode", QVariant(2)); // probably to have only the Display part
125 displayPropertiesDock->setWidget(displayPropertiesPanel);
126 myDockWidgets[displayPropertiesDock] = false;
127 displayPropertiesDock->hide();
130 QDockWidget* viewPropertiesDock = new QDockWidget( tr( "TTL_VIEW_PANEL" ), desk );
131 viewPropertiesDock->setObjectName("viewPropertiesDock");
132 viewPropertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea );
133 desk->addDockWidget( Qt::LeftDockWidgetArea, viewPropertiesDock );
135 pqPropertiesPanel* viewPropertiesPanel = new pqPropertiesPanel();
136 viewPropertiesPanel->setObjectName("viewPropertiesPanel");
137 viewPropertiesPanel->setProperty("panelMode", QVariant(4)); // probably to have only the View part
138 viewPropertiesDock->setWidget(viewPropertiesPanel);
139 myDockWidgets[viewPropertiesDock] = false;
140 viewPropertiesDock->hide();
142 // Taken from ParaViewMainWindow.cxx:
143 int propertiesPanelMode = settings->value(
144 "GeneralSettings.PropertiesPanelMode", vtkPVGeneralSettings::ALL_IN_ONE).toInt();
145 switch (propertiesPanelMode)
147 case vtkPVGeneralSettings::SEPARATE_DISPLAY_PROPERTIES:
148 viewPropertiesDock->hide();
149 propertiesPanel->setPanelMode(
150 pqPropertiesPanel::SOURCE_PROPERTIES|pqPropertiesPanel::VIEW_PROPERTIES);
153 case vtkPVGeneralSettings::SEPARATE_VIEW_PROPERTIES:
154 displayPropertiesDock->hide();
155 propertiesPanel->setPanelMode(
156 pqPropertiesPanel::SOURCE_PROPERTIES|pqPropertiesPanel::DISPLAY_PROPERTIES);
159 case vtkPVGeneralSettings::ALL_SEPARATE:
160 propertiesPanel->setPanelMode(pqPropertiesPanel::SOURCE_PROPERTIES);
163 case vtkPVGeneralSettings::ALL_IN_ONE:
165 propertiesPanel->setPanelMode(
166 pqPropertiesPanel::SOURCE_PROPERTIES|pqPropertiesPanel::VIEW_PROPERTIES|pqPropertiesPanel::DISPLAY_PROPERTIES);
167 viewPropertiesDock->hide();
168 displayPropertiesDock->hide();
173 QDockWidget* informationDock = new QDockWidget(tr( "TTL_INFORMATION" ), desk);
174 informationDock->setObjectName("informationDock");
176 QWidget* informationWidgetFrame = new QWidget(informationDock);
177 informationWidgetFrame->setObjectName("informationWidgetFrame");
179 QVBoxLayout* verticalLayout_2 = new QVBoxLayout(informationWidgetFrame);
180 verticalLayout_2->setSpacing(0);
181 verticalLayout_2->setContentsMargins(0, 0, 0, 0);
183 QScrollArea* informationScrollArea = new QScrollArea(informationWidgetFrame);
184 informationScrollArea->setObjectName("informationScrollArea") ;
185 informationScrollArea->setWidgetResizable(true);
187 pqProxyInformationWidget* informationWidget = new pqProxyInformationWidget();
188 informationWidget->setObjectName("informationWidget");
189 informationWidget->setGeometry(QRect(0, 0, 77, 214));
190 informationScrollArea->setWidget(informationWidget);
192 verticalLayout_2->addWidget(informationScrollArea);
193 informationDock->setWidget(informationWidgetFrame);
195 myDockWidgets[informationDock] = true;
197 desk->tabifyDockWidget(propertiesDock, viewPropertiesDock);
198 desk->tabifyDockWidget(propertiesDock, displayPropertiesDock);
199 desk->tabifyDockWidget(propertiesDock, informationDock);
200 propertiesDock->raise();
203 QDockWidget* statisticsViewDock = new QDockWidget( tr( "TTL_STATISTICS_VIEW" ), desk );
204 statisticsViewDock->setObjectName("statisticsViewDock");
205 statisticsViewDock->setAllowedAreas(Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|
206 Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
207 desk->addDockWidget( Qt::BottomDockWidgetArea, statisticsViewDock );
208 pqDataInformationWidget* aStatWidget = new pqDataInformationWidget(statisticsViewDock);
209 statisticsViewDock->setWidget(aStatWidget);
210 myDockWidgets[statisticsViewDock] = false; // hidden by default
213 QDockWidget* animationViewDock = new QDockWidget( tr( "TTL_ANIMATION_VIEW" ), desk );
214 animationViewDock->setObjectName("animationViewDock");
215 desk->addDockWidget( Qt::BottomDockWidgetArea, animationViewDock );
216 pqPVAnimationWidget* animation_panel = new pqPVAnimationWidget(animationViewDock); // [ABN] was resizeHelper
217 animationViewDock->setWidget(animation_panel);
218 myDockWidgets[animationViewDock] = false; // hidden by default
220 desk->tabifyDockWidget(animationViewDock, statisticsViewDock);
222 // Selection inspector
223 QDockWidget* selectionDisplayDock = new QDockWidget( tr( "TTL_SELECTION_INSPECTOR" ), desk );
224 selectionDisplayDock->setObjectName("selectionInspectorDock");
225 selectionDisplayDock->setAllowedAreas( Qt::AllDockWidgetAreas );
226 desk->addDockWidget( Qt::LeftDockWidgetArea, selectionDisplayDock );
227 pqFindDataSelectionDisplayFrame* aSelInspector = new pqFindDataSelectionDisplayFrame(selectionDisplayDock);
228 selectionDisplayDock->setWidget(aSelInspector);
229 myDockWidgets[selectionDisplayDock] = false; // hidden by default
231 // Multi-block inspector
232 QDockWidget* multiBlockInspectorPanelDock = new QDockWidget( tr( "TTL_MUTLI_BLOCK_INSPECTOR" ), desk );
233 multiBlockInspectorPanelDock->setObjectName("multiBlockInspectorPanelDock");
234 desk->addDockWidget( Qt::LeftDockWidgetArea, multiBlockInspectorPanelDock );
235 pqMultiBlockInspectorPanel* mbi_panel = new pqMultiBlockInspectorPanel( multiBlockInspectorPanelDock );
236 multiBlockInspectorPanelDock->setWidget(mbi_panel);
237 myDockWidgets[multiBlockInspectorPanelDock] = false; // hidden by default
240 QDockWidget* comparativePanelDock = new QDockWidget( tr( "TTL_COMPARATIVE_VIEW_INSPECTOR" ), desk );
241 comparativePanelDock->setObjectName("comparativePanelDock");
242 desk->addDockWidget( Qt::LeftDockWidgetArea, comparativePanelDock );
243 pqComparativeVisPanel* cv_panel = new pqComparativeVisPanel( comparativePanelDock );
244 comparativePanelDock->setWidget(cv_panel);
245 myDockWidgets[comparativePanelDock] = false; // hidden by default
247 // Collaboration view
248 QDockWidget* collaborationPanelDock = new QDockWidget(tr( "TTL_COLLABORATIVE_DOCK" ), desk);
249 collaborationPanelDock->setObjectName("collaborationPanelDock");
250 pqCollaborationPanel* collaborationPanel = new pqCollaborationPanel();
251 collaborationPanel->setObjectName("collaborationPanel");
252 collaborationPanelDock->setWidget(collaborationPanel);
253 desk->addDockWidget(Qt::RightDockWidgetArea, collaborationPanelDock);
254 myDockWidgets[collaborationPanelDock] = false; // hidden by default
257 QDockWidget* colorMapEditorDock = new QDockWidget( tr( "TTL_COLOR_MAP_EDITOR" ), desk );
258 colorMapEditorDock->setObjectName("colorMapEditorDock");
259 desk->addDockWidget( Qt::LeftDockWidgetArea, colorMapEditorDock );
260 pqColorMapEditor* cmed_panel = new pqColorMapEditor( colorMapEditorDock );
261 colorMapEditorDock->setWidget(cmed_panel);
262 myDockWidgets[colorMapEditorDock] = false; // hidden by default
264 // Provide access to the color-editor panel for the application.
265 pqApplicationCore::instance()->registerManager(
266 "COLOR_EDITOR_PANEL", colorMapEditorDock);
268 // Memory inspector dock
269 QDockWidget* memoryInspectorDock = new QDockWidget(tr( "TTL_MEMORY_INSPECTOR" ), desk);
270 memoryInspectorDock->setObjectName("memoryInspectorDock");
272 pqMemoryInspectorPanel* dockWidgetContents = new pqMemoryInspectorPanel();
273 dockWidgetContents->setObjectName("dockWidgetContents");
274 memoryInspectorDock->setWidget(dockWidgetContents);
276 desk->addDockWidget(Qt::RightDockWidgetArea, memoryInspectorDock);
277 myDockWidgets[memoryInspectorDock] = false; // hidden by default
279 // Setup the statusbar ...
280 pqProgressManager* progress_manager =
281 pqApplicationCore::instance()->getProgressManager();
283 // Progress bar/button management
284 pqProgressWidget* aProgress = new pqProgressWidget(desk->statusBar());
285 progress_manager->addNonBlockableObject(aProgress);
286 progress_manager->addNonBlockableObject(aProgress->getAbortButton());
288 QObject::connect( progress_manager, SIGNAL(enableProgress(bool)),
289 aProgress, SLOT(enableProgress(bool)));
291 QObject::connect( progress_manager, SIGNAL(progress(const QString&, int)),
292 aProgress, SLOT(setProgress(const QString&, int)));
294 QObject::connect( progress_manager, SIGNAL(enableAbort(bool)),
295 aProgress, SLOT(enableAbort(bool)));
297 QObject::connect( aProgress, SIGNAL(abortPressed()),
298 progress_manager, SLOT(triggerAbort()));
300 desk->statusBar()->addPermanentWidget(aProgress);
301 aProgress->setEnabled(true);
303 // Set up the dock window corners to give the vertical docks more room.
304 // desk->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
305 // desk->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
307 // Setup the default dock configuration ...
308 statisticsViewDock->hide();
309 comparativePanelDock->hide();
310 animationViewDock->hide();
311 multiBlockInspectorPanelDock->hide();
312 selectionDisplayDock->hide();
313 collaborationPanelDock->hide();
314 memoryInspectorDock->hide();
315 colorMapEditorDock->hide();
319 \brief Save states of dockable ParaView widgets.
321 void PVGUI_Module::saveDockWidgetsState()
323 SUIT_Desktop* desk = application()->desktop();
325 // VSR: 19/06/2011: do not use Paraview's methods, since it conflicts with SALOME GUI architecture
326 // ... the following code is commented...
327 // Save the state of the window ...
328 // pqApplicationCore::instance()->settings()->saveState(*desk, "MainWindow");
330 //for (int i = 0; i < myDockWidgets.size(); ++i)
331 // myDockWidgets.at(i)->setParent(0);
332 // ... and replaced - manually hide dock windows
334 // store dock widgets visibility state and hide'em all
335 QMapIterator<QWidget*, bool> it1( myDockWidgets );
336 while( it1.hasNext() ) {
338 QDockWidget* dw = qobject_cast<QDockWidget*>( it1.key() );
339 myDockWidgets[dw] = dw->isVisible();
340 dw->setVisible( false );
341 dw->toggleViewAction()->setVisible( false );
343 // store toolbar breaks state and remove all tollbar breaks
344 QMapIterator<QWidget*, bool> it2( myToolbarBreaks );
345 while( it2.hasNext() ) {
347 QToolBar* tb = qobject_cast<QToolBar*>( it2.key() );
348 myToolbarBreaks[tb] = desk->toolBarBreak( tb );
349 if ( myToolbarBreaks[tb] )
350 desk->removeToolBarBreak( tb );
352 // store toolbars visibility state and hide'em all
353 QMapIterator<QWidget*, bool> it3( myToolbars );
354 while( it3.hasNext() ) {
356 QToolBar* tb = qobject_cast<QToolBar*>( it3.key() );
357 myToolbars[tb] = tb->isVisible();
358 tb->setVisible( false );
359 tb->toggleViewAction()->setVisible( false );
364 \brief Restore states of dockable ParaView widgets.
366 void PVGUI_Module::restoreDockWidgetsState()
368 SUIT_Desktop* desk = application()->desktop();
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 //for (int i = 0; i < myDockWidgets.size(); ++i)
373 // myDockWidgets.at(i)->setParent(desk);
375 // Restore the state of the window ...
376 //pqApplicationCore::instance()->settings()->restoreState("MainWindow", *desk);
377 // ... and replaced - manually hide dock windows
379 // restore dock widgets visibility state
380 QMapIterator<QWidget*, bool> it1( myDockWidgets );
381 while( it1.hasNext() ) {
383 QDockWidget* dw = qobject_cast<QDockWidget*>( it1.key() );
384 dw->setVisible( it1.value() );
385 dw->toggleViewAction()->setVisible( true );
388 // restore toolbar breaks state
389 QMapIterator<QWidget*, bool> it2( myToolbarBreaks );
390 while( it2.hasNext() ) {
392 QToolBar* tb = qobject_cast<QToolBar*>( it2.key() );
393 if ( myToolbarBreaks[tb] )
394 desk->insertToolBarBreak( tb );
397 // restore toolbar visibility state
398 QMapIterator<QWidget*, bool> it3( myToolbars );
399 while( it3.hasNext() ) {
401 QToolBar* tb = qobject_cast<QToolBar*>( it3.key() );
402 tb->setVisible( it3.value() );
403 tb->toggleViewAction()->setVisible( true );
410 \brief Store visibility of the common dockable windows (OB, PyConsole, ... etc.)
412 void PVGUI_Module::storeCommonWindowsState() {
413 //rnv: Make behaviour of the dockable windows and toolbars coherent with others
414 // modules: if 'Save position of the windows' or 'Save position of the toolbars'
415 // in the General SALOME preferences are cheked, then properties of the windows and/or toolbars
416 // are stored/restored using standard Qt saveState(...) and restoreState(...) methods.
417 // Otherwise to the windows and toolbars applied default settins stored int the SalomeApp.xml
418 // configuration file.
420 // But in contrast to others modules ParaVis module default settings hide some dockable
421 // windows, so to restore it at the moment of the ParaVis de-activation we call
422 // restoreCommonWindowsState() method, and at the moment of the ParaVis activation we call
425 //LightApp_Application* anApp = getApp();
426 SalomeApp_Application* anApp = getApp();
430 // int begin = SalomeApp_Application::WT_ObjectBrowser;
431 // int end = SalomeApp_Application::WT_NoteBook;
432 int begin = LightApp_Application::WT_ObjectBrowser;
433 int end = LightApp_Application::WT_User;
434 for( int i = begin; i <= end; i++ ) {
435 QWidget* wg = anApp->getWindow(i);
437 QDockWidget* dock = 0;
438 QWidget* w = wg->parentWidget();
439 while ( w && !dock ) {
440 dock = ::qobject_cast<QDockWidget*>( w );
441 w = w->parentWidget();
444 if(!myCommonMap.contains(i)){
445 myCommonMap.insert(i,dock->isVisible());
447 myCommonMap[i] = dock->isVisible();
455 \brief Restore visibility of the common dockable windows (OB, PyConsole, ... etc.)
457 void PVGUI_Module::restoreCommonWindowsState() {
458 SalomeApp_Application* anApp = getApp();
459 // LightApp_Application* anApp = getApp();
462 DockWindowMap::const_iterator it = myCommonMap.begin();
463 for( ;it != myCommonMap.end(); it++ ) {
464 QWidget* wg = anApp->getWindow(it.key());
466 QDockWidget* dock = 0;
467 QWidget* w = wg->parentWidget();
468 while ( w && !dock ) {
469 dock = ::qobject_cast<QDockWidget*>( w );
470 w = w->parentWidget();
473 dock->setVisible(it.value());