diff --git a/mapview/2D/HasMoveableNodes.h b/mapview/2D/HasMoveableNodes.h index 610eeee..89e55e7 100644 --- a/mapview/2D/HasMoveableNodes.h +++ b/mapview/2D/HasMoveableNodes.h @@ -36,9 +36,11 @@ public: /** get a list of all nodes that are selectable / moveable */ virtual std::vector getMoveableNodes() const = 0; - /** the given node was moved */ + /** the given node is currently moved */ virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) = 0; + /** the given node was previously moved */ + virtual void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) = 0; /** the given node was selected */ virtual void onNodeSelect(MapView2D* v, const int userIdx) { diff --git a/mapview/2D/MV2DElementAccessPoint.h b/mapview/2D/MV2DElementAccessPoint.h index 3afc9b3..e89388a 100644 --- a/mapview/2D/MV2DElementAccessPoint.h +++ b/mapview/2D/MV2DElementAccessPoint.h @@ -84,6 +84,11 @@ public: if (userIdx == 0) {ap->pos.x = newPos.x; ap->pos.y = newPos.y;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } virtual void mousePressed(MapView2D* v, const Point2 p) override { (void) v; diff --git a/mapview/2D/MV2DElementBeacon.h b/mapview/2D/MV2DElementBeacon.h index d836def..ea329eb 100644 --- a/mapview/2D/MV2DElementBeacon.h +++ b/mapview/2D/MV2DElementBeacon.h @@ -77,6 +77,12 @@ public: if (userIdx == 0) {b->pos.x = newPos.x; b->pos.y = newPos.y;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } + virtual void onFocus() override { ; } diff --git a/mapview/2D/MV2DElementElevator.h b/mapview/2D/MV2DElementElevator.h index 2fe6c6c..3a03257 100644 --- a/mapview/2D/MV2DElementElevator.h +++ b/mapview/2D/MV2DElementElevator.h @@ -94,6 +94,12 @@ public: if (userIdx == 0) {elevator->center.x = newPos.x; elevator->center.y = newPos.y;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } + virtual void mousePressed(MapView2D* v, const Point2 p) override { (void) v; diff --git a/mapview/2D/MV2DElementFingerprintLocation.h b/mapview/2D/MV2DElementFingerprintLocation.h index 89eea4e..1f38b03 100644 --- a/mapview/2D/MV2DElementFingerprintLocation.h +++ b/mapview/2D/MV2DElementFingerprintLocation.h @@ -82,6 +82,12 @@ public: if (userIdx == 0) {fpl->posOnFloor = newPos;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } + virtual void onFocus() override { ; } diff --git a/mapview/2D/MV2DElementFloorObstacleDoor.cpp b/mapview/2D/MV2DElementFloorObstacleDoor.cpp index 18c82a5..fd22f99 100644 --- a/mapview/2D/MV2DElementFloorObstacleDoor.cpp +++ b/mapview/2D/MV2DElementFloorObstacleDoor.cpp @@ -128,12 +128,16 @@ std::vector MV2DElementFloorObstacleDoor::getMoveableNodes() const return nodes; } +void MV2DElementFloorObstacleDoor::onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) { + emit v->onElementChange(this); +} + void MV2DElementFloorObstacleDoor::onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) { switch (userIdx) { case 0: fo->from = newPos; break; case 1: fo->to = newPos; break; } - emit v->onElementChange(this); +// emit v->onElementChange(this); } bool MV2DElementFloorObstacleDoor::keyPressEvent(MapView2D* v, QKeyEvent *e) { diff --git a/mapview/2D/MV2DElementFloorObstacleDoor.h b/mapview/2D/MV2DElementFloorObstacleDoor.h index ba60924..848a930 100644 --- a/mapview/2D/MV2DElementFloorObstacleDoor.h +++ b/mapview/2D/MV2DElementFloorObstacleDoor.h @@ -41,9 +41,10 @@ public: /** get a list of all nodes that are selectable / moveable */ virtual std::vector getMoveableNodes() const override; - /** the given node was moved */ virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override; + virtual void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override; + virtual bool keyPressEvent(MapView2D* v, QKeyEvent *e) override; }; diff --git a/mapview/2D/MV2DElementFloorObstacleLine.h b/mapview/2D/MV2DElementFloorObstacleLine.h index c70da1b..2ac327e 100644 --- a/mapview/2D/MV2DElementFloorObstacleLine.h +++ b/mapview/2D/MV2DElementFloorObstacleLine.h @@ -129,6 +129,13 @@ public: if (userIdx == 1) {fo->to.x = newPos.x; fo->to.y = newPos.y;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } + + }; #endif // MV2DELEMENTFLOOROBSTACLELINE_H diff --git a/mapview/2D/MV2DElementFloorObstacleObject.cpp b/mapview/2D/MV2DElementFloorObstacleObject.cpp index 33f34e1..1ee73cc 100644 --- a/mapview/2D/MV2DElementFloorObstacleObject.cpp +++ b/mapview/2D/MV2DElementFloorObstacleObject.cpp @@ -102,6 +102,11 @@ void MV2DElementFloorObstacleObject::onNodeMove(MapView2D* v, const int userIdx, if (userIdx == 0) {fo->pos.x = newPos.x; fo->pos.y = newPos.y;} } +void MV2DElementFloorObstacleObject::onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); +} void MV2DElementFloorObstacleObject::mousePressed(MapView2D* v, const Point2 p) { (void) v; diff --git a/mapview/2D/MV2DElementFloorObstacleObject.h b/mapview/2D/MV2DElementFloorObstacleObject.h index de64f52..172574d 100644 --- a/mapview/2D/MV2DElementFloorObstacleObject.h +++ b/mapview/2D/MV2DElementFloorObstacleObject.h @@ -34,6 +34,8 @@ public: virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override; + virtual void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override; + virtual void mousePressed(MapView2D* v, const Point2 p) override; virtual void mouseMove(MapView2D* v, const Point2 p) override; diff --git a/mapview/2D/MV2DElementFloorOutlinePolygon.h b/mapview/2D/MV2DElementFloorOutlinePolygon.h index 9211d55..80998db 100644 --- a/mapview/2D/MV2DElementFloorOutlinePolygon.h +++ b/mapview/2D/MV2DElementFloorOutlinePolygon.h @@ -103,12 +103,19 @@ public: } /** the given node was moved */ - virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override { + void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override { (void) v; fo.poly.points[userIdx].x = newPos.x; fo.poly.points[userIdx].y = newPos.y; } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } + + // virtual void mousePressed(MapView2D* v, const Point2 p) override { // (void) v; // (void) p; diff --git a/mapview/2D/MV2DElementGroundTruthPoint.h b/mapview/2D/MV2DElementGroundTruthPoint.h index e5abacf..036a357 100644 --- a/mapview/2D/MV2DElementGroundTruthPoint.h +++ b/mapview/2D/MV2DElementGroundTruthPoint.h @@ -81,6 +81,11 @@ public: if (userIdx == 0) {gtp->pos.x = newPos.x; gtp->pos.y = newPos.y;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } /** mouse pressed at the given point */ virtual void mousePressed(MapView2D* v, const Point2 p) override { diff --git a/mapview/2D/MV2DElementPOI.h b/mapview/2D/MV2DElementPOI.h index a3f6bc9..b79f885 100644 --- a/mapview/2D/MV2DElementPOI.h +++ b/mapview/2D/MV2DElementPOI.h @@ -81,6 +81,11 @@ public: if (userIdx == 0) {poi->pos = newPos;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } /** mouse pressed at the given point */ virtual void mousePressed(MapView2D* v, const Point2 p) override { diff --git a/mapview/2D/MV2DElementRegistrationPoint.h b/mapview/2D/MV2DElementRegistrationPoint.h index 2e56a03..7b21b79 100644 --- a/mapview/2D/MV2DElementRegistrationPoint.h +++ b/mapview/2D/MV2DElementRegistrationPoint.h @@ -77,6 +77,11 @@ public: if (userIdx == 0) {reg->posOnMap_m.x = newPos.x; reg->posOnMap_m.y = newPos.y;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } virtual void mousePressed(MapView2D* v, const Point2 p) override { (void) v; diff --git a/mapview/2D/MV2DElementStair.h b/mapview/2D/MV2DElementStair.h index f0465f7..a5b0f5e 100644 --- a/mapview/2D/MV2DElementStair.h +++ b/mapview/2D/MV2DElementStair.h @@ -307,6 +307,12 @@ public: } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } + void onNodeSelect(MapView2D* v, const int userIdx) override { HasMoveableNodes::onNodeSelect(v, userIdx); emit v->onElementChange(this); diff --git a/mapview/2D/tools/ToolSelector.h b/mapview/2D/tools/ToolSelector.h index 5fa19bb..dae6238 100644 --- a/mapview/2D/tools/ToolSelector.h +++ b/mapview/2D/tools/ToolSelector.h @@ -120,9 +120,10 @@ private: // // left mouse button? // if (e->button() == Qt::MouseButton::LeftButton) { // // element has selectedable nodes? try to select one -// if (dynamic_cast(me)) { -// if (selectNode(m, p, dynamic_cast(me))) {return;} -// } + if (dynamic_cast(me)) { + //if (selectNode(m, p, dynamic_cast(me))) {return;} + if (nodeMoved(m, p, dynamic_cast(me))) {return;} + } // } // otherwise: let the element itself process all events @@ -173,6 +174,21 @@ private: } + /** moved the currently selected node (now done). true if successful */ + bool nodeMoved(MapView2D* v, Point2 p, HasMoveableNodes* elem) { + + // no node selected? -> done + if (elem->getSelectedNode() == -1) {return false;} + + // snap the node + const Point2 pSnapped = v->getScaler().snap(p); + + // moved (done) + elem->onNodeMoved(v, elem->getSelectedNode(), pSnapped); + return true; + + } + private: diff --git a/mapview/3D/navMesh/NavMeshRenderer.h b/mapview/3D/navMesh/NavMeshRenderer.h index 0e24a86..5b89706 100644 --- a/mapview/3D/navMesh/NavMeshRenderer.h +++ b/mapview/3D/navMesh/NavMeshRenderer.h @@ -16,7 +16,7 @@ #include "../misc/Shader.h" #include "../misc/TriangleData.h" -class NavMeshRenderer : protected QOpenGLFunctions { +class NavMeshRenderer { private: @@ -89,7 +89,7 @@ public: rs.shader->setVertices(data.getVertices().data()); rs.shader->setVertexColor(data.getRGBA().data()); - glDrawArrays(GL_TRIANGLES, 0, data.getVertices().size()/3); + rs.funcs->glDrawArrays(GL_TRIANGLES, 0, data.getVertices().size()/3); rs.shader->unsetVertices(); rs.shader->unsetVertexColor(); @@ -133,7 +133,7 @@ public: rs.shader->setVertices(data.getVertices().data()); rs.shader->setVertexColor(data.getRGBA().data()); - glDrawArrays(GL_LINES, 0, data.getVertices().size()/3); + rs.funcs->glDrawArrays(GL_LINES, 0, data.getVertices().size()/3); rs.shader->unsetVertices(); rs.shader->unsetVertexColor();