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