Salome HOME
[MEDCalc] Deflection shape presentation
authorabn <adrien.bruneton@cea.fr>
Thu, 4 Aug 2016 15:10:35 +0000 (17:10 +0200)
committerabn <adrien.bruneton@cea.fr>
Thu, 4 Aug 2016 15:10:35 +0000 (17:10 +0200)
15 files changed:
idl/MEDPresentationManager.idl
src/MEDCalc/cmp/CMakeLists.txt
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/MEDPresentationVectorField.cxx
src/MEDCalc/gui/CMakeLists.txt
src/MEDCalc/gui/MEDWidgetHelperDeflectionShape.hxx [new file with mode: 0644]
src/MEDCalc/gui/PresentationController.cxx
src/MEDCalc/test/tui/CMakeLists.txt
src/MEDCalc/test/tui/deflection_shape.py [new file with mode: 0644]
src/MEDCalc/test/tui/medfiles/deplacements.med [new file with mode: 0644]
src/MEDCalc/tui/__init__.py
src/MEDCalc/tui/medpresentation.py

index 2d9e0663436d0a937655a5909c498ec420d69619..b86b63e450947f3935dfe4f6fd259ece3681c04e 100644 (file)
@@ -125,11 +125,13 @@ module MEDCALC
     SliceOrientationType orientation;
     long nbSlices;
   };
-//
-//  struct DeflectionShapeParameters {
-//    long fieldHandlerId;
-//  };
-//
+
+  struct DeflectionShapeParameters {
+    long fieldHandlerId;
+    ScalarBarRangeType scalarBarRange;
+    ColorMapType colorMap;
+  };
+
   struct PointSpriteParameters {
     long fieldHandlerId;
     string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
@@ -147,9 +149,9 @@ module MEDCALC
     long makeScalarMap(in ScalarMapParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
     long makeContour(in ContourParameters params, in ViewModeType viewMode)     raises (SALOME::SALOME_Exception);
     long makeVectorField(in VectorFieldParameters params, in ViewModeType viewMode)  raises (SALOME::SALOME_Exception);
-    long makeSlices(in SlicesParameters params, in ViewModeType viewMode)  raises (SALOME::SALOME_Exception);
-//    long makeDeflectionShape(in DeflectionShapeParameters params, in ViewModeType viewMode);
-    long makePointSprite(in PointSpriteParameters params, in ViewModeType viewMode);
+    long makeSlices(in SlicesParameters params, in ViewModeType viewMode)            raises (SALOME::SALOME_Exception);
+    long makeDeflectionShape(in DeflectionShapeParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
+    long makePointSprite(in PointSpriteParameters params, in ViewModeType viewMode)  raises (SALOME::SALOME_Exception);
 
     void setPresentationStringProperty(in long presId, in string propName, in string propValue);
     string getPresentationStringProperty(in long presId, in string propName);
@@ -162,22 +164,23 @@ module MEDCALC
     SlicesParameters     getSlicesParameters(in long presId);
     VectorFieldParameters     getVectorFieldParameters(in long presId);
     PointSpriteParameters     getPointSpriteParameters(in long presId);
+    DeflectionShapeParameters     getDeflectionShapeParameters(in long presId);
 
-    void updateMeshView(in long presId, in MeshViewParameters params);
-    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);
+    void updateMeshView(in long presId, in MeshViewParameters params)   raises (SALOME::SALOME_Exception);
+    void updateScalarMap(in long presId, in ScalarMapParameters params) raises (SALOME::SALOME_Exception);
+    void updateContour(in long presId, in ContourParameters params)     raises (SALOME::SALOME_Exception);
+    void updateVectorField(in long presId, in VectorFieldParameters params) raises (SALOME::SALOME_Exception);
+    void updateSlices(in long presId, in SlicesParameters params)       raises (SALOME::SALOME_Exception);
+    void updateDeflectionShape(in long presId, in DeflectionShapeParameters params) raises (SALOME::SALOME_Exception);
+    void updatePointSprite(in long presId, in PointSpriteParameters params)         raises (SALOME::SALOME_Exception);
 
-    boolean removePresentation(in long presId);
+    boolean removePresentation(in long presId)   raises (SALOME::SALOME_Exception);
 
     // Helper function to keep GUI sync
-    boolean activateView(in long presentationId);
+    boolean activateView(in long presentationId) raises (SALOME::SALOME_Exception);
 
     // Low level ParaVis dump
-    string getParavisDump(in long presId);
+    string getParavisDump(in long presId) raises (SALOME::SALOME_Exception);
 
 //    ViewModeType getPresentationViewMode(in long presId);
     
index c735141c4d9229485f71e2df059cf4d1618f8878..70c383a389ad25b0856326998e1032da3315223e 100644 (file)
@@ -45,7 +45,7 @@ SET(COMMON_SOURCES
   MEDPresentationVectorField.cxx
   MEDPresentationSlices.cxx
   MEDPresentationPointSprite.cxx
-#  MEDPresentationDeflectionShape.cxx  
+  MEDPresentationDeflectionShape.cxx  
 )
 
 SET(MEDFactoryEngine_SOURCES
index 12a1d288a6ebcdf5f493583733e2622ca9eb33a0..9fab15f781984012318cf9bea63a32d9805127e8 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
+#include "MEDPyLockWrapper.hxx"
+
 #include "MEDPresentationDeflectionShape.hxx"
+#include "MEDPresentationException.hxx"
+
+#include <SALOME_KernelServices.hxx>
+#undef LOG  // should be fixed in KERNEL - double definition
+#include <Basics_Utils.hxx>
+
+#include <sstream>
+
+const std::string MEDPresentationDeflectionShape::TYPE_NAME = "MEDPresentationDeflectionShape";
+
+MEDPresentationDeflectionShape::MEDPresentationDeflectionShape(const MEDCALC::DeflectionShapeParameters& params,
+                                                   const MEDCALC::ViewModeType viewMode) :
+    MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange), _params(params)
+{
+}
+
+void
+MEDPresentationDeflectionShape::autoScale()
+{
+  std::ostringstream oss;
+  oss << "import medcalc;";
+  pushAndExecPyLine(oss.str()); oss.str("");
+  oss << _objVar << ".ScaleFactor = 3.0*medcalc.ComputeCellAverageSize(__srcObj0)/(" << _rangeVar
+      << "[1]-" << _rangeVar << "[0]);";
+  pushAndExecPyLine(oss.str()); oss.str("");
+}
 
 void
 MEDPresentationDeflectionShape::internalGeneratePipeline()
 {
-//  PyGILState_STATE _gil_state = PyGILState_Ensure();
-//
-//  std::string cmd = std::string("import pvsimple as pvs;");
-//  cmd += getRenderViewCommand(_params.viewMode); // define __view1
-//
-//  cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
-//  cmd += std::string("__warpByVector1 = pvs.WarpByVector(Input=__obj1);");
-//  cmd += std::string("__disp1 = pvs.Show(__warpByVector1, __view1);");
-//  cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
-//  cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
-//  cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
-//  cmd += std::string("pvs.Render();");
-//
-//  cmd += getResetCameraCommand();
-//
-//  //std::cerr << "Python command:" << std::endl;
-//  //std::cerr << cmd << std::endl;
-//  PyRun_SimpleString(cmd.c_str());
-//  // Retrieve Python object for internal storage:
-//  PyObject* obj = getPythonObjectFromMain("__warpByVector1");
-//  PyObject* disp = getPythonObjectFromMain("__disp1");
-//  pushInternal(obj, disp);
-//
-//  PyGILState_Release(_gil_state);
+  MEDPresentation::internalGeneratePipeline();
+
+  MEDPyLockWrapper lock;
+
+  setOrCreateRenderView();
+  createSource();
+
+  // Populate internal array of available components:
+  fillAvailableFieldComponents();
+  if (getIntProperty(MEDPresentation::PROP_NB_COMPONENTS) <= 1)
+    {
+      const char * msg = "Deflection shape presentation does not work for scalar field!"; // this message will appear in GUI too
+      STDLOG(msg);
+      throw KERNEL::createSalomeException(msg);
+    }
+
+  // Warp needs point data:
+  applyCellToPointIfNeeded();
+
+  std::ostringstream oss;
+  oss << _objVar << " = pvs.WarpByVector(Input=" << _srcObjVar << ");";
+  pushAndExecPyLine(oss.str()); oss.str("");
+
+  showObject(); // to be done first so that the scale factor computation properly works
+
+  oss << _objVar << ".Vectors = ['POINTS', '" << _fieldName << "'];";
+  pushAndExecPyLine(oss.str()); oss.str("");
+
+  colorBy("POINTS");
+  showScalarBar();
+  selectColorMap();
+  rescaleTransferFunction();
+
+  autoScale();   // to be called after transfer function so we have the range
+
+  resetCameraAndRender();
 }
 
 void
 MEDPresentationDeflectionShape::updatePipeline(const MEDCALC::DeflectionShapeParameters& params)
 {
-  // :TODO:
+  if (params.fieldHandlerId != _params.fieldHandlerId)
+    throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
+
+  if (params.scalarBarRange != _params.scalarBarRange)
+    {
+      updateScalarBarRange<MEDPresentationDeflectionShape, MEDCALC::DeflectionShapeParameters>(params.scalarBarRange);
+      autoScale();
+      pushAndExecPyLine("pvs.Render();");
+    }
+  if (params.colorMap != _params.colorMap)
+    updateColorMap<MEDPresentationDeflectionShape, MEDCALC::DeflectionShapeParameters>(params.colorMap);
 }
index e23be43741cce85702e8b46f521a7efe58b7108f..f4ead11e30767e501668bce77ec949e6bd01be21 100644 (file)
 class MEDCALC_EXPORT MEDPresentationDeflectionShape : public MEDPresentation
 {
 public:
-  MEDPresentationDeflectionShape(const MEDCALC::DeflectionShapeParameters& params) :
-    MEDPresentation(params.fieldHandlerId, "MEDPresentationDeflectionShape"), _params(params)
-  {}
+  static const std::string TYPE_NAME;
+
+  MEDPresentationDeflectionShape(const MEDCALC::DeflectionShapeParameters& params, const MEDCALC::ViewModeType viewMode);
   virtual ~MEDPresentationDeflectionShape() {}
 
   void updatePipeline(const MEDCALC::DeflectionShapeParameters& params);
-  MEDCALC::ViewModeType getViewMode() { return _params.viewMode; }
+
+  void getParameters(MEDCALC::DeflectionShapeParameters & params) const { params = _params; } ;
+  void setParameters(const MEDCALC::DeflectionShapeParameters & params) { _params = params; } ;
 
 protected:
   virtual void internalGeneratePipeline();
+  void autoScale();
 
 private:
   MEDCALC::DeflectionShapeParameters _params;
index c787a16e9c72674418784b843e46bb75f4eee299..9fd1a1e6ac0fa1857c81dac465cb54828a56686b 100644 (file)
@@ -27,7 +27,7 @@
 #include "MEDPresentationContour.hxx"
 #include "MEDPresentationSlices.hxx"
 #include "MEDPresentationVectorField.hxx"
-//#include "MEDPresentationDeflectionShape.hxx"
+#include "MEDPresentationDeflectionShape.hxx"
 #include "MEDPresentationPointSprite.hxx"
 
 #include <SALOME_KernelServices.hxx>
@@ -152,12 +152,12 @@ MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params, co
 {
   return _makePresentation<MEDPresentationSlices>(params, viewMode);
 }
-//
-//MEDPresentation::TypeID
-//MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params)
-//{
-//  return _makePresentation<MEDPresentationDeflectionShape>(params);
-//}
+
+MEDPresentation::TypeID
+MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params, const MEDCALC::ViewModeType viewMode)
+{
+  return _makePresentation<MEDPresentationDeflectionShape>(params, viewMode);
+}
 
 MEDPresentation::TypeID
 MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params, const MEDCALC::ViewModeType viewMode)
@@ -217,6 +217,15 @@ MEDPresentationManager_i::getPointSpriteParameters(MEDPresentation::TypeID prese
   return tmp._retn();
 }
 
+MEDCALC::DeflectionShapeParameters
+MEDPresentationManager_i::getDeflectionShapeParameters(MEDPresentation::TypeID presentationID)
+{
+  MEDCALC::DeflectionShapeParameters p;
+  _getParameters<MEDPresentationDeflectionShape>(presentationID, p);
+  return p;
+}
+
+
 void
 MEDPresentationManager_i::updateMeshView(MEDPresentation::TypeID presentationID, const MEDCALC::MeshViewParameters& params)
 {
@@ -246,12 +255,12 @@ MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, c
 {
   return _updatePresentation<MEDPresentationSlices>(presentationID, params);
 }
-//
-//void
-//MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params)
-//{
-//  return _updatePresentation<MEDPresentationDeflectionShape>(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)
index 95fd9edf3a0e095d12fe74b4282ec6404406e458..e984b56edac713c78f123b277cd0d1e02d7baa9d 100644 (file)
@@ -44,7 +44,7 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager,
   MEDCALC_EXPORT MEDPresentation::TypeID makeContour(const MEDCALC::ContourParameters&, const MEDCALC::ViewModeType);
   MEDCALC_EXPORT MEDPresentation::TypeID makeVectorField(const MEDCALC::VectorFieldParameters&, const MEDCALC::ViewModeType);
   MEDCALC_EXPORT MEDPresentation::TypeID makeSlices(const MEDCALC::SlicesParameters&, const MEDCALC::ViewModeType);
-//  MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&, const MEDCALC::ViewModeType);
+  MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&, const MEDCALC::ViewModeType);
   MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&, const MEDCALC::ViewModeType);
 
   MEDCALC_EXPORT void setPresentationStringProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue);
@@ -59,13 +59,14 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager,
   MEDCALC_EXPORT MEDCALC::SlicesParameters*    getSlicesParameters(MEDPresentation::TypeID presentationID);
   MEDCALC_EXPORT MEDCALC::VectorFieldParameters     getVectorFieldParameters(MEDPresentation::TypeID presentationID);
   MEDCALC_EXPORT MEDCALC::PointSpriteParameters*    getPointSpriteParameters(MEDPresentation::TypeID presentationID);
+  MEDCALC_EXPORT MEDCALC::DeflectionShapeParameters     getDeflectionShapeParameters(MEDPresentation::TypeID presentationID);
 
   MEDCALC_EXPORT void updateMeshView(MEDPresentation::TypeID, const MEDCALC::MeshViewParameters&);
   MEDCALC_EXPORT void updateScalarMap(MEDPresentation::TypeID, const MEDCALC::ScalarMapParameters&);
   MEDCALC_EXPORT void updateContour(MEDPresentation::TypeID, const MEDCALC::ContourParameters&);
   MEDCALC_EXPORT void updateVectorField(MEDPresentation::TypeID, const MEDCALC::VectorFieldParameters&);
   MEDCALC_EXPORT void updateSlices(MEDPresentation::TypeID, const MEDCALC::SlicesParameters&);
-//  MEDCALC_EXPORT void updateDeflectionShape(MEDPresentation::TypeID, const MEDCALC::DeflectionShapeParameters&);
+  MEDCALC_EXPORT void updateDeflectionShape(MEDPresentation::TypeID, const MEDCALC::DeflectionShapeParameters&);
   MEDCALC_EXPORT void updatePointSprite(MEDPresentation::TypeID, const MEDCALC::PointSpriteParameters&);
 
   MEDCALC_EXPORT CORBA::Boolean removePresentation(MEDPresentation::TypeID);
index e175108154f8a90616e423ca83f2134286c460a3..d1dde7836ff03cb8dc9cedc390bec7fcc605992c 100644 (file)
@@ -82,8 +82,6 @@ MEDPresentationVectorField::internalGeneratePipeline()
   pushAndExecPyLine(oss.str()); oss.str("");
   oss << _objVar << "GlyphTransform = 'Transform2';";  // not sure this is really needed?
   pushAndExecPyLine(oss.str()); oss.str("");
-  oss << _objVar << ".ScaleFactor = 0.1;";
-  pushAndExecPyLine(oss.str()); oss.str("");
 
   colorBy("POINTS");
   showScalarBar();
index f968a83811126e84c143e5409da79bb73c6d88dc..b8c67be0d60f38694c35269ed4aeb5365d10a4f5 100644 (file)
@@ -63,6 +63,7 @@ SET(MEDCALCGUI_HEADERS
   MEDWidgetHelperSlices.hxx
   MEDWidgetHelperPointSprite.hxx
   MEDWidgetHelperVectorField.hxx
+  MEDWidgetHelperDeflectionShape.hxx
   )
  
 IF(SALOME_MED_WITH_QTTESTING)
diff --git a/src/MEDCalc/gui/MEDWidgetHelperDeflectionShape.hxx b/src/MEDCalc/gui/MEDWidgetHelperDeflectionShape.hxx
new file mode 100644 (file)
index 0000000..7ae5897
--- /dev/null
@@ -0,0 +1,43 @@
+// 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 SRC_MEDCALC_GUI_MEDWIDGETHELPERDEFLECTIONSHAPE_HXX_
+#define SRC_MEDCALC_GUI_MEDWIDGETHELPERDEFLECTIONSHAPE_HXX_
+
+#include "MEDWidgetHelperComponent.hxx"
+
+class PresentationController;
+
+class MEDWidgetHelperDeflectionShape: public MEDWidgetHelper
+{
+  Q_OBJECT
+
+public:
+  MEDWidgetHelperDeflectionShape(const PresentationController* presController,
+                           MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+                           WidgetPresentationParameters * paramW):
+     MEDWidgetHelper(presController, presManager, presId, presName, paramW)
+  {}
+  virtual ~MEDWidgetHelperDeflectionShape() {}
+
+  virtual std::string getPythonTag() const { return "DeflectionShape"; }
+
+};
+
+#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERDEFLECTIONSHAPE_HXX_ */
index fe19f432e5bcf20d9862fb08e3d7a854d804409f..09426d90f07524c7b1072fa09f3dceb79c5c67a5 100644 (file)
@@ -33,7 +33,7 @@
 #include "MEDPresentationSlices.hxx"
 #include "MEDPresentationPointSprite.hxx"
 #include "MEDPresentationVectorField.hxx"
-//#include "MEDPresentationDeflectionShape.hxx"
+#include "MEDPresentationDeflectionShape.hxx"
 
 #include "MEDWidgetHelperMeshView.hxx"
 #include "MEDWidgetHelperScalarMap.hxx"
@@ -41,7 +41,7 @@
 #include "MEDWidgetHelperSlices.hxx"
 #include "MEDWidgetHelperPointSprite.hxx"
 #include "MEDWidgetHelperVectorField.hxx"
-//#include "MEDWidgetHelperDeflectionShape.hxx"
+#include "MEDWidgetHelperDeflectionShape.hxx"
 
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
@@ -484,6 +484,10 @@ PresentationController::processPresentationEvent(const PresentationEvent* event)
   QString scalarBarRange = getScalarBarRangePython();
   MEDCALC::FieldHandler* fieldHandler = event->fieldHandler;
   QStringList commands;
+
+  // [ABN] using event mechanism for all this is awkward? TODO: direct implementation in each
+  // dedicated widget helper class?
+
   if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_MESH_VIEW ) {
         commands += QString("presentation_id = medcalc.MakeMeshView(accessField(%1), viewMode=%2)").arg(fieldHandler->id).arg(viewMode);
         commands += QString("presentation_id");
@@ -513,13 +517,13 @@ PresentationController::processPresentationEvent(const PresentationEvent* event)
               .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
       commands += QString("presentation_id");
   }
+    else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
+      commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
+          .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
+      commands += QString("presentation_id");
+  }
 
-  //  else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
-  //    commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
-  //    commands += QString("presentation_id");
 
-  // [ABN] using event mechanism for this is awkward? TODO: direct implementation in each
-  // dedicated widget helper class?
   else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_COMPONENT ) {
       std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
       commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
@@ -592,6 +596,8 @@ PresentationController::findOrCreateWidgetHelper(MEDCALC::MEDPresentationManager
     wh = new MEDWidgetHelperVectorField(this, _presManager, presId, name, _widgetPresentationParameters);
   else if (type == MEDPresentationPointSprite::TYPE_NAME)
     wh = new MEDWidgetHelperPointSprite(this, _presManager, presId, name, _widgetPresentationParameters);
+  else if (type == MEDPresentationDeflectionShape::TYPE_NAME)
+    wh = new MEDWidgetHelperDeflectionShape(this, _presManager, presId, name, _widgetPresentationParameters);
   else
     {
       const char * msg ="findOrCreateWidgetHelper(): NOT IMPLEMENTED !!!";
index 862434a7e76a0d39bf9857ce2378119c00f68974..8a6cc20e48d20b30a4099fc99822dd19b1d51a6e 100644 (file)
@@ -22,6 +22,7 @@ INCLUDE(tests.set)
 SET(_test_files
     medfiles/smooth_surface_and_field.med
     medfiles/agitateur.med
+    medfiles/deplacements.med
 )
 
 SET(TEST_INSTALL_DIRECTORY ${SALOME_MED_INSTALL_TEST}/MEDCalc/tui)
diff --git a/src/MEDCalc/test/tui/deflection_shape.py b/src/MEDCalc/test/tui/deflection_shape.py
new file mode 100644 (file)
index 0000000..3c71868
--- /dev/null
@@ -0,0 +1,39 @@
+# 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
+#
+
+import os
+from time import sleep
+
+import medcalc
+medcalc.medconsole.setConsoleGlobals(globals())
+import MEDCALC
+from medcalc.medconsole import accessField
+
+from medcalc_testutils import GetMEDFileDirTUI
+
+datafile = os.path.join(GetMEDFileDirTUI(), "deplacements.med")
+source_id = medcalc.LoadDataSource(datafile)
+
+presentation_id = medcalc.MakeDeflectionShape(accessField(0), viewMode=MEDCALC.VIEW_MODE_REPLACE, 
+                                          colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW,
+                                          scalarBarRange=MEDCALC.SCALAR_BAR_CURRENT_TIMESTEP
+                                          )
+sleep(1)
+medcalc.RemovePresentation(presentation_id)
+sleep(1)
diff --git a/src/MEDCalc/test/tui/medfiles/deplacements.med b/src/MEDCalc/test/tui/medfiles/deplacements.med
new file mode 100644 (file)
index 0000000..ec1125f
Binary files /dev/null and b/src/MEDCalc/test/tui/medfiles/deplacements.med differ
index 949fadd91f50d28e8157a34dad121b4b02285900..7dc847e5d9c0a1fd35409fa70e2fa7e90d6dc09b 100644 (file)
@@ -46,7 +46,7 @@ from medpresentation import MakeVectorField
 from medpresentation import MakeSlices
 from medpresentation import MakePointSprite
 from medpresentation import RemovePresentation
-#from medpresentation import MakeDeflectionShape
+from medpresentation import MakeDeflectionShape
 
 from medpresentation import GetMeshViewParameters
 from medpresentation import GetScalarMapParameters
@@ -54,7 +54,7 @@ from medpresentation import GetContourParameters
 from medpresentation import GetSlicesParameters
 from medpresentation import GetPointSpriteParameters
 from medpresentation import GetVectorFieldParameters
-#from medpresentation import GetDeflectionShapeParameters
+from medpresentation import GetDeflectionShapeParameters
 
 from medpresentation import UpdateMeshView
 from medpresentation import UpdateScalarMap
@@ -62,7 +62,7 @@ from medpresentation import UpdateContour
 from medpresentation import UpdateSlices
 from medpresentation import UpdateVectorField
 from medpresentation import UpdatePointSprite
-#from medpresentation import UpdateDeflectionShape
+from medpresentation import UpdateDeflectionShape
 
 from medpresentation import ComputeCellAverageSize, GetDomainCenter, GetSliceOrigins
 
index 01defc0daaab6eab800321429cb51c33d9a4072e..ea9574ab84fc69a30f5d32791382bc985e76c3fd 100644 (file)
@@ -106,17 +106,25 @@ def MakeSlices(proxy,
   except SALOME.SALOME_Exception as e:
     notifyGui_error("An error occured while creating the slices:\n" + e.details.text)
     raise Exception(e.details.text)
-##
-#
-#def MakeDeflectionShape(proxy,
-#                        viewMode=MEDCALC.VIEW_MODE_DEFAULT
-#                        ):
-#  params = MEDCALC.DeflectionShapeParameters(proxy.id, viewMode)
-#  presentation_id = __manager.makeDeflectionShape(params)
-#  notifyGui_addPresentation(proxy.id, presentation_id)
-#  return presentation_id
-##
-#
+
+
+def MakeDeflectionShape(proxy,
+                  viewMode=MEDCALC.VIEW_MODE_DEFAULT,
+                  scalarBarRange=MEDCALC.SCALAR_BAR_RANGE_DEFAULT,
+                  colorMap=MEDCALC.COLOR_MAP_DEFAULT
+                  ):
+  # Create the presentation instance in CORBA engine
+  # The engine in turn creates the ParaView pipeline elements
+  params = MEDCALC.DeflectionShapeParameters(proxy.id, scalarBarRange, colorMap)
+  try:
+    presentation_id = __manager.makeDeflectionShape(params, viewMode)
+    notifyGui_addPresentation(proxy.id, presentation_id)
+    return presentation_id
+  except SALOME.SALOME_Exception as e:
+    notifyGui_error("An error occured while creating the deflection shape:\n" + e.details.text)
+    raise Exception(e.details.text)
+
+
 def MakePointSprite(proxy,
                   viewMode=MEDCALC.VIEW_MODE_DEFAULT,
                   displayedComponent=MEDCALC.DISPLAY_DEFAULT,
@@ -150,7 +158,7 @@ GetContourParameters = lambda pres_id: __GetGENERICParameters("Contour", pres_id
 GetSlicesParameters = lambda pres_id: __GetGENERICParameters("Slices", pres_id)
 GetPointSpriteParameters = lambda pres_id: __GetGENERICParameters("PointSprite", pres_id)
 GetVectorFieldParameters = lambda pres_id: __GetGENERICParameters("VectorField", pres_id)
-#GetDeflectionShapeParameters = lambda pres_id: __GetGENERICParameters("DeflectionShape", pres_id)
+GetDeflectionShapeParameters = lambda pres_id: __GetGENERICParameters("DeflectionShape", pres_id)
 
 
 def __UpdateGENERIC(tag, presentation_id, params):
@@ -163,7 +171,7 @@ UpdateContour = lambda pres_id, params: __UpdateGENERIC("Contour", pres_id, para
 UpdateSlices = lambda pres_id, params: __UpdateGENERIC("Slices", pres_id, params)
 UpdateVectorField = lambda pres_id, params: __UpdateGENERIC("VectorField", pres_id, params)
 UpdatePointSprite = lambda pres_id, params: __UpdateGENERIC("PointSprite", pres_id, params)
-#UpdateDeflectionShape = lambda pres_id, params: __UpdateGENERIC("DeflectionShape", pres_id, params)
+UpdateDeflectionShape = lambda pres_id, params: __UpdateGENERIC("DeflectionShape", pres_id, params)
 
 def ComputeCellAverageSize(obj):
   """