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
34#include <RobotAPI/gui-plugins/RobotViewerPlugin/ui_RobotViewerGuiPlugin.h>
36
37/* Qt headers */
38#include <QMainWindow>
39
40#include <VirtualRobot/VirtualRobot.h>
41
42#include <Inventor/sensors/SoTimerSensor.h>
43
44namespace armarx
45{
46 class RobotViewerConfigDialog;
47
48 /**
49 \class RobotViewerGuiPlugin
50 \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.
51 Further, DebugDrawer methods are available.
52 \see RobotViewerWidget
53 */
55 {
56 Q_OBJECT
57 Q_INTERFACES(ArmarXGuiInterface)
58 Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00")
59 public:
61
62 QString
63 getPluginName() override
64 {
65 return "RobotViewerGuiPlugin";
66 }
67 };
68
69 /**
70 \page RobotAPI-GuiPlugins-RobotViewerPlugin RobotViewerPlugin
71
72 \brief This widget shows a 3D model of the robot. The robot is articulated and moved according to the corresponding RemoteRobot.
73 Further, DebugDrawer methods are available.
74 \image html RobotViewerGUI.png
75 When you add the widget to the Gui, you need to specify the following parameters:
76
77 Parameter Name | Example Value | Required? | Description
78 :---------------- | :-------------: | :-------------- |:--------------------
79 Proxy | RobotStateComponent | Yes | The name of the robot state component.
80 */
82 public ArmarXComponentWidgetControllerTemplate<RobotViewerWidgetController>,
83 public RobotStateListenerInterface
84 {
85 Q_OBJECT
86 public:
88
90 {
91 }
92
93 // inherited from Component
94 void onInitComponent() override;
95 void onConnectComponent() override;
96 void onDisconnectComponent() override;
97 void onExitComponent() override;
98
99 // inherited from ArmarXWidget
100 static QString
102 {
103 return "Visualization.RobotViewerGUI";
104 }
105
106 QPointer<QDialog> getConfigDialog(QWidget* parent = 0) override;
107 void loadSettings(QSettings* settings) override;
108 void saveSettings(QSettings* settings) override;
109 void configured() override;
110
111 SoNode* getScene() override;
112
113 // overwrite setMutex, so that we can inform the debugdrawer
114 void setMutex3D(RecursiveMutexPtr const& mutex3D) override;
115
116 signals:
119
120 public slots:
121 void updateRobotVisu();
122 void inflateCollisionModel(int inflationValueMM);
123
124 protected:
125 void connectSlots();
126
127
128 Ui::RobotViewerGuiPlugin ui;
129
131
132
135
138
140
141 SoSeparator* rootVisu;
142 SoSeparator* robotVisu;
143
144 SoTimerSensor* timerSensor;
145
146 SoSeparator* debugLayerVisu;
148
149 static void timerCB(void* data, SoSensor* sensor);
150 void setRobotVisu(bool colModel);
151
152 protected slots:
153 void showVisuLayers(bool show);
154 void showRoot(bool show);
155 void showRobot(bool show);
156 void colModel(bool c);
157
158 void updateStateSettings(int);
159 void copyToClipboard();
160 void updateState();
162
163 private:
164 // init stuff
165 VirtualRobot::RobotPtr loadRobotFile(std::string fileName);
166
167 VirtualRobot::CoinVisualizationPtr getCoinVisualization(VirtualRobot::RobotPtr robot);
168
169 QPointer<QWidget> __widget;
170 QPointer<SimpleConfigDialog> dialog;
171
172 // ArmarXWidgetController interface
173 public:
174 static QIcon
176 {
177 return QIcon(":icons/armarx-gui.png");
178 }
179
180 // RobotStateListenerInterface interface
181 public:
182 void reportGlobalRobotRootPose(const FramedPoseBasePtr& pose,
183 Ice::Long timestamp,
184 bool poseChanged,
185 const Ice::Current&) override;
186 void reportJointValues(const NameValueMap& jointAngles,
187 Ice::Long timestamp,
188 bool aValueChanged,
189 const Ice::Current&) override;
190 };
191
192 using RobotViewerGuiPluginPtr = std::shared_ptr<RobotViewerWidgetController>;
193} // 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
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)
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