1 // Copyright (C) 2010-2016 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author: Adrien Bruneton (CEA)
23 #include "PVViewer_GUIElements.h"
24 #include "PVViewer_Core.h"
26 #include <pqPVApplicationCore.h>
27 #include <pqActiveObjects.h>
28 #include <pqObjectBuilder.h>
30 #include <pqPropertiesPanel.h>
31 #include <pqPipelineBrowserWidget.h>
32 #include <pqTabbedMultiViewWidget.h>
33 #include <pqParaViewMenuBuilders.h>
34 #include <pqMainControlsToolbar.h>
35 #include <pqVCRToolbar.h>
36 #include <pqAnimationTimeToolbar.h>
37 #include <pqColorToolbar.h>
38 #include <pqRepresentationToolbar.h>
39 #include <pqCameraToolbar.h>
40 #include <pqAxesToolbar.h>
41 #include <pqSetName.h>
43 #include <pqPythonManager.h>
44 #include <pqApplicationCore.h>
46 #include <QMainWindow>
53 #include <QCoreApplication>
55 PVViewer_GUIElements * PVViewer_GUIElements::theInstance = 0;
57 PVViewer_GUIElements::PVViewer_GUIElements(QMainWindow* desk) :
58 propertiesPanel(0), pipelineBrowserWidget(0),
61 propertiesPanel = new pqPropertiesPanel(desk);
62 propertiesPanel->hide();
63 pipelineBrowserWidget = new pqPipelineBrowserWidget(desk);
64 pipelineBrowserWidget->hide();
66 sourcesMenu = new QMenu(0);
67 pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, desk);
68 filtersMenu = new QMenu(0);
69 pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk);
70 macrosMenu = new QMenu(0);
71 pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
73 //myBuildToolbars(desk);
76 PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(QMainWindow* desk)
79 theInstance = new PVViewer_GUIElements(desk);
84 pqTabbedMultiViewWidget * PVViewer_GUIElements::getTabbedMultiViewWidget()
86 pqTabbedMultiViewWidget * multiv =
87 qobject_cast<pqTabbedMultiViewWidget*>(PVViewer_Core::GetPVApplication()->manager("MULTIVIEW_WIDGET"));
89 // If not found, instanciate it. It will then register automatically as a MULTIVIEW_WIDGET.
90 // Also create a single view that will be attached by the tabbedMultiView automatically
91 // (in PV this is done automatically upon server connection event).
94 multiv = new pqTabbedMultiViewWidget();
96 // Create a new view proxy on the server
97 pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder();
98 pqServer* active_serv = pqActiveObjects::instance().activeServer();
99 pqView * pqview = builder->createView(QString("RenderView"), active_serv);
107 * See ParaView source code: pqParaViewMenuBuilders::buildToolbars()
108 * to keep this function up to date:
110 void PVViewer_GUIElements::myBuildToolbars(QMainWindow* mainWindow)
112 mainToolBar = new pqMainControlsToolbar(mainWindow)
113 << pqSetName("MainControlsToolbar");
114 mainToolBar->layout()->setSpacing(0);
116 vcrToolbar = new pqVCRToolbar(mainWindow)
117 << pqSetName("VCRToolbar");
118 vcrToolbar->layout()->setSpacing(0);
120 timeToolbar = new pqAnimationTimeToolbar(mainWindow)
121 << pqSetName("currentTimeToolbar");
122 timeToolbar->layout()->setSpacing(0);
124 colorToolbar = new pqColorToolbar(mainWindow)
125 << pqSetName("variableToolbar");
126 colorToolbar->layout()->setSpacing(0);
128 reprToolbar = new pqRepresentationToolbar(mainWindow)
129 << pqSetName("representationToolbar");
130 reprToolbar->layout()->setSpacing(0);
132 cameraToolbar = new pqCameraToolbar(mainWindow)
133 << pqSetName("cameraToolbar");
134 cameraToolbar->layout()->setSpacing(0);
136 axesToolbar = new pqAxesToolbar(mainWindow)
137 << pqSetName("axesToolbar");
138 axesToolbar->layout()->setSpacing(0);
140 // Give the macros menu to the pqPythonMacroSupervisor
141 pqPythonManager* manager = qobject_cast<pqPythonManager*>(
142 pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
144 macrosToolbar = new QToolBar("Macros Toolbars", mainWindow)
145 << pqSetName("MacrosToolbar");
146 manager->addWidgetForRunMacros(macrosToolbar);
148 commonToolbar = new QToolBar("Common", mainWindow) << pqSetName("Common");
149 commonToolbar->layout()->setSpacing(0);
151 dataToolbar = new QToolBar("DataAnalysis", mainWindow) << pqSetName("DataAnalysis");
152 dataToolbar->layout()->setSpacing(0);
154 //addToolbars(mainWindow);
157 void PVViewer_GUIElements::setToolBarVisible(bool show)
159 QCoreApplication::processEvents();
160 mainAction->setChecked(!show);
161 mainAction->setVisible(show);
162 mainAction->trigger();
163 vcrAction->setChecked(!show);
164 vcrAction->setVisible(show);
165 vcrAction->trigger();
166 timeAction->setChecked(!show);
167 timeAction->setVisible(show);
168 timeAction->trigger();
169 colorAction->setChecked(!show);
170 colorAction->setVisible(show);
171 colorAction->trigger();
172 reprAction->setChecked(!show);
173 reprAction->setVisible(show);
174 reprAction->trigger();
175 cameraAction->setChecked(!show);
176 cameraAction->setVisible(show);
177 cameraAction->trigger();
178 axesAction->setChecked(!show);
179 axesAction->setVisible(show);
180 axesAction->trigger();
181 macrosAction->setChecked(!show);
182 macrosAction->setVisible(show);
183 macrosAction->trigger();
184 commonAction->setChecked(!show);
185 commonAction->setVisible(show);
186 commonAction->trigger();
187 dataAction->setChecked(!show);
188 dataAction->setVisible(show);
189 dataAction->trigger();
192 void PVViewer_GUIElements::addToolbars(QMainWindow* desk)
194 desk->addToolBar(Qt::TopToolBarArea, mainToolBar);
195 desk->addToolBar(Qt::TopToolBarArea, vcrToolbar);
196 desk->addToolBar(Qt::TopToolBarArea, timeToolbar);
197 desk->addToolBar(Qt::TopToolBarArea, colorToolbar);
198 desk->insertToolBarBreak(colorToolbar);
199 desk->addToolBar(Qt::TopToolBarArea, reprToolbar);
200 desk->addToolBar(Qt::TopToolBarArea, cameraToolbar);
201 desk->addToolBar(Qt::TopToolBarArea, axesToolbar);
202 desk->addToolBar(Qt::TopToolBarArea, macrosToolbar);
203 desk->addToolBar(Qt::TopToolBarArea, commonToolbar);
204 desk->addToolBar(Qt::TopToolBarArea, dataToolbar);
206 mainAction = mainToolBar->toggleViewAction();
207 vcrAction = vcrToolbar->toggleViewAction();
208 timeAction = timeToolbar->toggleViewAction();
209 colorAction = colorToolbar->toggleViewAction();
210 reprAction = reprToolbar->toggleViewAction();
211 cameraAction = cameraToolbar->toggleViewAction();
212 axesAction = axesToolbar->toggleViewAction();
213 macrosAction = macrosToolbar->toggleViewAction();
214 commonAction = commonToolbar->toggleViewAction();
215 dataAction = dataToolbar->toggleViewAction();
218 void PVViewer_GUIElements::onEmulateApply()
221 propertiesPanel->apply();
224 QList<QToolBar*> PVViewer_GUIElements::getToolbars()
227 l << mainToolBar << vcrToolbar << timeToolbar << colorToolbar
228 << reprToolbar << cameraToolbar << axesToolbar << macrosToolbar
229 << commonToolbar << dataToolbar;
233 void PVViewer_GUIElements::setToolBarEnabled(bool enabled)
235 mainToolBar ->setEnabled(enabled);
236 vcrToolbar ->setEnabled(enabled);
237 timeToolbar ->setEnabled(enabled);
238 colorToolbar ->setEnabled(enabled);
239 reprToolbar ->setEnabled(enabled);
240 cameraToolbar->setEnabled(enabled);
241 axesToolbar ->setEnabled(enabled);
242 macrosToolbar->setEnabled(enabled);
243 commonToolbar->setEnabled(enabled);
244 dataToolbar ->setEnabled(enabled);