##

EditorView.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _EDITOR_VIEW_HH_
#define _EDITOR_VIEW_HH_
#include <map>
#include <string>
#include <vector>
#include "gazebo/gui/qt.h"
#include "gazebo/common/Event.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace gui
{
class EditorItem;
class GrabberHandle;
class WindowItem;
class StairsItem;
class DoorItem;
class WallSegmentItem;
class FloorItem;
class BuildingMaker;
class LevelInspectorDialog;
class GridLines;
class GZ_GUI_VISIBLE Level
{
public: Level() : level(0), name("level"), baseHeight(0),
// 2.4384m == 8ft, standard room height in US
height(2.4384),
backgroundPixmap(nullptr),
floorItem(nullptr) {}
public: int level;
public: std::string name;
public: double baseHeight;
public: double height;
public: QGraphicsPixmapItem *backgroundPixmap;
public: FloorItem *floorItem;
};
class GZ_GUI_VISIBLE EditorView : public QGraphicsView
{
Q_OBJECT
public: enum DrawModes {
NONE,
WALL,
WINDOW,
DOOR,
STAIRS,
COLOR,
TEXTURE
};
public: explicit EditorView(QWidget *_parent = 0);
public: ~EditorView();
public: void Create3DVisual(EditorItem *_item);
public: void DeleteItem(EditorItem *_item);
public: void SetBackgroundImage(const std::string &_filename,
double _scale);
private: void resizeEvent(QResizeEvent *_event);
private: void scrollContentsBy(int _dx, int _dy);
private: void contextMenuEvent(QContextMenuEvent *_event);
private: void wheelEvent(QWheelEvent *_event);
private: void mouseMoveEvent(QMouseEvent *_event);
private: void mousePressEvent(QMouseEvent *_event);
private: void mouseReleaseEvent(QMouseEvent *_event);
private: void mouseDoubleClickEvent(QMouseEvent *_event);
private: void leaveEvent(QEvent *_event);
private: void keyPressEvent(QKeyEvent *_event);
private: void DrawWall(const QPoint &_pos);
private: void DrawWindow(const QPoint &_pos);
private: void DrawDoor(const QPoint &_pos);
private: void DrawStairs(const QPoint &_pos);
private: void OnCreateEditorItem(const std::string &_type);
private: void OnColorSelected(QColor _color);
private: void OnTextureSelected(QString _texture);
private: void OnFinishModel();
private: void OnDiscardModel();
private slots: void OnAddLevel();
private slots: void OnDeleteLevel();
private slots: void OnLevelApply();
private slots: void OnOpenLevelInspector();
private: void OnChangeLevel(int _level);
private: void DeleteLevel(int _level);
private: void CancelDrawMode();
private: void OnShowFloorplan();
private: void OnShowElements();
private: void ShowCurrentLevelItems();
private: void LinkGrabbers(GrabberHandle *_grabber1,
GrabberHandle *_grabber2);
private: void UnlinkGrabbers(GrabberHandle *_grabber1,
GrabberHandle *_grabber2 = nullptr);
private: int drawMode;
private: bool drawInProgress;
private: bool floorplanVisible;
private: bool elementsVisible;
private: std::vector<WallSegmentItem*> wallSegmentList;
private: std::vector<WindowItem*> windowList;
private: std::vector<DoorItem*> doorList;
private: std::vector<StairsItem*> stairsList;
private: std::vector<FloorItem*> floorList;
private: std::map<EditorItem *, std::string> itemToVisualMap;
private: std::vector<event::ConnectionPtr> connections;
private: QGraphicsItem *currentMouseItem = nullptr;
private: QGraphicsItem *currentSelectedItem = nullptr;
private: BuildingMaker *buildingMaker = nullptr;
private: int currentLevel = 0;
private: std::vector<Level *> levels;
private: int levelCounter = 0;
private: double levelDefaultHeight = 0.0;
private: QAction *openLevelInspectorAct;
private: QAction *addLevelAct;
private: QAction *deleteLevelAct;
private: double mousePressRotation;
private: LevelInspectorDialog *levelInspector;
private: GridLines *gridLines;
private: double viewScale;
private: bool snapToGrabber = false;
private: GrabberHandle *snapGrabberOther = nullptr;
private: GrabberHandle *snapGrabberCurrent = nullptr;
private: QGraphicsTextItem *mouseTooltip;
};
}
}
#endif
gazebo::gui::Level::level
int level
Level number.
Definition: EditorView.hh:55
gazebo::gui::Level::Level
Level()
Constructor.
Definition: EditorView.hh:48
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
qt.h
gazebo::gui::EditorItem
Base class of an item in the editor.
Definition: EditorItem.hh:42
gazebo::gui::Level
A convenient structure for storing level information.
Definition: EditorView.hh:45
gazebo::gui::EditorView::EditorView
EditorView(QWidget *_parent=0)
Constructor.
gazebo::gui::LevelInspectorDialog
Dialog for configuring a building level.
Definition: LevelInspectorDialog.hh:40
system.hh
gazebo::gui::EditorView::WINDOW
Window mode.
Definition: EditorView.hh:90
gazebo::gui::GrabberHandle
Definition: GrabberHandle.hh:38
gazebo::gui::EditorView::TEXTURE
Texture mode.
Definition: EditorView.hh:98
gazebo::gui::EditorView::NONE
None mode.
Definition: EditorView.hh:86
gazebo::gui::FloorItem
2D representation of a floor.
Definition: FloorItem.hh:43
gazebo::gui::Level::floorItem
FloorItem * floorItem
Level's floor item.
Definition: EditorView.hh:70
gazebo::gui::EditorView::STAIRS
Stairs mode.
Definition: EditorView.hh:94
gazebo::gui::EditorView::WALL
Wall mode.
Definition: EditorView.hh:88
gazebo::gui::Level::height
double height
Level height.
Definition: EditorView.hh:64
gazebo::gui::EditorView::DrawModes
DrawModes
Unique identifiers for all drawing modes within the editor.
Definition: EditorView.hh:84
gazebo::gui::EditorView::DOOR
Door mode.
Definition: EditorView.hh:92
gazebo::gui::Level::name
std::string name
Level name.
Definition: EditorView.hh:58
gazebo::gui::EditorView::COLOR
Color mode.
Definition: EditorView.hh:96
gazebo::gui::BuildingMaker
Create and manage 3D visuals of a building.
Definition: BuildingMaker.hh:48
gazebo::gui::EditorView::DeleteItem
void DeleteItem(EditorItem *_item)
Delete an editor item.
gui
gui
Definition: KeyEventHandler.hh:29
gazebo::gui::EditorView::SetBackgroundImage
void SetBackgroundImage(const std::string &_filename, double _scale)
Set the graphics view background image.
gazebo::gui::Level::backgroundPixmap
QGraphicsPixmapItem * backgroundPixmap
Background pixmap for a level.
Definition: EditorView.hh:67
gazebo::gui::Level::baseHeight
double baseHeight
Level height from ground.
Definition: EditorView.hh:61
gazebo::gui::EditorView
Control the editor view and manage contents in the editor scene.
Definition: EditorView.hh:78
Event.hh
gazebo::gui::GridLines
2D grid lines.
Definition: GridLines.hh:37
gazebo::gui::EditorView::~EditorView
~EditorView()
Destructor.
gazebo::gui::EditorView::Create3DVisual
void Create3DVisual(EditorItem *_item)
Create a 3D visual from a 2D editor item.