This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
IndoorMap/mapview/model/MMFloorObstacleDoor.h
2018-07-30 20:56:17 +02:00

91 lines
2.7 KiB
C++

#ifndef MMFLOOROBSTACLEDOOR_H
#define MMFLOOROBSTACLEDOOR_H
#include "MapModelElement.h"
#include "../2D/MapViewElementHelper.h"
#include "EElementParams.h"
#include "IHasParams.h"
#include "../2D/MV2DElementFloorObstacleDoor.h"
//#include "../3D/MV3DElementFloorObstacleDoor.h"
#include <Indoor/floorplan/v2/Floorplan.h>
class MMFloorObstacleDoor : public MapModelElement, 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 5;
}
/** 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, getDoorTypeStrings());
case 4: return Param("material", ParamType::ENUM, getMaterialStrings());
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;
case 4: return (int) fo->material;
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;
case 4: fo->material = (Floorplan::Material) val.toInt(); break;
default: throw Exception("out of bounds");
}
}
};
#endif // MMFLOOROBSTACLEDOOR_H