Salome HOME
Porting to Python 3 (1st draft)
[modules/med.git] / src / MEDCalc / gui / MEDWidgetHelper.hxx
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 #ifndef SRC_MEDCALC_GUI_MEDWIDGETHELPER_HXX_
21 #define SRC_MEDCALC_GUI_MEDWIDGETHELPER_HXX_
22
23 #include <Python.h>
24 #include "WidgetPresentationParameters.hxx"
25 #include "PresentationEvent.hxx"
26
27 #include <SALOMEconfig.h>
28 #include CORBA_SERVER_HEADER(MEDPresentationManager)
29
30 class WidgetPresentationParameters;
31 class PresentationController;
32
33 /*!
34  * The widget helper hierarchy is in charge of seting up the WidgetPresentationParameters
35  * to display the Qt widgets relevant to the underlying presentation on the component side.
36  */
37 class MEDWidgetHelper : public QObject
38 {
39   Q_OBJECT
40
41 public:
42   virtual ~MEDWidgetHelper();
43
44   virtual void updateWidget(bool connect);
45   virtual void releaseWidget();
46
47   ///! Returns the string X in the Python command "Update<X>" or "Get<X>Parameters"
48   virtual std::string getPythonTag() const = 0;
49
50 signals:
51   void presentationUpdateSignal(const PresentationEvent *);
52
53 protected:
54   // Only child classes to be instanciated:
55   MEDWidgetHelper(const PresentationController* presController,
56                   MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
57                   WidgetPresentationParameters * paramWidget);
58   virtual void loadParametersFromEngine();
59
60 protected slots:
61   void onComponentChanged(int idx);
62   void onColorMapChanged(int idx);
63   void onScalarBarRangeChanged(int idx);
64
65 protected:
66   ///! GUI needs to talk directly to the pres manager to activate a view, get some params, etc ...:
67   MEDCALC::MEDPresentationManager_ptr _presManager;
68   const PresentationController * _presController  ;
69   const int _presId;
70   const std::string _presName;
71
72   WidgetPresentationParameters* _paramWidget;
73
74   // Component related members
75   int _selectedCompo;                  // Selected field component
76   int _nbCompos;                       // Total number of available components
77   std::vector<std::string> _allCompos; // All available components
78
79   // Color map
80   MEDCALC::ColorMapType _colorMap;
81
82   // Scalar bar range
83   MEDCALC::ScalarBarRangeType _scalarBarRange;
84 };
85
86 #endif