mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-15 09:04:36 +00:00
default value in widget constructor
This commit is contained in:
parent
6d5f296a1e
commit
aa9afc5431
@ -98,6 +98,13 @@ public:
|
||||
virtual Value* clone() const = 0;
|
||||
virtual bool operator==(const Value& p) const = 0;
|
||||
virtual void fillToXMLElement(QDomElement& element) const = 0;
|
||||
|
||||
template <class Val>
|
||||
bool isOfType() const
|
||||
{
|
||||
const Val* t = dynamic_cast<const Val*>(this);
|
||||
return (t != nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //MESHLAB_VALUE_H
|
||||
|
||||
@ -219,66 +219,66 @@ RichParameterWidget* RichParameterListFrame::createWidgetFromRichParameter(
|
||||
const RichParameter& pd,
|
||||
const RichParameter& def)
|
||||
{
|
||||
if (pd.isOfType<RichAbsPerc>()) {
|
||||
return new AbsPercWidget(parent, (const RichAbsPerc&) pd, (const RichAbsPerc&) def);
|
||||
if (pd.isOfType<RichAbsPerc>() && def.isOfType<RichAbsPerc>()) {
|
||||
return new AbsPercWidget(parent, (const RichAbsPerc&) pd, (const FloatValue&) def.value());
|
||||
}
|
||||
else if (pd.isOfType<RichDynamicFloat>()) {
|
||||
else if (pd.isOfType<RichDynamicFloat>() && def.isOfType<RichDynamicFloat>()) {
|
||||
return new DynamicFloatWidget(
|
||||
parent, (const RichDynamicFloat&) pd, (const RichDynamicFloat&) def);
|
||||
}
|
||||
else if (pd.isOfType<RichEnum>()) {
|
||||
else if (pd.isOfType<RichEnum>() && def.isOfType<RichEnum>()) {
|
||||
return new EnumWidget(parent, (const RichEnum&) pd, (const RichEnum&) def);
|
||||
}
|
||||
else if (pd.isOfType<RichBool>()) {
|
||||
return new BoolWidget(parent, (const RichBool&) pd, (const RichBool&) def);
|
||||
else if (pd.isOfType<RichBool>() && def.isOfType<RichBool>()) {
|
||||
return new BoolWidget(parent, (const RichBool&) pd, (const BoolValue&) def.value());
|
||||
}
|
||||
else if (pd.isOfType<RichInt>()) {
|
||||
else if (pd.isOfType<RichInt>() && def.isOfType<RichInt>()) {
|
||||
return new IntWidget(parent, (const RichInt&) pd, (const RichInt&) def);
|
||||
}
|
||||
else if (pd.isOfType<RichFloat>()) {
|
||||
else if (pd.isOfType<RichFloat>() && def.isOfType<RichFloat>()) {
|
||||
return new FloatWidget(parent, (const RichFloat&) pd, (const RichFloat&) def);
|
||||
}
|
||||
else if (pd.isOfType<RichString>()) {
|
||||
else if (pd.isOfType<RichString>() && def.isOfType<RichString>()) {
|
||||
return new StringWidget(parent, (const RichString&) pd, (const RichString&) def);
|
||||
}
|
||||
else if (pd.isOfType<RichMatrix44f>()) {
|
||||
else if (pd.isOfType<RichMatrix44f>() && def.isOfType<RichMatrix44f>()) {
|
||||
return new Matrix44Widget(
|
||||
parent,
|
||||
(const RichMatrix44f&) pd,
|
||||
(const RichMatrix44f&) def,
|
||||
reinterpret_cast<RichParameterListFrame*>(parent)->gla);
|
||||
}
|
||||
else if (pd.isOfType<RichPosition>()) {
|
||||
else if (pd.isOfType<RichPosition>() && def.isOfType<RichPosition>()) {
|
||||
return new PositionWidget(
|
||||
parent,
|
||||
(const RichPosition&) pd,
|
||||
(const RichPosition&) def,
|
||||
reinterpret_cast<RichParameterListFrame*>(parent)->gla);
|
||||
}
|
||||
else if (pd.isOfType<RichDirection>()) {
|
||||
else if (pd.isOfType<RichDirection>() && def.isOfType<RichDirection>()) {
|
||||
return new DirectionWidget(
|
||||
parent,
|
||||
(const RichDirection&) pd,
|
||||
(const RichDirection&) def,
|
||||
reinterpret_cast<RichParameterListFrame*>(parent)->gla);
|
||||
}
|
||||
else if (pd.isOfType<RichShotf>()) {
|
||||
else if (pd.isOfType<RichShotf>() && def.isOfType<RichShotf>()) {
|
||||
return new ShotWidget(
|
||||
parent,
|
||||
(const RichShotf&) pd,
|
||||
(const RichShotf&) def,
|
||||
reinterpret_cast<RichParameterListFrame*>(parent)->gla);
|
||||
}
|
||||
else if (pd.isOfType<RichColor>()) {
|
||||
return new ColorWidget(parent, (const RichColor&) pd, (const RichColor&) def);
|
||||
else if (pd.isOfType<RichColor>() && def.isOfType<RichColor>()) {
|
||||
return new ColorWidget(parent, (const RichColor&) pd, (const ColorValue&) def.value());
|
||||
}
|
||||
else if (pd.isOfType<RichOpenFile>()) {
|
||||
else if (pd.isOfType<RichOpenFile>() && def.isOfType<RichOpenFile>()) {
|
||||
return new OpenFileWidget(parent, (const RichOpenFile&) pd, (const RichOpenFile&) def);
|
||||
}
|
||||
else if (pd.isOfType<RichSaveFile>()) {
|
||||
else if (pd.isOfType<RichSaveFile>() && def.isOfType<RichSaveFile>()) {
|
||||
return new SaveFileWidget(parent, (const RichSaveFile&) pd, (const RichSaveFile&) def);
|
||||
}
|
||||
else if (pd.isOfType<RichMesh>()) {
|
||||
else if (pd.isOfType<RichMesh>() && def.isOfType<RichMesh>()) {
|
||||
return new MeshWidget(parent, (const RichMesh&) pd, (const RichMesh&) def);
|
||||
}
|
||||
else {
|
||||
|
||||
@ -29,13 +29,9 @@
|
||||
#include <QFileDialog>
|
||||
#include <common/ml_document/mesh_document.h>
|
||||
|
||||
AbsPercWidget::AbsPercWidget(QWidget* p, const RichAbsPerc& rabs, const RichAbsPerc& rdef) :
|
||||
RichParameterWidget(p, rabs, rdef)
|
||||
|
||||
AbsPercWidget::AbsPercWidget(QWidget *p, const RichAbsPerc &rabs, const FloatValue &defaultValue) :
|
||||
RichParameterWidget(p, rabs, defaultValue), m_min(rabs.min), m_max(rabs.max)
|
||||
{
|
||||
m_min = rabs.min;
|
||||
m_max = rabs.max;
|
||||
|
||||
descriptionLabel->setText(descriptionLabel->text() + " (abs and %)");
|
||||
|
||||
absSB = new QDoubleSpinBox(this);
|
||||
|
||||
@ -30,7 +30,7 @@ class AbsPercWidget : public RichParameterWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AbsPercWidget(QWidget* p, const RichAbsPerc& rabs, const RichAbsPerc& rdef);
|
||||
AbsPercWidget(QWidget* p, const RichAbsPerc &rabs, const FloatValue &defaultValue);
|
||||
~AbsPercWidget();
|
||||
|
||||
void addWidgetToGridLayout(QGridLayout* lay, const int r);
|
||||
|
||||
@ -29,8 +29,8 @@
|
||||
#include <QFileDialog>
|
||||
#include <common/ml_document/mesh_document.h>
|
||||
|
||||
BoolWidget::BoolWidget(QWidget* p, const RichBool& rb, const RichBool& rdef) :
|
||||
RichParameterWidget(p, rb, rdef)
|
||||
BoolWidget::BoolWidget(QWidget *p, const RichBool ¶m, const BoolValue &defaultValue) :
|
||||
RichParameterWidget(p, param, defaultValue)
|
||||
{
|
||||
cb = new QCheckBox("", this);
|
||||
cb->setToolTip(parameter->toolTip());
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
class BoolWidget : public RichParameterWidget
|
||||
{
|
||||
public:
|
||||
BoolWidget(QWidget* p, const RichBool& rb, const RichBool& rdef);
|
||||
BoolWidget(QWidget* p, const RichBool& param, const BoolValue& defaultValue);
|
||||
~BoolWidget();
|
||||
|
||||
void addWidgetToGridLayout(QGridLayout* lay, const int r);
|
||||
|
||||
@ -29,8 +29,8 @@
|
||||
#include <QFileDialog>
|
||||
#include <common/ml_document/mesh_document.h>
|
||||
|
||||
ColorWidget::ColorWidget(QWidget* p, const RichColor& newColor, const RichColor& rdef) :
|
||||
RichParameterWidget(p, newColor, rdef), pickcol()
|
||||
ColorWidget::ColorWidget(QWidget *p, const RichColor &newColor, const ColorValue &defaultValue) :
|
||||
RichParameterWidget(p, newColor, defaultValue), pickcol(defaultValue.getColor())
|
||||
{
|
||||
colorLabel = new QLabel(this);
|
||||
colorButton = new QPushButton(this);
|
||||
@ -51,7 +51,6 @@ ColorWidget::ColorWidget(QWidget* p, const RichColor& newColor, const RichColor&
|
||||
widgets.push_back(colorLabel);
|
||||
widgets.push_back(colorButton);
|
||||
|
||||
pickcol = parameter->value().getColor();
|
||||
connect(colorButton, SIGNAL(clicked()), this, SLOT(pickColor()));
|
||||
connect(this, SIGNAL(dialogParamChanged()), this, SLOT(setParameterChanged()));
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ class ColorWidget : public RichParameterWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorWidget(QWidget* p, const RichColor& newColor, const RichColor& rdef);
|
||||
ColorWidget(QWidget* p, const RichColor& newColor, const ColorValue& defaultValue);
|
||||
~ColorWidget();
|
||||
|
||||
void addWidgetToGridLayout(QGridLayout* lay, const int r);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user