Back to index

salome-paravis  6.5.0
PVGUI_Module_widgets.cxx
Go to the documentation of this file.
00001 // PARAVIS : ParaView wrapper SALOME module
00002 //
00003 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00018 //
00019 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00020 //
00021 // File   : PVGUI_Module_MenuActions.cxx
00022 // Author : Margarita KARPUNINA
00023 //
00024 
00025 #include "PVGUI_Module.h"
00026 
00027 #include <QtxActionToolMgr.h>
00028 #include <LightApp_Application.h>
00029 #include <SUIT_Desktop.h>
00030 
00031 #include <QAction>
00032 #include <QDockWidget>
00033 #include <QToolBar>
00034 #include <QStatusBar>
00035 #include <QShortcut>
00036 #include <QScrollArea>
00037 #include <QVBoxLayout>
00038 
00039 #include <pqAnimationViewWidget.h> 
00040 
00041 #include <pqApplicationCore.h>
00042 #include <pqComparativeVisPanel.h>
00043 #include <pqObjectInspectorWidget.h>
00044 #include <pqPipelineBrowserWidget.h>
00045 //#include <pqProxyTabWidget.h>
00046 #include <pqObjectInspectorWidget.h>
00047 #include <pqProxyInformationWidget.h>
00048 #include <pqDisplayProxyEditorWidget.h>
00049 #include <pqSettings.h>
00050 #include <pqDataInformationWidget.h>
00051 #include <pqPVAnimationWidget.h>
00052 #include <pqSelectionInspectorWidget.h>
00053 #include <pqProgressWidget.h>
00054 
00055 #include <pqAlwaysConnectedBehavior.h>
00056 #include <pqApplicationCore.h>
00057 #include <pqAutoLoadPluginXMLBehavior.h>
00058 #include <pqCommandLineOptionsBehavior.h>
00059 #include <pqCrashRecoveryBehavior.h>
00060 #include <pqDataTimeStepBehavior.h>
00061 #include <pqDefaultViewBehavior.h>
00062 #include <pqDeleteBehavior.h>
00063 #include <pqPersistentMainWindowStateBehavior.h>
00064 #include <pqPluginActionGroupBehavior.h>
00065 #include <pqPluginDockWidgetsBehavior.h>
00066 #include <pqPluginManager.h>
00067 #include <pqPVNewSourceBehavior.h>
00068 #include <pqSpreadSheetVisibilityBehavior.h>
00069 #include <pqStandardViewModules.h>
00070 #include <pqUndoRedoBehavior.h>
00071 #include <pqViewFrameActionsBehavior.h>
00072 #include <pqParaViewMenuBuilders.h>
00073 #include <pqCollaborationPanel.h>
00074 #include <pqMemoryInspector.h>
00075 
00080 void PVGUI_Module::setupDockWidgets()
00081 {
00082   SUIT_Desktop* desk = application()->desktop();
00083  
00084   desk->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
00085   desk->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
00086 
00087   // Pipeline
00088   QDockWidget* pipelineBrowserDock = new QDockWidget( tr( "TTL_PIPELINE_BROWSER" ), desk );
00089   pipelineBrowserDock->setObjectName("pipelineBrowserDock");
00090   pipelineBrowserDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
00091   desk->addDockWidget( Qt::LeftDockWidgetArea, pipelineBrowserDock );
00092   pqPipelineBrowserWidget* browser = new pqPipelineBrowserWidget(pipelineBrowserDock);
00093   pqParaViewMenuBuilders::buildPipelineBrowserContextMenu(*browser);
00094   pipelineBrowserDock->setWidget(browser);
00095   myDockWidgets[pipelineBrowserDock] = true;
00096 
00097 
00098   
00099 
00100   //Object inspector
00101   QDockWidget* objectInspectorDock = new QDockWidget( tr( "TTL_OBJECT_INSPECTOR" ), desk );
00102   objectInspectorDock->setObjectName("objectInspectorDock");
00103   objectInspectorDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
00104   desk->addDockWidget( Qt::LeftDockWidgetArea, objectInspectorDock );
00105 
00106   pqObjectInspectorWidget* objectInspectorWidget = new pqObjectInspectorWidget(objectInspectorDock);
00107   objectInspectorDock->setObjectName("objectInspectorWidget");
00108   objectInspectorWidget->setShowOnAccept(true);
00109   objectInspectorDock->setWidget(objectInspectorWidget);
00110   connect( objectInspectorWidget, SIGNAL( helpRequested(const QString&, const QString&) ),  this, SLOT( showHelpForProxy(const QString&, const QString&) ) );
00111   myDockWidgets[objectInspectorDock] = true;
00112 
00113   //Display Dock
00114   QDockWidget* displayDock = new QDockWidget( tr( "TTL_DISPLAY" ), desk );
00115   displayDock->setObjectName("displayDock");
00116   QWidget* displayWidgetFrame = new QWidget(displayDock);
00117   displayWidgetFrame->setObjectName("displayWidgetFrame");
00118   displayDock->setWidget(displayWidgetFrame);
00119 
00120   QScrollArea* displayScrollArea = new QScrollArea(displayWidgetFrame);
00121   displayScrollArea->setObjectName("displayScrollArea");
00122   displayScrollArea->setWidgetResizable(true);
00123 
00124   QVBoxLayout* verticalLayout = new QVBoxLayout(displayWidgetFrame);
00125   verticalLayout->setSpacing(0);
00126   verticalLayout->setContentsMargins(0, 0, 0, 0);
00127 
00128   pqDisplayProxyEditorWidget* displayWidget = new pqDisplayProxyEditorWidget(displayDock);
00129   displayWidget->setObjectName("displayWidget");
00130   displayScrollArea->setWidget(displayWidget);
00131   verticalLayout->addWidget(displayScrollArea);
00132 
00133   myDockWidgets[displayDock] = true;
00134 
00135   // information dock
00136   QDockWidget* informationDock = new QDockWidget(tr( "TTL_INFORMATION" ), desk);
00137   informationDock->setObjectName("informationDock");
00138 
00139   QWidget* informationWidgetFrame = new QWidget(informationDock);
00140   informationWidgetFrame->setObjectName("informationWidgetFrame");
00141   
00142   QVBoxLayout* verticalLayout_2 = new QVBoxLayout(informationWidgetFrame);
00143   verticalLayout_2->setSpacing(0);
00144   verticalLayout_2->setContentsMargins(0, 0, 0, 0);
00145 
00146   QScrollArea* informationScrollArea = new QScrollArea(informationWidgetFrame);
00147   informationScrollArea->setObjectName("informationScrollArea") ;
00148   informationScrollArea->setWidgetResizable(true);
00149 
00150   pqProxyInformationWidget* informationWidget = new pqProxyInformationWidget();
00151   informationWidget->setObjectName("informationWidget");
00152   informationWidget->setGeometry(QRect(0, 0, 77, 214));
00153   informationScrollArea->setWidget(informationWidget);
00154 
00155   verticalLayout_2->addWidget(informationScrollArea);
00156   informationDock->setWidget(informationWidgetFrame);
00157 
00158   myDockWidgets[informationDock] = true;
00159 
00160   desk->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::North);
00161   desk->tabifyDockWidget(objectInspectorDock, displayDock);
00162   desk->tabifyDockWidget(objectInspectorDock, informationDock);
00163   objectInspectorDock->raise();
00164 
00165   // Statistic View
00166   QDockWidget* statisticsViewDock  = new QDockWidget( tr( "TTL_STATISTICS_VIEW" ), desk );
00167   statisticsViewDock->setObjectName("statisticsViewDock");
00168   statisticsViewDock->setAllowedAreas(Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|
00169                                       Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
00170   desk->addDockWidget( Qt::BottomDockWidgetArea, statisticsViewDock );
00171   pqDataInformationWidget* aStatWidget = new pqDataInformationWidget(statisticsViewDock);
00172   statisticsViewDock->setWidget(aStatWidget);
00173   myDockWidgets[statisticsViewDock] = false; // hidden by default
00174 
00175   //Animation view
00176   QDockWidget* animationViewDock     = new QDockWidget( tr( "TTL_ANIMATION_VIEW" ), desk );
00177   animationViewDock->setObjectName("animationViewDock");
00178   desk->addDockWidget( Qt::BottomDockWidgetArea, animationViewDock );
00179   pqPVAnimationWidget* animation_panel = new pqPVAnimationWidget(animationViewDock);
00180   animationViewDock->setWidget(animation_panel);
00181   myDockWidgets[animationViewDock] = false; // hidden by default
00182 
00183   desk->tabifyDockWidget(animationViewDock,  statisticsViewDock);
00184 
00185   // Selection view
00186   QDockWidget* selectionInspectorDock = new QDockWidget( tr( "TTL_SELECTION_INSPECTOR" ), desk );
00187   selectionInspectorDock->setObjectName("selectionInspectorDock");
00188   selectionInspectorDock->setAllowedAreas( Qt::AllDockWidgetAreas );
00189   desk->addDockWidget( Qt::LeftDockWidgetArea, selectionInspectorDock );
00190   pqSelectionInspectorPanel* aSelInspector = new pqSelectionInspectorWidget(selectionInspectorDock);
00191   selectionInspectorDock->setWidget(aSelInspector);
00192   myDockWidgets[selectionInspectorDock] = false; // hidden by default
00193 
00194   // Comparative View
00195   QDockWidget* comparativePanelDock  = new QDockWidget( tr( "TTL_COMPARATIVE_VIEW_INSPECTOR" ), desk );
00196   comparativePanelDock->setObjectName("comparativePanelDock");
00197   desk->addDockWidget( Qt::LeftDockWidgetArea, comparativePanelDock );
00198   pqComparativeVisPanel* cv_panel = new pqComparativeVisPanel( comparativePanelDock );
00199   comparativePanelDock->setWidget(cv_panel);
00200   myDockWidgets[comparativePanelDock] = false; // hidden by default
00201 
00202   // Collaboration view
00203   QDockWidget* collaborationPanelDock = new QDockWidget(tr( "TTL_COLLABORATIVE_DOCK" ), desk);
00204   collaborationPanelDock->setObjectName("collaborationPanelDock");
00205   pqCollaborationPanel* collaborationPanel = new pqCollaborationPanel();
00206   collaborationPanel->setObjectName("collaborationPanel");
00207   collaborationPanelDock->setWidget(collaborationPanel);
00208   desk->addDockWidget(Qt::RightDockWidgetArea, collaborationPanelDock);
00209   myDockWidgets[collaborationPanelDock] = false; // hidden by default
00210   
00211   // Memory inspector dock
00212   QDockWidget* memoryInspectorDock = new QDockWidget(tr( "TTL_MEMORY_INSPECTOR" ), desk);
00213   memoryInspectorDock->setObjectName("memoryInspectorDock");
00214   pqMemoryInspector* dockWidgetContents = new pqMemoryInspector();
00215   dockWidgetContents->setObjectName("dockWidgetContents");
00216   memoryInspectorDock->setWidget(dockWidgetContents);
00217   desk->addDockWidget(Qt::RightDockWidgetArea, memoryInspectorDock);
00218   myDockWidgets[memoryInspectorDock] = false; // hidden by default
00219 
00220 
00221   // Setup the statusbar ...
00222   pqProgressWidget* aProgress = new pqProgressWidget(desk->statusBar());
00223   desk->statusBar()->addPermanentWidget(aProgress);
00224   
00225   // Set up the dock window corners to give the vertical docks more room.
00226   desk->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
00227   desk->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
00228   
00229   // Setup the default dock configuration ...
00230   statisticsViewDock->hide();
00231   comparativePanelDock->hide();
00232   animationViewDock->hide();
00233   selectionInspectorDock->hide();
00234   collaborationPanelDock->hide();
00235   memoryInspectorDock->hide();
00236 
00237 
00238   // Setup quick-launch shortcuts.
00239   QShortcut *ctrlSpace = new QShortcut(Qt::CTRL + Qt::Key_Space, desk);
00240   QObject::connect(ctrlSpace, SIGNAL(activated()), pqApplicationCore::instance(), SLOT(quickLaunch()));
00241   QShortcut *altSpace = new QShortcut(Qt::ALT + Qt::Key_Space, desk);
00242   QObject::connect(altSpace, SIGNAL(activated()), pqApplicationCore::instance(), SLOT(quickLaunch()));
00243 
00244 }
00245 
00249 void PVGUI_Module::saveDockWidgetsState()
00250 {
00251   SUIT_Desktop* desk = application()->desktop();
00252 
00253   // VSR: 19/06/2011: do not use Paraview's methods, since it conflicts with SALOME GUI architecture
00254   // ... the following code is commented...
00255   // Save the state of the window ...
00256   // pqApplicationCore::instance()->settings()->saveState(*desk, "MainWindow");
00257   //
00258   //for (int i = 0; i < myDockWidgets.size(); ++i)
00259   //  myDockWidgets.at(i)->setParent(0);
00260   // ... and replaced - manually hide dock windows
00261 
00262   // store dock widgets visibility state and hide'em all
00263   QMapIterator<QWidget*, bool> it1( myDockWidgets );
00264   while( it1.hasNext() ) {
00265     it1.next();
00266     QDockWidget* dw = qobject_cast<QDockWidget*>( it1.key() );
00267     myDockWidgets[dw] = dw->isVisible();
00268     dw->setVisible( false );
00269     dw->toggleViewAction()->setVisible( false );
00270   }
00271   // store toolbar breaks state and remove all tollbar breaks 
00272   QMapIterator<QWidget*, bool> it2( myToolbarBreaks );
00273   while( it2.hasNext() ) {
00274     it2.next();
00275     QToolBar* tb = qobject_cast<QToolBar*>( it2.key() );
00276     myToolbarBreaks[tb] = desk->toolBarBreak( tb );
00277     if ( myToolbarBreaks[tb] )
00278       desk->removeToolBarBreak( tb );
00279   }
00280   // store toolbars visibility state and hide'em all
00281   QMapIterator<QWidget*, bool> it3( myToolbars );
00282   while( it3.hasNext() ) {
00283     it3.next();
00284     QToolBar* tb = qobject_cast<QToolBar*>( it3.key() );
00285     myToolbars[tb] = tb->isVisible();
00286     tb->setVisible( false );
00287     tb->toggleViewAction()->setVisible( false );
00288   }
00289 }
00290 
00294 void PVGUI_Module::restoreDockWidgetsState()
00295 {
00296   SUIT_Desktop* desk = application()->desktop();
00297 
00298   // VSR: 19/06/2011: do not use Paraview's methods, since it conflicts with SALOME GUI architecture
00299   // ... the following code is commented...
00300   //for (int i = 0; i < myDockWidgets.size(); ++i)
00301   //  myDockWidgets.at(i)->setParent(desk);
00302   //
00303   // Restore the state of the window ...
00304   //pqApplicationCore::instance()->settings()->restoreState("MainWindow", *desk);
00305   // ... and replaced - manually hide dock windows
00306 
00307   // restore dock widgets visibility state
00308   QMapIterator<QWidget*, bool> it1( myDockWidgets );
00309   while( it1.hasNext() ) {
00310     it1.next();
00311     QDockWidget* dw = qobject_cast<QDockWidget*>( it1.key() );
00312     dw->setVisible( it1.value() );
00313     dw->toggleViewAction()->setVisible( true );
00314   }
00315   // restore toolbar breaks state
00316   QMapIterator<QWidget*, bool> it2( myToolbarBreaks );
00317   while( it2.hasNext() ) {
00318     it2.next();
00319     QToolBar* tb = qobject_cast<QToolBar*>( it2.key() );
00320     if ( myToolbarBreaks[tb] )
00321       desk->insertToolBarBreak( tb );
00322   }
00323   // restore toolbar visibility state
00324   QMapIterator<QWidget*, bool> it3( myToolbars );
00325   while( it3.hasNext() ) {
00326     it3.next();
00327     QToolBar* tb = qobject_cast<QToolBar*>( it3.key() );
00328     tb->setVisible( it3.value() );
00329     tb->toggleViewAction()->setVisible( true );
00330   }
00331 }