RobotUnitWidgetBase.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 <boost/thread.hpp>
29
30#include <QCheckBox>
31#include <QComboBox>
32#include <QFormLayout>
33#include <QHBoxLayout>
34#include <QLabel>
35#include <QLineEdit>
36#include <QPushButton>
37#include <QSettings>
38#include <QStackedWidget>
39#include <QTreeWidget>
40#include <QWidget>
41
42#include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
43
44namespace armarx
45{
46
47 class RobotUnitWidgetBase : public QWidget
48 {
49 Q_OBJECT
50
51 public:
52 explicit RobotUnitWidgetBase(QString name, QWidget* parent);
55
56 virtual void
57 loadSettings(QSettings*)
58 {
59 }
60
61 virtual void
62 saveSettings(QSettings*)
63 {
64 }
65
66 void setVisible(bool visible) override;
67 protected slots:
68 void updateContent();
69 private slots:
70 void doReset();
71
72 protected:
73 virtual QTreeWidget& getTreeWidget() = 0;
74 virtual QStackedWidget& getStackedWidget() = 0;
75 virtual QLabel& getResettigLabel() = 0;
76
77 virtual void
79 {
80 }
81
82 virtual void clearAll() = 0;
83 virtual void doContentUpdate() = 0;
84
85 virtual void getResetData() = 0;
86 /**
87 * @return true if all objects were added
88 */
89 virtual bool addOneFromResetData() = 0;
90
91 void timerEvent(QTimerEvent*) override;
92
94 mutable std::recursive_timed_mutex mutex;
95 std::atomic_bool gotResetData{false};
97 int resetCount{0};
98 std::atomic_bool isResetting{false};
99 std::atomic_bool doMetaCall{false};
100
101 private:
102 boost::thread _resetThread;
103 };
104
105 template <class UI>
107 {
108 public:
109 RobotUnitWidgetTemplateBase(QString name, QWidget* parent) :
110 RobotUnitWidgetBase(name, parent), ui{new UI}
111 {
112 ui->setupUi(this);
113 }
114
115 protected:
116 QTreeWidget&
117 getTreeWidget() final override
118 {
119 return *(ui->treeWidget);
120 }
121
122 QStackedWidget&
123 getStackedWidget() final override
124 {
125 return *(ui->stackedWidget);
126 }
127
128 QLabel&
129 getResettigLabel() final override
130 {
131 return *(ui->labelResetting);
132 }
133
134 UI* ui;
135 };
136} // namespace armarx
virtual QTreeWidget & getTreeWidget()=0
virtual void getResetData()=0
RobotUnitInterfacePrx robotUnit
virtual bool addOneFromResetData()=0
RobotUnitWidgetBase(QString name, QWidget *parent)
virtual QStackedWidget & getStackedWidget()=0
virtual void clearAll()=0
virtual void loadSettings(QSettings *)
virtual QLabel & getResettigLabel()=0
void reset(RobotUnitInterfacePrx ru)
void timerEvent(QTimerEvent *) override
virtual void saveSettings(QSettings *)
virtual void doContentUpdate()=0
std::recursive_timed_mutex mutex
void setVisible(bool visible) override
QLabel & getResettigLabel() final override
QTreeWidget & getTreeWidget() final override
RobotUnitWidgetTemplateBase(QString name, QWidget *parent)
QStackedWidget & getStackedWidget() final override
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotUnitInterface > RobotUnitInterfacePrx