added support for fingerprint adding/editing
some visualization changes
This commit is contained in:
91
mapview/2D/MV2DElementFingerprintLocation.h
Normal file
91
mapview/2D/MV2DElementFingerprintLocation.h
Normal file
@@ -0,0 +1,91 @@
|
||||
#ifndef MV2DELEMENTFINGERPRINTLOCATION_H
|
||||
#define MV2DELEMENTFINGERPRINTLOCATION_H
|
||||
|
||||
|
||||
#include "MV2DElement.h"
|
||||
#include "HasMoveableNodes.h"
|
||||
|
||||
#include "MapViewElementHelper.h"
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
#include "../../UIHelper.h"
|
||||
|
||||
class MV2DElementFingerprintLocation : public MV2DElement, public HasMoveableNodes {
|
||||
|
||||
private:
|
||||
|
||||
Floorplan::FingerprintLocation* fpl;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with the AP to render/edit */
|
||||
MV2DElementFingerprintLocation(Floorplan::FingerprintLocation* fpl) : fpl(fpl) {;}
|
||||
|
||||
|
||||
/** get the element's 2D bounding box */
|
||||
BBox2 getBoundingBox() const override {
|
||||
BBox2 bbox;
|
||||
bbox.add(Point2(fpl->posOnFloor.x, fpl->posOnFloor.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(fpl->posOnFloor), ClickDistType::DIRECT);
|
||||
}
|
||||
|
||||
/** repaint me */
|
||||
void paint(Painter& p) override {
|
||||
|
||||
static const QPixmap& pixmapUnfocused = UIHelper::getPixmapColored("fingerprint", CFG::UNFOCUS_COLOR, 16);
|
||||
static const QPixmap& pixmapFocused = UIHelper::getPixmapColored("fingerprint", CFG::FOCUS_COLOR, 16);
|
||||
static const QPixmap& pixmapSel = UIHelper::getPixmapColored("fingerprint", CFG::SEL_COLOR, 16);
|
||||
|
||||
|
||||
if (selectedUserIdx == 0) {
|
||||
//p.setPenBrush(Qt::black, CFG::SEL_COLOR);
|
||||
//p.drawCircle(ap->pos.xy());
|
||||
p.drawPixmap(fpl->posOnFloor, pixmapSel);
|
||||
} else if (hasFocus()) {
|
||||
//p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
//p.drawCircle(ap->pos.xy());
|
||||
p.drawPixmap(fpl->posOnFloor, pixmapFocused);
|
||||
} else {
|
||||
//p.setPenBrush(Qt::gray, Qt::NoBrush);
|
||||
//p.drawCircle(ap->pos.xy());
|
||||
p.drawPixmap(fpl->posOnFloor, pixmapUnfocused);
|
||||
}
|
||||
|
||||
// label
|
||||
p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
p.drawDot(fpl->posOnFloor);
|
||||
|
||||
if (p.getScaler().getScale() >= 10) {
|
||||
const std::string str = fpl->name;
|
||||
p.p->drawText(p.getScaler().xms(fpl->posOnFloor.x) + 10, p.getScaler().yms(fpl->posOnFloor.y) + 5, str.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
virtual std::vector<MoveableNode> getMoveableNodes() const override {
|
||||
return { MoveableNode(0, fpl->posOnFloor) };
|
||||
}
|
||||
|
||||
virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override {
|
||||
(void) v;
|
||||
if (userIdx == 0) {fpl->posOnFloor = newPos;}
|
||||
}
|
||||
|
||||
virtual void onFocus() override {
|
||||
;
|
||||
}
|
||||
|
||||
virtual void onUnfocus() override {
|
||||
;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // MV2DELEMENTFINGERPRINTLOCATION_H
|
||||
Reference in New Issue
Block a user