Salome HOME
Adding option to skip the connection to an external server.
[modules/paravis.git] / src / PVGUI / view / PVViewer_ViewWindow.cxx
1 // Copyright (C) 2010-2014  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File   : PVViewer_ViewWindow.cxx
20 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
21 //
22
23 #include "PVViewer_ViewWindow.h"
24 #include "PVViewer_ViewManager.h"
25
26 #include <SUIT_ViewManager.h>
27 #include <SUIT_ResourceMgr.h>
28 #include <SUIT_Session.h>
29 #include <SUIT_Desktop.h>
30
31 #include <pqTabbedMultiViewWidget.h>
32 #include <pqApplicationCore.h>
33
34 /*!
35   \class PVViewer_ViewWindow
36   \brief PVGUI view window.
37 */
38
39 /*!
40   \brief Constructor.
41   \param theDesktop parent desktop window
42   \param theModel view model
43 */
44 PVViewer_ViewWindow::PVViewer_ViewWindow( SUIT_Desktop* theDesktop, PVViewer_Viewer* theModel )
45   : SUIT_ViewWindow( theDesktop ), myPVMgr( 0 )
46 {
47   myModel = theModel;
48   myPVMgr = qobject_cast<pqTabbedMultiViewWidget*>(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET"));
49   if (myPVMgr) {
50     myPVMgr->setParent( this );
51     // This is mandatory, see setParent() method in Qt 4 documentation
52     myPVMgr->show();
53     setCentralWidget( myPVMgr );
54
55     // Finish ParaView set up: behaviors, connection and configurations.
56     // None of this is invoked in PARAVIS module case as it done earlier than View creation:
57     PVViewer_ViewManager::ParaviewInitBehaviors(true, theDesktop);
58     PVViewer_ViewManager::ConnectToExternalPVServer(theDesktop);
59     PVViewer_ViewManager::ParaviewLoadConfigurations();
60   } else
61     qDebug("No multiViewManager defined");
62 }
63
64 /*!
65   \brief Destructor.
66   As pqViewManager persists through the whole session,
67   the destructor first removes it from the children of this PVViewer_ViewWindow
68   to prevent its unexpected deletion.
69 */
70 PVViewer_ViewWindow::~PVViewer_ViewWindow()
71 {
72   if ( myPVMgr ) {
73     myPVMgr->setParent( 0 );
74     myPVMgr->hide();
75     myPVMgr = 0;
76     setCentralWidget( 0 );
77   }
78 }
79
80 /*!
81   \brief Get the visual parameters of the view window.
82   \return visual parameters of this view window formatted to the string
83 */
84 QString PVViewer_ViewWindow::getVisualParameters()
85 {
86   return SUIT_ViewWindow::getVisualParameters();
87 }
88
89 /*!
90   \brief Restore visual parameters of the view window from the formated string
91   \param parameters view window visual parameters
92 */
93 void PVViewer_ViewWindow::setVisualParameters( const QString& parameters )
94 {
95   SUIT_ViewWindow::setVisualParameters( parameters );
96 }
97
98
99 /*!
100   \brief Returns the ParaView multi-view manager previously set with setMultiViewManager()
101 */
102 pqTabbedMultiViewWidget* PVViewer_ViewWindow::getMultiViewManager() const
103 {
104   return myPVMgr;
105 }
106
107 void PVViewer_ViewWindow::onEmulateApply()
108 {
109   emit this->applyRequest();
110 }