1 // Copyright (C) 2011-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 // Authors: A Bruneton (CEA), C Aguerre (EdF)
21 #ifndef SRC_MEDCALC_CMP_MEDPRESENTATION_HXX_
22 #define SRC_MEDCALC_CMP_MEDPRESENTATION_HXX_
25 #include "MEDCouplingRefCountObject.hxx"
26 #include "MEDCALC.hxx"
28 #include <SALOMEconfig.h>
29 #include CORBA_SERVER_HEADER(MEDDataManager)
30 #include CORBA_SERVER_HEADER(MEDPresentationManager)
36 class MEDCALC_EXPORT MEDPresentation
38 friend class MEDPresentationManager_i;
41 typedef ::CORBA::Long TypeID;
43 virtual ~MEDPresentation();
45 static const std::string PROP_NAME; // name of the presentation
46 static const std::string PROP_NB_COMPONENTS; // number of field components
47 static const std::string PROP_SELECTED_COMPONENT; // index of the selected component - 0 means Euclidean norm
48 static const std::string PROP_COMPONENT; // string prefix for all properties storing component names
49 static const std::string PROP_COLOR_MAP; // color map - TODO: arch fix - should be in params only
50 static const std::string PROP_SCALAR_BAR_RANGE; // scalar bar range - TODO: arch fix - should be in params only
52 virtual void setStringProperty(const std::string& propName, const std::string& propValue);
53 const std::string getStringProperty(const std::string& propName) const;
55 virtual void setIntProperty(const std::string& propName, const int propValue);
56 int getIntProperty(const std::string& propName) const;
58 void activateView(); // non const because generates a Python trace
60 void dumpIntProperties() const;
61 void dumpStringProperties() const;
63 std::string paravisDump() const;
65 long getPyViewID() const { return _renderViewPyId; }
66 void setPyViewID(long id) { _renderViewPyId = id; }
69 typedef std::pair<int, PyObject *> PyObjectId;
70 static int GeneratePythonId();
72 MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name,
73 const MEDCALC::MEDPresentationViewMode viewMode,
74 const MEDCALC::MEDPresentationColorMap colorMap,
75 const MEDCALC::MEDPresentationScalarBarRange sbRange);
76 std::string getRenderViewCommand() const;
77 std::string getRenderViewVar() const;
78 std::string getResetCameraCommand() const;
80 std::string getComponentSelectionCommand() const;
81 std::string getColorMapCommand() const;
82 std::string getRescaleCommand() const;
84 virtual void internalGeneratePipeline();
85 PyObject* getPythonObjectFromMain(const char* var) const;
86 // void pushPyObjects(PyObjectId obj, PyObjectId disp);
87 void execPyLine(const std::string & lin);
88 void pushAndExecPyLine(const std::string & lin);
90 MEDPresentation::TypeID getID() const { return _fieldHandlerId; }
92 void fillAvailableFieldComponents();
94 // virtual MEDCALC::MEDPresentationViewMode getViewMode() = 0;
96 template<typename PresentationType, typename PresentationParameters>
97 void updateComponent(const std::string& newCompo);
99 template<typename PresentationType, typename PresentationParameters>
100 void updateColorMap(MEDCALC::MEDPresentationColorMap colorMap);
102 template<typename PresentationType, typename PresentationParameters>
103 void updateScalarBarRange(MEDCALC::MEDPresentationScalarBarRange sbRange);
105 template<typename PresentationType, typename PresentationParameters>
106 void getParameters(PresentationParameters& params) const;
108 template<typename PresentationType, typename PresentationParameters>
109 void setParameters(const PresentationParameters& params);
112 std::string getFieldTypeString(MEDCoupling::TypeOfField fieldType) const;
114 // The following functions are reserved to friend class MEDPresentationManager
115 void generatePipeline();
117 template<typename PresentationType, typename PresentationParameters>
118 void updatePipeline(const PresentationParameters& params);
121 std::string _fileName;
122 std::string _fieldName;
123 std::string _fieldType;
125 MEDPresentation::TypeID _fieldHandlerId;
127 int _selectedComponentIndex;
128 MEDCALC::MEDPresentationViewMode _viewMode;
129 MEDCALC::MEDPresentationColorMap _colorMap;
130 MEDCALC::MEDPresentationScalarBarRange _sbRange;
132 ///! Identifier (in the Python dump) of the render view
134 ///! ParaView object variable in the Python scripting commands (source object)
135 std::string _srcObjVar;
136 ///! ParaView object variable in the Python scripting commands (final object on which all display commands are done)
138 ///! ParaView display variable in the Python scripting commands
139 std::string _dispVar;
140 ///! ParaView LUT variable in the Python scripting commands
144 ///! Pipeline elements
145 // std::vector<PyObjectId> _pipeline;
147 ///! Corresponding display object, if any:
148 // std::vector<PyObjectId> _display;
150 ///! Presentation properties <key,value>
151 std::map<std::string, std::string> _propertiesStr;
152 std::map<std::string, int> _propertiesInt;
154 std::vector<std::string> _pythonCmds;
156 mutable PyObject* _globalDict;
159 #include "MEDPresentation.txx"
161 #endif /* SRC_MEDCALC_CMP_MEDPRESENTATION_HXX_ */