DebugDrawerGuiPluginWidgetController.cpp
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::DebugDrawerGuiPluginWidgetController
17 * \author Raphael Grimm ( raphael dot grimm at kit dot edu )
18 * \date 2019
19 * \copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
24
25#include <string>
26
27#include <Ice/UUID.h>
28
29#include <VirtualRobot/MathTools.h>
30
32
33namespace armarx
34{
36 _layerName{Ice::generateUUID()}, _debugDrawer{_layerName}
37 {
39 _ui.setupUi(getWidget());
40 connect(_ui.pushButtonLayerClear,
41 SIGNAL(clicked()),
42 this,
43 SLOT(on_pushButtonLayerClear_clicked()));
44 connect(_ui.pushButtonPoseDelete,
45 SIGNAL(clicked()),
46 this,
47 SLOT(on_pushButtonPoseDelete_clicked()));
48 connect(_ui.pushButtonArrowDelete,
49 SIGNAL(clicked()),
50 this,
51 SLOT(on_pushButtonArrowDelete_clicked()));
52
53 connect(_ui.doubleSpinBoxPoseTX, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
54 connect(_ui.doubleSpinBoxPoseTY, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
55 connect(_ui.doubleSpinBoxPoseTZ, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
56 connect(_ui.doubleSpinBoxPoseRX, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
57 connect(_ui.doubleSpinBoxPoseRY, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
58 connect(_ui.doubleSpinBoxPoseRZ, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
59 connect(_ui.doubleSpinBoxPoseScale, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
60
61 connect(_ui.doubleSpinBoxArrowFX, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
62 connect(_ui.doubleSpinBoxArrowFY, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
63 connect(_ui.doubleSpinBoxArrowFZ, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
64 connect(_ui.doubleSpinBoxArrowTX, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
65 connect(_ui.doubleSpinBoxArrowTY, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
66 connect(_ui.doubleSpinBoxArrowTZ, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
67 connect(
68 _ui.doubleSpinBoxArrowClrR, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
69 connect(
70 _ui.doubleSpinBoxArrowClrG, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
71 connect(
72 _ui.doubleSpinBoxArrowClrB, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
73 connect(
74 _ui.doubleSpinBoxArrowClrA, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
75 connect(
76 _ui.doubleSpinBoxArrowWidth, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
77 }
78
82
83 void
87
88 void
92
93 void
99
100 void
102 {
104 _debugDrawer.setDebugDrawer(getTopic<DebugDrawerInterfacePrx>(_debugDrawerTopicName));
105 }
106
107 void
109 {
110 _debugDrawer.clearLayer();
111 }
112
113 void
114 DebugDrawerGuiPluginWidgetController::on_pushButtonArrowDelete_clicked()
115 {
116 const auto name = _ui.lineEditArrowName->text().toStdString();
117 ARMARX_INFO << "Delete arrow " << name;
118 _debugDrawer.getDebugDrawer()->removePoseVisu(_layerName, name);
119 }
120
121 void
122 DebugDrawerGuiPluginWidgetController::on_pushButtonPoseDelete_clicked()
123 {
124 const auto name = _ui.lineEditPoseName->text().toStdString();
125 ARMARX_INFO << "Delete pose " << name;
126 _debugDrawer.getDebugDrawer()->removePoseVisu(_layerName, name);
127 }
128
129 void
130 DebugDrawerGuiPluginWidgetController::on_pushButtonLayerClear_clicked()
131 {
132 _debugDrawer.clearLayer();
133 }
134
135 void
136 DebugDrawerGuiPluginWidgetController::updatePose()
137 {
138 const auto name = _ui.lineEditPoseName->text().toStdString();
139 ARMARX_INFO << "Updated pose " << name;
140
141 const float deg2rad = M_PI / 360;
142
143 _debugDrawer.drawPose(
144 name,
145 VirtualRobot::MathTools::posrpy2eigen4f(_ui.doubleSpinBoxPoseTX->value(),
146 _ui.doubleSpinBoxPoseTY->value(),
147 _ui.doubleSpinBoxPoseTZ->value(),
148 _ui.doubleSpinBoxPoseRX->value() * deg2rad,
149 _ui.doubleSpinBoxPoseRY->value() * deg2rad,
150 _ui.doubleSpinBoxPoseRZ->value() * deg2rad),
151 _ui.doubleSpinBoxPoseScale->value());
152 }
153
154 void
155 DebugDrawerGuiPluginWidgetController::updateArrow()
156 {
157 const Eigen::Vector3f from{static_cast<float>(_ui.doubleSpinBoxArrowFX->value()),
158 static_cast<float>(_ui.doubleSpinBoxArrowFY->value()),
159 static_cast<float>(_ui.doubleSpinBoxArrowFZ->value())};
160
161 const Eigen::Vector3f to{static_cast<float>(_ui.doubleSpinBoxArrowTX->value()),
162 static_cast<float>(_ui.doubleSpinBoxArrowTY->value()),
163 static_cast<float>(_ui.doubleSpinBoxArrowTZ->value())};
164
165 const Eigen::Vector3f dir = to - from;
166
167 const float len = dir.norm();
168
169 const auto name = _ui.lineEditArrowName->text().toStdString();
170 ARMARX_INFO << "Updated arrow " << name;
171
172 _debugDrawer.drawArrow(name,
173 from,
174 dir.normalized(),
175 {static_cast<float>(_ui.doubleSpinBoxArrowClrR->value()),
176 static_cast<float>(_ui.doubleSpinBoxArrowClrG->value()),
177 static_cast<float>(_ui.doubleSpinBoxArrowClrB->value()),
178 static_cast<float>(_ui.doubleSpinBoxArrowClrA->value())},
179 len,
180 static_cast<float>(_ui.doubleSpinBoxArrowWidth->value()));
181 }
182} // namespace armarx
#define M_PI
Definition MathTools.h:17
virtual QPointer< QWidget > getWidget()
getWidget returns a pointer to the a widget of this controller.
void onInitComponent() override
Pure virtual hook for the 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.
void onConnectComponent() override
Pure virtual hook for the subclass.
const DebugDrawerInterfacePrx & getDebugDrawer() const
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
TopicProxyType getTopic(const std::string &name)
Returns a proxy of the specified topic.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
state::Type from(Eigen::Vector3f targetPosition)
This file offers overloads of toIce() and fromIce() functions for STL container types.
#define ARMARX_TRACE
Definition trace.h:77