22 #include <QApplication>
25 #include <QColorDialog>
27 #include <QDoubleSpinBox>
32 #include <QToolButton>
38 double singleStep(
int decimals)
41 return 1. / std::pow(10., decimals - 1);
70 , m_textLabel(new QLabel)
71 , m_pixmapLabel(new QLabel)
73 , m_extDialogType(
"ExtMaterialEditor")
75 setMouseTracking(
true);
76 setAutoFillBackground(
true);
78 auto layout =
new QHBoxLayout;
79 layout->setContentsMargins(4, 0, 0, 0);
85 auto button =
new QToolButton;
86 button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
87 button->setText(QLatin1String(
" . . . "));
88 button->setToolTip(
"Material selector");
91 layout->addStretch(1);
92 layout->addWidget(button);
93 setFocusPolicy(Qt::StrongFocus);
94 setAttribute(Qt::WA_InputMethodEnabled);
117 throw GUIHelpers::Error(
"ExternalPropertyEditor::buttonClicked() -> Unexpected dialog");
122 if (newProperty.isValid() && newProperty != property)
139 setAutoFillBackground(
true);
140 setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
142 auto layout =
new QVBoxLayout;
143 layout->setMargin(0);
144 layout->setSpacing(0);
145 layout->addWidget(
m_box);
155 return m_box->sizeHint();
160 return m_box->minimumSizeHint();
169 setDataIntern(QVariant::fromValue<ComboProperty>(comboProperty));
207 connect(
m_box,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this,
210 disconnect(
m_box,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
217 :
CustomEditor(parent), m_lineEdit(new QLineEdit), m_validator(nullptr)
219 setAutoFillBackground(
true);
221 auto layout =
new QVBoxLayout;
222 layout->setMargin(0);
223 layout->setSpacing(0);
227 m_validator =
new QDoubleValidator(0.0, 1e+200, 1000,
this);
228 m_validator->setNotation(QDoubleValidator::ScientificNotation);
231 connect(
m_lineEdit, &QLineEdit::editingFinished,
this,
246 double new_value =
m_lineEdit->text().toDouble();
248 if (new_value !=
m_data.toDouble())
261 :
CustomEditor(parent), m_doubleEditor(new QDoubleSpinBox)
263 setAutoFillBackground(
true);
264 setFocusPolicy(Qt::StrongFocus);
268 auto layout =
new QVBoxLayout;
269 layout->setMargin(0);
270 layout->setSpacing(0);
275 static_cast<void (QDoubleSpinBox::*)(
double)
>(&QDoubleSpinBox::valueChanged),
286 m_doubleEditor->setMinimum(std::numeric_limits<double>::lowest());
304 if (new_value !=
m_data.toDouble())
319 setAutoFillBackground(
true);
320 setFocusPolicy(Qt::StrongFocus);
324 auto layout =
new QVBoxLayout;
325 layout->setMargin(0);
326 layout->setSpacing(0);
340 : std::numeric_limits<double>::lowest());
342 : std::numeric_limits<double>::max());
360 if (new_value !=
m_data.toDouble())
374 setAutoFillBackground(
true);
378 auto layout =
new QVBoxLayout;
379 layout->setMargin(0);
380 layout->setSpacing(0);
384 connect(
m_intEditor,
static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
394 m_intEditor->setMaximum(std::numeric_limits<int>::max());
406 if (new_value !=
m_data.toInt())
412 if (!
m_data.isValid() ||
m_data.type() != QVariant::Int)
421 setAutoFillBackground(
true);
422 auto layout =
new QHBoxLayout;
423 layout->setContentsMargins(4, 0, 0, 0);
434 if (value !=
m_data.toBool())
441 bool value =
m_data.toBool();
445 m_checkBox->setText(value ?
"True" :
"False");
#define ASSERT(condition)
Defines class ComboProperty.
Defines CustomEditors classes.
Defines classes releted to event filtering.
Defines class GUIHelpers functions.
Defines class GroupItemController.
Defines class MaterialItemUtils.
Defines class ScientificSpinBox.
BoolEditor(QWidget *parent=nullptr)
void initEditor()
Inits editor widgets from m_data.
void onCheckBoxChange(bool value)
virtual int internIndex()
Returns index for QComboBox.
void setConnected(bool isConnected)
virtual QStringList internLabels()
Returns list of labels for QComboBox.
virtual void onIndexChanged(int index)
class WheelEventEater * m_wheel_event_filter
QSize minimumSizeHint() const
void initEditor()
Inits editor widgets from m_data.
ComboPropertyEditor(QWidget *parent=nullptr)
Custom property to define list of string values with multiple selections.
QStringList getValues() const
void setCurrentIndex(int index)
Base class for all custom variants editors.
void dataChanged(const QVariant &data)
Signal emit then user changed the data through the editor.
virtual void initEditor()
Inits editor widgets from m_data.
void setData(const QVariant &data)
Sets the data from the model to editor.
void setDataIntern(const QVariant &data)
Saves the data from the editor and informs external delegates.
void setDecimals(int decimals)
void setLimits(const RealLimits &limits)
class QDoubleSpinBox * m_doubleEditor
DoubleEditor(QWidget *parent=nullptr)
void initEditor()
Inits editor widgets from m_data.
ExternalPropertyEditor(QWidget *parent=nullptr)
void setExternalDialogType(const QString &dialogType)
LostFocusFilter * m_focusFilter
QString m_extDialogType
Type of the dialog which will be created on button click.
void initEditor()
Inits editor widgets from m_data.
The ExternalProperty class defines custom QVariant property to carry the text, color and an identifie...
IntEditor(QWidget *parent=nullptr)
class QSpinBox * m_intEditor
void setLimits(const RealLimits &limits)
void initEditor()
Inits editor widgets from m_data.
Event filter to prevent lost of focus by custom material editor.
Limits for a real fit parameter.
bool hasUpperLimit() const
if has upper limit
double upperLimit() const
Returns upper limit.
double lowerLimit() const
Returns lower limit.
bool hasLowerLimit() const
if has lower limit
void initEditor()
Inits editor widgets from m_data.
class QLineEdit * m_lineEdit
void setLimits(const RealLimits &limits)
ScientificDoublePropertyEditor(QWidget *parent=nullptr)
class QDoubleValidator * m_validator
void setDecimals(int decimals)
void setLimits(const RealLimits &limits)
void initEditor()
Inits editor widgets from m_data.
void setSingleStep(double step)
ScientificSpinBoxEditor(QWidget *parent=nullptr)
class ScientificSpinBox * m_doubleEditor
void setMaximum(double max)
void setMinimum(double min)
void setValue(double val)
void setSingleStep(double step)
void valueChanged(double value)
Event filter to install on combo boxes and spin boxes to not to react on wheel events during scrollin...
ExternalProperty selectMaterialProperty(const ExternalProperty &previous=ExternalProperty())
Calls material selector dialog.
ExternalProperty materialProperty(const SessionItem &materialItem)
Constructs material property corresponding to given material.
ExternalProperty selectColorProperty(const ExternalProperty &previous=ExternalProperty())
Calls color selector dialog.