Gazebo Sim

API Reference

9.0.0
component_inspector/Pose3d.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17#ifndef GZ_SIM_GUI_COMPONENTINSPECTOR_POSE3D_HH_
18#define GZ_SIM_GUI_COMPONENTINSPECTOR_POSE3D_HH_
19
20#include <gz/math/Pose3.hh>
21
25
26#include "ComponentInspector.hh"
27#include "Types.hh"
28
29#include <QObject>
30#include <QStandardItem>
31
32namespace gz
33{
34namespace sim
35{
36class ComponentInspector;
37namespace inspector
38{
43 class Pose3d : public QObject
44 {
45 Q_OBJECT
46
49 public: explicit Pose3d(ComponentInspector *_inspector);
50
55 public:
56 template<typename ComponentType>
58 QStandardItem *_item)
59 {
60 if (nullptr == _item)
61 return;
62
63 auto comp = _ecm.Component<ComponentType>(this->inspector->GetEntity());
64 if (nullptr == comp)
65 return;
66
67 auto pose = comp->Data();
68
69 _item->setData(QString("Pose3d"),
70 ComponentsModel::RoleNames().key("dataType"));
71 _item->setData(QList({
72 QVariant(pose.Pos().X()),
73 QVariant(pose.Pos().Y()),
74 QVariant(pose.Pos().Z()),
75 QVariant(pose.Rot().Roll()),
76 QVariant(pose.Rot().Pitch()),
77 QVariant(pose.Rot().Yaw())
78 }), ComponentsModel::RoleNames().key("data"));
79 }
80
88 public: Q_INVOKABLE void OnPose(double _x, double _y, double _z,
89 double _roll, double _pitch, double _yaw);
90
93 private: ComponentInspector *inspector{nullptr};
94 };
95}
96}
97}
98#endif