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 <RobotAPI/gui-plugins/DebugDrawerGuiPlugin/ui_DebugDrawerGuiPluginWidget.h>
26
27#include <string>
28
29#include <Ice/UUID.h>
30
31#include <VirtualRobot/MathTools.h>
32
34
35namespace armarx
36{
38 _layerName{Ice::generateUUID()}, _debugDrawer{_layerName}
39 {
41 _ui = std::make_unique<Ui::DebugDrawerGuiPluginWidget>();
42 _ui->setupUi(getWidget());
43 connect(_ui->pushButtonLayerClear,
44 SIGNAL(clicked()),
45 this,
46 SLOT(on_pushButtonLayerClear_clicked()));
47 connect(_ui->pushButtonPoseDelete,
48 SIGNAL(clicked()),
49 this,
50 SLOT(on_pushButtonPoseDelete_clicked()));
51 connect(_ui->pushButtonArrowDelete,
52 SIGNAL(clicked()),
53 this,
54 SLOT(on_pushButtonArrowDelete_clicked()));
55
56 connect(_ui->doubleSpinBoxPoseTX, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
57 connect(_ui->doubleSpinBoxPoseTY, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
58 connect(_ui->doubleSpinBoxPoseTZ, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
59 connect(_ui->doubleSpinBoxPoseRX, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
60 connect(_ui->doubleSpinBoxPoseRY, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
61 connect(_ui->doubleSpinBoxPoseRZ, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
62 connect(_ui->doubleSpinBoxPoseScale, SIGNAL(valueChanged(double)), this, SLOT(updatePose()));
63
64 connect(_ui->doubleSpinBoxArrowFX, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
65 connect(_ui->doubleSpinBoxArrowFY, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
66 connect(_ui->doubleSpinBoxArrowFZ, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
67 connect(_ui->doubleSpinBoxArrowTX, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
68 connect(_ui->doubleSpinBoxArrowTY, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
69 connect(_ui->doubleSpinBoxArrowTZ, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
70 connect(
71 _ui->doubleSpinBoxArrowClrR, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
72 connect(
73 _ui->doubleSpinBoxArrowClrG, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
74 connect(
75 _ui->doubleSpinBoxArrowClrB, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
76 connect(
77 _ui->doubleSpinBoxArrowClrA, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
78 connect(
79 _ui->doubleSpinBoxArrowWidth, SIGNAL(valueChanged(double)), this, SLOT(updateArrow()));
80 }
81
85
86 void
90
91 void
95
96 void
102
103 void
105 {
107 _debugDrawer.setDebugDrawer(getTopic<DebugDrawerInterfacePrx>(_debugDrawerTopicName));
108 }
109
110 void
112 {
113 _debugDrawer.clearLayer();
114 }
115
116 void
117 DebugDrawerGuiPluginWidgetController::on_pushButtonArrowDelete_clicked()
118 {
119 const auto name = _ui->lineEditArrowName->text().toStdString();
120 ARMARX_INFO << "Delete arrow " << name;
121 _debugDrawer.getDebugDrawer()->removePoseVisu(_layerName, name);
122 }
123
124 void
125 DebugDrawerGuiPluginWidgetController::on_pushButtonPoseDelete_clicked()
126 {
127 const auto name = _ui->lineEditPoseName->text().toStdString();
128 ARMARX_INFO << "Delete pose " << name;
129 _debugDrawer.getDebugDrawer()->removePoseVisu(_layerName, name);
130 }
131
132 void
133 DebugDrawerGuiPluginWidgetController::on_pushButtonLayerClear_clicked()
134 {
135 _debugDrawer.clearLayer();
136 }
137
138 void
139 DebugDrawerGuiPluginWidgetController::updatePose()
140 {
141 const auto name = _ui->lineEditPoseName->text().toStdString();
142 ARMARX_INFO << "Updated pose " << name;
143
144 const float deg2rad = M_PI / 360;
145
146 _debugDrawer.drawPose(
147 name,
148 VirtualRobot::MathTools::posrpy2eigen4f(_ui->doubleSpinBoxPoseTX->value(),
149 _ui->doubleSpinBoxPoseTY->value(),
150 _ui->doubleSpinBoxPoseTZ->value(),
151 _ui->doubleSpinBoxPoseRX->value() * deg2rad,
152 _ui->doubleSpinBoxPoseRY->value() * deg2rad,
153 _ui->doubleSpinBoxPoseRZ->value() * deg2rad),
154 _ui->doubleSpinBoxPoseScale->value());
155 }
156
157 void
158 DebugDrawerGuiPluginWidgetController::updateArrow()
159 {
160 const Eigen::Vector3f from{static_cast<float>(_ui->doubleSpinBoxArrowFX->value()),
161 static_cast<float>(_ui->doubleSpinBoxArrowFY->value()),
162 static_cast<float>(_ui->doubleSpinBoxArrowFZ->value())};
163
164 const Eigen::Vector3f to{static_cast<float>(_ui->doubleSpinBoxArrowTX->value()),
165 static_cast<float>(_ui->doubleSpinBoxArrowTY->value()),
166 static_cast<float>(_ui->doubleSpinBoxArrowTZ->value())};
167
168 const Eigen::Vector3f dir = to - from;
169
170 const float len = dir.norm();
171
172 const auto name = _ui->lineEditArrowName->text().toStdString();
173 ARMARX_INFO << "Updated arrow " << name;
174
175 _debugDrawer.drawArrow(name,
176 from,
177 dir.normalized(),
178 {static_cast<float>(_ui->doubleSpinBoxArrowClrR->value()),
179 static_cast<float>(_ui->doubleSpinBoxArrowClrG->value()),
180 static_cast<float>(_ui->doubleSpinBoxArrowClrB->value()),
181 static_cast<float>(_ui->doubleSpinBoxArrowClrA->value())},
182 len,
183 static_cast<float>(_ui->doubleSpinBoxArrowWidth->value()));
184 }
185} // 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:179
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:75