Ignition Gazebo

API Reference

3.12.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/Vector3.hh>
26 
29 #include <ignition/gazebo/Types.hh>
30 
32 
33 #include "Types.hh"
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::Vector3d &_data);
75 
79  template<>
80  void setData(QStandardItem *_item, const sdf::Physics &_data);
81 
85  template<>
86  void setData(QStandardItem *_item, const bool &_data);
87 
91  template<>
92  void setData(QStandardItem *_item, const int &_data);
93 
97  template<>
98  void setData(QStandardItem *_item, const double &_data);
99 
103  template<>
104  void setData(QStandardItem *_item, const std::ostream &_data);
105 
109  void setUnit(QStandardItem *_item, const std::string &_unit);
110 
113  class ComponentsModel : public QStandardItemModel
114  {
115  Q_OBJECT
116 
118  public: explicit ComponentsModel();
119 
121  public: ~ComponentsModel() override = default;
122 
123  // Documentation inherited
124  public: QHash<int, QByteArray> roleNames() const override;
125 
128  public: static QHash<int, QByteArray> RoleNames();
129 
133  public slots: QStandardItem *AddComponentType(
135 
138  public slots: void RemoveComponentType(
140 
143  };
144 
149  class ComponentInspector : public gazebo::GuiSystem
150  {
151  Q_OBJECT
152 
154  Q_PROPERTY(
155  Entity entity
156  READ GetEntity
157  WRITE SetEntity
158  NOTIFY EntityChanged
159  )
160 
161 
162  Q_PROPERTY(
163  QString type
164  READ Type
165  WRITE SetType
166  NOTIFY TypeChanged
167  )
168 
169 
170  Q_PROPERTY(
171  bool locked
172  READ Locked
173  WRITE SetLocked
174  NOTIFY LockedChanged
175  )
176 
177 
178  Q_PROPERTY(
179  bool paused
180  READ Paused
181  WRITE SetPaused
182  NOTIFY PausedChanged
183  )
184 
185 
186  Q_PROPERTY(
187  bool nestedModel
188  READ NestedModel
189  NOTIFY NestedModelChanged
190  )
191 
192 
193  public: ComponentInspector();
194 
196  public: ~ComponentInspector() override;
197 
198  // Documentation inherited
199  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
200 
201  // Documentation inherited
202  public: void Update(const UpdateInfo &, EntityComponentManager &) override;
203 
208  public: void AddUpdateViewCb(ComponentTypeId _id,
210 
214  public: Q_INVOKABLE void OnPhysics(double _stepSize,
215  double _realTimeFactor);
216 
219  public: Q_INVOKABLE bool NestedModel() const;
220 
222  signals: void NestedModelChanged();
223 
224  // Documentation inherited
225  protected: bool eventFilter(QObject *_obj, QEvent *_event) override;
226 
229  public: Q_INVOKABLE Entity GetEntity() const;
230 
233  public: Q_INVOKABLE void SetEntity(const Entity &_entity);
234 
236  signals: void EntityChanged();
237 
240  public: Q_INVOKABLE QString Type() const;
241 
244  public: Q_INVOKABLE void SetType(const QString &_entity);
245 
247  signals: void TypeChanged();
248 
251  public: Q_INVOKABLE bool Locked() const;
252 
255  public: Q_INVOKABLE void SetLocked(bool _locked);
256 
258  signals: void LockedChanged();
259 
262  public: Q_INVOKABLE bool Paused() const;
263 
266  public: Q_INVOKABLE void SetPaused(bool _paused);
267 
269  signals: void PausedChanged();
270 
273  public: const std::string &WorldName() const;
274 
277  public: transport::Node &TransportNode();
278 
282  };
283 }
284 }
285 
286 #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:87
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:48
#define ignwarn