TreeDataVisitorBase.cpp
Go to the documentation of this file.
2
4
6
8{
9
13
15 {
16 rootItems.push(root);
17 }
22
23 void
24 TreeDataVisitorBase::setColumns(int key, int value, int type)
25 {
26 this->columnKey = key;
27 this->columnType = type;
28 this->columnValue = value;
29 }
30
31 bool
32 TreeDataVisitorBase::_visitEnter(const std::string& key,
33 const std::string& type,
34 size_t numChildren)
35 {
36 QTreeWidgetItem* item = nullptr;
37 if (rootItems.size() > 0)
38 {
39 item = rootItems.top();
40 rootItems.pop();
41 }
42 else
43 {
44 QStringList cols;
45 cols.insert(columnKey, QString::fromStdString(key));
46 cols.insert(columnValue, QString::number(numChildren) + " items");
47 cols.insert(columnType, QString::fromStdString(type));
48 item = new QTreeWidgetItem(cols);
49 }
50 items.push(item);
51 return true;
52 }
53
54 bool
56 {
58 QTreeWidgetItem* item = items.top();
59 items.pop();
60 item->setExpanded(true);
61 if (items.size() > 0)
62 {
63 items.top()->addChild(item);
64 }
65 else
66 {
67 rootItems.push(item);
68 }
69 return true;
70 }
72 void
73 TreeDataVisitorBase::streamValueText(const aron::data::Bool& n, std::stringstream& ss) const
74 {
75 if (n.getValue())
76 {
77 ss << "true";
78 }
79 else
80 {
81 ss << "false";
82 }
83 }
84
85 void
86 TreeDataVisitorBase::streamValueText(const aron::data::String& n, std::stringstream& ss) const
87 {
88 ss << "'" << n.getValue() << "'";
89 }
90
91 void
92 TreeDataVisitorBase::streamValueText(const aron::data::NDArray& n, std::stringstream& ss) const
93 {
94 ss << "shape " << aron::data::NDArray::DimensionsToString(n.getShape());
95 }
96
97} // namespace armarx::armem::gui::instance
void streamValueText(Navigator &n, std::stringstream &ss) const
bool _visitEnter(const std::string &key, const std::string &type, size_t numChildren)
static std::string DimensionsToString(const std::vector< int > &dimensions)
Return dimensions in a readable string such as "(2, 3, 4)".
Definition NDArray.cpp:257
#define ARMARX_CHECK_POSITIVE(number)
This macro evaluates whether number is positive (> 0) and if it turns out to be false it will throw a...