88 lines
2.6 KiB
C++
88 lines
2.6 KiB
C++
#ifndef MMFLOOROBSTACLEDOOR_H
|
|
#define MMFLOOROBSTACLEDOOR_H
|
|
|
|
#include "MapModelElement.h"
|
|
#include "../2D/MapViewElementHelper.h"
|
|
|
|
#include "IHasMaterial.h"
|
|
#include "IHasDoorType.h"
|
|
#include "IHasParams.h"
|
|
|
|
#include "../2D/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 4;
|
|
}
|
|
|
|
/** 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);
|
|
case 3: return Param("type", ParamType::ENUM, {"unknown", "swing", "double swing", "slide", "double slide", "revolving"});
|
|
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;
|
|
case 3: return (int) fo->type;
|
|
default: throw Exception("out of bounds");
|
|
}
|
|
}
|
|
|
|
/** set the idx-th param's value */
|
|
virtual void setParamValue(const int idx, const ParamValue& val) override {
|
|
switch (idx) {
|
|
case 0: break;
|
|
case 1: fo->height = val.toFloat(); break;
|
|
case 2: fo->swap = val.toBool(); break;
|
|
case 3: fo->type = (Floorplan::DoorType) val.toInt(); break;
|
|
default: throw Exception("out of bounds");
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
#endif // MMFLOOROBSTACLEDOOR_H
|