]> SALOME platform Git repositories - modules/gui.git/blob - src/PVViewer/PVViewer_GUIElements.cxx
Salome HOME
Merge branch 'master' of ssh://git.salome-platform.org/modules/gui
[modules/gui.git] / src / PVViewer / PVViewer_GUIElements.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 // Author: Adrien Bruneton (CEA)
20
21 #include "PVViewer_GUIElements.h"
22 #include "SUIT_Desktop.h"
23
24 #include <pqPropertiesPanel.h>
25 #include <pqPipelineBrowserWidget.h>
26 #include <pqParaViewMenuBuilders.h>
27
28 #include <QMenu>
29 #include <QList>
30 #include <QAction>
31
32 PVViewer_GUIElements * PVViewer_GUIElements::theInstance = 0;
33
34 PVViewer_GUIElements::PVViewer_GUIElements(SUIT_Desktop* desk) :
35   propertiesPanel(0), pipelineBrowserWidget(0),
36   sourcesMenu(0)
37 {
38   propertiesPanel = new pqPropertiesPanel(desk);
39   propertiesPanel->hide();
40   pipelineBrowserWidget  = new pqPipelineBrowserWidget(desk);
41   pipelineBrowserWidget->hide();
42
43   sourcesMenu = new QMenu(desk);
44   pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, desk);
45
46   filtersMenu = new QMenu(desk);
47   pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk);
48
49   macrosMenu = new QMenu(desk);
50   pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
51 }
52
53 PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(SUIT_Desktop* desk)
54 {
55   if (! theInstance)
56     theInstance = new PVViewer_GUIElements(desk);
57   return theInstance;
58 }
59
60 void PVViewer_GUIElements::updateSourcesMenu(QMenu *menu)
61 {
62   if (menu)
63     {
64       menu->clear();
65       QList<QAction *> act_list = sourcesMenu->actions();
66       foreach(QAction * a, act_list)
67       {
68         menu->addAction(a);
69       }
70     }
71 }
72
73 void PVViewer_GUIElements::updateFiltersMenu(QMenu *menu)
74 {
75   if (menu)
76     {
77       menu->clear();
78       QList<QAction *> act_list = filtersMenu->actions();
79       foreach(QAction * a, act_list)
80       {
81         menu->addAction(a);
82       }
83     }
84 }
85
86 void PVViewer_GUIElements::updateMacrosMenu(QMenu *menu)
87 {
88   if (menu)
89     {
90       menu->clear();
91       QList<QAction *> act_list = macrosMenu->actions();
92       foreach(QAction * a, act_list)
93       {
94         menu->addAction(a);
95       }
96     }
97 }
98
99
100 void PVViewer_GUIElements::onEmulateApply()
101 {
102   if (propertiesPanel)
103     propertiesPanel->apply();
104 }