Salome HOME
Merge branch 'V9_9_BR'
[modules/med.git] / src / MEDCalc / gui / MEDWidgetHelper.hxx
1 // Copyright (C) 2016-2022  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 setting 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 instantiated:
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   void onScalarBarVisibilityChanged(int idx);
65   void onUseCustomRangeChanged(int idx);
66   void onCustomRangeValueChanged(double min, double max);
67   void onHideDataOutsideCustomRangeChanged(int idx);
68
69
70 protected:
71   ///! GUI needs to talk directly to the pres manager to activate a view, get some params, etc ...:
72   MEDCALC::MEDPresentationManager_ptr _presManager;
73   const PresentationController * _presController  ;
74   const int _presId;
75   const std::string _presName;
76
77   WidgetPresentationParameters* _paramWidget;
78
79   // Component related members
80   int _selectedCompo;                  // Selected field component
81   int _nbCompos;                       // Total number of available components
82   std::vector<std::string> _allCompos; // All available components
83   bool _scalarBarVisibility;
84   double _scalarBarRangeArray[2];
85   bool _hideDataOutsideCustomRange;
86
87   // Color map
88   MEDCALC::ColorMapType _colorMap;
89
90   // Scalar bar range
91   MEDCALC::ScalarBarRangeType _scalarBarRange;
92 };
93
94 #endif