1 // Copyright (C) 2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "WidgetPresentationParameters.hxx"
21 #include <Basics_Utils.hxx>
25 WidgetPresentationParameters::WidgetPresentationParameters(QWidget* parent)
26 : QWidget(parent), _blockSig(false)
28 _ui.setupUi(this); // To be done first
31 QObject::connect(_ui.comboBoxCompo, SIGNAL(currentIndexChanged(int)),
32 this, SLOT(onComboCompoIndexChanged(int)) );
33 QObject::connect(_ui.comboBoxScalarBarRange, SIGNAL(currentIndexChanged(int)),
34 this, SLOT(onComboScalarBarRangeIndexChanged(int)) );
35 QObject::connect(_ui.comboBoxColorMap, SIGNAL(currentIndexChanged(int)),
36 this, SLOT(onComboColorMapIndexChanged(int)) );
40 WidgetPresentationParameters::onComboCompoIndexChanged(int idx)
42 if (!_blockSig) emit comboCompoIndexChanged(idx);
46 WidgetPresentationParameters::onComboColorMapIndexChanged(int idx)
48 if (!_blockSig) emit comboColorMapIndexChanged(idx);
52 WidgetPresentationParameters::onComboScalarBarRangeIndexChanged(int idx)
54 if (!_blockSig) emit comboScalarBarRangeIndexChanged(idx);
59 WidgetPresentationParameters::toggleWidget(bool show)
64 _ui.widgetDynamic->hide();
65 setPresName("Choose a presentation");
66 // reset colorMap and scalarBarRange:
67 setColorMap(MEDCALC::COLOR_MAP_DEFAULT);
68 setScalarBarRange(MEDCALC::SCALAR_BAR_RANGE_DEFAULT);
72 _ui.widgetDynamic->show();
73 // It is the WidgetHelper responsability to re-show the widgets it needs
74 _ui.labelCompo->hide();
75 _ui.comboBoxCompo->hide();
76 _ui.labelSpinBox->hide();
78 _ui.labelSliceOrient->hide();
79 _ui.comboBoxSliceOrient->hide();
85 WidgetPresentationParameters::isShown() const
87 return _ui.widgetDynamic->isVisible();
91 WidgetPresentationParameters::getComponent() const
93 if (_ui.comboBoxCompo->currentIndex() == 0) // Euclidean norm
96 return _ui.comboBoxCompo->currentText().toStdString();
100 WidgetPresentationParameters::setComponents(vector<string> compos, int selecIndex)
103 _ui.labelCompo->show();
104 _ui.comboBoxCompo->show();
107 _ui.comboBoxCompo->clear();
108 _ui.comboBoxCompo->addItem(tr("LAB_EUCLIDEAN_NORM"));
109 for(vector<string>::const_iterator it = compos.begin(); it != compos.end(); ++it)
110 _ui.comboBoxCompo->addItem(QString::fromStdString(*it));
111 _ui.comboBoxCompo->setCurrentIndex(selecIndex);
116 WidgetPresentationParameters::setScalarBarRange(MEDCALC::MEDPresentationScalarBarRange sbrange)
119 if (sbrange == MEDCALC::SCALAR_BAR_ALL_TIMESTEPS)
120 idx = _ui.comboBoxScalarBarRange->findText(tr("LAB_ALL_TIMESTEPS"));
121 else if (sbrange == MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP)
122 idx = _ui.comboBoxScalarBarRange->findText(tr("LAB_CURRENT_TIMESTEP"));
127 _ui.comboBoxScalarBarRange->setCurrentIndex(idx);
131 STDLOG("Strange!! No matching found - unable to set scalar bar range in GUI.");
135 WidgetPresentationParameters::setColorMap(MEDCALC::MEDPresentationColorMap colorMap)
138 if (colorMap == MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW)
139 idx = _ui.comboBoxColorMap->findText(tr("LAB_BLUE_TO_RED"));
140 else if (colorMap == MEDCALC::COLOR_MAP_COOL_TO_WARM)
141 idx = _ui.comboBoxColorMap->findText(tr("LAB_COOL_TO_WARM"));
146 _ui.comboBoxColorMap->setCurrentIndex(idx);
151 STDLOG("Strange!! No matching found - unable to set color map in GUI.");
155 MEDCALC::MEDPresentationScalarBarRange
156 WidgetPresentationParameters::getScalarBarRange() const
158 QString sbrange = _ui.comboBoxScalarBarRange->currentText();
159 if (sbrange == tr("LAB_ALL_TIMESTEPS")) {
160 return MEDCALC::SCALAR_BAR_ALL_TIMESTEPS;
162 else if (sbrange == tr("LAB_CURRENT_TIMESTEP")) {
163 return MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP;
166 STDLOG("Strange!! No matching found - returning SCALAR_BAR_ALL_TIMESTEPS.");
167 return MEDCALC::SCALAR_BAR_ALL_TIMESTEPS;
171 //WidgetPresentationParameters::getScalarBarTimestep() const
173 // return _ui.doubleSpinBoxTimeStep->value();
177 //WidgetPresentationParameters::getScalarBarMinVal() const
179 // return _ui.doubleSpinBoxMinVal->value();
183 //WidgetPresentationParameters::getScalarBarMaxVal() const
185 // return _ui.doubleSpinBoxMaxVal->value();
188 MEDCALC::MEDPresentationColorMap
189 WidgetPresentationParameters::getColorMap() const
191 QString colorMap = _ui.comboBoxColorMap->currentText();
192 if (colorMap == tr("LAB_BLUE_TO_RED")) {
193 return MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW;
195 else if (colorMap == tr("LAB_COOL_TO_WARM")) {
196 return MEDCALC::COLOR_MAP_COOL_TO_WARM;
199 STDLOG("Strange!! No matching color map found - returning blue to red.");
200 return MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW;
204 WidgetPresentationParameters::getComboBoxCompo()
206 return _ui.comboBoxCompo;
210 WidgetPresentationParameters::setPresName(const std::string& name)
212 _ui.labelPresName->setText(QString::fromStdString(name));
213 QFont f(_ui.labelPresName->font());
215 _ui.labelPresName->setFont(f);