a lot of work on th map-creator
This commit is contained in:
16
mapview/model/IHasDoorType.h
Normal file
16
mapview/model/IHasDoorType.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef IHASDOORTYPE_H
|
||||
#define IHASDOORTYPE_H
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
class IHasDoorType {
|
||||
public:
|
||||
|
||||
virtual void setDoorType(const Floorplan::DoorType t) = 0;
|
||||
|
||||
virtual Floorplan::DoorType getDoorType() const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // IHASDOORTYPE_H
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <Indoor/geo/Point3.h>
|
||||
|
||||
enum class ParamType {
|
||||
NOT_AVAILABLE,
|
||||
BOOL,
|
||||
INT,
|
||||
FLOAT,
|
||||
STRING,
|
||||
@@ -18,6 +20,7 @@ class ParamValue {
|
||||
|
||||
private:
|
||||
union {
|
||||
bool _bool;
|
||||
int _int;
|
||||
float _float;
|
||||
float _arr[3];
|
||||
@@ -31,16 +34,18 @@ public:
|
||||
}
|
||||
|
||||
void setValue(const std::string& val) {_str = val;}
|
||||
void setValue(float val) {_float = val;}
|
||||
void setValue(int val) {_int = val;}
|
||||
void setValue(Point2 p) {_arr[0] = p.x; _arr[1] = p.y;}
|
||||
void setValue(Point3 p) {_arr[0] = p.x; _arr[1] = p.y; _arr[2] = p.z;}
|
||||
void setValue(const float val) {_float = val;}
|
||||
void setValue(const int val) {_int = val;}
|
||||
void setValue(const bool val) {_bool = val;}
|
||||
void setValue(const Point2 p) {_arr[0] = p.x; _arr[1] = p.y;}
|
||||
void setValue(const Point3 p) {_arr[0] = p.x; _arr[1] = p.y; _arr[2] = p.z;}
|
||||
|
||||
Point2 toPoint2() const {return Point2(_arr[0], _arr[1]);}
|
||||
Point3 toPoint3() const {return Point3(_arr[0], _arr[1], _arr[2]);}
|
||||
std::string toString() const {return _str;}
|
||||
float toFloat() const {return _float;}
|
||||
int toInt() const {return _int;}
|
||||
bool toBool() const {return _bool;}
|
||||
|
||||
};
|
||||
|
||||
@@ -66,9 +71,23 @@ public:
|
||||
//};
|
||||
|
||||
struct Param {
|
||||
|
||||
/** parameter name */
|
||||
std::string name;
|
||||
|
||||
/** parameter type */
|
||||
ParamType type;
|
||||
Param(const std::string& name, const ParamType type) : name(name), type(type) {;}
|
||||
|
||||
/** read-only parameter? */
|
||||
bool readOnly;
|
||||
|
||||
|
||||
/** ctor */
|
||||
Param(const std::string& name, const ParamType type, const bool readOnly = false) : name(name), type(type), readOnly(readOnly) {;}
|
||||
|
||||
/** special parameter */
|
||||
static Param getNA() { return Param("", ParamType::NOT_AVAILABLE); }
|
||||
|
||||
};
|
||||
|
||||
/** free parameters */
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "MMFloorBeacons.h"
|
||||
#include "MMFloorUnderlays.h"
|
||||
#include "MMFloorPOIs.h"
|
||||
#include "MMFloorStairs.h"
|
||||
|
||||
#include "IHasParams.h"
|
||||
|
||||
@@ -37,6 +38,7 @@ public:
|
||||
new MMFloorAccessPoints(this, floor);
|
||||
new MMFloorBeacons(this, floor);
|
||||
new MMFloorPOIs(this, floor);
|
||||
new MMFloorStairs(this, floor);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
|
||||
class MMFloorObstacleCircle : public MapModelElement, public IHasMaterial, public IHasObstacleType {
|
||||
class MMFloorObstacleCircle : public MapModelElement, public IHasMaterial {
|
||||
|
||||
private:
|
||||
|
||||
@@ -31,8 +31,8 @@ public:
|
||||
void setMaterial(const Floorplan::Material m) override {c->material = m;}
|
||||
Floorplan::Material getMaterial() const override {return c->material;}
|
||||
|
||||
void setObstacleType(const Floorplan::ObstacleType t) override {c->type = t;}
|
||||
Floorplan::ObstacleType getObatcleType() const override {return c->type;}
|
||||
// void setObstacleType(const Floorplan::ObstacleType t) override {c->type = t;}
|
||||
// Floorplan::ObstacleType getObatcleType() const override {return c->type;}
|
||||
|
||||
MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;}
|
||||
|
||||
|
||||
84
mapview/model/MMFloorObstacleDoor.h
Normal file
84
mapview/model/MMFloorObstacleDoor.h
Normal file
@@ -0,0 +1,84 @@
|
||||
#ifndef MMFLOOROBSTACLEDOOR_H
|
||||
#define MMFLOOROBSTACLEDOOR_H
|
||||
|
||||
#include "MapModelElement.h"
|
||||
#include "../elements/MapViewElementHelper.h"
|
||||
|
||||
#include "IHasMaterial.h"
|
||||
#include "IHasDoorType.h"
|
||||
#include "IHasParams.h"
|
||||
|
||||
#include "../elements/MV2DElementFloorObstacleDoor.h"
|
||||
#include "../3D/MV3DElementFloorObstacleDoor.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
|
||||
class MMFloorObstacleDoor : public MapModelElement, public IHasMaterial, public IHasDoorType, public IHasParams {
|
||||
|
||||
public:
|
||||
|
||||
Floorplan::Floor* mf;
|
||||
Floorplan::FloorObstacleDoor* fo;
|
||||
MV2DElementFloorObstacleDoor mv2d;
|
||||
MV3DElementFloorObstacleDoor mv3d;
|
||||
|
||||
public:
|
||||
|
||||
MMFloorObstacleDoor(MapLayer* parent, Floorplan::Floor* mf, Floorplan::FloorObstacleDoor* fo) :
|
||||
MapModelElement(parent), mf(mf), fo(fo), mv2d(fo), mv3d(mf,fo) {
|
||||
|
||||
}
|
||||
|
||||
void setMaterial(const Floorplan::Material m) override {fo->material = m;}
|
||||
Floorplan::Material getMaterial() const override {return fo->material;}
|
||||
|
||||
void setDoorType(const Floorplan::DoorType t) override {fo->type = t;}
|
||||
Floorplan::DoorType getDoorType() const override {return fo->type;}
|
||||
|
||||
MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;}
|
||||
MV3DElement* getMV3D() const override {return (MV3DElement*) &mv3d;}
|
||||
|
||||
void deleteMe() const override {
|
||||
parent->removeElement(this);
|
||||
mf->obstacles.erase(std::remove(mf->obstacles.begin(), mf->obstacles.end(), fo), mf->obstacles.end());
|
||||
}
|
||||
|
||||
/** get the number of parameters */
|
||||
int getNumParams() const override {
|
||||
return 3;
|
||||
}
|
||||
|
||||
/** get the description of the idx-th parameter */
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
switch (idx) {
|
||||
case 0: return Param("width", ParamType::FLOAT, true);
|
||||
case 1: return Param("height", ParamType::FLOAT);
|
||||
case 2: return Param("swap", ParamType::BOOL);
|
||||
default: throw Exception("out of bounds");
|
||||
}
|
||||
}
|
||||
|
||||
/** get the idx-th param's value */
|
||||
virtual ParamValue getParamValue(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return fo->getSize();
|
||||
case 1: return fo->height;
|
||||
case 2: return fo->swap;
|
||||
default: throw Exception("out of bounds");
|
||||
}
|
||||
}
|
||||
|
||||
/** set the idx-th param's value */
|
||||
virtual void setParamValue(const int idx, const ParamValue& val) const override {
|
||||
switch (idx) {
|
||||
case 0: break;
|
||||
case 1: fo->height = val.toFloat(); break;
|
||||
case 2: fo->swap = val.toBool(); break;
|
||||
default: throw Exception("out of bounds");
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // MMFLOOROBSTACLEDOOR_H
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "MapLayer.h"
|
||||
#include "MMFloorObstacleCircle.h"
|
||||
#include "MMFloorObstacleLine.h"
|
||||
#include "MMFloorObstacleDoor.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
@@ -25,6 +26,10 @@ public:
|
||||
elements.push_back(new MMFloorObstacleLine(this, floor, (Floorplan::FloorObstacleLine*)o));
|
||||
} else if (dynamic_cast<Floorplan::FloorObstacleCircle*>(o)) {
|
||||
elements.push_back(new MMFloorObstacleCircle(this, floor, (Floorplan::FloorObstacleCircle*)o));
|
||||
} else if (dynamic_cast<Floorplan::FloorObstacleDoor*>(o)) {
|
||||
elements.push_back(new MMFloorObstacleDoor(this, floor, (Floorplan::FloorObstacleDoor*)o));
|
||||
} else {
|
||||
throw new Exception("todo: not yet implemented obstacle type");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +38,17 @@ public:
|
||||
/** get the corresponding floor from the underlying model */
|
||||
Floorplan::Floor* getFloor() {return floor;}
|
||||
|
||||
//TODO: check
|
||||
void createDoor(Floorplan::FloorObstacleDoor* obs) {
|
||||
|
||||
// add to underlying model
|
||||
floor->obstacles.push_back(obs);
|
||||
|
||||
// add to myself as element
|
||||
elements.push_back(new MMFloorObstacleDoor(this, floor, obs));
|
||||
|
||||
}
|
||||
|
||||
//TODO: check
|
||||
void createLine(Floorplan::FloorObstacleLine* obs) {
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return Param("anem", ParamType::STRING);
|
||||
case 0: return Param("name", ParamType::STRING);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
132
mapview/model/MMFloorStair.h
Normal file
132
mapview/model/MMFloorStair.h
Normal file
@@ -0,0 +1,132 @@
|
||||
#ifndef MMFLOORSTAIR_H
|
||||
#define MMFLOORSTAIR_H
|
||||
|
||||
#include "MapLayer.h"
|
||||
#include "IHasParams.h"
|
||||
#include "MMFloorOutlinePolygon.h"
|
||||
|
||||
#include "../elements/MV2DElementStair.h"
|
||||
#include "../3D/MV3DElementStair.h"
|
||||
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
/**
|
||||
* layer containing all elements describing a floor's outline
|
||||
*/
|
||||
class MMFloorStair : public MapModelElement, public IHasParams {
|
||||
|
||||
private:
|
||||
|
||||
/** the underlying model */
|
||||
Floorplan::Floor* floor;
|
||||
Floorplan::StairFreeform* stair;
|
||||
|
||||
MV2DElementStair mv2d;
|
||||
MV3DElementStair mv3d;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with the underlying model */
|
||||
MMFloorStair(MapLayer* parent, Floorplan::Floor* floor, Floorplan::StairFreeform* stair) :
|
||||
MapModelElement(parent), floor(floor), stair(stair), mv2d(floor, stair), mv3d(floor, stair) {
|
||||
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;}
|
||||
MV3DElement* getMV3D() const override {return (MV3DElement*) &mv3d;}
|
||||
|
||||
|
||||
virtual int getNumParams() const override {
|
||||
const int selPart = mv2d.getSelPart();
|
||||
return (selPart >= 0) ? (3) : (0);
|
||||
}
|
||||
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
const int selPart = mv2d.getSelPart();
|
||||
const int selNode = mv2d.getSelNode();
|
||||
switch(idx) {
|
||||
case 0: return Param("node height", ParamType::FLOAT);
|
||||
case 1: return (selPart >= 0 && selNode == 0) ? Param("part width", ParamType::FLOAT) : Param::getNA();
|
||||
case 2: return (selPart >= 0 && selNode == 0) ? Param("connect", ParamType::BOOL) : Param::getNA();
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual ParamValue getParamValue(const int idx) const override {
|
||||
const int selPart = mv2d.getSelPart();
|
||||
const int selNode = mv2d.getSelNode();
|
||||
switch(idx) {
|
||||
case 0: if (selPart >= 0) {return stair->parts[selPart][selNode].z;} else {return NAN;}
|
||||
case 1: if (selPart >= 0) {return stair->parts[selPart].width;} else {return NAN;}
|
||||
case 2: if (selPart >= 0) {return stair->parts[selPart].connectWithPrev;} else {return false;}
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual void setParamValue(const int idx, const ParamValue& val) const override {
|
||||
const int selPart = mv2d.getSelPart();
|
||||
const int selNode = mv2d.getSelNode();
|
||||
switch(idx) {
|
||||
case 0: if (selPart >= 0) {stair->parts[selPart][selNode].z = val.toFloat();} break;
|
||||
case 1: if (selPart >= 0) {stair->parts[selPart].width = val.toFloat();} break;
|
||||
case 2: if (selPart >= 0) {stair->parts[selPart].connectWithPrev = val.toBool();} break;
|
||||
}
|
||||
}
|
||||
|
||||
void deleteMe() const override {
|
||||
parent->removeElement(this);
|
||||
floor->stairs.erase(std::remove(floor->stairs.begin(), floor->stairs.end(), stair), floor->stairs.end());
|
||||
}
|
||||
|
||||
// virtual int getNumParams() const override {
|
||||
// return 4;
|
||||
// }
|
||||
|
||||
// virtual Param getParamDesc(const int idx) const override {
|
||||
// switch(idx) {
|
||||
// case 0: return Param("center", ParamType::POINT2);
|
||||
// case 1: return Param("at height", ParamType::FLOAT);
|
||||
// case 2: return Param("height", ParamType::FLOAT);
|
||||
// case 3: return Param("angle", ParamType::FLOAT);
|
||||
// }
|
||||
// throw 1;
|
||||
// }
|
||||
|
||||
// virtual ParamValue getParamValue(const int idx) const override {
|
||||
// switch(idx) {
|
||||
// case 0: return stair->center;
|
||||
// case 1: return stair->atHeight;
|
||||
// case 2: return stair->height;
|
||||
// case 3: return stair->angleDeg;
|
||||
// }
|
||||
// throw 1;
|
||||
// }
|
||||
|
||||
// virtual void setParamValue(const int idx, const ParamValue& val) const override {
|
||||
// switch(idx) {
|
||||
// case 0: stair->center = val.toPoint2(); break;
|
||||
// case 1: stair->atHeight = val.toFloat(); break;
|
||||
// case 2: stair->height = val.toFloat(); break;
|
||||
// case 3: stair->angleDeg = val.toFloat(); break;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// //TODO: check
|
||||
// void create(Floorplan::FloorOutlinePolygon* poly) {
|
||||
|
||||
// // add to underlying model
|
||||
// floor->outline.push_back(poly);
|
||||
|
||||
// // add to myself as element
|
||||
// elements.push_back(new MMFloorOutlinePolygon(this, floor, poly));
|
||||
|
||||
// }
|
||||
|
||||
};
|
||||
|
||||
#endif // MMFLOORSTAIR_H
|
||||
48
mapview/model/MMFloorStairs.h
Normal file
48
mapview/model/MMFloorStairs.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef MMFLOORSTAIRS_H
|
||||
#define MMFLOORSTAIRS_H
|
||||
|
||||
#include "MapLayer.h"
|
||||
#include "MMFloorStair.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
/**
|
||||
* layer containing all stairs of one floor
|
||||
*/
|
||||
class MMFloorStairs : public MapLayer {
|
||||
|
||||
private:
|
||||
|
||||
Floorplan::Floor* floor;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with the underlying model */
|
||||
MMFloorStairs(MapLayer* parent, Floorplan::Floor* floor) : MapLayer(parent, MapLayerType::FLOOR_STAIRS), floor(floor) {
|
||||
|
||||
// add all floors
|
||||
for (Floorplan::Stair* stair : floor->stairs) {
|
||||
if (dynamic_cast<Floorplan::StairFreeform*>(stair)) {
|
||||
elements.push_back( new MMFloorStair(this, floor, (Floorplan::StairFreeform*)stair) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void create(Floorplan::StairFreeform* stair) {
|
||||
|
||||
// add to underlying model
|
||||
floor->stairs.push_back(stair);
|
||||
|
||||
// add to myself as element
|
||||
elements.push_back(new MMFloorStair(this, floor, stair));
|
||||
|
||||
}
|
||||
|
||||
std::string getLayerName() const override {return "stairs";}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // MMFLOORSTAIRS_H
|
||||
@@ -19,6 +19,7 @@ enum class MapLayerType {
|
||||
FLOOR_ACCESS_POINTS,
|
||||
FLOOR_UNDERLAYS,
|
||||
FLOOR_POIS,
|
||||
FLOOR_STAIRS,
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user