Commit b5d19c7f authored by LACROIX Romain's avatar LACROIX Romain

We store the shared fields in the parent class DecoratorWithClut, and remove...

We store the shared fields in the parent class DecoratorWithClut, and remove them from the inheritors.
These fields are: "Display", "Scalar Bar", "Colors", "Fixed Range", "Component".
parent 3b30fc18
......@@ -95,7 +95,6 @@ public:
vtkSmartPointer<vtkActor> curves_actor;
public:
QCheckBox *show_actor_cb = nullptr;
QCheckBox *show_source_actor_cb = nullptr;
public:
......@@ -209,7 +208,6 @@ dtkVisualizationDecoratorVectorCurvedGlyphs::dtkVisualizationDecoratorVectorCurv
//////////
// Inspectors creation and setup
d->show_actor_cb = new QCheckBox;
d->show_source_actor_cb = new QCheckBox;
d->cb_integrator_type = new QComboBox;
......@@ -244,7 +242,7 @@ dtkVisualizationDecoratorVectorCurvedGlyphs::dtkVisualizationDecoratorVectorCurv
//////////
// Inspectors connections
connect(d->show_actor_cb, &QCheckBox::stateChanged, [=] (int state)
connect(d_func()->show_actor_cb, &QCheckBox::stateChanged, [=] (int state)
{
this->saveSettings("visibility",state == Qt::Checked);
this->setVisibility(state == Qt::Checked);
......@@ -292,7 +290,6 @@ dtkVisualizationDecoratorVectorCurvedGlyphs::dtkVisualizationDecoratorVectorCurv
this->setObjectName("Vector Curved Glyphs");
d->show_actor_cb->setObjectName("Display");
d->show_source_actor_cb->setObjectName("Display Source");
d->cb_integrator_type->setObjectName("Integrator Type");
d->sp_integrator_max_steps->setObjectName("Maximum Steps");
......@@ -300,8 +297,7 @@ dtkVisualizationDecoratorVectorCurvedGlyphs::dtkVisualizationDecoratorVectorCurv
d->sp_radius->setObjectName("Tube Radius");
d->sp_resolution->setObjectName("Resolution");
d_func()->inspectors << d->show_actor_cb << d->show_source_actor_cb
<< d_func()->field_components->child()
d_func()->inspectors << d->show_source_actor_cb
<< d->cb_integrator_type << d->sp_integrator_max_steps
<< d->sp_integrator_max_lengths << d->sp_radius << d->sp_resolution;
......@@ -324,9 +320,9 @@ void dtkVisualizationDecoratorVectorCurvedGlyphs::restoreSettings(void)
dtkVisualizationDecoratorWithClut::restoreSettings();
d->arrows_actor->SetVisibility(d_func()->default_visibility);
d->curves_actor->SetVisibility(d_func()->default_visibility);
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setChecked(d_func()->default_visibility);
d->show_actor_cb->blockSignals(false);
d_func()->show_actor_cb->blockSignals(true);
d_func()->show_actor_cb->setChecked(d_func()->default_visibility);
d_func()->show_actor_cb->blockSignals(false);
}
void dtkVisualizationDecoratorVectorCurvedGlyphs::setData(const QVariant& data)
......
......@@ -45,7 +45,6 @@ public:
vtkSmartPointer<vtkGlyph3DMapper> glyphs_mapper;
public:
QCheckBox *show_actor_cb = nullptr;
QComboBox *glyphs_scale_mode_cb = nullptr;
QSpinBox *glyphs_stride_sb = nullptr;
QDoubleSpinBox *glyphs_scale_factor_sb = nullptr;
......@@ -82,7 +81,6 @@ dtkVisualizationDecoratorVectorGlyphs::dtkVisualizationDecoratorVectorGlyphs(voi
//////////
// Inspectors creation
d->show_actor_cb = new QCheckBox;
d->glyphs_scale_mode_cb = new QComboBox;
d->glyphs_stride_sb = new QSpinBox;
d->glyphs_scale_factor_sb = new QDoubleSpinBox;
......@@ -109,7 +107,7 @@ dtkVisualizationDecoratorVectorGlyphs::dtkVisualizationDecoratorVectorGlyphs(voi
//////////
// Inspectors connections
connect(d->show_actor_cb, &QCheckBox::stateChanged, [=] (int state)
connect(d_func()->show_actor_cb, &QCheckBox::stateChanged, [=] (int state)
{
this->saveSettings("visibility", state == Qt::Checked);
this->setVisibility(state == Qt::Checked);
......@@ -137,14 +135,11 @@ dtkVisualizationDecoratorVectorGlyphs::dtkVisualizationDecoratorVectorGlyphs(voi
});
this->setObjectName("Vector Glyphs");
d->show_actor_cb->setObjectName("Display");
d->glyphs_scale_mode_cb->setObjectName("Scaling Mode");
d->glyphs_stride_sb->setObjectName("Every Nth point");
d->glyphs_scale_factor_sb->setObjectName("Scale Factor");
d_func()->inspectors << d->show_actor_cb
<< d_func()->field_components->child()
<< d->glyphs_scale_mode_cb
d_func()->inspectors << d->glyphs_scale_mode_cb
<< d->glyphs_stride_sb
<< d->glyphs_scale_factor_sb;
}
......@@ -167,9 +162,9 @@ void dtkVisualizationDecoratorVectorGlyphs::restoreSettings(void)
dtkVisualizationDecoratorWithClut::restoreSettings();
d->actor->SetVisibility(d_func()->default_visibility);
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setChecked(d_func()->default_visibility);
d->show_actor_cb->blockSignals(false);
d_func()->show_actor_cb->blockSignals(true);
d_func()->show_actor_cb->setChecked(d_func()->default_visibility);
d_func()->show_actor_cb->blockSignals(false);
QSettings settings;
settings.beginGroup("canvas");
......
......@@ -117,7 +117,6 @@ public:
vtkSmartPointer<vtkActor> actor;
public:
QCheckBox *show_actor_cb = nullptr;
dtkVisualizationWidgetsCategoryItem *cb_show_seed = nullptr;
dtkVisualizationWidgetsCategoryItem *cb_seed_type = nullptr;
......@@ -205,8 +204,6 @@ dtkVisualizationDecoratorVectorStreamTracer::dtkVisualizationDecoratorVectorStre
//////////
// Inspectors creation and setup
d->show_actor_cb = new QCheckBox;
QCheckBox *show_seed = new QCheckBox;
d->cb_show_seed = new dtkVisualizationWidgetsCategoryItem("Display", show_seed);
show_seed->setChecked(true);
......@@ -259,7 +256,7 @@ dtkVisualizationDecoratorVectorStreamTracer::dtkVisualizationDecoratorVectorStre
//////////
// Inspectors connections
connect(d->show_actor_cb, &QCheckBox::stateChanged, [=] (int state)
connect(d_func()->show_actor_cb, &QCheckBox::stateChanged, [=] (int state)
{
this->saveSettings("visibility",state == Qt::Checked);
this->setVisibility(state == Qt::Checked);
......@@ -331,8 +328,6 @@ dtkVisualizationDecoratorVectorStreamTracer::dtkVisualizationDecoratorVectorStre
this->setObjectName("Vector Stream Tracer");
d->show_actor_cb->setObjectName("Display");
QWidget *seed_box = new dtkVisualizationWidgetsCategory("Seed", {
d->cb_show_seed,
d->cb_seed_type });
......@@ -342,12 +337,10 @@ dtkVisualizationDecoratorVectorStreamTracer::dtkVisualizationDecoratorVectorStre
d->sp_integrator_max_steps,
d->sp_integrator_max_lengths});
QWidget *styling_box = new dtkVisualizationWidgetsCategory("Styling", {
d_func()->field_components,
d->sp_radius,
d->sp_resolution });
d_func()->inspectors << d->show_actor_cb
<< seed_box
d_func()->inspectors << seed_box
<< integrator_box
<< styling_box;
}
......@@ -368,9 +361,9 @@ void dtkVisualizationDecoratorVectorStreamTracer::restoreSettings(void)
}
dtkVisualizationDecoratorWithClut::restoreSettings();
d->actor->SetVisibility(d_func()->default_visibility);
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setChecked(d_func()->default_visibility);
d->show_actor_cb->blockSignals(false);
d_func()->show_actor_cb->blockSignals(true);
d_func()->show_actor_cb->setChecked(d_func()->default_visibility);
d_func()->show_actor_cb->blockSignals(false);
}
void dtkVisualizationDecoratorVectorStreamTracer::setData(const QVariant& data)
......
......@@ -100,7 +100,6 @@ public:
vtkSmartPointer<vtkActor> actor;
public:
QCheckBox *show_actor_cb = nullptr;
QCheckBox *show_source_actor_cb = nullptr;
QDoubleSpinBox *sp_radius = nullptr;
QDoubleSpinBox *sp_start_pos_x = nullptr;
......@@ -170,7 +169,6 @@ dtkVisualizationDecoratorVectorStreamlines::dtkVisualizationDecoratorVectorStrea
//////////
// Inspectors creation and setup
d->show_actor_cb = new QCheckBox;
d->show_source_actor_cb = new QCheckBox;
d->show_source_actor_cb->setChecked(true);
......@@ -198,7 +196,7 @@ dtkVisualizationDecoratorVectorStreamlines::dtkVisualizationDecoratorVectorStrea
//////////
// Inspectors connections
connect(d->show_actor_cb, &QCheckBox::stateChanged, [=] (int state)
connect(d_func()->show_actor_cb, &QCheckBox::stateChanged, [=] (int state)
{
this->saveSettings("visibility",state == Qt::Checked);
this->setVisibility(state == Qt::Checked);
......@@ -246,13 +244,11 @@ dtkVisualizationDecoratorVectorStreamlines::dtkVisualizationDecoratorVectorStrea
this->setObjectName("Vector Streamlines 2D");
d->show_actor_cb->setObjectName("Display");
d->show_source_actor_cb->setObjectName("Display Source");
d->sp_radius->setObjectName("Tube Radius");
start_pos_widget->setObjectName("Start Position");
d_func()->inspectors << d->show_actor_cb << d->show_source_actor_cb
<< d_func()->field_components->child()
d_func()->inspectors << d->show_source_actor_cb
<< start_pos_widget
<< d->sp_radius;
}
......@@ -273,9 +269,9 @@ void dtkVisualizationDecoratorVectorStreamlines::restoreSettings(void)
return;
dtkVisualizationDecoratorWithClut::restoreSettings();
d->actor->SetVisibility(d_func()->default_visibility);
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setChecked(d_func()->default_visibility);
d->show_actor_cb->blockSignals(false);
d_func()->show_actor_cb->blockSignals(true);
d_func()->show_actor_cb->setChecked(d_func()->default_visibility);
d_func()->show_actor_cb->blockSignals(false);
}
bool dtkVisualizationDecoratorVectorStreamlines::isCurrentFieldUniform(void)
......
......@@ -54,14 +54,14 @@ dtkVisualizationDecoratorWithClutPrivate::dtkVisualizationDecoratorWithClutPriva
this->fields_box = new QComboBox;
QComboBox *cb_components = new QComboBox;
cb_components->addItem("Uniform");
cb_components->addItem("Magnitude");
cb_components->addItem("X");
cb_components->addItem("Y");
cb_components->addItem("W");
cb_components->setCurrentIndex(0);
this->field_components = new dtkVisualizationWidgetsCategoryItem("Coloring", cb_components);
this->field_components = new QComboBox;
this->field_components->addItem("Uniform");
this->field_components->addItem("Magnitude");
this->field_components->addItem("X");
this->field_components->addItem("Y");
this->field_components->addItem("W");
this->field_components->setCurrentIndex(0);
this->field_components->setObjectName("Component"); // to remove
this->fixed_range = new QCheckBox;
this->min_range = new QLineEdit;
......@@ -77,13 +77,14 @@ dtkVisualizationDecoratorWithClutPrivate::dtkVisualizationDecoratorWithClutPriva
//////////
// Inspectors setup
show_actor_cb = new QCheckBox;
QDoubleValidator *double_validator = new QDoubleValidator;
double_validator->setDecimals(9);
this->min_range->setValidator(double_validator);
this->max_range->setValidator(double_validator);
h_layout_range->setAlignment(Qt::AlignLeft);
h_layout_range->addWidget(new QLabel("Fixed Range:"));
h_layout_range->addWidget(this->fixed_range);
h_layout_range->addWidget(this->min_range);
h_layout_range->addWidget(this->max_range);
......@@ -93,12 +94,17 @@ dtkVisualizationDecoratorWithClutPrivate::dtkVisualizationDecoratorWithClutPriva
this->show_scalar_bar->setChecked(false);
this->fields_box->setObjectName("Field");
this->field_components->setObjectName("Coloring");
range_widget->setObjectName("");
this->colormap_editor->setObjectName("Color Map");
this->show_scalar_bar->setObjectName("Scalar Bar");
this->inspectors << this->fields_box << this->colormap_editor << range_widget << this->show_scalar_bar;
this->inspectors
<< this->fields_box
<< new dtkVisualizationWidgetsCategory("Elements", {
new dtkVisualizationWidgetsCategoryItem("Display", this->show_actor_cb),
new dtkVisualizationWidgetsCategoryItem("Scalar Bar", this->show_scalar_bar) } )
<< new dtkVisualizationWidgetsCategory("Colors", {
new dtkVisualizationWidgetsCategoryItem("Color Map", colormap_editor),
new dtkVisualizationWidgetsCategoryItem("Fixed Range", range_widget),
new dtkVisualizationWidgetsCategoryItem("Component", this->field_components) } );
}
void dtkVisualizationDecoratorWithClutPrivate::clear(void)
......@@ -254,7 +260,7 @@ void dtkVisualizationDecoratorWithClutPrivate::updateRange(void)
if (!this->fixed_range->isChecked()) {
// The following trick gives directly the right index value
// to extract in the GetRange method for the vector case.
int component_id = dynamic_cast<QComboBox*>(this->field_components->child())->currentIndex() - 2;
int component_id = this->field_components->currentIndex() - 2;
using Kind = dtkVisualizationDecoratorWithClutPrivate::Kind;
using Support = dtkVisualizationDecoratorWithClutPrivate::Support;
......@@ -312,7 +318,7 @@ void dtkVisualizationDecoratorWithClutPrivate::updateColorTransferFunction(void)
using Kind = dtkVisualizationDecoratorWithClutPrivate::Kind;
// The following trick gives directly the right index value
// to extract in the GetRange method for the vector case.
int component_id = dynamic_cast<QComboBox*>(this->field_components->child())->currentIndex() - 2;
int component_id = this->field_components->currentIndex() - 2;
switch (this->kinds[this->current_field_name]) {
case Kind::Vector:
......@@ -360,7 +366,7 @@ dtkVisualizationDecoratorWithClut::dtkVisualizationDecoratorWithClut(void): dtkV
this->saveSettings("field_name", field_name);
this->touch();
});
connect(dynamic_cast<QComboBox*>(d->field_components->child()), QOverload<int>::of(&QComboBox::currentIndexChanged), [=] (int component_id)
connect(d->field_components, QOverload<int>::of(&QComboBox::currentIndexChanged), [=] (int component_id)
{
d->current_field_component = component_id;
this->saveSettings("field_component", component_id);
......@@ -427,8 +433,8 @@ void dtkVisualizationDecoratorWithClut::restoreSettings(void)
}
d->default_field_component = settings.value(name+"_field_component").toInt();
d->field_components->child()->blockSignals(true);
dynamic_cast<QComboBox*>(d->field_components->child())->setCurrentIndex(d->default_field_component);
d->field_components->blockSignals(true);
d->field_components->setCurrentIndex(d->default_field_component);
d->field_components->blockSignals(false);
d->default_color_map = settings.value(name+"_colormap", "inferno").toString();
......
......@@ -65,11 +65,12 @@ public:
QList<QWidget *> inspectors;
QComboBox *fields_box = nullptr;
dtkVisualizationWidgetsCategoryItem *field_components = nullptr;
QComboBox *field_components = nullptr;
QCheckBox *fixed_range = nullptr;
QLineEdit *min_range = nullptr;
QLineEdit *max_range = nullptr;
QCheckBox *show_scalar_bar = nullptr;
QCheckBox *show_actor_cb = nullptr;
public:
dtkVisualizationWidgetsColorMapEditor *colormap_editor = nullptr;
......
......@@ -20,7 +20,7 @@ QWidget *dtkVisualizationWidgetsCategoryItem::child()
return c;
}
dtkVisualizationWidgetsCategory::dtkVisualizationWidgetsCategory(const QString& name, const QVector<dtkVisualizationWidgetsCategoryItem*>& widgets, QWidget* parent) : QGroupBox(parent)
dtkVisualizationWidgetsCategory::dtkVisualizationWidgetsCategory(const QString& name, const QVector<QWidget*>& widgets, QWidget* parent) : QGroupBox(parent)
{
QLayout *layout = new QVBoxLayout;
layout->setContentsMargins(0,0,0,0);
......
......@@ -19,6 +19,6 @@ private:
class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsCategory : public QGroupBox
{
public:
dtkVisualizationWidgetsCategory(const QString& name, const QVector<dtkVisualizationWidgetsCategoryItem*>& widgets, QWidget* parent = nullptr);
dtkVisualizationWidgetsCategory(const QString& name, const QVector<QWidget*>& widgets, QWidget* parent = nullptr);
};
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