initial commit
This commit is contained in:
74
mapview/elements/MV2DElement.h
Normal file
74
mapview/elements/MV2DElement.h
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifndef MV2DELEMENT_H
|
||||
#define MV2DELEMENT_H
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "../MapView2D.h"
|
||||
#include "../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) = 0;
|
||||
|
||||
/** mouse moved to the given point */
|
||||
virtual void mouseMove(MapView2D* v, const Point2 p) = 0;
|
||||
|
||||
/** mouse released */
|
||||
virtual void mouseReleased(MapView2D* v, const Point2 p) = 0;
|
||||
|
||||
/** key pressed. return true when consumed. */
|
||||
virtual bool keyPressEvent(MapView2D* v, QKeyEvent* e) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void onFocus() = 0;
|
||||
|
||||
virtual void onUnfocus() = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // MV2DELEMENT_H
|
||||
Reference in New Issue
Block a user