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/MMFloorObstacleCircle.h
2018-07-30 20:56:17 +02:00

83 lines
2.3 KiB
C++

#ifndef MAPMODELELEMENTFLOOROBSTACLECIRCLE_H
#define MAPMODELELEMENTFLOOROBSTACLECIRCLE_H
#include "MapModelElement.h"
#include "../2D/MapViewElementHelper.h"
#include "EElementParams.h"
#include "IHasParams.h"
#include "../2D/MV2DElementFloorObstacleCircle.h"
#include <Indoor/floorplan/v2/Floorplan.h>
class MMFloorObstacleCircle : public MapModelElement, public IHasParams {
private:
Floorplan::Floor* mf;
Floorplan::FloorObstacleCircle* c;
MV2DElementFloorObstacleCircle mv2d;
public:
MMFloorObstacleCircle(MapLayer* parent, Floorplan::Floor* mf, Floorplan::FloorObstacleCircle* c) :
MapModelElement(parent), mf(mf), c(c), mv2d(c) {
}
// 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;}
MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;}
void deleteMe() const override {
parent->removeElement(this);
mf->obstacles.erase(std::remove(mf->obstacles.begin(), mf->obstacles.end(), c), 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("radius", ParamType::FLOAT);
case 1: return Param("height", ParamType::FLOAT);
case 2: 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 c->radius;
case 1: return c->height;
case 2: return (int) c->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: c->radius = val.toFloat(); break;
case 1: c->height = val.toFloat(); break;
case 2: c->material = (Floorplan::Material) val.toInt(); break;
default: throw Exception("out of bounds");
}
}
};
#endif // MAPMODELELEMENTFLOOROBSTACLECIRCLE_H