From: abn Date: Thu, 4 Aug 2016 13:10:36 +0000 (+0200) Subject: [MEDCalc] Fix scalar bar title when changing component. X-Git-Tag: V8_1_0b1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=daeb36686dde7ab050ede3cea3f6b6dab7359999;p=modules%2Fmed.git [MEDCalc] Fix scalar bar title when changing component. --- diff --git a/src/MEDCalc/cmp/MEDPresentation.cxx b/src/MEDCalc/cmp/MEDPresentation.cxx index a11077b64..1060819d1 100644 --- a/src/MEDCalc/cmp/MEDPresentation.cxx +++ b/src/MEDCalc/cmp/MEDPresentation.cxx @@ -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 diff --git a/src/MEDCalc/cmp/MEDPresentation.hxx b/src/MEDCalc/cmp/MEDPresentation.hxx index 55999b0e1..dc2e7aeed 100644 --- a/src/MEDCalc/cmp/MEDPresentation.hxx +++ b/src/MEDCalc/cmp/MEDPresentation.hxx @@ -84,6 +84,7 @@ protected: void showScalarBar(); void rescaleTransferFunction(); void selectColorMap(); + void fixScalarBarTitle(); void resetCameraAndRender(); virtual void internalGeneratePipeline(); diff --git a/src/MEDCalc/cmp/MEDPresentation.txx b/src/MEDCalc/cmp/MEDPresentation.txx index 84b4137c4..bb3410b5c 100644 --- a/src/MEDCalc/cmp/MEDPresentation.txx +++ b/src/MEDCalc/cmp/MEDPresentation.txx @@ -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();"); } }