RobotViewerGuiPlugin.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 ArmarX::Component::RobotViewerGuiPlugin
17* @author Nikolaus Vahrenkamp
18* @copyright 2015 KIT
19* @license http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21
22*/
23
24#pragma once
25
26/* ArmarX headers */
28
32
35
36/* Qt headers */
37#include <QMainWindow>
38
39#include <VirtualRobot/VirtualRobot.h>
40
41#include <Inventor/sensors/SoTimerSensor.h>
42
43// C++ includes
44#include <memory>
45
46// ui_RobotViewerGuiPlugin.h is included by the .cpp, not here: moc textually inlines every
47// #include it can resolve, and parsing the uic-generated header alongside this one
48// makes moc mis-qualify this class as Ui::armarx::*.
49namespace Ui
50{
51 class RobotViewerGuiPlugin;
52}
53
54namespace armarx
55{
56 class RobotViewerConfigDialog;
57
58 /**
59 \class RobotViewerGuiPlugin
60 \brief This plugin provides a generic widget showing a 3D model of the robot. The robot is articulated and moved according to the corresponding RemoteRobot.
61 Further, DebugDrawer methods are available.
62 \see RobotViewerWidget
63 */
65 {
66 Q_OBJECT
67 Q_INTERFACES(ArmarXGuiInterface)
68 Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00")
69 public:
71
72 QString
73 getPluginName() override
74 {
75 return "RobotViewerGuiPlugin";
76 }
77 };
78
79 /**
80 \page RobotAPI-GuiPlugins-RobotViewerPlugin RobotViewerPlugin
81
82 \brief This widget shows a 3D model of the robot. The robot is articulated and moved according to the corresponding RemoteRobot.
83 Further, DebugDrawer methods are available.
84 \image html RobotViewerGUI.png
85 When you add the widget to the Gui, you need to specify the following parameters:
86
87 Parameter Name | Example Value | Required? | Description
88 :---------------- | :-------------: | :-------------- |:--------------------
89 Proxy | RobotStateComponent | Yes | The name of the robot state component.
90 */
92 public ArmarXComponentWidgetControllerTemplate<RobotViewerWidgetController>,
93 public RobotStateListenerInterface
94 {
95 Q_OBJECT
96 public:
98
99 // Defined in the .cpp, where Ui::RobotViewerGuiPlugin is complete.
101 // inherited from Component
102 void onInitComponent() override;
103 void onConnectComponent() override;
104 void onDisconnectComponent() override;
105 void onExitComponent() override;
106
107 // inherited from ArmarXWidget
108 static QString
110 {
111 return "Visualization.RobotViewerGUI";
112 }
113
114 QPointer<QDialog> getConfigDialog(QWidget* parent = 0) override;
115 void loadSettings(QSettings* settings) override;
116 void saveSettings(QSettings* settings) override;
117 void configured() override;
118
119 SoNode* getScene() override;
120
121 // overwrite setMutex, so that we can inform the debugdrawer
122 void setMutex3D(RecursiveMutexPtr const& mutex3D) override;
123
124 signals:
127
128 public slots:
129 void updateRobotVisu();
130 void inflateCollisionModel(int inflationValueMM);
131
132 protected:
133 void connectSlots();
134
135 std::unique_ptr<Ui::RobotViewerGuiPlugin> ui;
136
138
139
142
145
147
148 SoSeparator* rootVisu;
149 SoSeparator* robotVisu;
150
151 SoTimerSensor* timerSensor;
152
153 SoSeparator* debugLayerVisu;
155
156 static void timerCB(void* data, SoSensor* sensor);
157 void setRobotVisu(bool colModel);
158
159 protected slots:
160 void showVisuLayers(bool show);
161 void showRoot(bool show);
162 void showRobot(bool show);
163 void colModel(bool c);
164
165 void updateStateSettings(int);
166 void copyToClipboard();
167 void updateState();
169
170 private:
171 // init stuff
172 VirtualRobot::RobotPtr loadRobotFile(std::string fileName);
173
174 VirtualRobot::CoinVisualizationPtr getCoinVisualization(VirtualRobot::RobotPtr robot);
175
176 QPointer<QWidget> __widget;
177 QPointer<SimpleConfigDialog> dialog;
178
179 // ArmarXWidgetController interface
180 public:
181 static QIcon
183 {
184 return QIcon(":icons/armarx-gui.png");
185 }
186
187 // RobotStateListenerInterface interface
188 public:
189 void reportGlobalRobotRootPose(const FramedPoseBasePtr& pose,
190 Ice::Long timestamp,
191 bool poseChanged,
192 const Ice::Current&) override;
193 void reportJointValues(const NameValueMap& jointAngles,
194 Ice::Long timestamp,
195 bool aValueChanged,
196 const Ice::Current&) override;
197 };
198
199 using RobotViewerGuiPluginPtr = std::shared_ptr<RobotViewerWidgetController>;
200} // namespace armarx
std::string timestamp()
constexpr T c
The main gui interface.
std::shared_ptr< RecursiveMutex > RecursiveMutexPtr
std::shared_ptr< std::recursive_mutex > mutex3D
void onInitComponent() override
Pure virtual hook for the subclass.
void onDisconnectComponent() override
Hook for subclass.
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
SoNode * getScene() override
Reimplementing this function and returning a SoNode* will show this SoNode in the 3DViewerWidget,...
void setMutex3D(RecursiveMutexPtr const &mutex3D) override
This mutex is used to protect 3d scene updates. Usually called by the ArmarXGui main window on creati...
armarx::DebugDrawerComponentPtr debugDrawer
QPointer< QDialog > getConfigDialog(QWidget *parent=0) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
void onConnectComponent() override
Pure virtual hook for the subclass.
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
void reportJointValues(const NameValueMap &jointAngles, Ice::Long timestamp, bool aValueChanged, const Ice::Current &) override
std::unique_ptr< Ui::RobotViewerGuiPlugin > ui
void inflateCollisionModel(int inflationValueMM)
RobotStateComponentInterfacePrx robotStateComponentPrx
void onExitComponent() override
Hook for subclass.
void reportGlobalRobotRootPose(const FramedPoseBasePtr &pose, Ice::Long timestamp, bool poseChanged, const Ice::Current &) override
static void timerCB(void *data, SoSensor *sensor)
ArmarX Headers.
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< DebugDrawerComponent > DebugDrawerComponentPtr
std::shared_ptr< RobotViewerWidgetController > RobotViewerGuiPluginPtr
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx