]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
[MEDCalc] Fix scalar bar title when changing component.
authorabn <adrien.bruneton@cea.fr>
Thu, 4 Aug 2016 13:10:36 +0000 (15:10 +0200)
committerabn <adrien.bruneton@cea.fr>
Thu, 4 Aug 2016 13:10:36 +0000 (15:10 +0200)
src/MEDCalc/cmp/MEDPresentation.cxx
src/MEDCalc/cmp/MEDPresentation.hxx
src/MEDCalc/cmp/MEDPresentation.txx

index a11077b64108d0ae80aa25e376bf4916e343a4e2..1060819d17f5d8291e5ddd5c19cc56ef2fcf0819 100644 (file)
@@ -317,6 +317,25 @@ MEDPresentation::selectFieldComponent()
     }
 }
 
+/**
+ * Needs the LUT, so to be called after selectColorMap for the first time.
+ */
+void
+MEDPresentation::fixScalarBarTitle()
+{
+  // get selected component name:
+  std::string compoName("Magnitude");
+  if (_selectedComponentIndex != -1)
+    {
+      std::ostringstream oss1;
+      oss1 << MEDPresentation::PROP_COMPONENT << _selectedComponentIndex;
+      compoName = getStringProperty(oss1.str());
+    }
+  std::ostringstream oss;
+  oss << "pvs.GetScalarBar(" << _lutVar << ").ComponentTitle = '" << compoName << "';";
+  pushAndExecPyLine(oss.str()); oss.str("");
+}
+
 void
 MEDPresentation::selectColorMap()
 {
@@ -366,20 +385,20 @@ MEDPresentation::colorBy(const std::string & fieldType)
 void
 MEDPresentation::rescaleTransferFunction()
 {
-  std::string ret;
+  std::ostringstream oss;
   switch(_sbRange)
   {
     case MEDCALC::SCALAR_BAR_ALL_TIMESTEPS:
-      ret = _dispVar + ".RescaleTransferFunctionToDataRangeOverTime();";
+      oss << _dispVar << ".RescaleTransferFunctionToDataRangeOverTime();";
       break;
     case MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP:
-      ret = _dispVar + ".RescaleTransferFunctionToDataRange(False);";
+      oss << _dispVar << ".RescaleTransferFunctionToDataRange(False);";
       break;
     default:
       STDLOG("MEDPresentation::getRescaleCommand(): invalid range!");
       throw KERNEL::createSalomeException("MEDPresentation::getRescaleCommand(): invalid range!");
   }
-  pushAndExecPyLine(ret);
+  pushAndExecPyLine(oss.str()); oss.str("");
 }
 
 int
index 55999b0e1fbd4f1d45e727fa6d4d46db16263a25..dc2e7aeeddfe316808a67da4527ebef08f52d5de 100644 (file)
@@ -84,6 +84,7 @@ protected:
   void showScalarBar();
   void rescaleTransferFunction();
   void selectColorMap();
+  void fixScalarBarTitle();
   void resetCameraAndRender();
 
   virtual void internalGeneratePipeline();
index 84b4137c4b55dee3d2421171cd294594dc0f6979..bb3410b5c902d7b1ac17cbaccbd91cd8c4a41d85 100644 (file)
@@ -92,6 +92,7 @@ MEDPresentation::updateComponent(const std::string& newCompo)
     selectFieldComponent();
     // The component has changed, we need to rescale the scalar bar to adapt:
     rescaleTransferFunction();
+    fixScalarBarTitle();   // should be fixed in PV one day!
     pushAndExecPyLine("pvs.Render();");
   }
 }