From 66875c12e73f94da0599db5f435ef82c34c44a96 Mon Sep 17 00:00:00 2001 From: rnv Date: Thu, 18 Feb 2021 18:47:28 +0300 Subject: [PATCH] Fix for issue [CEA]: FIELDS: Wrong behaviour of "Displayed component" gui control --- src/MEDCalc/cmp/MEDPresentation.cxx | 39 +++++++++++++++++-- .../dialogs/WidgetPresentationParameters.cxx | 2 +- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/MEDCalc/cmp/MEDPresentation.cxx b/src/MEDCalc/cmp/MEDPresentation.cxx index ff63e90a1..a234c6b83 100644 --- a/src/MEDCalc/cmp/MEDPresentation.cxx +++ b/src/MEDCalc/cmp/MEDPresentation.cxx @@ -653,6 +653,8 @@ MEDPresentation::fillAvailableFieldComponents() if (!(nbCompo > 1 && nbCompo <= 3)) _selectedComponentIndex = 0; + std::map aCompoMap; + std::vector aCompos; for (long i = 0; i(compo, 1)); + aCompos.push_back(compo); + } + else { + if (aCompoMap[compo] == 1) { + for (std::vector::size_type ii = 0; ii != aCompos.size(); ii++) { + // Modify the previous occurrence + if (aCompos[ii] == compo) { + std::ostringstream oss_m; + oss_m << compo << "(" << 1 << ")"; + aCompos[ii] = oss_m.str(); + break; + } + } + std::ostringstream oss_n; + oss_n << compo << "(" << 2 << ")"; + aCompos.push_back(oss_n.str()); + } + else if (aCompoMap[compo] > 1) { + auto val = aCompoMap[compo]; + val++; + std::ostringstream oss_n; + oss_n << compo << "(" << val << ")"; + aCompos.push_back(oss_n.str()); + } + aCompoMap[compo] = aCompoMap[compo]++; + } } + for (std::vector::size_type i = 0; i != aCompos.size(); i++) { + std::ostringstream oss_p; + oss_p << MEDPresentation::PROP_COMPONENT << i; + setStringProperty(oss_p.str(), aCompos[i]); + } + } /** diff --git a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx index e8963edea..503684e3a 100644 --- a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx +++ b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx @@ -129,7 +129,7 @@ WidgetPresentationParameters::isShown() const string WidgetPresentationParameters::getComponent() const { - if (_ui.comboBoxCompo->count() > 1 && _ui.comboBoxCompo->count() <= 3) + if (_ui.comboBoxCompo->count() > 1 && _ui.comboBoxCompo->count() <= 4) if (_ui.comboBoxCompo->currentIndex() == 0) // Euclidean norm return ""; -- 2.39.2