Commit 9fd5ea42 authored by LACROIX Romain's avatar LACROIX Romain

Scalars controlled by widget: we also implement this technique for the Line seed.

parent e159a3a8
......@@ -34,8 +34,9 @@ public:
double reset_value = 0;
};
dtkVisualizationWidgetsScalarControl::dtkVisualizationWidgetsScalarControl(double reset, QWidget *parent) : QGroupBox(parent), d(new dtkVisualizationWidgetsScalarControlPrivate)
dtkVisualizationWidgetsScalarControl::dtkVisualizationWidgetsScalarControl(const QString& name, double reset, QWidget *parent) : QGroupBox(parent), d(new dtkVisualizationWidgetsScalarControlPrivate)
{
setObjectName(name);
d->spbox = new QDoubleSpinBox;
d->breset = new QPushButton;
d->reset_value = reset;
......@@ -73,7 +74,25 @@ void dtkVisualizationWidgetsScalarControl::setValue(double value)
d->spbox->setValue(value);
}
dtkVisualizationWidgetsScalarPositiveControl::dtkVisualizationWidgetsScalarPositiveControl(double reset, QWidget *parent) : dtkVisualizationWidgetsScalarControl(reset, parent)
void dtkVisualizationWidgetsScalarControl::setCurrentValueAsResetValue()
{
d->reset_value = d->spbox->value();
}
void dtkVisualizationWidgetsScalarControl::setVisible(bool visible)
{
QObject *p = parent();
QWidget *w = nullptr;
if (p && (w = dynamic_cast<QWidget*>(p)))
{
// we apply setVisible() to parent() because
// the parent includes the whole line, with QLabel (prefix, name)
w->setVisible(visible);
}
QWidget::setVisible(visible);
}
dtkVisualizationWidgetsScalarPositiveControl::dtkVisualizationWidgetsScalarPositiveControl(const QString& name, double reset, QWidget *parent) : dtkVisualizationWidgetsScalarControl(name, reset, parent)
{
d->spbox->setMinimum(0);
}
......@@ -17,13 +17,14 @@ class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsScalarControl : publ
Q_OBJECT
public:
dtkVisualizationWidgetsScalarControl(double reset = 0, QWidget *parent = nullptr);
dtkVisualizationWidgetsScalarControl(const QString& name = "", double reset = 0, QWidget *parent = nullptr);
void setValue(double value);
void setCurrentValueAsResetValue();
virtual ~dtkVisualizationWidgetsScalarControl();
virtual void setVisible(bool visible) override;
signals:
void valueChanged(double);
protected:
// TODO show pos+radius or pos1+pos2 depending on sphere/line
dtkVisualizationWidgetsScalarControlPrivate *d;
};
......@@ -32,5 +33,5 @@ class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsScalarPositiveContro
Q_OBJECT
public:
dtkVisualizationWidgetsScalarPositiveControl(double reset = 0, QWidget *parent = nullptr);
dtkVisualizationWidgetsScalarPositiveControl(const QString& name = "", 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