Merge branch 'master' of https://git.frank-ebner.de/FHWS/IndoorMap
This commit is contained in:
@@ -36,9 +36,11 @@ public:
|
||||
/** get a list of all nodes that are selectable / moveable */
|
||||
virtual std::vector<MoveableNode> 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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
;
|
||||
}
|
||||
|
||||
@@ -128,12 +128,16 @@ std::vector<MoveableNode> 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) {
|
||||
|
||||
@@ -41,9 +41,10 @@ public:
|
||||
/** get a list of all nodes that are selectable / moveable */
|
||||
virtual std::vector<MoveableNode> 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;
|
||||
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<HasMoveableNodes*>(me)) {
|
||||
// if (selectNode(m, p, dynamic_cast<HasMoveableNodes*>(me))) {return;}
|
||||
// }
|
||||
if (dynamic_cast<HasMoveableNodes*>(me)) {
|
||||
//if (selectNode(m, p, dynamic_cast<HasMoveableNodes*>(me))) {return;}
|
||||
if (nodeMoved(m, p, dynamic_cast<HasMoveableNodes*>(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:
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user