Ignition Gazebo

API Reference

3.9.0
ComponentInspector.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 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 
18 #ifndef IGNITION_GAZEBO_GUI_COMPONENTINSPECTOR_HH_
19 #define IGNITION_GAZEBO_GUI_COMPONENTINSPECTOR_HH_
20 
21 #include <map>
22 #include <memory>
23 #include <string>
24 #include <ignition/math/Pose3.hh>
25 #include <ignition/math/Vector3.hh>
26 
29 #include <ignition/gazebo/Types.hh>
30 
32 
34 
35 namespace ignition
36 {
37 namespace gazebo
38 {
39  class ComponentInspectorPrivate;
40 
44  template <class DataType>
45  void setData(QStandardItem *_item, const DataType &_data)
46  {
47  // cppcheck-suppress syntaxError
48  // cppcheck-suppress unmatchedSuppression
50  {
52  ss << _data;
53  setData(_item, ss.str());
54  }
55  else
56  {
57  ignwarn << "Attempting to set unsupported data type to item ["
58  << _item->text().toStdString() << "]" << std::endl;
59  }
60  }
61 
65  template<>
66  void setData(QStandardItem *_item, const std::string &_data);
67 
71  template<>
72  void setData(QStandardItem *_item, const math::Pose3d &_data);
73 
77  template<>
78  void setData(QStandardItem *_item, const math::Vector3d &_data);
79 
83  template<>
84  void setData(QStandardItem *_item, const sdf::Physics &_data);
85 
89  template<>
90  void setData(QStandardItem *_item, const bool &_data);
91 
95  template<>
96  void setData(QStandardItem *_item, const int &_data);
97 
101  template<>
102  void setData(QStandardItem *_item, const double &_data);
103 
107  template<>
108  void setData(QStandardItem *_item, const std::ostream &_data);
109 
113  void setUnit(QStandardItem *_item, const std::string &_unit);
114 
117  class ComponentsModel : public QStandardItemModel
118  {
119  Q_OBJECT
120 
122  public: explicit ComponentsModel();
123 
125  public: ~ComponentsModel() override = default;
126 
127  // Documentation inherited
128  public: QHash<int, QByteArray> roleNames() const override;
129 
132  public: static QHash<int, QByteArray> RoleNames();
133 
137  public slots: QStandardItem *AddComponentType(
139 
142  public slots: void RemoveComponentType(
144 
147  };
148 
153  class ComponentInspector : public gazebo::GuiSystem
154  {
155  Q_OBJECT
156 
158  Q_PROPERTY(
159  int entity
160  READ Entity
161  WRITE SetEntity
162  NOTIFY EntityChanged
163  )
164 
165 
166  Q_PROPERTY(
167  QString type
168  READ Type
169  WRITE SetType
170  NOTIFY TypeChanged
171  )
172 
173 
174  Q_PROPERTY(
175  bool locked
176  READ Locked
177  WRITE SetLocked
178  NOTIFY LockedChanged
179  )
180 
181 
182  Q_PROPERTY(
183  bool paused
184  READ Paused
185  WRITE SetPaused
186  NOTIFY PausedChanged
187  )
188 
189 
190  Q_PROPERTY(
191  bool nestedModel
192  READ NestedModel
193  NOTIFY NestedModelChanged
194  )
195 
196 
197  public: ComponentInspector();
198 
200  public: ~ComponentInspector() override;
201 
202  // Documentation inherited
203  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
204 
205  // Documentation inherited
206  public: void Update(const UpdateInfo &, EntityComponentManager &) override;
207 
215  public: Q_INVOKABLE void OnPose(double _x, double _y, double _z,
216  double _roll, double _pitch, double _yaw);
217 
221  public: Q_INVOKABLE void OnPhysics(double _stepSize,
222  double _realTimeFactor);
223 
226  public: Q_INVOKABLE bool NestedModel() const;
227 
229  signals: void NestedModelChanged();
230 
231  // Documentation inherited
232  protected: bool eventFilter(QObject *_obj, QEvent *_event) override;
233 
236  public: Q_INVOKABLE int Entity() const;
237 
240  public: Q_INVOKABLE void SetEntity(const int &_entity);
241 
243  signals: void EntityChanged();
244 
247  public: Q_INVOKABLE QString Type() const;
248 
251  public: Q_INVOKABLE void SetType(const QString &_entity);
252 
254  signals: void TypeChanged();
255 
258  public: Q_INVOKABLE bool Locked() const;
259 
262  public: Q_INVOKABLE void SetLocked(bool _locked);
263 
265  signals: void LockedChanged();
266 
269  public: Q_INVOKABLE bool Paused() const;
270 
273  public: Q_INVOKABLE void SetPaused(bool _paused);
274 
276  signals: void PausedChanged();
277 
281  };
282 }
283 }
284 
285 #endif
T endl(T... args)
STL class.
STL class.
Pose3< double > Pose3d
T str(T... args)
uint64_t ComponentTypeId
A unique identifier for a component type. A component type must be derived from components::BaseCompo...
Definition: Types.hh:87
STL class.
Vector3< double > Vector3d
Q_DECLARE_METATYPE(ComponentTypeId) namespace ignition
Definition: ComponentInspector.hh:33
This library is part of the Ignition Robotics project.
static constexpr bool value
Definition: Component.hh:72
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light. At its core, an Entity is just an identifier.
Definition: Entity.hh:59
STL class.
Component< sdf::Physics, class PhysicsTag, serializers::PhysicsSerializer > Physics
A component type that contains the physics properties of the World entity.
Definition: include/ignition/gazebo/components/Physics.hh:48
#define ignwarn