added support for ground truth points: \n -layer for gt points \n -button with icon
-saving and loading support
This commit is contained in:
119
mapview/2D/MV2DElementGroundTruthPoint.h
Normal file
119
mapview/2D/MV2DElementGroundTruthPoint.h
Normal file
@@ -0,0 +1,119 @@
|
||||
#ifndef MV2DELEMENTGROUNDTRUTHPOINT_H
|
||||
#define MV2DELEMENTGROUNDTRUTHPOINT_H
|
||||
|
||||
#include "MV2DElement.h"
|
||||
#include "HasMoveableNodes.h"
|
||||
#include "MapViewElementHelper.h"
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
#include "../../UIHelper.h"
|
||||
|
||||
class MV2DElementGroundTruthPoint : public MV2DElement, public HasMoveableNodes {
|
||||
|
||||
private:
|
||||
|
||||
//bool sel = false;
|
||||
Floorplan::GroundTruthPoint* gtp;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with the AP to render/edit */
|
||||
MV2DElementGroundTruthPoint(Floorplan::GroundTruthPoint* gtp) : gtp(gtp) {;}
|
||||
|
||||
|
||||
/** get the element's 3D bounding box */
|
||||
BBox2 getBoundingBox() const override {
|
||||
BBox2 bbox;
|
||||
bbox.add(Point2(gtp->pos.x, gtp->pos.y));
|
||||
bbox.grow(Point2(0.1, 0.1));
|
||||
return bbox;
|
||||
}
|
||||
|
||||
/** get the element's minimal distance (nearest whatsoever) to the given point */
|
||||
float getMinDistanceXY(const Point2 p) const override {
|
||||
return p.getDistance(gtp->pos);
|
||||
}
|
||||
|
||||
/** repaint me */
|
||||
void paint(Painter& p) override {
|
||||
|
||||
static const QPixmap& pixmapUnfocused = UIHelper::getPixmapColored("gtp", CFG::UNFOCUS_COLOR, 16);
|
||||
static const QPixmap& pixmapFocused = UIHelper::getPixmapColored("gtp", CFG::FOCUS_COLOR, 16);
|
||||
static const QPixmap& pixmapSel = UIHelper::getPixmapColored("gtp", CFG::SEL_COLOR, 16);
|
||||
|
||||
|
||||
if (selectedUserIdx == 0) {
|
||||
// p.setPenBrush(Qt::black, CFG::SEL_COLOR);
|
||||
// p.drawCircle(gtp->pos);
|
||||
p.drawPixmap(gtp->pos, pixmapSel);
|
||||
} else if (hasFocus()) {
|
||||
// p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
// p.drawCircle(gtp->pos);
|
||||
p.drawPixmap(gtp->pos, pixmapFocused);
|
||||
} else {
|
||||
// p.setPenBrush(Qt::gray, Qt::NoBrush);
|
||||
// p.drawCircle(gtp->pos);
|
||||
p.drawPixmap(gtp->pos, pixmapUnfocused);
|
||||
}
|
||||
|
||||
// label
|
||||
p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
p.drawDot(gtp->pos);
|
||||
if (p.getScaler().getScale() >= 10) {
|
||||
const std::string str = std::to_string(gtp->id);
|
||||
p.p->drawText(p.getScaler().xms(gtp->pos.x) + 10, p.getScaler().yms(gtp->pos.y) + 5, str.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual std::vector<MoveableNode> getMoveableNodes() const override {
|
||||
return { MoveableNode(0, gtp->pos) };
|
||||
}
|
||||
|
||||
virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override {
|
||||
(void) v;
|
||||
if (userIdx == 0) {gtp->pos = newPos;}
|
||||
}
|
||||
|
||||
|
||||
/** mouse pressed at the given point */
|
||||
virtual void mousePressed(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
}
|
||||
|
||||
/** mouse moved to the given point */
|
||||
virtual void mouseMove(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
// if (sel) {
|
||||
// const Point2 p = v->getScaler().snap(_p);
|
||||
// gtp->pos.x = p.x;
|
||||
// gtp->pos.y = p.y;
|
||||
// }
|
||||
}
|
||||
|
||||
/** mouse released */
|
||||
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 // MV2DELEMENTGROUNDTRUTHPOINT_H
|
||||
@@ -8,6 +8,8 @@ struct MyNode : public GridNode, public GridPoint, public GridNodeImportance {
|
||||
|
||||
MyNode(float x, float y, float z) : GridPoint(x,y,z) {;}
|
||||
|
||||
float walkImportance;
|
||||
|
||||
};
|
||||
|
||||
#endif // MYNODE_H
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "MMFloorPOIs.h"
|
||||
#include "MMFloorStairs.h"
|
||||
#include "MMFloorElevators.h"
|
||||
#include "MMFloorGroundTruthPoints.h"
|
||||
|
||||
#include "IHasParams.h"
|
||||
|
||||
@@ -41,6 +42,7 @@ public:
|
||||
new MMFloorPOIs(this, floor);
|
||||
new MMFloorStairs(this, floor);
|
||||
new MMFloorElevators(this, floor);
|
||||
new MMFloorGroundTruthPoints(this, floor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
61
mapview/model/MMFloorGroundTruthPoint.h
Normal file
61
mapview/model/MMFloorGroundTruthPoint.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef MMFLOORGROUNDTRUTHPOINT_H
|
||||
#define MMFLOORGROUNDTRUTHPOINT_H
|
||||
|
||||
#include "MapModelElement.h"
|
||||
#include "IHasParams.h"
|
||||
|
||||
#include "../2D/MV2DElementGroundTruthPoint.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
class MMFloorGroundTruthPoint : public MapModelElement, public IHasParams {
|
||||
|
||||
private:
|
||||
|
||||
Floorplan::Floor* floor;
|
||||
Floorplan::GroundTruthPoint* gtp;
|
||||
MV2DElementGroundTruthPoint mv2d;
|
||||
|
||||
public:
|
||||
|
||||
MMFloorGroundTruthPoint(MapLayer* parent, Floorplan::Floor* floor, Floorplan::GroundTruthPoint* gtp) : MapModelElement(parent), floor(floor), gtp(gtp), mv2d(gtp) {
|
||||
;
|
||||
}
|
||||
|
||||
virtual int getNumParams() const override {
|
||||
return 2;
|
||||
}
|
||||
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return Param("id", ParamType::INT);
|
||||
case 1: return Param("position", ParamType::POINT2);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual ParamValue getParamValue(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return gtp->id; //TODO: this value can be changed and isn't set incremental within the indoormap
|
||||
case 1: return gtp->pos;
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual void setParamValue(const int idx, const ParamValue& val) const override {
|
||||
switch(idx) {
|
||||
case 0: gtp->id = val.toInt(); break;
|
||||
case 1: gtp->pos = val.toPoint2(); break;
|
||||
}
|
||||
}
|
||||
|
||||
MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;}
|
||||
|
||||
void deleteMe() const override {
|
||||
parent->removeElement(this);
|
||||
floor->gtpoints.erase(std::remove(floor->gtpoints.begin(), floor->gtpoints.end(), gtp), floor->gtpoints.end());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // MMFLOORGROUNDTRUTHPOINT_H
|
||||
46
mapview/model/MMFloorGroundTruthPoints.h
Normal file
46
mapview/model/MMFloorGroundTruthPoints.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef MMFLOORGROUNDTRUTHPOINTS_H
|
||||
#define MMFLOORGROUNDTRUTHPOINTS_H
|
||||
|
||||
#include "MapLayer.h"
|
||||
#include "MMFloorGroundTruthPoint.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
/**
|
||||
* layer that contains all of one floor's GroundTruthPoints
|
||||
*/
|
||||
class MMFloorGroundTruthPoints : public MapLayer {
|
||||
|
||||
Floorplan::Floor* floor;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with the floor */
|
||||
MMFloorGroundTruthPoints(MapLayer* parent, Floorplan::Floor* floor) : MapLayer(parent, MapLayerType::FLOOR_GROUND_TRUTH_POINTS), floor(floor) {
|
||||
|
||||
// the POIs
|
||||
for (Floorplan::GroundTruthPoint* gtp : floor->gtpoints) {
|
||||
elements.push_back(new MMFloorGroundTruthPoint(this, floor, gtp));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** get the corresponding floor from the underlying model */
|
||||
Floorplan::Floor* getFloor() {return floor;}
|
||||
|
||||
//TODO: check
|
||||
void createGroundTruthPoint(Floorplan::GroundTruthPoint* gtp) {
|
||||
|
||||
// add to underlying model
|
||||
floor->gtpoints.push_back(gtp);
|
||||
|
||||
// add to myself as element
|
||||
elements.push_back(new MMFloorGroundTruthPoint(this, floor, gtp));
|
||||
|
||||
}
|
||||
|
||||
std::string getLayerName() const override {return "GroundTruthPoints";}
|
||||
|
||||
};
|
||||
|
||||
#endif // MMFLOORGROUNDTRUTHPOINTS_H
|
||||
@@ -21,6 +21,7 @@ enum class MapLayerType {
|
||||
FLOOR_UNDERLAYS,
|
||||
FLOOR_POIS,
|
||||
FLOOR_STAIRS,
|
||||
FLOOR_GROUND_TRUTH_POINTS
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user