Ignition Gazebo

API Reference

5.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 #include <ignition/math/Pose3.hh>
25 #include <ignition/math/Vector3.hh>
26 
29 #include <ignition/gazebo/Types.hh>
30 
32 
33 #include <ignition/msgs/light.pb.h>
34 
36 
37 namespace ignition
38 {
39 namespace gazebo
40 {
41  class ComponentInspectorPrivate;
42 
46  template <class DataType>
47  void setData(QStandardItem *_item, const DataType &_data)
48  {
49  // cppcheck-suppress syntaxError
50  // cppcheck-suppress unmatchedSuppression
52  {
54  ss << _data;
55  setData(_item, ss.str());
56  }
57  else
58  {
59  ignwarn << "Attempting to set unsupported data type to item ["
60  << _item->text().toStdString() << "]" << std::endl;
61  }
62  }
63 
67  template<>
68  void setData(QStandardItem *_item, const std::string &_data);
69 
73  template<>
74  void setData(QStandardItem *_item, const math::Pose3d &_data);
75 
79  template<>
80  void setData(QStandardItem *_item, const msgs::Light &_data);
81 
85  template<>
86  void setData(QStandardItem *_item, const math::Vector3d &_data);
87 
91  template<>
92  void setData(QStandardItem *_item, const sdf::Physics &_data);
93 
97  template<>
98  void setData(QStandardItem *_item, const bool &_data);
99 
103  template<>
104  void setData(QStandardItem *_item, const int &_data);
105 
109  template<>
110  void setData(QStandardItem *_item, const double &_data);
111 
115  template<>
116  void setData(QStandardItem *_item, const std::ostream &_data);
117 
121  void setUnit(QStandardItem *_item, const std::string &_unit);
122 
125  class ComponentsModel : public QStandardItemModel
126  {
127  Q_OBJECT
128 
130  public: explicit ComponentsModel();
131 
133  public: ~ComponentsModel() override = default;
134 
135  // Documentation inherited
136  public: QHash<int, QByteArray> roleNames() const override;
137 
140  public: static QHash<int, QByteArray> RoleNames();
141 
145  public slots: QStandardItem *AddComponentType(
147 
150  public slots: void RemoveComponentType(
152 
155  };
156 
161  class ComponentInspector : public gazebo::GuiSystem
162  {
163  Q_OBJECT
164 
166  Q_PROPERTY(
167  int entity
168  READ Entity
169  WRITE SetEntity
170  NOTIFY EntityChanged
171  )
172 
173 
174  Q_PROPERTY(
175  QString type
176  READ Type
177  WRITE SetType
178  NOTIFY TypeChanged
179  )
180 
181 
182  Q_PROPERTY(
183  bool locked
184  READ Locked
185  WRITE SetLocked
186  NOTIFY LockedChanged
187  )
188 
189 
190  Q_PROPERTY(
191  bool paused
192  READ Paused
193  WRITE SetPaused
194  NOTIFY PausedChanged
195  )
196 
197 
198  Q_PROPERTY(
199  bool nestedModel
200  READ NestedModel
201  NOTIFY NestedModelChanged
202  )
203 
204 
205  public: ComponentInspector();
206 
208  public: ~ComponentInspector() override;
209 
210  // Documentation inherited
211  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
212 
213  // Documentation inherited
214  public: void Update(const UpdateInfo &, EntityComponentManager &) override;
215 
223  public: Q_INVOKABLE void OnPose(double _x, double _y, double _z,
224  double _roll, double _pitch, double _yaw);
225 
248  public: Q_INVOKABLE void OnLight(
249  double _rSpecular, double _gSpecular, double _bSpecular,
250  double _aSpecular, double _rDiffuse, double _gDiffuse,
251  double _bDiffuse, double _aDiffuse, double _attRange,
252  double _attLinear, double _attConstant, double _attQuadratic,
253  bool _castShadows, double _directionX, double _directionY,
254  double _directionZ, double _innerAngle, double _outerAngle,
255  double _falloff, double _intensity, int _type);
256 
260  public: Q_INVOKABLE void OnPhysics(double _stepSize,
261  double _realTimeFactor);
262 
265  public: Q_INVOKABLE bool NestedModel() const;
266 
268  signals: void NestedModelChanged();
269 
270  // Documentation inherited
271  protected: bool eventFilter(QObject *_obj, QEvent *_event) override;
272 
275  public: Q_INVOKABLE int Entity() const;
276 
279  public: Q_INVOKABLE void SetEntity(const int &_entity);
280 
282  signals: void EntityChanged();
283 
286  public: Q_INVOKABLE QString Type() const;
287 
290  public: Q_INVOKABLE void SetType(const QString &_entity);
291 
293  signals: void TypeChanged();
294 
297  public: Q_INVOKABLE bool Locked() const;
298 
301  public: Q_INVOKABLE void SetLocked(bool _locked);
302 
304  signals: void LockedChanged();
305 
308  public: Q_INVOKABLE bool Paused() const;
309 
312  public: Q_INVOKABLE void SetPaused(bool _paused);
313 
315  signals: void PausedChanged();
316 
320  };
321 }
322 }
323 
324 #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:86
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:35
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