4#pragma warning(disable : 4800)
5#pragma warning(disable : 4251)
6#pragma warning(disable : 4244)
7#include <QDoubleSpinBox>
12#include "../../global.hpp"
13#include "../../genapi/value_node.hpp"
14#include "../../genapi/float_node.hpp"
15#include "detail_property.hpp"
27 class FloatProperty :
public Private::Property
33 FloatProperty(
const ValueNodePtr &node, Property *parent)
34 : Property(node, PT_Float, parent)
38 QWidget *CreateEditor(QWidget *parent)
override
40 auto floatNode = std::dynamic_pointer_cast<FloatNode>(Node());
41 if (floatNode && floatNode->IsAvailable())
43 auto editor =
new QDoubleSpinBox(parent);
44 editor->setDecimals(6);
45 editor->setMinimum(floatNode->Min());
46 editor->setMaximum(floatNode->Max());
47 editor->setValue(floatNode->Value());
48 editor->setSingleStep(0.1);
50 QObject::connect(editor,
static_cast<void (QDoubleSpinBox::*)(
double)
>(&QDoubleSpinBox::valueChanged),
this,
51 [=](
double value) { SetValue(QVariant(value)); });
58 bool SetEditorData(QWidget *editor,
const QVariant &data)
override
60 if (
auto dsb = qobject_cast<QDoubleSpinBox *>(editor))
62 dsb->setValue(data.toDouble());
68 QVariant EditorData(QWidget *editor)
override
70 if (
auto dsb = qobject_cast<QDoubleSpinBox *>(editor))
72 return QVariant(dsb->value());
80 QVariant Value(
int column,
int role = Qt::UserRole)
override
87 return Data(column, role);
89 auto floatNode = std::dynamic_pointer_cast<FloatNode>(Node());
90 if (floatNode && floatNode->IsAvailable())
94 return QVariant::fromValue(floatNode->Value());
96 catch (
const CvbException &e)
102 return QVariant(
"-");
108 void SetValue(
const QVariant &value)
override
110 if (
auto floatNode = std::dynamic_pointer_cast<FloatNode>(Node()))
114 floatNode->SetValue(value.toFloat());
116 catch (
const CvbException &)
123 QString HtmlDescription()
override
125 if (
auto floatNode = std::dynamic_pointer_cast<Cvb::FloatNode>(Node()))
127 auto txt = QString(
"<br><table>");
128 auto min = QString(
"-");
129 auto max = QString(
"-");
130 auto rep = QString(
"-");
131 auto unit = QString(
"");
133 rep =
UI::CvbToQt(NodeRepresentation(floatNode->Representation()));
136 min = QString::number(floatNode->Min());
137 max = QString::number(floatNode->Max());
140 txt.append(
"<tr><td><b>Unit:</b></td><td align=\"right\">" + unit +
"</td></tr>");
141 txt.append(
"<tr><td><b>Minimum:</b></td><td align=\"right\">" + min +
"</td></tr>");
142 txt.append(
"<tr><td><b>Maximum:</b></td><td align=\"right\">" + max +
"</td></tr>");
143 txt.append(
"<tr><td><b>Representation:</b></td><td align=\"right\">" + rep +
"</td></tr>");
144 txt.append(
"</table>");
const int CVB_TIMEOUT
Timeout in function.
Definition exception.hpp:29
std::shared_ptr< ValueNode > ValueNodePtr
Convenience shared pointer for ValueNode.
Definition genapi.hpp:91
Namespace for user interface components.
Definition decl_image_scene.hpp:39
QString CvbToQt(const Cvb::String &text) noexcept
Convenience converter for strings.
Definition ui.hpp:257
Root namespace for the Image Manager interface.
Definition version.hpp:11