-// Copyright (C) 2016 CEA/DEN, EDF R&D
+// Copyright (C) 2016-2020 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+#ifdef WIN32
+#define NOMINMAX
+#endif
+
#include "WidgetPresentationParameters.hxx"
#include <Basics_Utils.hxx>
_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)) );
+ QObject::connect(_ui.spinBox, SIGNAL(editingFinished()),
+ this, SLOT(onSpinBoxEditingFinished()) );
}
void
}
void
-WidgetPresentationParameters::onSpinBoxValueChanged(int val)
+WidgetPresentationParameters::onSpinBoxEditingFinished()
{
- if (!_blockSig) emit spinBoxValueChanged(val);
+ if (!_blockSig) emit spinBoxValueChanged(_ui.spinBox->value());
}
void
void
WidgetPresentationParameters::toggleWidget(bool show)
{
+ toggleCommonFieldWidget(true);
if (!show)
{
- toggleCommonFieldWidget(true);
-
_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);
else
{
_ui.widgetDynamic->show();
- // It is the WidgetHelper responsability to re-show the widgets it needs
+ // It is the WidgetHelper responsibility to re-show the widgets it needs
_ui.labelCompo->hide();
_ui.comboBoxCompo->hide();
_ui.labelMeshMode->hide();
string
WidgetPresentationParameters::getComponent() const
{
- if (_ui.comboBoxCompo->currentIndex() == 0) // Euclidean norm
+ if (_ui.comboBoxCompo->count() > 1 && _ui.comboBoxCompo->count() <= 3)
+ if (_ui.comboBoxCompo->currentIndex() == 0) // Euclidean norm
return "";
return _ui.comboBoxCompo->currentText().toStdString();
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"));
+ bool vectorField = (compos.size() > 1 && compos.size() <= 3);
+ if (vectorField)
+ _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);
+ if (!vectorField)
+ _ui.comboBoxCompo->setCurrentIndex(std::max(0, selecIndex-1));
+ else
+ _ui.comboBoxCompo->setCurrentIndex(selecIndex);
+
_blockSig = false;
}
void
WidgetPresentationParameters::setNbContour(int nbContour)
{
+ _blockSig = true;
+
if (nbContour <= 0)
{
//TODO throw?
}
// Show the widget:
- _ui.labelSpinBox->setText(tr("LAB_NB_CONTOURS"));
+ _ui.labelSpinBox->setText(tr("LAB_NB_CONTOURS").arg(MEDCALC::NB_CONTOURS_MAX));
+
_ui.labelSpinBox->show();
_ui.spinBox->show();
-
- _blockSig = true;
+ _ui.spinBox->setRange(1, MEDCALC::NB_CONTOURS_MAX);
_ui.spinBox->setValue(nbContour);
+
_blockSig = false;
}
void
WidgetPresentationParameters::setNbSlices(int nbSlices)
{
+ _blockSig = true;
+
if (nbSlices <= 0)
{
//TODO throw?
}
// Show the widget:
- _ui.labelSpinBox->setText(tr("LAB_NB_SLICES"));
+ _ui.labelSpinBox->setText(tr("LAB_NB_SLICES").arg(MEDCALC::NB_SLICES_MAX));
_ui.labelSpinBox->show();
_ui.spinBox->show();
-
- _blockSig = true;
+ _ui.spinBox->setRange(1, MEDCALC::NB_SLICES_MAX);
_ui.spinBox->setValue(nbSlices);
+
_blockSig = false;
}
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"));
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"));
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();
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();
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;
}