Commit fdb3c059 authored by LACROIX Romain's avatar LACROIX Romain

Simpler implementation : the reset event is handled internally by our class,...

Simpler implementation : the reset event is handled internally by our class, no need to connect to another signal by the caller.
parent 13c6dd97
......@@ -259,7 +259,7 @@ dtkVisualizationDecoratorVectorStreamTracer::dtkVisualizationDecoratorVectorStre
seed_pos1_y->setObjectName("Position Y");
dtkVisualizationWidgetsScalarControl *seed_pos1_z = new dtkVisualizationWidgetsScalarControl;
seed_pos1_z->setObjectName("Position Z");
dtkVisualizationWidgetsScalarControl *seed_radius = new dtkVisualizationWidgetsScalarPositiveControl;
dtkVisualizationWidgetsScalarControl *seed_radius = new dtkVisualizationWidgetsScalarPositiveControl(1);
seed_radius->setObjectName("Radius");
//////////
......@@ -355,19 +355,6 @@ dtkVisualizationDecoratorVectorStreamTracer::dtkVisualizationDecoratorVectorStre
}
this->draw();
});
connect(seed_widget, QOverload<>::of(&dtkVisualizationWidgetsScalarControl::reset), [=] ()
{
if (axis == 3) // radius
{
d->source_sphere->SetRadius(1);
} else {
double pos[3];
d->source_sphere->GetCenter(pos);
pos[axis] = 0;
d->source_sphere->SetCenter(pos);
}
this->draw();
});
}
this->setObjectName("Vector Stream Tracer");
......
......@@ -26,7 +26,7 @@ dtkVisualizationWidgetsCategory::dtkVisualizationWidgetsCategory(const QString&
setStyleSheet("QGroupBox { background-color: transparent; margin: 0px; border: transparent; } ");
}
dtkVisualizationWidgetsScalarControl::dtkVisualizationWidgetsScalarControl(QWidget *parent) : QGroupBox(parent), spbox(new QDoubleSpinBox), breset(new QPushButton)
dtkVisualizationWidgetsScalarControl::dtkVisualizationWidgetsScalarControl(double reset, QWidget *parent) : QGroupBox(parent), spbox(new QDoubleSpinBox), breset(new QPushButton), reset_value(reset)
{
QLayout *layout = new QHBoxLayout;
spbox->setMinimum(-100000);
......@@ -42,11 +42,12 @@ dtkVisualizationWidgetsScalarControl::dtkVisualizationWidgetsScalarControl(QWidg
});
connect(breset, QOverload<>::of(&QPushButton::released), [=] ()
{
emit reset();
spbox->setValue(reset_value);
emit valueChanged(reset_value);
});
}
dtkVisualizationWidgetsScalarPositiveControl::dtkVisualizationWidgetsScalarPositiveControl(QWidget *parent) : dtkVisualizationWidgetsScalarControl(parent)
dtkVisualizationWidgetsScalarPositiveControl::dtkVisualizationWidgetsScalarPositiveControl(double reset, QWidget *parent) : dtkVisualizationWidgetsScalarControl(reset, parent)
{
spbox->setMinimum(0);
}
......@@ -19,16 +19,16 @@ class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsScalarControl : publ
Q_OBJECT
public:
dtkVisualizationWidgetsScalarControl(QWidget *parent = nullptr);
dtkVisualizationWidgetsScalarControl(double reset = 0, QWidget *parent = nullptr);
signals:
void valueChanged(double);
void reset();
protected:
// TODO move in private d-pointer (and remove forward declarations above)
// TODO show pos+radius or pos1+pos2 depending on sphere/line
// TODO plug other direction : with observers
QDoubleSpinBox *spbox;
QPushButton *breset;
double reset_value;
};
class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsScalarPositiveControl : public dtkVisualizationWidgetsScalarControl
......@@ -36,5 +36,5 @@ class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsScalarPositiveContro
Q_OBJECT
public:
dtkVisualizationWidgetsScalarPositiveControl(QWidget *parent = nullptr);
dtkVisualizationWidgetsScalarPositiveControl(double reset = 0, 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