ControlDevicesWidget.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 <atomic>
26#include <mutex>
27
28#include <QCheckBox>
29#include <QComboBox>
30#include <QFormLayout>
31#include <QHBoxLayout>
32#include <QLabel>
33#include <QLineEdit>
34#include <QPushButton>
35#include <QTreeWidget>
36#include <QTreeWidgetItem>
37#include <QWidget>
38
41
42#include <RobotAPI/gui-plugins/RobotUnitPlugin/ui_ControlDevicesWidget.h>
43#include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
44
45#include "RobotUnitWidgetBase.h"
46
47namespace armarx
48{
50
51 class ControlDevicesWidget : public RobotUnitWidgetTemplateBase<Ui::ControlDevicesWidget>
52 {
53 public:
54 explicit ControlDevicesWidget(QWidget* parent = 0);
55 ~ControlDevicesWidget() override;
56 void controlDeviceStatusChanged(const ControlDeviceStatusSeq& allStatus);
57
58 protected:
59 void clearAll() override;
60 void doContentUpdate() override;
61 void getResetData() override;
62 bool addOneFromResetData() override;
63
64 private:
65 void add(const ControlDeviceDescription& desc);
66 void update(const ControlDeviceStatus& status);
67
68 std::map<std::string, ControlDevicesWidgetEntry*> entries;
69 std::map<std::string, ControlDeviceStatus> statusUpdates;
70 ControlDeviceDescriptionSeq resetData;
71
72 public:
73 static constexpr int idxName = 0;
74 static constexpr int idxTags = 1;
75 static constexpr int idxMode = 2;
76 static constexpr int idxHWMode = 3;
77 static constexpr int idxAct = 4;
78 static constexpr int idxReq = 5;
79 static constexpr int idxType = 6;
80 static constexpr int idxVal = 7;
81 };
82
84 {
85
86 Q_OBJECT
87 public:
89 QTreeWidget& treeWidget,
90 const ControlDeviceDescription& desc);
91
92
93 void update(const ControlDeviceStatus& status);
94
95 bool matchName(const QString& name);
96 bool matchTag(const QString& tag);
97 std::set<QTreeWidgetItem*> matchMode(const QString& mode);
98 std::set<QTreeWidgetItem*> isActiveState(const QString& state);
99 std::set<QTreeWidgetItem*> isRequestedState(const QString& state);
100 std::set<QTreeWidgetItem*> matchTargetType(const QString& type);
101
102 public slots:
103 void setVisible(bool vis);
104 void setChildVis(bool vis, std::set<QTreeWidgetItem*> children);
105
106 private slots:
107 void hideTagList(bool hide);
108
109 private:
110 struct ControllerEntry
111 {
112 QTreeWidgetItem* child;
113 VariantWidget* value;
114 };
115
116 std::map<std::string, ControllerEntry> subEntries;
117 std::string activeMode;
118 std::string requestedMode;
119
120 QTreeWidgetItem* header;
121
122 std::vector<QTreeWidgetItem*> tags;
123 };
124} // namespace armarx
std::set< QTreeWidgetItem * > isActiveState(const QString &state)
void setChildVis(bool vis, std::set< QTreeWidgetItem * > children)
std::set< QTreeWidgetItem * > matchMode(const QString &mode)
std::set< QTreeWidgetItem * > isRequestedState(const QString &state)
std::set< QTreeWidgetItem * > matchTargetType(const QString &type)
ControlDevicesWidgetEntry(ControlDevicesWidget &parent, QTreeWidget &treeWidget, const ControlDeviceDescription &desc)
void update(const ControlDeviceStatus &status)
void controlDeviceStatusChanged(const ControlDeviceStatusSeq &allStatus)
This file offers overloads of toIce() and fromIce() functions for STL container types.