]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
[MEDCalc] Fully functional scalar map (other pres deactivated)
authorabn <adrien.bruneton@cea.fr>
Wed, 27 Jul 2016 09:27:00 +0000 (11:27 +0200)
committerabn <adrien.bruneton@cea.fr>
Wed, 27 Jul 2016 13:53:17 +0000 (15:53 +0200)
  + color map, scalar bar range, component can be edited
  + low level ParaVis dump available

39 files changed:
idl/MEDPresentationManager.idl
idl/MED_Gen.idl
src/MEDCalc/MEDCalcConstants.hxx
src/MEDCalc/cmp/CMakeLists.txt
src/MEDCalc/cmp/MED.cxx
src/MEDCalc/cmp/MED.hxx
src/MEDCalc/cmp/MEDDataManager_i.cxx
src/MEDCalc/cmp/MEDPresentation.cxx
src/MEDCalc/cmp/MEDPresentation.hxx
src/MEDCalc/cmp/MEDPresentation.txx
src/MEDCalc/cmp/MEDPresentationContour.cxx
src/MEDCalc/cmp/MEDPresentationContour.hxx
src/MEDCalc/cmp/MEDPresentationException.hxx
src/MEDCalc/cmp/MEDPresentationManager_i.cxx
src/MEDCalc/cmp/MEDPresentationManager_i.hxx
src/MEDCalc/cmp/MEDPresentationManager_i.txx
src/MEDCalc/cmp/MEDPresentationScalarMap.cxx
src/MEDCalc/cmp/MEDPresentationScalarMap.hxx
src/MEDCalc/gui/CMakeLists.txt
src/MEDCalc/gui/DatasourceController.cxx
src/MEDCalc/gui/MEDModule.cxx
src/MEDCalc/gui/MEDModule.hxx
src/MEDCalc/gui/MEDWidgetHelper.cxx [new file with mode: 0644]
src/MEDCalc/gui/MEDWidgetHelper.hxx [new file with mode: 0644]
src/MEDCalc/gui/MEDWidgetHelperScalarMap.cxx [new file with mode: 0644]
src/MEDCalc/gui/MEDWidgetHelperScalarMap.hxx [new file with mode: 0644]
src/MEDCalc/gui/MED_msg_en.ts
src/MEDCalc/gui/MED_msg_fr.ts
src/MEDCalc/gui/PresentationController.cxx
src/MEDCalc/gui/PresentationController.hxx
src/MEDCalc/gui/PresentationEvent.hxx [new file with mode: 0644]
src/MEDCalc/gui/WorkspaceController.cxx
src/MEDCalc/gui/WorkspaceController.hxx
src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx
src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx
src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui
src/MEDCalc/tui/__init__.py
src/MEDCalc/tui/fieldproxy.py
src/MEDCalc/tui/medpresentation.py

index c3e100225381634171c8dcb7ca63d8ba505220bf..4007aa8d55ea8edb028d5e329d453737a89158f2 100644 (file)
@@ -39,16 +39,23 @@ module MEDCALC
     COLOR_MAP_COOL_TO_WARM
   };
 
-  struct ScalarBarRange {
-    // (valMin,valMax) defines the scalar bar range from:
-    //      (-1,timetep): the field values at the chosen timestep
-    //      (-1,-1):      the field values across all timesteps
-    //      (start,end):  a user-input range of values
-    long valMin;
-    long valMax;
+  enum MEDPresentationScalarBarRange {
+    SCALAR_BAR_ALL_TIMESTEPS,
+    SCALAR_BAR_CURRENT_TIMESTEP
   };
 
-  const string DISPLAY_EUCLIDEAN_NORM = "Euclidean norm";
+
+//  struct ScalarBarRange {
+//    // (valMin,valMax) defines the scalar bar range from:
+//    //      (-1,timestep): the field values at the chosen timestep
+//    //      (-1,-1):      the field values across all timesteps
+//    //      (-2,-2):      the field values at current timestep
+//    //      (start,end):  a user-input range of values
+//    long valMin;
+//    long valMax;
+//  };
+
+  const string DISPLAY_EUCLIDEAN_NORM = "";  // Void string to avoid clash with a real component name -- never used actually?
 
   enum SliceOrientation {
     SLICE_NORMAL_TO_X,
@@ -64,6 +71,7 @@ module MEDCALC
 
   const MEDPresentationViewMode VIEW_MODE_DEFAULT = VIEW_MODE_REPLACE;
   const MEDPresentationColorMap COLOR_MAP_DEFAULT = COLOR_MAP_BLUE_TO_RED_RAINBOW;
+  const MEDPresentationScalarBarRange SCALAR_BAR_RANGE_DEFAULT = SCALAR_BAR_ALL_TIMESTEPS;
   //const ScalarBarRange SCALAR_BAR_RANGE_DEFAULT = ;
   const long SCALAR_BAR_RANGE_VAL_MIN_DEFAULT = -1;
   const long SCALAR_BAR_RANGE_VAL_MAX_DEFAULT = -1;
@@ -76,77 +84,76 @@ module MEDCALC
 
   struct ScalarMapParameters {
     long fieldHandlerId;
-    MEDPresentationViewMode viewMode;
-    string displayedInfo; // DISPLAY_EUCLIDEAN_NORM or any field name
-    ScalarBarRange sbRange;
+    string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
+    MEDPresentationScalarBarRange scalarBarRange;
     MEDPresentationColorMap colorMap;
   };
 
   // A contour is an isoline in 2D and an isosurface in 3D
-  struct ContourParameters {
-    long fieldHandlerId;
-    MEDPresentationViewMode viewMode;
-    string displayedInfo; // DISPLAY_EUCLIDEAN_NORM or any field name
-    ScalarBarRange sbRange;
-    MEDPresentationColorMap colorMap;
-    long nbContours;
-  };
-
-  struct VectorFieldParameters {
-    long fieldHandlerId;
-    MEDPresentationViewMode viewMode;
-  };
-
-  struct SlicesParameters {
-    long fieldHandlerId;
-    MEDPresentationViewMode viewMode;
-    SliceOrientation orientation;
-    long nbSlices;
-  };
-
-  struct DeflectionShapeParameters {
-    long fieldHandlerId;
-    MEDPresentationViewMode viewMode;
-  };
-
-  struct PointSpriteParameters {
-    long fieldHandlerId;
-    MEDPresentationViewMode viewMode;
-    string displayedInfo; // DISPLAY_EUCLIDEAN_NORM or any field name
-    ScalarBarRange sbRange;
-    MEDPresentationColorMap colorMap;
-  };
+//  struct ContourParameters {
+//    long fieldHandlerId;
+//    string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
+//    ScalarBarRange scalarBarRange;
+//    MEDPresentationColorMap colorMap;
+//    long nbContours;
+//  };
+//
+//  struct VectorFieldParameters {
+//    long fieldHandlerId;
+//  };
+//
+//  struct SlicesParameters {
+//    long fieldHandlerId;
+//    SliceOrientation orientation;
+//    long nbSlices;
+//  };
+//
+//  struct DeflectionShapeParameters {
+//    long fieldHandlerId;
+//  };
+//
+//  struct PointSpriteParameters {
+//    long fieldHandlerId;
+//    string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
+//    ScalarBarRange scalarBarRange;
+//    MEDPresentationColorMap colorMap;
+//  };
 
   /* Functions */
 
   interface MEDPresentationManager : SALOME::GenericObj
   {
+    long makeScalarMap(in ScalarMapParameters params, in MEDPresentationViewMode viewMode);
+//    long makeContour(in ContourParameters params, in MEDPresentationViewMode viewMode);
+//    long makeVectorField(in VectorFieldParameters params, in MEDPresentationViewMode viewMode);
+//    long makeSlices(in SlicesParameters params, in MEDPresentationViewMode viewMode);
+//    long makeDeflectionShape(in DeflectionShapeParameters params, in MEDPresentationViewMode viewMode);
+//    long makePointSprite(in PointSpriteParameters params, in MEDPresentationViewMode viewMode);
 
-    long makeScalarMap(in ScalarMapParameters params);
-    long makeContour(in ContourParameters params);
-    long makeVectorField(in VectorFieldParameters params);
-    long makeSlices(in SlicesParameters params);
-    long makeDeflectionShape(in DeflectionShapeParameters params);
-    long makePointSprite(in PointSpriteParameters params);
+    void setPresentationStringProperty(in long presId, in string propName, in string propValue);
+    string getPresentationStringProperty(in long presId, in string propName);
+    void setPresentationIntProperty(in long presId, in string propName, in long propValue);
+    long getPresentationIntProperty(in long presId, in string propName);
 
-    void setPresentationProperty(in long presId, in string propName, in string propValue);
-    string getPresentationProperty(in long presId, in string propName);
+    ScalarMapParameters getScalarMapParameters(in long presId);
 
     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 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);
 
     boolean removePresentation(in long presId);
 
-    // Helper functions to keep GUI sync
+    // Helper function to keep GUI sync
     boolean activateView(in long presentationId);
 
+    // Low level ParaVis dump
+    string getParavisDump(in long presId);
+    
     MEDPresentationViewMode getPresentationViewMode(in long presId);
   };
-
 };
 
 #endif
index 21df0b93374d867cc8eee8fd69501dd57e7aa0c0..94bd24136828607352a30b5cb664da9ddbbb3c83 100644 (file)
@@ -46,7 +46,8 @@ module MED_ORB
     status registerPresentation(in SALOMEDS::Study study,
                                 in long fieldId,
                                 in string name,
-                                in string label,
+                                in string type,
+                                in string ico,
                                 in long presentationId)
       raises (SALOME::SALOME_Exception);
 
index 2023db6d7986d89c7c3f48c0290308ba08ba6e37..934ee38b0d864f3af76252b4408e63d6200b0c4d 100644 (file)
@@ -26,8 +26,9 @@
 #define FIELD_ID         "fieldId"
 #define PRESENTATION_ID  "presentationId"
 #define IS_PRESENTATION  "isPresentation"
-
+#define PRESENTATION_TYPE  "presentationType"
 
 static const int NB_TYPE_OF_FIELDS = 4;
 static const char* mapTypeOfFieldLabel[NB_TYPE_OF_FIELDS] =
   {"ON_CELLS", "ON_NODES", "ON_GAUSS_PT", "ON_GAUSS_NE" };
+
index 63415add6e5c2ee18715fc1ca79656d4c6395f53..489d221ce5ed73b1f4c0107e555549e7c2aacbd8 100644 (file)
@@ -41,11 +41,11 @@ SET(COMMON_SOURCES
   MEDPresentation.cxx
   # presentations
   MEDPresentationScalarMap.cxx
-  MEDPresentationContour.cxx
-  MEDPresentationVectorField.cxx
-  MEDPresentationSlices.cxx
-  MEDPresentationDeflectionShape.cxx
-  MEDPresentationPointSprite.cxx
+#  MEDPresentationContour.cxx
+#  MEDPresentationVectorField.cxx
+#  MEDPresentationSlices.cxx
+#  MEDPresentationDeflectionShape.cxx
+#  MEDPresentationPointSprite.cxx
 )
 
 SET(MEDFactoryEngine_SOURCES
index 99b6976c6a07e0c4f55d4395e7af546b4494aef1..1d0ff2fe4350509a9122722395233878a660a1da 100644 (file)
@@ -28,6 +28,7 @@
 #include <Utils_ExceptHandlers.hxx>
 #include <SALOME_LifeCycleCORBA.hxx>
 #include <SALOME_NamingService.hxx>
+#include <SALOME_KernelServices.hxx>
 
 #include <string>
 #include <sstream>
@@ -159,22 +160,30 @@ MED_ORB::status
 MED::registerPresentation(SALOMEDS::Study_ptr study,
                           CORBA::Long fieldId,
                           const char* name,
-                          const char* label,
+                          const char* type,
+                          const char* ico,
                           CORBA::Long presentationId)
 {
   // set exception handler to catch unexpected CORBA exceptions
   Unexpect aCatch(SALOME_SalomeException);
 
-  if (_fieldSeriesEntries.find(fieldId) == _fieldSeriesEntries.end()) {
-    std::cerr << "Field not found\n";
+  MEDCALC::FieldHandler_var fldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
+  int fieldSeriesId = fldHandler->fieldseriesId;
+  if (fieldSeriesId < 0){
+      std::cerr << "MED::registerPresentation(): Error getting field handler\n";
+      return MED_ORB::OP_ERROR ;
+    }
+
+  if (_fieldSeriesEntries.find(fieldSeriesId) == _fieldSeriesEntries.end()) {
+    std::cerr << "MED::registerPresentation(): Field series not found\n";
     return MED_ORB::OP_ERROR ;
   }
-  std::string entry = _fieldSeriesEntries[fieldId];
+  std::string entry = _fieldSeriesEntries[fieldSeriesId];
   SALOMEDS::SObject_var sobject = study->FindObjectID(entry.c_str());
   SALOMEDS::SObject_ptr soFieldseries = sobject._retn();
 
   if (soFieldseries->IsNull()) {
-    std::cerr << "Entry not found\n";
+    std::cerr << "MED::registerPresentation(): Entry not found\n";
     return MED_ORB::OP_ERROR;
   }
 
@@ -184,7 +193,7 @@ MED::registerPresentation(SALOMEDS::Study_ptr study,
   useCaseBuilder->AppendTo(soPresentation->GetFather(), soPresentation);
 
   soPresentation->SetAttrString("AttributeName", name);
-  soPresentation->SetAttrString("AttributePixMap", label);
+  soPresentation->SetAttrString("AttributePixMap", ico);
 
   SALOMEDS::GenericAttribute_var anAttr;
   SALOMEDS::AttributeParameter_var aParam;
@@ -193,6 +202,7 @@ MED::registerPresentation(SALOMEDS::Study_ptr study,
   aParam->SetInt(FIELD_ID, fieldId);
   aParam->SetBool(IS_PRESENTATION, true);
   aParam->SetInt(PRESENTATION_ID, presentationId);
+  aParam->SetString(PRESENTATION_TYPE, type);
 
   return MED_ORB::OP_OK;
 }
index ddd373a7696924a51e0c47d5c525203f565d937c..c4b432234b5d840c32dec2b22c30fd6988b13451 100644 (file)
@@ -58,7 +58,8 @@ public:
   MED_ORB::status registerPresentation(SALOMEDS::Study_ptr study,
                                        CORBA::Long fieldId,
                                        const char* name,
-                                       const char* label,
+                                       const char* type,
+                                       const char* ico,
                                        CORBA::Long presentationId);
 
   MED_ORB::status unregisterPresentation(SALOMEDS::Study_ptr study,
index 3db0cd3dd419378b291fa330ffafc6ac4edf9b7d..7896465c86fecd5a798d6e5a20f287c59b7a191a 100644 (file)
@@ -182,6 +182,7 @@ MEDCALC::DatasourceHandler * MEDDataManager_i::loadDatasource(const char *filepa
     fieldHandler->meshid = meshHandler->id;
     fieldHandler->fieldseriesId = fieldseriesHandler->id;
     _fieldHandlerMap[fieldHandler->id] = fieldHandler;
+//    LOG("=== Storing " << fieldName << " (" << fieldHandler->id << ")");
   }
       }
     }
index 48305be826ccb315fcda4adcfdbef4c0c288bc16..61c631d689dd86cc1d131788d68af1b715e394a5 100644 (file)
 #include "MEDPresentation.hxx"
 #include "MEDPresentationException.hxx"
 #include "MEDCouplingRefCountObject.hxx"
-#include "Basics_Utils.hxx"
-#include "PyInterp_Utils.h"
+#include <SALOME_KernelServices.hxx>
+#undef LOG
+#include <Basics_Utils.hxx>
+#include <PyInterp_Utils.h>
 
 #include <sstream>
 
-MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name)
-    : _fieldHandlerId(fieldHandlerId), _pipeline(0), _display(0), _properties(),
-      _renderViewPyId(GeneratePythonId())
+const std::string MEDPresentation::PROP_NAME  = "name";
+const std::string MEDPresentation::PROP_NB_COMPONENTS = "nbComponents";
+const std::string MEDPresentation::PROP_SELECTED_COMPONENT = "selectedComponent";
+const std::string MEDPresentation::PROP_COMPONENT = "component_";
+const std::string MEDPresentation::PROP_COLOR_MAP = "colorMap";
+const std::string MEDPresentation::PROP_SCALAR_BAR_RANGE = "scalarBarRange";
+
+MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name,
+                                 const MEDCALC::MEDPresentationViewMode viewMode,
+                                 const MEDCALC::MEDPresentationColorMap colorMap)
+    : _fieldHandlerId(fieldHandlerId), _propertiesStr(),
+      //_pipeline(0), _display(0)
+      _selectedComponentIndex(-1),
+      _viewMode(viewMode),
+      _colorMap(colorMap),
+      _renderViewPyId(GeneratePythonId()),
+      _objId(_renderViewPyId), _dispId(_renderViewPyId), _lutId(_renderViewPyId),
+      _globalDict(0)
 {
   MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
   MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId);
@@ -46,7 +63,13 @@ MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const s
   }
   _fileName = _fileName.substr(7, _fileName.size());
 
-  setProperty("name", name);
+  setStringProperty(MEDPresentation::PROP_NAME, name);
+
+  setIntProperty(MEDPresentation::PROP_NB_COMPONENTS, 0);
+  setIntProperty(MEDPresentation::PROP_SELECTED_COMPONENT, 0);
+
+  setIntProperty(MEDPresentation::PROP_COLOR_MAP, static_cast<int>(MEDCALC::COLOR_MAP_DEFAULT));
+  setIntProperty(MEDPresentation::PROP_SCALAR_BAR_RANGE, static_cast<int>(MEDCALC::SCALAR_BAR_RANGE_DEFAULT));
 }
 
 MEDPresentation::~MEDPresentation()
@@ -55,13 +78,11 @@ MEDPresentation::~MEDPresentation()
   {
     PyLockWrapper lock;
     std::ostringstream oss_o, oss_v, oss;
-    // Get top level object and display:
-    oss_o << "__obj" << _pipeline.front().first;
+    oss_o << "__obj" << _objId;
     oss_v << "__view" << _renderViewPyId;
     oss << "pvs.Hide(" << oss_o.str() <<  ", view=" << oss_v.str() << ");";
     oss << "pvs.Render();";
 
-//    std::cerr << oss.str() << std::endl;
     PyRun_SimpleString(oss.str().c_str());
   }
 }
@@ -74,56 +95,102 @@ MEDPresentation::generatePipeline()
   this->internalGeneratePipeline();
 }
 
-void
-MEDPresentation::pushPyObjects(PyObjectId obj, PyObjectId disp)
-{
-  _pipeline.push_back(obj);
-  _display.push_back(disp);
-}
+//void
+//MEDPresentation::pushPyObjects(PyObjectId obj, PyObjectId disp)
+//{
+//  _pipeline.push_back(obj);
+//  _display.push_back(disp);
+//}
 
 void
 MEDPresentation::pushAndExecPyLine(const std::string & lin)
 {
-  // TODO: store internally for low level dump
   PyLockWrapper lock;
 //  std::cerr << lin << std::endl;
-  PyRun_SimpleString(lin.c_str());
+  if(PyRun_SimpleString(lin.c_str()))
+    {
+      std::ostringstream oss;
+      oss << "MEDPresentation::pushAndExecPyLine(): following Python command failed!\n";
+      oss << ">> " << lin;
+      STDLOG(oss.str());
+      throw KERNEL::createSalomeException(oss.str().c_str());
+    }
+  _pythonCmds.push_back(lin);
 }
 
 void
-MEDPresentation::setProperty(const std::string& propName, const std::string& propValue)
+MEDPresentation::setStringProperty(const std::string& propName, const std::string& propValue)
 {
-  // LIMITED!!! For now switch the first display element to Wireframe
-  /*
-  PyLockWrapper lock;
-  PyObject_CallMethod(_display[0], (char*)"SetRepresentationType", (char*)"(s)", "Wireframe");
-  */
-
-  _properties[propName] = propValue;
+  _propertiesStr[propName] = propValue;
 }
 
 const std::string
-MEDPresentation::getProperty(const std::string& propName) const
+MEDPresentation::getStringProperty(const std::string& propName) const
 {
-  std::map<std::string, std::string>::const_iterator it = _properties.find(propName);
-  if (it != _properties.end()) {
-    return (*it).second;
+  std::map<std::string, std::string>::const_iterator it = _propertiesStr.find(propName);
+  if (it != _propertiesStr.end()) {
+      return (*it).second;
   }
   else {
-    STDLOG("MEDPresentation::getProperty(): no property named " + propName);
-    return std::string();
+      throw MEDPresentationException("MEDPresentation::getStringProperty(): no property named " + propName);
   }
 }
 
+void
+MEDPresentation::setIntProperty(const std::string& propName, const int propValue)
+{
+  _propertiesInt[propName] = propValue;
+}
+
+int
+MEDPresentation::getIntProperty(const std::string& propName) const
+{
+  std::map<std::string, int>::const_iterator it = _propertiesInt.find(propName);
+  if (it != _propertiesInt.end()) {
+      return (*it).second;
+  }
+  else {
+      throw MEDPresentationException("MEDPresentation::getIntProperty(): no property named " + propName);
+  }
+}
+
+ void
+ MEDPresentation::dumpIntProperties() const
+ {
+   std::map<std::string, int>::const_iterator it = _propertiesInt.begin();
+   STDLOG("@@@ Dumping INT properties");
+   for(; it != _propertiesInt.end(); ++it)
+     {
+       std::ostringstream oss;
+       oss << (*it).first << "  ->   " << (*it).second;
+       STDLOG(oss.str());
+     }
+ }
+
+ void
+ MEDPresentation::dumpStringProperties() const
+ {
+   std::map<std::string, std::string>::const_iterator it = _propertiesStr.begin();
+   STDLOG("@@@ Dumping STR properties");
+   for(; it != _propertiesStr.end(); ++it)
+     {
+       std::ostringstream oss;
+       oss << (*it).first << "  ->   " << (*it).second;
+       STDLOG(oss.str());
+     }
+ }
+
+
 PyObject*
 MEDPresentation::getPythonObjectFromMain(const char* python_var) const
 {
-  // TODO: improve to avoid getting dict at each call
-
-  // All the calls below returns *borrowed* references
-  PyObject* main_module = PyImport_AddModule((char*)"__main__");
-  PyObject* global_dict = PyModule_GetDict(main_module);
-  return PyDict_GetItemString(global_dict, python_var);
+  if (! _globalDict)
+    {
+      // All the calls below returns *borrowed* references
+      PyObject* main_module = PyImport_AddModule((char*)"__main__");
+      _globalDict = PyModule_GetDict(main_module);
+    }
+  return PyDict_GetItemString(_globalDict, python_var);
 }
 
 std::string
@@ -142,23 +209,23 @@ MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldType) const
 }
 
 std::string
-MEDPresentation::getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode) const
+MEDPresentation::getRenderViewCommand() const
 {
   std::ostringstream oss, oss2;
   oss << "__view" << _renderViewPyId;
   std::string view(oss.str());
-  oss2 << "pvs._DisableFirstRenderCameraReset();";
-  if (viewMode == MEDCALC::VIEW_MODE_OVERLAP) {
-      oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');";
-  } else if (viewMode == MEDCALC::VIEW_MODE_REPLACE) {
-      oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');";
-      oss2 << "pvs.active_objects.source and pvs.Hide(view=" << view << ");";
-      oss2 << "pvs.Render();";
-  } else if (viewMode == MEDCALC::VIEW_MODE_NEW_LAYOUT) {
-      oss2 <<  "__layout1 = pvs.servermanager.misc.ViewLayout(registrationGroup='layouts');";
-      oss2 << view << " = pvs.CreateView('RenderView');";
-  } else if (viewMode == MEDCALC::VIEW_MODE_SPLIT_VIEW) {
-      oss2 << view << " = pvs.CreateView('RenderView');";
+  oss2 << "pvs._DisableFirstRenderCameraReset();" << std::endl;
+  if (_viewMode == MEDCALC::VIEW_MODE_OVERLAP) {
+      oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');" << std::endl;
+  } else if (_viewMode == MEDCALC::VIEW_MODE_REPLACE) {
+      oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');" << std::endl;
+      oss2 << "pvs.active_objects.source and pvs.Hide(view=" << view << ");" << std::endl;
+      oss2 << "pvs.Render();" << std::endl;
+  } else if (_viewMode == MEDCALC::VIEW_MODE_NEW_LAYOUT) {
+      oss2 <<  "__layout1 = pvs.servermanager.misc.ViewLayout(registrationGroup='layouts');" << std::endl;
+      oss2 << view << " = pvs.CreateView('RenderView');" << std::endl;
+  } else if (_viewMode == MEDCALC::VIEW_MODE_SPLIT_VIEW) {
+      oss2 << view << " = pvs.CreateView('RenderView');" << std::endl;
   }
   return oss2.str();
 }
@@ -172,12 +239,57 @@ MEDPresentation::getResetCameraCommand() const
 }
 
 std::string
-MEDPresentation::getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap) const
+MEDPresentation::getComponentSelectionCommand() const
+{
+  std::ostringstream oss, oss_l;
+  oss_l << "__lut" << _lutId;    std::string lut(oss_l.str());
+
+  if (_selectedComponentIndex != -1)
+    {
+      oss << lut << ".VectorMode = 'Component';\n";
+      oss << lut << ".VectorComponent = " << _selectedComponentIndex << ";";
+    }
+  else  // Euclidean norm
+    {
+      oss << lut << ".VectorMode = 'Magnitude';";
+    }
+  return oss.str();
+}
+
+std::string
+MEDPresentation::getColorMapCommand() const
 {
-  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";
+  std::ostringstream oss, oss_l;
+  oss_l << "__lut" << _lutId;    std::string lut(oss_l.str());
+  switch (_colorMap) {
+  case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW:
+    oss << lut << ".ApplyPreset('Blue to Red Rainbow',True);";
+    break;
+  case MEDCALC::COLOR_MAP_COOL_TO_WARM:
+    oss << lut << ".ApplyPreset('Cool to Warm',True);";
+    break;
+  default:
+    throw KERNEL::createSalomeException("MEDPresentation::getColorMapCommand(): invalid colormap!");
   }
+  return oss.str();
+}
+std::string
+MEDPresentation::getRescaleCommand() const
+{
+  std::ostringstream oss, oss_d;
+  oss_d << "__disp" << _dispId;    std::string disp(oss_d.str());
+  switch(_sbRange)
+  {
+    case MEDCALC::SCALAR_BAR_ALL_TIMESTEPS:
+      oss << disp <<  ".RescaleTransferFunctionToDataRangeOverTime();";
+      break;
+    case MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP:
+      oss << disp <<  ".RescaleTransferFunctionToDataRange(False);";
+      break;
+    default:
+      throw KERNEL::createSalomeException("MEDPresentation::getRescaleCommand(): invalid range!");
+  }
+  return oss.str();
 }
 
 int
@@ -188,11 +300,81 @@ MEDPresentation::GeneratePythonId()
 }
 
 void
-MEDPresentation::activateView() const
+MEDPresentation::activateView()
 {
   PyLockWrapper lock;
+
   std::ostringstream oss;
   oss << "pvs.SetActiveView(__view" << _renderViewPyId << ");";
-  std::cerr << oss.str() << std::endl;
+  pushAndExecPyLine(oss.str());
+}
+
+
+std::string
+MEDPresentation::paravisDump() const
+{
+  using namespace std;
+  ostringstream oss;
+  for (vector<string>::const_iterator it=_pythonCmds.begin(); it != _pythonCmds.end(); ++it)
+    {
+      oss << (*it);
+      oss << "\n";
+    }
+  return oss.str();
+}
+
+/**
+ * Query all available component names for the field associated with this presentation.
+ * Fills in all the corresponding string properties:
+ *  - PROP_COMPONENT1
+ *  - PROP_COMPONENT2
+ *    etc...
+ *  and the number of components.
+ */
+void
+MEDPresentation::fillAvailableFieldComponents()
+{
+  PyLockWrapper lock;  // GIL!
+
+  std::ostringstream oss_o;
+  oss_o << "__obj" << _objId;      std::string obj(oss_o.str());
+  std::string typ;
+
+  if(_fieldType == "CELLS") {
+      typ = "CellData";
+  }
+  else if (_fieldType == "POINTS") {
+      typ = "PointData";
+  }
+  else {
+      std::string msg("Unsupported spatial discretisation: " + _fieldType);
+      throw KERNEL::createSalomeException(msg.c_str());
+  }
+
+  std::ostringstream oss;
+  oss << "__nbCompo = " << obj << "." << typ << ".GetArray('" <<  _fieldName << "').GetNumberOfComponents();";
   PyRun_SimpleString(oss.str().c_str());
+  PyObject* p_obj = getPythonObjectFromMain("__nbCompo");
+  long nbCompo;
+  if (p_obj && PyInt_Check(p_obj))
+    nbCompo = PyInt_AS_LONG(p_obj);
+  else
+    throw KERNEL::createSalomeException("Unexpected Python error");
+  setIntProperty(MEDPresentation::PROP_NB_COMPONENTS, nbCompo);
+  for (long i = 0; i<nbCompo; i++)
+    {
+      std::ostringstream oss2;
+      oss2 << "__compo = " << obj << "." << typ << ".GetArray('" <<  _fieldName << "').GetComponentName(" << i << ");";
+      PyRun_SimpleString(oss2.str().c_str());
+      PyObject* p_obj = getPythonObjectFromMain("__compo");
+      std::string compo;
+      if (p_obj && PyString_Check(p_obj))
+        compo = std::string(PyString_AsString(p_obj));  // pointing to internal Python memory, so make a copy!!
+      else
+        throw KERNEL::createSalomeException("Unexpected Python error");
+      std::ostringstream oss_p;
+      oss_p << MEDPresentation::PROP_COMPONENT << i;
+      setStringProperty(oss_p.str(), compo);
+    }
 }
+
index d67971dbed4236e2d3c43efa12d569b161309871..4307e356fcd1b51214bd4013234cbca0b35bee4a 100644 (file)
@@ -38,65 +38,117 @@ class MEDCALC_EXPORT MEDPresentation
   friend class MEDPresentationManager_i;
 
 public:
-
   typedef ::CORBA::Long TypeID;
 
   virtual ~MEDPresentation();
 
-  void setProperty(const std::string& propName, const std::string& propValue);
-  const std::string getProperty(const std::string& propName) const;
+  static const std::string PROP_NAME;                 // name of the presentation
+  static const std::string PROP_NB_COMPONENTS;        // number of field components
+  static const std::string PROP_SELECTED_COMPONENT;   // index of the selected component - 0 means Euclidean norm
+  static const std::string PROP_COMPONENT;            // string prefix for all properties storing component names
+
+  static const std::string PROP_COLOR_MAP;            // color map - TODO: arch fix - should be in params only
+  static const std::string PROP_SCALAR_BAR_RANGE;     // scalar bar range - TODO: arch fix - should be in params only
+
+  virtual void setStringProperty(const std::string& propName, const std::string& propValue);
+  const std::string getStringProperty(const std::string& propName) const;
+
+  virtual void setIntProperty(const std::string& propName, const int propValue);
+  int getIntProperty(const std::string& propName) const;
 
-  void activateView() const;
+  void activateView();  // non const because generates a Python trace
+
+  void dumpIntProperties() const;
+  void dumpStringProperties() const;
+
+  std::string paravisDump() const;
 
 protected:
   typedef std::pair<int, PyObject *> PyObjectId;
+  static int GeneratePythonId();
 
-  MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name);
-  std::string getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode) const;
+  MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name,
+                  const MEDCALC::MEDPresentationViewMode viewMode,
+                  const MEDCALC::MEDPresentationColorMap colorMap);
+  std::string getRenderViewCommand() const;
   std::string getResetCameraCommand() const;
-  std::string getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap) const;
+
+  std::string getComponentSelectionCommand() const;
+  std::string getColorMapCommand() const;
+  std::string getRescaleCommand() const;
 
   virtual void internalGeneratePipeline() = 0;
   PyObject* getPythonObjectFromMain(const char* var) const;
-  void pushPyObjects(PyObjectId obj, PyObjectId disp);
+//  void pushPyObjects(PyObjectId obj, PyObjectId disp);
   void pushAndExecPyLine(const std::string & lin);
 
   MEDPresentation::TypeID getID() const { return _fieldHandlerId; }
   long getPyViewID() const { return _renderViewPyId; }
 
-  static int GeneratePythonId();
+  void fillAvailableFieldComponents();
 
+  // TODO: follow the pattern of the others methods: template!
   virtual MEDCALC::MEDPresentationViewMode getViewMode() = 0;
 
-private:
+  template<typename PresentationType, typename PresentationParameters>
+  void updateComponent(const std::string& newCompo);
 
+  template<typename PresentationType, typename PresentationParameters>
+  void updateColorMap(MEDCALC::MEDPresentationColorMap colorMap);
+
+  template<typename PresentationType, typename PresentationParameters>
+  void updateScalarBarRange(MEDCALC::MEDPresentationScalarBarRange sbRange);
+
+  template<typename PresentationType, typename PresentationParameters>
+  void getParameters(PresentationParameters& params) const;
+
+  template<typename PresentationType, typename PresentationParameters>
+  void setParameters(const PresentationParameters& params);
+
+private:
   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);
+  void updatePipeline(const PresentationParameters& params);
 
 protected:
   std::string _fileName;
   std::string _fieldName;
   std::string _fieldType;
 
+  MEDPresentation::TypeID _fieldHandlerId;
+
+  int _selectedComponentIndex;
+  MEDCALC::MEDPresentationViewMode _viewMode;
+  MEDCALC::MEDPresentationColorMap _colorMap;
+  MEDCALC::MEDPresentationScalarBarRange _sbRange;
+
   ///! Identifier (in the Python dump) of the render view
   int _renderViewPyId;
+  ///! ParaView object ID in the Python scripting commands
+  int _objId;
+  ///! ParaView display ID in the Python scripting commands
+  int _dispId;
+  ///! ParaView LUT ID in the Python scripting commands
+  int _lutId;
 
 private:
-  MEDPresentation::TypeID _fieldHandlerId;
-
   ///! Pipeline elements
-  std::vector<PyObjectId> _pipeline;
+//  std::vector<PyObjectId> _pipeline;
 
   ///! Corresponding display object, if any:
-  std::vector<PyObjectId> _display;
+//  std::vector<PyObjectId> _display;
 
   ///! Presentation properties <key,value>
-  std::map<std::string, std::string> _properties;
+  std::map<std::string, std::string> _propertiesStr;
+  std::map<std::string, int> _propertiesInt;
+
+  std::vector<std::string> _pythonCmds;
+
+  mutable PyObject* _globalDict;
 };
 
 #include "MEDPresentation.txx"
index a99a462606ce19da9097d09723dfe539ea2bc909..f4100e77bbfea009234bf097a38086acd8d13e5e 100644 (file)
 #ifndef _MED_PRESENTATION_TXX_
 #define _MED_PRESENTATION_TXX_
 
+#include <sstream>
+#include <SALOME_KernelServices.hxx>
+#include <PyInterp_Utils.h>
+
 template<typename PresentationType, typename PresentationParameters>
 void
-MEDPresentation::updatePipeline(PresentationParameters params)
+MEDPresentation::updatePipeline(const PresentationParameters& params)
 {
   static_cast<PresentationType*>(this)->updatePipeline(params);
 }
 
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentation::getParameters(PresentationParameters& params) const
+{
+  const PresentationType * p = static_cast<const PresentationType*>(this);
+  p->getParameters(params);
+}
+
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentation::setParameters(const PresentationParameters& params)
+{
+  PresentationType * p = static_cast<PresentationType*>(this);
+  p->setParameters(params);
+}
+
+
+/**
+ * Update the ParaVis pipeline so that the given component appears on screen.
+ * Blank means "Euclidean norm"
+ * The property PROP_SELECTED_COMPONENT holding the corresponding index selected is also updated (help for the GUI).
+ */
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentation::updateComponent(const std::string& newCompo)
+{
+  PresentationType * p = static_cast<PresentationType*>(this);
+
+  PresentationParameters params;
+  p->getParameters(params);
+  params.displayedComponent = newCompo.c_str();
+  p->setParameters(params);
+
+
+
+  int nbCompo = getIntProperty(MEDPresentation::PROP_NB_COMPONENTS);
+  int idx = -1;
+  for (int i=0; i < nbCompo; i++)
+    {
+      std::ostringstream oss_p;
+      oss_p << MEDPresentation::PROP_COMPONENT << i;
+      std::string compo = getStringProperty(oss_p.str());
+      if (compo == newCompo)
+        {
+          idx = i;
+          break;
+        }
+    }
+  if (idx == -1 && newCompo != "")
+    {
+      std::string msg("updateComponent(): internal error - field component not found!");
+      throw KERNEL::createSalomeException(msg.c_str());
+    }
+  setIntProperty(MEDPresentation::PROP_SELECTED_COMPONENT, idx+1); // +1 because idx=0 means Euclidean norm
+  p->_selectedComponentIndex = idx;
+
+  // Update ParaView pipeline:
+  {
+    PyLockWrapper lock;
+
+    std::ostringstream oss;
+    std::string cmd = getComponentSelectionCommand();
+    pushAndExecPyLine(cmd);
+    pushAndExecPyLine("pvs.Render();");
+  }
+
+}
+
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentation::updateColorMap(MEDCALC::MEDPresentationColorMap colorMap)
+{
+  PresentationType * p = static_cast<PresentationType*>(this);
+
+  PresentationParameters params;
+  p->getParameters(params);
+  params.colorMap = colorMap;
+  p->setParameters(params);
+
+  p->_colorMap = colorMap;
+
+  // GUI helper:
+  setIntProperty(MEDPresentation::PROP_COLOR_MAP, colorMap);
+
+  // Update the pipeline:
+  {
+    PyLockWrapper lock;
+    std::string cmd = getColorMapCommand();
+    pushAndExecPyLine(cmd);
+    pushAndExecPyLine("pvs.Render();");
+  }
+}
+
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentation::updateScalarBarRange(MEDCALC::MEDPresentationScalarBarRange sbRange)
+{
+  PresentationType * p = static_cast<PresentationType*>(this);
+
+  PresentationParameters params;
+  p->getParameters(params);
+  params.scalarBarRange = sbRange;
+  p->setParameters(params);
+
+  p->_sbRange = sbRange;
+
+  // GUI helper:
+  setIntProperty(MEDPresentation::PROP_SCALAR_BAR_RANGE, sbRange);
+
+  // Update the pipeline:
+  {
+    PyLockWrapper lock;
+    std::string cmd = getRescaleCommand();
+    pushAndExecPyLine(cmd);
+    pushAndExecPyLine("pvs.Render();");
+  }
+}
+
+
 #endif // _MED_PRESENTATION_TXX_
index 87ce8e8c2818d17eb0e5d64abf814b2130d23bdf..a0f14a272cff8a35f3d7f4058e8b0faa26fdd18b 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "MEDPresentationContour.hxx"
 
+const std::string MEDPresentationContour::PROP_NB_CONTOUR = "nbContour";
+
 void
 MEDPresentationContour::internalGeneratePipeline()
 {
index 364965cd6000563a9748ba0d5b0dc99fcfc0f7e5..36acc6f728e8affc07e748ee5ad4148f8b54e0ac 100644 (file)
@@ -26,6 +26,8 @@
 class MEDCALC_EXPORT MEDPresentationContour : public MEDPresentation
 {
 public:
+  static const std::string PROP_NB_CONTOUR;
+
   MEDPresentationContour(const MEDCALC::ContourParameters& params) :
     MEDPresentation(params.fieldHandlerId, "MEDPresentationContour"), _params(params)
   {}
index adebd5179d2607b7478d6e9d2b15c09103efc246..dd66635b250b65c7fac40fac5cf19919faebc8fa 100644 (file)
@@ -36,6 +36,12 @@ public:
     this->_msg = oss.str();
   }
 
+  MEDPresentationException(const std::string& msg) {
+      std::ostringstream oss;
+      oss << "Error: " << msg;
+      this->_msg = oss.str();
+    }
+
   virtual ~MEDPresentationException() throw() {}
 
   virtual const char* what() const throw() {
index e88e77cfb59e0e810e0fe3600cd6f7145d41468b..f2608c1251f1fe3f082d8ec115221499af1c10d6 100644 (file)
 
 // presentations
 #include "MEDPresentationScalarMap.hxx"
-#include "MEDPresentationContour.hxx"
-#include "MEDPresentationVectorField.hxx"
-#include "MEDPresentationSlices.hxx"
-#include "MEDPresentationDeflectionShape.hxx"
-#include "MEDPresentationPointSprite.hxx"
+//#include "MEDPresentationContour.hxx"
+//#include "MEDPresentationVectorField.hxx"
+//#include "MEDPresentationSlices.hxx"
+//#include "MEDPresentationDeflectionShape.hxx"
+//#include "MEDPresentationPointSprite.hxx"
+
+#include <SALOME_KernelServices.hxx>
 
 #include <iostream>
 #include <sstream>
@@ -75,62 +77,92 @@ MEDPresentationManager_i::_getPresentation(MEDPresentation::TypeID presentationI
 }
 
 void
-MEDPresentationManager_i::setPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue)
+MEDPresentationManager_i::setPresentationStringProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue)
 {
   MEDPresentation* pres = _getPresentation(presentationID);
   if (pres)
-    pres->setProperty(propName, propValue);
+    pres->setStringProperty(propName, propValue);
   else
-    std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
+    throw KERNEL::createSalomeException("setPresentationStringProperty(): presentation not found!!");
 }
 
 char*
-MEDPresentationManager_i::getPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName)
+MEDPresentationManager_i::getPresentationStringProperty(MEDPresentation::TypeID presentationID, const char* propName)
 {
   MEDPresentation* pres = _getPresentation(presentationID);
   if (pres) {
-    return (char*) pres->getProperty(propName).c_str();
-  }
-  else {
-    std::cerr << "getPresentationProperty(): presentation not found!!" << std::endl;
-    return (char*) "";
+    return (char*) pres->getStringProperty(propName).c_str();
   }
+  else
+    throw KERNEL::createSalomeException("getPresentationStringProperty(): presentation not found!!");
 }
 
-MEDPresentation::TypeID
-MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params)
+void
+MEDPresentationManager_i::setPresentationIntProperty(MEDPresentation::TypeID presentationID, const char* propName,
+                                                     const CORBA::Long propValue)
 {
-  return _makePresentation<MEDPresentationScalarMap>(params);
+  MEDPresentation* pres = _getPresentation(presentationID);
+  if (pres)
+    pres->setIntProperty(propName, propValue);
+  else
+    throw KERNEL::createSalomeException("setPresentationIntProperty(): presentation not found!!");
 }
 
-MEDPresentation::TypeID
-MEDPresentationManager_i::makeContour(const MEDCALC::ContourParameters& params)
+CORBA::Long
+MEDPresentationManager_i::getPresentationIntProperty(MEDPresentation::TypeID presentationID, const char* propName)
 {
-  return _makePresentation<MEDPresentationContour>(params);
-}
+  MEDPresentation* pres = _getPresentation(presentationID);
+  if (pres) {
+    return (CORBA::Long) pres->getIntProperty(propName);
+  }
+  else
+    throw KERNEL::createSalomeException("getPresentationIntProperty(): presentation not found!!");
 
-MEDPresentation::TypeID
-MEDPresentationManager_i::makeVectorField(const MEDCALC::VectorFieldParameters& params)
-{
-  return _makePresentation<MEDPresentationVectorField>(params);
 }
 
 MEDPresentation::TypeID
-MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params)
+MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params, const MEDCALC::MEDPresentationViewMode viewMode)
 {
-  return _makePresentation<MEDPresentationSlices>(params);
+  return _makePresentation<MEDPresentationScalarMap>(params, viewMode);
 }
 
-MEDPresentation::TypeID
-MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params)
-{
-  return _makePresentation<MEDPresentationDeflectionShape>(params);
-}
+//MEDPresentation::TypeID
+//MEDPresentationManager_i::makeContour(const MEDCALC::ContourParameters& params)
+//{
+//  return _makePresentation<MEDPresentationContour>(params);
+//}
+//
+//MEDPresentation::TypeID
+//MEDPresentationManager_i::makeVectorField(const MEDCALC::VectorFieldParameters& params)
+//{
+//  return _makePresentation<MEDPresentationVectorField>(params);
+//}
+//
+//MEDPresentation::TypeID
+//MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params)
+//{
+//  return _makePresentation<MEDPresentationSlices>(params);
+//}
+//
+//MEDPresentation::TypeID
+//MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params)
+//{
+//  return _makePresentation<MEDPresentationDeflectionShape>(params);
+//}
+//
+//MEDPresentation::TypeID
+//MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params)
+//{
+//  return _makePresentation<MEDPresentationPointSprite>(params);
+//}
 
-MEDPresentation::TypeID
-MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params)
+MEDCALC::ScalarMapParameters*
+MEDPresentationManager_i::getScalarMapParameters(MEDPresentation::TypeID presentationID)
 {
-  return _makePresentation<MEDPresentationPointSprite>(params);
+  MEDCALC::ScalarMapParameters* p = new MEDCALC::ScalarMapParameters();
+  _getParameters<MEDPresentationScalarMap>(presentationID, *p);
+  MEDCALC::ScalarMapParameters_var tmp(p);
+  return tmp._retn();
 }
 
 void
@@ -139,35 +171,35 @@ MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID
   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);
-}
+//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);
+//}
 
 CORBA::Boolean
 MEDPresentationManager_i::removePresentation(MEDPresentation::TypeID presentationID)
@@ -214,3 +246,15 @@ MEDPresentationManager_i::getPresentationViewMode(MEDPresentation::TypeID presen
     return MEDCALC::VIEW_MODE_DEFAULT;
   }
 }
+
+char*
+MEDPresentationManager_i::getParavisDump(MEDPresentation::TypeID presentationID)
+{
+  MEDPresentation* pres = _getPresentation(presentationID);
+  if (pres) {
+    return (char*) pres->paravisDump().c_str();
+  }
+  else
+    throw KERNEL::createSalomeException("getParavisDump(): presentation not found!!");
+}
+
index 16c587583c355b7da86858d3e04df9b4d7be7b7f..5092867292c7aa87af13f7e729930e103d0c4b3a 100644 (file)
@@ -39,30 +39,32 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager,
 
   static MEDPresentationManager_i* getInstance();
 
-  MEDCALC_EXPORT MEDPresentation::TypeID makeScalarMap(const MEDCALC::ScalarMapParameters&);
-  MEDCALC_EXPORT MEDPresentation::TypeID makeContour(const MEDCALC::ContourParameters&);
-  MEDCALC_EXPORT MEDPresentation::TypeID makeVectorField(const MEDCALC::VectorFieldParameters&);
-  MEDCALC_EXPORT MEDPresentation::TypeID makeSlices(const MEDCALC::SlicesParameters&);
-  MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&);
-  MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&);
+  MEDCALC_EXPORT MEDPresentation::TypeID makeScalarMap(const MEDCALC::ScalarMapParameters&, const MEDCALC::MEDPresentationViewMode);
+//  MEDCALC_EXPORT MEDPresentation::TypeID makeContour(const MEDCALC::ContourParameters&, const MEDCALC::MEDPresentationViewMode);
+//  MEDCALC_EXPORT MEDPresentation::TypeID makeVectorField(const MEDCALC::VectorFieldParameters&);
+//  MEDCALC_EXPORT MEDPresentation::TypeID makeSlices(const MEDCALC::SlicesParameters&);
+//  MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&);
+//  MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&);
 
-  MEDCALC_EXPORT void setPresentationProperty(MEDPresentation::TypeID, const char* propName, const char* propValue);
-  MEDCALC_EXPORT char* getPresentationProperty(MEDPresentation::TypeID, const char* propName);
+  MEDCALC_EXPORT void setPresentationStringProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue);
+  MEDCALC_EXPORT char* getPresentationStringProperty(MEDPresentation::TypeID presentationID, const char* propName);
+
+  MEDCALC_EXPORT void setPresentationIntProperty(MEDPresentation::TypeID presentationID, const char* propName, const CORBA::Long propValue);
+  MEDCALC_EXPORT CORBA::Long getPresentationIntProperty(MEDPresentation::TypeID presentationID, const char* propName);
+
+  MEDCALC_EXPORT MEDCALC::ScalarMapParameters* getScalarMapParameters(MEDPresentation::TypeID presentationID);
 
   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 updatePointSprite(MEDPresentation::TypeID, const MEDCALC::PointSpriteParameters&);
+//  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 updatePointSprite(MEDPresentation::TypeID, const MEDCALC::PointSpriteParameters&);
 
   MEDCALC_EXPORT CORBA::Boolean removePresentation(MEDPresentation::TypeID);
-
   MEDCALC_EXPORT CORBA::Boolean activateView(MEDPresentation::TypeID);
-
   MEDCALC_EXPORT MEDCALC::MEDPresentationViewMode getPresentationViewMode(MEDPresentation::TypeID);
-
-  MEDCALC_EXPORT CORBA::Boolean activateView(MEDPresentation::TypeID presentationID);
+  MEDCALC_EXPORT char* getParavisDump(MEDPresentation::TypeID presentationID);
 
  private:
   MEDPresentationManager_i();
@@ -72,11 +74,15 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager,
 
   // Create a new presentation instance and return its unique ID
   template<typename PresentationType, typename PresentationParameters>
-  MEDPresentation::TypeID _makePresentation(PresentationParameters params);
+  MEDPresentation::TypeID _makePresentation(const PresentationParameters params, MEDCALC::MEDPresentationViewMode viewMode);
 
   // Update presentation
   template<typename PresentationType, typename PresentationParameters>
-  void _updatePresentation(MEDPresentation::TypeID presentationID, PresentationParameters params);
+  void _updatePresentation(MEDPresentation::TypeID presentationID, const PresentationParameters params);
+
+  // Get presentation parameters
+  template<typename PresentationType, typename PresentationParameters>
+  void _getParameters(MEDPresentation::TypeID presentationID, PresentationParameters & params) const;
 
   MEDPresentation* _getPresentation(MEDPresentation::TypeID) const;
 
index eb283bf152986e6e60abcb850c3e4dd16c52e227..80f5e84f89b44204109c97efaa6f712129dde2e7 100644 (file)
 
 template<typename PresentationType, typename PresentationParameters>
 MEDPresentation::TypeID
-MEDPresentationManager_i::_makePresentation(PresentationParameters params)
+MEDPresentationManager_i::_makePresentation(const PresentationParameters params, const MEDCALC::MEDPresentationViewMode viewMode)
 {
+  // Replace = Remove then add
+  if (viewMode == MEDCALC::VIEW_MODE_REPLACE) {
+    MEDPresentation::TypeID currentPresentationId = _getActivePresentationId();
+    if (currentPresentationId > -1)
+      removePresentation(currentPresentationId);
+  }
+
   // Create a new presentation instance
   PresentationType* presentation = NULL;
   try {
-    presentation = new PresentationType(params);  // on stack or on heap?? stack for now
+    presentation = new PresentationType(params, viewMode);  // on stack or on heap?? heap for now
   }
   catch (const std::exception& e) {
     std::cerr << e.what() << std::endl;
@@ -42,7 +49,7 @@ MEDPresentationManager_i::_makePresentation(PresentationParameters params)
 
 template<typename PresentationType, typename PresentationParameters>
 void
-MEDPresentationManager_i::_updatePresentation(MEDPresentation::TypeID presentationID, PresentationParameters params)
+MEDPresentationManager_i::_updatePresentation(MEDPresentation::TypeID presentationID, const PresentationParameters params)
 {
   MEDPresentation* presentation = _getPresentation(presentationID);
   if (!presentation) {
@@ -53,4 +60,18 @@ MEDPresentationManager_i::_updatePresentation(MEDPresentation::TypeID presentati
   presentation->updatePipeline<PresentationType>(params);
 }
 
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentationManager_i::_getParameters(MEDPresentation::TypeID presentationID, PresentationParameters & params) const
+{
+  MEDPresentation* presentation = _getPresentation(presentationID);
+  if (!presentation) {
+    std::cerr << "_getParameters(): presentation not found!!" << std::endl;
+    return;
+  }
+
+  presentation->getParameters<PresentationType>(params);
+}
+
+
 #endif // _MED_PRESENTATION_MANAGER_I_TXX_
index 6af5375bd2729fc3fe637f8a4f6778a9839dcc7c..03c46af005b313dafaca29225a4fadd91be98ec0 100644 (file)
 //
 
 #include "MEDPresentationScalarMap.hxx"
-#include "PyInterp_Utils.h"
+#include "MEDPresentationException.hxx"
+
+#include <PyInterp_Utils.h>
+#include <SALOME_KernelServices.hxx>
+#undef LOG  // should be fixed in KERNEL - double definition
+#include <Basics_Utils.hxx>
 
 #include <sstream>
 
+const std::string MEDPresentationScalarMap::TYPE_NAME = "MEDPresentationScalarMap";
+
+MEDPresentationScalarMap::MEDPresentationScalarMap(const MEDCALC::ScalarMapParameters& params,
+                                                   const MEDCALC::MEDPresentationViewMode viewMode) :
+    MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap), _params(params)
+{
+}
+
 void
 MEDPresentationScalarMap::internalGeneratePipeline()
 {
   PyLockWrapper lock;
 
-  int disp_id(GeneratePythonId());
-  int obj_id(disp_id);
-  std::ostringstream oss_o, oss_d, oss, oss_v;
-  oss_o << "__obj" << obj_id;      std::string obj(oss_o.str());
-  oss_d << "__disp" << disp_id;    std::string disp(oss_d.str());
+  std::ostringstream oss_o, oss_d,oss_l, oss, oss_v;
+  oss_o << "__obj" << _objId;      std::string obj(oss_o.str());
+  oss_d << "__disp" << _dispId;    std::string disp(oss_d.str());
+  oss_l << "__lut" << _lutId;    std::string lut(oss_l.str());
 
   pushAndExecPyLine( "import pvsimple as pvs;");
-  pushAndExecPyLine( getRenderViewCommand(_params.viewMode) ); // define __viewXXX
+  pushAndExecPyLine( getRenderViewCommand() ); // define __viewXXX
 
   oss_v << "__view" << _renderViewPyId;    std::string view(oss_v.str());
 
   oss << obj << " = pvs.MEDReader(FileName='" << _fileName << "');";
   pushAndExecPyLine(oss.str()); oss.str("");
+
+  // Populate internal array of available components:
+  fillAvailableFieldComponents();
+//  dumpIntProperties();
+//  dumpStringProperties();
+
   oss << disp << " = pvs.Show(" << obj << ", " << view << ");";
   pushAndExecPyLine(oss.str()); oss.str("");
   oss << "pvs.ColorBy(" << disp << ", ('" << _fieldType << "', '" << _fieldName << "'));";
   pushAndExecPyLine(oss.str()); oss.str("");
   oss << disp <<  ".SetScalarBarVisibility(" << view << ", True);";
   pushAndExecPyLine(oss.str()); oss.str("");
-  oss << disp <<  ".RescaleTransferFunctionToDataRangeOverTime();";
-  pushAndExecPyLine(oss.str()); oss.str("");
-  oss << "__lut = pvs.GetColorTransferFunction('" << _fieldName << "');";
+  oss << getRescaleCommand();
   pushAndExecPyLine(oss.str()); oss.str("");
-  oss << "__lut.ApplyPreset('" << getColorMapCommand(_params.colorMap) << "',True);";
+  oss << lut << " = pvs.GetColorTransferFunction('" << _fieldName << "');";
   pushAndExecPyLine(oss.str()); oss.str("");
+  pushAndExecPyLine(getColorMapCommand()); oss.str("");
   pushAndExecPyLine(getResetCameraCommand());
   pushAndExecPyLine("pvs.Render();");
 
   // Retrieve Python object for internal storage:
-  PyObject* p_obj = getPythonObjectFromMain(obj.c_str());
-  PyObject* p_disp = getPythonObjectFromMain(disp.c_str());
-  pushPyObjects(std::make_pair(obj_id, p_obj), std::make_pair(disp_id, p_disp));
+//  PyObject* p_obj = getPythonObjectFromMain(obj.c_str());
+//  PyObject* p_disp = getPythonObjectFromMain(disp.c_str());
+//  pushPyObjects(std::make_pair(_objId, p_obj), std::make_pair(disp_id, p_disp));
 }
 
 void
 MEDPresentationScalarMap::updatePipeline(const MEDCALC::ScalarMapParameters& params)
 {
-  // :TODO:
+  if (params.fieldHandlerId != _params.fieldHandlerId)
+    throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
+
+  if (params.displayedComponent != _params.displayedComponent)
+    updateComponent<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(std::string(params.displayedComponent));
+  if (params.scalarBarRange != _params.scalarBarRange)
+    updateScalarBarRange<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.scalarBarRange);
+  if (params.colorMap != _params.colorMap)
+    updateColorMap<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.colorMap);
 }
+
index 2b35a3482b76b79c36441525f1e0d93cd7167641..71c5521d44b66277a3203dc5501ed2afdd8f0661 100644 (file)
 
 #include "MEDCALC.hxx"
 #include "MEDPresentation.hxx"
+#include <string>
 
 class MEDCALC_EXPORT MEDPresentationScalarMap : public MEDPresentation
 {
 public:
-  MEDPresentationScalarMap(const MEDCALC::ScalarMapParameters& params) :
-    MEDPresentation(params.fieldHandlerId, "MEDPresentationScalarMap"), _params(params)
-  {}
+  static const std::string TYPE_NAME;
+
+  MEDPresentationScalarMap(const MEDCALC::ScalarMapParameters& params, const MEDCALC::MEDPresentationViewMode viewMode);
   virtual ~MEDPresentationScalarMap() {}
 
   void updatePipeline(const MEDCALC::ScalarMapParameters& params);
   MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
 
+  void getParameters(MEDCALC::ScalarMapParameters & params) const { params = _params; } ;
+  void setParameters(const MEDCALC::ScalarMapParameters & params) { _params = params; } ;
+
 protected:
   virtual void internalGeneratePipeline();
 
index b33ab4dfc4f1ec6b4472f79b10a1d852c9335e11..66c91bb245acf275a381b5fac32486aa614c24d7 100644 (file)
@@ -37,6 +37,8 @@ SET(MEDCALCGUI_SOURCES
     WorkspaceController.cxx
     XmedConsoleDriver.cxx
     XmedDataModel.cxx
+    MEDWidgetHelper.cxx
+    MEDWidgetHelperScalarMap.cxx
 )
 
 IF(SALOME_MED_WITH_QTTESTING)
@@ -50,6 +52,8 @@ SET(MEDCALCGUI_HEADERS
   DatasourceController.hxx
   PresentationController.hxx
   ProcessingController.hxx
+  MEDWidgetHelper.hxx
+  MEDWidgetHelperScalarMap.hxx
   )
  
 IF(SALOME_MED_WITH_QTTESTING)
index 8fa43b3f67fe603f1527ebd5330456da9fda6f5f..cbf2649d569ba10c203f8032c055f6dd8b62c991 100644 (file)
@@ -105,6 +105,7 @@ void DatasourceController::createActions() {
   icon  = tr("ICO_DATASOURCE_USE");
   actionId = _salomeModule->createStandardAction(label,this,SLOT(OnUseInWorkspace()),icon);
   _salomeModule->addActionInPopupMenu(actionId);
+
 }
 
 /**
@@ -121,13 +122,14 @@ DatasourceController::addDatasource(const char* filename)
   DatasourceEvent* event = new DatasourceEvent();
   event->eventtype = DatasourceEvent::EVENT_ADD_DATASOURCE;
   event->objectalias = filename;
-  emit datasourceSignal(event);
+  emit datasourceSignal(event);  // --> WorkspaceController::processDatasourceEvent()
 //#ifdef MED_WITH_QTTESTING
 //  _dirtyAddDataSource = true;
 //  while(_dirtyAddDataSource)
 //    QApplication::processEvents();
 //#endif
 }
+
 // After above data source creation, python console emits a signal, forwarded by workspace, to update the GUI
 void
 DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceHandler* datasourceHandler)
@@ -216,7 +218,7 @@ void DatasourceController::OnAddImagesource()
   DatasourceEvent* event = new DatasourceEvent();
   event->eventtype = DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE;
   event->objectalias = imageFilename;
-  emit datasourceSignal(event);
+  emit datasourceSignal(event); // --> WorkspaceController::processDatasourceEvent()
 }
 
 void DatasourceController::OnExpandField()
@@ -323,7 +325,7 @@ void DatasourceController::OnUseInWorkspace() {
     dataObject->setFieldHandler(*fieldHandler);
     event->objectdata  = dataObject;
     event->objectalias = alias;
-    emit datasourceSignal(event);
+    emit datasourceSignal(event);  // --> WorkspaceController::processDatasourceEvent()
     // Tag the item to prevent double import
     //    _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,true);
     // Tag the field as persistent on the server. It means that a
@@ -347,7 +349,7 @@ void DatasourceController::OnUseInWorkspace() {
         XmedDataObject* dataObject = new XmedDataObject();
         dataObject->setFieldHandler(*fieldHandler);
         event->objectdata  = dataObject;
-        emit datasourceSignal(event);
+        emit datasourceSignal(event); // --> WorkspaceController::processDatasourceEvent()
         // Note that this signal is processed by the WorkspaceController
 
         // Tag the item to prevent double import
index 1a48312bec4bfde059c2135b118a07a1836b163f..8cef0f7d17d1e40cfd1b856e4334756708c4b5d5 100644 (file)
 #include <SALOMEDS_Study.hxx>
 
 #ifndef DISABLE_PVVIEWER
-#include "PVViewer_ViewModel.h"
-#include "PVViewer_GUIElements.h"
+#include <PVViewer_ViewModel.h>
+#include <PVViewer_GUIElements.h>
 #endif
 
 #include "MEDFactoryClient.hxx"
 #include "MEDPresentationManager_i.hxx"
-#include <QTimer>
 
+#include <QTimer>
 #include <sstream>
 
 #include <pqAnimationManager.h>
 #include <pqPVApplicationCore.h>
 
-
 //! The only instance of the reference to engine
 MED_ORB::MED_Gen_var MEDModule::_MED_engine;
-//! The only instance of the MEDPresentationManager
-MEDCALC::MEDPresentationManager_ptr MEDModule::_presManager;
 
 MEDModule::MEDModule() :
   SalomeApp_Module("MED"), _studyEditor(0),
@@ -101,11 +98,6 @@ MEDModule::init()
       SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "MED" );
     _MED_engine = MED_ORB::MED_Gen::_narrow( comp );
   }
-
-  // Retrieve MEDFactory to get MEDPresentationManager (sometimes
-  if ( ! _presManager ) {
-      _presManager = MEDFactoryClient::getFactory()->getPresentationManager();
-    }
 }
 
 //void MEDModule::onEventLoopStarted()
@@ -256,6 +248,8 @@ MEDModule::createModuleWidgets() {
   _xmedDataModel  = new XmedDataModel();
   _workspaceController->setDataModel(_xmedDataModel);
   _presentationController = new PresentationController(this);
+  // ABN: ultimately console driver should be owned by module: everyone needs it, not only WorkspaceController
+  _presentationController->setConsoleDriver(_workspaceController->getConsoleDriver());
   _processingController = new ProcessingController(this);
 #ifdef MED_HAS_QTTESTING
   _testController = new TestController(this);
@@ -265,7 +259,7 @@ MEDModule::createModuleWidgets() {
     _workspaceController, SLOT(processDatasourceEvent(const DatasourceEvent*)));
 
   connect(_presentationController, SIGNAL(presentationSignal(const PresentationEvent*)),
-    _workspaceController, SLOT(processPresentationEvent(const PresentationEvent*)));
+    _presentationController, SLOT(processPresentationEvent(const PresentationEvent*)));
 
   connect(_processingController, SIGNAL(processingSignal(const ProcessingEvent*)),
     _workspaceController, SLOT(processProcessingEvent(const ProcessingEvent*)));
@@ -366,20 +360,27 @@ MEDModule::addActionInPopupMenu(int actionId,const QString& menus,const QString&
   mgr->setRule( this->action( actionId ), rule, QtxPopupMgr::VisibleRule );
 }
 
-MEDCALC::MEDPresentationViewMode
-MEDModule::getSelectedViewMode()
-{
-  return _presentationController->getSelectedViewMode();
-}
+//MEDCALC::MEDPresentationViewMode
+//MEDModule::getSelectedViewMode() const
+//{
+//  return _presentationController->getSelectedViewMode();
+//}
+//
+//MEDCALC::MEDPresentationColorMap
+//MEDModule::getSelectedColorMap() const
+//{
+//  return _presentationController->getSelectedColorMap();
+//}
+//
+//MEDCALC::MEDPresentationScalarBarRange
+//MEDModule::getSelectedScalarBarRange() const
+//{
+//  return _presentationController->getSelectedScalarBarRange();
+//}
 
-MEDCALC::MEDPresentationColorMap
-MEDModule::getSelectedColorMap()
-{
-  return _presentationController->getSelectedColorMap();
-}
 
 bool
-MEDModule::itemClickGeneric(const QModelIndex & index, std::string & name, int & fieldId, int & presId) const
+MEDModule::itemClickGeneric(const QModelIndex & index, std::string & name, std::string & type, int & fieldId, int & presId) const
 {
   DataObjectList dol = getApp()->objectBrowser()->getSelected();
   if (dol.isEmpty())
@@ -414,6 +415,9 @@ MEDModule::itemClickGeneric(const QModelIndex & index, std::string & name, int &
   if (!attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
       return false;
   presId = attrParam->GetInt(PRESENTATION_ID);
+  if (!attrParam->IsSet(PRESENTATION_TYPE, PT_STRING))
+    return false;
+  type = attrParam->GetString(PRESENTATION_TYPE);
   return true;
 }
 
@@ -421,29 +425,34 @@ void
 MEDModule::onClick(const QModelIndex & index)
 {
   int fieldId, presId;
-  std::string name;
-  if (!itemClickGeneric(index, name, fieldId, presId))
-    return;
+  std::string name, type;
+  if (!itemClickGeneric(index, name, type, fieldId, presId))
+    {
+      // Not a presentation - clear widget:
+      emit presentationSelected(-1, QString(""), QString(""));
+      return;
+    }
 
-  STDLOG("Presentation selection (activate view)");
-  std::ostringstream oss;
-  oss << fieldId << " / " << presId;
-  STDLOG("    - Field id / pres id:   " + oss.str());
-  STDLOG("    - Presentation name: " + name);
+//  STDLOG("Presentation selection");
+//  std::ostringstream oss;
+//  oss << fieldId << " / " << presId;
+//  STDLOG("    - Field id / pres id:   " + oss.str());
+//  STDLOG("    - Presentation type: " + type);
+//  STDLOG("    - Presentation name: " + name);
 
-  _presManager->activateView(presId);
+  emit presentationSelected(presId, QString::fromStdString(type), QString::fromStdString(name) );  // caught by PresentationController
 }
 
 void
 MEDModule::onDblClick(const QModelIndex& index)
 {
   int fieldId, presId;
-  std::string name;
-  if (!itemClickGeneric(index, name, fieldId, presId))
+  std::string name, type;
+  if (!itemClickGeneric(index, name, type, fieldId, presId))
     return;
 
   STDLOG("Presentation edition: NOT IMPLEMENTED YET");
-  STDLOG("  Presention infos:");
+  STDLOG("  Presentation infos:");
 //  STDLOG("    - Component:         " + item->componentDataType().toStdString());
 //  STDLOG("    - Item entry:        " + item->entry().toStdString());
 //  STDLOG("    - Item name:         " + item->name().toStdString());
index d32a1c93cd5737a8a0431a96f45aa37cedb57043..ed3cafce551ebe0a6b7da39513315bb9b28e126f 100644 (file)
@@ -80,14 +80,15 @@ public:
                             const QString& menus="",
                             const QString& rule="client='ObjectBrowser'");
 
-  MEDCALC::MEDPresentationViewMode getSelectedViewMode();
-  MEDCALC::MEDPresentationColorMap getSelectedColorMap();
+//  MEDCALC::MEDPresentationViewMode getSelectedViewMode() const;
+//  MEDCALC::MEDPresentationColorMap getSelectedColorMap() const;
+//  MEDCALC::MEDPresentationScalarBarRange getSelectedScalarBarRange() const;
 
   inline SALOME_AppStudyEditor* getStudyEditor() { return _studyEditor; }
-
   void requestSALOMETermination() const;
 
-//  bool hasMainEventLoopStarted() const;
+signals:
+  void presentationSelected(int presId, const QString& presType, const QString& presName);
 
 public slots:
   virtual bool activateModule(SUIT_Study* theStudy);
@@ -99,7 +100,9 @@ private:
   void createModuleWidgets();
   void createModuleActions();
   void initToolbars();
-  bool itemClickGeneric(const QModelIndex & index, std::string & name, int & fieldId, int & presId) const;
+
+  bool itemClickGeneric(const QModelIndex & index, std::string & name,
+                        std::string & type, int & fieldId, int & presId) const;
 
   static void init();
 
@@ -121,7 +124,6 @@ private:
 #ifdef MED_HAS_QTTESTING
   TestController * _testController;
 #endif
-
 };
 
 #endif
diff --git a/src/MEDCalc/gui/MEDWidgetHelper.cxx b/src/MEDCalc/gui/MEDWidgetHelper.cxx
new file mode 100644 (file)
index 0000000..015bb8e
--- /dev/null
@@ -0,0 +1,119 @@
+// 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
+//
+
+#include "MEDWidgetHelper.hxx"
+#include "PresentationController.hxx"
+#include "MEDPresentation.hxx"
+#include <Basics_Utils.hxx>
+
+MEDWidgetHelper::MEDWidgetHelper(const PresentationController * presController,
+                                 MEDCALC::MEDPresentationManager_ptr presManager, int presId,
+                                 const std::string & presName,  WidgetPresentationParameters * paramWidget):
+  _presController(presController),
+  _presManager(presManager),
+  _presId(presId),
+  _presName(presName),
+  _paramWidget(paramWidget)
+{}
+
+MEDWidgetHelper::~MEDWidgetHelper()
+{}
+
+void MEDWidgetHelper::loadParametersFromEngine()
+{
+  _selectedCompo = _presManager->getPresentationIntProperty(_presId, MEDPresentation::PROP_SELECTED_COMPONENT.c_str());
+  _nbCompos = _presManager->getPresentationIntProperty(_presId, MEDPresentation::PROP_NB_COMPONENTS.c_str());
+  _allCompos.clear();
+  _allCompos.reserve(_nbCompos);
+  for (int i = 0; i < _nbCompos; i++)
+    {
+      std::ostringstream oss;
+      oss << MEDPresentation::PROP_COMPONENT << i;
+      _allCompos.push_back(_presManager->getPresentationStringProperty(_presId, oss.str().c_str()));
+    }
+  _colorMap = static_cast<MEDCALC::MEDPresentationColorMap>(
+      _presManager->getPresentationIntProperty(_presId, MEDPresentation::PROP_COLOR_MAP.c_str()));
+  _scalarBarRange = static_cast<MEDCALC::MEDPresentationScalarBarRange>(
+      _presManager->getPresentationIntProperty(_presId, MEDPresentation::PROP_SCALAR_BAR_RANGE.c_str()));
+}
+
+void MEDWidgetHelper::udpateWidget()
+{
+  // Set presentation name
+  _paramWidget->setPresName(_presName);
+
+  // Show dynamic part of the widget (i.e. everything else than color map and scalar bar range)
+  _paramWidget->toggleWidget(true);
+
+  loadParametersFromEngine();
+
+  // Set properly color map and scalar bar range
+  _paramWidget->setColorMap(_colorMap);
+  _paramWidget->setScalarBarRange(_scalarBarRange);
+
+  QObject::connect( _paramWidget, SIGNAL(comboScalarBarRangeIndexChanged(int)), this, SLOT(onScalarBarRangeChanged(int)) );
+  QObject::connect( _paramWidget, SIGNAL(comboColorMapIndexChanged(int)), this, SLOT(onColorMapChanged(int)) );
+}
+
+void MEDWidgetHelper::releaseWidget()
+{
+  QObject::disconnect( _paramWidget, SIGNAL(comboScalarBarRangeIndexChanged(int)), this, SLOT(onScalarBarRangeChanged(int)) );
+  QObject::disconnect( _paramWidget, SIGNAL(comboColorMapIndexChanged(int)), this, SLOT(onColorMapChanged(int)) );
+
+  // Reset default for color map and scalar bar range
+  _paramWidget->setColorMap(MEDCALC::COLOR_MAP_DEFAULT);
+  _paramWidget->setScalarBarRange(MEDCALC::SCALAR_BAR_RANGE_DEFAULT);
+}
+
+void MEDWidgetHelper::onComponentChanged(int idx)
+{
+  STDLOG("MEDWidgetHelper::onComponentChanged");
+  PresentationEvent* event = new PresentationEvent();
+  event->eventtype = PresentationEvent::EVENT_CHANGE_COMPONENT;
+  event->presentationId = _presId;
+  event->anInteger = idx;
+  event->aString = _paramWidget->getComponent();
+
+  emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
+
+void MEDWidgetHelper::onColorMapChanged(int idx)
+{
+  STDLOG("MEDWidgetHelper::onColorMapChanged");
+  PresentationEvent* event = new PresentationEvent();
+  event->eventtype = PresentationEvent::EVENT_CHANGE_COLORMAP;
+  event->presentationId = _presId;
+  // The actual selected item in the combo list is retrieved by the workspace controller _getColorMap()
+//  event->anInteger = idx;
+
+  emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
+
+void MEDWidgetHelper::onScalarBarRangeChanged(int idx)
+{
+  STDLOG("MEDWidgetHelper::onScalarBarRangeChanged");
+  PresentationEvent* event = new PresentationEvent();
+  event->eventtype = PresentationEvent::EVENT_CHANGE_TIME_RANGE;
+  event->presentationId = _presId;
+  event->anInteger = idx;
+  // The actual selected item in the combo list is retrieved by the workspace controller _getScalarBarRange()
+  //event->aString = _paramWidget->getScalarBarRange();
+
+  emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
diff --git a/src/MEDCalc/gui/MEDWidgetHelper.hxx b/src/MEDCalc/gui/MEDWidgetHelper.hxx
new file mode 100644 (file)
index 0000000..fa0e6a0
--- /dev/null
@@ -0,0 +1,85 @@
+// 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_MEDWIDGETHELPER_HXX_
+#define SRC_MEDCALC_GUI_MEDWIDGETHELPER_HXX_
+
+#include "WidgetPresentationParameters.hxx"
+#include "PresentationEvent.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(MEDPresentationManager)
+
+class WidgetPresentationParameters;
+class PresentationController;
+
+/*!
+ * The widget helper hierarchy is in charge of seting up the WidgetPresentationParameters
+ * to display the Qt widgets relevant to the underlying presentation on the component side.
+ */
+class MEDWidgetHelper : public QObject
+{
+  Q_OBJECT
+
+public:
+  virtual ~MEDWidgetHelper();
+
+  virtual void udpateWidget();
+  virtual void releaseWidget();
+
+  ///! Returns the string X in the Python command "Update<X>" or "Get<X>Parameters"
+  virtual std::string getPythonTag() const = 0;
+
+signals:
+  void presentationUpdateSignal(const PresentationEvent *);
+
+protected:
+  // Only child classes to be instanciated:
+  MEDWidgetHelper(const PresentationController* presController,
+                  MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+                  WidgetPresentationParameters * paramWidget);
+  virtual void loadParametersFromEngine();
+
+protected slots:
+  void onComponentChanged(int idx);
+  void onColorMapChanged(int idx);
+  void onScalarBarRangeChanged(int idx);
+
+protected:
+  ///! GUI needs to talk directly to the pres manager to activate a view, get some params, etc ...:
+  MEDCALC::MEDPresentationManager_ptr _presManager;
+  const PresentationController * _presController  ;
+  const int _presId;
+  const std::string _presName;
+
+  WidgetPresentationParameters* _paramWidget;
+
+  // Component related members
+  int _selectedCompo;                  // Selected field component
+  int _nbCompos;                       // Total number of available components
+  std::vector<std::string> _allCompos; // All available components
+
+  // Color map
+  MEDCALC::MEDPresentationColorMap _colorMap;
+
+  // Scalar bar range
+  MEDCALC::MEDPresentationScalarBarRange _scalarBarRange;
+};
+
+#endif
diff --git a/src/MEDCalc/gui/MEDWidgetHelperScalarMap.cxx b/src/MEDCalc/gui/MEDWidgetHelperScalarMap.cxx
new file mode 100644 (file)
index 0000000..755bf80
--- /dev/null
@@ -0,0 +1,55 @@
+// 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
+//
+
+#include "MEDWidgetHelperScalarMap.hxx"
+#include "MEDPresentationScalarMap.hxx"  // from component side.
+#include "PresentationController.hxx"
+
+#include <sstream>
+
+MEDWidgetHelperScalarMap::MEDWidgetHelperScalarMap(const PresentationController * presController, MEDCALC::MEDPresentationManager_ptr presManager, int presId,
+                                                   const std::string & presName, WidgetPresentationParameters * paramW):
+  MEDWidgetHelper(presController, presManager, presId, presName, paramW)
+{
+}
+
+MEDWidgetHelperScalarMap::~MEDWidgetHelperScalarMap()
+{}
+
+void MEDWidgetHelperScalarMap::udpateWidget()
+{
+  MEDWidgetHelper::udpateWidget();
+
+  // Scalar map presentation needs the component name, that's all.
+  _paramWidget->setComponents(_allCompos, _selectedCompo);
+
+  // Connect combo box changes
+  QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
+                    _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
+  QObject::connect( _paramWidget, SIGNAL(comboCompoIndexChanged(int)), this, SLOT(onComponentChanged(int)) );
+}
+
+void MEDWidgetHelperScalarMap::releaseWidget()
+{
+  MEDWidgetHelper::releaseWidget();
+
+  QObject::disconnect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
+                       _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
+  QObject::disconnect( _paramWidget, SIGNAL(comboCompoIndexChanged(int)), this, SLOT(onComponentChanged(int)) );
+}
diff --git a/src/MEDCalc/gui/MEDWidgetHelperScalarMap.hxx b/src/MEDCalc/gui/MEDWidgetHelperScalarMap.hxx
new file mode 100644 (file)
index 0000000..c068705
--- /dev/null
@@ -0,0 +1,48 @@
+// 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_MEDWIDGETHELPERSCALARMAP_HXX_
+#define SRC_MEDCALC_GUI_MEDWIDGETHELPERSCALARMAP_HXX_
+
+#include "MEDWidgetHelper.hxx"
+#include <QComboBox>
+
+class PresentationController;
+
+class MEDWidgetHelperScalarMap: public MEDWidgetHelper
+{
+  Q_OBJECT
+
+public:
+  MEDWidgetHelperScalarMap(const PresentationController* presController,
+                           MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+                           WidgetPresentationParameters * paramW);
+  virtual ~MEDWidgetHelperScalarMap();
+
+  virtual void udpateWidget();
+  virtual void releaseWidget();
+
+  virtual std::string getPythonTag() const { return "ScalarMap"; }
+
+protected:
+
+
+};
+
+#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERSCALARMAP_HXX_ */
index 8841a7d85311851e091b114119a001c61a799214..73d655dfe9c3d47d69fbd56de4c5a57b49bc017c 100644 (file)
       <translation>All timesteps</translation>
     </message>
     <message>
-      <source>LAB_ONE_TIMESTEP</source>
-      <translation>Selected timestep</translation>
+      <source>LAB_CURRENT_TIMESTEP</source>
+      <translation>Current timestep</translation>
     </message>
     <message>
       <source>LAB_USER_RANGE</source>
index acf347d1f6f4c1ad65587139eee58e312bfeeb1d..be5cf5ba24fab3212d5df99fa3b558ccbea45202 100644 (file)
       <translation>Tous les pas de temps</translation>
     </message>
     <message>
-      <source>LAB_ONE_TIMESTEP</source>
-      <translation>Pas de temps sélectionné</translation>
+      <source>LAB_CURRENT_TIMESTEP</source>
+      <translation>Pas de temps courant</translation>
     </message>
     <message>
       <source>LAB_USER_RANGE</source>
index 1785436a6c16c255701b6e79554e1f1686373d9c..0f7735122318255464186783596aa7aa841089cb 100644 (file)
 #include "QtxActionToolMgr.h"
 #include "MEDFactoryClient.hxx"
 #include "MEDPresentationManager_i.hxx"
+#include "XmedConsoleDriver.hxx"
+
+#include "MEDWidgetHelperScalarMap.hxx"
+#include "MEDPresentationScalarMap.hxx"
 
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
 #include <QMessageBox>
 #include <sstream>
 
+#include "MEDFactoryClient.hxx"
+
 static const int OPTIONS_VIEW_MODE_ID = 943;
 static const int OPTIONS_VIEW_MODE_REPLACE_ID = 944;
 static const int OPTIONS_VIEW_MODE_OVERLAP_ID = 945;
 static const int OPTIONS_VIEW_MODE_NEW_LAYOUT_ID = 946;
 static const int OPTIONS_VIEW_MODE_SPLIT_VIEW_ID = 947;
 
+//! The only instance of the MEDPresentationManager
+MEDCALC::MEDPresentationManager_ptr PresentationController::_presManager;
+
 PresentationController::PresentationController(MEDModule* salomeModule) :
     _salomeModule(salomeModule),
-    _studyEditor(salomeModule->getStudyEditor())
+    _consoleDriver(0),
+    _studyEditor(salomeModule->getStudyEditor()),
+    _presHelperMap(),
+    _currentWidgetHelper(0)
 {
   STDLOG("Creating a PresentationController");
 
@@ -63,11 +75,38 @@ PresentationController::PresentationController(MEDModule* salomeModule) :
   _dockWidget->setWidget(_widgetPresentationParameters);
   parent->addDockWidget(Qt::LeftDockWidgetArea, _dockWidget);
   //_dockWidget->show();
+
+  // Retrieve MEDFactory to get MEDPresentationManager (sometimes GUI needs to talk to the engine directly)
+  if ( ! _presManager ) {
+      _presManager = MEDFactoryClient::getFactory()->getPresentationManager();
+    }
+
+  // Connect to the click in the object browser
+  connect(salomeModule, SIGNAL( presentationSelected(int , const QString&, const QString&) ),
+             this, SLOT(onPresentationSelected(int , const QString&, const QString&) )     );
 }
 
 PresentationController::~PresentationController()
 {
-  STDLOG("Deleting the PresentationController");
+  STDLOG("Deleting the resentationController");
+  // Clean allocated widget helpers:
+  for ( std::map<int, MEDWidgetHelper *>::iterator it = _presHelperMap.begin(); it != _presHelperMap.end(); ++it)
+    delete((*it).second);
+}
+
+/**
+ * [ABN] Created this probably because I don't know the right way to deal with non existent
+ * attributes in an object from the study ...
+ */
+int
+PresentationController::getIntParamFromStudyEditor(SALOMEDS::SObject_var obj, const char * name)
+{
+  int theInt = -1;
+  try {
+      theInt = _studyEditor->getParameterInt(obj,name);
+  }
+  catch(...)  {  }
+  return theInt;
 }
 
 std::string
@@ -132,7 +171,7 @@ PresentationController::createActions()
   tooltip = tr("TIP_PRESENTATION_SCALAR_MAP");
   QString icon = tr(_getIconName("ICO_PRESENTATION_SCALAR_MAP").c_str());
   int actionId;
-  actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeScalarMap()),icon,tooltip);
+  actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizeScalarMap()),icon,tooltip);
   _salomeModule->createTool(actionId, presentationToolbarId);
   _salomeModule->action(actionId)->setIconVisibleInMenu(true);
   _salomeModule->createMenu(actionId, presentationMenuId);
@@ -140,7 +179,7 @@ PresentationController::createActions()
   label   = tr("LAB_PRESENTATION_CONTOUR");
   tooltip = tr("TIP_PRESENTATION_CONTOUR");
   icon    = tr(_getIconName("ICO_PRESENTATION_CONTOUR").c_str());
-  actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeContour()),icon,tooltip);
+  actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizeContour()),icon,tooltip);
   _salomeModule->createTool(actionId, presentationToolbarId);
   _salomeModule->action(actionId)->setIconVisibleInMenu(true);
   _salomeModule->createMenu(actionId, presentationMenuId);
@@ -148,7 +187,7 @@ PresentationController::createActions()
   label   = tr("LAB_PRESENTATION_VECTOR_FIELD");
   tooltip = tr("TIP_PRESENTATION_VECTOR_FIELD");
   icon    = tr(_getIconName("ICO_PRESENTATION_VECTOR_FIELD").c_str());
-  actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeVectorField()),icon,tooltip);
+  actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizeVectorField()),icon,tooltip);
   _salomeModule->createTool(actionId, presentationToolbarId);
   _salomeModule->action(actionId)->setIconVisibleInMenu(true);
   _salomeModule->createMenu(actionId, presentationMenuId);
@@ -156,7 +195,7 @@ PresentationController::createActions()
   label   = tr("LAB_PRESENTATION_SLICES");
   tooltip = tr("TIP_PRESENTATION_SLICES");
   icon    = tr(_getIconName("ICO_PRESENTATION_SLICES").c_str());
-  actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeSlices()),icon,tooltip);
+  actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizeSlices()),icon,tooltip);
   _salomeModule->createTool(actionId, presentationToolbarId);
   _salomeModule->action(actionId)->setIconVisibleInMenu(true);
   _salomeModule->createMenu(actionId, presentationMenuId);
@@ -164,7 +203,7 @@ PresentationController::createActions()
   label   = tr("LAB_PRESENTATION_DEFLECTION_SHAPE");
   tooltip = tr("TIP_PRESENTATION_DEFLECTION_SHAPE");
   icon    = tr(_getIconName("ICO_PRESENTATION_DEFLECTION_SHAPE").c_str());
-  actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeDeflectionShape()),icon,tooltip);
+  actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizeDeflectionShape()),icon,tooltip);
   _salomeModule->createTool(actionId, presentationToolbarId);
   _salomeModule->action(actionId)->setIconVisibleInMenu(true);
   _salomeModule->createMenu(actionId, presentationMenuId);
@@ -172,23 +211,36 @@ PresentationController::createActions()
   label   = tr("LAB_PRESENTATION_POINT_SPRITE");
   tooltip = tr("TIP_PRESENTATION_POINT_SPRITE");
   icon    = tr(_getIconName("ICO_PRESENTATION_POINT_SPRITE").c_str());
-  actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizePointSprite()),icon,tooltip);
+  actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizePointSprite()),icon,tooltip);
   _salomeModule->createTool(actionId, presentationToolbarId);
   _salomeModule->action(actionId)->setIconVisibleInMenu(true);
   _salomeModule->createMenu(actionId, presentationMenuId);
 
+  // Separator
+  _salomeModule->createMenu(_salomeModule->separator(), presentationMenuId);
+
   label   = tr("LAB_DELETE_PRESENTATION");
   tooltip = tr("TIP_DELETE_PRESENTATION");
   icon    = tr(_getIconName("ICO_DELETE_PRESENTATION").c_str());
-  actionId = _salomeModule->createStandardAction(label,this, SLOT(OnDeletePresentation()),icon,tooltip);
+  actionId = _salomeModule->createStandardAction(label,this, SLOT(onDeletePresentation()),icon,tooltip);
 //  _salomeModule->createTool(actionId, presentationToolbarId);
 //  _salomeModule->action(actionId)->setIconVisibleInMenu(true);
   _salomeModule->createMenu(actionId, presentationMenuId);
 
+  //
+  // Actions for popup menu only
+  //
+  // Low level PARAVIS dump
+  label = tr("LAB_PARAVIS_DUMP");
+  //icon  = tr("ICO_DATASOURCE_EXPAND_FIELD");
+  actionId = _salomeModule->createStandardAction(label,this,SLOT(onParavisDump()),"");
+  _salomeModule->addActionInPopupMenu(actionId);
+
+
 }
 
 MEDCALC::MEDPresentationViewMode
-PresentationController::getSelectedViewMode()
+PresentationController::getSelectedViewMode() const
 {
   if (_salomeModule->action(OPTIONS_VIEW_MODE_REPLACE_ID)->isChecked()) {
     return MEDCALC::VIEW_MODE_REPLACE;
@@ -208,11 +260,17 @@ PresentationController::getSelectedViewMode()
 }
 
 MEDCALC::MEDPresentationColorMap
-PresentationController::getSelectedColorMap()
+PresentationController::getSelectedColorMap() const
 {
   return _widgetPresentationParameters->getColorMap();
 }
 
+MEDCALC::MEDPresentationScalarBarRange
+PresentationController::getSelectedScalarBarRange() const
+{
+  return _widgetPresentationParameters->getScalarBarRange();
+}
+
 void
 PresentationController::visualize(PresentationEvent::EventType eventType)
 {
@@ -227,16 +285,10 @@ PresentationController::visualize(PresentationEvent::EventType eventType)
   // to make a view of an object from the tui console).
   for (int i=0; i<listOfSObject->size(); i++) {
     SALOMEDS::SObject_var soField = listOfSObject->at(i);
-    int fieldId = -1;
-    try {
-        fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);    }
-    catch(...)    { }
+    int fieldId = getIntParamFromStudyEditor(soField, FIELD_ID);
     if (fieldId < 0)  // is it a field serie ?
       {
-        int fieldSeriesId = -1;
-        try {
-            fieldSeriesId = _studyEditor->getParameterInt(soField,FIELD_SERIES_ID);      }
-        catch(...)  { }
+        int fieldSeriesId = getIntParamFromStudyEditor(soField, FIELD_SERIES_ID);
         // If fieldId and fieldSeriesId equals -1, then it means that it is not a field
         // managed by the MED module, and we stop this function process.
         if ( fieldSeriesId < 0)
@@ -259,51 +311,49 @@ PresentationController::visualize(PresentationEvent::EventType eventType)
 
     PresentationEvent* event = new PresentationEvent();
     event->eventtype = eventType;
-    XmedDataObject* dataObject = new XmedDataObject();
-    dataObject->setFieldHandler(*fieldHandler);
-    event->objectdata = dataObject;
-    emit presentationSignal(event); // --> WorkspaceController::processPresentationEvent
+    event->fieldHandler = fieldHandler;
+    emit presentationSignal(event); // --> processPresentationEvent()
   }
 }
 
 void
-PresentationController::OnVisualizeScalarMap()
+PresentationController::onVisualizeScalarMap()
 {
   this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP);
 }
 
 void
-PresentationController::OnVisualizeContour()
+PresentationController::onVisualizeContour()
 {
   this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR);
 }
 
 void
-PresentationController::OnVisualizeVectorField()
+PresentationController::onVisualizeVectorField()
 {
   this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD);
 }
 
 void
-PresentationController::OnVisualizeSlices()
+PresentationController::onVisualizeSlices()
 {
   this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_SLICES);
 }
 
 void
-PresentationController::OnVisualizeDeflectionShape()
+PresentationController::onVisualizeDeflectionShape()
 {
   this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE);
 }
 
 void
-PresentationController::OnVisualizePointSprite()
+PresentationController::onVisualizePointSprite()
 {
   this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE);
 }
 
 void
-PresentationController::OnDeletePresentation()
+PresentationController::onDeletePresentation()
 {
   // We need a _studyEditor updated on the active study
   _studyEditor->updateActiveStudy();
@@ -314,23 +364,230 @@ PresentationController::OnDeletePresentation()
   // For each object, emit a signal to the workspace to request pres deletion
   for (int i=0; i<listOfSObject->size(); i++) {
     SALOMEDS::SObject_var soPres = listOfSObject->at(i);
-    int presId = _studyEditor->getParameterInt(soPres,PRESENTATION_ID);
+    int presId = getIntParamFromStudyEditor(soPres,PRESENTATION_ID);
     // If fieldId equals -1, then it means that it is not a field
     // managed by the MED module, and we stop this function process.
     if ( presId < 0 )
       continue;
 
-    STDLOG("Requesting deletion of presentation: ")
-    std::ostringstream oss;
-    oss << presId;
-    STDLOG("    - Pres id:          " + oss.str());
-
     PresentationEvent* event = new PresentationEvent();
     event->eventtype = PresentationEvent::EVENT_DELETE_PRESENTATION;
-    XmedDataObject* dataObject = new XmedDataObject();
-    dataObject->setPresentationId(presId);
-    event->objectdata = dataObject;
-    emit presentationSignal(event); // --> WorkspaceController::processPresentationEvent
+    event->presentationId = presId;
+    emit presentationSignal(event); // --> processPresentationEvent()
+  }
+}
+
+QString
+PresentationController::getViewModePython() const
+{
+  MEDCALC::MEDPresentationViewMode viewMode = getSelectedViewMode();
+  switch(viewMode) {
+  case MEDCALC::VIEW_MODE_REPLACE: return "MEDCALC.VIEW_MODE_REPLACE";
+  case MEDCALC::VIEW_MODE_OVERLAP: return "MEDCALC.VIEW_MODE_OVERLAP";
+  case MEDCALC::VIEW_MODE_NEW_LAYOUT: return "MEDCALC.VIEW_MODE_NEW_LAYOUT";
+  case MEDCALC::VIEW_MODE_SPLIT_VIEW: return "MEDCALC.VIEW_MODE_SPLIT_VIEW";
+  }
+  return QString();
+}
+
+QString
+PresentationController::getColorMapPython() const
+{
+  MEDCALC::MEDPresentationColorMap colorMap = getSelectedColorMap();
+  switch(colorMap) {
+  case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW";
+  case MEDCALC::COLOR_MAP_COOL_TO_WARM: return "MEDCALC.COLOR_MAP_COOL_TO_WARM";
+  }
+  return QString();
+}
+
+QString
+PresentationController::getScalarBarRangePython() const
+{
+  MEDCALC::MEDPresentationScalarBarRange colorMap = getSelectedScalarBarRange();
+   switch(colorMap) {
+   case MEDCALC::SCALAR_BAR_ALL_TIMESTEPS: return "MEDCALC.SCALAR_BAR_ALL_TIMESTEPS";
+   case MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP: return "MEDCALC.SCALAR_BAR_CURRENT_TIMESTEP";
+   }
+   return QString();
+}
+
+std::string
+PresentationController::getPresTypeFromWidgetHelper(int presId) const
+{
+  std::map<int, MEDWidgetHelper *>::const_iterator it =_presHelperMap.find(presId);
+  if (it != _presHelperMap.end())
+      return (*it).second->getPythonTag();
+  return "UNKNOWN";
+}
+
+void
+PresentationController::processPresentationEvent(const PresentationEvent* event) {
+  // --> Send commands to SALOME Python console
+  if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) {
+    QString viewMode = getViewModePython();
+    //QString displayedComponent = ; // from PresentationController combobox
+    //QString scalarBarRange = ; // from PresentationController spinbox
+    QString colorMap = getColorMapPython();
+    MEDCALC::FieldHandler* fieldHandler = event->fieldHandler;
+    QStringList commands;
+    commands += QString("presentation_id = medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
+    commands += QString("presentation_id");
+    _consoleDriver->exec(commands);
+  }
+//  else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
+//    QString viewMode = getViewModePython();
+//    MEDCALC::FieldHandler* fieldHandler = event->_fieldHandler;
+//    QStringList commands;
+//    commands += QString("presentation_id = medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+//    commands += QString("presentation_id");
+//    _consoleDriver->exec(commands);
+//  }
+//  else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) {
+//    QString viewMode = getViewModePython();
+//    MEDCALC::FieldHandler* fieldHandler = event->_fieldHandler;
+//    QStringList commands;
+//    commands += QString("presentation_id = medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+//    commands += QString("presentation_id");
+//    _consoleDriver->exec(commands);
+//  }
+//  else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
+//    QString viewMode = getViewModePython();
+//    MEDCALC::FieldHandler* fieldHandler = event->_fieldHandler;
+//    QStringList commands;
+//    commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+//    commands += QString("presentation_id");
+//    _consoleDriver->exec(commands);
+//  }
+//  else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
+//    QString viewMode = getViewModePython();
+//    MEDCALC::FieldHandler* fieldHandler = event->_fieldHandler;
+//    QStringList commands;
+//    commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+//    commands += QString("presentation_id");
+//    _consoleDriver->exec(commands);
+//  }
+//  else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) {
+//    QString viewMode = getViewModePython();
+//    MEDCALC::FieldHandler* fieldHandler = event->_fieldHandler;
+//    QStringList commands;
+//    commands += QString("presentation_id = medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+//    commands += QString("presentation_id");
+//    _consoleDriver->exec(commands);
+//  }
+
+  // [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);
+      QStringList commands;
+      commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
+      commands += QString("params.displayedComponent = '%1'").arg(QString::fromStdString(event->aString));
+      commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
+      _consoleDriver->exec(commands);
+  }
+  else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_COLORMAP ) {
+      std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+      QStringList commands;
+      commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
+      commands += QString("params.colorMap = %1").arg(getColorMapPython());
+      commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
+      _consoleDriver->exec(commands);
+    }
+  else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_TIME_RANGE ) {
+      std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+      QStringList commands;
+      commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
+      commands += QString("params.scalarBarRange = %1").arg(getScalarBarRangePython());
+      commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
+      _consoleDriver->exec(commands);
+  }
+  else if ( event->eventtype == PresentationEvent::EVENT_DELETE_PRESENTATION ) {
+      QStringList commands;
+      commands += QString("medcalc.RemovePresentation(%1)").arg(event->presentationId);
+      _consoleDriver->exec(commands);
+  }
+  else {
+    STDLOG("The event "<<event->eventtype<<" is not implemented yet");
+  }
+}
+
+MEDWidgetHelper *
+PresentationController::findOrCreateWidgetHelper(MEDCALC::MEDPresentationManager_ptr presManager,
+                                                 int presId, const std::string& type, const std::string& name )
+{
+  std::map<int, MEDWidgetHelper *>::const_iterator it =_presHelperMap.find(presId);
+  if (it != _presHelperMap.end())
+    return (*it).second;
+  MEDWidgetHelper * wh;
+  if (type == MEDPresentationScalarMap::TYPE_NAME)
+    wh = new MEDWidgetHelperScalarMap(this, _presManager, presId, name, _widgetPresentationParameters);
+  else
+    {
+//    case PRES_CONTOUR:
+//// break;
+//    case PRES_DEFLECTION:
+////          break;
+//    case PRES_VECTOR_FIELD:
+//  //        break;
+//    case PRES_POINT_SPRITE:
+//    //      break;
+//    case PRES_POINT_SPRITE:
+//      //    break;
+//    default:
+      STDLOG("findOrCreateWidgetHelper(): NOT IMPLEMENTED !!!");
+
+  }
+  _presHelperMap[presId] = wh;
+  return wh;
+}
+
+void
+PresentationController::onPresentationSelected(int presId, const QString& presType, const QString& presName)
+{
+  if (presId == -1)
+    {
+      if (_widgetPresentationParameters->isShown())
+        {
+          _widgetPresentationParameters->toggleWidget(false);
+          if(_currentWidgetHelper)
+            _currentWidgetHelper->releaseWidget();
+        }
+    }
+  else
+    {
+      // Activate corresponding ParaView render view
+      _presManager->activateView(presId);
+      // Update widgets parameters
+      _currentWidgetHelper = findOrCreateWidgetHelper(_presManager, presId, presType.toStdString(), presName.toStdString());
+      _currentWidgetHelper->udpateWidget();
+    }
+}
+
+void
+PresentationController::onParavisDump()
+{
+  // We need a _studyEditor updated on the active study
+  _studyEditor->updateActiveStudy();
+
+  // Get the selected objects in the study (SObject)
+  SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
+
+  // For the first object only, request the dump
+  for (int i=0; i<listOfSObject->size(); i++) {
+    SALOMEDS::SObject_var soPres = listOfSObject->at(i);
+    int presId = getIntParamFromStudyEditor(soPres,PRESENTATION_ID);
+    // If fieldId equals -1, then it means that it is not a field
+    // managed by the MED module, and we stop this function process.
+    if ( presId < 0 )
+      continue;
+
+    std::string dump(_presManager->getParavisDump(presId));
+    std::cerr << "#====== ParaVis dump =============== " << std::endl;
+    std::cerr << dump;
+    std::cerr << "#====== End of ParaVis dump ======== " << std::endl;
+
+    break; // stop at the first one
   }
 }
 
@@ -342,16 +599,22 @@ PresentationController::updateTreeViewWithNewPresentation(long fieldId, long pre
     return;
   }
 
-  std::string name = MEDFactoryClient::getPresentationManager()->getPresentationProperty(presentationId, "name");
-  std::string icon = std::string("ICO_") + name;
+  std::string name(MEDFactoryClient::getPresentationManager()->getPresentationStringProperty(presentationId, MEDPresentation::PROP_NAME.c_str()));
+  std::string type = name;
+  std::string icon = std::string("ICO_") + type;
   icon = _getIconName(icon);
+  std::string ico = tr(icon.c_str()).toStdString();
+
+  // Append presentation ID to the displayed name in the OB:
+  std::ostringstream oss;
   name = tr(name.c_str()).toStdString();
-  std::string label = tr(icon.c_str()).toStdString();
+  oss << name << " (" << presentationId << ")";
 
   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(_salomeModule->application()->activeStudy());
   _PTR(Study) studyDS = study->studyDS();
 
-  _salomeModule->engine()->registerPresentation(_CAST(Study, studyDS)->GetStudy(), fieldId, name.c_str(), label.c_str(), presentationId);
+  _salomeModule->engine()->registerPresentation(_CAST(Study, studyDS)->GetStudy(), fieldId,
+      oss.str().c_str(), type.c_str(),ico.c_str(), presentationId);
 
 
   MEDCALC::MEDPresentationViewMode viewMode = MEDFactoryClient::getPresentationManager()->getPresentationViewMode(presentationId);
@@ -414,6 +677,6 @@ PresentationController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
 void
 PresentationController::showDockWidgets(bool isVisible)
 {
-  STDLOG("Switching PresentationController visibility to: " << isVisible);
   _dockWidget->setVisible(isVisible);
 }
+
index d2d9fc4617f699895b3f84421bed7d272c71d103..98fc9ffb63e35907e08cf6393054b855bfaca3ba 100644 (file)
 #include <SALOME_AppStudyEditor.hxx>
 #include "WidgetPresentationParameters.hxx"
 
-typedef struct {
-  enum EventType {
-    EVENT_VIEW_OBJECT_CONTOUR,
-    EVENT_VIEW_OBJECT_DEFLECTION_SHAPE,
-    EVENT_VIEW_OBJECT_POINT_SPRITE,
-    EVENT_VIEW_OBJECT_SCALAR_MAP,
-    EVENT_VIEW_OBJECT_SLICES,
-    EVENT_VIEW_OBJECT_VECTOR_FIELD,
-    EVENT_DELETE_PRESENTATION
-  };
-  int eventtype;
-  XmedDataObject* objectdata;
-} PresentationEvent;
+#include "PresentationEvent.hxx"
 
 class MEDModule;
 class QDockWidget;
+class MEDWidgetHelper;
+class XmedConsoleDriver;
 
 class MEDCALCGUI_EXPORT PresentationController : public QObject {
   Q_OBJECT
@@ -58,38 +48,64 @@ public:
 
   void createActions();
 
-  MEDCALC::MEDPresentationViewMode getSelectedViewMode();
-  MEDCALC::MEDPresentationColorMap getSelectedColorMap();
+  MEDCALC::MEDPresentationViewMode getSelectedViewMode() const;
+  MEDCALC::MEDPresentationColorMap getSelectedColorMap() const;
+  MEDCALC::MEDPresentationScalarBarRange getSelectedScalarBarRange() const;
 
   void showDockWidgets(bool isVisible);
 
+  std::string getPresTypeFromWidgetHelper(int presId) const;
+
+  void setConsoleDriver(XmedConsoleDriver* driver) { _consoleDriver = driver; };
+
 signals:
   void presentationSignal(const PresentationEvent*);
 
 protected slots:
-  void OnVisualizeScalarMap();
-  void OnVisualizeContour();
-  void OnVisualizeVectorField();
-  void OnVisualizeSlices();
-  void OnVisualizeDeflectionShape();
-  void OnVisualizePointSprite();
+  void onVisualizeScalarMap();
+  void onVisualizeContour();
+  void onVisualizeVectorField();
+  void onVisualizeSlices();
+  void onVisualizeDeflectionShape();
+  void onVisualizePointSprite();
 
-  void OnDeletePresentation();
+  void onDeletePresentation();
+  void onParavisDump();
+
+  void onPresentationSelected(int presId, const QString& presType, const QString& presName);
 
   void processWorkspaceEvent(const MEDCALC::MedEvent*);
+  void processPresentationEvent(const PresentationEvent* event);
 
 private:
   void visualize(PresentationEvent::EventType);
   void updateTreeViewWithNewPresentation(long, long);
   void updateTreeViewForPresentationRemoval(long);
   std::string _getIconName(const std::string&);
+  MEDWidgetHelper * findOrCreateWidgetHelper(MEDCALC::MEDPresentationManager_ptr presManager,
+                                             int presId, const std::string& type, const std::string& name);
+
+  int getIntParamFromStudyEditor(SALOMEDS::SObject_var obj, const char * name);
+
+  QString getViewModePython() const;
+  QString getColorMapPython() const;
+  QString getScalarBarRangePython() const;
 
 private:
   MEDModule* _salomeModule;
+  XmedConsoleDriver* _consoleDriver;   // the same as in WorkspaceController
   SALOME_AppStudyEditor* _studyEditor; // borrowed to MEDModule
 
   QDockWidget *_dockWidget;
   WidgetPresentationParameters* _widgetPresentationParameters;
+
+  // GUI needs to talk directly to the pres manager to activate a view, get some params, print low level py dump, etc ...:
+  static MEDCALC::MEDPresentationManager_ptr _presManager;
+
+  // Key: presentation ID, value MEDPresentationHelper *
+  std::map<int, MEDWidgetHelper *> _presHelperMap;
+
+  MEDWidgetHelper * _currentWidgetHelper;
 };
 
 #endif /* PRESENTATION_CONTROLLER_HXX */
diff --git a/src/MEDCalc/gui/PresentationEvent.hxx b/src/MEDCalc/gui/PresentationEvent.hxx
new file mode 100644 (file)
index 0000000..536631a
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef SRC_MEDCALC_GUI_PRESENTATIONEVENT_HXX_
+#define SRC_MEDCALC_GUI_PRESENTATIONEVENT_HXX_
+
+#include <string>
+
+typedef struct {
+  enum EventType {
+    EVENT_VIEW_OBJECT_CONTOUR,
+    EVENT_VIEW_OBJECT_DEFLECTION_SHAPE,
+    EVENT_VIEW_OBJECT_POINT_SPRITE,
+    EVENT_VIEW_OBJECT_SCALAR_MAP,
+    EVENT_VIEW_OBJECT_SLICES,
+    EVENT_VIEW_OBJECT_VECTOR_FIELD,
+    EVENT_DELETE_PRESENTATION,
+
+    EVENT_CHANGE_COMPONENT,
+    EVENT_CHANGE_COLORMAP,
+    EVENT_CHANGE_TIME_RANGE
+  };
+
+  EventType eventtype;
+  MEDCALC::FieldHandler * fieldHandler;
+  int presentationId;
+  int anInteger;                // multi-purpose variable
+  //int anInteger2;             // multi-purpose variable
+  std::string aString;          // multi-purpose variable
+} PresentationEvent;
+
+#endif
index 8a2231969f58aaa2312c0988c4220679b0247fb8..ad2c1e231383e3ccc724931b834ac07099c3bf4b 100644 (file)
@@ -529,113 +529,6 @@ void WorkspaceController::processDatasourceEvent(const DatasourceEvent* event) {
   }
 }
 
-QString
-WorkspaceController::_getViewMode()
-{
-  MEDCALC::MEDPresentationViewMode viewMode = _salomeModule->getSelectedViewMode();
-  switch(viewMode) {
-  case MEDCALC::VIEW_MODE_REPLACE: return "MEDCALC.VIEW_MODE_REPLACE";
-  case MEDCALC::VIEW_MODE_OVERLAP: return "MEDCALC.VIEW_MODE_OVERLAP";
-  case MEDCALC::VIEW_MODE_NEW_LAYOUT: return "MEDCALC.VIEW_MODE_NEW_LAYOUT";
-  case MEDCALC::VIEW_MODE_SPLIT_VIEW: return "MEDCALC.VIEW_MODE_SPLIT_VIEW";
-  }
-  return QString();
-}
-
-QString
-WorkspaceController::_getColorMap()
-{
-  MEDCALC::MEDPresentationColorMap colorMap = _salomeModule->getSelectedColorMap();
-  switch(colorMap) {
-  case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW";
-  case MEDCALC::COLOR_MAP_COOL_TO_WARM: return "MEDCALC.COLOR_MAP_COOL_TO_WARM";
-  }
-  return QString();
-}
-
-/**
- * This slot can process the event coming from the
- * DatasourceController. The connection between the datasource signal
- * and this slot is realized by the main class MEDModule.
- */
-void WorkspaceController::processPresentationEvent(const PresentationEvent* event) {
-  XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
-  if ( dataModel == NULL ) {
-    STDLOG("No data model associated to this tree view");
-    return;
-  }
-
-  // >>>
-  // __GBO__ To know what to do we should test the type, because the
-  // object could be a mesh, a timeseries or a single field. We test
-  // here the case of a single field. Moreover, there could have
-  // options such that "change the underlying mesh".
-  // <<<
-
-  XmedDataObject* dataObject = event->objectdata;
-
-  // --> Send commands to SALOME Python console
-  if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) {
-    QString viewMode = _getViewMode();
-    //QString displayedInfo = ; // from PresentationController combobox
-    //QString scalarBarRange = ; // from PresentationController spinbox
-    QString colorMap = _getColorMap();
-    MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
-    QStringList commands;
-    commands += QString("presentation_id = medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
-    commands += QString("presentation_id");
-    _consoleDriver->exec(commands);
-  }
-  else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
-    QString viewMode = _getViewMode();
-    MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
-    QStringList commands;
-    commands += QString("presentation_id = medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
-    commands += QString("presentation_id");
-    _consoleDriver->exec(commands);
-  }
-  else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) {
-    QString viewMode = _getViewMode();
-    MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
-    QStringList commands;
-    commands += QString("presentation_id = medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
-    commands += QString("presentation_id");
-    _consoleDriver->exec(commands);
-  }
-  else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
-    QString viewMode = _getViewMode();
-    MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
-    QStringList commands;
-    commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
-    commands += QString("presentation_id");
-    _consoleDriver->exec(commands);
-  }
-  else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
-    QString viewMode = _getViewMode();
-    MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
-    QStringList commands;
-    commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
-    commands += QString("presentation_id");
-    _consoleDriver->exec(commands);
-  }
-  else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) {
-    QString viewMode = _getViewMode();
-    MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
-    QStringList commands;
-    commands += QString("presentation_id = medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
-    commands += QString("presentation_id");
-    _consoleDriver->exec(commands);
-  }
-  else if ( event->eventtype == PresentationEvent::EVENT_DELETE_PRESENTATION ) {
-      QStringList commands;
-      commands += QString("medcalc.RemovePresentation(%1)").arg(dataObject->getPresentationId());
-      _consoleDriver->exec(commands);
-  }
-  else {
-    STDLOG("The event "<<event->eventtype<<" is not implemented yet");
-  }
-}
-
 void
 WorkspaceController::processProcessingEvent(const ProcessingEvent* event)
 {
index f85a068e4b4f68939f83f069a3b3dad677838d89..c5fac88adddfa536030293a95186c4902283f53e 100644 (file)
@@ -52,6 +52,7 @@ public:
   ~WorkspaceController();
 
   void createActions();
+  XmedConsoleDriver* getConsoleDriver() { return _consoleDriver; }
 
 public slots:
   // Slots overiding TreeGuiManager
@@ -60,13 +61,10 @@ public slots:
   // Internal slots
   void processMedEvent(const MEDCALC::MedEvent* event);
   void processDatasourceEvent(const DatasourceEvent* event);
-  void processPresentationEvent(const PresentationEvent* event);
   void processProcessingEvent(const ProcessingEvent* event);
   void OnSaveWorkspace();
   void OnCleanWorkspace();
 
-  void onRequestTermination();
-
 signals:
   void workspaceSignal(const MEDCALC::MedEvent* event);
 
@@ -81,15 +79,13 @@ private:
   void _saveItemList(QStringList itemNameIdList);
   void _removeItemList(QStringList itemNameIdList);
   void _viewItemList(QStringList itemNameIdList);
-  QString _getViewMode();
-  QString _getColorMap();
 
 private:
   XmedConsoleDriver* _consoleDriver;
   MEDModule* _salomeModule;
   MEDEventListener_i* _medEventListener;
 
-  // This structure is intended to memorized in a bundle the whole set
+  // This structure is intended to memorize in a bundle the whole set
   // of integers identifying the actions of the popup menu associated
   // to the TreeView embedded in this TreeGuiManager
   typedef struct {
index 380784b0200829cb8cc3d519c9e4fa3105abc5ca..05765430e1fe840a71a8134dad4cbeb8dcd6ef36 100644 (file)
 #include "WidgetPresentationParameters.hxx"
 #include <Basics_Utils.hxx>
 
+using namespace std;
+
 WidgetPresentationParameters::WidgetPresentationParameters(QWidget* parent)
-  : QWidget(parent)
+  : QWidget(parent), _blockSig(false)
+{
+  _ui.setupUi(this); // To be done first
+
+  toggleWidget(false);
+  QObject::connect(_ui.comboBoxCompo,          SIGNAL(currentIndexChanged(int)),
+                   this,                       SLOT(onComboCompoIndexChanged(int)) );
+  QObject::connect(_ui.comboBoxScalarBarRange, SIGNAL(currentIndexChanged(int)),
+                   this,                       SLOT(onComboScalarBarRangeIndexChanged(int)) );
+  QObject::connect(_ui.comboBoxColorMap,       SIGNAL(currentIndexChanged(int)),
+                   this,                       SLOT(onComboColorMapIndexChanged(int)) );
+}
+
+void
+WidgetPresentationParameters::onComboCompoIndexChanged(int idx)
+{
+  if (!_blockSig) emit comboCompoIndexChanged(idx);
+}
+
+void
+WidgetPresentationParameters::onComboColorMapIndexChanged(int idx)
+{
+  if (!_blockSig) emit comboColorMapIndexChanged(idx);
+}
+
+void
+WidgetPresentationParameters::onComboScalarBarRangeIndexChanged(int idx)
+{
+  if (!_blockSig) emit comboScalarBarRangeIndexChanged(idx);
+}
+
+
+void
+WidgetPresentationParameters::toggleWidget(bool show)
+{
+  if (!show)
+    {
+      _blockSig = true;
+      _ui.widgetDynamic->hide();
+      setPresName("Choose a presentation");
+      // reset colorMap and scalarBarRange:
+      setColorMap(MEDCALC::COLOR_MAP_DEFAULT);
+      setScalarBarRange(MEDCALC::SCALAR_BAR_RANGE_DEFAULT);
+    }
+  else
+    {
+      _ui.widgetDynamic->show();
+      // It is the WidgetHelper responsability to re-show the widgets it needs
+      _ui.labelCompo->hide();
+      _ui.comboBoxCompo->hide();
+      _ui.labelSpinBox->hide();
+      _ui.spinBox->hide();
+      _ui.labelSliceOrient->hide();
+      _ui.comboBoxSliceOrient->hide();
+      _blockSig = false;
+    }
+}
+
+bool
+WidgetPresentationParameters::isShown() const
 {
-  ui.setupUi(this); // To be done first
+  return _ui.widgetDynamic->isVisible();
 }
 
-std::string
-WidgetPresentationParameters::getField()
+string
+WidgetPresentationParameters::getComponent() const
 {
-  return this->ui.comboBoxField->currentText().toStdString();
+  if (_ui.comboBoxCompo->currentIndex() == 0) // Euclidean norm
+      return "";
+
+  return _ui.comboBoxCompo->currentText().toStdString();
 }
 
-std::string
-WidgetPresentationParameters::getScalarBarRange()
+void
+WidgetPresentationParameters::setComponents(vector<string> compos, int selecIndex)
 {
-  return this->ui.comboBoxScalarBarRange->currentText().toStdString();
+  // Show the widget:
+  _ui.labelCompo->show();
+  _ui.comboBoxCompo->show();
+
+  _blockSig = true;
+  _ui.comboBoxCompo->clear();
+  _ui.comboBoxCompo->addItem(tr("LAB_EUCLIDEAN_NORM"));
+  for(vector<string>::const_iterator it = compos.begin(); it != compos.end(); ++it)
+    _ui.comboBoxCompo->addItem(QString::fromStdString(*it));
+  _ui.comboBoxCompo->setCurrentIndex(selecIndex);
+  _blockSig = false;
 }
 
-double
-WidgetPresentationParameters::getScalarBarTimestep()
+void
+WidgetPresentationParameters::setScalarBarRange(MEDCALC::MEDPresentationScalarBarRange sbrange)
 {
-  return this->ui.doubleSpinBoxTimeStep->value();
+  int idx;
+  if (sbrange == MEDCALC::SCALAR_BAR_ALL_TIMESTEPS)
+    idx = _ui.comboBoxScalarBarRange->findText(tr("LAB_ALL_TIMESTEPS"));
+  else if (sbrange == MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP)
+    idx = _ui.comboBoxScalarBarRange->findText(tr("LAB_CURRENT_TIMESTEP"));
+
+  if (idx >= 0)
+    {
+      _blockSig = true;
+      _ui.comboBoxScalarBarRange->setCurrentIndex(idx);
+      _blockSig = false;
+    }
+  else
+    STDLOG("Strange!! No matching found - unable to set scalar bar range in GUI.");
 }
 
-double
-WidgetPresentationParameters::getScalarBarMinVal()
+void
+WidgetPresentationParameters::setColorMap(MEDCALC::MEDPresentationColorMap colorMap)
 {
-  return this->ui.doubleSpinBoxMinVal->value();
+  int idx;
+  if (colorMap == MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW)
+    idx = _ui.comboBoxColorMap->findText(tr("LAB_BLUE_TO_RED"));
+  else if (colorMap == MEDCALC::COLOR_MAP_COOL_TO_WARM)
+    idx = _ui.comboBoxColorMap->findText(tr("LAB_COOL_TO_WARM"));
+
+  if (idx >= 0)
+    {
+      _blockSig = true;
+      _ui.comboBoxColorMap->setCurrentIndex(idx);
+      _blockSig = false;
+    }
+
+  else
+    STDLOG("Strange!! No matching found - unable to set color map in GUI.");
 }
 
-double
-WidgetPresentationParameters::getScalarBarMaxVal()
+
+MEDCALC::MEDPresentationScalarBarRange
+WidgetPresentationParameters::getScalarBarRange() const
 {
-  return this->ui.doubleSpinBoxMaxVal->value();
+  QString sbrange = _ui.comboBoxScalarBarRange->currentText();
+  if (sbrange == tr("LAB_ALL_TIMESTEPS")) {
+    return MEDCALC::SCALAR_BAR_ALL_TIMESTEPS;
+  }
+  else if (sbrange == tr("LAB_CURRENT_TIMESTEP")) {
+    return MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP;
+  }
+  // Should not happen
+  STDLOG("Strange!! No matching found - returning SCALAR_BAR_ALL_TIMESTEPS.");
+  return MEDCALC::SCALAR_BAR_ALL_TIMESTEPS;
 }
 
+//double
+//WidgetPresentationParameters::getScalarBarTimestep() const
+//{
+//  return _ui.doubleSpinBoxTimeStep->value();
+//}
+//
+//double
+//WidgetPresentationParameters::getScalarBarMinVal() const
+//{
+//  return _ui.doubleSpinBoxMinVal->value();
+//}
+//
+//double
+//WidgetPresentationParameters::getScalarBarMaxVal() const
+//{
+//  return _ui.doubleSpinBoxMaxVal->value();
+//}
+
 MEDCALC::MEDPresentationColorMap
-WidgetPresentationParameters::getColorMap()
+WidgetPresentationParameters::getColorMap() const
 {
-  QString colorMap = this->ui.comboBoxColorMap->currentText();
+  QString colorMap = _ui.comboBoxColorMap->currentText();
   if (colorMap == tr("LAB_BLUE_TO_RED")) {
     return MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW;
   }
@@ -70,3 +199,18 @@ WidgetPresentationParameters::getColorMap()
   STDLOG("Strange!! No matching color map found - returning blue to red.");
   return MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW;
 }
+
+QComboBox *
+WidgetPresentationParameters::getComboBoxCompo()
+{
+  return _ui.comboBoxCompo;
+}
+
+void
+WidgetPresentationParameters::setPresName(const std::string& name)
+{
+  _ui.labelPresName->setText(QString::fromStdString(name));
+  QFont f(_ui.labelPresName->font());
+  f.setItalic(true);
+  _ui.labelPresName->setFont(f);
+}
index 8e1905a8c9258fa7a9e81e88f30453836d2d7a94..03f70bdb016ff4d67428932dda2fca67e378063d 100644 (file)
@@ -28,6 +28,8 @@
 #include CORBA_SERVER_HEADER(MEDPresentationManager)
 
 #include <QObject>
+#include <vector>
+#include <string>
 
 class MEDCALCGUI_DIALOGS_EXPORT WidgetPresentationParameters : public QWidget
 {
@@ -37,15 +39,37 @@ public:
   WidgetPresentationParameters(QWidget* parent = 0);
   virtual ~WidgetPresentationParameters() {}
 
-  std::string getField();
-  std::string getScalarBarRange();
-  double getScalarBarTimestep();
-  double getScalarBarMinVal();
-  double getScalarBarMaxVal();
-  MEDCALC::MEDPresentationColorMap getColorMap();
+  std::string getComponent() const;
+  void setComponents(std::vector<std::string> compos, int selecIndex);
 
- private:
-  Ui_WidgetPresentationParameters ui; // instance of the class defined in ui_WidgetPresentationParameters.h
+  MEDCALC::MEDPresentationScalarBarRange getScalarBarRange() const;
+  void setScalarBarRange(MEDCALC::MEDPresentationScalarBarRange);
+
+//  double getScalarBarTimestep() const;
+//  double getScalarBarMinVal() const;
+//  double getScalarBarMaxVal() const;
+  MEDCALC::MEDPresentationColorMap getColorMap() const;
+  void setColorMap(MEDCALC::MEDPresentationColorMap);
+
+  void setPresName(const std::string& name);
+
+  void toggleWidget(bool show);
+  bool isShown() const;
+  QComboBox * getComboBoxCompo();
+
+signals:
+  void comboScalarBarRangeIndexChanged(int);
+  void comboColorMapIndexChanged(int);
+  void comboCompoIndexChanged(int);
+
+private slots:
+  void onComboScalarBarRangeIndexChanged(int);
+  void onComboColorMapIndexChanged(int);
+  void onComboCompoIndexChanged(int);
+
+private:
+  Ui_WidgetPresentationParameters _ui; // instance of the class defined in ui_WidgetPresentationParameters.h
+  bool _blockSig;
 };
 
 
index 291ef54fe787993fe09be5595110983c8d6a9f33..85279d3695eed19689425962b79117c128fd0dcc 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>404</width>
-    <height>200</height>
+    <width>439</width>
+    <height>359</height>
    </rect>
   </property>
   <property name="minimumSize">
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout">
-   <item row="0" column="0">
-    <widget class="QLabel" name="label">
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QLabel" name="labelPresName">
      <property name="text">
-      <string>LAB_DISP_COMP</string>
+      <string>LAB_PRES_NAME</string>
      </property>
     </widget>
    </item>
-   <item row="0" column="1">
-    <widget class="QComboBox" name="comboBoxField">
-     <item>
-      <property name="text">
-       <string>LAB_EUCLIDEAN_NORM</string>
-      </property>
-     </item>
+   <item>
+    <widget class="QWidget" name="widget" native="true">
+     <layout class="QGridLayout" name="gridLayout_2">
+      <item row="0" column="1">
+       <widget class="QComboBox" name="comboBoxScalarBarRange">
+        <property name="enabled">
+         <bool>true</bool>
+        </property>
+        <item>
+         <property name="text">
+          <string>LAB_ALL_TIMESTEPS</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>LAB_CURRENT_TIMESTEP</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+      <item row="2" column="0">
+       <widget class="QLabel" name="label_3">
+        <property name="text">
+         <string>LAB_COLOR_MAP</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="QComboBox" name="comboBoxColorMap">
+        <item>
+         <property name="text">
+          <string>LAB_BLUE_TO_RED</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>LAB_COOL_TO_WARM</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+      <item row="0" column="0">
+       <widget class="QLabel" name="label_4">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>LAB_RANGE</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
     </widget>
    </item>
-   <item row="4" column="0">
-    <widget class="QLabel" name="labelTimeStep">
-     <property name="enabled">
-      <bool>false</bool>
-     </property>
-     <property name="text">
-      <string>LAB_TIMESTEP</string>
-     </property>
-     <property name="alignment">
-      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+   <item>
+    <widget class="Line" name="line">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
      </property>
     </widget>
    </item>
-   <item row="4" column="1">
-    <widget class="QDoubleSpinBox" name="doubleSpinBoxTimeStep">
-     <property name="enabled">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="5" column="0">
-    <widget class="QLabel" name="labelMinVal">
-     <property name="enabled">
-      <bool>false</bool>
-     </property>
-     <property name="text">
-      <string>LAB_MIN_VALUE</string>
-     </property>
-     <property name="alignment">
-      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-     </property>
+   <item>
+    <widget class="QWidget" name="widgetDynamic" native="true">
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0">
+       <widget class="QLabel" name="labelCompo">
+        <property name="text">
+         <string>LAB_DISP_COMP</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" colspan="2">
+       <widget class="QComboBox" name="comboBoxCompo">
+        <item>
+         <property name="text">
+          <string>LAB_EUCLIDEAN_NORM</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="labelSpinBox">
+        <property name="text">
+         <string>LAB_SPIN_BOX</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="QSpinBox" name="spinBox"/>
+      </item>
+      <item row="1" column="2">
+       <spacer name="horizontalSpacer">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>235</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="2" column="0">
+       <widget class="QLabel" name="labelSliceOrient">
+        <property name="text">
+         <string>LAB_SLICE_ORIENT</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1" colspan="2">
+       <widget class="QComboBox" name="comboBoxSliceOrient">
+        <item>
+         <property name="text">
+          <string>LAB_SLICE_NORMAL_TO_X</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>LAB_SLICE_NORMAL_TO_Y</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>LAB_SLICE_NORMAL_TO_Z</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+     </layout>
     </widget>
    </item>
-   <item row="5" column="1">
-    <widget class="QDoubleSpinBox" name="doubleSpinBoxMinVal">
-     <property name="enabled">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="6" column="0">
-    <widget class="QLabel" name="labelMaxVal">
-     <property name="enabled">
-      <bool>false</bool>
-     </property>
-     <property name="text">
-      <string>LAB_MAX_VALUE</string>
-     </property>
-     <property name="alignment">
-      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-     </property>
-    </widget>
-   </item>
-   <item row="6" column="1">
-    <widget class="QDoubleSpinBox" name="doubleSpinBoxMaxVal">
-     <property name="enabled">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="7" column="0">
-    <widget class="QLabel" name="label_3">
-     <property name="text">
-      <string>LAB_COLOR_MAP</string>
-     </property>
-    </widget>
-   </item>
-   <item row="7" column="1">
-    <widget class="QComboBox" name="comboBoxColorMap">
-     <item>
-      <property name="text">
-       <string>LAB_BLUE_TO_RED</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>LAB_COOL_TO_WARM</string>
-      </property>
-     </item>
-    </widget>
-   </item>
-   <item row="3" column="1">
-    <widget class="QComboBox" name="comboBoxScalarBarRange">
-     <property name="enabled">
-      <bool>true</bool>
-     </property>
-     <item>
-      <property name="text">
-       <string>LAB_ALL_TIMESTEPS</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>LAB_ONE_TIMESTEP</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>LAB_USER_RANGE</string>
-      </property>
-     </item>
-    </widget>
-   </item>
-   <item row="1" column="0">
-    <widget class="QLabel" name="label_2">
-     <property name="text">
-      <string>LAB_SCALARBAR</string>
-     </property>
-    </widget>
-   </item>
-   <item row="3" column="0">
-    <widget class="QLabel" name="label_5">
-     <property name="enabled">
-      <bool>true</bool>
-     </property>
-     <property name="text">
-      <string>LAB_RANGE</string>
-     </property>
-     <property name="alignment">
-      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-     </property>
-    </widget>
+   <item>
+    <spacer name="verticalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>167</height>
+      </size>
+     </property>
+    </spacer>
    </item>
   </layout>
  </widget>
index 0877a8c1d098bbf1fbb98537f7e23c29fcbb23b5..1bf752c9e587d148a1c196fa2b5203061afdb741 100644 (file)
@@ -40,13 +40,17 @@ from medio import LoadImageAsDataSource
 
 # Presentations
 from medpresentation import MakeScalarMap
-from medpresentation import MakeContour
-from medpresentation import MakeVectorField
-from medpresentation import MakeSlices
-from medpresentation import MakeDeflectionShape
-from medpresentation import MakePointSprite
+#from medpresentation import MakeContour
+#from medpresentation import MakeVectorField
+#from medpresentation import MakeSlices
+#from medpresentation import MakeDeflectionShape
+#from medpresentation import MakePointSprite
 from medpresentation import RemovePresentation
 
+from medpresentation import GetScalarMapParameters
+
+from medpresentation import UpdateScalarMap
+
 # Console commands
 import medconsole
 
index 04d252b9a17eca51355a3a62a517bfb4a8dad641..ac80b13a0066cc53c9cc016d9e67bed36bc7ef7d 100644 (file)
@@ -48,7 +48,7 @@ def _typeOfFieldLabel(typeOfField):
   try:
     return __mapTypeOfFieldLabel[typeOfField]
   except IndexError, e:
-    return "UNCKNOWN"
+    return "UNKNOWN"
 #
 
 def newFieldProxy(fieldHandlerId):
index c48eebd485bf085a12eb97b33bfc3c4d388afe1c..8762d9a02213a1497208e94496717a56aba2ed7c 100644 (file)
@@ -25,73 +25,70 @@ __manager = medcalc.medcorba.factory.getPresentationManager()
 
 def MakeScalarMap(proxy,
                   viewMode=MEDCALC.VIEW_MODE_DEFAULT,
-                  displayedInfo=MEDCALC.DISPLAY_DEFAULT,
-                  scalarBarRange=MEDCALC.ScalarBarRange(MEDCALC.SCALAR_BAR_RANGE_VAL_MIN_DEFAULT,
-                                                        MEDCALC.SCALAR_BAR_RANGE_VAL_MAX_DEFAULT),
+                  displayedComponent=MEDCALC.DISPLAY_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.ScalarMapParameters(proxy.id, viewMode, displayedInfo, scalarBarRange, colorMap)
-  presentation_id = __manager.makeScalarMap(params)
+  params = MEDCALC.ScalarMapParameters(proxy.id, displayedComponent, scalarBarRange, colorMap)
+  presentation_id = __manager.makeScalarMap(params, viewMode)
   notifyGui_addPresentation(proxy.id, presentation_id)
   return presentation_id
 #
 
-def MakeContour(proxy,
-                viewMode=MEDCALC.VIEW_MODE_DEFAULT,
-                displayedInfo=MEDCALC.DISPLAY_DEFAULT,
-                scalarBarRange=MEDCALC.ScalarBarRange(MEDCALC.SCALAR_BAR_RANGE_VAL_MIN_DEFAULT,
-                                                      MEDCALC.SCALAR_BAR_RANGE_VAL_MAX_DEFAULT),
-                colorMap=MEDCALC.COLOR_MAP_DEFAULT,
-                nbContours=MEDCALC.NB_CONTOURS_DEFAULT
-                ):
-  params = MEDCALC.ContourParameters(proxy.id, viewMode, displayedInfo, scalarBarRange, colorMap, nbContours)
-  presentation_id = __manager.makeContour(params)
-  notifyGui_addPresentation(proxy.id, presentation_id)
-  return presentation_id
+#def MakeContour(proxy,
+#                viewMode=MEDCALC.VIEW_MODE_DEFAULT,
+#                displayedComponent=MEDCALC.DISPLAY_DEFAULT,
+#                scalarBarRange=MEDCALC.SCALAR_BAR_RANGE_DEFAULT,
+#                colorMap=MEDCALC.COLOR_MAP_DEFAULT,
+#                nbContours=MEDCALC.NB_CONTOURS_DEFAULT
+#                ):
+#  params = MEDCALC.ContourParameters(proxy.id, viewMode, displayedComponent, scalarBarRange, colorMap, nbContours)
+#  presentation_id = __manager.makeContour(params)
+#  notifyGui_addPresentation(proxy.id, presentation_id)
+#  return presentation_id
+##
 #
-
-def MakeVectorField(proxy,
-                    viewMode=MEDCALC.VIEW_MODE_DEFAULT
-                    ):
-  params = MEDCALC.VectorFieldParameters(proxy.id, viewMode)
-  presentation_id = __manager.makeVectorField(params)
-  notifyGui_addPresentation(proxy.id, presentation_id)
-  return presentation_id
+#def MakeVectorField(proxy,
+#                    viewMode=MEDCALC.VIEW_MODE_DEFAULT
+#                    ):
+#  params = MEDCALC.VectorFieldParameters(proxy.id, viewMode)
+#  presentation_id = __manager.makeVectorField(params)
+#  notifyGui_addPresentation(proxy.id, presentation_id)
+#  return presentation_id
+##
 #
-
-def MakeSlices(proxy,
-               viewMode=MEDCALC.VIEW_MODE_DEFAULT,
-               orientation=MEDCALC.SLICE_ORIENTATION_DEFAULT,
-               nbSlices=MEDCALC.NB_SLICES_DEFAULT
-               ):
-  params = MEDCALC.SlicesParameters(proxy.id, viewMode, orientation, nbSlices)
-  presentation_id = __manager.makeSlices(params)
-  notifyGui_addPresentation(proxy.id, presentation_id)
-  return presentation_id
+#def MakeSlices(proxy,
+#               viewMode=MEDCALC.VIEW_MODE_DEFAULT,
+#               orientation=MEDCALC.SLICE_ORIENTATION_DEFAULT,
+#               nbSlices=MEDCALC.NB_SLICES_DEFAULT
+#               ):
+#  params = MEDCALC.SlicesParameters(proxy.id, viewMode, orientation, nbSlices)
+#  presentation_id = __manager.makeSlices(params)
+#  notifyGui_addPresentation(proxy.id, presentation_id)
+#  return presentation_id
+##
 #
-
-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
+#                        ):
+#  params = MEDCALC.DeflectionShapeParameters(proxy.id, viewMode)
+#  presentation_id = __manager.makeDeflectionShape(params)
+#  notifyGui_addPresentation(proxy.id, presentation_id)
+#  return presentation_id
+##
 #
-
-def MakePointSprite(proxy,
-                    viewMode=MEDCALC.VIEW_MODE_DEFAULT,
-                    displayedInfo=MEDCALC.DISPLAY_DEFAULT,
-                    scalarBarRange=MEDCALC.ScalarBarRange(MEDCALC.SCALAR_BAR_RANGE_VAL_MIN_DEFAULT,
-                                                          MEDCALC.SCALAR_BAR_RANGE_VAL_MAX_DEFAULT),
-                    colorMap=MEDCALC.COLOR_MAP_DEFAULT,
-                    ):
-  params = MEDCALC.PointSpriteParameters(proxy.id, viewMode, displayedInfo, scalarBarRange, colorMap)
-  presentation_id = __manager.makePointSprite(params)
-  notifyGui_addPresentation(proxy.id, presentation_id)
-  return presentation_id
+#def MakePointSprite(proxy,
+#                    viewMode=MEDCALC.VIEW_MODE_DEFAULT,
+#                    displayedComponent=MEDCALC.DISPLAY_DEFAULT,
+#                    scalarBarRange=MEDCALC.SCALAR_BAR_RANGE_DEFAULT,
+#                    colorMap=MEDCALC.COLOR_MAP_DEFAULT,
+#                    ):
+#  params = MEDCALC.PointSpriteParameters(proxy.id, viewMode, displayedComponent, scalarBarRange, colorMap)
+#  presentation_id = __manager.makePointSprite(params)
+#  notifyGui_addPresentation(proxy.id, presentation_id)
+#  return presentation_id
 #
 
 def RemovePresentation(presentation_id):
@@ -99,3 +96,11 @@ def RemovePresentation(presentation_id):
   if ok:
     notifyGui_removePresentation(presentation_id)
 #
+
+def GetScalarMapParameters(presentation_id):
+  # TODO: check that pres id is really a ScalarMap ...
+  params = __manager.getScalarMapParameters(presentation_id)
+  return params
+
+def UpdateScalarMap(presentation_id, params):
+  __manager.updateScalarMap(presentation_id, params)