Salome HOME
Merge 'abn/V8_1_fix' branch into V8_1_BR.
[modules/med.git] / src / MEDCalc / cmp / MEDPresentation.hxx
index bfcdd2fccd2a68af110fc812181ddf641a2ec4c3..800b7cd91c86e4a74a2bc52819548418e34f6027 100644 (file)
@@ -40,6 +40,8 @@ class MEDCALC_EXPORT MEDPresentation
 public:
   typedef ::CORBA::Long TypeID;
 
+  virtual void initFieldMeshInfos();
+
   virtual ~MEDPresentation();
 
   static const std::string PROP_NAME;                 // name of the presentation
@@ -55,7 +57,10 @@ public:
   virtual void setIntProperty(const std::string& propName, const int propValue);
   int getIntProperty(const std::string& propName) const;
 
-  void activateView();  // non const because generates a Python trace
+  // returns True if the view was still alive, False if it must have been recreated
+  // because the user closed it.
+  bool activateView();
+  virtual void recreateViewSetup();
 
   void dumpIntProperties() const;
   void dumpStringProperties() const;
@@ -69,29 +74,35 @@ protected:
   typedef std::pair<int, PyObject *> PyObjectId;
   static int GeneratePythonId();
 
-  MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name,
+  MEDPresentation(MEDPresentation::TypeID handlerId, const std::string& name,
                   const MEDCALC::ViewModeType viewMode,
                   const MEDCALC::ColorMapType colorMap,
                   const MEDCALC::ScalarBarRangeType sbRange);
-  std::string getRenderViewCommand() const;
   std::string getRenderViewVar() const;
-  std::string getResetCameraCommand() const;
 
-  std::string getComponentSelectionCommand() const;
-  std::string getColorMapCommand() const;
-  std::string getRescaleCommand() const;
+  // The most common elements of the ParaView pipeline:
+  void setOrCreateRenderView();
+  void createSource();
+  void selectFieldComponent();
+  void showObject();
+  void colorBy();
+  void showScalarBar();
+  void rescaleTransferFunction();
+  void selectColorMap();
+  void scalarBarTitle();
+  void resetCameraAndRender();
 
   virtual void internalGeneratePipeline();
   PyObject* getPythonObjectFromMain(const char* var) const;
-//  void pushPyObjects(PyObjectId obj, PyObjectId disp);
   void execPyLine(const std::string & lin);
   void pushAndExecPyLine(const std::string & lin);
 
-  MEDPresentation::TypeID getID() const { return _fieldHandlerId; }
+  MEDPresentation::TypeID getID() const { return _handlerId; }
 
   void fillAvailableFieldComponents();
-
-//  virtual MEDCALC::ViewModeType getViewMode() = 0;
+  void applyCellToPointIfNeeded();
+  void extractFileName(const std::string& name);
+//  void convertTo3DVectorField();
 
   template<typename PresentationType, typename PresentationParameters>
   void updateComponent(const std::string& newCompo);
@@ -109,7 +120,7 @@ protected:
   void setParameters(const PresentationParameters& params);
 
 private:
-  std::string getFieldTypeString(MEDCoupling::TypeOfField fieldType) const;
+  std::string getPVFieldTypeString(MEDCoupling::TypeOfField fieldType) const;
 
   // The following functions are reserved to friend class MEDPresentationManager
   void generatePipeline();
@@ -118,11 +129,18 @@ private:
   void updatePipeline(const PresentationParameters& params);
 
 protected:
+  std::string _meshName;
   std::string _fileName;
   std::string _fieldName;
-  std::string _fieldType;
 
-  MEDPresentation::TypeID _fieldHandlerId;
+  ///! MEDCoupling field type (ON_NODES, ON_CELLS, ON_GAUSS_PT, ON_GAUSS_NE
+  MEDCoupling::TypeOfField _mcFieldType;
+  ///! ParaView field type: "CELLS" or "POINTS"
+  std::string _pvFieldType;
+  ///! ParaView field type: "CELLS" or "POINTS" used in the ColorBy method. Not necessarily equal to _pvFieldType.
+  std::string _colorByType;
+
+  MEDPresentation::TypeID _handlerId;  // either a field or a mesh id (a field ID though, most of the time)
 
   int _selectedComponentIndex;
   MEDCALC::ViewModeType _viewMode;
@@ -139,14 +157,10 @@ protected:
   std::string _dispVar;
   ///! ParaView LUT variable in the Python scripting commands
   std::string _lutVar;
+  ///! ParaView variable in Python holding the data range
+  std::string _rangeVar;
 
 private:
-  ///! Pipeline elements
-//  std::vector<PyObjectId> _pipeline;
-
-  ///! Corresponding display object, if any:
-//  std::vector<PyObjectId> _display;
-
   ///! Presentation properties <key,value>
   std::map<std::string, std::string> _propertiesStr;
   std::map<std::string, int> _propertiesInt;