SensorDevicesWidget.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * \package RobotAPI::gui-plugins::RobotUnitPlugin
17  * \author Raphael Grimm ( raphael dot grimm at kit dot edu )
18  * \date 2017
19  * \copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <mutex>
26 #include <atomic>
27 
28 #include <QWidget>
29 #include <QLabel>
30 #include <QLineEdit>
31 #include <QHBoxLayout>
32 #include <QFormLayout>
33 #include <QPushButton>
34 #include <QTreeWidget>
35 #include <QTreeWidgetItem>
36 #include <QTreeWidgetItem>
37 
40 #include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
41 
42 #include "RobotUnitWidgetBase.h"
43 #include <RobotAPI/gui-plugins/RobotUnitPlugin/ui_SensorDevicesWidget.h>
44 
45 namespace armarx
46 {
47  class SensorDevicesWidgetEntry;
48 
49  class SensorDevicesWidget : public RobotUnitWidgetTemplateBase<Ui::SensorDevicesWidget>
50  {
51  public:
52  explicit SensorDevicesWidget(QWidget* parent = 0);
53  ~SensorDevicesWidget() override;
54  void sensorDeviceStatusChanged(const SensorDeviceStatusSeq& allStatus);
55 
56  protected:
57  void clearAll() override;
58  void doContentUpdate() override;
59  void getResetData() override;
60  bool addOneFromResetData() override;
61  private:
62  void add(const SensorDeviceDescription& desc);
63 
64  std::map<std::string, SensorDevicesWidgetEntry*> entries;
65  std::map<std::string, SensorDeviceStatus> statusUpdates;
66  SensorDeviceDescriptionSeq resetData;
67 
68  public:
69  static constexpr int idxName = 0;
70  static constexpr int idxTags = 1;
71  static constexpr int idxValType = 2;
72  static constexpr int idxValue = 3;
73  };
74 
75  class SensorDevicesWidgetEntry : QObject
76  {
77 
78  Q_OBJECT
79  public:
81  SensorDevicesWidget& parent,
82  QTreeWidget& treeWidget,
83  const SensorDeviceDescription& desc
84  );
85 
86  void update(const SensorDeviceStatus& status);
87 
88  bool matchName(const QString& name);
89  bool matchTag(const QString& tag);
90  bool matchValueType(const QString& type);
91 
92  public slots:
93  void setVisible(bool vis);
94 
95  private slots:
96  void hideTagList(bool hide);
97 
98  private:
99  QTreeWidgetItem* header;
100  VariantWidget* value;
101  std::vector<QTreeWidgetItem*> tags;
102  };
103 }
104 
armarx::SensorDevicesWidget::clearAll
void clearAll() override
Definition: SensorDevicesWidget.cpp:73
RobotUnitWidgetBase.h
armarx::SensorDevicesWidget::getResetData
void getResetData() override
Definition: SensorDevicesWidget.cpp:93
armarx::SensorDevicesWidget
Definition: SensorDevicesWidget.h:49
VariantWidget.h
armarx::SensorDevicesWidget::idxValue
static constexpr int idxValue
Definition: SensorDevicesWidget.h:72
WidgetDescription.h
armarx::SensorDevicesWidgetEntry::setVisible
void setVisible(bool vis)
Definition: SensorDevicesWidget.cpp:177
armarx::SensorDevicesWidget::~SensorDevicesWidget
~SensorDevicesWidget() override
Definition: SensorDevicesWidget.cpp:48
armarx::SensorDevicesWidget::addOneFromResetData
bool addOneFromResetData() override
Definition: SensorDevicesWidget.cpp:102
armarx::SensorDevicesWidgetEntry::update
void update(const SensorDeviceStatus &status)
Definition: SensorDevicesWidget.cpp:149
armarx::SensorDevicesWidget::SensorDevicesWidget
SensorDevicesWidget(QWidget *parent=0)
Definition: SensorDevicesWidget.cpp:30
armarx::status
status
Definition: FiniteStateMachine.h:259
armarx::SensorDevicesWidget::idxValType
static constexpr int idxValType
Definition: SensorDevicesWidget.h:71
armarx::SensorDevicesWidgetEntry::matchTag
bool matchTag(const QString &tag)
Definition: SensorDevicesWidget.cpp:160
armarx::SensorDevicesWidgetEntry::matchName
bool matchName(const QString &name)
Definition: SensorDevicesWidget.cpp:155
armarx::SensorDevicesWidgetEntry
Definition: SensorDevicesWidget.h:75
armarx::RobotUnitWidgetTemplateBase
Definition: RobotUnitWidgetBase.h:93
armarx::SensorDevicesWidget::doContentUpdate
void doContentUpdate() override
Definition: SensorDevicesWidget.cpp:80
armarx::SensorDevicesWidget::idxName
static constexpr int idxName
Definition: SensorDevicesWidget.h:69
armarx::SensorDevicesWidget::sensorDeviceStatusChanged
void sensorDeviceStatusChanged(const SensorDeviceStatusSeq &allStatus)
Definition: SensorDevicesWidget.cpp:53
armarx::SensorDevicesWidgetEntry::matchValueType
bool matchValueType(const QString &type)
Definition: SensorDevicesWidget.cpp:172
armarx::SensorDevicesWidgetEntry::SensorDevicesWidgetEntry
SensorDevicesWidgetEntry(SensorDevicesWidget &parent, QTreeWidget &treeWidget, const SensorDeviceDescription &desc)
Definition: SensorDevicesWidget.cpp:122
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::VariantWidget
Definition: VariantWidget.h:38
armarx::SensorDevicesWidget::idxTags
static constexpr int idxTags
Definition: SensorDevicesWidget.h:70