Ignition Gazebo

API Reference

3.5.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 namespace ignition
34 {
35 namespace gazebo
36 {
37  class ComponentInspectorPrivate;
38 
42  template <class DataType>
43  void setData(QStandardItem *_item, const DataType &_data)
44  {
45  // cppcheck-suppress syntaxError
46  // cppcheck-suppress unmatchedSuppression
48  {
50  ss << _data;
51  setData(_item, ss.str());
52  }
53  else
54  {
55  ignwarn << "Attempting to set unsupported data type to item ["
56  << _item->text().toStdString() << "]" << std::endl;
57  }
58  }
59 
63  template<>
64  void setData(QStandardItem *_item, const std::string &_data);
65 
69  template<>
70  void setData(QStandardItem *_item, const math::Pose3d &_data);
71 
75  template<>
76  void setData(QStandardItem *_item, const math::Vector3d &_data);
77 
81  template<>
82  void setData(QStandardItem *_item, const bool &_data);
83 
87  template<>
88  void setData(QStandardItem *_item, const int &_data);
89 
93  template<>
94  void setData(QStandardItem *_item, const double &_data);
95 
99  template<>
100  void setData(QStandardItem *_item, const std::ostream &_data);
101 
105  void setUnit(QStandardItem *_item, const std::string &_unit);
106 
109  class ComponentsModel : public QStandardItemModel
110  {
111  Q_OBJECT
112 
114  public: explicit ComponentsModel();
115 
117  public: ~ComponentsModel() override = default;
118 
119  // Documentation inherited
120  public: QHash<int, QByteArray> roleNames() const override;
121 
124  public: static QHash<int, QByteArray> RoleNames();
125 
129  public slots: QStandardItem *AddComponentType(
131 
134  public slots: void RemoveComponentType(
136 
139  };
140 
145  class ComponentInspector : public gazebo::GuiSystem
146  {
147  Q_OBJECT
148 
150  Q_PROPERTY(
151  int entity
152  READ Entity
153  WRITE SetEntity
154  NOTIFY EntityChanged
155  )
156 
157 
158  Q_PROPERTY(
159  QString type
160  READ Type
161  WRITE SetType
162  NOTIFY TypeChanged
163  )
164 
165 
166  Q_PROPERTY(
167  bool locked
168  READ Locked
169  WRITE SetLocked
170  NOTIFY LockedChanged
171  )
172 
173 
174  Q_PROPERTY(
175  bool paused
176  READ Paused
177  WRITE SetPaused
178  NOTIFY PausedChanged
179  )
180 
181 
182  Q_PROPERTY(
183  bool nestedModel
184  READ NestedModel
185  NOTIFY NestedModelChanged
186  )
187 
188 
189  public: ComponentInspector();
190 
192  public: ~ComponentInspector() override;
193 
194  // Documentation inherited
195  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
196 
197  // Documentation inherited
198  public: void Update(const UpdateInfo &, EntityComponentManager &) override;
199 
207  public: Q_INVOKABLE void OnPose(double _x, double _y, double _z,
208  double _roll, double _pitch, double _yaw);
209 
212  public: Q_INVOKABLE bool NestedModel() const;
213 
215  signals: void NestedModelChanged();
216 
217  // Documentation inherited
218  protected: bool eventFilter(QObject *_obj, QEvent *_event) override;
219 
222  public: Q_INVOKABLE int Entity() const;
223 
226  public: Q_INVOKABLE void SetEntity(const int &_entity);
227 
229  signals: void EntityChanged();
230 
233  public: Q_INVOKABLE QString Type() const;
234 
237  public: Q_INVOKABLE void SetType(const QString &_entity);
238 
240  signals: void TypeChanged();
241 
244  public: Q_INVOKABLE bool Locked() const;
245 
248  public: Q_INVOKABLE void SetLocked(bool _locked);
249 
251  signals: void LockedChanged();
252 
255  public: Q_INVOKABLE bool Paused() const;
256 
259  public: Q_INVOKABLE void SetPaused(bool _paused);
260 
262  signals: void PausedChanged();
263 
267  };
268 }
269 }
270 
271 #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:87
STL class.
Vector3< double > Vector3d
Q_DECLARE_METATYPE(ComponentTypeId) namespace ignition
Definition: ComponentInspector.hh:31
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.
#define ignwarn