DataView.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <deque>
4 #include <optional>
5 #include <variant>
6 
7 #include <QGroupBox>
8 #include <QMenu>
9 #include <QWidget>
10 
11 #include <SimoxUtility/color/ColorMap.h>
12 
14 
18 
19 
20 class QGroupBox;
21 class QLabel;
22 class QSplitter;
23 class QTreeWidget;
24 class QTreeWidgetItem;
25 
26 
28 {
29  class ImageView;
30  class MemoryIDTreeWidgetItem;
31  class WidgetsWithToolbar;
32 
33 
34  class DataView : public QWidget, public armarx::Logging
35  {
36  Q_OBJECT
37 
38  public:
39  DataView();
40 
41  virtual ~DataView() = default;
42 
43  void setStatusLabel(QLabel* statusLabel);
44  void setUseTypeInfo(bool enable);
45 
46  virtual void update() = 0;
47 
48  void addDataView(DataView* dataView);
49 
50 
51  signals:
52 
53  void updated();
54  void useTypeInfoChanged(bool enable);
55  void memoryIdResolutionRequested(const MemoryID& id);
56  void actionsMenuRequested(const MemoryID& memoryID, QWidget* parent,
57  const QPoint& pos, QMenu* menu);
58 
59  protected slots:
60 
61  virtual void prepareTreeContextMenu(const QPoint& pos);
62 
63  void showImageView(const aron::Path& elementPath);
64  void removeImageView();
65 
66 
67  private:
68  QAction* makeActionResolveMemoryID(const MemoryID& id);
69  std::vector<QAction*> makeActionsCopyDataToClipboard();
70  std::vector<QAction*> makeActionsCopyDataToClipboard(const aron::Path& path);
71  std::vector<QAction*> makeCopyActions(const aron::data::VariantPtr& element,
72  const aron::type::VariantPtr& elementType);
73 
74 
75  protected:
76  virtual aron::data::DictPtr getData() = 0;
77  virtual void updateData(const aron::data::DictPtr& data,
78  aron::type::ObjectPtr aronType = nullptr);
79  virtual QMenu* buildActionsMenu(const QPoint& pos);
80  QAction* makeActionCopyMemoryID(const MemoryID& id);
82 
83  void showErrorMessage(const std::string& message);
84 
85  static std::optional<aron::Path> getElementPath(const QTreeWidgetItem* item);
86  std::optional<MemoryID> getElementMemoryID(const aron::Path& elementPath);
87 
88  protected:
89  enum class Columns
90  {
91  KEY = 0,
92  VALUE = 1,
93  TYPE = 2,
94  };
95 
97  bool useTypeInfo = true;
98 
99  QSplitter* splitter;
100 
101  QTreeWidget* tree;
102  QTreeWidgetItem* treeItemData;
103 
104 
105  class ImageView : public QGroupBox
106  {
107  public:
108  ImageView();
109 
110  QImage convertDepth32ToRGB32(const aron::data::NDArray& aron);
111 
114 
116 
117 
118  struct Limits
119  {
122  };
123 
124  /// Color map to visualize depth images.
125  simox::ColorMap cmap;
126  /// History over first n extremal depth values used to calibrate the colormap.
127  std::deque<Limits> limitsHistory;
128  /// In this context, n.
129  const size_t limitsHistoryMaxSize;
130  };
131  ImageView* imageView = nullptr;
132 
133  QLabel* statusLabel = nullptr;
134  };
135 
136 } // namespace armarx::armem::gui::instance
armarx::aron::type::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
armarx::armem::gui::instance::DataView::getElementMemoryID
std::optional< MemoryID > getElementMemoryID(const aron::Path &elementPath)
Definition: DataView.cpp:157
armarx::armem::gui::instance::DataView::statusLabel
QLabel * statusLabel
Definition: DataView.h:133
armarx::armem::gui::instance::DataView::ImageView::Limits::max
float max
Definition: DataView.h:121
armarx::armem::gui::instance::DataView::useTypeInfo
bool useTypeInfo
Definition: DataView.h:97
armarx::armem::gui::instance::DataView::splitter
QSplitter * splitter
Definition: DataView.h:99
armarx::armem::gui::instance::DataView::ImageView
Definition: DataView.h:105
armarx::aron::data::NDArray
Definition: NDArray.h:48
armarx::armem::gui::instance::DataView::memoryIdResolutionRequested
void memoryIdResolutionRequested(const MemoryID &id)
armarx::armem::gui::instance::DataView::Columns::KEY
@ KEY
Path.h
armarx::armem::gui::instance::DataView::Columns::TYPE
@ TYPE
armarx::armem::gui::instance::DataView::Columns
Columns
Definition: DataView.h:89
armarx::armem::gui::instance::DataView::ImageView::cmap
simox::ColorMap cmap
Color map to visualize depth images.
Definition: DataView.h:125
armarx::armem::gui::instance::DataView::updated
void updated()
armarx::armem::gui::instance::DataView::setUseTypeInfo
void setUseTypeInfo(bool enable)
Definition: DataView.cpp:71
armarx::armem::gui::instance::DataView::useTypeInfoChanged
void useTypeInfoChanged(bool enable)
armarx::armem::gui::instance::DataView::getData
virtual aron::data::DictPtr getData()=0
armarx::armem::gui::instance::WidgetsWithToolbar
Definition: WidgetsWithToolbar.h:34
message
message(STATUS "Boost-Library-Dir: " "${Boost_LIBRARY_DIRS}") message(STATUS "Boost-LIBRARIES
Definition: CMakeLists.txt:8
armarx::armem::gui::instance::DataView::ImageView::elementPath
aron::Path elementPath
Definition: DataView.h:113
armarx::armem::gui::instance::DataView::tree
QTreeWidget * tree
Definition: DataView.h:101
armarx::armem::gui::instance::DataView::~DataView
virtual ~DataView()=default
armarx::armem::gui::instance::DataView::DataView
DataView()
Definition: DataView.cpp:30
armarx::armem::gui::instance::DataView::actionsMenuRequested
void actionsMenuRequested(const MemoryID &memoryID, QWidget *parent, const QPoint &pos, QMenu *menu)
armarx::armem::gui::instance::DataView::removeImageView
void removeImageView()
Definition: DataView.cpp:482
armarx::aron::Path
The Path class.
Definition: Path.h:36
armarx::armem::gui::instance::DataView::getElementPath
static std::optional< aron::Path > getElementPath(const QTreeWidgetItem *item)
Definition: DataView.cpp:142
armarx::aron::data::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
armarx::armem::gui::instance::ImageView
A widget drawing an image in itself.
Definition: ImageView.h:34
armarx::armem::gui::instance::DataView::ImageView::convertDepth32ToRGB32
QImage convertDepth32ToRGB32(const aron::data::NDArray &aron)
Definition: DataView.cpp:489
armarx::armem::gui::instance::DataView::ImageView::limitsHistoryMaxSize
const size_t limitsHistoryMaxSize
In this context, n.
Definition: DataView.h:129
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::armem::gui::instance
Definition: AronDataView.cpp:2
armarx::armem::gui::instance::DataView::addDataView
void addDataView(DataView *dataView)
Definition: DataView.cpp:79
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::armem::gui::instance::DataView::ImageView::view
instance::ImageView * view
Definition: DataView.h:112
armarx::armem::gui::instance::DataView::ImageView::limitsHistory
std::deque< Limits > limitsHistory
History over first n extremal depth values used to calibrate the colormap.
Definition: DataView.h:127
armarx::armem::gui::instance::DataView::ImageView::toolbar
WidgetsWithToolbar * toolbar
Definition: DataView.h:115
max
T max(T t1, T t2)
Definition: gdiam.h:48
armarx::armem::gui::instance::DataView::updateData
virtual void updateData(const aron::data::DictPtr &data, aron::type::ObjectPtr aronType=nullptr)
Definition: DataView.cpp:101
armarx::armem::gui::instance::DataView
Definition: DataView.h:34
armarx::armem::gui::instance::DataView::buildActionsMenu
virtual QMenu * buildActionsMenu(const QPoint &pos)
Definition: DataView.cpp:343
forward_declarations.h
memory_definitions.h
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::Logging
Base Class for all Logging classes.
Definition: Logging.h:232
armarx::armem::gui::instance::DataView::imageView
ImageView * imageView
Definition: DataView.h:131
armarx::armem::gui::instance::DataView::update
virtual void update()=0
armarx::armem::gui::instance::DataView::showErrorMessage
void showErrorMessage(const std::string &message)
Definition: DataView.cpp:133
armarx::armem::index::memoryID
const MemoryID memoryID
Definition: memory_ids.cpp:29
armarx::armem::gui::instance::DataView::ImageView::ImageView
ImageView()
Definition: DataView.cpp:695
armarx::armem::gui::instance::DataView::treeItemData
QTreeWidgetItem * treeItemData
Definition: DataView.h:102
armarx::armem::gui::instance::DataView::ImageView::Limits
Definition: DataView.h:118
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
Logging.h
armarx::armem::gui::instance::DataView::currentAronType
aron::type::ObjectPtr currentAronType
Definition: DataView.h:96
armarx::armem::gui::instance::DataView::setStatusLabel
void setStatusLabel(QLabel *statusLabel)
Definition: DataView.cpp:65
armarx::armem::gui::instance::DataView::ImageView::Limits::min
float min
Definition: DataView.h:120
armarx::armem::gui::instance::DataView::prepareTreeContextMenu
virtual void prepareTreeContextMenu(const QPoint &pos)
Definition: DataView.cpp:443
armarx::armem::gui::instance::DataView::Columns::VALUE
@ VALUE
armarx::armem::gui::instance::DataView::updateImageView
void updateImageView(const aron::data::DictPtr &data)
Definition: DataView.cpp:576
armarx::armem::gui::instance::DataView::makeActionCopyMemoryID
QAction * makeActionCopyMemoryID(const MemoryID &id)
Definition: DataView.cpp:232
armarx::armem::gui::instance::DataView::showImageView
void showImageView(const aron::Path &elementPath)
Definition: DataView.cpp:458