All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EditorView.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 _EDITOR_VIEW_HH_
19 #define _EDITOR_VIEW_HH_
20 
21 #include <map>
22 #include <string>
23 #include <vector>
24 #include "gazebo/gui/qt.h"
25 #include "gazebo/common/Event.hh"
26 #include "gazebo/util/system.hh"
27 
28 namespace gazebo
29 {
30  namespace gui
31  {
32  class EditorItem;
33  class WindowItem;
34  class StairsItem;
35  class DoorItem;
36  class WallItem;
37  class FloorItem;
38  class BuildingMaker;
39  class LevelInspectorDialog;
40  class GridLines;
41 
45  {
47  public: int level;
48 
50  public: std::string name;
51 
53  public: double height;
54  };
55 
58 
61  class GAZEBO_VISIBLE EditorView : public QGraphicsView
62  {
63  Q_OBJECT
64 
67  public: enum DrawModes {
77  STAIRS
78  };
79 
82  public: EditorView(QWidget *_parent = 0);
83 
85  public: ~EditorView();
86 
88  public: void Create3DVisual(EditorItem *_item);
89 
92  public: void DeleteItem(EditorItem *_item);
93 
96  private: void resizeEvent(QResizeEvent *_event);
97 
101  private: void scrollContentsBy(int _dx, int _dy);
102 
105  private: void contextMenuEvent(QContextMenuEvent *_event);
106 
109  private: void wheelEvent(QWheelEvent *_event);
110 
113  private: void mouseMoveEvent(QMouseEvent *_event);
114 
117  private: void mousePressEvent(QMouseEvent *_event);
118 
121  private: void mouseReleaseEvent(QMouseEvent *_event);
122 
125  private: void mouseDoubleClickEvent(QMouseEvent *_event);
126 
129  private: void keyPressEvent(QKeyEvent *_event);
130 
133  private: void DrawWall(const QPoint &_pos);
134 
138  private: void DrawWindow(const QPoint &_pos);
139 
143  private: void DrawDoor(const QPoint &_pos);
144 
148  private: void DrawStairs(const QPoint &_pos);
149 
153  private: void OnCreateEditorItem(const std::string &_type);
154 
155  // private: void OnSaveModel(const std::string &_modelName,
156  // const std::string &_savePath);
157 
160  private: void OnFinishModel();
161 
163  private: void OnDiscardModel();
164 
166  private slots: void OnAddLevel();
167 
170  private slots: void OnDeleteLevel();
171 
173  private slots: void OnLevelApply();
174 
176  private slots: void OnOpenLevelInspector();
177 
180  private: void OnChangeLevel(int _level);
181 
184  private: void DeleteLevel(int _level);
185 
187  private: void CancelDrawMode();
188 
190  private: int drawMode;
191 
193  private: bool drawInProgress;
194 
196  private: std::vector<WallItem*> wallList;
197 
199  private: std::vector<WindowItem*> windowList;
200 
202  private: std::vector<DoorItem*> doorList;
203 
205  private: std::vector<StairsItem*> stairsList;
206 
208  private: std::vector<FloorItem*> floorList;
209 
211  private: std::map<EditorItem *, std::string> itemToVisualMap;
212 
214  private: std::vector<event::ConnectionPtr> connections;
215 
218  private: QGraphicsItem *currentMouseItem;
219 
221  private: QGraphicsItem *currentSelectedItem;
222 
224  private: BuildingMaker *buildingMaker;
225 
226  // private: std::string lastWallSegmentName;
227 
229  private: int currentLevel;
230 
232  private: std::vector<Level *> levels;
233 
236  private: int levelCounter;
237 
239  private: QAction *openLevelInspectorAct;
240 
242  private: QAction *addLevelAct;
243 
245  private: QAction *deleteLevelAct;
246 
249  private: double mousePressRotation;
250 
252  private: LevelInspectorDialog *levelInspector;
253 
255  private: GridLines *gridLines;
256 
258  private: double viewScale;
259 
262  private: bool snapToCloseWall;
263  };
265  }
266 }
267 
268 #endif
Base class of an item in the editor.
Definition: EditorItem.hh:34
Wall mode.
Definition: EditorView.hh:71
Window mode.
Definition: EditorView.hh:73
Door mode.
Definition: EditorView.hh:75
DrawModes
Unique identifiers for all drawing modes within the editor.
Definition: EditorView.hh:67
Create and manage 3D visuals of a building.
Definition: BuildingMaker.hh:51
A convenient structure for storing level information.
Definition: EditorView.hh:44
Dialog for configuring a building level.
Definition: LevelInspectorDialog.hh:34
Control the editor view and manage contents in the editor scene.
Definition: EditorView.hh:61
std::string name
Level name.
Definition: EditorView.hh:50
2D grid lines.
Definition: GridLines.hh:33
int level
Level number.
Definition: EditorView.hh:47
None mode.
Definition: EditorView.hh:69
double height
Level height from ground.
Definition: EditorView.hh:53
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48