added elevator support
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "MMFloorUnderlays.h"
|
||||
#include "MMFloorPOIs.h"
|
||||
#include "MMFloorStairs.h"
|
||||
#include "MMFloorElevators.h"
|
||||
|
||||
#include "IHasParams.h"
|
||||
|
||||
@@ -39,7 +40,7 @@ public:
|
||||
new MMFloorBeacons(this, floor);
|
||||
new MMFloorPOIs(this, floor);
|
||||
new MMFloorStairs(this, floor);
|
||||
|
||||
new MMFloorElevators(this, floor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
68
mapview/model/MMFloorElevator.h
Normal file
68
mapview/model/MMFloorElevator.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef MMFLOORELEVATOR_H
|
||||
#define MMFLOORELEVATOR_H
|
||||
|
||||
#include "MapModelElement.h"
|
||||
#include "IHasParams.h"
|
||||
|
||||
#include "../2D/MV2DElementElevator.h"
|
||||
//#include "../3D/MV3DElementElevator.h" TODO
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
class MMFloorElevator : public MapModelElement, public IHasParams {
|
||||
|
||||
private:
|
||||
|
||||
Floorplan::Floor* floor;
|
||||
Floorplan::Elevator* elevator;
|
||||
MV2DElementElevator mv2d;
|
||||
//MV3DElementElevator mv3d; TODO
|
||||
|
||||
public:
|
||||
|
||||
MMFloorElevator(MapLayer* parent, Floorplan::Floor* floor, Floorplan::Elevator* elevator) :
|
||||
MapModelElement(parent), floor(floor), elevator(elevator), mv2d(elevator) {
|
||||
|
||||
}
|
||||
|
||||
virtual int getNumParams() const override {
|
||||
return 3;
|
||||
}
|
||||
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return Param("width", ParamType::FLOAT);
|
||||
case 1: return Param("depth", ParamType::FLOAT);
|
||||
case 2: return Param("rotation", ParamType::FLOAT);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual ParamValue getParamValue(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return elevator->width;
|
||||
case 1: return elevator->depth;
|
||||
case 2: return (elevator->rotation * 180.0f / (float)M_PI);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual void setParamValue(const int idx, const ParamValue& val) const override {
|
||||
switch(idx) {
|
||||
case 0: elevator->width = val.toFloat(); break;
|
||||
case 1: elevator->depth = val.toFloat(); break;
|
||||
case 2: elevator->rotation = val.toFloat() / 180.0f * (float)M_PI; break;
|
||||
}
|
||||
}
|
||||
|
||||
MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;}
|
||||
MV3DElement* getMV3D() const override {return nullptr;} // TODO
|
||||
|
||||
void deleteMe() const override {
|
||||
parent->removeElement(this);
|
||||
floor->elevators.erase(std::remove(floor->elevators.begin(), floor->elevators.end(), elevator), floor->elevators.end());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // MMFLOORELEVATOR_H
|
||||
47
mapview/model/MMFloorElevators.h
Normal file
47
mapview/model/MMFloorElevators.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef MMFLOORELEVATORS_H
|
||||
#define MMFLOORELEVATORS_H
|
||||
|
||||
|
||||
#include "MapLayer.h"
|
||||
#include "MMFloorElevator.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
/**
|
||||
* layer containing one floor's elevators
|
||||
*/
|
||||
class MMFloorElevators : public MapLayer {
|
||||
|
||||
private:
|
||||
|
||||
Floorplan::Floor* floor;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with the underlying model */
|
||||
MMFloorElevators(MapLayer* parent, Floorplan::Floor* floor) : MapLayer(parent, MapLayerType::FLOOR_ELEVATORS), floor(floor) {
|
||||
|
||||
// add all elevators
|
||||
for (Floorplan::Elevator* elevator : floor->elevators) {
|
||||
elements.push_back(new MMFloorElevator(this, floor, elevator));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string getLayerName() const override {return "Elevators";}
|
||||
|
||||
//TODO: check
|
||||
void create(Floorplan::Elevator* elevator) {
|
||||
|
||||
// add to underlying model
|
||||
floor->elevators.push_back(elevator);
|
||||
|
||||
// add to myself as element
|
||||
elements.push_back(new MMFloorElevator(this, floor, elevator));
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // MMFLOORELEVATORS_H
|
||||
@@ -17,6 +17,7 @@ enum class MapLayerType {
|
||||
FLOOR_OBSTACLES,
|
||||
FLOOR_BEACONS,
|
||||
FLOOR_ACCESS_POINTS,
|
||||
FLOOR_ELEVATORS,
|
||||
FLOOR_UNDERLAYS,
|
||||
FLOOR_POIS,
|
||||
FLOOR_STAIRS,
|
||||
|
||||
Reference in New Issue
Block a user