4#pragma warning(disable : 4800)
5#pragma warning(disable : 4251)
6#pragma warning(disable : 4244)
15#include "../../global.hpp"
16#include "../../genapi/value_node.hpp"
17#include "../../genapi/node_map.hpp"
32 class Property :
public QObject
55 explicit Property(
const NodePtr &node, PropertyType type = PT_Unknown, Property *parent = 0)
60 children_ = QList<Property *>();
64 eventCookie_ = node_->RegisterEventUpdated([
this](
const GenApi::Node &value) { OnNodeUpdated(value); });
68 Property(
const Property &other) =
delete;
69 Property &operator=(
const Property &other) =
delete;
70 Property(Property &&other) =
delete;
71 Property &operator=(Property &&other) =
delete;
74 qDeleteAll(children_);
78 node_->UnregisterEventUpdated(eventCookie_);
83 int ChildCount()
const
85 return children_.size();
88 int ColumnCount()
const
90 return itemData_.size();
93 Property *Child(
int number)
95 return children_.value(number);
106 return parent_->children_.indexOf(
this);
110 QVariant Data(
int column,
int )
const
112 if (column < itemData_.size())
113 return itemData_.value(column);
117 bool InsertChild(
int position, Property *child)
119 if (position < 0 || position > children_.size())
122 children_.insert(position, child);
133 if (
auto catNode = std::dynamic_pointer_cast<CategoryNode>(node_))
134 return CVB_LIT(
"Category");
135 else if (
auto strNode = std::dynamic_pointer_cast<StringNode>(node_))
136 return CVB_LIT(
"String");
137 else if (
auto cmdNode = std::dynamic_pointer_cast<CommandNode>(node_))
138 return CVB_LIT(
"Command");
139 else if (
auto fNode = std::dynamic_pointer_cast<FloatNode>(node_))
140 return CVB_LIT(
"Float");
141 else if (
auto boolNode = std::dynamic_pointer_cast<BooleanNode>(node_))
142 return CVB_LIT(
"Boolean");
143 else if (
auto enumNode = std::dynamic_pointer_cast<EnumerationNode>(node_))
144 return CVB_LIT(
"Enumeration");
145 else if (
auto enumEntryNode = std::dynamic_pointer_cast<EnumEntryNode>(node_))
146 return CVB_LIT(
"Enumeration Entry");
147 else if (
auto iNode = std::dynamic_pointer_cast<IntegerNode>(node_))
148 return CVB_LIT(
"Integer");
150 return CVB_LIT(
"Unknown");
153 String NodeAccessMode()
const
158 switch (node_->AccessMode())
161 return CVB_LIT(
"Not implemented");
163 return CVB_LIT(
"Not available");
165 return CVB_LIT(
"Read only");
167 return CVB_LIT(
"Read/Write");
169 return CVB_LIT(
"Write only");
175 String NodeVisibility()
const
180 switch (node_->Visibility())
183 return CVB_LIT(
"Beginner");
185 return CVB_LIT(
"Expert");
187 return CVB_LIT(
"Guru");
189 return CVB_LIT(
"Invisible");
195 String NodeCachingMode()
const
200 switch (node_->CacheMode())
203 return CVB_LIT(
"No Cache");
205 return CVB_LIT(
"Write Around");
207 return CVB_LIT(
"Write Through");
215 switch (representation)
218 return CVB_LIT(
"Boolean");
220 return CVB_LIT(
"Hexadecimal Number");
222 return CVB_LIT(
"IPv4 Address");
224 return CVB_LIT(
"Linear");
226 return CVB_LIT(
"Logarithmic");
228 return CVB_LIT(
"MAC Address");
230 return CVB_LIT(
"Pure Number");
233 return CVB_LIT(
"Undefined");
237 PropertyType Type()
const
244 return (parent_ == 0);
247 bool NodeHasPolling()
const
249 if (
auto n = std::dynamic_pointer_cast<ValueNode>(node_))
251 return (n->PollingTime() > std::chrono::milliseconds(0));
256 bool NodeIsStreamable()
const
258 if (
auto n = std::dynamic_pointer_cast<ValueNode>(node_))
260 return (n->IsStreamable());
265 int FindChildProperty(
const NodePtr &node)
267 for (
int i = 0; i < children_.size(); i++)
269 auto child = children_.at(i);
270 if (child && child->Node() == node)
276 Property *ChildProperty(
int position)
278 if (position < children_.size())
279 return children_.at(position);
283 void RemoveChild(
int position)
285 auto p = ChildProperty(position);
288 children_.removeAt(position);
294 QWidget *EmptyEditor()
300 void OnNodeUpdated(
const GenApi::Node & )
309 if (!node_->IsWriteable() || !node_->IsAvailable())
315 virtual QVariant Value(
int column,
int role = Qt::UserRole) = 0;
316 virtual void SetValue(
const QVariant &value) = 0;
317 virtual QWidget *CreateEditor(QWidget *parent) = 0;
318 virtual bool SetEditorData(QWidget *editor,
const QVariant &data) = 0;
319 virtual QVariant EditorData(QWidget *editor) = 0;
320 virtual QString HtmlDescription() = 0;
324 void NodeUpdated(Property *p);
325 void TimeoutOccurred();
328 QList<Property *> children_;
332 QVector<QVariant> itemData_;
333 EventCookie eventCookie_;
std::shared_ptr< Node > NodePtr
Convenience shared pointer for Node.
Definition genapi.hpp:71
@ Expert
More complex feature, that requires deeper knowledge about the feature.
Definition genapi.hpp:244
@ Beginner
Simple feature usable by everybody.
Definition genapi.hpp:242
@ Guru
Definition genapi.hpp:251
@ Invisible
Node should not be displayed.
Definition genapi.hpp:240
@ NoCache
No caching used.
Definition genapi.hpp:225
@ WriteAround
Write to register, cache written on next read.
Definition genapi.hpp:229
@ WriteThrough
Write to cache and register.
Definition genapi.hpp:227
@ ReadOnly
Node can only be read.
Definition genapi.hpp:214
@ NotAvailable
Definition genapi.hpp:202
@ WriteOnly
Node can only be written to.
Definition genapi.hpp:216
@ ReadWrite
Node can be read and written to.
Definition genapi.hpp:218
@ NotImplemented
Definition genapi.hpp:196
NumberRepresentation
Defines how a number is to be interpreted/displayed in a graphical user interface.
Definition genapi.hpp:143
@ Boolean
True / False representation.
Definition genapi.hpp:151
@ MAC
MAC address in an edit control.
Definition genapi.hpp:159
@ Logarithmic
Slider with logarithmic behavior.
Definition genapi.hpp:149
@ Linear
Slider with linear behavior.
Definition genapi.hpp:147
@ IPv4
IPv4 address in an edit control.
Definition genapi.hpp:157
@ HexNumber
Hex number in an edit control.
Definition genapi.hpp:155
@ PureNumber
Decimal number in an edit control.
Definition genapi.hpp:153
@ Undefined
Not set in XML (treated as linear)
Definition genapi.hpp:145
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 c_bayer_to_rgb.h:17
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49