- 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
76 lines
1.4 KiB
C++
76 lines
1.4 KiB
C++
#ifndef MV2DELEMENT_H
|
|
#define MV2DELEMENT_H
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include "../2D/MapView2D.h"
|
|
#include "../2D/Painter.h"
|
|
|
|
#include <Indoor/geo/BBox2.h>
|
|
#include <Indoor/geo/Line2.h>
|
|
|
|
/**
|
|
* represents one drawable, selectable, editable, ...
|
|
* element shown within the MapView2D
|
|
*/
|
|
class MV2DElement {
|
|
|
|
private:
|
|
|
|
bool _focused = false;
|
|
|
|
public:
|
|
|
|
/** dtor */
|
|
virtual ~MV2DElement() {;}
|
|
|
|
|
|
/** get the element's 2D bounding box */
|
|
virtual BBox2 getBoundingBox() const = 0;
|
|
|
|
/** get the element's minimal distance (nearest whatsoever) to the given point */
|
|
virtual float getMinDistanceXY(const Point2 p) const = 0;
|
|
|
|
/** repaint me */
|
|
virtual void paint(Painter& p) = 0;
|
|
|
|
|
|
|
|
/** got focus */
|
|
void focus() {
|
|
_focused = true;
|
|
onFocus();
|
|
}
|
|
|
|
/** lost focus */
|
|
void unfocus() {
|
|
_focused = false;
|
|
onUnfocus();
|
|
}
|
|
|
|
bool hasFocus() {return _focused;}
|
|
|
|
|
|
/** mouse pressed at the given point */
|
|
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) {(void) v; (void) p;}
|
|
|
|
/** mouse released */
|
|
virtual void mouseReleased(MapView2D* v, const Point2 p) {(void) v; (void) p;}
|
|
|
|
/** key pressed. NOTE: return true when consumed. */
|
|
virtual bool keyPressEvent(MapView2D* v, QKeyEvent* e) {(void) v; (void) e; return false;}
|
|
|
|
|
|
protected:
|
|
|
|
virtual void onFocus() = 0;
|
|
|
|
virtual void onUnfocus() = 0;
|
|
|
|
};
|
|
|
|
#endif // MV2DELEMENT_H
|