Salome HOME
[MEDCalc] add presentations and view mode
[modules/med.git] / src / MEDCalc / gui / PresentationController.cxx
1 // Copyright (C) 2016  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
20 #include "PresentationController.hxx"
21 #include "MEDModule.hxx"
22 #include "Basics_Utils.hxx"
23 #include "QtxActionGroup.h"
24
25 static const int OPTIONS_VIEW_MODE_ID = 943;
26 static const int OPTIONS_VIEW_MODE_REPLACE_ID = 944;
27 static const int OPTIONS_VIEW_MODE_OVERLAP_ID = 945;
28 static const int OPTIONS_VIEW_MODE_NEW_LAYOUT_ID = 946;
29 static const int OPTIONS_VIEW_MODE_SPLIT_VIEW_ID = 947;
30
31 PresentationController::PresentationController(MEDModule* salomeModule)
32 {
33   STDLOG("Creating a PresentationController");
34   _salomeModule = salomeModule;
35 }
36
37 PresentationController::~PresentationController()
38 {
39   STDLOG("Deleting the PresentationController");
40 }
41
42 void
43 PresentationController::createActions()
44 {
45   STDLOG("Creating PresentationController actions");
46   int toolbarId = _salomeModule->createTool("View Mode", "PresentationToolbar");
47
48   QtxActionGroup* ag = _salomeModule->createActionGroup(OPTIONS_VIEW_MODE_ID, true);
49   ag->setText("View mode");
50   ag->setUsesDropDown(true);
51
52   QString label   = tr("LAB_VIEW_MODE_REPLACE");
53   QString tooltip = tr("TIP_VIEW_MODE_REPLACE");
54   QAction* a = _salomeModule->createAction(OPTIONS_VIEW_MODE_REPLACE_ID,label,QIcon(),label,tooltip,0);
55   a->setCheckable(true);
56   a->setChecked(true);
57   ag->add(a);
58
59   label   = tr("LAB_VIEW_MODE_OVERLAP");
60   tooltip = tr("TIP_VIEW_MODE_OVERLAP");
61   a = _salomeModule->createAction(OPTIONS_VIEW_MODE_OVERLAP_ID,label,QIcon(),label,tooltip,0);
62   a->setCheckable(true);
63   ag->add(a);
64
65   label   = tr("LAB_VIEW_MODE_NEW_LAYOUT");
66   tooltip = tr("TIP_VIEW_MODE_NEW_LAYOUT");
67   a = _salomeModule->createAction(OPTIONS_VIEW_MODE_NEW_LAYOUT_ID,label,QIcon(),label,tooltip,0);
68   a->setCheckable(true);
69   ag->add(a);
70
71   label   = tr("LAB_VIEW_MODE_SPLIT_VIEW");
72   tooltip = tr("TIP_VIEW_MODE_SPLIT_VIEW");
73   a = _salomeModule->createAction(OPTIONS_VIEW_MODE_SPLIT_VIEW_ID,label,QIcon(),label,tooltip,0);
74   a->setCheckable(true);
75   ag->add(a);
76
77   _salomeModule->createTool(OPTIONS_VIEW_MODE_ID, toolbarId);
78
79
80 }
81
82 MEDCALC::MEDPresentationViewMode
83 PresentationController::getSelectedViewMode()
84 {
85   if (_salomeModule->action(OPTIONS_VIEW_MODE_REPLACE_ID)->isChecked()) {
86     return MEDCALC::VIEW_MODE_REPLACE;
87   }
88   else if (_salomeModule->action(OPTIONS_VIEW_MODE_OVERLAP_ID)->isChecked()) {
89     return MEDCALC::VIEW_MODE_OVERLAP;
90   }
91   else if (_salomeModule->action(OPTIONS_VIEW_MODE_NEW_LAYOUT_ID)->isChecked()) {
92     return MEDCALC::VIEW_MODE_NEW_LAYOUT;
93   }
94   else if (_salomeModule->action(OPTIONS_VIEW_MODE_SPLIT_VIEW_ID)->isChecked()) {
95     return MEDCALC::VIEW_MODE_SPLIT_VIEW;
96   }
97 }