Ignition Gazebo

API Reference

6.1.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 
25 #include <sdf/Material.hh>
26 #include <sdf/Physics.hh>
27 
28 #include <ignition/math/Pose3.hh>
29 #include <ignition/math/Vector3.hh>
30 
33 #include <ignition/gazebo/Types.hh>
34 
35 #include <ignition/msgs/light.pb.h>
36 
38 
39 namespace ignition
40 {
41 namespace gazebo
42 {
43  class ComponentInspectorPrivate;
44 
48  template <class DataType>
49  void setData(QStandardItem *_item, const DataType &_data)
50  {
51  // cppcheck-suppress syntaxError
52  // cppcheck-suppress unmatchedSuppression
54  {
56  ss << _data;
57  setData(_item, ss.str());
58  }
59  else
60  {
61  ignwarn << "Attempting to set unsupported data type to item ["
62  << _item->text().toStdString() << "]" << std::endl;
63  }
64  }
65 
69  template<>
70  void setData(QStandardItem *_item, const std::string &_data);
71 
75  template<>
76  void setData(QStandardItem *_item, const math::Pose3d &_data);
77 
81  template<>
82  void setData(QStandardItem *_item, const msgs::Light &_data);
83 
87  template<>
88  void setData(QStandardItem *_item, const math::Vector3d &_data);
89 
93  template<>
94  void setData(QStandardItem *_item, const sdf::Physics &_data);
95 
99  template<>
100  void setData(QStandardItem *_item, const math::SphericalCoordinates &_data);
101 
105  template<>
106  void setData(QStandardItem *_item, const bool &_data);
107 
111  template<>
112  void setData(QStandardItem *_item, const int &_data);
113 
117  template<>
118  void setData(QStandardItem *_item, const double &_data);
119 
123  template<>
124  void setData(QStandardItem *_item, const std::ostream &_data);
125 
129  template<>
130  void setData(QStandardItem *_item, const sdf::Material &_data);
131 
132 
136  void setUnit(QStandardItem *_item, const std::string &_unit);
137 
140  class ComponentsModel : public QStandardItemModel
141  {
142  Q_OBJECT
143 
145  public: explicit ComponentsModel();
146 
148  public: ~ComponentsModel() override = default;
149 
150  // Documentation inherited
151  public: QHash<int, QByteArray> roleNames() const override;
152 
155  public: static QHash<int, QByteArray> RoleNames();
156 
160  public slots: QStandardItem *AddComponentType(
162 
165  public slots: void RemoveComponentType(
167 
170  };
171 
176  class ComponentInspector : public gazebo::GuiSystem
177  {
178  Q_OBJECT
179 
181  Q_PROPERTY(
182  Entity entity
183  READ GetEntity
184  WRITE SetEntity
185  NOTIFY EntityChanged
186  )
187 
188 
189  Q_PROPERTY(
190  QString type
191  READ Type
192  WRITE SetType
193  NOTIFY TypeChanged
194  )
195 
196 
197  Q_PROPERTY(
198  bool locked
199  READ Locked
200  WRITE SetLocked
201  NOTIFY LockedChanged
202  )
203 
204 
205  Q_PROPERTY(
206  bool paused
207  READ Paused
208  WRITE SetPaused
209  NOTIFY PausedChanged
210  )
211 
212 
213  Q_PROPERTY(
214  bool nestedModel
215  READ NestedModel
216  NOTIFY NestedModelChanged
217  )
218 
219 
220  public: ComponentInspector();
221 
223  public: ~ComponentInspector() override;
224 
225  // Documentation inherited
226  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
227 
228  // Documentation inherited
229  public: void Update(const UpdateInfo &, EntityComponentManager &) override;
230 
238  public: Q_INVOKABLE void OnPose(double _x, double _y, double _z,
239  double _roll, double _pitch, double _yaw);
240 
263  public: Q_INVOKABLE void OnLight(
264  double _rSpecular, double _gSpecular, double _bSpecular,
265  double _aSpecular, double _rDiffuse, double _gDiffuse,
266  double _bDiffuse, double _aDiffuse, double _attRange,
267  double _attLinear, double _attConstant, double _attQuadratic,
268  bool _castShadows, double _directionX, double _directionY,
269  double _directionZ, double _innerAngle, double _outerAngle,
270  double _falloff, double _intensity, int _type);
271 
275  public: Q_INVOKABLE void OnPhysics(double _stepSize,
276  double _realTimeFactor);
277 
278  // \brief Callback in Qt thread when material color changes for a visual
299  public: Q_INVOKABLE void OnMaterialColor(
300  double _rAmbient, double _gAmbient, double _bAmbient,
301  double _aAmbient, double _rDiffuse, double _gDiffuse,
302  double _bDiffuse, double _aDiffuse, double _rSpecular,
303  double _gSpecular, double _bSpecular, double _aSpecular,
304  double _rEmissive, double _gEmissive, double _bEmissive,
305  double _aEmissive, QString _type, QColor _currColor);
306 
313  public: Q_INVOKABLE void OnSphericalCoordinates(QString _surface,
314  double _latitude, double _longitude, double _elevation,
315  double _heading);
316 
319  public: Q_INVOKABLE bool NestedModel() const;
320 
322  signals: void NestedModelChanged();
323 
324  // Documentation inherited
325  protected: bool eventFilter(QObject *_obj, QEvent *_event) override;
326 
329  public: Q_INVOKABLE Entity GetEntity() const;
330 
333  public: Q_INVOKABLE void SetEntity(const Entity &_entity);
334 
336  signals: void EntityChanged();
337 
340  public: Q_INVOKABLE QString Type() const;
341 
344  public: Q_INVOKABLE void SetType(const QString &_entity);
345 
347  signals: void TypeChanged();
348 
351  public: Q_INVOKABLE bool Locked() const;
352 
355  public: Q_INVOKABLE void SetLocked(bool _locked);
356 
358  signals: void LockedChanged();
359 
362  public: Q_INVOKABLE bool Paused() const;
363 
366  public: Q_INVOKABLE void SetPaused(bool _paused);
367 
369  signals: void PausedChanged();
370 
374  };
375 }
376 }
377 
378 #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:90
Component< math::SphericalCoordinates, class SphericalCoordinatesTag, serializers::SphericalCoordinatesSerializer > SphericalCoordinates
This component holds the spherical coordinates of the world origin.
Definition: SphericalCoordinates.hh:45
Component< sdf::Material, class MaterialTag, serializers::MaterialSerializer > Material
This component holds an entity&#39;s material.
Definition: Material.hh:44
Component< sdf::Light, class LightTag, serializers::LightSerializer > Light
This component contains light source information. For more information on lights, see SDF&#39;s Light ele...
Definition: Light.hh:48
STL class.
Vector3< double > Vector3d
Q_DECLARE_METATYPE(ComponentTypeId) namespace ignition
Definition: ComponentInspector.hh:37
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:50
#define ignwarn