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
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
#include "ui_MainWindow.h"
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QStatusBar>
|
||||
|
||||
#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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define MV2D_IHASMOVEABLENODES_H
|
||||
|
||||
#include <Indoor/geo/Point2.h>
|
||||
#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 {
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "../MapView2D.h"
|
||||
#include "../Painter.h"
|
||||
#include "../2D/MapView2D.h"
|
||||
#include "../2D/Painter.h"
|
||||
|
||||
#include <Indoor/geo/BBox2.h>
|
||||
#include <Indoor/geo/Line2.h>
|
||||
@@ -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:
|
||||
@@ -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;
|
||||
@@ -2,14 +2,15 @@
|
||||
#define MV2DELEMENTFLOOROBSTACLELINE_H
|
||||
|
||||
#include "MV2DElement.h"
|
||||
#include "HasMoveableNodes.h"
|
||||
|
||||
#include "MapViewElementHelper.h"
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
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<MoveableNode> 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;}
|
||||
}
|
||||
|
||||
};
|
||||
@@ -2,15 +2,15 @@
|
||||
#define MV2DELEMENTFLOOROUTLINEPOLYGON_H
|
||||
|
||||
#include "MV2DElement.h"
|
||||
#include "HasMoveableNodes.h"
|
||||
#include "MapViewElementHelper.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
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<MoveableNode> getMoveableNodes() const override {
|
||||
std::vector<MoveableNode> 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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()) {
|
||||
@@ -8,7 +8,7 @@
|
||||
class MapModel;
|
||||
class MV2DElement;
|
||||
|
||||
#include "mapview/tools/Tools.h"
|
||||
#include "tools/Tools.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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -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;}
|
||||
58
mapview/2D/tools/Tool.h
Normal file
58
mapview/2D/tools/Tool.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef TOOL_H
|
||||
#define TOOL_H
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QObject>
|
||||
|
||||
#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
|
||||
@@ -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 {
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
@@ -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?
|
||||
// }
|
||||
|
||||
|
||||
};
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
@@ -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:
|
||||
0
mapview/2D/tools/Tools.cpp
Normal file
0
mapview/2D/tools/Tools.cpp
Normal file
126
mapview/2D/tools/Tools.h
Normal file
126
mapview/2D/tools/Tools.h
Normal file
@@ -0,0 +1,126 @@
|
||||
#ifndef TOOLS_H
|
||||
#define TOOLS_H
|
||||
|
||||
#include <vector>
|
||||
#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<Tool*> 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
|
||||
@@ -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;
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
GridFactory<MyNode> fac(grid);
|
||||
fac.build(im, &l);
|
||||
|
||||
Importance::addImportance(grid, 0);
|
||||
Importance::addImportance(grid);
|
||||
//Importance::addImportance(grid, 400);
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
#define MYNODE_H
|
||||
|
||||
#include <Indoor/grid/Grid.h>
|
||||
#include <Indoor/grid/factory/v2/GridNodeImportance.h>
|
||||
|
||||
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) {;}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "MapView2D.h"
|
||||
#include "2D/MapView2D.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QOpenGLFunctions>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "MapModelElement.h"
|
||||
#include "IHasParams.h"
|
||||
|
||||
#include "../elements/MV2DElementAccessPoint.h"
|
||||
#include "../2D/MV2DElementAccessPoint.h"
|
||||
#include "../3D/MV3DElementAccessPoint.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "MapModelElement.h"
|
||||
#include "IHasParams.h"
|
||||
|
||||
#include "../elements/MV2DElementBeacon.h"
|
||||
#include "../2D/MV2DElementBeacon.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.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 <Indoor/floorplan/v2/Floorplan.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 <Indoor/floorplan/v2/Floorplan.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 <Indoor/floorplan/v2/Floorplan.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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "IHasParams.h"
|
||||
#include "MapModelElement.h"
|
||||
|
||||
#include "../elements/MV2DElementFloorOutlinePolygon.h"
|
||||
#include "../2D/MV2DElementFloorOutlinePolygon.h"
|
||||
#include "../3D/MV3DElementFloorOutlinePolygon.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "MapModelElement.h"
|
||||
#include "IHasParams.h"
|
||||
|
||||
#include "../elements/MV2DElementPOI.h"
|
||||
#include "../2D/MV2DElementPOI.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "IHasParams.h"
|
||||
#include "MMFloorOutlinePolygon.h"
|
||||
|
||||
#include "../elements/MV2DElementStair.h"
|
||||
#include "../2D/MV2DElementStair.h"
|
||||
#include "../3D/MV3DElementStair.h"
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "IHasParams.h"
|
||||
#include "MapModelElement.h"
|
||||
|
||||
#include "../elements/MV2DElementFloorUnderlay.h"
|
||||
#include "../2D/MV2DElementFloorUnderlay.h"
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "MMFloorUnderlayImage.h"
|
||||
|
||||
#include "../elements/MV2DElementFloorUnderlay.h"
|
||||
#include "../2D/MV2DElementFloorUnderlay.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#ifndef TOOL_H
|
||||
#define TOOL_H
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QObject>
|
||||
|
||||
#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
|
||||
@@ -1,59 +0,0 @@
|
||||
#ifndef TOOLS_H
|
||||
#define TOOLS_H
|
||||
|
||||
#include <vector>
|
||||
#include "Tool.h"
|
||||
|
||||
/**
|
||||
* combine several tools under the interface for one tool
|
||||
*/
|
||||
class Tools : public Tool {
|
||||
|
||||
private:
|
||||
|
||||
std::vector<Tool*> 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
|
||||
@@ -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 <typename FloorplanElement, typename MapModelElement> 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<Floorplan::FloorObstacleLine, MMFloorObstacleLine> {
|
||||
|
||||
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<Floorplan::FloorObstacleDoor, MMFloorObstacleDoor> {
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
1
res.qrc
1
res.qrc
@@ -12,5 +12,6 @@
|
||||
<file>res/icons/poi.svg</file>
|
||||
<file>res/icons/stair.svg</file>
|
||||
<file>res/icons/door.svg</file>
|
||||
<file>res/icons/cursor.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
56
res/icons/cursor.svg
Normal file
56
res/icons/cursor.svg
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 297 297" style="enable-background:new 0 0 297 297;" xml:space="preserve">
|
||||
<g>
|
||||
<path d="M294.077,251.199l-59.104-59.106l42.166-24.357c3.295-1.904,5.213-5.521,4.938-9.316c-0.273-3.796-2.69-7.101-6.225-8.51
|
||||
L87.82,74.905c-3.687-1.472-7.895-0.605-10.702,2.201c-2.807,2.808-3.674,7.016-2.203,10.702l74.994,188.053
|
||||
c1.41,3.534,4.715,5.952,8.511,6.226c3.796,0.276,7.413-1.643,9.316-4.939l24.353-42.166l59.102,59.107
|
||||
c1.862,1.864,4.389,2.91,7.023,2.91c2.634,0,5.16-1.046,7.022-2.91l28.841-28.844C297.956,261.366,297.956,255.078,294.077,251.199
|
||||
z M258.214,273.022l-61.229-61.235c-1.876-1.876-4.407-2.91-7.023-2.91c-0.43,0-0.864,0.028-1.295,0.085
|
||||
c-3.063,0.402-5.763,2.206-7.306,4.881l-20.584,35.642l-58.849-147.564l147.549,58.857l-35.645,20.588
|
||||
c-2.674,1.543-4.478,4.243-4.88,7.306c-0.403,3.06,0.64,6.134,2.824,8.318l61.232,61.235L258.214,273.022z"/>
|
||||
<path d="M43.611,29.552c-3.88-3.876-10.166-3.876-14.048,0c-3.879,3.88-3.879,10.168,0,14.048l22.069,22.069
|
||||
c1.939,1.938,4.482,2.909,7.024,2.909c2.541,0,5.082-0.971,7.023-2.909c3.878-3.879,3.878-10.168,0-14.047L43.611,29.552z"/>
|
||||
<path d="M51.089,98.215c0-5.485-4.448-9.931-9.933-9.931H9.946c-5.484,0-9.933,4.445-9.933,9.931c0,5.484,4.448,9.932,9.933,9.932
|
||||
h31.21C46.641,108.146,51.089,103.699,51.089,98.215z"/>
|
||||
<path d="M47.063,128.87l-22.071,22.071c-3.88,3.877-3.88,10.166,0,14.045c1.939,1.939,4.479,2.909,7.023,2.909
|
||||
c2.541,0,5.082-0.97,7.021-2.909l22.072-22.07c3.879-3.878,3.879-10.168,0-14.046C57.231,124.992,50.943,124.992,47.063,128.87z"/>
|
||||
<path d="M98.222,51.078c5.484,0,9.932-4.448,9.932-9.933V9.932c0-5.484-4.447-9.932-9.932-9.932c-5.485,0-9.931,4.447-9.931,9.932
|
||||
v31.214C88.291,46.63,92.736,51.078,98.222,51.078z"/>
|
||||
<path d="M135.893,64.005c2.544,0,5.085-0.968,7.024-2.908l22.068-22.069c3.88-3.879,3.88-10.168,0-14.046
|
||||
c-3.878-3.879-10.169-3.879-14.045,0l-22.069,22.069c-3.879,3.878-3.879,10.168,0,14.046
|
||||
C130.81,63.037,133.352,64.005,135.893,64.005z"/>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
Reference in New Issue
Block a user