Commit 46be2fe3 authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud

Polish stuffs.

parent a70b150f
......@@ -119,11 +119,9 @@ dtkVisualizationDecoratorDelaunay2D::dtkVisualizationDecoratorDelaunay2D(void):
connect(d->opacity_spinbox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &dtkVisualizationDecoratorDelaunay2D::setOpacity);
connect(d->show_actor_cb, &QCheckBox::stateChanged, [=] (int state) {
if (state == Qt::Checked) {
this->show();
} else {
this->hide();
}
this->setVisibility(state == Qt::Checked);
this->touch();
this->draw();
});
d->inspectors << d->color_button << d->opacity_spinbox << d->show_actor_cb;
......@@ -143,8 +141,6 @@ void dtkVisualizationDecoratorDelaunay2D::touch(void)
dtkWarn() << Q_FUNC_INFO << "No canvas was set, call setCanvas to call draw on a canvas.";
return;
}
this->draw();
}
......@@ -202,39 +198,25 @@ void dtkVisualizationDecoratorDelaunay2D::unsetCanvas(void)
d->view = nullptr;
}
void dtkVisualizationDecoratorDelaunay2D::show(void)
void dtkVisualizationDecoratorDelaunay2D::setVisibility(bool b)
{
d->actor->SetVisibility(true);
d->actor->SetVisibility(b);
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setCheckState(Qt::Checked);
d->show_actor_cb->setCheckState(b ? Qt::Checked : Qt::Unchecked);
d->show_actor_cb->blockSignals(false);
this->draw();
}
void dtkVisualizationDecoratorDelaunay2D::hide(void)
{
d->actor->SetVisibility(false);
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setCheckState(Qt::Unchecked);
d->show_actor_cb->blockSignals(false);
this->draw();
}
void dtkVisualizationDecoratorDelaunay2D::setColor(const QColor& color)
{
d->actor->GetProperty()->SetColor(color.red(), color.green(), color.blue());
this->draw();
}
void dtkVisualizationDecoratorDelaunay2D::setOpacity(const double& alpha)
{
d->actor->GetProperty()->SetOpacity(alpha);
d->opacity_spinbox->blockSignals(true);
d->opacity_spinbox->setValue(alpha);
d->opacity_spinbox->blockSignals(false);
......
......@@ -26,12 +26,15 @@ public:
dtkVisualizationDecoratorDelaunay2D(void);
~dtkVisualizationDecoratorDelaunay2D(void);
public:
void touch(void) override;
public:
bool isDecorating(void) override;
void setData(const QVariant&) override;
void setData(const QVariant&) override;
void setCanvas(dtkVisualizationCanvas *) override;
void unsetCanvas(void) override;
void unsetCanvas(void) override;
QVariant data(void) const override;
dtkVisualizationCanvas *canvas(void) const override;
......@@ -39,17 +42,12 @@ public:
QList<QWidget *> inspectors(void) const override;
public:
void show(void);
void hide(void);
void setVisibility(bool);
public:
virtual void setColor(const QColor&);
virtual void setOpacity(const double&);
public:
void touch(void) override;
signals:
void updated(void);
......
......@@ -159,6 +159,11 @@ dtkVisualizationDecoratorInfo::~dtkVisualizationDecoratorInfo(void)
d = nullptr;
}
void dtkVisualizationDecoratorInfo::touch(void)
{
}
bool dtkVisualizationDecoratorInfo::isDecorating(void)
{
return d->dataset;
......@@ -222,11 +227,6 @@ void dtkVisualizationDecoratorInfo::setInformation(const QString& key, QWidget *
d->layout->addRow(key, value);
}
void dtkVisualizationDecoratorInfo::touch(void)
{
}
void dtkVisualizationDecoratorInfo::unsetCanvas(void)
{
d->view = nullptr;
......
......@@ -26,6 +26,9 @@ public:
dtkVisualizationDecoratorInfo(void);
~dtkVisualizationDecoratorInfo(void);
public:
void touch(void) override;
public:
void setFileInfo(const QFileInfo& f_info);
void setInformation(const QString& key, const QString& value, const QString& tooltip = QString());
......@@ -43,8 +46,6 @@ public:
QList<QWidget *> inspectors(void) const override;
void touch(void) override;
protected:
class dtkVisualizationDecoratorInfoPrivate *d;
};
......
......@@ -127,11 +127,9 @@ dtkVisualizationDecoratorPoints::dtkVisualizationDecoratorPoints(void): d(new dt
connect(d->size_spinbox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &dtkVisualizationDecoratorPoints::setSize);
connect(d->show_actor_cb, &QCheckBox::stateChanged, [=] (int state) {
if (state == Qt::Checked) {
this->show();
} else {
this->hide();
}
this->setVisibility(state == Qt::Checked);
this->touch();
this->draw();
});
d->inspectors << d->color_button << d->opacity_spinbox << d->size_spinbox << d->show_actor_cb;
......@@ -151,12 +149,6 @@ void dtkVisualizationDecoratorPoints::touch(void)
dtkWarn() << Q_FUNC_INFO << "No canvas was set, call setCanvas to call draw on a canvas.";
return;
}
Q_ASSERT(this->canvas()->renderer());
if (this->canvas()->interactor()) {
this->canvas()->interactor()->Render();
}
}
bool dtkVisualizationDecoratorPoints::isDecorating(void)
......@@ -188,9 +180,6 @@ void dtkVisualizationDecoratorPoints::setData(const QVariant& data)
if(this->canvas()) {
this->canvas()->renderer()->AddActor(d->actor);
if (this->canvas()->interactor()) {
this->canvas()->interactor()->Render();
}
}
}
......@@ -221,42 +210,19 @@ void dtkVisualizationDecoratorPoints::unsetCanvas(void)
d->view = nullptr;
}
void dtkVisualizationDecoratorPoints::show(void)
void dtkVisualizationDecoratorPoints::setVisibility(bool b)
{
d->actor->SetVisibility(true);
d->actor->SetVisibility(b);
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setCheckState(Qt::Checked);
d->show_actor_cb->setCheckState(b ? Qt::Checked : Qt::Unchecked);
d->show_actor_cb->blockSignals(false);
if (this->canvas() && this->canvas()->interactor()) {
this->canvas()->interactor()->Render();
this->canvas()->renderer()->GetRenderWindow()->Render();
}
}
void dtkVisualizationDecoratorPoints::hide(void)
{
d->actor->SetVisibility(false);
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setCheckState(Qt::Unchecked);
d->show_actor_cb->blockSignals(false);
if (this->canvas() && this->canvas()->interactor()) {
this->canvas()->interactor()->Render();
this->canvas()->renderer()->GetRenderWindow()->Render();
}
}
void dtkVisualizationDecoratorPoints::setColor(const QColor& color)
{
d->actor->GetProperty()->SetColor(color.red(), color.green(), color.blue());
if (this->canvas() && this->canvas()->interactor()) {
this->canvas()->interactor()->Render();
this->canvas()->renderer()->GetRenderWindow()->Render();
}
this->draw();
}
void dtkVisualizationDecoratorPoints::setOpacity(const double& alpha)
......@@ -267,10 +233,7 @@ void dtkVisualizationDecoratorPoints::setOpacity(const double& alpha)
d->opacity_spinbox->setValue(alpha);
d->opacity_spinbox->blockSignals(false);
if (this->canvas() && this->canvas()->interactor()) {
this->canvas()->interactor()->Render();
this->canvas()->renderer()->GetRenderWindow()->Render();
}
this->draw();
}
void dtkVisualizationDecoratorPoints::setSize(const double& size)
......@@ -281,10 +244,7 @@ void dtkVisualizationDecoratorPoints::setSize(const double& size)
d->size_spinbox->setValue(size);
d->size_spinbox->blockSignals(false);
if (this->canvas() && this->canvas()->interactor()) {
this->canvas()->interactor()->Render();
this->canvas()->renderer()->GetRenderWindow()->Render();
}
this->draw();
}
QVariant dtkVisualizationDecoratorPoints::data(void) const
......
......@@ -26,6 +26,9 @@ public:
dtkVisualizationDecoratorPoints(void);
~dtkVisualizationDecoratorPoints(void);
public:
void touch(void) override;
public:
bool isDecorating(void) override;
......@@ -38,11 +41,8 @@ public:
QList<QWidget *> inspectors(void) const override;
void touch(void) override;
public:
void show(void);
void hide(void);
void setVisibility(bool);
public:
virtual void setColor(const QColor&);
......
......@@ -100,6 +100,12 @@ dtkVisualizationDecoratorScalarColorMap::~dtkVisualizationDecoratorScalarColorMa
d = nullptr;
}
void dtkVisualizationDecoratorScalarColorMap::touch(void)
{
dtkVisualizationDecoratorWithClut::touch();
}
void dtkVisualizationDecoratorScalarColorMap::setData(const QVariant& data)
{
vtkDataSet *dataset = data.value<vtkDataSet *>();
......
......@@ -26,6 +26,9 @@ public:
dtkVisualizationDecoratorScalarColorMap(void);
~dtkVisualizationDecoratorScalarColorMap(void);
public:
void touch(void) override;
public:
void setData(const QVariant&) override;
void setCanvas(dtkVisualizationCanvas *) override;
......
......@@ -196,6 +196,11 @@ dtkVisualizationDecoratorScalarGlyphs::~dtkVisualizationDecoratorScalarGlyphs(vo
d = nullptr;
}
void dtkVisualizationDecoratorScalarGlyphs::touch(void)
{
dtkVisualizationDecoratorWithClut::touch();
}
void dtkVisualizationDecoratorScalarGlyphs::setData(const QVariant& data)
{
vtkDataSet *dataset = data.value<vtkDataSet *>();
......
......@@ -26,6 +26,9 @@ public:
dtkVisualizationDecoratorScalarGlyphs(void);
~dtkVisualizationDecoratorScalarGlyphs(void);
public:
void touch(void) override;
public:
void setData(const QVariant&) override;
void setCanvas(dtkVisualizationCanvas *) override;
......
......@@ -98,11 +98,13 @@ dtkVisualizationDecoratorScalarIsolines::dtkVisualizationDecoratorScalarIsolines
connect(d->show_actor_cb, &QCheckBox::stateChanged, [=] (int state) {
this->setVisibility(state == Qt::Checked);
this->touch();
this->draw();
});
connect(d->isolines_counts_sb, QOverload<int>::of(&QSpinBox::valueChanged), [=] (int value) {
this->setCurrentIsolinesCount(value);
this->touch();
this->draw();
});
......@@ -246,8 +248,6 @@ void dtkVisualizationDecoratorScalarIsolines::setCurrentIsolinesCount(std::size_
return;
}
d->isolines_counts[field_name] = count;
this->touch();
}
bool dtkVisualizationDecoratorScalarIsolines::setCurrentFieldName(const QString& field_name)
......
......@@ -28,14 +28,15 @@ public:
dtkVisualizationDecoratorSnapshot(void);
~dtkVisualizationDecoratorSnapshot(void);
public:
void touch(void) override;
public:
bool isDecorating(void) override;
QList<QWidget *> inspectors(void) const override;
QVariant data(void) const override;
dtkVisualizationCanvas *canvas(void) const override;
void touch(void) override;
public:
void setData(const QVariant&) override;
void setCanvas(dtkVisualizationCanvas *) override;
......
......@@ -132,11 +132,9 @@ dtkVisualizationDecoratorVectorStreamlines::dtkVisualizationDecoratorVectorStrea
// Inspectors connections
connect(d->show_actor_cb, &QCheckBox::stateChanged, [=] (int state) {
if (state == Qt::Checked) {
this->show();
} else {
this->hide();
}
this->setVisibility(state == Qt::Checked);
this->touch();
this->draw();
});
connect(d->show_source_actor_cb, &QCheckBox::stateChanged, [=] (int state) {
......@@ -163,6 +161,11 @@ dtkVisualizationDecoratorVectorStreamlines::~dtkVisualizationDecoratorVectorStre
d = nullptr;
}
void dtkVisualizationDecoratorVectorStreamlines::touch(void)
{
dtkVisualizationDecoratorWithClut::touch();
}
bool dtkVisualizationDecoratorVectorStreamlines::isCurrentFieldUniform(void)
{
auto r = d_func()->ranges[d_func()->current_field_name];
......@@ -250,16 +253,14 @@ void dtkVisualizationDecoratorVectorStreamlines::unsetCanvas(void)
d_func()->view = nullptr;
}
void dtkVisualizationDecoratorVectorStreamlines::show(void)
void dtkVisualizationDecoratorVectorStreamlines::setVisibility(bool b)
{
d->actor->SetVisibility(true);
this->draw();
}
dtkVisualizationDecoratorWithClut::setVisibility(b);
d->actor->SetVisibility(b);
void dtkVisualizationDecoratorVectorStreamlines::hide(void)
{
d->actor->SetVisibility(false);
this->draw();
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setCheckState(b ? Qt::Checked : Qt::Unchecked);
d->show_actor_cb->blockSignals(false);
}
bool dtkVisualizationDecoratorVectorStreamlines::setCurrentFieldName(const QString& field_name)
......@@ -290,12 +291,11 @@ bool dtkVisualizationDecoratorVectorStreamlines::setCurrentFieldName(const QStri
using Support = dtkVisualizationDecoratorWithClut::Support;
int support = d_func()->supports[field_name];
if(support == Support::Point) {
d_func()->dataset->GetPointData()->SetActiveVectors(qPrintable(d_func()->current_field_name));
d->streamlines->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, qPrintable(field_name));
} else if(support == Support::Cell) {
d_func()->dataset->GetCellData()->SetActiveVectors(qPrintable(d_func()->current_field_name));
d->streamlines->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, qPrintable(field_name));
}
d->streamlines->Modified();
return dtkVisualizationDecoratorWithClut::setCurrentFieldName(field_name);
}
......
......@@ -25,6 +25,9 @@ public:
dtkVisualizationDecoratorVectorStreamlines(void);
~dtkVisualizationDecoratorVectorStreamlines(void);
public:
void touch(void) override;
public:
void setData(const QVariant&) override;
void setCanvas(dtkVisualizationCanvas *) override;
......@@ -35,8 +38,7 @@ protected:
void setColorMap(const QMap<double, QColor>&) override;
public:
void show(void);
void hide(void);
void setVisibility(bool) override;
protected:
bool isCurrentFieldUniform(void);
......
......@@ -231,7 +231,7 @@ dtkVisualizationDecoratorWithClut::dtkVisualizationDecoratorWithClut(void): dtkV
d->fields_box->blockSignals(true);
this->setCurrentFieldName(field_name);
d->fields_box->blockSignals(false);
this->touch();
this->draw();
});
connect(d->min_range, &QLineEdit::editingFinished, [=] () {
......@@ -239,7 +239,7 @@ 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->touch();
this->draw();
});
connect(d->max_range, &QLineEdit::editingFinished, [=] () {
......@@ -247,7 +247,7 @@ 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->touch();
this->draw();
});
// Restores default ranges when unchecked
......@@ -267,6 +267,7 @@ dtkVisualizationDecoratorWithClut::dtkVisualizationDecoratorWithClut(void): dtkV
connect(d->show_scalar_bar, &QCheckBox::stateChanged, [=] (int state) {
d->scalar_bar->SetVisibility(state == Qt::Checked);
this->touch();
this->draw();
});
}
......
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