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::Light &_msg,
145  QtProperty *_parent);
146 
147  private: void FillVector3dProperty(const msgs::Vector3d &_msg,
148  QtProperty *_parent);
149 
150  private: void FillPoseProperty(const msgs::Pose &_msg,
151  QtProperty *_parent);
152 
157  private: void FillPropertyTree(const msgs::SphericalCoordinates &_msg,
158  QtProperty *_parent);
159 
163  private: void AddProperty(QtProperty *_item, QtProperty *_parent);
164 
165  private: void ProcessModelMsgs();
166  private: void ProcessLightMsgs();
167  private: void ProcessRemoveEntity();
168 
169  public: void InitTransport(const std::string &_name ="");
170  private: void ResetTree();
171  private: void ResetScene();
172 
175  private: void ModelPropertyChanged(QtProperty *_item);
176 
179  private: void ScenePropertyChanged(QtProperty *_item);
180 
181  private: void LightPropertyChanged(QtProperty *_item);
182 
185  private: void PhysicsPropertyChanged(QtProperty *_item);
186 
189  private: void GUIPropertyChanged(QtProperty *_item);
190 
193  private: std::unique_ptr<ModelListWidgetPrivate> dataPtr;
194  };
195  }
196 }
197 #endif
Forward declarations for the common classes.
Definition: Animation.hh:33
Definition: ModelListWidget.hh:40