added earth-registration support
This commit is contained in:
107
mapview/2D/MV2DElementRegistrationPoint.h
Normal file
107
mapview/2D/MV2DElementRegistrationPoint.h
Normal file
@@ -0,0 +1,107 @@
|
||||
#ifndef MV2DELEMENTREGISTRATIONPOINT_H
|
||||
#define MV2DELEMENTREGISTRATIONPOINT_H
|
||||
|
||||
|
||||
#include "MV2DElement.h"
|
||||
#include "HasMoveableNodes.h"
|
||||
|
||||
#include "MapViewElementHelper.h"
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
#include "../../UIHelper.h"
|
||||
|
||||
/** one earth <-> map correspondence */
|
||||
class MV2DElementRegistrationPoint : public MV2DElement, public HasMoveableNodes {
|
||||
|
||||
private:
|
||||
|
||||
//bool sel = false;
|
||||
Floorplan::EarthPosMapPos* reg;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with the AP to render/edit */
|
||||
MV2DElementRegistrationPoint(Floorplan::EarthPosMapPos* reg) : reg(reg) {;}
|
||||
|
||||
|
||||
/** get the element's 3D bounding box */
|
||||
BBox2 getBoundingBox() const override {
|
||||
BBox2 bbox;
|
||||
bbox.add(Point2(reg->posOnMap_m.x, reg->posOnMap_m.y));
|
||||
bbox.grow(Point2(0.1, 0.1));
|
||||
return bbox;
|
||||
}
|
||||
|
||||
/** get the element's minimal distance (nearest whatsoever) to the given point */
|
||||
ClickDist getMinDistanceXY(const Point2 p) const override {
|
||||
return ClickDist(p.getDistance(reg->posOnMap_m.xy()), ClickDistType::DIRECT);
|
||||
}
|
||||
|
||||
/** repaint me */
|
||||
void paint(Painter& p) override {
|
||||
|
||||
static const QPixmap& pixmapUnfocused = UIHelper::getPixmapColored("registration", CFG::UNFOCUS_COLOR, 16);
|
||||
static const QPixmap& pixmapFocused = UIHelper::getPixmapColored("registration", CFG::FOCUS_COLOR, 16);
|
||||
static const QPixmap& pixmapSel = UIHelper::getPixmapColored("registration", CFG::SEL_COLOR, 16);
|
||||
|
||||
|
||||
if (selectedUserIdx == 0) {
|
||||
p.drawPixmap(reg->posOnMap_m.xy(), pixmapSel);
|
||||
} else if (hasFocus()) {
|
||||
p.drawPixmap(reg->posOnMap_m.xy(), pixmapFocused);
|
||||
} else {
|
||||
p.drawPixmap(reg->posOnMap_m.xy(), pixmapUnfocused);
|
||||
}
|
||||
|
||||
// label
|
||||
p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
//p.drawDot(ap->pos.xy());
|
||||
if (p.getScaler().getScale() >= 10) {
|
||||
const std::string str = std::to_string(reg->posOnEarth.lat) + " " + std::to_string(reg->posOnEarth.lon);
|
||||
p.p->drawText(p.getScaler().xms(reg->posOnMap_m.x) + 10, p.getScaler().yms(reg->posOnMap_m.y) + 5, str.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
virtual std::vector<MoveableNode> getMoveableNodes() const override {
|
||||
return { MoveableNode(0, reg->posOnMap_m.xy()) };
|
||||
}
|
||||
|
||||
virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override {
|
||||
(void) v;
|
||||
if (userIdx == 0) {reg->posOnMap_m.x = newPos.x; reg->posOnMap_m.y = newPos.y;}
|
||||
}
|
||||
|
||||
|
||||
virtual void mousePressed(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
}
|
||||
|
||||
virtual void mouseMove(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
}
|
||||
|
||||
virtual void mouseReleased(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
}
|
||||
|
||||
virtual bool keyPressEvent(MapView2D* v, QKeyEvent *e) override {
|
||||
(void) v;
|
||||
(void) e;
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void onFocus() override {
|
||||
;
|
||||
}
|
||||
|
||||
virtual void onUnfocus() override {
|
||||
;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // MV2DELEMENTREGISTRATIONPOINT_H
|
||||
Reference in New Issue
Block a user