Salome HOME
[MEDCalc] Prepare to presentation edition
authorCédric Aguerre <cedric.aguerre@edf.fr>
Fri, 15 Apr 2016 15:31:28 +0000 (17:31 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Mon, 18 Apr 2016 07:48:25 +0000 (09:48 +0200)
20 files changed:
idl/MEDPresentationManager.idl
src/MEDCalc/cmp/MEDPresentation.cxx
src/MEDCalc/cmp/MEDPresentation.hxx
src/MEDCalc/cmp/MEDPresentation.txx [new file with mode: 0644]
src/MEDCalc/cmp/MEDPresentationContour.cxx
src/MEDCalc/cmp/MEDPresentationContour.hxx
src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx
src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx
src/MEDCalc/cmp/MEDPresentationManager_i.cxx
src/MEDCalc/cmp/MEDPresentationManager_i.hxx
src/MEDCalc/cmp/MEDPresentationManager_i.txx
src/MEDCalc/cmp/MEDPresentationPointSprite.cxx
src/MEDCalc/cmp/MEDPresentationPointSprite.hxx
src/MEDCalc/cmp/MEDPresentationScalarMap.cxx
src/MEDCalc/cmp/MEDPresentationScalarMap.hxx
src/MEDCalc/cmp/MEDPresentationSlices.cxx
src/MEDCalc/cmp/MEDPresentationSlices.hxx
src/MEDCalc/cmp/MEDPresentationVectorField.cxx
src/MEDCalc/cmp/MEDPresentationVectorField.hxx
src/MEDCalc/gui/MEDModule.cxx

index d108a917e7c87c91dd4f8985056d062e627fdfa4..deb0f0a522978bdf1c72bc1a6eedfe925261aacb 100644 (file)
@@ -132,6 +132,13 @@ module MEDCALC
     void setPresentationProperty(in long presId, in string propName, in string propValue);
     string getPresentationProperty(in long presId, in string propName);
 
+    void updateScalarMap(in long presId, in ScalarMapParameters params);
+    void updateContour(in long presId, in ContourParameters params);
+    void updateVectorField(in long presId, in VectorFieldParameters params);
+    void updateSlices(in long presId, in SlicesParameters params);
+    void updateDeflectionShape(in long presId, in DeflectionShapeParameters params);
+    void updatePointSprite(in long presId, in PointSpriteParameters params);
+
   };
 
 };
index 24d36c5a6bc78a9836aaffb8784b56cce69f332b..10fe56a4425702578fde7b64baed85992840e088 100644 (file)
@@ -45,20 +45,23 @@ MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, std::st
   setProperty("name", name);
 }
 
-void MEDPresentation::generatePipeline()
+void
+MEDPresentation::generatePipeline()
 {
   // Might be more complicated in the future:
 
   this->internalGeneratePipeline();
 }
 
-void MEDPresentation::pushInternal(PyObject * obj, PyObject * disp)
+void
+MEDPresentation::pushInternal(PyObject* obj, PyObject* disp)
 {
   _pipeline.push_back(obj);
   _display.push_back(disp);
 }
 
-void MEDPresentation::setProperty(const std::string& propName, const std::string& propValue)
+void
+MEDPresentation::setProperty(const std::string& propName, const std::string& propValue)
 {
   // LIMITED!!! For now switch the first display element to Wireframe
   /*
@@ -82,7 +85,8 @@ MEDPresentation::getProperty(const std::string& propName) const
   }
 }
 
-PyObject * MEDPresentation::getPythonObjectFromMain(const char * python_var) const
+PyObject*
+MEDPresentation::getPythonObjectFromMain(const char* python_var) const
 {
   // TODO: improve to avoid getting dict at each call
 
@@ -92,7 +96,8 @@ PyObject * MEDPresentation::getPythonObjectFromMain(const char * python_var) con
   return PyDict_GetItemString(global_dict, python_var);
 }
 
-std::string MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldType) const
+std::string
+MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldType) const
 {
   switch(fieldType)
   {
@@ -135,7 +140,7 @@ MEDPresentation::getResetCameraCommand() const
 std::string
 MEDPresentation::getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap) const
 {
-  switch(colorMap) {
+  switch (colorMap) {
   case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "Blue to Red Rainbow";
   case MEDCALC::COLOR_MAP_COOL_TO_WARM: return "Cool to Warm";
   }
index aac5c5a003ec9bee003219ffc46921889105ded5..e7675010724e3f85a836134352eee1a22e60becf 100644 (file)
@@ -61,9 +61,14 @@ protected:
 
 private:
 
-  void generatePipeline(); // reserved to friend class MEDPresentationManager
   std::string getFieldTypeString(MEDCoupling::TypeOfField fieldType) const;
 
+  // The following functions are reserved to friend class MEDPresentationManager
+  void generatePipeline();
+
+  template<typename PresentationType, typename PresentationParameters>
+  void updatePipeline(PresentationParameters params);
+
 protected:
 
   std::string _fileName;
@@ -84,4 +89,6 @@ private:
   std::map<std::string, std::string> _properties;
 };
 
+#include "MEDPresentation.txx"
+
 #endif /* SRC_MEDCALC_CMP_MEDPRESENTATION_HXX_ */
diff --git a/src/MEDCalc/cmp/MEDPresentation.txx b/src/MEDCalc/cmp/MEDPresentation.txx
new file mode 100644 (file)
index 0000000..a99a462
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2016  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _MED_PRESENTATION_TXX_
+#define _MED_PRESENTATION_TXX_
+
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentation::updatePipeline(PresentationParameters params)
+{
+  static_cast<PresentationType*>(this)->updatePipeline(params);
+}
+
+#endif // _MED_PRESENTATION_TXX_
index 883cfb176a17cc0e2b057dfd068c156c8082afac..cdf86ed6715aa9be5921fc8734879ab80517aa09 100644 (file)
@@ -47,3 +47,9 @@ MEDPresentationContour::internalGeneratePipeline()
 
   PyGILState_Release(_gil_state);
 }
+
+void
+MEDPresentationContour::updatePipeline(const MEDCALC::ContourParameters& params)
+{
+  // :TODO:
+}
index 555dfe7706faffafe4786358fc10158e3c3d4e05..e03b76b58ba4b061b8892d5bc6a54047d989be41 100644 (file)
@@ -31,6 +31,8 @@ public:
   {}
   virtual ~MEDPresentationContour() {}
 
+  void updatePipeline(const MEDCALC::ContourParameters& params);
+
 protected:
   virtual void internalGeneratePipeline();
 
index 1a20da49355c0eec4b636dbb9a77e009bd61a064..e56aa9f4bde1cd9a2c5cab70dc2b64e7839766bf 100644 (file)
@@ -47,3 +47,9 @@ MEDPresentationDeflectionShape::internalGeneratePipeline()
 
   PyGILState_Release(_gil_state);
 }
+
+void
+MEDPresentationDeflectionShape::updatePipeline(const MEDCALC::DeflectionShapeParameters& params)
+{
+  // :TODO:
+}
index 9d614bf1998dee912759ad674c7a951c62bf8e9b..f9bbbb2f24f7e7a9e255ff2fde8577ade249589d 100644 (file)
@@ -31,6 +31,8 @@ public:
   {}
   virtual ~MEDPresentationDeflectionShape() {}
 
+  void updatePipeline(const MEDCALC::DeflectionShapeParameters& params);
+
 protected:
   virtual void internalGeneratePipeline();
 
index b6c9ba970a8d378e7d0503d4a99a4a154646ecfb..c5f7a8f0baf064a02b25bbd5430edce40cc61383 100644 (file)
@@ -63,25 +63,30 @@ MEDPresentationManager_i::GenerateID()
   return START_ID;
 }
 
+MEDPresentation*
+MEDPresentationManager_i::_getPresentation(MEDPresentation::TypeID presentationID) const
+{
+  std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
+  if (citr == _presentations.end())
+    return NULL;
+  return (*citr).second;
+}
+
 void
-MEDPresentationManager_i::setPresentationProperty(MEDPresentation::TypeID presentationID, const char * propName, const char * propValue)
+MEDPresentationManager_i::setPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue)
 {
-  if (_presentations.find(presentationID) != _presentations.end())
-    {
-      MEDPresentation * pres(_presentations[presentationID]);
-      pres->setProperty(propName, propValue);
-    }
+  MEDPresentation* pres = _getPresentation(presentationID);
+  if (pres)
+    pres->setProperty(propName, propValue);
   else
-    {
-      std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
-    }
+    std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
 }
 
 char*
 MEDPresentationManager_i::getPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName)
 {
-  if (_presentations.find(presentationID) != _presentations.end()) {
-    MEDPresentation* pres = _presentations[presentationID];
+  MEDPresentation* pres = _getPresentation(presentationID);
+  if (pres) {
     return (char*) pres->getProperty(propName).c_str();
   }
   else {
@@ -125,3 +130,39 @@ MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters&
 {
   return _makePresentation<MEDPresentationPointSprite>(params);
 }
+
+void
+MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params)
+{
+  return _updatePresentation<MEDPresentationScalarMap>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateContour(MEDPresentation::TypeID presentationID, const MEDCALC::ContourParameters& params)
+{
+  return _updatePresentation<MEDPresentationContour>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters& params)
+{
+  return _updatePresentation<MEDPresentationVectorField>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params)
+{
+  return _updatePresentation<MEDPresentationSlices>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params)
+{
+  return _updatePresentation<MEDPresentationDeflectionShape>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters& params)
+{
+  return _updatePresentation<MEDPresentationPointSprite>(presentationID, params);
+}
index 5af811002f60044a3aecea53b91a22df5e856bfe..826ecc7bbd706083f045270760f1b13d0896abad 100644 (file)
@@ -46,9 +46,16 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager,
   MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&);
   MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&);
 
-  MEDCALC_EXPORT void setPresentationProperty(MEDPresentation::TypeID presentationID, const char * propName, const char * propValue);
+  MEDCALC_EXPORT void setPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue);
   MEDCALC_EXPORT char* getPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName);
 
+  MEDCALC_EXPORT void updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters&);
+  MEDCALC_EXPORT void updateContour(MEDPresentation::TypeID presentationID, const MEDCALC::ContourParameters&);
+  MEDCALC_EXPORT void updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters&);
+  MEDCALC_EXPORT void updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters&);
+  MEDCALC_EXPORT void updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters&);
+  MEDCALC_EXPORT void updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters&);
+
  private:
   MEDPresentationManager_i();
   virtual ~MEDPresentationManager_i();
@@ -59,14 +66,20 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager,
   template<typename PresentationType, typename PresentationParameters>
   MEDPresentation::TypeID _makePresentation(PresentationParameters params);
 
+  // Update presentation
+  template<typename PresentationType, typename PresentationParameters>
+  void _updatePresentation(MEDPresentation::TypeID presentationID, PresentationParameters params);
+
+  MEDPresentation* _getPresentation(MEDPresentation::TypeID) const;
+
  private :
 
   // The MEDPresentationManager is a singleton, whose instance can be obtained
   // using the getInstance static method.
-  static MEDPresentationManager_i * _instance;
+  static MEDPresentationManager_i* _instance;
 
   // Owns a list of MEDPresentation objects
-  std::map< MEDPresentation::TypeID, MEDPresentation * > _presentations;
+  std::map<MEDPresentation::TypeID, MEDPresentation*> _presentations;
 
 };
 
index c315746ea00a361d30c68bff2cf5ff990a562c2b..eb283bf152986e6e60abcb850c3e4dd16c52e227 100644 (file)
@@ -40,4 +40,17 @@ MEDPresentationManager_i::_makePresentation(PresentationParameters params)
   return newID;
 }
 
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentationManager_i::_updatePresentation(MEDPresentation::TypeID presentationID, PresentationParameters params)
+{
+  MEDPresentation* presentation = _getPresentation(presentationID);
+  if (!presentation) {
+    std::cerr << "_updatePresentation(): presentation not found!!" << std::endl;
+    return;
+  }
+
+  presentation->updatePipeline<PresentationType>(params);
+}
+
 #endif // _MED_PRESENTATION_MANAGER_I_TXX_
index 3d618575fdc4dccb5c3df4d62a029c6a313e7d5c..f3688036998db07a42db527676c0bccfcec6d8f4 100644 (file)
@@ -47,3 +47,9 @@ MEDPresentationPointSprite::internalGeneratePipeline()
 
   PyGILState_Release(_gil_state);
 }
+
+void
+MEDPresentationPointSprite::updatePipeline(const MEDCALC::PointSpriteParameters& params)
+{
+  // :TODO:
+}
index 34f0dd17080054830537769018a4128c45c6e9ae..27530af82a8ddd35cb084735de45f91b855584dc 100644 (file)
@@ -31,6 +31,8 @@ public:
   {}
   virtual ~MEDPresentationPointSprite() {}
 
+  void updatePipeline(const MEDCALC::PointSpriteParameters& params);
+
 protected:
   virtual void internalGeneratePipeline();
 
index a09da3febeeeb5a73181ac06d8b8c4e1f0b03e14..6042bf8f3446640bcb3c231ab81f3ec17418373c 100644 (file)
@@ -48,3 +48,9 @@ MEDPresentationScalarMap::internalGeneratePipeline()
 
   PyGILState_Release(_gil_state);
 }
+
+void
+MEDPresentationScalarMap::updatePipeline(const MEDCALC::ScalarMapParameters& params)
+{
+  // :TODO:
+}
index 1b26af56ffa9ef50f663d3bc1e2eece3b26ba526..d3d1ae1cf5e3a566d92d884042bb954fd4c4e4da 100644 (file)
@@ -31,6 +31,8 @@ public:
   {}
   virtual ~MEDPresentationScalarMap() {}
 
+  void updatePipeline(const MEDCALC::ScalarMapParameters& params);
+
 protected:
   virtual void internalGeneratePipeline();
 
index 4b5636aad1a854370e6bd232e955eb16c6683c1d..9b5d97c3c67c7a95049359e8021a06355dc22144 100644 (file)
@@ -47,3 +47,9 @@ MEDPresentationSlices::internalGeneratePipeline()
 
   PyGILState_Release(_gil_state);
 }
+
+void
+MEDPresentationSlices::updatePipeline(const MEDCALC::SlicesParameters& params)
+{
+  // :TODO:
+}
index a738d7a3f8fda84736bed290a031eb422d922a69..b7ee4184e66f989f61d4e6240cbf97f3bf2018b4 100644 (file)
@@ -31,6 +31,8 @@ public:
   {}
   virtual ~MEDPresentationSlices() {}
 
+  void updatePipeline(const MEDCALC::SlicesParameters& params);
+
 protected:
   virtual void internalGeneratePipeline();
 
index ae03a030da00d9f8559eddf27d21f1fd978e63b3..c5a1b3e345aa6a741545d2ec36ce79027f788dfb 100644 (file)
@@ -47,3 +47,9 @@ MEDPresentationVectorField::internalGeneratePipeline()
 
   PyGILState_Release(_gil_state);
 }
+
+void
+MEDPresentationVectorField::updatePipeline(const MEDCALC::VectorFieldParameters& params)
+{
+  // :TODO:
+}
index a7fc8d89f4191102edf9d43042aa3495eb1a87ed..7981f4264247690ca11f656c82ee3c7ee0e5f2b2 100644 (file)
@@ -31,6 +31,8 @@ public:
   {}
   virtual ~MEDPresentationVectorField() {}
 
+  void updatePipeline(const MEDCALC::VectorFieldParameters& params);
+
 protected:
   virtual void internalGeneratePipeline();
 
index c40bbe231b300f1c340483d29da6de13206ef4f9..448cc7f04d203f9a8be3d670dba364359d9214ce 100644 (file)
@@ -348,4 +348,9 @@ MEDModule::onDblClick(const QModelIndex& index)
   STDLOG("    - Field id:          " + oss.str());
   STDLOG("    - Presentation name: " + name);
 
+  // :TODO:
+  // get edited values from a popup widget
+  // get presentation
+  // call presentation edit function
+
 }