Ignition Gazebo

API Reference

6.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 
25 #include <sdf/Material.hh>
26 #include <sdf/Physics.hh>
27 
28 #include <ignition/math/Vector3.hh>
30 
33 #include <ignition/gazebo/Types.hh>
34 
35 #include "Types.hh"
36 
37 #include <ignition/msgs/light.pb.h>
38 
40 
41 namespace ignition
42 {
43 namespace gazebo
44 {
45  class ComponentInspectorPrivate;
46 
50  template <class DataType>
51  void setData(QStandardItem *_item, const DataType &_data)
52  {
53  // cppcheck-suppress syntaxError
54  // cppcheck-suppress unmatchedSuppression
56  {
58  ss << _data;
59  setData(_item, ss.str());
60  }
61  else
62  {
63  ignwarn << "Attempting to set unsupported data type to item ["
64  << _item->text().toStdString() << "]" << std::endl;
65  }
66  }
67 
71  template<>
72  void setData(QStandardItem *_item, const std::string &_data);
73 
77  template<>
78  void setData(QStandardItem *_item, const msgs::Light &_data);
79 
83  template<>
84  void setData(QStandardItem *_item, const math::Vector3d &_data);
85 
89  template<>
90  void setData(QStandardItem *_item, const sdf::Physics &_data);
91 
95  template<>
96  void setData(QStandardItem *_item, const math::SphericalCoordinates &_data);
97 
101  template<>
102  void setData(QStandardItem *_item, const bool &_data);
103 
107  template<>
108  void setData(QStandardItem *_item, const int &_data);
109 
113  template<>
114  void setData(QStandardItem *_item, const double &_data);
115 
119  template<>
120  void setData(QStandardItem *_item, const std::ostream &_data);
121 
125  template<>
126  void setData(QStandardItem *_item, const sdf::Material &_data);
127 
128 
132  void setUnit(QStandardItem *_item, const std::string &_unit);
133 
136  class ComponentsModel : public QStandardItemModel
137  {
138  Q_OBJECT
139 
141  public: explicit ComponentsModel();
142 
144  public: ~ComponentsModel() override = default;
145 
146  // Documentation inherited
147  public: QHash<int, QByteArray> roleNames() const override;
148 
151  public: static QHash<int, QByteArray> RoleNames();
152 
156  public slots: QStandardItem *AddComponentType(
158 
161  public slots: void RemoveComponentType(
163 
166  };
167 
172  class ComponentInspector : public gazebo::GuiSystem
173  {
174  Q_OBJECT
175 
177  Q_PROPERTY(
178  Entity entity
179  READ GetEntity
180  WRITE SetEntity
181  NOTIFY EntityChanged
182  )
183 
184 
185  Q_PROPERTY(
186  QString type
187  READ Type
188  WRITE SetType
189  NOTIFY TypeChanged
190  )
191 
192 
193  Q_PROPERTY(
194  bool locked
195  READ Locked
196  WRITE SetLocked
197  NOTIFY LockedChanged
198  )
199 
200 
201  Q_PROPERTY(
202  bool paused
203  READ Paused
204  WRITE SetPaused
205  NOTIFY PausedChanged
206  )
207 
208 
209  Q_PROPERTY(
210  bool nestedModel
211  READ NestedModel
212  NOTIFY NestedModelChanged
213  )
214 
215 
216  public: ComponentInspector();
217 
219  public: ~ComponentInspector() override;
220 
221  // Documentation inherited
222  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
223 
224  // Documentation inherited
225  public: void Update(const UpdateInfo &, EntityComponentManager &) override;
226 
231  public: void AddUpdateViewCb(ComponentTypeId _id,
233 
258  public: Q_INVOKABLE void OnLight(
259  double _rSpecular, double _gSpecular, double _bSpecular,
260  double _aSpecular, double _rDiffuse, double _gDiffuse,
261  double _bDiffuse, double _aDiffuse, double _attRange,
262  double _attLinear, double _attConstant, double _attQuadratic,
263  bool _castShadows, double _directionX, double _directionY,
264  double _directionZ, double _innerAngle, double _outerAngle,
265  double _falloff, double _intensity, int _type, bool _isLightOn,
266  bool _visualizeVisual);
267 
271  public: Q_INVOKABLE void OnPhysics(double _stepSize,
272  double _realTimeFactor);
273 
274  // \brief Callback in Qt thread when material color changes for a visual
295  public: Q_INVOKABLE void OnMaterialColor(
296  double _rAmbient, double _gAmbient, double _bAmbient,
297  double _aAmbient, double _rDiffuse, double _gDiffuse,
298  double _bDiffuse, double _aDiffuse, double _rSpecular,
299  double _gSpecular, double _bSpecular, double _aSpecular,
300  double _rEmissive, double _gEmissive, double _bEmissive,
301  double _aEmissive, QString _type, QColor _currColor);
302 
309  public: Q_INVOKABLE void OnSphericalCoordinates(QString _surface,
310  double _latitude, double _longitude, double _elevation,
311  double _heading);
312 
315  public: Q_INVOKABLE bool NestedModel() const;
316 
318  signals: void NestedModelChanged();
319 
320  // Documentation inherited
321  protected: bool eventFilter(QObject *_obj, QEvent *_event) override;
322 
325  public: Q_INVOKABLE Entity GetEntity() const;
326 
329  public: Q_INVOKABLE void SetEntity(const Entity &_entity);
330 
332  signals: void EntityChanged();
333 
336  public: Q_INVOKABLE QString Type() const;
337 
340  public: Q_INVOKABLE void SetType(const QString &_entity);
341 
343  signals: void TypeChanged();
344 
347  public: Q_INVOKABLE bool Locked() const;
348 
351  public: Q_INVOKABLE void SetLocked(bool _locked);
352 
354  signals: void LockedChanged();
355 
358  public: Q_INVOKABLE bool Paused() const;
359 
362  public: Q_INVOKABLE void SetPaused(bool _paused);
363 
365  signals: void PausedChanged();
366 
369  public: const std::string &WorldName() const;
370 
373  public: transport::Node &TransportNode();
374 
378  };
379 }
380 }
381 
382 #endif
T endl(T... args)
STL class.
STL class.
std::function< void(const EntityComponentManager &_ecm, QStandardItem *_item)> UpdateViewCb
Function definition that a component can use to update its UI elements based on changes from the ECM...
Definition: src/gui/plugins/component_inspector/Types.hh:37
T str(T... args)
uint64_t ComponentTypeId
A unique identifier for a component type. A component type must be derived from components::BaseCompo...
Definition: include/ignition/gazebo/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:39
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