Ignition Gazebo

API Reference

6.0.0~pre1
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/Physics.hh>
26 
27 #include <ignition/math/Pose3.hh>
28 #include <ignition/math/Vector3.hh>
29 
32 #include <ignition/gazebo/Types.hh>
33 
34 #include <ignition/msgs/light.pb.h>
35 
37 
38 namespace ignition
39 {
40 namespace gazebo
41 {
42  class ComponentInspectorPrivate;
43 
47  template <class DataType>
48  void setData(QStandardItem *_item, const DataType &_data)
49  {
50  // cppcheck-suppress syntaxError
51  // cppcheck-suppress unmatchedSuppression
53  {
55  ss << _data;
56  setData(_item, ss.str());
57  }
58  else
59  {
60  ignwarn << "Attempting to set unsupported data type to item ["
61  << _item->text().toStdString() << "]" << std::endl;
62  }
63  }
64 
68  template<>
69  void setData(QStandardItem *_item, const std::string &_data);
70 
74  template<>
75  void setData(QStandardItem *_item, const math::Pose3d &_data);
76 
80  template<>
81  void setData(QStandardItem *_item, const msgs::Light &_data);
82 
86  template<>
87  void setData(QStandardItem *_item, const math::Vector3d &_data);
88 
92  template<>
93  void setData(QStandardItem *_item, const sdf::Physics &_data);
94 
98  template<>
99  void setData(QStandardItem *_item, const math::SphericalCoordinates &_data);
100 
104  template<>
105  void setData(QStandardItem *_item, const bool &_data);
106 
110  template<>
111  void setData(QStandardItem *_item, const int &_data);
112 
116  template<>
117  void setData(QStandardItem *_item, const double &_data);
118 
122  template<>
123  void setData(QStandardItem *_item, const std::ostream &_data);
124 
128  void setUnit(QStandardItem *_item, const std::string &_unit);
129 
132  class ComponentsModel : public QStandardItemModel
133  {
134  Q_OBJECT
135 
137  public: explicit ComponentsModel();
138 
140  public: ~ComponentsModel() override = default;
141 
142  // Documentation inherited
143  public: QHash<int, QByteArray> roleNames() const override;
144 
147  public: static QHash<int, QByteArray> RoleNames();
148 
152  public slots: QStandardItem *AddComponentType(
154 
157  public slots: void RemoveComponentType(
159 
162  };
163 
168  class ComponentInspector : public gazebo::GuiSystem
169  {
170  Q_OBJECT
171 
173  Q_PROPERTY(
174  int entity
175  READ Entity
176  WRITE SetEntity
177  NOTIFY EntityChanged
178  )
179 
180 
181  Q_PROPERTY(
182  QString type
183  READ Type
184  WRITE SetType
185  NOTIFY TypeChanged
186  )
187 
188 
189  Q_PROPERTY(
190  bool locked
191  READ Locked
192  WRITE SetLocked
193  NOTIFY LockedChanged
194  )
195 
196 
197  Q_PROPERTY(
198  bool paused
199  READ Paused
200  WRITE SetPaused
201  NOTIFY PausedChanged
202  )
203 
204 
205  Q_PROPERTY(
206  bool nestedModel
207  READ NestedModel
208  NOTIFY NestedModelChanged
209  )
210 
211 
212  public: ComponentInspector();
213 
215  public: ~ComponentInspector() override;
216 
217  // Documentation inherited
218  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
219 
220  // Documentation inherited
221  public: void Update(const UpdateInfo &, EntityComponentManager &) override;
222 
230  public: Q_INVOKABLE void OnPose(double _x, double _y, double _z,
231  double _roll, double _pitch, double _yaw);
232 
255  public: Q_INVOKABLE void OnLight(
256  double _rSpecular, double _gSpecular, double _bSpecular,
257  double _aSpecular, double _rDiffuse, double _gDiffuse,
258  double _bDiffuse, double _aDiffuse, double _attRange,
259  double _attLinear, double _attConstant, double _attQuadratic,
260  bool _castShadows, double _directionX, double _directionY,
261  double _directionZ, double _innerAngle, double _outerAngle,
262  double _falloff, double _intensity, int _type);
263 
267  public: Q_INVOKABLE void OnPhysics(double _stepSize,
268  double _realTimeFactor);
269 
276  public: Q_INVOKABLE void OnSphericalCoordinates(QString _surface,
277  double _latitude, double _longitude, double _elevation,
278  double _heading);
279 
282  public: Q_INVOKABLE bool NestedModel() const;
283 
285  signals: void NestedModelChanged();
286 
287  // Documentation inherited
288  protected: bool eventFilter(QObject *_obj, QEvent *_event) override;
289 
292  public: Q_INVOKABLE int Entity() const;
293 
296  public: Q_INVOKABLE void SetEntity(const int &_entity);
297 
299  signals: void EntityChanged();
300 
303  public: Q_INVOKABLE QString Type() const;
304 
307  public: Q_INVOKABLE void SetType(const QString &_entity);
308 
310  signals: void TypeChanged();
311 
314  public: Q_INVOKABLE bool Locked() const;
315 
318  public: Q_INVOKABLE void SetLocked(bool _locked);
319 
321  signals: void LockedChanged();
322 
325  public: Q_INVOKABLE bool Paused() const;
326 
329  public: Q_INVOKABLE void SetPaused(bool _paused);
330 
332  signals: void PausedChanged();
333 
337  };
338 }
339 }
340 
341 #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::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:36
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