ModelListWidget.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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 #ifndef GAZEBO_GUI_MODELLISTWIDGET_HH_
18 #define GAZEBO_GUI_MODELLISTWIDGET_HH_
19 
20 #include <memory>
21 #include <string>
22 
23 #include <ignition/msgs/plugin.pb.h>
24 #include <ignition/msgs/plugin_v.pb.h>
25 
26 #include "gazebo/gui/qt.h"
27 #include "gazebo/msgs/msgs.hh"
28 #include "gazebo/util/system.hh"
29 
30 class QtBrowserItem;
31 class QtProperty;
32 class QTreeView;
33 class QTreeWidgetItem;
34 
35 namespace gazebo
36 {
37  namespace gui
38  {
39  class ModelListWidgetPrivate;
40 
41  class GZ_GUI_VISIBLE ModelListWidget : public QWidget
42  {
43  Q_OBJECT
44  public: explicit ModelListWidget(QWidget *_parent = 0);
45  public: virtual ~ModelListWidget();
46 
47  private slots: void OnModelSelection(QTreeWidgetItem *item, int column);
48  private slots: void Update();
49  private slots: void OnPropertyChanged(QtProperty *_item);
50  private slots: void OnCustomContextMenu(const QPoint &_pt);
51  private slots: void OnCurrentPropertyChanged(QtBrowserItem *_item);
52  private: void OnSetSelectedEntity(const std::string &_name,
53  const std::string &_mode);
54  private: void OnResponse(ConstResponsePtr &_msg);
55 
56  private: void OnModelUpdate(const msgs::Model &_msg);
57 
60  private: void OnLightUpdate(const msgs::Light &_msg);
61 
62  private: void OnRequest(ConstRequestPtr &_msg);
63 
64  private: void OnRemoveScene(const std::string &_name);
65  private: void OnCreateScene(const std::string &_name);
66 
67  private: void AddModelToList(const msgs::Model &_msg);
68 
69  private: void FillMsgField(QtProperty *_item,
70  google::protobuf::Message *_message,
71  const google::protobuf::Reflection *_reflection,
72  const google::protobuf::FieldDescriptor *_field);
73 
74  private: void FillMsg(QtProperty *_item,
75  google::protobuf::Message *_message,
76  const google::protobuf::Descriptor *_descriptor,
77  QtProperty *_changedItem);
78 
79  private: void FillGeometryMsg(QtProperty *_item,
80  google::protobuf::Message *_message,
81  const google::protobuf::Descriptor *_descriptor,
82  QtProperty *_changedItem);
83 
84  private: void FillPoseMsg(QtProperty *_item,
85  google::protobuf::Message *_message,
86  const google::protobuf::Descriptor *_descriptor);
87 
88  private: void FillColorMsg(QtProperty *_item, msgs::Color *_msg);
89 
90  private: void FillVector3Msg(QtProperty *_item, msgs::Vector3d *_msg);
91 
92  private: QtProperty *PopChildItem(QList<QtProperty*> &_list,
93  const std::string &_name);
94 
95  private: QtProperty *ParentItemValue(const std::string &_name);
96  private: QtProperty *ParentItemValue(QtProperty *_item,
97  const std::string &_name);
98 
99  private: QtProperty *ParentItem(const std::string &_name);
100  private: QtProperty *ParentItem(QtProperty *_item,
101  const std::string &_name);
102 
103  private: QtProperty *ChildItemValue(const std::string &_name);
104  private: QtProperty *ChildItemValue(QtProperty *_item,
105  const std::string &_name);
106 
107  private: QtProperty *ChildItem(const std::string &_name);
108  private: QtProperty *ChildItem(QtProperty *_item,
109  const std::string &_name);
110 
111  private: bool HasChildItem(QtProperty *_parent, QtProperty *_child);
112 
113  private: void RemoveEntity(const std::string &_name);
114 
115  private: QTreeWidgetItem *ListItem(const std::string &_name,
116  QTreeWidgetItem *_parent);
117 
118  private: void FillPropertyTree(const msgs::Model &_msg,
119  QtProperty *_parent);
120 
125  private: void FillPropertyTree(const ignition::msgs::Plugin &_msg,
126  QtProperty *_parent);
127 
128  private: void FillPropertyTree(const msgs::Link &_msg,
129  QtProperty *_parent);
130 
131  private: void FillPropertyTree(const msgs::Collision &_msg,
132  QtProperty *_parent);
133 
134  private: void FillPropertyTree(const msgs::Joint &_msg,
135  QtProperty *_parent);
136 
137  private: void FillPropertyTree(const msgs::Surface &_msg,
138  QtProperty *_parent);
139 
140  private: void FillPropertyTree(const msgs::Visual &_msg,
141  QtProperty *_parent);
142 
143  private: void FillPropertyTree(const msgs::Geometry &_msg,
144  QtProperty *_parent);
145 
146  private: void FillPropertyTree(const msgs::Scene &_msg,
147  QtProperty *_parent);
148 
149  private: void FillPropertyTree(const msgs::Physics &_msg,
150  QtProperty *_parent);
151 
152  private: void FillPropertyTree(const msgs::Wind &_msg,
153  QtProperty *_parent);
154 
159  private: void FillPropertyTree(const msgs::Atmosphere &_msg,
160  QtProperty *_parent);
161 
162  private: void FillPropertyTree(const msgs::Light &_msg,
163  QtProperty *_parent);
164 
165  private: void FillVector3dProperty(const msgs::Vector3d &_msg,
166  QtProperty *_parent);
167 
168  private: void FillPoseProperty(const msgs::Pose &_msg,
169  QtProperty *_parent);
170 
175  private: void FillPropertyTree(const msgs::SphericalCoordinates &_msg,
176  QtProperty *_parent);
177 
180  private: void FillUserCamera();
181 
183  private: void FillGrid();
184 
188  private: void AddProperty(QtProperty *_item, QtProperty *_parent);
189 
190  private: void ProcessModelMsgs();
191  private: void ProcessLightMsgs();
192  private: void ProcessRemoveEntity();
193 
194  public: void InitTransport(const std::string &_name ="");
195  private: void ResetTree();
196  private: void ResetScene();
197 
200  private: void ModelPropertyChanged(QtProperty *_item);
201 
204  private: void ScenePropertyChanged(QtProperty *_item);
205 
206  private: void LightPropertyChanged(QtProperty *_item);
207 
210  private: void PhysicsPropertyChanged(QtProperty *_item);
211 
214  private: void WindPropertyChanged(QtProperty *_item);
215 
218  private: void AtmospherePropertyChanged(QtProperty *_item);
219 
222  private: void GUIPropertyChanged(QtProperty *_item);
223 
226  private: void GUICameraPropertyChanged(QtProperty *_item);
227 
230  private: void GUIGridPropertyChanged(QtProperty *_item);
231 
235  private: void OnPluginInfo(const ignition::msgs::Plugin_V &_plugins,
236  const bool _success);
237 
240  private: std::unique_ptr<ModelListWidgetPrivate> dataPtr;
241  };
242  }
243 }
244 #endif
Definition: ModelListWidget.hh:41