Commit 6b53b50d authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

revert to default constructor. use restoreSettings when calling setObjectName

parent 827611ff
......@@ -47,9 +47,11 @@ protected:
void draw(void);
void saveSettings(const QString &, const QVariant&);
protected:
virtual void restoreSettings(void) {};
public:
virtual void setVisibility(bool visible) = 0;
virtual void restoreSettings(void) {};
virtual bool isDecorating(void) = 0;
......
......@@ -73,14 +73,9 @@ public:
// dtkVisualizationDecoratorDelaunay2D implementation
// ///////////////////////////////////////////////////////////////////
dtkVisualizationDecoratorDelaunay2D::dtkVisualizationDecoratorDelaunay2D(const QString& name): d(new dtkVisualizationDecoratorDelaunay2DPrivate())
dtkVisualizationDecoratorDelaunay2D::dtkVisualizationDecoratorDelaunay2D(void): d(new dtkVisualizationDecoratorDelaunay2DPrivate())
{
this->setObjectName(name);
QSettings settings;
settings.beginGroup("canvas");
d->default_visibility = settings.value(name+"_visibility", true).toBool();
settings.endGroup();
this->setObjectName("Delaunay 2D");
d->data = vtkSmartPointer<vtkPolyData>::New();
......@@ -143,6 +138,18 @@ dtkVisualizationDecoratorDelaunay2D::~dtkVisualizationDecoratorDelaunay2D(void)
d = nullptr;
}
void dtkVisualizationDecoratorDelaunay2D::restoreSettings(void)
{
QString name = this->objectName();
if (name.isEmpty())
return;
QSettings settings;
settings.beginGroup("canvas");
d->default_visibility = settings.value(name+"_visibility", true).toBool();
settings.endGroup();
}
void dtkVisualizationDecoratorDelaunay2D::touch(void)
{
if(!this->canvas()) {
......
......@@ -23,7 +23,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorDelaunay2D : public dtkVi
Q_OBJECT
public:
dtkVisualizationDecoratorDelaunay2D(const QString & name = QString("Delaunay 2D"));
dtkVisualizationDecoratorDelaunay2D(void);
~dtkVisualizationDecoratorDelaunay2D(void);
public:
......@@ -52,6 +52,9 @@ public:
signals:
void updated(void);
protected:
void restoreSettings(void) override;
protected:
class dtkVisualizationDecoratorDelaunay2DPrivate *d;
};
......
......@@ -57,27 +57,20 @@ public slots:
// dtkVisualizationDecoratorScalarColorMap implementation
// ///////////////////////////////////////////////////////////////////
dtkVisualizationDecoratorScalarColorMap::dtkVisualizationDecoratorScalarColorMap(const QString& name): dtkVisualizationDecoratorWithClut(name), d(new dtkVisualizationDecoratorScalarColorMapPrivate())
dtkVisualizationDecoratorScalarColorMap::dtkVisualizationDecoratorScalarColorMap(void): dtkVisualizationDecoratorWithClut(), d(new dtkVisualizationDecoratorScalarColorMapPrivate())
{
d->mapper = vtkSmartPointer<vtkDataSetMapper>::New();
d->mapper->SetColorModeToMapScalars();
d->mapper->SetScalarVisibility(true);
d->actor = vtkSmartPointer<vtkActor>::New();
d->actor->SetMapper(d->mapper);
d->actor->SetVisibility(d_func()->default_visibility);
//////////
// Inspectors creation
d->show_actor_cb = new QCheckBox;
//////////
// Inspectors setup
d->show_actor_cb->setChecked(d_func()->default_visibility);
//////////
// Inspectors connections
......@@ -87,9 +80,11 @@ dtkVisualizationDecoratorScalarColorMap::dtkVisualizationDecoratorScalarColorMap
this->draw();
});
this->setObjectName("Scalar ColorMap");
d->show_actor_cb->setObjectName("Display");
d_func()->inspectors << d->show_actor_cb;
}
dtkVisualizationDecoratorScalarColorMap::~dtkVisualizationDecoratorScalarColorMap(void)
......@@ -163,6 +158,17 @@ void dtkVisualizationDecoratorScalarColorMap::setVisibility(bool visible)
dtkVisualizationDecoratorWithClut::setVisibility(visible);
}
void dtkVisualizationDecoratorScalarColorMap::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);
}
bool dtkVisualizationDecoratorScalarColorMap::setCurrentFieldName(const QString& field_name)
{
if (!dtkVisualizationDecoratorWithClut::setCurrentFieldName(field_name)) {
......
......@@ -23,7 +23,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarColorMap : public d
Q_OBJECT
public:
dtkVisualizationDecoratorScalarColorMap(const QString & name = QString("Scalar ColorMap"));
dtkVisualizationDecoratorScalarColorMap(void);
~dtkVisualizationDecoratorScalarColorMap(void);
public:
......@@ -34,6 +34,7 @@ public:
protected:
bool setCurrentFieldName(const QString&) override;
void setColorMap(const QMap<double, QColor>&) override;
void restoreSettings(void);
public:
void setVisibility(bool) override;
......
......@@ -82,11 +82,8 @@ public:
// dtkVisualizationDecoratorScalarGlyphs implementation
// ///////////////////////////////////////////////////////////////////
dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(const QString& name): dtkVisualizationDecoratorWithClut(name), d(new dtkVisualizationDecoratorScalarGlyphsPrivate())
dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(void): dtkVisualizationDecoratorWithClut(), d(new dtkVisualizationDecoratorScalarGlyphsPrivate())
{
this->restoreSettings();
d->source_arrow = vtkSmartPointer<vtkArrowSource>::New();
d->source_cube = vtkSmartPointer<vtkCubeSource>::New();
d->source_cylinder = vtkSmartPointer<vtkCylinderSource>::New();
......@@ -120,7 +117,6 @@ dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(con
d->actor = vtkSmartPointer<vtkActor>::New();
d->actor->SetMapper(d->mapper);
d->actor->SetVisibility(d_func()->default_visibility);
//////////
// Inspectors creation
......@@ -132,8 +128,6 @@ dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(con
//////////
// Inspectors setup
d->show_actor_cb->setChecked(d_func()->default_visibility);
d->glyphs_size_sb->setMaximum(1000);
d->glyphs_size_sb->setKeyboardTracking(false);
......@@ -185,6 +179,7 @@ dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(con
this->draw();
});
this->setObjectName("Scalar Glyphs");
d->show_actor_cb->setObjectName("Display");
d->glyphs_size_sb->setObjectName("Glyphs Size");
d->glyphs_source_cb->setObjectName("Source Shape");
......@@ -206,11 +201,18 @@ void dtkVisualizationDecoratorScalarGlyphs::restoreSettings(void)
if (name.isEmpty())
return;
dtkVisualizationDecoratorWithClut::restoreSettings();
QSettings settings;
settings.beginGroup("canvas");
d->default_glyph_size = settings.value(name+"_glyph_size", 1.0).toDouble();
d->default_glyph_shape = settings.value(name+"_glyph_shape", "Sphere").toString();
settings.endGroup();
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);
}
void dtkVisualizationDecoratorScalarGlyphs::setData(const QVariant& data)
......
......@@ -23,7 +23,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarGlyphs : public dtk
Q_OBJECT
public:
dtkVisualizationDecoratorScalarGlyphs(const QString & name = QString("Scalar Glyphs"));
dtkVisualizationDecoratorScalarGlyphs(void);
~dtkVisualizationDecoratorScalarGlyphs(void);
public:
......
......@@ -54,6 +54,9 @@ public:
vtkSmartPointer<vtkContourFilter> isolines;
vtkSmartPointer<vtkCellDataToPointData> c2p_filter;
public:
int default_isolines_count = 10;
public:
QCheckBox *show_actor_cb = nullptr;
QSpinBox *isolines_counts_sb = nullptr;
......@@ -66,9 +69,8 @@ public:
// dtkVisualizationDecoratorScalarIsolines implementation
// ///////////////////////////////////////////////////////////////////
dtkVisualizationDecoratorScalarIsolines::dtkVisualizationDecoratorScalarIsolines(const QString& name): dtkVisualizationDecoratorWithClut(name), d(new dtkVisualizationDecoratorScalarIsolinesPrivate())
dtkVisualizationDecoratorScalarIsolines::dtkVisualizationDecoratorScalarIsolines(void): dtkVisualizationDecoratorWithClut(), d(new dtkVisualizationDecoratorScalarIsolinesPrivate())
{
d->isolines = vtkSmartPointer<vtkContourFilter>::New();
d->c2p_filter = vtkSmartPointer<vtkCellDataToPointData>::New();
......@@ -87,8 +89,6 @@ dtkVisualizationDecoratorScalarIsolines::dtkVisualizationDecoratorScalarIsolines
d->show_actor_cb = new QCheckBox;
d->isolines_counts_sb = new QSpinBox;
d->show_actor_cb->setChecked(d_func()->default_visibility);
d->isolines_counts_sb->setValue(10);
d->isolines_counts_sb->setMaximum(10000);
......@@ -102,16 +102,16 @@ dtkVisualizationDecoratorScalarIsolines::dtkVisualizationDecoratorScalarIsolines
});
connect(d->isolines_counts_sb, QOverload<int>::of(&QSpinBox::valueChanged), [=] (int value) {
this->saveSettings("isolines_count", value);
this->setCurrentIsolinesCount(value);
this->draw();
});
this->setObjectName("Scalar Isolines");
d->show_actor_cb->setObjectName("Display");
d->isolines_counts_sb->setObjectName("Count");
d_func()->inspectors << d->show_actor_cb << d->isolines_counts_sb;
this->setVisibility(d_func()->default_visibility);
}
dtkVisualizationDecoratorScalarIsolines::~dtkVisualizationDecoratorScalarIsolines(void)
......@@ -122,6 +122,34 @@ dtkVisualizationDecoratorScalarIsolines::~dtkVisualizationDecoratorScalarIsoline
d = nullptr;
}
void dtkVisualizationDecoratorScalarIsolines::restoreSettings(void)
{
QString name = this->objectName();
if (name.isEmpty())
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->actor->SetVisibility(d_func()->default_visibility);
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setCheckState(d_func()->default_visibility ? Qt::Checked : Qt::Unchecked);
d->show_actor_cb->blockSignals(false);
QSettings settings;
settings.beginGroup("canvas");
d->default_isolines_count = settings.value(name+"_isolines_count", 10).toInt();
settings.endGroup();
this->setCurrentIsolinesCount(d->default_isolines_count);
this->touch();
this->draw();
}
void dtkVisualizationDecoratorScalarIsolines::touch(void)
{
dtkVisualizationDecoratorWithClut::touch();
......@@ -171,7 +199,7 @@ void dtkVisualizationDecoratorScalarIsolines::setData(const QVariant& data)
d->isolines_counts.clear();
for (auto field_name : d_func()->eligible_field_names) {
d->isolines_counts[field_name] = 10;
d->isolines_counts[field_name] = d->default_isolines_count;
}
d->isolines->Modified();
......@@ -220,9 +248,6 @@ void dtkVisualizationDecoratorScalarIsolines::setVisibility(bool b)
dtkVisualizationDecoratorWithClut::setVisibility(b);
d->actor->SetVisibility(b);
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setCheckState(b ? Qt::Checked : Qt::Unchecked);
d->show_actor_cb->blockSignals(false);
}
void dtkVisualizationDecoratorScalarIsolines::setCurrentRange(double min, double max)
......@@ -243,7 +268,9 @@ void dtkVisualizationDecoratorScalarIsolines::setCurrentIsolinesCount(std::size_
{
QString& field_name = d_func()->current_field_name;
if (field_name.isEmpty()) {
return;
if (d_func()->default_field_name.isEmpty())
return;
field_name = d_func()->default_field_name;
}
d->isolines_counts[field_name] = count;
......
......@@ -22,7 +22,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarIsolines : public d
{
Q_OBJECT
public:
dtkVisualizationDecoratorScalarIsolines(const QString & name = QString("Scalar Isolines"));
dtkVisualizationDecoratorScalarIsolines(void);
~dtkVisualizationDecoratorScalarIsolines(void);
public:
......@@ -34,6 +34,7 @@ public:
void unsetCanvas(void) override;
protected:
void restoreSettings(void) override;
void setCurrentRange(double, double) override;
bool setCurrentFieldName(const QString&) override;
void setColorMap(const QMap<double, QColor>&) override;
......
......@@ -79,9 +79,8 @@ public:
// dtkVisualizationDecoratorVectorStreamlines implementation
// ///////////////////////////////////////////////////////////////////
dtkVisualizationDecoratorVectorStreamlines::dtkVisualizationDecoratorVectorStreamlines(const QString& name): dtkVisualizationDecoratorWithClut(name), d(new dtkVisualizationDecoratorVectorStreamlinesPrivate())
dtkVisualizationDecoratorVectorStreamlines::dtkVisualizationDecoratorVectorStreamlines(void): dtkVisualizationDecoratorWithClut(), d(new dtkVisualizationDecoratorVectorStreamlinesPrivate())
{
vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New();
matrix->Identity();
matrix->SetElement(2, 2, 0.);
......@@ -104,7 +103,6 @@ dtkVisualizationDecoratorVectorStreamlines::dtkVisualizationDecoratorVectorStrea
d->actor = vtkSmartPointer<vtkActor>::New();
d->actor->SetMapper(d->mapper);
d->actor->SetVisibility(d_func()->default_visibility);
d->actor->GetProperty()->SetColor(0, 0, 0);
d->actor->GetProperty()->SetLineWidth(3);
......@@ -124,8 +122,7 @@ dtkVisualizationDecoratorVectorStreamlines::dtkVisualizationDecoratorVectorStrea
d->show_actor_cb = new QCheckBox;
d->show_source_actor_cb = new QCheckBox;
d->show_actor_cb->setChecked(d_func()->default_visibility);
d->show_source_actor_cb->setChecked(d_func()->default_visibility);
d->show_source_actor_cb->setChecked(true);
//////////
// Inspectors connections
......@@ -138,17 +135,11 @@ dtkVisualizationDecoratorVectorStreamlines::dtkVisualizationDecoratorVectorStrea
connect(d->show_source_actor_cb, &QCheckBox::stateChanged, [=] (int state) {
d->source_actor->SetVisibility(state == Qt::Checked);
this->draw();
// FIXME: is it ok to replace this by draw() ?
// if (this->canvas() && this->canvas()->interactor()) {
// this->canvas()->interactor()->Render();
// this->canvas()->renderer()->GetRenderWindow()->Render();
// }
});
this->setObjectName("Vector Streamlines 2D");
d->show_actor_cb->setObjectName("Display");
d->show_source_actor_cb->setObjectName("Display Source");
d_func()->inspectors << d->show_actor_cb << d->show_source_actor_cb;
......@@ -162,6 +153,15 @@ dtkVisualizationDecoratorVectorStreamlines::~dtkVisualizationDecoratorVectorStre
d = nullptr;
}
void dtkVisualizationDecoratorVectorStreamlines::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);
}
bool dtkVisualizationDecoratorVectorStreamlines::isCurrentFieldUniform(void)
{
auto r = d_func()->ranges[d_func()->current_field_name];
......
......@@ -22,7 +22,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorVectorStreamlines : publi
{
Q_OBJECT
public:
dtkVisualizationDecoratorVectorStreamlines(const QString &name = QString("Vector Streamlines 2D"));
dtkVisualizationDecoratorVectorStreamlines(void);
~dtkVisualizationDecoratorVectorStreamlines(void);
public:
......@@ -31,6 +31,7 @@ public:
void unsetCanvas(void) override;
protected:
void restoreSettings(void) override;
bool setCurrentFieldName(const QString&) override;
void setColorMap(const QMap<double, QColor>&) override;
......
......@@ -224,11 +224,8 @@ void dtkVisualizationDecoratorWithClutPrivate::sortEligibleFields(void)
// dtkVisualizationDecoratorWithClut implementation
// ///////////////////////////////////////////////////////////////////
dtkVisualizationDecoratorWithClut::dtkVisualizationDecoratorWithClut(const QString& name): dtkVisualizationDecorator(), d(new dtkVisualizationDecoratorWithClutPrivate)
dtkVisualizationDecoratorWithClut::dtkVisualizationDecoratorWithClut(void): dtkVisualizationDecorator(), d(new dtkVisualizationDecoratorWithClutPrivate)
{
this->setObjectName(name);
this->restoreSettings();
//////////
// Inspectors connections
......@@ -293,7 +290,9 @@ void dtkVisualizationDecoratorWithClut::restoreSettings(void)
d->default_show_scalar_bar = settings.value(name+"_show_scalarbar", false).toBool();
settings.endGroup();
d->colormap_editor->blockSignals(true);
d->colormap_editor->setValue(d->default_color_map);
d->colormap_editor->blockSignals(false);
d->scalar_bar->SetVisibility(d->default_show_scalar_bar);
}
......
......@@ -36,7 +36,7 @@ public:
};
public:
dtkVisualizationDecoratorWithClut(const QString & name = QString());
dtkVisualizationDecoratorWithClut(void);
~dtkVisualizationDecoratorWithClut(void);
public:
......@@ -52,9 +52,9 @@ public:
public:
virtual void setVisibility(bool visible);
void restoreSettings(void) override;
protected:
virtual void restoreSettings(void) override;
virtual void setCurrentRange(double, double);
virtual bool setCurrentFieldName(const QString&);
virtual void setColorMap(const QMap<double, QColor>&);
......
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