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)
21 #include "PVViewer_GUIElements.h"
23 #include <pqPropertiesPanel.h>
24 #include <pqPipelineBrowserWidget.h>
25 #include <pqParaViewMenuBuilders.h>
26 #include <pqMainControlsToolbar.h>
27 #include <pqVCRToolbar.h>
28 #include <pqAnimationTimeToolbar.h>
29 #include <pqColorToolbar.h>
30 #include <pqRepresentationToolbar.h>
31 #include <pqCameraToolbar.h>
32 #include <pqAxesToolbar.h>
33 #include <pqSetName.h>
35 #include <pqPythonManager.h>
36 #include <pqApplicationCore.h>
38 #include <QMainWindow>
45 #include <QCoreApplication>
47 PVViewer_GUIElements * PVViewer_GUIElements::theInstance = 0;
49 PVViewer_GUIElements::PVViewer_GUIElements(QMainWindow* desk) :
50 propertiesPanel(0), pipelineBrowserWidget(0),
53 propertiesPanel = new pqPropertiesPanel(desk);
54 propertiesPanel->hide();
55 pipelineBrowserWidget = new pqPipelineBrowserWidget(desk);
56 pipelineBrowserWidget->hide();
58 sourcesMenu = new QMenu(0);
59 pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, desk);
60 filtersMenu = new QMenu(0);
61 pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk);
62 #ifdef PVCATALYST_ENABLED
63 catalystMenu = new QMenu(0);
64 pqParaViewMenuBuilders::buildCatalystMenu(*catalystMenu);
66 macrosMenu = new QMenu(0);
67 pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
69 myBuildToolbars(desk);
72 PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(QMainWindow* desk)
75 theInstance = new PVViewer_GUIElements(desk);
80 * See ParaView source code: pqParaViewMenuBuilders::buildToolbars()
81 * to keep this function up to date:
83 void PVViewer_GUIElements::myBuildToolbars(QMainWindow* mainWindow)
85 mainToolBar = new pqMainControlsToolbar(mainWindow)
86 << pqSetName("MainControlsToolbar");
87 mainToolBar->layout()->setSpacing(0);
89 vcrToolbar = new pqVCRToolbar(mainWindow)
90 << pqSetName("VCRToolbar");
91 vcrToolbar->layout()->setSpacing(0);
93 timeToolbar = new pqAnimationTimeToolbar(mainWindow)
94 << pqSetName("currentTimeToolbar");
95 timeToolbar->layout()->setSpacing(0);
97 colorToolbar = new pqColorToolbar(mainWindow)
98 << pqSetName("variableToolbar");
99 colorToolbar->layout()->setSpacing(0);
101 reprToolbar = new pqRepresentationToolbar(mainWindow)
102 << pqSetName("representationToolbar");
103 reprToolbar->layout()->setSpacing(0);
105 cameraToolbar = new pqCameraToolbar(mainWindow)
106 << pqSetName("cameraToolbar");
107 cameraToolbar->layout()->setSpacing(0);
109 axesToolbar = new pqAxesToolbar(mainWindow)
110 << pqSetName("axesToolbar");
111 axesToolbar->layout()->setSpacing(0);
113 // Give the macros menu to the pqPythonMacroSupervisor
114 pqPythonManager* manager = qobject_cast<pqPythonManager*>(
115 pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
117 macrosToolbar = new QToolBar("Macros Toolbars", mainWindow)
118 << pqSetName("MacrosToolbar");
119 manager->addWidgetForRunMacros(macrosToolbar);
121 commonToolbar = new QToolBar("Common", mainWindow) << pqSetName("Common");
122 commonToolbar->layout()->setSpacing(0);
124 dataToolbar = new QToolBar("DataAnalysis", mainWindow) << pqSetName("DataAnalysis");
125 dataToolbar->layout()->setSpacing(0);
127 addToolbars(mainWindow);
130 void PVViewer_GUIElements::setToolBarVisible(bool show)
132 QCoreApplication::processEvents();
133 mainAction->setChecked(!show);
134 mainAction->setVisible(show);
135 mainAction->trigger();
136 vcrAction->setChecked(!show);
137 vcrAction->setVisible(show);
138 vcrAction->trigger();
139 timeAction->setChecked(!show);
140 timeAction->setVisible(show);
141 timeAction->trigger();
142 colorAction->setChecked(!show);
143 colorAction->setVisible(show);
144 colorAction->trigger();
145 reprAction->setChecked(!show);
146 reprAction->setVisible(show);
147 reprAction->trigger();
148 cameraAction->setChecked(!show);
149 cameraAction->setVisible(show);
150 cameraAction->trigger();
151 axesAction->setChecked(!show);
152 axesAction->setVisible(show);
153 axesAction->trigger();
154 macrosAction->setChecked(!show);
155 macrosAction->setVisible(show);
156 macrosAction->trigger();
157 commonAction->setChecked(!show);
158 commonAction->setVisible(show);
159 commonAction->trigger();
160 dataAction->setChecked(!show);
161 dataAction->setVisible(show);
162 dataAction->trigger();
165 void PVViewer_GUIElements::addToolbars(QMainWindow* desk)
167 desk->addToolBar(Qt::TopToolBarArea, mainToolBar);
168 desk->addToolBar(Qt::TopToolBarArea, vcrToolbar);
169 desk->addToolBar(Qt::TopToolBarArea, timeToolbar);
170 desk->addToolBar(Qt::TopToolBarArea, colorToolbar);
171 desk->insertToolBarBreak(colorToolbar);
172 desk->addToolBar(Qt::TopToolBarArea, reprToolbar);
173 desk->addToolBar(Qt::TopToolBarArea, cameraToolbar);
174 desk->addToolBar(Qt::TopToolBarArea, axesToolbar);
175 desk->addToolBar(Qt::TopToolBarArea, macrosToolbar);
176 desk->addToolBar(Qt::TopToolBarArea, commonToolbar);
177 desk->addToolBar(Qt::TopToolBarArea, dataToolbar);
179 mainAction = mainToolBar->toggleViewAction();
180 vcrAction = vcrToolbar->toggleViewAction();
181 timeAction = timeToolbar->toggleViewAction();
182 colorAction = colorToolbar->toggleViewAction();
183 reprAction = reprToolbar->toggleViewAction();
184 cameraAction = cameraToolbar->toggleViewAction();
185 axesAction = axesToolbar->toggleViewAction();
186 macrosAction = macrosToolbar->toggleViewAction();
187 commonAction = commonToolbar->toggleViewAction();
188 dataAction = dataToolbar->toggleViewAction();
191 QList<QToolBar*> PVViewer_GUIElements::getToolbars()
194 l << mainToolBar << vcrToolbar << timeToolbar << colorToolbar
195 << reprToolbar << cameraToolbar << axesToolbar << macrosToolbar
196 << commonToolbar << dataToolbar;
200 void PVViewer_GUIElements::setToolBarEnabled(bool enabled)
202 mainToolBar ->setEnabled(enabled);
203 vcrToolbar ->setEnabled(enabled);
204 timeToolbar ->setEnabled(enabled);
205 colorToolbar ->setEnabled(enabled);
206 reprToolbar ->setEnabled(enabled);
207 cameraToolbar->setEnabled(enabled);
208 axesToolbar ->setEnabled(enabled);
209 macrosToolbar->setEnabled(enabled);
210 commonToolbar->setEnabled(enabled);
211 dataToolbar ->setEnabled(enabled);