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 #ifdef PVCATALYST_ENABLED
71 catalystMenu = new QMenu(0);
72 pqParaViewMenuBuilders::buildCatalystMenu(*catalystMenu);
74 macrosMenu = new QMenu(0);
75 pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
77 //myBuildToolbars(desk);
80 PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(QMainWindow* desk)
83 theInstance = new PVViewer_GUIElements(desk);
88 pqTabbedMultiViewWidget * PVViewer_GUIElements::getTabbedMultiViewWidget()
90 pqTabbedMultiViewWidget * multiv =
91 qobject_cast<pqTabbedMultiViewWidget*>(PVViewer_Core::GetPVApplication()->manager("MULTIVIEW_WIDGET"));
93 // If not found, instanciate it. It will then register automatically as a MULTIVIEW_WIDGET.
94 // Also create a single view that will be attached by the tabbedMultiView automatically
95 // (in PV this is done automatically upon server connection event).
98 multiv = new pqTabbedMultiViewWidget();
100 // Create a new view proxy on the server
101 pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder();
102 pqServer* active_serv = pqActiveObjects::instance().activeServer();
103 pqView * pqview = builder->createView(QString("RenderView"), active_serv);
111 * See ParaView source code: pqParaViewMenuBuilders::buildToolbars()
112 * to keep this function up to date:
114 void PVViewer_GUIElements::myBuildToolbars(QMainWindow* mainWindow)
116 mainToolBar = new pqMainControlsToolbar(mainWindow)
117 << pqSetName("MainControlsToolbar");
118 mainToolBar->layout()->setSpacing(0);
120 vcrToolbar = new pqVCRToolbar(mainWindow)
121 << pqSetName("VCRToolbar");
122 vcrToolbar->layout()->setSpacing(0);
124 timeToolbar = new pqAnimationTimeToolbar(mainWindow)
125 << pqSetName("currentTimeToolbar");
126 timeToolbar->layout()->setSpacing(0);
128 colorToolbar = new pqColorToolbar(mainWindow)
129 << pqSetName("variableToolbar");
130 colorToolbar->layout()->setSpacing(0);
132 reprToolbar = new pqRepresentationToolbar(mainWindow)
133 << pqSetName("representationToolbar");
134 reprToolbar->layout()->setSpacing(0);
136 cameraToolbar = new pqCameraToolbar(mainWindow)
137 << pqSetName("cameraToolbar");
138 cameraToolbar->layout()->setSpacing(0);
140 axesToolbar = new pqAxesToolbar(mainWindow)
141 << pqSetName("axesToolbar");
142 axesToolbar->layout()->setSpacing(0);
144 // Give the macros menu to the pqPythonMacroSupervisor
145 pqPythonManager* manager = qobject_cast<pqPythonManager*>(
146 pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
148 macrosToolbar = new QToolBar("Macros Toolbars", mainWindow)
149 << pqSetName("MacrosToolbar");
150 manager->addWidgetForRunMacros(macrosToolbar);
152 commonToolbar = new QToolBar("Common", mainWindow) << pqSetName("Common");
153 commonToolbar->layout()->setSpacing(0);
155 dataToolbar = new QToolBar("DataAnalysis", mainWindow) << pqSetName("DataAnalysis");
156 dataToolbar->layout()->setSpacing(0);
158 //addToolbars(mainWindow);
161 void PVViewer_GUIElements::setToolBarVisible(bool show)
163 QCoreApplication::processEvents();
164 mainAction->setChecked(!show);
165 mainAction->setVisible(show);
166 mainAction->trigger();
167 vcrAction->setChecked(!show);
168 vcrAction->setVisible(show);
169 vcrAction->trigger();
170 timeAction->setChecked(!show);
171 timeAction->setVisible(show);
172 timeAction->trigger();
173 colorAction->setChecked(!show);
174 colorAction->setVisible(show);
175 colorAction->trigger();
176 reprAction->setChecked(!show);
177 reprAction->setVisible(show);
178 reprAction->trigger();
179 cameraAction->setChecked(!show);
180 cameraAction->setVisible(show);
181 cameraAction->trigger();
182 axesAction->setChecked(!show);
183 axesAction->setVisible(show);
184 axesAction->trigger();
185 macrosAction->setChecked(!show);
186 macrosAction->setVisible(show);
187 macrosAction->trigger();
188 commonAction->setChecked(!show);
189 commonAction->setVisible(show);
190 commonAction->trigger();
191 dataAction->setChecked(!show);
192 dataAction->setVisible(show);
193 dataAction->trigger();
196 void PVViewer_GUIElements::addToolbars(QMainWindow* desk)
198 desk->addToolBar(Qt::TopToolBarArea, mainToolBar);
199 desk->addToolBar(Qt::TopToolBarArea, vcrToolbar);
200 desk->addToolBar(Qt::TopToolBarArea, timeToolbar);
201 desk->addToolBar(Qt::TopToolBarArea, colorToolbar);
202 desk->insertToolBarBreak(colorToolbar);
203 desk->addToolBar(Qt::TopToolBarArea, reprToolbar);
204 desk->addToolBar(Qt::TopToolBarArea, cameraToolbar);
205 desk->addToolBar(Qt::TopToolBarArea, axesToolbar);
206 desk->addToolBar(Qt::TopToolBarArea, macrosToolbar);
207 desk->addToolBar(Qt::TopToolBarArea, commonToolbar);
208 desk->addToolBar(Qt::TopToolBarArea, dataToolbar);
210 mainAction = mainToolBar->toggleViewAction();
211 vcrAction = vcrToolbar->toggleViewAction();
212 timeAction = timeToolbar->toggleViewAction();
213 colorAction = colorToolbar->toggleViewAction();
214 reprAction = reprToolbar->toggleViewAction();
215 cameraAction = cameraToolbar->toggleViewAction();
216 axesAction = axesToolbar->toggleViewAction();
217 macrosAction = macrosToolbar->toggleViewAction();
218 commonAction = commonToolbar->toggleViewAction();
219 dataAction = dataToolbar->toggleViewAction();
222 void PVViewer_GUIElements::onEmulateApply()
225 propertiesPanel->apply();
228 QList<QToolBar*> PVViewer_GUIElements::getToolbars()
231 l << mainToolBar << vcrToolbar << timeToolbar << colorToolbar
232 << reprToolbar << cameraToolbar << axesToolbar << macrosToolbar
233 << commonToolbar << dataToolbar;
237 void PVViewer_GUIElements::setToolBarEnabled(bool enabled)
239 mainToolBar ->setEnabled(enabled);
240 vcrToolbar ->setEnabled(enabled);
241 timeToolbar ->setEnabled(enabled);
242 colorToolbar ->setEnabled(enabled);
243 reprToolbar ->setEnabled(enabled);
244 cameraToolbar->setEnabled(enabled);
245 axesToolbar ->setEnabled(enabled);
246 macrosToolbar->setEnabled(enabled);
247 commonToolbar->setEnabled(enabled);
248 dataToolbar ->setEnabled(enabled);