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