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
|
||||
@@ -25,6 +25,7 @@ protected:
|
||||
void paintGL() override {
|
||||
|
||||
Cube cube(ap->getPos(f), 0.25);
|
||||
glColor3f(0,0,1);
|
||||
cube.paintGL();
|
||||
|
||||
}
|
||||
|
||||
36
mapview/3D/MV3DElementFingerprintLocation.h
Normal file
36
mapview/3D/MV3DElementFingerprintLocation.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef MV3DELEMENTFINGERPRINTLOCATION_H
|
||||
#define MV3DELEMENTFINGERPRINTLOCATION_H
|
||||
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
#include "misc/Cube.h"
|
||||
#include "MV3DElement.h"
|
||||
|
||||
class MV3DElementFingerprintLocation : public MV3DElement {
|
||||
|
||||
Floorplan::Floor* f;
|
||||
Floorplan::FingerprintLocation* fpl;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
MV3DElementFingerprintLocation(Floorplan::Floor* f, Floorplan::FingerprintLocation* fpl) : f(f), fpl(fpl) {
|
||||
;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
/** repaint me */
|
||||
void paintGL() override {
|
||||
|
||||
Cube cube(fpl->getPosition(*f), 0.15);
|
||||
glColor3f(1,0,1);
|
||||
cube.paintGL();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // MV3DELEMENTFINGERPRINTLOCATION_H
|
||||
@@ -25,8 +25,6 @@ public:
|
||||
glPushMatrix();
|
||||
glTranslatef(pos.x, pos.z, pos.y);
|
||||
|
||||
glColor3f(0,0,1);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
// bottom
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "MMFloorObstacles.h"
|
||||
#include "MMFloorAccessPoints.h"
|
||||
#include "MMFloorBeacons.h"
|
||||
#include "MMFloorFingerprints.h"
|
||||
#include "MMFloorUnderlays.h"
|
||||
#include "MMFloorPOIs.h"
|
||||
#include "MMFloorStairs.h"
|
||||
@@ -40,6 +41,7 @@ public:
|
||||
new MMFloorObstacles(this, floor);
|
||||
new MMFloorAccessPoints(this, floor);
|
||||
new MMFloorBeacons(this, floor);
|
||||
new MMFloorFingerprints(this, floor);
|
||||
new MMFloorPOIs(this, floor);
|
||||
new MMFloorStairs(this, floor);
|
||||
new MMFloorElevators(this, floor);
|
||||
|
||||
78
mapview/model/MMFloorFingerprintLocation.h
Normal file
78
mapview/model/MMFloorFingerprintLocation.h
Normal file
@@ -0,0 +1,78 @@
|
||||
#ifndef MMFLOORFINGERPRINTLOCATIONS_H
|
||||
#define MMFLOORFINGERPRINTLOCATIONS_H
|
||||
|
||||
|
||||
#include "MapModelElement.h"
|
||||
#include "IHasParams.h"
|
||||
#include "IHasEditableMeta.h"
|
||||
|
||||
#include "../2D/MV2DElementFingerprintLocation.h"
|
||||
#include "../3D/MV3DElementFingerprintLocation.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
class MMFloorFingerprintLocation : public MapModelElement, public IHasParams, public IHasEditableMeta {
|
||||
|
||||
private:
|
||||
|
||||
Floorplan::Floor* floor;
|
||||
Floorplan::FingerprintLocation* fpl;
|
||||
MV2DElementFingerprintLocation mv2d;
|
||||
MV3DElementFingerprintLocation mv3d;
|
||||
|
||||
public:
|
||||
|
||||
MMFloorFingerprintLocation(MapLayer* parent, Floorplan::Floor* floor, Floorplan::FingerprintLocation* fpl) :
|
||||
MapModelElement(parent), floor(floor), fpl(fpl), mv2d(fpl), mv3d(floor, fpl) {
|
||||
|
||||
}
|
||||
|
||||
virtual int getNumParams() const override {
|
||||
return 3;
|
||||
}
|
||||
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return Param("name", ParamType::STRING);
|
||||
case 1: return Param("Position", ParamType::POINT2);
|
||||
case 2: return Param("at height", ParamType::FLOAT);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual ParamValue getParamValue(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return fpl->name;
|
||||
case 1: return fpl->posOnFloor;
|
||||
case 2: return fpl->heightAboveFloor;
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual void setParamValue(const int idx, const ParamValue& val) const override {
|
||||
switch(idx) {
|
||||
case 0: fpl->name = val.toString(); break;
|
||||
case 1: fpl->posOnFloor = val.toPoint2(); break;
|
||||
case 2: fpl->heightAboveFloor = val.toFloat(); break;
|
||||
}
|
||||
}
|
||||
|
||||
virtual Floorplan::Meta* getMeta() override {
|
||||
return fpl->getMeta();
|
||||
}
|
||||
|
||||
virtual void setMeta(Floorplan::Meta* meta) override {
|
||||
fpl->setMeta(meta);
|
||||
}
|
||||
|
||||
MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;}
|
||||
MV3DElement* getMV3D() const override {return (MV3DElement*) &mv3d;}
|
||||
|
||||
void deleteMe() const override {
|
||||
parent->removeElement(this);
|
||||
floor->fpLocations.erase(std::remove(floor->fpLocations.begin(), floor->fpLocations.end(), fpl), floor->fpLocations.end());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // MMFLOORFINGERPRINTLOCATIONS_H
|
||||
51
mapview/model/MMFloorFingerprints.h
Normal file
51
mapview/model/MMFloorFingerprints.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef MMFLOORFINGERPRINTS_H
|
||||
#define MMFLOORFINGERPRINTS_H
|
||||
|
||||
|
||||
#include "MapLayer.h"
|
||||
#include "MMFloorFingerprintLocation.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
/**
|
||||
* layer that contains all of one floor's fingerprints:
|
||||
* locations, measurements?, other?
|
||||
*/
|
||||
class MMFloorFingerprints : public MapLayer {
|
||||
|
||||
Floorplan::Floor* floor;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with the floor */
|
||||
MMFloorFingerprints(MapLayer* parent, Floorplan::Floor* floor) : MapLayer(parent, MapLayerType::FLOOR_FINGERPRINTS), floor(floor) {
|
||||
|
||||
// the obstacles
|
||||
for (Floorplan::FingerprintLocation* fpl : floor->fpLocations) {
|
||||
addElement(new MMFloorFingerprintLocation(this, floor, fpl));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** get the corresponding floor from the underlying model */
|
||||
Floorplan::Floor* getFloor() {return floor;}
|
||||
|
||||
//TODO: check
|
||||
MMFloorFingerprintLocation* create(Floorplan::FingerprintLocation* fpl) {
|
||||
|
||||
// add to underlying model
|
||||
floor->fpLocations.push_back(fpl);
|
||||
|
||||
// add to myself as element
|
||||
MMFloorFingerprintLocation* mm = new MMFloorFingerprintLocation(this, floor, fpl);
|
||||
addElement(mm);
|
||||
return mm;
|
||||
|
||||
}
|
||||
|
||||
std::string getLayerName() const override {return "fingerprints";}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // MMFLOORFINGERPRINTS_H
|
||||
@@ -19,6 +19,7 @@ enum class MapLayerType {
|
||||
FLOOR_OBSTACLES,
|
||||
FLOOR_BEACONS,
|
||||
FLOOR_ACCESS_POINTS,
|
||||
FLOOR_FINGERPRINTS,
|
||||
FLOOR_ELEVATORS,
|
||||
FLOOR_UNDERLAYS,
|
||||
FLOOR_POIS,
|
||||
|
||||
Reference in New Issue
Block a user