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/MMFloorObstacleWall.h
2018-10-25 12:19:36 +02:00

155 lines
4.8 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* © Copyright 2014 Urheberrechtshinweis
* Alle Rechte vorbehalten / All Rights Reserved
*
* Programmcode ist urheberrechtlich geschuetzt.
* Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner.
* Keine Verwendung ohne explizite Genehmigung.
* (vgl. § 106 ff UrhG / § 97 UrhG)
*/
#ifndef MMFLOOROBSTACLEWALL_H
#define MMFLOOROBSTACLEWALL_H
#include "MapModelElement.h"
#include "../2D/MapViewElementHelper.h"
#include "EElementParams.h"
#include "IHasParams.h"
#include "../2D/MV2DElementFloorObstacleWall.h"
#include <Indoor/floorplan/v2/Floorplan.h>
class MMFloorObstacleWall : public MapModelElement, public IHasParams {
public:
Floorplan::Floor* mf;
Floorplan::FloorObstacleWall* wall;
MV2DElementFloorObstacleWall mv2d;
public:
MMFloorObstacleWall(MapLayer* parent, Floorplan::Floor* mf, Floorplan::FloorObstacleWall* wall) :
MapModelElement(parent), mf(mf), wall(wall), mv2d(mf, wall) {
;
}
// void setMaterial(const Floorplan::Material m) override {wall->material = m;}
// Floorplan::Material getMaterial() const override {return wall->material;}
// void setObstacleType(const Floorplan::ObstacleType t) override {wall->type = t;}
// Floorplan::ObstacleType getObatcleType() const override {return wall->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(), wall), mf->obstacles.end());
}
int getType() const {
const int idx = mv2d.getSelectedNode();
if (idx < 1000) {return 0;} // line
if (idx < 2000) {return 1;} // door
return 2; // window
}
Floorplan::FloorObstacleWallDoor* getCurDoor() const {
const int idx = mv2d.getSelectedNode()-1000;
return wall->doors[idx];
}
Floorplan::FloorObstacleWallWindow* getCurWindow() const {
const int idx = mv2d.getSelectedNode()-2000;
return wall->windows[idx];
}
int getNumParams() const override {
switch(getType()) {
case 0: return 5;
case 1: return 4;
case 2: return 4;
}
throw 1;
}
virtual Param getParamDesc(const int idx) const override {
switch(getType()) {
case 0: switch(idx) {
case 0: return Param("material", ParamType::ENUM, getMaterialStrings());
case 1: return Param("type", ParamType::ENUM, getObstacleTypeStrings());
case 2: return Param("thickness (m)", ParamType::FLOAT);
case 3: return Param("height (m)", ParamType::FLOAT);
case 4: return Param("length", ParamType::FLOAT, true);
} break;
case 1: switch(idx) {
case 0: return Param("width (m)", ParamType::FLOAT);
case 1: return Param("height (m)", ParamType::FLOAT);
case 2: return Param("left/right", ParamType::BOOL);
case 3: return Param("in/out", ParamType::BOOL);
} break;
case 2: switch(idx) {
case 0: return Param("above ground (m)", ParamType::FLOAT);
case 1: return Param("width (m)", ParamType::FLOAT);
case 2: return Param("height (m)", ParamType::FLOAT);
case 3: return Param("in/out", ParamType::BOOL);
} break;
}
throw 1;
}
virtual ParamValue getParamValue(const int idx) const override {
switch(getType()) {
case 0: switch(idx) {
case 0: return (int) wall->material;
case 1: return (int) wall->type;
case 2: return wall->thickness_m;
case 3: return wall->height_m;
case 4: return wall->from.getDistance(wall->to);
} break;
case 1: switch(idx) {
case 0: return getCurDoor()->width;
case 1: return getCurDoor()->height;
case 2: return getCurDoor()->leftRight;
case 3: return getCurDoor()->inOut;
} break;
case 2 : switch(idx) {
case 0: return getCurWindow()->startsAtHeight;
case 1: return getCurWindow()->width;
case 2: return getCurWindow()->height;
case 3: return getCurWindow()->inOut;
} break;
}
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(getType()) {
case 0: switch(idx) {
case 0: wall->material = (Floorplan::Material) val.toInt(); return;
case 1: wall->type = (Floorplan::ObstacleType) val.toInt(); return;
case 2: wall->thickness_m = val.toFloat(); return;
case 3: wall->height_m = val.toFloat(); return;
case 4: return;
} break;
case 1: switch(idx) {
case 0: getCurDoor()->width = val.toFloat(); return;
case 1: getCurDoor()->height = val.toFloat(); return;
case 2: getCurDoor()->leftRight = val.toBool(); return;
case 3: getCurDoor()->inOut = val.toBool(); return;
} break;
case 2: switch(idx) {
case 0: getCurWindow()->startsAtHeight = val.toFloat(); return;
case 1: getCurWindow()->width = val.toFloat(); return;
case 2: getCurWindow()->height = val.toFloat(); return;
case 3: getCurWindow()->inOut = val.toBool(); return;
} break;
}
}
};
#endif // MMFLOOROBSTACLEWALL_H