split line(old) and wall(new)

added new walling
started working on windows
This commit is contained in:
k-a-z-u
2018-07-25 16:20:34 +02:00
parent 4938987063
commit 8017241c6e
14 changed files with 703 additions and 122 deletions

View File

@@ -9,7 +9,6 @@
#include "IHasParams.h"
#include "../2D/MV2DElementFloorObstacleLine.h"
//#include "../3D/MV3DElementFloorObstacleWall.h"
#include <Indoor/floorplan/v2/Floorplan.h>
@@ -21,13 +20,12 @@ public:
Floorplan::Floor* mf;
Floorplan::FloorObstacleLine* fo;
MV2DElementFloorObstacleLine mv2d;
//MV3DElementFloorObstacleWall mv3d;
public:
MMFloorObstacleLine(MapLayer* parent, Floorplan::Floor* mf, Floorplan::FloorObstacleLine* fo) :
MapModelElement(parent), mf(mf), fo(fo), mv2d(mf, fo) {//, mv3d(mf,fo) {
MapModelElement(parent), mf(mf), fo(fo), mv2d(mf, fo) {
;
}
void setMaterial(const Floorplan::Material m) override {fo->material = m;}
@@ -37,44 +35,41 @@ public:
Floorplan::ObstacleType getObatcleType() 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());
}
virtual int getNumParams() const override {
int getNumParams() const override {
return 3;
}
virtual Param getParamDesc(const int idx) const override {
switch(idx) {
case 0: return Param("thickness (m)", ParamType::FLOAT);
case 1: return Param("height (m)", ParamType::FLOAT);
case 2: return Param("length", ParamType::FLOAT, true);
case 0: return Param("thickness (m)", ParamType::FLOAT);
case 1: return Param("height (m)", ParamType::FLOAT);
case 2: return Param("length", ParamType::FLOAT, true);
}
throw 1;
}
virtual ParamValue getParamValue(const int idx) const override {
switch(idx) {
case 0: return fo->thickness_m;
case 1: return fo->height_m;
case 2: return fo->from.getDistance(fo->to);
case 0: return fo->thickness_m;
case 1: return fo->height_m;
case 2: return fo->from.getDistance(fo->to);
}
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(idx) {
case 0: fo->thickness_m = val.toFloat(); break;
case 1: fo->height_m = val.toFloat(); break;
case 2: break;
case 0: fo->thickness_m = val.toFloat(); return;
case 1: fo->height_m = val.toFloat(); return;
case 2: return;
}
}
};
#endif // MAPELEMENTOBSTACLE_H

View File

@@ -0,0 +1,116 @@
#ifndef MMFLOOROBSTACLEWALL_H
#define MMFLOOROBSTACLEWALL_H
#include "MapModelElement.h"
#include "../2D/MapViewElementHelper.h"
#include "IHasMaterial.h"
#include "IHasObstacleType.h"
#include "IHasParams.h"
#include "../2D/MV2DElementFloorObstacleWall.h"
#include <Indoor/floorplan/v2/Floorplan.h>
class MMFloorObstacleWall : public MapModelElement, public IHasMaterial, public IHasObstacleType, 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];
}
int getNumParams() const override {
switch(getType()) {
case 0: return 3;
case 1: return 4;
case 2: return 0;
}
throw 1;
}
virtual Param getParamDesc(const int idx) const override {
switch(getType()) {
case 0: switch(idx) {
case 0: return Param("thickness (m)", ParamType::FLOAT);
case 1: return Param("height (m)", ParamType::FLOAT);
case 2: return Param("length", ParamType::FLOAT, true);
}
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);
}
}
throw 1;
}
virtual ParamValue getParamValue(const int idx) const override {
switch(getType()) {
case 0: switch(idx) {
case 0: return wall->thickness_m;
case 1: return wall->height_m;
case 2: return wall->from.getDistance(wall->to);
}
case 1: switch(idx) {
case 0: return getCurDoor()->width;
case 1: return getCurDoor()->height;
case 2: return getCurDoor()->leftRight;
case 3: return getCurDoor()->inOut;
}
}
throw 1;
}
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(getType()) {
case 0: switch(idx) {
case 0: wall->thickness_m = val.toFloat(); return;
case 1: wall->height_m = val.toFloat(); return;
case 2: return;
}
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;
}
}
}
};
#endif // MMFLOOROBSTACLEWALL_H

View File

@@ -4,6 +4,7 @@
#include "MapLayer.h"
#include "MMFloorObstacleCircle.h"
#include "MMFloorObstacleLine.h"
#include "MMFloorObstacleWall.h"
#include "MMFloorObstacleDoor.h"
#include "MMFloorObstacleObject.h"
@@ -25,12 +26,14 @@ public:
for (Floorplan::FloorObstacle* o : floor->obstacles) {
if (dynamic_cast<Floorplan::FloorObstacleLine*>(o)) {
addElement(new MMFloorObstacleLine(this, floor, (Floorplan::FloorObstacleLine*)o));
} else if (dynamic_cast<Floorplan::FloorObstacleWall*>(o)) {
addElement(new MMFloorObstacleWall(this, floor, (Floorplan::FloorObstacleWall*)o));
} else if (dynamic_cast<Floorplan::FloorObstacleCircle*>(o)) {
addElement(new MMFloorObstacleCircle(this, floor, (Floorplan::FloorObstacleCircle*)o));
} else if (dynamic_cast<Floorplan::FloorObstacleDoor*>(o)) {
addElement(new MMFloorObstacleDoor(this, floor, (Floorplan::FloorObstacleDoor*)o));
addElement(new MMFloorObstacleDoor(this, floor, (Floorplan::FloorObstacleDoor*)o));
} else if (dynamic_cast<Floorplan::FloorObstacleObject*>(o)) {
addElement(new MMFloorObstacleObject(this, floor, (Floorplan::FloorObstacleObject*)o));
addElement(new MMFloorObstacleObject(this, floor, (Floorplan::FloorObstacleObject*)o));
} else {
throw new Exception("todo: not yet implemented obstacle type");
}
@@ -50,6 +53,21 @@ public:
/** get the corresponding floor from the underlying model */
Floorplan::Floor* getFloor() {return floor;}
//TODO: check
MMFloorObstacleWall* createWall(Floorplan::FloorObstacleWall* obs) {
// add to underlying model
floor->obstacles.push_back(obs);
// add to myself as element
MMFloorObstacleWall* mm = new MMFloorObstacleWall(this, floor, obs);
addElement(mm);
return mm;
}
//TODO: check
MMFloorObstacleDoor* createDoor(Floorplan::FloorObstacleDoor* obs) {