OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
qml_parameter.hpp
1#pragma once
2#include <ossia/network/base/parameter.hpp>
3
4#include <ossia-qt/device/qml_node_base.hpp>
5#include <ossia-qt/qml_context.hpp>
6
7#include <QObject>
8#include <QQmlProperty>
9
10#include <verdigris>
11namespace ossia
12{
13namespace qt
14{
15class qml_node;
16class qml_device;
17
18class OSSIA_EXPORT qml_parameter : public qml_property_base
19{
20 W_OBJECT(qml_parameter)
21
22public:
23 qml_parameter(QQuickItem* parent = nullptr);
24 ~qml_parameter();
25
26 void resetNode() override;
27 void setDevice(QObject* device) override;
28
29 qml_val_type::val_type valueType() const;
30 qml_access_mode::access_mode access() const;
31 qml_bounding_mode::bounding_mode bounding() const;
32 qml_rep_filter::repetition_filter filterRepetitions() const;
33 QVariant min() const;
34 QVariant max() const;
35 QVariantList values() const;
36 QString unit() const;
37
38 QVariant value() const { return m_value; }
39
40public:
41 void setValue_sig(const ossia::value& arg_1)
42 E_SIGNAL(OSSIA_EXPORT, setValue_sig, arg_1);
43
44 void valueTypeChanged(qml_val_type::val_type valueType)
45 E_SIGNAL(OSSIA_EXPORT, valueTypeChanged, valueType);
46 void accessChanged(qml_access_mode::access_mode access)
47 E_SIGNAL(OSSIA_EXPORT, accessChanged, access);
48 void boundingChanged(qml_bounding_mode::bounding_mode bounding)
49 E_SIGNAL(OSSIA_EXPORT, boundingChanged, bounding);
50 void filterRepetitionsChanged(qml_rep_filter::repetition_filter filterRepetitions)
51 E_SIGNAL(OSSIA_EXPORT, filterRepetitionsChanged, filterRepetitions);
52 void minChanged(QVariant min) E_SIGNAL(OSSIA_EXPORT, minChanged, min);
53 void maxChanged(QVariant max) E_SIGNAL(OSSIA_EXPORT, maxChanged, max);
54 void valuesChanged(QVariantList values) E_SIGNAL(OSSIA_EXPORT, valuesChanged, values);
55 void unitChanged(QString unit) E_SIGNAL(OSSIA_EXPORT, unitChanged, unit);
56
57 void valueChanged(QVariant value) E_SIGNAL(OSSIA_EXPORT, valueChanged, value);
58
59public:
60 void setValue_slot(const ossia::value&);
61 W_SLOT(setValue_slot);
62
63 void setValueType(qml_val_type::val_type valueType);
64 W_SLOT(setValueType);
65 void setAccess(qml_access_mode::access_mode access);
66 W_SLOT(setAccess);
67 void setBounding(qml_bounding_mode::bounding_mode bounding);
68 W_SLOT(setBounding);
69 void setFilterRepetitions(qml_rep_filter::repetition_filter filterRepetitions);
70 W_SLOT(setFilterRepetitions);
71 void setMin(QVariant min);
72 W_SLOT(setMin);
73 void setMax(QVariant max);
74 W_SLOT(setMax);
75 void setValues(QVariantList values);
76 W_SLOT(setValues);
77 void setUnit(QString unit);
78 W_SLOT(setUnit);
79
80 void resetValueType()
81 {
82 if(m_valueType)
83 {
84 m_valueType = std::nullopt;
85 }
86 };
87 W_SLOT(resetValueType)
88 void resetAccess()
89 {
90 if(m_access)
91 {
92 m_access = std::nullopt;
93 }
94 };
95 W_SLOT(resetAccess)
96 void resetBounding()
97 {
98 if(m_bounding)
99 {
100 m_bounding = std::nullopt;
101 }
102 };
103 W_SLOT(resetBounding)
104 void resetFilterRepetitions()
105 {
106 if(m_filterRepetitions)
107 {
108 m_filterRepetitions = std::nullopt;
109 }
110 };
111 W_SLOT(resetFilterRepetitions)
112 void resetMin() { setMin(QVariant{}); };
113 W_SLOT(resetMin)
114 void resetMax() { setMax(QVariant{}); };
115 W_SLOT(resetMax)
116 void resetValues()
117 {
118 if(m_values)
119 {
120 m_values = std::nullopt;
121 }
122 };
123 W_SLOT(resetValues)
124 void resetUnit()
125 {
126 if(m_unit)
127 {
128 m_values = std::nullopt;
129 }
130 };
131 W_SLOT(resetUnit)
132 void setValue(QVariant value);
133 W_SLOT(setValue);
134
135private:
136 void setupAddress(bool reading);
137 void updateDomain();
138
139 QVariant m_value;
140 std::optional<qml_val_type::val_type> m_valueType{};
141 std::optional<qml_access_mode::access_mode> m_access{};
142 std::optional<qml_bounding_mode::bounding_mode> m_bounding{};
143 std::optional<qml_rep_filter::repetition_filter> m_filterRepetitions{};
144 QVariant m_min{};
145 QVariant m_max{};
146 std::optional<QVariantList> m_values{};
147 std::optional<QString> m_unit{};
148
149 W_PROPERTY(
150 QVariantList,
151 values READ values WRITE setValues NOTIFY valuesChanged RESET resetValues, W_Final)
152
153 W_PROPERTY(
154 QVariant, max READ max WRITE setMax NOTIFY maxChanged RESET resetMax, W_Final)
155
156 W_PROPERTY(
157 QVariant, min READ min WRITE setMin NOTIFY minChanged RESET resetMin, W_Final)
158
159 W_PROPERTY(
160 ossia::qt::qml_rep_filter::repetition_filter,
161 filterRepetitions READ filterRepetitions WRITE setFilterRepetitions NOTIFY
162 filterRepetitionsChanged RESET resetFilterRepetitions,
163 W_Final)
164
165 W_PROPERTY(
166 ossia::qt::qml_bounding_mode::bounding_mode,
167 bounding READ bounding WRITE setBounding NOTIFY boundingChanged RESET
168 resetBounding,
169 W_Final)
170
171 W_PROPERTY(
172 ossia::qt::qml_access_mode::access_mode,
173 access READ access WRITE setAccess NOTIFY accessChanged RESET resetAccess, W_Final)
174
175 W_PROPERTY(
176 ossia::qt::qml_val_type::val_type,
177 valueType READ valueType WRITE setValueType NOTIFY valueTypeChanged RESET
178 resetValueType,
179 W_Final)
180
181 W_PROPERTY(
182 QString, unit READ unit WRITE setUnit NOTIFY unitChanged RESET resetUnit, W_Final)
183
184 W_PROPERTY(QVariant, value READ value WRITE setValue NOTIFY valueChanged)
185};
186}
187}
The value class.
Definition value.hpp:173
Definition git_info.h:7
OSSIA_INLINE constexpr auto min(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
min function tailored for values
Definition math.hpp:125
OSSIA_INLINE constexpr auto max(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
max function tailored for values
Definition math.hpp:96