Salome HOME
Merge from BR_PARAVIS_LOT1_2 24/02/2010
[modules/paravis.git] / src / PVGUI / PVGUI_Module_widgets.cxx
1 // PARAVIS : ParaView wrapper SALOME module
2 //
3 // Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : PVGUI_Module_MenuActions.cxx
23 // Author : Margarita KARPUNINA
24 //
25
26 #include "PVGUI_Module_impl.h"
27
28 #include <QtxActionToolMgr.h>
29 #include <LightApp_Application.h>
30 #include <SUIT_Desktop.h>
31
32 #include <QAction>
33 #include <QDockWidget>
34 #include <QToolBar>
35 #include <QStatusBar>
36 #include <QShortcut>
37
38 #include <pqAnimationViewWidget.h> //VSV
39
40 #include <pqApplicationCore.h>
41 #include <pqComparativeVisPanel.h>
42 #include <pqObjectInspectorWidget.h>
43 #include <pqPipelineBrowserWidget.h>
44 #include <pqProxyTabWidget.h>
45 #include <pqSettings.h>
46 #include <pqDataInformationWidget.h>
47 #include <pqPVAnimationWidget.h>
48 #include <pqSelectionInspectorPanel.h>
49 #include <pqProgressWidget.h>
50
51 #include <pqAlwaysConnectedBehavior.h>
52 #include <pqApplicationCore.h>
53 #include <pqAutoLoadPluginXMLBehavior.h>
54 #include <pqCommandLineOptionsBehavior.h>
55 #include <pqCrashRecoveryBehavior.h>
56 #include <pqDataTimeStepBehavior.h>
57 #include <pqDefaultViewBehavior.h>
58 #include <pqDeleteBehavior.h>
59 #include <pqPersistentMainWindowStateBehavior.h>
60 #include <pqPluginActionGroupBehavior.h>
61 #include <pqPluginDockWidgetsBehavior.h>
62 #include <pqPluginManager.h>
63 #include <pqPVNewSourceBehavior.h>
64 #include <pqSpreadSheetVisibilityBehavior.h>
65 #include <pqStandardViewModules.h>
66 #include <pqUndoRedoBehavior.h>
67 #include <pqViewFrameActionsBehavior.h>
68 #include <pqParaViewMenuBuilders.h>
69
70 /*!
71   \brief Create dock widgets for ParaView widgets such as object inspector, pipeline browser, etc.
72   ParaView pqMainWIndowCore class is fully responsible for these dock widgets' contents.
73 */
74 void PVGUI_Module::setupDockWidgets()
75 {
76   SUIT_Desktop* desk = application()->desktop();
77
78   // Pipeline
79   QDockWidget* pipelineBrowserDock = new QDockWidget( tr( "TTL_PIPELINE_BROWSER" ), desk );
80   pipelineBrowserDock->setObjectName("pipelineBrowserDock");
81   pipelineBrowserDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
82   desk->addDockWidget( Qt::LeftDockWidgetArea, pipelineBrowserDock );
83   pqPipelineBrowserWidget* browser = new pqPipelineBrowserWidget(pipelineBrowserDock);
84   pqParaViewMenuBuilders::buildPipelineBrowserContextMenu(*browser);
85   pipelineBrowserDock->setWidget(browser);
86   myDockWidgets.append(pipelineBrowserDock);
87
88   //Object inspector
89   QDockWidget* objectInspectorDock = new QDockWidget( tr( "TTL_OBJECT_INSPECTOR" ), desk );
90   objectInspectorDock->setObjectName("objectInspectorDock");
91   objectInspectorDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
92   desk->addDockWidget( Qt::LeftDockWidgetArea, objectInspectorDock );
93   pqProxyTabWidget* proxyTab = new pqProxyTabWidget(objectInspectorDock);
94   proxyTab->setShowOnAccept(true);
95   objectInspectorDock->setWidget(proxyTab);
96   connect( proxyTab->getObjectInspector(), SIGNAL( helpRequested(QString) ),
97           this, SLOT( showHelpForProxy(QString) ) );
98   //connect( proxyTab->getObjectInspector(), SIGNAL( preaccept() ), this, SLOT( onPreAccept() ) );
99   //connect( proxyTab->getObjectInspector(), SIGNAL( postaccept() ), this, SLOT( onPostAccept() ) );
100   myDockWidgets.append(objectInspectorDock);
101
102   // Statistic View
103   QDockWidget* statisticsViewDock  = new QDockWidget( tr( "TTL_STATISTICS_VIEW" ), desk );
104   statisticsViewDock->setObjectName("statisticsViewDock");
105   statisticsViewDock->setAllowedAreas(Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|
106                                       Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
107   desk->addDockWidget( Qt::BottomDockWidgetArea, statisticsViewDock );
108   pqDataInformationWidget* aStatWidget = new pqDataInformationWidget(statisticsViewDock);
109   statisticsViewDock->setWidget(aStatWidget);
110   myDockWidgets.append(statisticsViewDock);
111
112   //Animation view
113   QDockWidget* animationViewDock     = new QDockWidget( tr( "TTL_ANIMATION_VIEW" ), desk );
114   animationViewDock->setObjectName("animationViewDock");
115   desk->addDockWidget( Qt::BottomDockWidgetArea, animationViewDock );
116   pqPVAnimationWidget* animation_panel = new pqPVAnimationWidget(animationViewDock);
117   animationViewDock->setWidget(animation_panel);
118   myDockWidgets.append(animationViewDock);
119
120   // Selection view
121   QDockWidget* selectionInspectorDock = new QDockWidget( tr( "TTL_SELECTION_INSPECTOR" ), desk );
122   selectionInspectorDock->setObjectName("selectionInspectorDock");
123   selectionInspectorDock->setAllowedAreas( Qt::AllDockWidgetAreas );
124   desk->addDockWidget( Qt::LeftDockWidgetArea, selectionInspectorDock );
125   pqSelectionInspectorPanel* aSelInspector = new pqSelectionInspectorPanel(selectionInspectorDock);
126   selectionInspectorDock->setWidget(aSelInspector);
127   myDockWidgets.append(selectionInspectorDock);
128
129   // Comparative View
130   QDockWidget* comparativePanelDock  = new QDockWidget( tr( "TTL_COMPARATIVE_VIEW_INSPECTOR" ), desk );
131   comparativePanelDock->setObjectName("comparativePanelDock");
132   desk->addDockWidget( Qt::LeftDockWidgetArea, comparativePanelDock );
133   pqComparativeVisPanel* cv_panel = new pqComparativeVisPanel( comparativePanelDock );
134   comparativePanelDock->setWidget(cv_panel);
135   myDockWidgets.append(comparativePanelDock);
136
137   // Setup the statusbar ...
138   pqProgressWidget* aProgress = new pqProgressWidget(desk->statusBar());
139   desk->statusBar()->addPermanentWidget(aProgress);
140   
141   // Set up the dock window corners to give the vertical docks more room.
142   desk->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
143   desk->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
144   
145   // Setup the default dock configuration ...
146   statisticsViewDock->hide();
147   comparativePanelDock->hide();
148   animationViewDock->hide();
149   selectionInspectorDock->hide();
150
151
152   // Setup quick-launch shortcuts.
153   QShortcut *ctrlSpace = new QShortcut(Qt::CTRL + Qt::Key_Space, desk);
154   QObject::connect(ctrlSpace, SIGNAL(activated()), pqApplicationCore::instance(), SLOT(quickLaunch()));
155   QShortcut *altSpace = new QShortcut(Qt::ALT + Qt::Key_Space, desk);
156   QObject::connect(altSpace, SIGNAL(activated()), pqApplicationCore::instance(), SLOT(quickLaunch()));
157
158 }
159
160 /*!
161   \brief Save states of dockable ParaView widgets.
162 */
163 void PVGUI_Module::saveDockWidgetsState()
164 {
165   SUIT_Desktop* desk = application()->desktop();
166
167   // Save the state of the window ...
168   pqApplicationCore::instance()->settings()->saveState(*desk, "MainWindow");
169
170   for (int i = 0; i < myDockWidgets.size(); ++i)
171     myDockWidgets.at(i)->setParent(0);
172 }
173
174 /*!
175   \brief Restore states of dockable ParaView widgets.
176 */
177 void PVGUI_Module::restoreDockWidgetsState()
178 {
179   SUIT_Desktop* desk = application()->desktop();
180
181   for (int i = 0; i < myDockWidgets.size(); ++i)
182     myDockWidgets.at(i)->setParent(desk);
183
184   // Restore the state of the window ...
185   pqApplicationCore::instance()->settings()->restoreState("MainWindow", *desk);
186 }