TreeDataVisitorBase.cpp
Go to the documentation of this file.
1 #include "TreeDataVisitorBase.h"
2 
5 
6 
8 {
9 
11  {
12  }
13 
15  {
16  rootItems.push(root);
17  }
18 
20  {}
21 
22  void TreeDataVisitorBase::setColumns(int key, int value, int type)
23  {
24  this->columnKey = key;
25  this->columnType = type;
26  this->columnValue = value;
27  }
28 
29  bool TreeDataVisitorBase::_visitEnter(const std::string& key, const std::string& type, size_t numChildren)
30  {
31  QTreeWidgetItem* item = nullptr;
32  if (rootItems.size() > 0)
33  {
34  item = rootItems.top();
35  rootItems.pop();
36  }
37  else
38  {
39  QStringList cols;
40  cols.insert(columnKey, QString::fromStdString(key));
41  cols.insert(columnValue, QString::number(numChildren) + " items");
42  cols.insert(columnType, QString::fromStdString(type));
43  item = new QTreeWidgetItem(cols);
44  }
45  items.push(item);
46  return true;
47  }
48 
50  {
52  QTreeWidgetItem* item = items.top();
53  items.pop();
54  item->setExpanded(true);
55  if (items.size() > 0)
56  {
57  items.top()->addChild(item);
58  }
59  else
60  {
61  rootItems.push(item);
62  }
63  return true;
64  }
65 
66  void TreeDataVisitorBase::streamValueText(const aron::data::Bool& n, std::stringstream& ss) const
67  {
68  if (n.getValue())
69  {
70  ss << "true";
71  }
72  else
73  {
74  ss << "false";
75  }
76  }
77 
78  void TreeDataVisitorBase::streamValueText(const aron::data::String& n, std::stringstream& ss) const
79  {
80  ss << "'" << n.getValue() << "'";
81  }
82 
83  void TreeDataVisitorBase::streamValueText(const aron::data::NDArray& n, std::stringstream& ss) const
84  {
86  }
87 
88 }
armarx::armem::gui::instance::TreeDataVisitorBase::items
std::stack< QTreeWidgetItem * > items
Definition: TreeDataVisitorBase.h:73
armarx::aron::data::NDArray
Definition: NDArray.h:48
armarx::aron::data::Bool
Definition: Bool.h:41
armarx::aron::data::NDArray::getShape
std::vector< int > getShape() const
Definition: NDArray.cpp:145
armarx::aron::data::NDArray::DimensionsToString
static std::string DimensionsToString(const std::vector< int > &dimensions)
Return dimensions in a readable string such as "(2, 3, 4)".
Definition: NDArray.cpp:254
armarx::aron::data::detail::PrimitiveVariant::getValue
ValueT getValue() const
Definition: PrimitiveVariant.h:132
armarx::armem::gui::instance::TreeDataVisitorBase::streamValueText
void streamValueText(Navigator &n, std::stringstream &ss) const
Definition: TreeDataVisitorBase.h:61
armarx::armem::gui::instance::TreeDataVisitorBase::TreeDataVisitorBase
TreeDataVisitorBase()
Definition: TreeDataVisitorBase.cpp:10
armarx::armem::gui::instance::TreeDataVisitorBase::_visitExit
bool _visitExit()
Definition: TreeDataVisitorBase.cpp:49
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::armem::gui::instance
Definition: AronDataView.cpp:2
armarx::aron::data::String
Definition: String.h:41
armarx::armem::gui::instance::TreeDataVisitorBase::_visitEnter
bool _visitEnter(const std::string &key, const std::string &type, size_t numChildren)
Definition: TreeDataVisitorBase.cpp:29
armarx::armem::gui::instance::TreeDataVisitorBase::rootItems
std::stack< QTreeWidgetItem * > rootItems
Definition: TreeDataVisitorBase.h:72
All.h
ARMARX_CHECK_POSITIVE
#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...
Definition: ExpressionException.h:145
armarx::armem::gui::instance::TreeDataVisitorBase::~TreeDataVisitorBase
virtual ~TreeDataVisitorBase()
Definition: TreeDataVisitorBase.cpp:19
armarx::armem::gui::instance::TreeDataVisitorBase::setColumns
void setColumns(int key, int value, int type)
Definition: TreeDataVisitorBase.cpp:22
ExpressionException.h
armarx::armem::gui::instance::TreeDataVisitorBase::columnValue
int columnValue
Definition: TreeDataVisitorBase.h:76
TreeDataVisitorBase.h
armarx::armem::gui::instance::TreeDataVisitorBase::columnKey
int columnKey
Definition: TreeDataVisitorBase.h:75
armarx::armem::gui::instance::TreeDataVisitorBase::columnType
int columnType
Definition: TreeDataVisitorBase.h:77