78 lines
1.7 KiB
C++
78 lines
1.7 KiB
C++
/*
|
||
* © Copyright 2014 – Urheberrechtshinweis
|
||
* Alle Rechte vorbehalten / All Rights Reserved
|
||
*
|
||
* Programmcode ist urheberrechtlich geschuetzt.
|
||
* Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner.
|
||
* Keine Verwendung ohne explizite Genehmigung.
|
||
* (vgl. § 106 ff UrhG / § 97 UrhG)
|
||
*/
|
||
|
||
#ifndef MV2D_IHASMOVEABLENODES_H
|
||
#define MV2D_IHASMOVEABLENODES_H
|
||
|
||
#include <Indoor/geo/Point2.h>
|
||
#include "../2D/MapView2D.h"
|
||
#include <vector>
|
||
|
||
/** the selectable/moveable node */
|
||
struct MoveableNode {
|
||
|
||
/** user-defined index */
|
||
int userIdx;
|
||
|
||
/** the node's position */
|
||
Point2 pos;
|
||
|
||
|
||
/** ctor */
|
||
MoveableNode(const int userIdx, const Point2 pos) : userIdx(userIdx), pos(pos) {;}
|
||
|
||
};
|
||
|
||
/**
|
||
* base for all 2D elements that have selectable and moveable nodes.
|
||
* the ToolSelector is able to get, select, and move those nodes
|
||
*/
|
||
class HasMoveableNodes {
|
||
|
||
protected:
|
||
|
||
/** currently selected node */
|
||
int selectedUserIdx = -1;
|
||
|
||
public:
|
||
|
||
|
||
/** get a list of all nodes that are selectable / moveable */
|
||
virtual std::vector<MoveableNode> getMoveableNodes() const = 0;
|
||
|
||
/** 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) {
|
||
(void) v;
|
||
this->selectedUserIdx = userIdx;
|
||
}
|
||
|
||
/** unselect any selected node */
|
||
virtual void onNodeUnselect(MapView2D* v) {
|
||
(void) v;
|
||
this->selectedUserIdx = -1;
|
||
}
|
||
|
||
/** get the currently selected node */
|
||
virtual int getSelectedNode() const {
|
||
return selectedUserIdx;
|
||
}
|
||
|
||
|
||
|
||
};
|
||
|
||
#endif // MV2D_IHASMOVEABLENODES_H
|