RobotAPIVariantWidget.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::ArmarXObjects::RobotAPIVariantWidget
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
24
25#include <QFormLayout>
26#include <QLabel>
27#include <QString>
28#include <QTableWidget>
29#include <QVBoxLayout>
30
32
33#include <RobotAPI/interface/core/FramedPoseBase.h>
34#include <RobotAPI/interface/core/LinkedPoseBase.h>
35#include <RobotAPI/interface/core/OrientedPoint.h>
36#include <RobotAPI/interface/core/PoseBase.h>
37
38namespace armarx::detail
39{
43} // namespace armarx::detail
44
46{
48 {
49 public:
50 Vector2BaseWidget(const VariantDataPtr& v)
51 {
52 auto l = new QFormLayout;
53 l->setContentsMargins(0, 0, 0, 0);
54 setLayout(l);
55 labelX = new QLabel;
56 labelY = new QLabel;
57 l->addRow("X", labelX);
58 l->addRow("Y", labelY);
59 update(v);
60 }
61
62 void
63 update(const VariantDataPtr& p) override
64 {
65 Vector2BasePtr v = Vector2BasePtr::dynamicCast(p);
67 labelX->setText(QString::number(v->x));
68 labelY->setText(QString::number(v->y));
69 }
70
71 private:
72 QLabel* labelX;
73 QLabel* labelY;
74 };
75
78
80 {
81 public:
82 Vector3BaseWidget(const VariantDataPtr& v)
83 {
84 auto l = new QFormLayout;
85 l->setContentsMargins(0, 0, 0, 0);
86 setLayout(l);
87 labelX = new QLabel;
88 labelY = new QLabel;
89 labelZ = new QLabel;
90 l->addRow("X", labelX);
91 l->addRow("Y", labelY);
92 l->addRow("Z", labelZ);
93 update(v);
94 }
95
96 void
97 update(const VariantDataPtr& p) override
98 {
99 Vector3BasePtr v = Vector3BasePtr::dynamicCast(p);
101 labelX->setText(QString::number(v->x));
102 labelY->setText(QString::number(v->y));
103 labelZ->setText(QString::number(v->z));
104 }
105
106 private:
107 QLabel* labelX;
108 QLabel* labelY;
109 QLabel* labelZ;
110 };
111
114
116 {
117 public:
118 FramedPositionBaseWidget(const VariantDataPtr& v)
119 {
120 auto l = new QFormLayout;
121 l->setContentsMargins(0, 0, 0, 0);
122 setLayout(l);
123 labelAg = new QLabel;
124 labelFr = new QLabel;
125 labelX = new QLabel;
126 labelY = new QLabel;
127 labelZ = new QLabel;
128 l->addRow("Agent", labelAg);
129 l->addRow("Frame", labelFr);
130 l->addRow("X", labelX);
131 l->addRow("Y", labelY);
132 l->addRow("Z", labelZ);
133 update(v);
134 }
135
136 void
137 update(const VariantDataPtr& p) override
138 {
139 FramedPositionBasePtr v = FramedPositionBasePtr::dynamicCast(p);
141 labelAg->setText(QString::fromStdString(v->agent));
142 labelFr->setText(QString::fromStdString(v->frame));
143 labelX->setText(QString::number(v->x));
144 labelY->setText(QString::number(v->y));
145 labelZ->setText(QString::number(v->z));
146 }
147
148 private:
149 QLabel* labelAg;
150 QLabel* labelFr;
151 QLabel* labelX;
152 QLabel* labelY;
153 QLabel* labelZ;
154 };
155
158
160 {
161 public:
162 FramedDirectionBaseWidget(const VariantDataPtr& v)
163 {
164 auto l = new QFormLayout;
165 l->setContentsMargins(0, 0, 0, 0);
166 setLayout(l);
167 labelAg = new QLabel;
168 labelFr = new QLabel;
169 labelX = new QLabel;
170 labelY = new QLabel;
171 labelZ = new QLabel;
172 l->addRow("Agent", labelAg);
173 l->addRow("Frame", labelFr);
174 l->addRow("X", labelX);
175 l->addRow("Y", labelY);
176 l->addRow("Z", labelZ);
177 update(v);
178 }
179
180 void
181 update(const VariantDataPtr& p) override
182 {
183 FramedDirectionBasePtr v = FramedDirectionBasePtr::dynamicCast(p);
185 labelAg->setText(QString::fromStdString(v->agent));
186 labelFr->setText(QString::fromStdString(v->frame));
187 labelX->setText(QString::number(v->x));
188 labelY->setText(QString::number(v->y));
189 labelZ->setText(QString::number(v->z));
190 }
191
192 private:
193 QLabel* labelAg;
194 QLabel* labelFr;
195 QLabel* labelX;
196 QLabel* labelY;
197 QLabel* labelZ;
198 };
199
200 VariantDataWidgetFactoryRegistration<FramedDirectionBaseWidget>
201 registerFramedDirectionBaseWidget{FramedDirectionBase::ice_staticId()};
202
204 {
205 public:
206 OrientedPointBaseWidget(const VariantDataPtr& v)
207 {
208 auto l = new QFormLayout;
209 l->setContentsMargins(0, 0, 0, 0);
210 setLayout(l);
211 labelPX = new QLabel;
212 labelPY = new QLabel;
213 labelPZ = new QLabel;
214 labelNX = new QLabel;
215 labelNY = new QLabel;
216 labelNZ = new QLabel;
217 l->addRow("PX", labelPX);
218 l->addRow("PY", labelPY);
219 l->addRow("PZ", labelPZ);
220 l->addRow("NX", labelNX);
221 l->addRow("NY", labelNY);
222 l->addRow("NZ", labelNZ);
223 update(v);
224 }
225
226 void
227 update(const VariantDataPtr& p) override
228 {
229 OrientedPointBasePtr v = OrientedPointBasePtr::dynamicCast(p);
231 labelPX->setText(QString::number(v->px));
232 labelPY->setText(QString::number(v->py));
233 labelPZ->setText(QString::number(v->pz));
234 labelNX->setText(QString::number(v->nx));
235 labelNY->setText(QString::number(v->ny));
236 labelNZ->setText(QString::number(v->nz));
237 }
238
239 private:
240 QLabel* labelPX;
241 QLabel* labelPY;
242 QLabel* labelPZ;
243 QLabel* labelNX;
244 QLabel* labelNY;
245 QLabel* labelNZ;
246 };
247
250
252 {
253 public:
254 FramedOrientedPointBaseWidget(const VariantDataPtr& v)
255 {
256 auto l = new QFormLayout;
257 l->setContentsMargins(0, 0, 0, 0);
258 setLayout(l);
259 labelAg = new QLabel;
260 labelFr = new QLabel;
261 labelPX = new QLabel;
262 labelPY = new QLabel;
263 labelPZ = new QLabel;
264 labelNX = new QLabel;
265 labelNY = new QLabel;
266 labelNZ = new QLabel;
267 l->addRow("Agent", labelAg);
268 l->addRow("Frame", labelFr);
269 l->addRow("PX", labelPX);
270 l->addRow("PY", labelPY);
271 l->addRow("PZ", labelPZ);
272 l->addRow("NX", labelNX);
273 l->addRow("NY", labelNY);
274 l->addRow("NZ", labelNZ);
275 update(v);
276 }
277
278 void
279 update(const VariantDataPtr& p) override
280 {
281 FramedOrientedPointBasePtr v = FramedOrientedPointBasePtr::dynamicCast(p);
283 labelAg->setText(QString::fromStdString(v->agent));
284 labelFr->setText(QString::fromStdString(v->frame));
285 labelPX->setText(QString::number(v->px));
286 labelPY->setText(QString::number(v->py));
287 labelPZ->setText(QString::number(v->pz));
288 labelNX->setText(QString::number(v->nx));
289 labelNY->setText(QString::number(v->ny));
290 labelNZ->setText(QString::number(v->nz));
291 }
292
293 private:
294 QLabel* labelAg;
295 QLabel* labelFr;
296 QLabel* labelPX;
297 QLabel* labelPY;
298 QLabel* labelPZ;
299 QLabel* labelNX;
300 QLabel* labelNY;
301 QLabel* labelNZ;
302 };
303
304 VariantDataWidgetFactoryRegistration<FramedOrientedPointBaseWidget>
305 registerFramedOrientedPointBaseWidget{FramedOrientedPointBase::ice_staticId()};
306
308 {
309 public:
310 QuaternionBaseWidget(const VariantDataPtr& v)
311 {
312 auto l = new QFormLayout;
313 l->setContentsMargins(0, 0, 0, 0);
314 setLayout(l);
315 labelQW = new QLabel;
316 labelQX = new QLabel;
317 labelQY = new QLabel;
318 labelQZ = new QLabel;
319 l->addRow("QW", labelQW);
320 l->addRow("QX", labelQX);
321 l->addRow("QY", labelQY);
322 l->addRow("QZ", labelQZ);
323 update(v);
324 }
325
326 void
327 update(const VariantDataPtr& p) override
328 {
329 QuaternionBasePtr v = QuaternionBasePtr::dynamicCast(p);
331 labelQW->setText(QString::number(v->qw));
332 labelQX->setText(QString::number(v->qx));
333 labelQY->setText(QString::number(v->qy));
334 labelQZ->setText(QString::number(v->qz));
335 }
336
337 private:
338 QLabel* labelQW;
339 QLabel* labelQX;
340 QLabel* labelQY;
341 QLabel* labelQZ;
342 };
343
346
348 {
349 public:
350 FramedOrientationBaseWidget(const VariantDataPtr& v)
351 {
352 auto l = new QFormLayout;
353 l->setContentsMargins(0, 0, 0, 0);
354 setLayout(l);
355 labelAg = new QLabel;
356 labelFr = new QLabel;
357 labelQW = new QLabel;
358 labelQX = new QLabel;
359 labelQY = new QLabel;
360 labelQZ = new QLabel;
361 l->addRow("Agent", labelAg);
362 l->addRow("Frame", labelFr);
363 l->addRow("QW", labelQW);
364 l->addRow("QX", labelQX);
365 l->addRow("QY", labelQY);
366 l->addRow("QZ", labelQZ);
367 update(v);
368 }
369
370 void
371 update(const VariantDataPtr& p) override
372 {
373 FramedOrientationBasePtr v = FramedOrientationBasePtr::dynamicCast(p);
375 labelAg->setText(QString::fromStdString(v->agent));
376 labelFr->setText(QString::fromStdString(v->frame));
377 labelQW->setText(QString::number(v->qw));
378 labelQX->setText(QString::number(v->qx));
379 labelQY->setText(QString::number(v->qy));
380 labelQZ->setText(QString::number(v->qz));
381 }
382
383 private:
384 QLabel* labelAg;
385 QLabel* labelFr;
386 QLabel* labelQW;
387 QLabel* labelQX;
388 QLabel* labelQY;
389 QLabel* labelQZ;
390 };
391
392 VariantDataWidgetFactoryRegistration<FramedOrientationBaseWidget>
393 registerFramedOrientationBaseWidget{FramedOrientationBase::ice_staticId()};
394
396 {
397 public:
398 PoseBaseWidget(const VariantDataPtr& v)
399 {
400 auto l = new QFormLayout;
401 l->setContentsMargins(0, 0, 0, 0);
402 setLayout(l);
403 labelX = new QLabel;
404 labelY = new QLabel;
405 labelZ = new QLabel;
406 labelQW = new QLabel;
407 labelQX = new QLabel;
408 labelQY = new QLabel;
409 labelQZ = new QLabel;
410 l->addRow("X", labelX);
411 l->addRow("Y", labelY);
412 l->addRow("Z", labelZ);
413 l->addRow("QW", labelQW);
414 l->addRow("QX", labelQX);
415 l->addRow("QY", labelQY);
416 l->addRow("QZ", labelQZ);
417 update(v);
418 }
419
420 void
421 update(const VariantDataPtr& p) override
422 {
423 PoseBasePtr v = PoseBasePtr::dynamicCast(p);
425 ARMARX_CHECK_EXPRESSION(v->position);
426 ARMARX_CHECK_EXPRESSION(v->orientation);
427 labelX->setText(QString::number(v->position->x));
428 labelY->setText(QString::number(v->position->y));
429 labelZ->setText(QString::number(v->position->z));
430 labelQW->setText(QString::number(v->orientation->qw));
431 labelQX->setText(QString::number(v->orientation->qx));
432 labelQY->setText(QString::number(v->orientation->qy));
433 labelQZ->setText(QString::number(v->orientation->qz));
434 }
435
436 private:
437 QLabel* labelX;
438 QLabel* labelY;
439 QLabel* labelZ;
440 QLabel* labelQW;
441 QLabel* labelQX;
442 QLabel* labelQY;
443 QLabel* labelQZ;
444 };
445
448
450 {
451 public:
452 FramedPoseBaseWidget(const VariantDataPtr& v)
453 {
454 auto l = new QFormLayout;
455 l->setContentsMargins(0, 0, 0, 0);
456 setLayout(l);
457 labelAg = new QLabel;
458 labelFr = new QLabel;
459 labelX = new QLabel;
460 labelY = new QLabel;
461 labelZ = new QLabel;
462 labelQW = new QLabel;
463 labelQX = new QLabel;
464 labelQY = new QLabel;
465 labelQZ = new QLabel;
466 l->addRow("Agent", labelAg);
467 l->addRow("Frame", labelFr);
468 l->addRow("X", labelX);
469 l->addRow("Y", labelY);
470 l->addRow("Z", labelZ);
471 l->addRow("QW", labelQW);
472 l->addRow("QX", labelQX);
473 l->addRow("QY", labelQY);
474 l->addRow("QZ", labelQZ);
475 update(v);
476 }
477
478 void
479 update(const VariantDataPtr& p) override
480 {
481 FramedPoseBasePtr v = FramedPoseBasePtr::dynamicCast(p);
483 ARMARX_CHECK_EXPRESSION(v->position);
484 ARMARX_CHECK_EXPRESSION(v->orientation);
485 labelAg->setText(QString::fromStdString(v->agent));
486 labelFr->setText(QString::fromStdString(v->frame));
487 labelX->setText(QString::number(v->position->x));
488 labelY->setText(QString::number(v->position->y));
489 labelZ->setText(QString::number(v->position->z));
490 labelQW->setText(QString::number(v->orientation->qw));
491 labelQX->setText(QString::number(v->orientation->qx));
492 labelQY->setText(QString::number(v->orientation->qy));
493 labelQZ->setText(QString::number(v->orientation->qz));
494 }
495
496 private:
497 QLabel* labelAg;
498 QLabel* labelFr;
499 QLabel* labelX;
500 QLabel* labelY;
501 QLabel* labelZ;
502 QLabel* labelQW;
503 QLabel* labelQX;
504 QLabel* labelQY;
505 QLabel* labelQZ;
506 };
507
510} // namespace armarx::VariantDataWidgets
void update(const VariantDataPtr &p) override
void update(const VariantDataPtr &p) override
void update(const VariantDataPtr &p) override
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
VariantDataWidgetFactoryRegistration< Vector3BaseWidget > registerVector3BaseWidget
VariantDataWidgetFactoryRegistration< FramedOrientationBaseWidget > registerFramedOrientationBaseWidget
VariantDataWidgetFactoryRegistration< FramedPositionBaseWidget > registerFramedPositionBaseWidget
VariantDataWidgetFactoryRegistration< QuaternionBaseWidget > registerQuaternionBaseWidget
VariantDataWidgetFactoryRegistration< FramedPoseBaseWidget > registerFramedPoseBaseWidget
VariantDataWidgetFactoryRegistration< FramedOrientedPointBaseWidget > registerFramedOrientedPointBaseWidget
VariantDataWidgetFactoryRegistration< OrientedPointBaseWidget > registerOrientedPointBaseWidget
VariantDataWidgetFactoryRegistration< Vector2BaseWidget > registerVector2BaseWidget
VariantDataWidgetFactoryRegistration< FramedDirectionBaseWidget > registerFramedDirectionBaseWidget
VariantDataWidgetFactoryRegistration< PoseBaseWidget > registerPoseBaseWidget