NJointControllersWidget.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 <QFormLayout>
30#include <QHBoxLayout>
31#include <QLabel>
32#include <QLineEdit>
33#include <QPushButton>
34#include <QTreeWidget>
35#include <QTreeWidgetItem>
36#include <QWidget>
37
39
42
43#include <RobotAPI/gui-plugins/RobotUnitPlugin/ui_NJointControllersWidget.h>
44#include <RobotAPI/interface/units/RobotUnit/NJointController.h>
45#include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
46
47#include "RobotUnitWidgetBase.h"
48
49namespace armarx
50{
54
55 class NJointControllersWidget : public RobotUnitWidgetTemplateBase<Ui::NJointControllersWidget>
56 {
57 Q_OBJECT
58 public:
59 explicit NJointControllersWidget(QWidget* parent = 0);
60 ~NJointControllersWidget() override;
61 void nJointControllerStatusChanged(const NJointControllerStatusSeq& allStatus);
62
63 virtual void nJointControllerCreated(std::string name);
64 virtual void nJointControllerDeleted(std::string name);
65
66 void loadSettings(QSettings* settings) override;
67 void saveSettings(QSettings* settings) override;
68
69 protected:
70 void clearAll() override;
71 void doContentUpdate() override;
72 void getResetData() override;
73 bool addOneFromResetData() override;
74
75 private:
76 void add(const NJointControllerDescriptionWithStatus& ds);
77
78 std::map<std::string, NJointControllersWidgetEntry*> entries;
79 std::map<std::string, NJointControllerStatus> statusUpdates;
80 std::map<std::string, NJointControllerDescriptionWithStatus> controllersCreated;
81 std::set<std::string> controllersDeleted;
82 private slots:
83 void onPushButtonStopAll_clicked();
84 void onPushButtonRemoveAll_clicked();
85
86 public:
87 static constexpr int idxName = 0;
88 static constexpr int idxClass = 1;
89 static constexpr int idxActive = 2;
90 static constexpr int idxRequested = 3;
91 static constexpr int idxError = 4;
92 static constexpr int idxInternal = 5;
93 static constexpr int idxCtrlDev = 6;
94 static constexpr int idxCtrlMode = 7;
95 static constexpr int idxActivate = 8;
96 static constexpr int idxDeactivate = 9;
97 static constexpr int idxDelete = 10;
98 };
99
100 class NJointControllersWidgetEntry : public QObject
101 {
102 Q_OBJECT
103 public:
105
107 QTreeWidget& treeWidget,
108 const NJointControllerDescription& desc);
109
110 void update(const NJointControllerStatus& status);
111
112 bool matchName(const QString& name);
113 bool matchClass(const QString& name);
114 bool isActiveState(const QString& state);
115 bool isRequestedState(const QString& state);
116 bool isErrorState(const QString& state);
117 bool matchDevice(const QString& dev);
118 bool matchMode(const QString& mode);
119 void deleteContent();
120
121 public slots:
122 void setVisible(bool vis);
123 private slots:
124 void activateController();
125 void deactivateController();
126 void deleteController();
127
128 void hideDeviceList();
129
130 void setDeviceListVisible(bool vis);
131
132 private:
133 const bool deletable;
134 QCheckBox* boxDev;
135 QCheckBox* boxMod;
136 QTreeWidgetItem* header;
137 NJointControllerInterfacePrx controller;
138 std::vector<QTreeWidgetItem*> devsToModes;
139 };
140
143 {
144 Q_OBJECT
145 public:
146 NJointControllersWidgetRemoteFunction(QTreeWidget& treeWidget,
147 QTreeWidgetItem& header,
148 const std::string& functionName,
149 const NJointControllerInterfacePrx& ctrl,
151 private slots:
152 void execFunction();
153
154 private:
155 QTreeWidgetItem* functionHeader;
156
157 std::string functionName;
158 NJointControllerInterfacePrx ctrl;
159
160 QCheckBox* execOnParamChange;
162
163 std::map<std::string, VariantBasePtr> paramValues;
164
165 public slots:
166 void valueChangedSlot(std::string name, VariantBasePtr value) override;
167 };
168} // namespace armarx
void update(const NJointControllerStatus &status)
NJointControllersWidgetEntry(NJointControllersWidget &parent, QTreeWidget &treeWidget, const NJointControllerDescription &desc)
void valueChangedSlot(std::string name, VariantBasePtr value) override
NJointControllersWidgetRemoteFunction(QTreeWidget &treeWidget, QTreeWidgetItem &header, const std::string &functionName, const NJointControllerInterfacePrx &ctrl, const WidgetDescription::WidgetPtr &w)
virtual void nJointControllerDeleted(std::string name)
void loadSettings(QSettings *settings) override
void saveSettings(QSettings *settings) override
virtual void nJointControllerCreated(std::string name)
void nJointControllerStatusChanged(const NJointControllerStatusSeq &allStatus)
::IceInternal::Handle<::armarx::WidgetDescription::Widget > WidgetPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr