Merge branch 'master' of https://git.frank-ebner.de/FHWS/IndoorMap
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "MMFloorPOIs.h"
|
||||
#include "MMFloorStairs.h"
|
||||
#include "MMFloorElevators.h"
|
||||
#include "MMFloorGroundTruthPoints.h"
|
||||
|
||||
#include "IHasParams.h"
|
||||
|
||||
@@ -45,6 +46,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) {
|
||||
addElement(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
|
||||
addElement(new MMFloorGroundTruthPoint(this, floor, gtp));
|
||||
|
||||
}
|
||||
|
||||
std::string getLayerName() const override {return "GroundTruthPoints";}
|
||||
|
||||
};
|
||||
|
||||
#endif // MMFLOORGROUNDTRUTHPOINTS_H
|
||||
@@ -39,12 +39,13 @@ public:
|
||||
//MV3DElement* getMV3D() const override {return (MV3DElement*) &mv3d;}
|
||||
|
||||
virtual int getNumParams() const override {
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return Param("name", ParamType::STRING);
|
||||
case 1: return Param("outdoor", ParamType::BOOL);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
@@ -52,6 +53,7 @@ public:
|
||||
virtual ParamValue getParamValue(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return fo->name;
|
||||
case 1: return fo->outdoor;
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
@@ -59,6 +61,7 @@ public:
|
||||
virtual void setParamValue(const int idx, const ParamValue& val) const override {
|
||||
switch(idx) {
|
||||
case 0: fo->name = val.toString(); break;
|
||||
case 1: fo->outdoor = val.toBool(); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ enum class MapLayerType {
|
||||
FLOOR_UNDERLAYS,
|
||||
FLOOR_POIS,
|
||||
FLOOR_STAIRS,
|
||||
FLOOR_GROUND_TRUTH_POINTS
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -86,6 +86,82 @@ public:
|
||||
|
||||
}
|
||||
|
||||
float snap(const float val) {
|
||||
const float s = 0.1;
|
||||
return std::round(val / s) * s;
|
||||
}
|
||||
|
||||
/** resize everything within the floorplay by the given factor */
|
||||
void resize(const float sx, const float sy, const float sz, const float ox, const float oy, const float oz) {
|
||||
|
||||
for (Floorplan::Floor* f : im->floors) {
|
||||
f->atHeight = snap(f->atHeight * sz);
|
||||
f->height = snap(f->height * sz);
|
||||
for (Floorplan::FloorOutlinePolygon* poly : f->outline) {
|
||||
for (Point2& p : poly->poly.points) {
|
||||
p.x = snap(p.x * sx + ox);
|
||||
p.y = snap(p.y * sy + oy);
|
||||
}
|
||||
}
|
||||
for (Floorplan::AccessPoint* ap : f->accesspoints) {
|
||||
ap->pos.x = snap(ap->pos.x * sx + ox);
|
||||
ap->pos.y = snap(ap->pos.y * sy + oy);
|
||||
ap->pos.z = snap(ap->pos.z * sz + oz);
|
||||
}
|
||||
for (Floorplan::Beacon* b : f->beacons) {
|
||||
b->pos.x = snap(b->pos.x * sx + ox);
|
||||
b->pos.y = snap(b->pos.y * sy + oy);
|
||||
b->pos.z = snap(b->pos.z * sz + oz);
|
||||
}
|
||||
for (Floorplan::POI* p : f->pois) {
|
||||
p->pos.x = snap(p->pos.x * sx + ox);
|
||||
p->pos.y = snap(p->pos.y * sy + oy);
|
||||
}
|
||||
for (Floorplan::FingerprintLocation* fpl : f->fpLocations) {
|
||||
fpl->posOnFloor.x = snap(fpl->posOnFloor.x * sx + ox);
|
||||
fpl->posOnFloor.y = snap(fpl->posOnFloor.y * sy + oy);
|
||||
fpl->heightAboveFloor = snap(fpl->heightAboveFloor * sz + oz);
|
||||
}
|
||||
for (Floorplan::FloorObstacle* o : f->obstacles) {
|
||||
Floorplan::FloorObstacleLine* line = dynamic_cast<Floorplan::FloorObstacleLine*>(o);
|
||||
Floorplan::FloorObstacleDoor* door = dynamic_cast<Floorplan::FloorObstacleDoor*>(o);
|
||||
if (line) {
|
||||
line->from.x = snap(line->from.x * sx + ox);
|
||||
line->from.y = snap(line->from.y * sy + oy);
|
||||
line->to.x = snap(line->to.x * sx + ox);
|
||||
line->to.y = snap(line->to.y * sy + oy);
|
||||
} else if (door) {
|
||||
door->from.x = snap(door->from.x * sx + ox);
|
||||
door->from.y = snap(door->from.y * sy + oy);
|
||||
door->to.x = snap(door->to.x * sx + ox);
|
||||
door->to.y = snap(door->to.y * sy + oy);
|
||||
}
|
||||
}
|
||||
for (Floorplan::Stair* s : f->stairs) {
|
||||
Floorplan::StairFreeform* stair = dynamic_cast<Floorplan::StairFreeform*>(s);
|
||||
for (Floorplan::StairPart& sp : stair->parts) {
|
||||
sp.width = snap(sp.width * sx);
|
||||
sp.end.x = snap(sp.end.x * sx + ox);
|
||||
sp.end.y = snap(sp.end.y * sy + oy);
|
||||
sp.end.z = snap(sp.end.z * sz + oz);
|
||||
sp.start.x = snap(sp.start.x * sx + ox);
|
||||
sp.start.y = snap(sp.start.y * sy + oy);
|
||||
sp.start.z = snap(sp.start.z * sz + oz);
|
||||
}
|
||||
}
|
||||
for (Floorplan::Elevator* e : f->elevators) {
|
||||
e->center.x = snap(e->center.x * sx + ox);
|
||||
e->center.y = snap(e->center.y * sy + oy);
|
||||
e->width = snap(e->width * sx);
|
||||
e->depth = snap(e->depth * sx);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void onLayerChanged(MapLayer* layer) override {
|
||||
for (MapModelListener* l : listeners) {l->onLayerChanged(layer);}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user