ModelEditorPalette.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013-2015 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 _GAZEBO_MODEL_EDITOR_PALETTE_HH_
19 #define _GAZEBO_MODEL_EDITOR_PALETTE_HH_
20 
21 #include <mutex>
22 #include <map>
23 #include <string>
24 #include <vector>
25 
27 #include "gazebo/common/Event.hh"
28 
30 #include "gazebo/gui/qt.h"
31 #include "gazebo/util/system.hh"
32 
33 namespace gazebo
34 {
35  namespace rendering
36  {
37  }
38 
39  namespace gui
40  {
41  class ModelCreator;
42 
45 
49  {
50  Q_OBJECT
51 
54  public: ModelEditorPalette(QWidget *_parent = 0);
55 
57  public: ~ModelEditorPalette();
58 
62  public: void AddItem(QWidget *_item,
63  const std::string &_category = "Other");
64 
67  public: void CreateJoint(const std::string &_type);
68 
71  public: ModelCreator *GetModelCreator();
72 
76  private: bool OnKeyPress(const common::KeyEvent &_event);
77 
81  private: void OnSetSelectedEntity(const std::string &_name,
82  const std::string &_mode);
83 
88  private: void OnSetSelectedLink(const std::string &_name, bool _selected);
89 
94  private: void OnSetSelectedJoint(const std::string &_name,
95  bool _selected);
96 
99  private: void DeselectType(const std::string &_type);
100 
102  private slots: void OnCylinder();
103 
105  private slots: void OnSphere();
106 
108  private slots: void OnBox();
109 
111  private slots: void OnCustom();
112 
114  private slots: void OnLinkAdded();
115 
117  private slots: void OnStatic();
118 
120  private slots: void OnAutoDisable();
121 
124  private slots: void OnNameChanged(const QString &_name);
125 
129  private slots: void OnItemDoubleClicked(QTreeWidgetItem *_item,
130  int _column);
131 
135  private slots: void OnItemClicked(QTreeWidgetItem *_item, int _column);
136 
138  private slots: void OnItemSelectionChanged();
139 
143  private slots: void OnCustomContextMenu(const QPoint &_pt);
144 
147  private: void OnLinkInserted(const std::string &_linkName);
148 
154  private: void OnJointInserted(const std::string &_jointId,
155  const std::string &_jointName, const std::string &_parentName,
156  const std::string &_childName);
157 
160  private: void OnLinkRemoved(const std::string &_linkId);
161 
164  private: void OnJointRemoved(const std::string &_jointId);
165 
167  private: void ClearModelTree();
168 
172  private: void OnJointNameChanged(const std::string &_jointId,
173  const std::string &_newJointName);
174 
178  private: void OnSaveModel(const std::string &_saveName);
179 
181  private: void OnNewModel();
182 
188  private: void OnModelPropertiesChanged(bool _static, bool _autoDisable,
189  const math::Pose &_pose, const std::string &_name);
190 
192  private: std::vector<event::ConnectionPtr> connections;
193 
195  private: QButtonGroup *linkButtonGroup;
196 
198  private: ModelCreator *modelCreator;
199 
201  private: QCheckBox *staticCheck;
202 
205  private: QCheckBox *autoDisableCheck;
206 
208  private: std::string modelDefaultName;
209 
211  private: QLineEdit *modelNameEdit;
212 
214  private: QTreeWidget *modelTreeWidget;
215 
217  private: QTreeWidgetItem *linksItem;
218 
220  private: QTreeWidgetItem *jointsItem;
221 
223  private: std::recursive_mutex updateMutex;
224 
226  private: QList<QTreeWidgetItem *> selected;
227 
229  private: QVBoxLayout *otherItemsLayout;
230 
232  private: std::map<std::string, QGridLayout *> categories;
233  };
234  }
235 }
236 #endif
Encapsulates a position and rotation in three space.
Definition: Pose.hh:37
A palette of model items which can be added to the editor.
Definition: ModelEditorPalette.hh:48
Generic description of a keyboard event.
Definition: KeyEvent.hh:32
Create and manage 3D visuals of a model with links and joints.
Definition: ModelCreator.hh:60
#define GZ_GUI_MODEL_VISIBLE
Definition: system.hh:418