From fa063202190ef2b5e12e0a5793d18f24e81b068b Mon Sep 17 00:00:00 2001 From: kazu Date: Mon, 29 Aug 2016 19:05:46 +0200 Subject: [PATCH] a whole lotta work!! - refactoring - completely changed the tooling (adding elements) - better re-use for more stable editing - new elements - ui adjustments - LINT for stair-editing - many more changes --- IndoorMap.pro | 50 +-- MainController.cpp | 32 +- MainWindow.cpp | 28 +- MainWindow.h | 5 + mapview/{elements => 2D}/HasMoveableNodes.h | 4 +- mapview/{elements => 2D}/MV2DElement.h | 14 +- .../{elements => 2D}/MV2DElementAccessPoint.h | 4 - mapview/{elements => 2D}/MV2DElementBeacon.h | 0 .../MV2DElementFloorObstacleCircle.h | 0 .../MV2DElementFloorObstacleDoor.h | 0 .../MV2DElementFloorObstacleLine.h | 62 +-- .../MV2DElementFloorOutlinePolygon.h | 86 ++-- .../MV2DElementFloorUnderlay.h | 2 +- mapview/{elements => 2D}/MV2DElementPOI.h | 0 mapview/{elements => 2D}/MV2DElementStair.h | 9 +- mapview/{ => 2D}/MapView2D.h | 2 +- .../{elements => 2D}/MapViewElementHelper.h | 3 + mapview/{ => 2D}/Painter.h | 1 + mapview/{ => 2D}/Scaler.h | 4 + mapview/{ => 2D}/tools/Tool.cpp | 0 mapview/2D/tools/Tool.h | 58 +++ mapview/{ => 2D}/tools/ToolMapGrid.h | 9 +- mapview/{ => 2D}/tools/ToolMapZoom.h | 11 +- mapview/{ => 2D}/tools/ToolMoveMap.h | 30 +- mapview/{ => 2D}/tools/ToolRuler.h | 19 +- mapview/{ => 2D}/tools/ToolSelector.cpp | 0 mapview/{ => 2D}/tools/ToolSelector.h | 44 ++- mapview/2D/tools/Tools.cpp | 0 mapview/2D/tools/Tools.h | 126 ++++++ mapview/3D/MapView3D.cpp | 18 +- mapview/3DGrid/GridModel.h | 2 +- mapview/3DGrid/GridRenderer.h | 2 +- mapview/3DGrid/MyNode.h | 5 +- mapview/MapView2D.cpp | 2 +- mapview/model/MMFloorAccessPoint.h | 2 +- mapview/model/MMFloorBeacon.h | 2 +- mapview/model/MMFloorObstacleCircle.h | 4 +- mapview/model/MMFloorObstacleDoor.h | 4 +- mapview/model/MMFloorObstacleLine.h | 4 +- mapview/model/MMFloorObstacles.h | 12 +- mapview/model/MMFloorOutlinePolygon.h | 2 +- mapview/model/MMFloorPOI.h | 2 +- mapview/model/MMFloorStair.h | 2 +- mapview/model/MMFloorUnderlayImage.h | 2 +- mapview/model/MMFloorUnderlays.h | 2 +- mapview/tools/Tool.h | 35 -- mapview/tools/Tools.h | 59 --- params/ToolBox.cpp | 369 ++++++++++++++++-- params/ToolBoxWidget.h | 8 +- res.qrc | 1 + res/icons/cursor.svg | 56 +++ 51 files changed, 880 insertions(+), 318 deletions(-) rename mapview/{elements => 2D}/HasMoveableNodes.h (97%) rename mapview/{elements => 2D}/MV2DElement.h (69%) rename mapview/{elements => 2D}/MV2DElementAccessPoint.h (96%) rename mapview/{elements => 2D}/MV2DElementBeacon.h (100%) rename mapview/{elements => 2D}/MV2DElementFloorObstacleCircle.h (100%) rename mapview/{elements => 2D}/MV2DElementFloorObstacleDoor.h (100%) rename mapview/{elements => 2D}/MV2DElementFloorObstacleLine.h (57%) rename mapview/{elements => 2D}/MV2DElementFloorOutlinePolygon.h (50%) rename mapview/{elements => 2D}/MV2DElementFloorUnderlay.h (99%) rename mapview/{elements => 2D}/MV2DElementPOI.h (100%) rename mapview/{elements => 2D}/MV2DElementStair.h (98%) rename mapview/{ => 2D}/MapView2D.h (97%) rename mapview/{elements => 2D}/MapViewElementHelper.h (92%) rename mapview/{ => 2D}/Painter.h (98%) rename mapview/{ => 2D}/Scaler.h (97%) rename mapview/{ => 2D}/tools/Tool.cpp (100%) create mode 100644 mapview/2D/tools/Tool.h rename mapview/{ => 2D}/tools/ToolMapGrid.h (86%) rename mapview/{ => 2D}/tools/ToolMapZoom.h (65%) rename mapview/{ => 2D}/tools/ToolMoveMap.h (52%) rename mapview/{ => 2D}/tools/ToolRuler.h (87%) rename mapview/{ => 2D}/tools/ToolSelector.cpp (100%) rename mapview/{ => 2D}/tools/ToolSelector.h (86%) create mode 100644 mapview/2D/tools/Tools.cpp create mode 100644 mapview/2D/tools/Tools.h delete mode 100644 mapview/tools/Tool.h delete mode 100644 mapview/tools/Tools.h create mode 100644 res/icons/cursor.svg diff --git a/IndoorMap.pro b/IndoorMap.pro index 7c6ec85..0f2fc8c 100644 --- a/IndoorMap.pro +++ b/IndoorMap.pro @@ -26,8 +26,8 @@ SOURCES += \ main.cpp \ MainWindow.cpp \ MainController.cpp \ - mapview/tools/ToolSelector.cpp \ - mapview/tools/Tool.cpp \ + mapview/2D/tools/ToolSelector.cpp \ + mapview/2D/tools/Tool.cpp \ mapview/MapView2D.cpp \ params/ElementParamWidget.cpp \ params/LayerParamWidget.cpp \ @@ -36,44 +36,45 @@ SOURCES += \ mapview/model/MapModel.cpp \ tree/MapTreeModel.cpp \ mapview/3D/MapView3D.cpp \ - params/StairBuilder.cpp + params/StairBuilder.cpp \ + mapview/2D/tools/Tools.cpp HEADERS += MainWindow.h \ - mapview/Painter.h \ - mapview/Scaler.h \ - mapview/tools/ToolSelector.h \ - mapview/tools/Tool.h \ mapview/model/MapLayer.h \ mapview/model/MapModel.h \ - mapview/tools/ToolMoveMap.h \ - mapview/tools/Tools.h \ - mapview/tools/ToolRuler.h \ - mapview/tools/ToolMapZoom.h \ tree/MapTreeModel.h \ MainController.h \ - mapview/tools/ToolMapGrid.h \ mapview/model/MapLayers.h \ - mapview/MapView2D.h \ params/ElementParamWidget.h \ params/LayerParamWidget.h \ params/ActionWidget.h \ params/ToolBoxWidget.h \ UIHelper.h \ mapview/model/MapModelElement.h \ - mapview/elements/MapViewElementHelper.h \ mapview/model/IHasAttributes.h \ mapview/model/IHasMAC.h \ mapview/model/IHasMaterial.h \ mapview/model/IHasName.h \ mapview/model/IHasObstacleType.h \ mapview/model/IHasPosition3D.h \ - mapview/elements/MV2DElementFloorObstacleLine.h \ - mapview/elements/MV2DElement.h \ - mapview/elements/MV2DElementFloorOutlinePolygon.h \ - mapview/elements/MV2DElementBeacon.h \ - mapview/elements/MV2DElementAccessPoint.h \ - mapview/elements/MV2DElementFloorObstacleCircle.h \ + mapview/2D/MV2DElementFloorObstacleLine.h \ + mapview/2D/MV2DElement.h \ + mapview/2D/MV2DElementFloorOutlinePolygon.h \ + mapview/2D/MV2DElementBeacon.h \ + mapview/2D/MV2DElementAccessPoint.h \ + mapview/2D/MV2DElementFloorObstacleCircle.h \ + mapview/2D/MapViewElementHelper.h \ + mapview/2D/MV2DElementFloorUnderlay.h \ + mapview/2D/MV2DElementPOI.h \ + mapview/2D/MV2DElementStair.h \ + mapview/2D/tools/ToolMoveMap.h \ + mapview/2D/tools/Tools.h \ + mapview/2D/tools/ToolRuler.h \ + mapview/2D/tools/ToolMapZoom.h \ + mapview/2D/tools/ToolSelector.h \ + mapview/2D/tools/ToolMapGrid.h \ + mapview/2D/tools/Tool.h \ mapview/model/MMFloorObstacleCircle.h \ mapview/model/MMFloorObstacleLine.h \ mapview/model/MMFloorOutlinePolygon.h \ @@ -87,11 +88,9 @@ HEADERS += MainWindow.h \ mapview/model/MMFloorAccessPoints.h \ mapview/model/MMFloorBeacons.h \ mapview/model/IHasFile.h \ - mapview/elements/MV2DElementFloorUnderlay.h \ mapview/model/MMFloorUnderlayImage.h \ mapview/model/IHasParams.h \ mapview/model/MMFloorUnderlays.h \ - mapview/elements/MV2DElementPOI.h \ mapview/model/MMFloorPOIs.h \ mapview/model/MMFloorPOI.h \ mapview/3D/MapView3D.h \ @@ -111,7 +110,6 @@ HEADERS += MainWindow.h \ mapview/3D/MV3DElementStair.h \ mapview/model/MMFloorStair.h \ mapview/model/MMFloorStairs.h \ - mapview/elements/MV2DElementStair.h \ params/StairBuilder.h \ misc/GnuplotExport.h \ exp.h \ @@ -121,7 +119,11 @@ HEADERS += MainWindow.h \ mapview/model/IHasDoorType.h \ mapview/3D/MV3DElementFloorObstacleDoor.h \ mapview/3D/misc/Plane.h \ - mapview/elements/HasMoveableNodes.h + mapview/elements/HasMoveableNodes.h \ + mapview/2D/MapView2D.h \ + mapview/2D/Painter.h \ + mapview/2D/Scaler.h + FORMS += MainWindow.ui diff --git a/MainController.cpp b/MainController.cpp index ce5fcd7..24e6ce7 100644 --- a/MainController.cpp +++ b/MainController.cpp @@ -5,11 +5,11 @@ #include "mapview/model/MapModelElement.h" -#include "mapview/tools/ToolSelector.h" -#include "mapview/tools/ToolMoveMap.h" -#include "mapview/tools/ToolMapZoom.h" -#include "mapview/tools/ToolRuler.h" -#include "mapview/tools/ToolMapGrid.h" +#include "mapview/2D/tools/ToolSelector.h" +#include "mapview/2D/tools/ToolMoveMap.h" +#include "mapview/2D/tools/ToolMapZoom.h" +#include "mapview/2D/tools/ToolRuler.h" +#include "mapview/2D/tools/ToolMapGrid.h" #include "params/ElementParamWidget.h" #include "params/LayerParamWidget.h" @@ -49,13 +49,17 @@ MainController::MainController() { ToolMapGrid* mapGrid = new ToolMapGrid(); ToolSelector* mapSelector = new ToolSelector(); - mapView2D->getTools().enable(mapGrid); - mapView2D->getTools().enable(moveMap); - mapView2D->getTools().enable(mapZoom); - mapView2D->getTools().enable(mapSelector); - mapView2D->getTools().enable(ruler); + mapView2D->getTools().addBackground(mapGrid); + mapView2D->getTools().addBackground(moveMap); + mapView2D->getTools().addBackground(mapZoom); + mapView2D->getTools().addBackground(ruler); + + mapView2D->getTools().setMain(mapSelector); + + + //connect(layerTree, SIGNAL(activated(QModelIndex)), this, SLOT(layerSelected(QModelIndex))); + connect(layerTree->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(layerSelected(QModelIndex))); - connect(layerTree, SIGNAL(clicked(QModelIndex)), this, SLOT(layerSelected(QModelIndex))); connect(mapSelector, SIGNAL(onMapElementSelected(MapModelElement*)), this, SLOT(mapElementSelected(MapModelElement*))); connect(mw->getMapView2D(), SIGNAL(onElementChange(MV2DElement*)), this, SLOT(curMapElementChanged())); @@ -77,9 +81,13 @@ MainController::MainController() { connect(mw, &MainWindow::onGridShowEdges, [&] (const bool show) {mw->getMapView3D()->getGridRenderer()->setShowEdges(show);} ); - mapModel->load("../IndoorMap/maps/SHL20.xml"); + //mapModel->load("../IndoorMap/maps/SHL21.xml"); //mapModel->load("../IndoorMap/maps/test.xml"); + //mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/CAR/CAR9.xml"); + //mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UAH/UAH7_test.xml"); + mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UJI-TI/UJI-TI4.xml"); + } void MainController::onShow3DFloorplan() { diff --git a/MainWindow.cpp b/MainWindow.cpp index bf074f5..c77199b 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -2,8 +2,9 @@ #include "ui_MainWindow.h" #include +#include -#include "mapview/MapView2D.h" +#include "mapview/2D/MapView2D.h" #include "mapview/model/MMFloorObstacleLine.h" @@ -11,9 +12,9 @@ #include "mapview/3D/MapView3D.h" -#include "mapview/tools/ToolMoveMap.h" -#include "mapview/tools/ToolRuler.h" -#include "mapview/tools/ToolMapZoom.h" +#include "mapview/2D/tools/ToolMoveMap.h" +#include "mapview/2D/tools/ToolRuler.h" +#include "mapview/2D/tools/ToolMapZoom.h" #include "params/ElementParamWidget.h" #include "params/LayerParamWidget.h" @@ -37,7 +38,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi this->setStyleSheet(css); - layerTree = new QTreeView(); + { + layerTree = new QTreeView(); + QString css; + //css += "QTreeView::item:selected:active {background-color: #888888;}"; + //css += "QTreeView::item:selected:!active {background-color: #888888;}"; + layerTree->setStyleSheet(css); + } mapView2D = new MapView2D(); mapView3D = new MapView3D(); @@ -51,7 +58,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi QDockWidget* toolBoxWidgetDock = new QDockWidget("", this); toolBoxWidgetDock->setWidget(toolBoxWidget); addDockWidget(Qt::LeftDockWidgetArea, toolBoxWidgetDock); - // layers QDockWidget* layerTreeDock = new QDockWidget("layers", this); layerTreeDock->setWidget(layerTree); addDockWidget(Qt::RightDockWidgetArea, layerTreeDock); @@ -68,8 +74,16 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi QDockWidget* actionWidgetDock = new QDockWidget("actions", this); actionWidgetDock->setWidget(actionWidget); addDockWidget(Qt::RightDockWidgetArea, actionWidgetDock); + // status + statusBar = new QStatusBar(); this->setStatusBar(statusBar); + QHBoxLayout* layStatus = new QHBoxLayout(statusBar); statusBar->setLayout(layStatus); + statusBarText1 = new QLabel(statusBar); layStatus->addWidget(statusBarText1); + statusBarText1->setMinimumWidth(200); - + // tools + connect(&mapView2D->getTools(), &Tools::onHelpTextChange, [&] (QString txt) { + statusBarText1->setText(txt); + }); QSplitter* splitter = new QSplitter(Qt::Orientation::Vertical); setCentralWidget(splitter); diff --git a/MainWindow.h b/MainWindow.h index 0c3f658..25ba600 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -6,6 +6,8 @@ class MapView2D; class MapView3D; class QTreeView; +class QStatusBar; +class QLabel; class ElementParamWidget; class LayerParamWidget; class ActionWidget; @@ -53,6 +55,9 @@ private: ActionWidget* actionWidget; ToolBoxWidget* toolBoxWidget; + QStatusBar* statusBar; + QLabel* statusBarText1; + }; #endif // MAINWINDOW_H diff --git a/mapview/elements/HasMoveableNodes.h b/mapview/2D/HasMoveableNodes.h similarity index 97% rename from mapview/elements/HasMoveableNodes.h rename to mapview/2D/HasMoveableNodes.h index 48c2ff2..610eeee 100644 --- a/mapview/elements/HasMoveableNodes.h +++ b/mapview/2D/HasMoveableNodes.h @@ -2,7 +2,7 @@ #define MV2D_IHASMOVEABLENODES_H #include -#include "../MapView2D.h" +#include "../2D/MapView2D.h" /** the selectable/moveable node */ struct MoveableNode { @@ -20,7 +20,7 @@ struct MoveableNode { }; /** - * base for all 2D elements that have selectable and moveable nodes + * base for all 2D elements that have selectable and moveable nodes. * the ToolSelector is able to get, select, and move those nodes */ class HasMoveableNodes { diff --git a/mapview/elements/MV2DElement.h b/mapview/2D/MV2DElement.h similarity index 69% rename from mapview/elements/MV2DElement.h rename to mapview/2D/MV2DElement.h index 71e4f17..32cf049 100644 --- a/mapview/elements/MV2DElement.h +++ b/mapview/2D/MV2DElement.h @@ -3,8 +3,8 @@ #include -#include "../MapView2D.h" -#include "../Painter.h" +#include "../2D/MapView2D.h" +#include "../2D/Painter.h" #include #include @@ -52,16 +52,16 @@ public: /** mouse pressed at the given point */ - virtual void mousePressed(MapView2D* v, const Point2 p) = 0; + virtual void mousePressed(MapView2D* v, const Point2 p) {(void) v; (void) p;} /** mouse moved to the given point */ - virtual void mouseMove(MapView2D* v, const Point2 p) = 0; + virtual void mouseMove(MapView2D* v, const Point2 p) {(void) v; (void) p;} /** mouse released */ - virtual void mouseReleased(MapView2D* v, const Point2 p) = 0; + virtual void mouseReleased(MapView2D* v, const Point2 p) {(void) v; (void) p;} - /** key pressed. return true when consumed. */ - virtual bool keyPressEvent(MapView2D* v, QKeyEvent* e) = 0; + /** key pressed. NOTE: return true when consumed. */ + virtual bool keyPressEvent(MapView2D* v, QKeyEvent* e) {(void) v; (void) e; return false;} protected: diff --git a/mapview/elements/MV2DElementAccessPoint.h b/mapview/2D/MV2DElementAccessPoint.h similarity index 96% rename from mapview/elements/MV2DElementAccessPoint.h rename to mapview/2D/MV2DElementAccessPoint.h index 922dd85..a9d3c37 100644 --- a/mapview/elements/MV2DElementAccessPoint.h +++ b/mapview/2D/MV2DElementAccessPoint.h @@ -80,20 +80,16 @@ public: } - /** mouse pressed at the given point */ virtual void mousePressed(MapView2D* v, const Point2 p) override { (void) v; (void) p; - } - /** mouse moved to the given point */ virtual void mouseMove(MapView2D* v, const Point2 p) override { (void) v; (void) p; } - /** mouse released */ virtual void mouseReleased(MapView2D* v, const Point2 p) override { (void) v; (void) p; diff --git a/mapview/elements/MV2DElementBeacon.h b/mapview/2D/MV2DElementBeacon.h similarity index 100% rename from mapview/elements/MV2DElementBeacon.h rename to mapview/2D/MV2DElementBeacon.h diff --git a/mapview/elements/MV2DElementFloorObstacleCircle.h b/mapview/2D/MV2DElementFloorObstacleCircle.h similarity index 100% rename from mapview/elements/MV2DElementFloorObstacleCircle.h rename to mapview/2D/MV2DElementFloorObstacleCircle.h diff --git a/mapview/elements/MV2DElementFloorObstacleDoor.h b/mapview/2D/MV2DElementFloorObstacleDoor.h similarity index 100% rename from mapview/elements/MV2DElementFloorObstacleDoor.h rename to mapview/2D/MV2DElementFloorObstacleDoor.h diff --git a/mapview/elements/MV2DElementFloorObstacleLine.h b/mapview/2D/MV2DElementFloorObstacleLine.h similarity index 57% rename from mapview/elements/MV2DElementFloorObstacleLine.h rename to mapview/2D/MV2DElementFloorObstacleLine.h index c8baeda..f415afd 100644 --- a/mapview/elements/MV2DElementFloorObstacleLine.h +++ b/mapview/2D/MV2DElementFloorObstacleLine.h @@ -2,14 +2,15 @@ #define MV2DELEMENTFLOOROBSTACLELINE_H #include "MV2DElement.h" +#include "HasMoveableNodes.h" + #include "MapViewElementHelper.h" #include -class MV2DElementFloorObstacleLine : public MV2DElement { +class MV2DElementFloorObstacleLine : public MV2DElement, public HasMoveableNodes { private: - int selPoint = -1; Floorplan::FloorObstacleLine* fo; public: @@ -38,8 +39,8 @@ public: // selected endpoints? if (hasFocus()) { p.setPenBrush(Qt::NoPen, CFG::SEL_COLOR); - if (selPoint == 0) {p.drawCircle(fo->from);} - if (selPoint == 1) {p.drawCircle(fo->to);} + if (selectedUserIdx == 0) {p.drawCircle(fo->from);} + if (selectedUserIdx == 1) {p.drawCircle(fo->to);} } @@ -86,52 +87,25 @@ public: } - virtual void onFocus() override { + void onFocus() override { ; } - virtual void onUnfocus() override { - selPoint = -1; // clear selection + void onUnfocus() override { + selectedUserIdx = -1; // clear selection } - /** mouse pressed at the given point */ - virtual void mousePressed(MapView2D* v, const Point2 p) override { + virtual std::vector getMoveableNodes() const override { + return { + MoveableNode(0, fo->from), + MoveableNode(1, fo->to) + }; + } + + void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override { (void) v; - (void) p; - - } - - /** mouse moved to the given point */ - virtual void mouseMove(MapView2D* v, const Point2 _p) override { - (void) v; - if (selPoint == -1) {return;} - const Point2 p = v->getScaler().snap(_p); - if (selPoint == 0) {fo->from.x = p.x; fo->from.y = p.y;} - if (selPoint == 1) {fo->to.x = p.x; fo->to.y = p.y;} - } - - /** mouse released */ - virtual void mouseReleased(MapView2D* v, const Point2 _p) override { -// (void) v; -// if (selPoint == -1) {return;} -// const Point3 p = Scaler::snap(_p, CFG::MOVE_SNAP_SIZE_M); -// if (selPoint == 0) {fo.from.x = p.x; fo.from.y = p.y;} -// if (selPoint == 1) {fo.to.x = p.x; fo.to.y = p.y;} - - // select a new point on mouse-release (more robust than on mouse-press) - const float t = v->getScaler().sm(CFG::SEL_THRESHOLD_SIZE_PX); - const float l1 = _p.getDistance(fo->from); - const float l2 = _p.getDistance(fo->to); - if (l1 < l2 && l1 <= t) {selPoint = 0;} - else if (l2 < l1 && l2 <= t) {selPoint = 1;} - else {selPoint = -1;} - - } - - virtual bool keyPressEvent(MapView2D* v, QKeyEvent *e) override { - (void) v; - (void) e; - return false; + if (userIdx == 0) {fo->from.x = newPos.x; fo->from.y = newPos.y;} + if (userIdx == 1) {fo->to.x = newPos.x; fo->to.y = newPos.y;} } }; diff --git a/mapview/elements/MV2DElementFloorOutlinePolygon.h b/mapview/2D/MV2DElementFloorOutlinePolygon.h similarity index 50% rename from mapview/elements/MV2DElementFloorOutlinePolygon.h rename to mapview/2D/MV2DElementFloorOutlinePolygon.h index 34f10e1..f9bd0a4 100644 --- a/mapview/elements/MV2DElementFloorOutlinePolygon.h +++ b/mapview/2D/MV2DElementFloorOutlinePolygon.h @@ -2,15 +2,15 @@ #define MV2DELEMENTFLOOROUTLINEPOLYGON_H #include "MV2DElement.h" +#include "HasMoveableNodes.h" #include "MapViewElementHelper.h" #include -class MV2DElementFloorOutlinePolygon : public MV2DElement { +class MV2DElementFloorOutlinePolygon : public MV2DElement, public HasMoveableNodes { private: - int selPoint = -1; Floorplan::FloorOutlinePolygon& fo; public: @@ -42,7 +42,7 @@ public: } virtual void onUnfocus() override { - selPoint = -1; // clear selection + selectedUserIdx = -1; // clear selection } void paint(Painter& p) override { @@ -69,9 +69,9 @@ public: p.drawPolygon(fo.poly.points); // selected endpoints? - if (hasFocus() && selPoint != -1) { + if (hasFocus() && selectedUserIdx != -1) { p.setPenBrush(Qt::NoPen, CFG::SEL_COLOR); - p.drawCircle(fo.poly.points[selPoint]); + p.drawCircle(fo.poly.points[selectedUserIdx]); } // available endpoints @@ -85,38 +85,54 @@ public: } - virtual void mousePressed(MapView2D* v, const Point2 p) override { - (void) v; - (void) p; + /** get a list of all nodes that are selectable / moveable */ + virtual std::vector getMoveableNodes() const override { + std::vector nodes; + for (int i = 0; i < (int) fo.poly.points.size(); ++i) { + nodes.push_back(MoveableNode(i, fo.poly.points[i])); + } + return nodes; } - virtual void mouseMove(MapView2D* v, const Point2 _p) override { + /** the given node was moved */ + virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override { (void) v; - if (selPoint == -1) {return;} - const Point2 p = v->getScaler().snap(_p); - fo.poly.points[selPoint].x = p.x; - fo.poly.points[selPoint].y = p.y; + fo.poly.points[userIdx].x = newPos.x; + fo.poly.points[userIdx].y = newPos.y; } - virtual void mouseReleased(MapView2D* v, const Point2 _p) override { +// virtual void mousePressed(MapView2D* v, const Point2 p) override { +// (void) v; +// (void) p; +// } - (void) v; +// virtual void mouseMove(MapView2D* v, const Point2 _p) override { +// (void) v; +// if (selPoint == -1) {return;} +// const Point2 p = v->getScaler().snap(_p); +// fo.poly.points[selPoint].x = p.x; +// fo.poly.points[selPoint].y = p.y; +// } - // if (selPoint != -1) { - // const Point3 p = Scaler::snap(_p, CFG::MOVE_SNAP_SIZE_M); - // fo.poly.points[selPoint].x = p.x; - // fo.poly.points[selPoint].y = p.y; - // } +// virtual void mouseReleased(MapView2D* v, const Point2 _p) override { - // select a new point on mouse-release (more robust than on mouse-press) - const float t = v->getScaler().sm(CFG::SEL_THRESHOLD_SIZE_PX); - auto comp = [&] (const Point2 a, const Point2 b) {return a.getDistance(_p) < b.getDistance(_p);}; - auto it = std::min_element(fo.poly.points.begin(), fo.poly.points.end(), comp); - if (it == fo.poly.points.end()) {selPoint = -1;} // none found -> skip - else if ((*it).getDistance(_p) > t) {selPoint = -1;} // nearest distance is above threshold -> skip - else {selPoint = it - fo.poly.points.begin();} +// (void) v; - } +// // if (selPoint != -1) { +// // const Point3 p = Scaler::snap(_p, CFG::MOVE_SNAP_SIZE_M); +// // fo.poly.points[selPoint].x = p.x; +// // fo.poly.points[selPoint].y = p.y; +// // } + +// // select a new point on mouse-release (more robust than on mouse-press) +// const float t = v->getScaler().sm(CFG::SEL_THRESHOLD_SIZE_PX); +// auto comp = [&] (const Point2 a, const Point2 b) {return a.getDistance(_p) < b.getDistance(_p);}; +// auto it = std::min_element(fo.poly.points.begin(), fo.poly.points.end(), comp); +// if (it == fo.poly.points.end()) {selPoint = -1;} // none found -> skip +// else if ((*it).getDistance(_p) > t) {selPoint = -1;} // nearest distance is above threshold -> skip +// else {selPoint = it - fo.poly.points.begin();} + +// } virtual bool keyPressEvent(MapView2D* v, QKeyEvent *e) override { (void) v; @@ -125,19 +141,19 @@ public: if (e->key() == Qt::Key_Delete) { // delete the currently selected vertex? - if (selPoint != -1) { - fo.poly.points.erase(fo.poly.points.begin() + selPoint); - selPoint = -1; + if (selectedUserIdx != -1) { + fo.poly.points.erase(fo.poly.points.begin() + selectedUserIdx); + selectedUserIdx = -1; return true; } - } else if (e->key() == Qt::Key_Plus && selPoint != -1) { - int idx1 = selPoint; - int idx2 = (selPoint + 1) % fo.poly.points.size(); + } else if (e->key() == Qt::Key_Plus && selectedUserIdx != -1) { + int idx1 = selectedUserIdx; + int idx2 = (selectedUserIdx + 1) % fo.poly.points.size(); int idxNew = idx2; Point2 pNew = (fo.poly.points[idx1] + fo.poly.points[idx2]) / 2.0f; fo.poly.points.insert(fo.poly.points.begin() + idxNew, pNew); - selPoint = idxNew; + selectedUserIdx = idxNew; return true; } diff --git a/mapview/elements/MV2DElementFloorUnderlay.h b/mapview/2D/MV2DElementFloorUnderlay.h similarity index 99% rename from mapview/elements/MV2DElementFloorUnderlay.h rename to mapview/2D/MV2DElementFloorUnderlay.h index 0c4d1a5..ee09ac3 100644 --- a/mapview/elements/MV2DElementFloorUnderlay.h +++ b/mapview/2D/MV2DElementFloorUnderlay.h @@ -88,7 +88,7 @@ public: float opacity = p.p->opacity(); - p.p->setOpacity(0.65f); + p.p->setOpacity(0.50f); p.p->drawImage(QRectF(sx1, sy1-sh, sw, sh), img, QRectF(0,0,img.width(),img.height())); p.p->setOpacity(opacity); diff --git a/mapview/elements/MV2DElementPOI.h b/mapview/2D/MV2DElementPOI.h similarity index 100% rename from mapview/elements/MV2DElementPOI.h rename to mapview/2D/MV2DElementPOI.h diff --git a/mapview/elements/MV2DElementStair.h b/mapview/2D/MV2DElementStair.h similarity index 98% rename from mapview/elements/MV2DElementStair.h rename to mapview/2D/MV2DElementStair.h index 8e5bccb..05c196f 100644 --- a/mapview/elements/MV2DElementStair.h +++ b/mapview/2D/MV2DElementStair.h @@ -118,13 +118,18 @@ public: if (quad.p1.z != floor->getStartingZ()) { p.drawLine(quad.p1, quad.p2); } - } - if (i == (int) parts.size() - 1) { + } else if (i == (int) parts.size() - 1) { if (quad.p3.z != floor->getEndingZ()) { p.drawLine(quad.p3, quad.p4); } } + if (i > 0) { + if (quads[i-1].p4.z != quads[i-0].p1.z) { + p.drawLine(quad.p1, quad.p2); + } + } + } if (hasFocus()) { diff --git a/mapview/MapView2D.h b/mapview/2D/MapView2D.h similarity index 97% rename from mapview/MapView2D.h rename to mapview/2D/MapView2D.h index 92fb050..e05e21e 100644 --- a/mapview/MapView2D.h +++ b/mapview/2D/MapView2D.h @@ -8,7 +8,7 @@ class MapModel; class MV2DElement; -#include "mapview/tools/Tools.h" +#include "tools/Tools.h" /** diff --git a/mapview/elements/MapViewElementHelper.h b/mapview/2D/MapViewElementHelper.h similarity index 92% rename from mapview/elements/MapViewElementHelper.h rename to mapview/2D/MapViewElementHelper.h index 5156709..6ad31ba 100644 --- a/mapview/elements/MapViewElementHelper.h +++ b/mapview/2D/MapViewElementHelper.h @@ -69,6 +69,9 @@ public: if (mat == Material::CONCRETE) {pen.setWidth(3);} if (mat == Material::GLASS) {pen.setStyle(Qt::PenStyle::DotLine);} if (type == ObstacleType::HANDRAIL) {pen.setStyle(Qt::PenStyle::DashLine);} + if (type == ObstacleType::UNKNOWN) {pen.setColor(Qt::red); pen.setWidth(5);} + if (type == ObstacleType::PILLAR) {pen.setColor(Qt::red); pen.setWidth(5);} + return pen; } diff --git a/mapview/Painter.h b/mapview/2D/Painter.h similarity index 98% rename from mapview/Painter.h rename to mapview/2D/Painter.h index 10ec592..b2a9f07 100644 --- a/mapview/Painter.h +++ b/mapview/2D/Painter.h @@ -58,6 +58,7 @@ public: p->drawEllipse(s.xms(center.x)-r, s.yms(center.y)-r, 2*r, 2*r); } + /** draw a dot at the given map coordinates */ void drawDot(const Point2 center) { int r = 1; p->drawEllipse(s.xms(center.x)-r, s.yms(center.y)-r, 2*r, 2*r); diff --git a/mapview/Scaler.h b/mapview/2D/Scaler.h similarity index 97% rename from mapview/Scaler.h rename to mapview/2D/Scaler.h index 1eca86a..cf3faf6 100644 --- a/mapview/Scaler.h +++ b/mapview/2D/Scaler.h @@ -42,6 +42,10 @@ public: float xsm(const float x) const {return ((x-w/2)/_scale)-_offset.x;} /** y screen->map */ float ysm(const float y) const {return ((h/2-y)/_scale)+_offset.y;} + /** x,y screen->map */ + Point2 sm(const Point2 p) const {return Point2(xsm(p.x), ysm(p.y));} + + void setScale(const float s) {_scale = s;} float getScale() const {return _scale;} diff --git a/mapview/tools/Tool.cpp b/mapview/2D/tools/Tool.cpp similarity index 100% rename from mapview/tools/Tool.cpp rename to mapview/2D/tools/Tool.cpp diff --git a/mapview/2D/tools/Tool.h b/mapview/2D/tools/Tool.h new file mode 100644 index 0000000..f74cc04 --- /dev/null +++ b/mapview/2D/tools/Tool.h @@ -0,0 +1,58 @@ +#ifndef TOOL_H +#define TOOL_H + +#include +#include +#include + +#include "../Painter.h" + +class MapView2D; + +/** + * interface for every MapView tool. + * a tool may be a background tool (e.g. a ruler-display, grid, ..) + * or a foreground (active) one, which e.g. selects nodes, creates a new element, ... + */ +class Tool : public QObject { + + Q_OBJECT + +public: + + Tool() {;} + + virtual ~Tool() {;} + + /** the tool must return its name here */ + virtual const std::string getName() const = 0; + + /** the tool was activated (by user or by code) */ + virtual void becomesActive() {;} + + /** the tool was deactivated (by user or by code) */ + virtual void becomesInactive() {;} + + + /** events: return TRUE when you consumed the event */ + + virtual bool mousePressEvent(MapView2D* m, QMouseEvent* e) { (void) m; (void) e; return false; } + virtual bool mouseMoveEvent(MapView2D* m, QMouseEvent* e) { (void) m; (void) e; return false; } + virtual bool mouseReleaseEvent(MapView2D* m, QMouseEvent* e) { (void) m; (void) e; return false; } + + virtual bool wheelEvent(MapView2D* m, QWheelEvent* e) { (void) m; (void) e; return false; } + + virtual bool keyPressEvent(MapView2D* m, QKeyEvent* e) { (void) m; (void) e; return false; } + + virtual void paintBefore(MapView2D* m, Painter& p) { (void) m; (void) p; } + virtual void paintAfter(MapView2D* m, Painter& p) { (void) m; (void) p; } + + virtual void layerChange(MapView2D* m) { (void) m; } + +signals: + + void onHelpTextChange(QString str); + +}; + +#endif // TOOL_H diff --git a/mapview/tools/ToolMapGrid.h b/mapview/2D/tools/ToolMapGrid.h similarity index 86% rename from mapview/tools/ToolMapGrid.h rename to mapview/2D/tools/ToolMapGrid.h index ce1f5e4..f903a4b 100644 --- a/mapview/tools/ToolMapGrid.h +++ b/mapview/2D/tools/ToolMapGrid.h @@ -11,9 +11,14 @@ private: public: - virtual void keyPressEvent(MapView2D* m, QKeyEvent* e) { + const std::string getName() const override { + return "MapGrid"; + } + + virtual bool keyPressEvent(MapView2D* m, QKeyEvent* e) override { (void) m; - if (e->key() == Qt::Key_NumberSign) { show = !show; } + if (e->key() == Qt::Key_NumberSign) { show = !show; return true; } + return false; } void paintBefore(MapView2D* m, Painter& p) override { diff --git a/mapview/tools/ToolMapZoom.h b/mapview/2D/tools/ToolMapZoom.h similarity index 65% rename from mapview/tools/ToolMapZoom.h rename to mapview/2D/tools/ToolMapZoom.h index 83acb9b..d8468c5 100644 --- a/mapview/tools/ToolMapZoom.h +++ b/mapview/2D/tools/ToolMapZoom.h @@ -4,11 +4,18 @@ #include "Tool.h" #include "../MapView2D.h" +/** + * this tool allows zooming in and out of the map + */ class ToolMapZoom : public Tool { public: - virtual void wheelEvent(MapView2D* m, QWheelEvent* e) override { + const std::string getName() const override { + return "MapZoom"; + } + + virtual bool wheelEvent(MapView2D* m, QWheelEvent* e) override { Scaler& s = m->getScaler(); @@ -21,6 +28,8 @@ public: if (s.getScale() > 1000) {s.setScale(1000);} if (s.getScale() < 5) {s.setScale(5);} + return true; + } }; diff --git a/mapview/tools/ToolMoveMap.h b/mapview/2D/tools/ToolMoveMap.h similarity index 52% rename from mapview/tools/ToolMoveMap.h rename to mapview/2D/tools/ToolMoveMap.h index 72cf959..b27ef11 100644 --- a/mapview/tools/ToolMoveMap.h +++ b/mapview/2D/tools/ToolMoveMap.h @@ -5,7 +5,7 @@ #include "../MapView2D.h" /** - * + * this tool allows moving the 2D map */ class ToolMoveMap : public Tool { @@ -16,32 +16,42 @@ private: int sx; int sy; - virtual void mousePressEvent(MapView2D* m, QMouseEvent* e) override { + const std::string getName() const override { + return "MapMove"; + } + +public: + + virtual bool mousePressEvent(MapView2D* m, QMouseEvent* e) override { if (e->button() == Qt::MouseButton::MidButton) { mouseIsDown = true; this->sx = e->x(); this->sy = e->y(); this->startOffset = m->getScaler().getOffset(); + return true; } + return false; } - virtual void mouseMoveEvent(MapView2D* m, QMouseEvent* e) override { - if (!mouseIsDown) {return;} + virtual bool mouseMoveEvent(MapView2D* m, QMouseEvent* e) override { + if (!mouseIsDown) {return false;} m->getScaler().setOffset(startOffset); m->getScaler().addOffset(e->x()-sx, e->y()-sy); + return true; } - virtual void mouseReleaseEvent(MapView2D* m, QMouseEvent* e) override { + virtual bool mouseReleaseEvent(MapView2D* m, QMouseEvent* e) override { (void) m; (void) e; mouseIsDown = false; + return false; } - virtual void keyPressEvent(MapView2D* m, QKeyEvent* e) override { - (void) m; - (void) e; - // TODO: move on arrow keys? - } +// virtual void keyPressEvent(MapView2D* m, QKeyEvent* e) override { +// (void) m; +// (void) e; +// // TODO: move on arrow keys? +// } }; diff --git a/mapview/tools/ToolRuler.h b/mapview/2D/tools/ToolRuler.h similarity index 87% rename from mapview/tools/ToolRuler.h rename to mapview/2D/tools/ToolRuler.h index 8893529..2adbaf1 100644 --- a/mapview/tools/ToolRuler.h +++ b/mapview/2D/tools/ToolRuler.h @@ -3,6 +3,9 @@ #include "Tool.h" +/** + * draw a ruler into the 2D map view + */ class ToolRuler : public Tool { private: @@ -17,12 +20,19 @@ private: public: - virtual void mouseMoveEvent(MapView2D* m, QMouseEvent* e) override { + const std::string getName() const override { + return "MapRuler"; + } + + virtual bool mouseMoveEvent(MapView2D* m, QMouseEvent* e) override { (void) m; this->mouseX = e->x(); this->mouseY = e->y(); + + return false; + } virtual void paintBefore(MapView2D* m, Painter& p) override { @@ -129,9 +139,14 @@ public: p.p->drawText(xMajor+2, 18, buf); } - p.p->setClipping(false); + // snapped dot + const Point2 mouseOnScreen(mouseX, mouseY); + const Point2 mouseInMap = p.s.sm(mouseOnScreen); + const Point2 snappedMouseInMap = p.s.snap(mouseInMap); + p.drawDot(snappedMouseInMap); + } }; diff --git a/mapview/tools/ToolSelector.cpp b/mapview/2D/tools/ToolSelector.cpp similarity index 100% rename from mapview/tools/ToolSelector.cpp rename to mapview/2D/tools/ToolSelector.cpp diff --git a/mapview/tools/ToolSelector.h b/mapview/2D/tools/ToolSelector.h similarity index 86% rename from mapview/tools/ToolSelector.h rename to mapview/2D/tools/ToolSelector.h index 3c4d2e9..054f022 100644 --- a/mapview/tools/ToolSelector.h +++ b/mapview/2D/tools/ToolSelector.h @@ -1,15 +1,17 @@ #ifndef TOOLSELECTOR_H #define TOOLSELECTOR_H + #include "Tool.h" -#include "../model/MapModelElement.h" #include "../MapView2D.h" -#include "../model/MapModel.h" + +#include "../../model/MapModelElement.h" +#include "../../model/MapModel.h" /** * this tool allows: - * - selecting 2D elements within the view (focus/unfocus) + * - selecting elements within the 2D view (focus/unfocus) * - selecting and moving nodes of elements inheriting from HasMoveableNodes * */ @@ -30,7 +32,13 @@ public: virtual ~ToolSelector() {;} + const std::string getName() const override { + return "Selection"; + } + void becomesActive() override { + showHelp(); + } /** needed eg. when the focused element gets invalid (switching visible layers) */ void layerChange(MapView2D* m) override { @@ -141,6 +149,11 @@ private: private: + void showHelp() { + if (focused) {emit onHelpTextChange("select one of the element's nodes");} + if (!focused) {emit onHelpTextChange("select an element by clicking on it");} + } + /** * @brief change the currently focused element. throws an event. * @param el the to-be-focused element or null @@ -162,6 +175,9 @@ private: // focus the new one (if any) if (focused) {focused->getMV2D()->focus();} + // update the help-text + showHelp(); + emit onMapElementSelected(el); } @@ -175,9 +191,9 @@ private: private: - virtual void mousePressEvent(MapView2D* m, QMouseEvent* e) override { + virtual bool mousePressEvent(MapView2D* m, QMouseEvent* e) override { - if (e->button() != Qt::MouseButton::LeftButton) {return;} + if (e->button() != Qt::MouseButton::LeftButton) {return false;} mouseIsDown = true; @@ -216,9 +232,11 @@ private: } + return true; + } - virtual void mouseMoveEvent(MapView2D* m, QMouseEvent* e) override { + virtual bool mouseMoveEvent(MapView2D* m, QMouseEvent* e) override { const Scaler& s = m->getScaler(); Point2 p2(s.xsm(e->x()), s.ysm(e->y())); @@ -231,9 +249,11 @@ private: } + return false; + } - virtual void mouseReleaseEvent(MapView2D* m, QMouseEvent* e) override { + virtual bool mouseReleaseEvent(MapView2D* m, QMouseEvent* e) override { const Scaler& s = m->getScaler(); Point2 p2(s.xsm(e->x()), s.ysm(e->y())); @@ -243,15 +263,18 @@ private: mouseIsDown = false; + return false; + } - virtual void keyPressEvent(MapView2D* m, QKeyEvent* e) override { + virtual bool keyPressEvent(MapView2D* m, QKeyEvent* e) override { + (void) m; if (focused) { // pass it to the element which may consume this event - if (focused->getMV2D()->keyPressEvent(m, e)) {return;} + if (focused->getMV2D()->keyPressEvent(m, e)) {return false;} // not consumed -> additional options @@ -262,10 +285,13 @@ private: if (e->key() == Qt::Key_Delete) { focused->deleteMe(); setFocused(m, nullptr); + return true; } } + return false; + } signals: diff --git a/mapview/2D/tools/Tools.cpp b/mapview/2D/tools/Tools.cpp new file mode 100644 index 0000000..e69de29 diff --git a/mapview/2D/tools/Tools.h b/mapview/2D/tools/Tools.h new file mode 100644 index 0000000..44542e4 --- /dev/null +++ b/mapview/2D/tools/Tools.h @@ -0,0 +1,126 @@ +#ifndef TOOLS_H +#define TOOLS_H + +#include +#include "Tool.h" + +/** + * combine several tools under the interface for one tool + */ +class Tools : public QObject { //public Tool { + + Q_OBJECT + +private: + + /** all added tools */ + std::vector backgroundTools; + Tool* mainTool = nullptr; + + +signals: + + void mainToolChanged(); + + void onHelpTextChange(QString str); + + +public: + + Tools() { + ; + } + + virtual ~Tools() { + ; + } + + + + const std::string getName() const {//override { + return (mainTool) ? (mainTool->getName()) : (""); + } + + + /** add a new background-helper-tool (ruler, grid, ..) those are always processed! */ + void addBackground(Tool* t) { + backgroundTools.push_back(t); + } + + /** remove this tool */ + void removeBackground(Tool* t) { + backgroundTools.erase(std::remove(backgroundTools.begin(), backgroundTools.end(), t)); + } + + /** set the currently active main tool. there is only one that can be active! (e.g. selector, new wall, new polygon, ..) */ + void setMain(Tool* t) { + if (this->mainTool) { + this->mainTool->becomesInactive(); + disconnect(this->mainTool, &Tool::onHelpTextChange, this, &Tools::onHelpTextChange); + } + this->mainTool = t; + emit mainToolChanged(); + if (this->mainTool) { + connect(this->mainTool, &Tool::onHelpTextChange, this, &Tools::onHelpTextChange); + this->mainTool->becomesActive(); + } + } + + /** get the current main tool */ + Tool* getMain() { + return this->mainTool; + } + + + + + virtual bool mousePressEvent(MapView2D* m, QMouseEvent* e) {//override { + if (mainTool) {mainTool->mousePressEvent(m, e);} + for (Tool* t : backgroundTools) { if(t->mousePressEvent(m, e)) {return true;} } + return false; + } + + virtual bool mouseMoveEvent(MapView2D* m, QMouseEvent* e) {//override { + if (mainTool) {mainTool->mouseMoveEvent(m, e);} + for (Tool* t : backgroundTools) { if(t->mouseMoveEvent(m, e)) {return true;} } + return false; + } + + virtual bool mouseReleaseEvent(MapView2D* m, QMouseEvent* e) {//override { + if (mainTool) {mainTool->mouseReleaseEvent(m, e);} + for (Tool* t : backgroundTools) { if(t->mouseReleaseEvent(m, e)) {return true;} } + return false; + } + + virtual bool wheelEvent(MapView2D* m, QWheelEvent* e) {//override { + if (mainTool) {mainTool->wheelEvent(m, e);} + for (Tool* t : backgroundTools) { if(t->wheelEvent(m, e)) {return true;} } + return false; + } + + virtual bool keyPressEvent(MapView2D* m, QKeyEvent* e) {//override { + if (mainTool) {mainTool->keyPressEvent(m, e);} + for (Tool* t : backgroundTools) { if(t->keyPressEvent(m, e)) {return true;} } + return false; + } + + + virtual void paintBefore(MapView2D* m, Painter& p) {//override { + for (Tool* t : backgroundTools) {t->paintBefore(m, p);} + if (mainTool) {mainTool->paintBefore(m, p);} + } + + virtual void paintAfter(MapView2D* m, Painter& p) {//override { + for (Tool* t : backgroundTools) {t->paintAfter(m, p);} + if (mainTool) {mainTool->paintAfter(m, p);} + } + + virtual void layerChange(MapView2D* m) {//override { + for (Tool* t : backgroundTools) {t->layerChange(m);} + if (mainTool) {mainTool->layerChange(m);} + } + + +}; + +#endif // TOOLS_H diff --git a/mapview/3D/MapView3D.cpp b/mapview/3D/MapView3D.cpp index e3fc841..8c762bd 100644 --- a/mapview/3D/MapView3D.cpp +++ b/mapview/3D/MapView3D.cpp @@ -32,6 +32,8 @@ void MapView3D::initializeGL() { QGLWidget::initializeGL(); + //glCullFace(GL_FRONT); + // culling, lighting, depth-test, ... glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); @@ -42,6 +44,7 @@ void MapView3D::initializeGL() { glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); + //glEnable(GL_LIGHT1); GLfloat light0_position [] = {+50, 50, +50, 1}; @@ -89,7 +92,7 @@ void MapView3D::paintGL() { glTranslatef(center.x, center.z, center.y); // 0) swap the y axis - //glScalef(+1, -1, +1); + glScalef(+1, -1, +1); @@ -110,9 +113,6 @@ void MapView3D::resizeGL(int width, int height) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); -#ifdef QT_OPENGL_ES_1 - //glOrthof(-2, +2, -2, +2, 1.0, 15.0); -#else //glOrtho(-2, +2, -2, +2, 1.0, 25.0); //glFrustum(-1,1, -1,1, 0.1,20); viewport.size.x = 2.0f; @@ -120,8 +120,12 @@ void MapView3D::resizeGL(int width, int height) { const float w = viewport.size.x; const float h = viewport.size.y; glOrtho(-w, +w, -h, +h, -20, +20); + //glScalef(1,-1,1); + //glFrustum(+w, -w, -h, +h, -20, +20); -#endif + + + glMatrixMode(GL_MODELVIEW); } @@ -137,10 +141,10 @@ void MapView3D::mouseMoveEvent(QMouseEvent* e) { float dx = mouse.x - e->x(); float dy = mouse.y - e->y(); if (mouse.btn == 1) { - rot.z -= dx/2.0f; // upward + rot.z += dx/2.0f; // upward rot.x -= dy/2.0f; } else if (mouse.btn == 4) { - Point3 vec(-dx / width() * 2 * viewport.size.x, 0, dy / height() * 2 * viewport.size.y); + Point3 vec(-dx / width() * 2 * viewport.size.x, 0, +dy / height() * 2 * viewport.size.y); vec = vec.rot(rot.x/180*M_PI, rot.y/180*M_PI, rot.z/180*M_PI); vec /= scale; center += vec; diff --git a/mapview/3DGrid/GridModel.h b/mapview/3DGrid/GridModel.h index e106726..ab24063 100644 --- a/mapview/3DGrid/GridModel.h +++ b/mapview/3DGrid/GridModel.h @@ -84,7 +84,7 @@ public: GridFactory fac(grid); fac.build(im, &l); - Importance::addImportance(grid, 0); + Importance::addImportance(grid); //Importance::addImportance(grid, 400); } diff --git a/mapview/3DGrid/GridRenderer.h b/mapview/3DGrid/GridRenderer.h index e71ccba..3e668ec 100644 --- a/mapview/3DGrid/GridRenderer.h +++ b/mapview/3DGrid/GridRenderer.h @@ -80,7 +80,7 @@ public: } case GridRendererColorMode::SHOW_NODE_IMPORTANCE: { - const float xx = n.imp - 0.6; + const float xx = n.navImportance - 0.6; glColor3f(xx, xx, xx); break; } diff --git a/mapview/3DGrid/MyNode.h b/mapview/3DGrid/MyNode.h index 192d22a..05c10b3 100644 --- a/mapview/3DGrid/MyNode.h +++ b/mapview/3DGrid/MyNode.h @@ -2,10 +2,9 @@ #define MYNODE_H #include +#include -struct MyNode : public GridNode, public GridPoint { - - float imp; +struct MyNode : public GridNode, public GridPoint, public GridNodeImportance { MyNode(float x, float y, float z) : GridPoint(x,y,z) {;} diff --git a/mapview/MapView2D.cpp b/mapview/MapView2D.cpp index 0f435c0..271a94f 100644 --- a/mapview/MapView2D.cpp +++ b/mapview/MapView2D.cpp @@ -1,4 +1,4 @@ -#include "MapView2D.h" +#include "2D/MapView2D.h" #include #include diff --git a/mapview/model/MMFloorAccessPoint.h b/mapview/model/MMFloorAccessPoint.h index 656dcfd..b364956 100644 --- a/mapview/model/MMFloorAccessPoint.h +++ b/mapview/model/MMFloorAccessPoint.h @@ -4,7 +4,7 @@ #include "MapModelElement.h" #include "IHasParams.h" -#include "../elements/MV2DElementAccessPoint.h" +#include "../2D/MV2DElementAccessPoint.h" #include "../3D/MV3DElementAccessPoint.h" #include diff --git a/mapview/model/MMFloorBeacon.h b/mapview/model/MMFloorBeacon.h index 0f01bde..eb6f078 100644 --- a/mapview/model/MMFloorBeacon.h +++ b/mapview/model/MMFloorBeacon.h @@ -4,7 +4,7 @@ #include "MapModelElement.h" #include "IHasParams.h" -#include "../elements/MV2DElementBeacon.h" +#include "../2D/MV2DElementBeacon.h" #include diff --git a/mapview/model/MMFloorObstacleCircle.h b/mapview/model/MMFloorObstacleCircle.h index 6737530..313dfb6 100644 --- a/mapview/model/MMFloorObstacleCircle.h +++ b/mapview/model/MMFloorObstacleCircle.h @@ -3,12 +3,12 @@ #include "MapModelElement.h" -#include "../elements/MapViewElementHelper.h" +#include "../2D/MapViewElementHelper.h" #include "IHasMaterial.h" #include "IHasObstacleType.h" -#include "../elements/MV2DElementFloorObstacleCircle.h" +#include "../2D/MV2DElementFloorObstacleCircle.h" #include diff --git a/mapview/model/MMFloorObstacleDoor.h b/mapview/model/MMFloorObstacleDoor.h index cb6bc89..d1816a5 100644 --- a/mapview/model/MMFloorObstacleDoor.h +++ b/mapview/model/MMFloorObstacleDoor.h @@ -2,13 +2,13 @@ #define MMFLOOROBSTACLEDOOR_H #include "MapModelElement.h" -#include "../elements/MapViewElementHelper.h" +#include "../2D/MapViewElementHelper.h" #include "IHasMaterial.h" #include "IHasDoorType.h" #include "IHasParams.h" -#include "../elements/MV2DElementFloorObstacleDoor.h" +#include "../2D/MV2DElementFloorObstacleDoor.h" #include "../3D/MV3DElementFloorObstacleDoor.h" #include diff --git a/mapview/model/MMFloorObstacleLine.h b/mapview/model/MMFloorObstacleLine.h index 33e1145..e36773a 100644 --- a/mapview/model/MMFloorObstacleLine.h +++ b/mapview/model/MMFloorObstacleLine.h @@ -2,12 +2,12 @@ #define MAPELEMENTOBSTACLE_H #include "MapModelElement.h" -#include "../elements/MapViewElementHelper.h" +#include "../2D/MapViewElementHelper.h" #include "IHasMaterial.h" #include "IHasObstacleType.h" -#include "../elements/MV2DElementFloorObstacleLine.h" +#include "../2D/MV2DElementFloorObstacleLine.h" #include "../3D/MV3DElementFloorObstacleWall.h" #include diff --git a/mapview/model/MMFloorObstacles.h b/mapview/model/MMFloorObstacles.h index f58f8b8..c03c32a 100644 --- a/mapview/model/MMFloorObstacles.h +++ b/mapview/model/MMFloorObstacles.h @@ -39,24 +39,28 @@ public: Floorplan::Floor* getFloor() {return floor;} //TODO: check - void createDoor(Floorplan::FloorObstacleDoor* obs) { + MMFloorObstacleDoor* createDoor(Floorplan::FloorObstacleDoor* obs) { // add to underlying model floor->obstacles.push_back(obs); // add to myself as element - elements.push_back(new MMFloorObstacleDoor(this, floor, obs)); + MMFloorObstacleDoor* mm = new MMFloorObstacleDoor(this, floor, obs); + elements.push_back(mm); + return mm; } //TODO: check - void createLine(Floorplan::FloorObstacleLine* obs) { + MMFloorObstacleLine* createLine(Floorplan::FloorObstacleLine* obs) { // add to underlying model floor->obstacles.push_back(obs); // add to myself as element - elements.push_back(new MMFloorObstacleLine(this, floor, obs)); + MMFloorObstacleLine* mm = new MMFloorObstacleLine(this, floor, obs); + elements.push_back(mm); + return mm; } diff --git a/mapview/model/MMFloorOutlinePolygon.h b/mapview/model/MMFloorOutlinePolygon.h index 4a225e6..df57e19 100644 --- a/mapview/model/MMFloorOutlinePolygon.h +++ b/mapview/model/MMFloorOutlinePolygon.h @@ -4,7 +4,7 @@ #include "IHasParams.h" #include "MapModelElement.h" -#include "../elements/MV2DElementFloorOutlinePolygon.h" +#include "../2D/MV2DElementFloorOutlinePolygon.h" #include "../3D/MV3DElementFloorOutlinePolygon.h" #include diff --git a/mapview/model/MMFloorPOI.h b/mapview/model/MMFloorPOI.h index a018eef..5f9184c 100644 --- a/mapview/model/MMFloorPOI.h +++ b/mapview/model/MMFloorPOI.h @@ -4,7 +4,7 @@ #include "MapModelElement.h" #include "IHasParams.h" -#include "../elements/MV2DElementPOI.h" +#include "../2D/MV2DElementPOI.h" #include diff --git a/mapview/model/MMFloorStair.h b/mapview/model/MMFloorStair.h index 55530a6..6d2fcb8 100644 --- a/mapview/model/MMFloorStair.h +++ b/mapview/model/MMFloorStair.h @@ -5,7 +5,7 @@ #include "IHasParams.h" #include "MMFloorOutlinePolygon.h" -#include "../elements/MV2DElementStair.h" +#include "../2D/MV2DElementStair.h" #include "../3D/MV3DElementStair.h" diff --git a/mapview/model/MMFloorUnderlayImage.h b/mapview/model/MMFloorUnderlayImage.h index 85b3833..34eafa4 100644 --- a/mapview/model/MMFloorUnderlayImage.h +++ b/mapview/model/MMFloorUnderlayImage.h @@ -5,7 +5,7 @@ #include "IHasParams.h" #include "MapModelElement.h" -#include "../elements/MV2DElementFloorUnderlay.h" +#include "../2D/MV2DElementFloorUnderlay.h" #include /** diff --git a/mapview/model/MMFloorUnderlays.h b/mapview/model/MMFloorUnderlays.h index 3102869..da25db0 100644 --- a/mapview/model/MMFloorUnderlays.h +++ b/mapview/model/MMFloorUnderlays.h @@ -3,7 +3,7 @@ #include "MMFloorUnderlayImage.h" -#include "../elements/MV2DElementFloorUnderlay.h" +#include "../2D/MV2DElementFloorUnderlay.h" #include diff --git a/mapview/tools/Tool.h b/mapview/tools/Tool.h deleted file mode 100644 index 6338fef..0000000 --- a/mapview/tools/Tool.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef TOOL_H -#define TOOL_H - -#include -#include -#include - -#include "../Painter.h" - -class MapView2D; - -class Tool : public QObject { - - Q_OBJECT - -public: - - virtual ~Tool() {;} - - virtual void mousePressEvent(MapView2D* m, QMouseEvent* e) { (void) m; (void) e; } - virtual void mouseMoveEvent(MapView2D* m, QMouseEvent* e) { (void) m; (void) e; } - virtual void mouseReleaseEvent(MapView2D* m, QMouseEvent* e) { (void) m; (void) e; } - - virtual void wheelEvent(MapView2D* m, QWheelEvent* e) { (void) m; (void) e; } - - virtual void keyPressEvent(MapView2D* m, QKeyEvent* e) { (void) m; (void) e; } - - virtual void paintBefore(MapView2D* m, Painter& p) { (void) m; (void) p; } - virtual void paintAfter(MapView2D* m, Painter& p) { (void) m; (void) p; } - - virtual void layerChange(MapView2D* m) { (void) m; } - -}; - -#endif // TOOL_H diff --git a/mapview/tools/Tools.h b/mapview/tools/Tools.h deleted file mode 100644 index 0063ab7..0000000 --- a/mapview/tools/Tools.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef TOOLS_H -#define TOOLS_H - -#include -#include "Tool.h" - -/** - * combine several tools under the interface for one tool - */ -class Tools : public Tool { - -private: - - std::vector tools; - -public: - - /** add this tool */ - void enable(Tool* t) {tools.push_back(t);} - - /** remove this tool */ - void disable(Tool* t) {tools.erase(std::remove(tools.begin(), tools.end(), t));} - - - virtual void mousePressEvent(MapView2D* m, QMouseEvent* e) override { - for (Tool* t : tools) {t->mousePressEvent(m, e);} - } - - virtual void mouseMoveEvent(MapView2D* m, QMouseEvent* e) override { - for (Tool* t : tools) {t->mouseMoveEvent(m, e);} - } - - virtual void mouseReleaseEvent(MapView2D* m, QMouseEvent* e) override { - for (Tool* t : tools) {t->mouseReleaseEvent(m, e);} - } - - virtual void wheelEvent(MapView2D* m, QWheelEvent* e) override { - for (Tool* t : tools) {t->wheelEvent(m, e);} - } - - virtual void keyPressEvent(MapView2D* m, QKeyEvent* e) override { - for (Tool* t : tools) {t->keyPressEvent(m, e);} - } - - virtual void paintBefore(MapView2D* m, Painter& p) override { - for (Tool* t : tools) {t->paintBefore(m, p);} - } - - virtual void paintAfter(MapView2D* m, Painter& p) override { - for (Tool* t : tools) {t->paintAfter(m, p);} - } - - virtual void layerChange(MapView2D* m) override { - for (Tool* t : tools) {t->layerChange(m);} - } - -}; - -#endif // TOOLS_H diff --git a/params/ToolBox.cpp b/params/ToolBox.cpp index a9c3e33..9081eab 100644 --- a/params/ToolBox.cpp +++ b/params/ToolBox.cpp @@ -8,7 +8,7 @@ #include "../mapview/model/MapLayers.h" -#include "../mapview/MapView2D.h" +#include "../mapview/2D/MapView2D.h" #include "../mapview/model/MapModel.h" #include "../mapview/model/MMFloorAccessPoint.h" #include "../mapview/model/MMFloorBeacon.h" @@ -23,6 +23,13 @@ ToolBoxWidget::ToolBoxWidget(MapView2D* view, QWidget *parent) : QWidget(parent) QGridLayout* lay = new QGridLayout(this); + // SELECTION + btnSelect = new QPushButton(UIHelper::getIcon("cursor"), ""); + btnSelect->setMinimumSize(s,s); + lay->addWidget(btnSelect, r++, 0, 1,1,Qt::AlignTop); + connect(btnSelect, SIGNAL(clicked(bool)), this, SLOT(onSelect())); + + // OBSTACLES btnGround = new QPushButton(UIHelper::getIcon("floor"), ""); @@ -122,23 +129,323 @@ void ToolBoxWidget::onNewGround() { } + + +template class NewElementTool : public Tool { + +protected: + + /** add another line after this one? */ + bool addAnother = true; + + /** register this tool into the given tools-queue */ + Tools& tools; + Tool* oldMainTool; + + /** the layer to add the new element to */ + MapLayer* layer = nullptr; + + /** currently edited element */ + FloorplanElement* foEL = nullptr; + MapModelElement* mmEL = nullptr; + +public: + + NewElementTool(Tools& tools, MapLayer* layer) : tools(tools), layer(layer) { + oldMainTool = tools.getMain(); // keep the current tool to reset it later + tools.setMain(this); + } + + virtual ~NewElementTool() { + tools.setMain(oldMainTool); // reset to the previous tool + } + + virtual bool mousePressEvent(MapView2D* m, QMouseEvent* e) override { + if (e->button() == Qt::MouseButton::LeftButton) { + (void) m; (void) e; + return true; + } else { + return false; + } + } + + virtual bool mouseMoveEvent(MapView2D* m, QMouseEvent* e) override { + const Point2 onScreen(e->x(), e->y()); + Point2 onMap = m->getScaler().sm(onScreen); + onMap = m->getScaler().snap(onMap); + moving(onMap); + return true; + } + + virtual bool mouseReleaseEvent(MapView2D* m, QMouseEvent* e) override { + if (e->button() == Qt::MouseButton::LeftButton) { + (void) m; (void) e; + next(); + return true; + } else { + return false; + } + } + + virtual bool keyPressEvent(MapView2D* m, QKeyEvent* e) override { + (void) m; + if (e->key() == Qt::Key_Escape) { + deleteCurrent(); + disableMe(); + return true; + } + return false; + } + +protected: + + /** all subclasses must create a new, empty element here */ + virtual void createEmptyElement() = 0; + + /** mouse is currently moved */ + virtual void moving(const Point2 mapPoint) = 0; + + /** next pont */ + virtual void next() = 0; + +protected: + + void create() { + createEmptyElement(); + mmEL->getMV2D()->focus(); + } + + /** delete the currently edited element */ + void deleteCurrent() { + if (mmEL) {mmEL->deleteMe();} + } + + /** finalize the current element (if any) */ + void finalizeCurrent() { + if (!mmEL) {return;} + mmEL->getMV2D()->unfocus(); + mmEL = nullptr; + } + + /** finish creating new elements */ + void disableMe() { + finalizeCurrent(); + delete this; // see dtor! + } + +}; + +class NewWallTool : public NewElementTool { + +private: + + /** currently edited line node (has 2) */ + int idx = 0; + +public: + + NewWallTool(Tools& tools, MapLayer* layer) : NewElementTool(tools, layer) { + create(); + } + + const std::string getName() const override { + return "new Wall"; + } + + void createEmptyElement() override { + + foEL = new Floorplan::FloorObstacleLine(Floorplan::ObstacleType::WALL, Floorplan::Material::DRYWALL, Point2(0, 0), Point2(0, 0)); + MMFloorObstacles* obs = (MMFloorObstacles*)layer; + mmEL = obs->createLine(foEL); + + } + + /** mouse is currently moved */ + void moving(const Point2 mapPoint) override { + + if (idx == 0) { foEL->from = mapPoint; foEL->to = mapPoint; } + if (idx == 1) { foEL->to = mapPoint; } + + } + + /** next pont */ + void next() override { + + if (++idx == 2) { + finalizeCurrent(); + if (addAnother) { + idx = 0; + create(); + } else { + disableMe(); + } + } + + } + +}; + + +class NewDoorTool : public NewElementTool { + +private: + + /** currently edited line node (has 2) */ + int idx = 0; + +public: + + NewDoorTool(Tools& tools, MapLayer* layer) : NewElementTool(tools, layer) { + create(); + } + + const std::string getName() const override { + return "new Door"; + } + + void createEmptyElement() override { + + foEL = new Floorplan::FloorObstacleDoor(Floorplan::DoorType::SWING, Floorplan::Material::WOOD, Point2(0, 0), Point2(0, 0)); + MMFloorObstacles* obs = (MMFloorObstacles*)layer; + mmEL = obs->createDoor(foEL); + + } + + /** mouse is currently moved */ + void moving(const Point2 mapPoint) override { + + if (idx == 0) { foEL->from = mapPoint; foEL->to = mapPoint; } + if (idx == 1) { foEL->to = mapPoint; } + + } + + /** next pont */ + void next() override { + + if (++idx == 2) { + finalizeCurrent(); + if (addAnother) { + idx = 0; + create(); + } else { + disableMe(); + } + } + + } + +}; + +//struct NewLineTool : public Tool { + +// /** add another line after this one? */ +// bool multiple = true; + +// /** register this tool into the given tools-queue */ +// Tools& tools; + +// /** the layer to add the new line to */ +// MapLayer* layer; + +// /** currently edited line */ +// Floorplan::FloorObstacleLine* foLine; +// MMFloorObstacleLine* mmLine; + +// /** new line type */ +// Floorplan::ObstacleType type; + +// /** new line material */ +// Floorplan::Material mat; + +// /** currently edited line node (has 2) */ +// int idx = 0; + + +// NewLineTool(Tools& tools, MapLayer* layer, Floorplan::ObstacleType type, Floorplan::Material mat) : tools(tools), layer(layer), type(type), mat(mat) { +// createEmptyLine(); +// tools.addFront(this); +// } + +// virtual bool mousePressEvent(MapView2D* m, QMouseEvent* e) override { +// (void) m; (void) e; +// return true; +// } + +// virtual bool mouseMoveEvent(MapView2D* m, QMouseEvent* e) override { +// const Point2 onScreen(e->x(), e->y()); +// Point2 onMap = m->getScaler().sm(onScreen); +// onMap = m->getScaler().snap(onMap); +// if (idx == 0) { foLine->from = onMap; foLine->to = onMap; } +// if (idx == 1) { foLine->to = onMap; } +// return true; +// } + +// virtual bool mouseReleaseEvent(MapView2D* m, QMouseEvent* e) override { +// (void) m; (void) e; +// ++idx; +// if (idx == 2) { + +// finalizeLine(); + +// if (multiple) { +// idx = 0; +// createEmptyLine(); +// } else { +// disableMe(); +// } +// } +// return true; +// } + +// virtual bool keyPressEvent(MapView2D* m, QKeyEvent* e) override { +// (void) m; +// if (e->key() == Qt::Key_Escape) { +// if (mmLine) {mmLine->deleteMe();} +// disableMe(); return true; +// } +// return false; +// } + +//private: + +// /** finalize the current line */ +// void finalizeLine() { +// if (!mmLine) {return;} +// mmLine->getMV2D()->unfocus(); +// mmLine = nullptr; +// } + +// /** stop creating new lines */ +// void disableMe() { +// finalizeLine(); +// tools.remove(this); +// delete this; +// } + +// /** create a new, empty line */ +// void createEmptyLine() { +// foLine = new Floorplan::FloorObstacleLine(type, mat, Point2(0, 0), Point2(0, 0)); +// MMFloorObstacles* obs = (MMFloorObstacles*)layer; +// mmLine = obs->createLine(foLine); +// mmLine->getMV2D()->focus(); +// } + +//}; + + + + + +void ToolBoxWidget::onSelect() { + + + +} + + void ToolBoxWidget::onNewWall() { - - const Point2 center = view->getScaler().getCenter(); - float s = view->getScaler().sm(50); - - Floorplan::FloorObstacleLine* wall = new Floorplan::FloorObstacleLine( - Floorplan::ObstacleType::WALL, - Floorplan::Material::DRYWALL, - Point2(center.x-s, center.y), - Point2(center.x+s, center.y) - ); - - MMFloorObstacles* obs = (MMFloorObstacles*)curLayer; - obs->createLine(wall); - - view->getModel()->reselect(); - + new NewWallTool(view->getTools(), curLayer); + //view->getModel()->reselect(); } void ToolBoxWidget::onNewPillar() { @@ -155,26 +462,28 @@ void ToolBoxWidget::onNewPillar() { MMFloorObstacles* obs = (MMFloorObstacles*)curLayer; obs->createCircle(pillar); - view->getModel()->reselect(); + //view->getModel()->reselect(); } void ToolBoxWidget::onNewDoor() { - const Point2 center = view->getScaler().getCenter(); - float s = view->getScaler().sm(50); + new NewDoorTool(view->getTools(), curLayer); - Floorplan::FloorObstacleDoor* door = new Floorplan::FloorObstacleDoor( - Floorplan::DoorType::SWING, - Floorplan::Material::WOOD, - Point2(center.x-s, center.y), - Point2(center.x+s, center.y) - ); +// const Point2 center = view->getScaler().getCenter(); +// float s = view->getScaler().sm(50); - MMFloorObstacles* obs = (MMFloorObstacles*)curLayer; - obs->createDoor(door); +// Floorplan::FloorObstacleDoor* door = new Floorplan::FloorObstacleDoor( +// Floorplan::DoorType::SWING, +// Floorplan::Material::WOOD, +// Point2(center.x-s, center.y), +// Point2(center.x+s, center.y) +// ); - view->getModel()->reselect(); +// MMFloorObstacles* obs = (MMFloorObstacles*)curLayer; +// obs->createDoor(door); + + //view->getModel()->reselect(); } @@ -192,7 +501,7 @@ void ToolBoxWidget::onNewStair() { MMFloorStairs* stairs = (MMFloorStairs*)curLayer; stairs->create(stair); - view->getModel()->reselect(); + //view->getModel()->reselect(); } diff --git a/params/ToolBoxWidget.h b/params/ToolBoxWidget.h index 56f0ab6..a9481bc 100644 --- a/params/ToolBoxWidget.h +++ b/params/ToolBoxWidget.h @@ -7,6 +7,9 @@ class MapLayer; class QPushButton; class MapView2D; +/** + * gui element with actions to perform + */ class ToolBoxWidget : public QWidget { Q_OBJECT @@ -28,13 +31,14 @@ private: MapLayer* curLayer; int r = 0; + QPushButton* btnSelect; + QPushButton* btnGround; QPushButton* btnWall; QPushButton* btnPillar; QPushButton* btnDoor; QPushButton* btnStair; - QPushButton* btnWifi; QPushButton* btnBeacon; QPushButton* btnPOI; @@ -43,6 +47,8 @@ private: private slots: + void onSelect(); + void onNewGround(); void onNewWall(); void onNewPillar(); diff --git a/res.qrc b/res.qrc index 705e61a..7e03938 100644 --- a/res.qrc +++ b/res.qrc @@ -12,5 +12,6 @@ res/icons/poi.svg res/icons/stair.svg res/icons/door.svg + res/icons/cursor.svg diff --git a/res/icons/cursor.svg b/res/icons/cursor.svg new file mode 100644 index 0000000..3b692e5 --- /dev/null +++ b/res/icons/cursor.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +