ModelListWidget.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 #include <QItemDelegate>
23 #include <QObject>
24 #include <QWidget>
25 
26 #include "gazebo/msgs/msgs.hh"
27 #include "gazebo/util/system.hh"
28 
29 class QtBrowserItem;
30 class QtProperty;
31 class QTreeView;
32 class QTreeWidgetItem;
33 
34 namespace gazebo
35 {
36  namespace gui
37  {
38  class ModelListWidgetPrivate;
39 
40  class GZ_GUI_VISIBLE ModelListWidget : public QWidget
41  {
42  Q_OBJECT
43  public: ModelListWidget(QWidget *_parent = 0);
44  public: virtual ~ModelListWidget();
45 
46  private slots: void OnModelSelection(QTreeWidgetItem *item, int column);
47  private slots: void Update();
48  private slots: void OnPropertyChanged(QtProperty *_item);
49  private slots: void OnCustomContextMenu(const QPoint &_pt);
50  private slots: void OnCurrentPropertyChanged(QtBrowserItem *_item);
51  private: void OnSetSelectedEntity(const std::string &_name,
52  const std::string &_mode);
53  private: void OnResponse(ConstResponsePtr &_msg);
54 
55  private: void OnModelUpdate(const msgs::Model &_msg);
56 
59  private: void OnLightUpdate(const msgs::Light &_msg);
60 
61  private: void OnRequest(ConstRequestPtr &_msg);
62 
63  private: void OnRemoveScene(const std::string &_name);
64  private: void OnCreateScene(const std::string &_name);
65 
66  private: void AddModelToList(const msgs::Model &_msg);
67 
68  private: void FillMsgField(QtProperty *_item,
69  google::protobuf::Message *_message,
70  const google::protobuf::Reflection *_reflection,
71  const google::protobuf::FieldDescriptor *_field);
72 
73  private: void FillMsg(QtProperty *_item,
74  google::protobuf::Message *_message,
75  const google::protobuf::Descriptor *_descriptor,
76  QtProperty *_changedItem);
77 
78  private: void FillGeometryMsg(QtProperty *_item,
79  google::protobuf::Message *_message,
80  const google::protobuf::Descriptor *_descriptor,
81  QtProperty *_changedItem);
82 
83  private: void FillPoseMsg(QtProperty *_item,
84  google::protobuf::Message *_message,
85  const google::protobuf::Descriptor *_descriptor);
86 
87  private: void FillColorMsg(QtProperty *_item, msgs::Color *_msg);
88 
89  private: void FillVector3Msg(QtProperty *_item, msgs::Vector3d *_msg);
90 
91  private: QtProperty *PopChildItem(QList<QtProperty*> &_list,
92  const std::string &_name);
93 
94  private: QtProperty *ParentItemValue(const std::string &_name);
95  private: QtProperty *ParentItemValue(QtProperty *_item,
96  const std::string &_name);
97 
98  private: QtProperty *ParentItem(const std::string &_name);
99  private: QtProperty *ParentItem(QtProperty *_item,
100  const std::string &_name);
101 
102  private: QtProperty *ChildItemValue(const std::string &_name);
103  private: QtProperty *ChildItemValue(QtProperty *_item,
104  const std::string &_name);
105 
106  private: QtProperty *ChildItem(const std::string &_name);
107  private: QtProperty *ChildItem(QtProperty *_item,
108  const std::string &_name);
109 
110  private: bool HasChildItem(QtProperty *_parent, QtProperty *_child);
111 
112  private: void RemoveEntity(const std::string &_name);
113 
114  private: QTreeWidgetItem *ListItem(const std::string &_name,
115  QTreeWidgetItem *_parent);
116 
117  private: void FillPropertyTree(const msgs::Model &_msg,
118  QtProperty *_parent);
119 
120  private: void FillPropertyTree(const msgs::Link &_msg,
121  QtProperty *_parent);
122 
123  private: void FillPropertyTree(const msgs::Collision &_msg,
124  QtProperty *_parent);
125 
126  private: void FillPropertyTree(const msgs::Joint &_msg,
127  QtProperty *_parent);
128 
129  private: void FillPropertyTree(const msgs::Surface &_msg,
130  QtProperty *_parent);
131 
132  private: void FillPropertyTree(const msgs::Visual &_msg,
133  QtProperty *_parent);
134 
135  private: void FillPropertyTree(const msgs::Geometry &_msg,
136  QtProperty *_parent);
137 
138  private: void FillPropertyTree(const msgs::Scene &_msg,
139  QtProperty *_parent);
140 
141  private: void FillPropertyTree(const msgs::Physics &_msg,
142  QtProperty *_parent);
143 
144  private: void FillPropertyTree(const msgs::Wind &_msg,
145  QtProperty *_parent);
146 
151  private: void FillPropertyTree(const msgs::Atmosphere &_msg,
152  QtProperty *_parent);
153 
154  private: void FillPropertyTree(const msgs::Light &_msg,
155  QtProperty *_parent);
156 
157  private: void FillVector3dProperty(const msgs::Vector3d &_msg,
158  QtProperty *_parent);
159 
160  private: void FillPoseProperty(const msgs::Pose &_msg,
161  QtProperty *_parent);
162 
167  private: void FillPropertyTree(const msgs::SphericalCoordinates &_msg,
168  QtProperty *_parent);
169 
173  private: void AddProperty(QtProperty *_item, QtProperty *_parent);
174 
175  private: void ProcessModelMsgs();
176  private: void ProcessLightMsgs();
177  private: void ProcessRemoveEntity();
178 
179  public: void InitTransport(const std::string &_name ="");
180  private: void ResetTree();
181  private: void ResetScene();
182 
185  private: void ModelPropertyChanged(QtProperty *_item);
186 
189  private: void ScenePropertyChanged(QtProperty *_item);
190 
191  private: void LightPropertyChanged(QtProperty *_item);
192 
195  private: void PhysicsPropertyChanged(QtProperty *_item);
196 
199  private: void WindPropertyChanged(QtProperty *_item);
200 
203  private: void AtmospherePropertyChanged(QtProperty *_item);
204 
207  private: void GUIPropertyChanged(QtProperty *_item);
208 
211  private: std::unique_ptr<ModelListWidgetPrivate> dataPtr;
212  };
213  }
214 }
215 #endif
Definition: ModelListWidget.hh:40