Salome HOME
[MEDCalc] Multiple slices + other minor imps:
authorabn <adrien.bruneton@cea.fr>
Thu, 4 Aug 2016 10:24:10 +0000 (12:24 +0200)
committerabn <adrien.bruneton@cea.fr>
Thu, 4 Aug 2016 10:24:10 +0000 (12:24 +0200)
  + bug fix when updating parameters
  + nicer mesh icons

22 files changed:
src/MEDCalc/cmp/MEDPresentationSlices.cxx
src/MEDCalc/cmp/MEDPresentationSlices.hxx
src/MEDCalc/gui/MEDWidgetHelper.cxx
src/MEDCalc/gui/MEDWidgetHelper.hxx
src/MEDCalc/gui/MEDWidgetHelperComponent.cxx
src/MEDCalc/gui/MEDWidgetHelperComponent.hxx
src/MEDCalc/gui/MEDWidgetHelperContour.cxx
src/MEDCalc/gui/MEDWidgetHelperContour.hxx
src/MEDCalc/gui/MEDWidgetHelperMeshView.cxx
src/MEDCalc/gui/MEDWidgetHelperMeshView.hxx
src/MEDCalc/gui/MEDWidgetHelperSlices.cxx
src/MEDCalc/gui/MEDWidgetHelperSlices.hxx
src/MEDCalc/gui/MED_msg_en.ts
src/MEDCalc/gui/PresentationController.cxx
src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx
src/MEDCalc/res/presentations/classic/visu_mesh16.png
src/MEDCalc/res/presentations/classic/visu_mesh24.png
src/MEDCalc/res/presentations/modern/mesh16.png
src/MEDCalc/res/presentations/modern/mesh24.png
src/MEDCalc/test/tui/slices.py
src/MEDCalc/tui/__init__.py
src/MEDCalc/tui/medpresentation.py

index 16dbf4fad256bf69bdb5b2da793c2b019e8c9a8e..83945b32d3ca6b552d2b8a4ea2d44636cd9c244d 100644 (file)
@@ -39,53 +39,86 @@ MEDPresentationSlices::MEDPresentationSlices(const MEDCALC::SlicesParameters& pa
 }
 
 void
-MEDPresentationSlices::setNumberOfSlices()
+MEDPresentationSlices::generateSlices()
 {
-  std::ostringstream oss1;
-  // TODO
-//  oss1 << _objVar << ".SliceType.Normal = " << norm << ";";
+  std::ostringstream oss;
+  int nbSlices = getIntProperty(MEDPresentationSlices::PROP_NB_SLICES);
+  std::string normal = getNormalVector();
+
+  oss << "import medcalc; __origins = medcalc.GetSliceOrigins(" << _srcObjVar << ", " << nbSlices << ", " << normal << ");";
+  pushAndExecPyLine(oss.str()); oss.str("");
+  pushAndExecPyLine("__objLst = [];");
+  oss << "for sliceNum in range(" << nbSlices << "):\n";
+  oss << "  obj = pvs.Slice(Input=" << _srcObjVar << ")\n";
+  oss << "  obj.SliceType = 'Plane'\n";
+  oss << "  obj.SliceType.Normal = " << normal << "\n";
+  oss << "  obj.SliceType.Origin = __origins[sliceNum]\n";
+  oss << "  __objLst.append(obj)\n\n";
+  pushAndExecPyLine(oss.str()); oss.str("");
+
+  oss << _objVar << " = pvs.GroupDatasets(Input=__objLst);";
+  pushAndExecPyLine(oss.str()); oss.str("");
 }
 
 void
-MEDPresentationSlices::selectSliceOrientation()
+MEDPresentationSlices::generateAndDisplay()
 {
-  std::ostringstream oss1;
-  std::string norm;
+  generateSlices();
+  showObject();
+
+  colorBy(_fieldType);
+  showScalarBar();
+  rescaleTransferFunction();
+  selectColorMap();
+  resetCameraAndRender();
+}
+
+
+void
+MEDPresentationSlices::clearPreviousSlices()
+{
+  std::ostringstream oss;
+
+  pushAndExecPyLine("for sliceNum, _ in enumerate(__objLst):\n  pvs.Delete(__objLst[sliceNum]);");
+  oss <<            "pvs.Delete(" << _objVar << ");";
+  pushAndExecPyLine(oss.str()); oss.str("");
+}
 
+std::string
+MEDPresentationSlices::getNormalVector() const
+{
   switch(_params.orientation)
   {
     case MEDCALC::SLICE_NORMAL_TO_X:
-      norm = "[1.0, 0.0, 0.0]";
-      break;
+      return "[1.0, 0.0, 0.0]";
     case MEDCALC::SLICE_NORMAL_TO_Y:
-      norm = "[0.0, 1.0, 0.0]";
-      break;
+      return "[0.0, 1.0, 0.0]";
     case MEDCALC::SLICE_NORMAL_TO_Z:
-      norm = "[0.0, 0.0, 1.0]";
-      break;
+      return "[0.0, 0.0, 1.0]";
     case MEDCALC::SLICE_NORMAL_TO_XY:
-      norm = "[1.0, 1.0, 0.0]";
-      break;
+      return "[1.0, 1.0, 0.0]";
     case MEDCALC::SLICE_NORMAL_TO_XZ:
-      norm = "[1.0, 0.0, 1.0]";
-      break;
+      return "[1.0, 0.0, 1.0]";
     case MEDCALC::SLICE_NORMAL_TO_YZ:
-      norm = "[0.0, 1.0, 1.0]";
-      break;
+      return "[0.0, 1.0, 1.0]";
     case MEDCALC::SLICE_NORMAL_TO_XYZ:
-      norm = "[1.0, 1.0, 1.0]";
-      break;
+      return "[1.0, 1.0, 1.0]";
     default:
       const char * mes = "Unexpected getSliceOrientationCommand() error!";
       STDLOG(mes);
       throw KERNEL::createSalomeException(mes);
   }
+  return ""; // never happens
+}
 
-  oss1 << _objVar << ".SliceType.Normal = " << norm << ";";
+void
+MEDPresentationSlices::selectSliceOrientation(const std::string & obj)
+{
+  std::ostringstream oss1;
+  oss1 << obj << ".SliceType.Normal = " << getNormalVector() << ";";
   pushAndExecPyLine(oss1.str()); oss1.str("");
 }
 
-
 void
 MEDPresentationSlices::internalGeneratePipeline()
 {
@@ -101,21 +134,8 @@ MEDPresentationSlices::internalGeneratePipeline()
   fillAvailableFieldComponents();
   setOrCreateRenderView(); // instanciate __viewXXX
 
-  oss << _objVar << " = pvs.Slice(Input=" << _srcObjVar << ");";
-  pushAndExecPyLine(oss.str()); oss.str("");
-
-  showObject();
-
-  oss << _objVar << ".SliceType = 'Plane';";
-  pushAndExecPyLine(oss.str()); oss.str("");
-
-  // Set slice orientation
-  selectSliceOrientation();
-  colorBy(_fieldType);
-  showScalarBar();
-  rescaleTransferFunction();
-  selectColorMap();
-  resetCameraAndRender();
+  // Now create the initial number of slices
+  generateAndDisplay();
 }
 
 void
@@ -148,8 +168,8 @@ MEDPresentationSlices::updateNbSlices(const int nbSlices)
   // Update the pipeline:
   {
     MEDPyLockWrapper lock;
-    setNumberOfSlices();
-    pushAndExecPyLine("pvs.Render();");
+    clearPreviousSlices();
+    generateAndDisplay();
   }
 }
 
@@ -159,13 +179,14 @@ MEDPresentationSlices::updateOrientation(const MEDCALC::SliceOrientationType ori
   _params.orientation = orientation;
 
   // GUI helper:
-  setIntProperty(MEDPresentationSlices::PROP_SLICE_ORIENTATION, orientation);
+  setIntProperty(MEDPresentationSlices::PROP_SLICE_ORIENTATION, static_cast<int>(orientation));
 
   // Update the pipeline:
   {
     MEDPyLockWrapper lock;
-    selectSliceOrientation();
-    pushAndExecPyLine("pvs.Render();");
+
+    clearPreviousSlices();
+    generateAndDisplay();
   }
 }
 
index 81d5ae7e8ac117c1f9a879afcecadc1b290dffd1..19afa196e92d5440f2870e547dd309dd7b09eaa2 100644 (file)
@@ -43,8 +43,12 @@ protected:
   void updateOrientation(const MEDCALC::SliceOrientationType orientation);
   virtual void internalGeneratePipeline();
 
-  void setNumberOfSlices();
-  void selectSliceOrientation();
+  void generateSlices();
+  void clearPreviousSlices();
+  void generateAndDisplay();
+  void selectSliceOrientation(const std::string & obj);
+
+  std::string getNormalVector() const;
 
 private:
   MEDCALC::SlicesParameters _params;
index 4451ca9ad2ac8892839cddccb36913d862d15c3e..8869c847ba4f0efd38b694243f1153bbca0fba6e 100644 (file)
@@ -53,7 +53,7 @@ void MEDWidgetHelper::loadParametersFromEngine()
       _presManager->getPresentationIntProperty(_presId, MEDPresentation::PROP_SCALAR_BAR_RANGE.c_str()));
 }
 
-void MEDWidgetHelper::udpateWidget()
+void MEDWidgetHelper::updateWidget(bool connect)
 {
   // Set presentation name
   _paramWidget->setPresName(_presName);
@@ -67,8 +67,11 @@ void MEDWidgetHelper::udpateWidget()
   _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)) );
+  if (connect)
+    {
+      QObject::connect( _paramWidget, SIGNAL(comboScalarBarRangeIndexChanged(int)), this, SLOT(onScalarBarRangeChanged(int)) );
+      QObject::connect( _paramWidget, SIGNAL(comboColorMapIndexChanged(int)), this, SLOT(onColorMapChanged(int)) );
+    }
 }
 
 void MEDWidgetHelper::releaseWidget()
index 2fbeaadca42d5a887adcdaf72d42a0458a3fe221..a5f60a561897a0b73c087f2d90b15b1b26d58b8c 100644 (file)
@@ -40,7 +40,7 @@ class MEDWidgetHelper : public QObject
 public:
   virtual ~MEDWidgetHelper();
 
-  virtual void udpateWidget();
+  virtual void updateWidget(bool connect);
   virtual void releaseWidget();
 
   ///! Returns the string X in the Python command "Update<X>" or "Get<X>Parameters"
index 947fc3434f29603474c06835cd5908b3eb013e95..01a29e9edf4cd52ed68cf73f5ef59b1664674a86 100644 (file)
@@ -28,16 +28,19 @@ MEDWidgetHelperComponent::MEDWidgetHelperComponent(const PresentationController
 MEDWidgetHelperComponent::~MEDWidgetHelperComponent()
 {}
 
-void MEDWidgetHelperComponent::udpateWidget()
+void MEDWidgetHelperComponent::updateWidget(bool connect)
 {
-  MEDWidgetHelper::udpateWidget();
+  MEDWidgetHelper::updateWidget(connect);
 
   _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)) );
+  if (connect)
+    {
+      // 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 MEDWidgetHelperComponent::releaseWidget()
index 58c774f158174604419a43f4eaf00d0b0ff58098..fce67204d9ab7b20058476709aae72fd0890ab75 100644 (file)
@@ -37,7 +37,7 @@ public:
                            WidgetPresentationParameters * paramW);
   virtual ~MEDWidgetHelperComponent();
 
-  virtual void udpateWidget();
+  virtual void updateWidget(bool connect);
   virtual void releaseWidget();
 
   virtual std::string getPythonTag() const = 0;
index 40ded91d5a39cfc60b7aa6a6d3b7075eaaadf538..351c558bf5b8ffd06dc3c51407d6304b0624e9ed 100644 (file)
@@ -41,20 +41,21 @@ void MEDWidgetHelperContour::loadParametersFromEngine()
   _nbContours = _presManager->getPresentationIntProperty(_presId, MEDPresentationContour::PROP_NB_CONTOUR.c_str());
 }
 
-void MEDWidgetHelperContour::udpateWidget()
+void MEDWidgetHelperContour::updateWidget(bool connect)
 {
-  MEDWidgetHelper::udpateWidget();
+  MEDWidgetHelper::updateWidget(connect);
   STDLOG("MEDWidgetHelperContour::udpateWidget() nbContour is " << _nbContours);
 
   // Contour presentation needs the number of contours
-//  _paramWidget->setComponents(_allCompos, _selectedCompo);
   _paramWidget->setNbContour(_nbContours);
 
   // 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)) );
-  QObject::connect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbContourChanged(int)) );
+  if (connect)
+    {
+      QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
+                        _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
+      QObject::connect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbContourChanged(int)) );
+    }
 }
 
 void MEDWidgetHelperContour::releaseWidget()
index 0e545fe7862473a6e721b8ed5cf29a354c131d1c..fc37759931f55da61b66de8641001826d0d74346 100644 (file)
@@ -34,7 +34,7 @@ public:
                            WidgetPresentationParameters * paramW);
   virtual ~MEDWidgetHelperContour();
 
-  virtual void udpateWidget();
+  virtual void updateWidget(bool connect);
   virtual void releaseWidget();
 
   virtual std::string getPythonTag() const { return "Contour"; }
index 2ea42450099a22329de575078bdac30b2020ee33..c75d453f042de27431625223565f5a263a63ed8f 100644 (file)
@@ -42,19 +42,22 @@ void MEDWidgetHelperMeshView::loadParametersFromEngine()
           _presManager->getPresentationIntProperty(_presId, MEDPresentationMeshView::PROP_MESH_MODE.c_str()));
 }
 
-void MEDWidgetHelperMeshView::udpateWidget()
+void MEDWidgetHelperMeshView::updateWidget(bool connect)
 {
-  MEDWidgetHelper::udpateWidget();
+  MEDWidgetHelper::updateWidget(connect);
 
   // MeshView presentation needs the mesh mode that's all.
   _paramWidget->setMeshMode(_meshMode);
   // Hide color map and scalar bar range
   _paramWidget->toggleCommonFieldWidget(false);
 
-  // Connect combo box changes
-  QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
-                    _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
-  QObject::connect( _paramWidget, SIGNAL(comboMeshIndexChanged(int)), this, SLOT(onMeshModeChanged(int)) );
+  if (connect)
+    {
+      // Connect combo box changes
+      QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
+                        _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
+      QObject::connect( _paramWidget, SIGNAL(comboMeshIndexChanged(int)), this, SLOT(onMeshModeChanged(int)) );
+    }
 }
 
 void MEDWidgetHelperMeshView::releaseWidget()
index efbd56117ef562676d0ea95816c9e21ece6a357f..83f2b50e6641d5604548ec4cf62b54d4fe2188ee 100644 (file)
@@ -34,7 +34,7 @@ public:
                            WidgetPresentationParameters * paramW);
   virtual ~MEDWidgetHelperMeshView();
 
-  virtual void udpateWidget();
+  virtual void updateWidget(bool connect);
   virtual void releaseWidget();
 
   virtual std::string getPythonTag() const { return "MeshView"; }
index b785cfab604338a4dd230fc32536828cd5cd4955..eb99e87759f32779982b99a2f93359a816e12f87 100644 (file)
@@ -44,19 +44,22 @@ void MEDWidgetHelperSlices::loadParametersFromEngine()
       _presManager->getPresentationIntProperty(_presId, MEDPresentationSlices::PROP_SLICE_ORIENTATION.c_str()));
 }
 
-void MEDWidgetHelperSlices::udpateWidget()
+void MEDWidgetHelperSlices::updateWidget(bool connect)
 {
-  MEDWidgetHelper::udpateWidget();
+  MEDWidgetHelper::updateWidget(connect);
   STDLOG("MEDWidgetHelperSlices::udpateWidget() nbSlices is " << _nbSlices);
 
-//  _paramWidget->setNbSlices(_nbSlices);        // TODO: uncomment when ready to deal with slice number
+  _paramWidget->setNbSlices(_nbSlices);
   _paramWidget->setSliceOrientation(_sliceOrientation);
 
   // Connect combo box changes
-  QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
-                    _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
-  QObject::connect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbSlicesChanged(int)) );
-  QObject::connect( _paramWidget, SIGNAL(comboOrientIndexChanged(int)), this, SLOT(onSliceOrientationChanged(int)) );
+  if (connect)
+    {
+      QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
+                        _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
+      QObject::connect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbSlicesChanged(int)) );
+      QObject::connect( _paramWidget, SIGNAL(comboOrientIndexChanged(int)), this, SLOT(onSliceOrientationChanged(int)) );
+    }
 }
 
 void MEDWidgetHelperSlices::releaseWidget()
@@ -83,7 +86,7 @@ void MEDWidgetHelperSlices::onNbSlicesChanged(int nbSlices)
 
 void MEDWidgetHelperSlices::onSliceOrientationChanged(int sliceOrient)
 {
-  STDLOG("MEDWidgetHelperSlices::onNbSlicesChanged");
+  STDLOG("MEDWidgetHelperSlices::onSliceOrientationChanged");
   PresentationEvent* event = new PresentationEvent();
   event->eventtype = PresentationEvent::EVENT_CHANGE_SLICE_ORIENTATION;
   event->presentationId = _presId;
index ddfcb2a84751938b026bdcbd20017dbb0db1181e..bce48ef03b681ae2e7e0bcb34e7993209a630fae 100644 (file)
@@ -34,7 +34,7 @@ public:
                            WidgetPresentationParameters * paramW);
   virtual ~MEDWidgetHelperSlices();
 
-  virtual void udpateWidget();
+  virtual void updateWidget(bool connect);
   virtual void releaseWidget();
 
   virtual std::string getPythonTag() const { return "Slices"; }
index a3564ddd2eb0b2ad097ee7b82e4b7abede2d04b3..a9a9a1ebca845460c28b15369f5303c0bffea73e 100644 (file)
   </context>
   <context>
     <name>WidgetPresentationParameters</name>
+    <message>
+      <source>LAB_DEFAULT_DYN_TITLE</source>
+      <translation>Default parameters</translation>
+    </message>    
     <message>
       <source>LAB_DISP_COMP</source>
       <translation>Displayed component:</translation>
index 44acb921eac52bbd25acfe734980da0917f80103..c6fcbbe78966cc13ba876f9a8a3b08e1c2bfafda 100644 (file)
@@ -619,7 +619,7 @@ PresentationController::onPresentationSelected(int presId, const QString& presTy
       _presManager->activateView(presId);
       // Update widgets parameters
       _currentWidgetHelper = findOrCreateWidgetHelper(_presManager, presId, presType.toStdString(), presName.toStdString());
-      _currentWidgetHelper->udpateWidget();
+      _currentWidgetHelper->updateWidget(true);
     }
 }
 
@@ -752,7 +752,7 @@ PresentationController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
   else if ( event->type == MEDCALC::EVENT_MODIFY_PRESENTATION ) {
       // Update parameter widget if shown:
       if(_currentWidgetHelper)
-        _currentWidgetHelper->udpateWidget();
+        _currentWidgetHelper->updateWidget(false);
   }
 }
 
index 8d7a3e1be906e779978c5b8e1b211b3d928b5445..601e46d44f34aca07898c17983524b7f9354ab89 100644 (file)
@@ -28,15 +28,15 @@ WidgetPresentationParameters::WidgetPresentationParameters(QWidget* parent)
   _ui.setupUi(this); // To be done first
 
   toggleWidget(false);
-  QObject::connect(_ui.comboBoxCompo,          SIGNAL(currentIndexChanged(int)),
+  QObject::connect(_ui.comboBoxCompo,          SIGNAL(activated(int)),
                    this,                       SLOT(onComboCompoIndexChanged(int)) );
-  QObject::connect(_ui.comboBoxMesh,          SIGNAL(currentIndexChanged(int)),
+  QObject::connect(_ui.comboBoxMesh,          SIGNAL(activated(int)),
                      this,                       SLOT(onComboMeshIndexChanged(int)) );
-  QObject::connect(_ui.comboBoxScalarBarRange, SIGNAL(currentIndexChanged(int)),
+  QObject::connect(_ui.comboBoxScalarBarRange, SIGNAL(activated(int)),
                    this,                       SLOT(onComboScalarBarRangeIndexChanged(int)) );
-  QObject::connect(_ui.comboBoxColorMap,       SIGNAL(currentIndexChanged(int)),
+  QObject::connect(_ui.comboBoxColorMap,       SIGNAL(activated(int)),
                    this,                       SLOT(onComboColorMapIndexChanged(int)) );
-  QObject::connect(_ui.comboBoxSliceOrient,       SIGNAL(currentIndexChanged(int)),
+  QObject::connect(_ui.comboBoxSliceOrient,       SIGNAL(activated(int)),
                    this,                       SLOT(onComboOrientIndexChanged(int)) );
   QObject::connect(_ui.spinBox,                SIGNAL(valueChanged(int)),
                      this,                     SLOT(onSpinBoxValueChanged(int)) );
@@ -96,7 +96,7 @@ WidgetPresentationParameters::toggleWidget(bool show)
 
       _blockSig = true;
       _ui.widgetDynamic->hide();
-      setPresName("Choose a presentation");
+      setPresName(tr("LAB_DEFAULT_DYN_TITLE").toStdString());
       // reset colorMap and scalarBarRange:
       setColorMap(MEDCALC::COLOR_MAP_DEFAULT);
       setScalarBarRange(MEDCALC::SCALAR_BAR_RANGE_DEFAULT);
@@ -135,22 +135,26 @@ WidgetPresentationParameters::getComponent() const
 void
 WidgetPresentationParameters::setComponents(vector<string> compos, int selecIndex)
 {
+  _blockSig = true;
+
   // 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;
 }
 
 void
 WidgetPresentationParameters::setNbContour(int nbContour)
 {
+  _blockSig = true;
+
   if (nbContour <= 0)
     {
       //TODO throw?
@@ -161,15 +165,16 @@ WidgetPresentationParameters::setNbContour(int nbContour)
   _ui.labelSpinBox->setText(tr("LAB_NB_CONTOURS"));
   _ui.labelSpinBox->show();
   _ui.spinBox->show();
-
-  _blockSig = true;
   _ui.spinBox->setValue(nbContour);
+
   _blockSig = false;
 }
 
 void
 WidgetPresentationParameters::setNbSlices(int nbSlices)
 {
+  _blockSig = true;
+
   if (nbSlices <= 0)
     {
       //TODO throw?
@@ -180,9 +185,8 @@ WidgetPresentationParameters::setNbSlices(int nbSlices)
   _ui.labelSpinBox->setText(tr("LAB_NB_SLICES"));
   _ui.labelSpinBox->show();
   _ui.spinBox->show();
-
-  _blockSig = true;
   _ui.spinBox->setValue(nbSlices);
+
   _blockSig = false;
 }
 
@@ -200,6 +204,8 @@ int WidgetPresentationParameters::getNbSlices() const
 void
 WidgetPresentationParameters::setScalarBarRange(MEDCALC::ScalarBarRangeType sbrange)
 {
+  _blockSig = true;
+
   int idx;
   if (sbrange == MEDCALC::SCALAR_BAR_ALL_TIMESTEPS)
     idx = _ui.comboBoxScalarBarRange->findText(tr("LAB_ALL_TIMESTEPS"));
@@ -207,18 +213,18 @@ WidgetPresentationParameters::setScalarBarRange(MEDCALC::ScalarBarRangeType sbra
     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.");
+
+  _blockSig = false;
 }
 
 void
 WidgetPresentationParameters::setColorMap(MEDCALC::ColorMapType colorMap)
 {
+  _blockSig = true;
+
   int idx = -1;
   if (colorMap == MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW)
     idx = _ui.comboBoxColorMap->findText(tr("LAB_BLUE_TO_RED"));
@@ -226,19 +232,18 @@ WidgetPresentationParameters::setColorMap(MEDCALC::ColorMapType colorMap)
     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.");
+
+  _blockSig = false;
 }
 
 void
 WidgetPresentationParameters::setMeshMode(MEDCALC::MeshModeType mode)
 {
+  _blockSig = true;
+
   // Show the widget:
   _ui.labelMeshMode->show();
   _ui.comboBoxMesh->show();
@@ -259,18 +264,18 @@ WidgetPresentationParameters::setMeshMode(MEDCALC::MeshModeType mode)
       idx = -1;
   }
   if (idx >= 0)
-    {
-      _blockSig = true;
       _ui.comboBoxMesh->setCurrentIndex(idx);
-      _blockSig = false;
-    }
   else
     STDLOG("Strange!! No matching found - unable to set mesh mode in GUI.");
+
+  _blockSig = false;
 }
 
 void
 WidgetPresentationParameters::setSliceOrientation(MEDCALC::SliceOrientationType orient)
 {
+  _blockSig = true;
+
   // Show the widget:
   _ui.labelSliceOrient->show();
   _ui.comboBoxSliceOrient->show();
@@ -303,13 +308,11 @@ WidgetPresentationParameters::setSliceOrientation(MEDCALC::SliceOrientationType
       idx = -1;
   }
   if (idx >= 0)
-    {
-      _blockSig = true;
-      _ui.comboBoxSliceOrient->setCurrentIndex(idx);
-      _blockSig = false;
-    }
+    _ui.comboBoxSliceOrient->setCurrentIndex(idx);
   else
     STDLOG("Strange!! No matching found - unable to set slice orientation in GUI.");
+
+  _blockSig = false;
 }
 
 
index 1105b373753ad9b14d01afd7ef22615420e64099..d2671e057f9110bdc93379def7f441903e2a6692 100644 (file)
Binary files a/src/MEDCalc/res/presentations/classic/visu_mesh16.png and b/src/MEDCalc/res/presentations/classic/visu_mesh16.png differ
index 3b3de8b4a828a5534ec47e4613938b1d8bd85be7..a9708fab288ce7e424cc0e631efea8bda0829719 100644 (file)
Binary files a/src/MEDCalc/res/presentations/classic/visu_mesh24.png and b/src/MEDCalc/res/presentations/classic/visu_mesh24.png differ
index 1105b373753ad9b14d01afd7ef22615420e64099..d2671e057f9110bdc93379def7f441903e2a6692 100644 (file)
Binary files a/src/MEDCalc/res/presentations/modern/mesh16.png and b/src/MEDCalc/res/presentations/modern/mesh16.png differ
index 3b3de8b4a828a5534ec47e4613938b1d8bd85be7..a9708fab288ce7e424cc0e631efea8bda0829719 100644 (file)
Binary files a/src/MEDCalc/res/presentations/modern/mesh24.png and b/src/MEDCalc/res/presentations/modern/mesh24.png differ
index e3edd10ba2475b489068267c044325fcd311c6f1..bbfcff31d2d6aefa584d8804ec7ea827b274e3b6 100644 (file)
@@ -32,7 +32,8 @@ source_id = medcalc.LoadDataSource(datafile)
 
 presentation_id = medcalc.MakeSlices(accessField(0), MEDCALC.VIEW_MODE_REPLACE, 
                                      colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW,
-                                     sliceOrientation=MEDCALC.SLICE_NORMAL_TO_Z)  # normal to Z to see something!
+                                     sliceOrientation=MEDCALC.SLICE_NORMAL_TO_Z,  # normal to Z to see something!
+                                     nbSlices=3) 
 sleep(1)
 medcalc.RemovePresentation(presentation_id)
 sleep(1)
index ee461af8a9484f37c35a75f6a9df2dbe44ffb7ff..1f1f0fd9df7063036d696e64afa1e3fac1fd5e04 100644 (file)
@@ -64,7 +64,7 @@ from medpresentation import UpdateVectorField
 from medpresentation import UpdatePointSprite
 #from medpresentation import UpdateDeflectionShape
 
-from medpresentation import SetDefaultScaleFactor, ComputeCellAverageSize, GetDomainCenter
+from medpresentation import SetDefaultScaleFactor, ComputeCellAverageSize, GetDomainCenter, GetSliceOrigins
 
 # Console commands
 import medconsole
index b85d3d442cfe913b66127103d1443e0ae57dfc04..6b23e20bd0258628c5f1a156d7878321c3ef3550 100644 (file)
@@ -270,3 +270,27 @@ def SetDefaultScaleFactor(active=None):
       scalefactor = scaledextent / divisor 
       active.ScaleFactor = scalefactor
       return
+
+def GetSliceOrigins(obj, nbSlices, normal):
+  """
+  Compute all origin points for the position of the slices.
+  @param normal is a list of 3 floats either 0 or 1 indicating the normal vector of the slices
+  """
+  from math import sqrt
+  bb = obj.GetDataInformation().GetBounds()
+  bb = zip(bb[::2], bb[1::2])
+  origin = [x[0] + 0.5*(x[1]-x[0]) for x in bb]
+  deltas = [x[1]-x[0] for x in bb]
+  # Compute extent of slices:
+  l = [normal[i]*deltas[i]**2 for i in range(3)]   # either the X extend, or the XY diagonal, or the XYZ diagonal
+  plus = lambda x,y: x+y
+  extent = sqrt(reduce(plus, l, 0.0))
+  norm = sqrt(reduce(plus, normal, 0.0))
+  normal = [normal[i]/norm for i in range(3)]
+  origins = []
+  step = extent/nbSlices
+  for j in range(nbSlices):
+    orig_j = [origin[i]+normal[i]*(-0.5*extent + step*(0.5+j)) for i in range(3)]
+    origins.append(orig_j)
+  return origins
+