Commit 586559cf authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

restore fixed range settings with min and max values

parent 6b53b50d
......@@ -71,8 +71,6 @@ public:
dtkVisualizationDecoratorPoints::dtkVisualizationDecoratorPoints(void): d(new dtkVisualizationDecoratorPointsPrivate())
{
this->setObjectName("Points");
d->data = vtkSmartPointer<vtkPolyData>::New();
d->filter = vtkSmartPointer<vtkVertexGlyphFilter>::New();
......@@ -109,6 +107,8 @@ dtkVisualizationDecoratorPoints::dtkVisualizationDecoratorPoints(void): d(new dt
d->size_spinbox->setSingleStep(0.01);
d->size_spinbox->setValue(1.);
this->setObjectName("Points");
d->show_actor_cb->setObjectName("Display");
d->show_actor_cb->setChecked(false);
......
......@@ -113,6 +113,7 @@ void dtkVisualizationDecoratorScalarColorMap::setData(const QVariant& data)
return;
}
d_func()->dataset = dataset;
this->restoreSettings();
d->mapper->SetInputData(d_func()->dataset);
d_func()->sortEligibleFields();
......
......@@ -245,6 +245,7 @@ void dtkVisualizationDecoratorScalarGlyphs::setData(const QVariant& data)
}
d_func()->dataset = dataset;
this->restoreSettings();
d->cell_centers->SetInputData(dataset);
......
......@@ -194,6 +194,7 @@ void dtkVisualizationDecoratorScalarIsolines::setData(const QVariant& data)
}
d_func()->dataset = dataset;
this->restoreSettings();
d->c2p_filter->SetInputData(dataset);
......
......@@ -190,6 +190,7 @@ void dtkVisualizationDecoratorVectorStreamlines::setData(const QVariant& data)
}
d_func()->dataset = dataset;
this->restoreSettings();
d->transform_filter->SetInputData(dataset);
......
......@@ -242,6 +242,8 @@ dtkVisualizationDecoratorWithClut::dtkVisualizationDecoratorWithClut(void): dtkV
d->fixed_range->setChecked(Qt::Checked);
d->fixed_range->blockSignals(false);
this->setCurrentRange(d->min_range->text().toDouble(), d->max_range->text().toDouble());
this->saveSettings("range_min", d->min_range->text().toDouble());
this->saveSettings("range_max", d->max_range->text().toDouble());
this->touch();
});
......@@ -250,12 +252,15 @@ dtkVisualizationDecoratorWithClut::dtkVisualizationDecoratorWithClut(void): dtkV
d->fixed_range->setChecked(Qt::Checked);
d->fixed_range->blockSignals(false);
this->setCurrentRange(d->min_range->text().toDouble(), d->max_range->text().toDouble());
this->saveSettings("range_min", d->min_range->text().toDouble());
this->saveSettings("range_max", d->max_range->text().toDouble());
this->touch();
});
// Restores default ranges when unchecked
connect(d->fixed_range, &QCheckBox::stateChanged, [=] (int state) {
this->touch();
this->saveSettings("fixed_range", state == Qt::Checked);
this->draw();
});
......@@ -288,11 +293,22 @@ void dtkVisualizationDecoratorWithClut::restoreSettings(void)
d->default_field_name = settings.value(name+"_field_name").toString();
d->default_color_map = settings.value(name+"_colormap", "inferno").toString();
d->default_show_scalar_bar = settings.value(name+"_show_scalarbar", false).toBool();
double range_min = settings.value(name+"_range_min", -1.).toDouble();
double range_max = settings.value(name+"_range_max", -1.).toDouble();
bool fixed_range = settings.value(name+"_fixed_range", false).toBool();
settings.endGroup();
if (range_min != -1.0 && range_max != -1.0) {
this->setCurrentRange(range_min, range_max);
}
d->fixed_range->setChecked(fixed_range);
d->colormap_editor->blockSignals(true);
d->colormap_editor->setValue(d->default_color_map);
d->colormap_editor->blockSignals(false);
d->show_scalar_bar->blockSignals(true);
d->show_scalar_bar->setChecked(d->default_show_scalar_bar);
d->show_scalar_bar->blockSignals(false);
d->scalar_bar->SetVisibility(d->default_show_scalar_bar);
}
......@@ -378,7 +394,7 @@ bool dtkVisualizationDecoratorWithClut::setCurrentFieldName(const QString& field
void dtkVisualizationDecoratorWithClut::setCurrentRange(double min, double max)
{
if (d->current_field_name.isEmpty()) {
if (d->current_field_name.isEmpty() && d->default_field_name.isEmpty()) {
qWarning() << Q_FUNC_INFO << "Field not selected";
return;
}
......@@ -386,7 +402,9 @@ void dtkVisualizationDecoratorWithClut::setCurrentRange(double min, double max)
qWarning() << Q_FUNC_INFO << " min >= max : " << min << max;
return;
}
auto&& range = d->ranges[d->current_field_name];
QString field_name = d->current_field_name.isEmpty() ? d->default_field_name : d->current_field_name;
qDebug() << Q_FUNC_INFO << field_name;
auto&& range = d->ranges[field_name];
range[0] = min;
range[1] = max;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment