refactoring/cleanups

This commit is contained in:
2018-07-30 20:56:17 +02:00
parent 9a07790ec6
commit a9fcb77675
23 changed files with 276 additions and 247 deletions

View File

@@ -87,9 +87,7 @@ HEADERS += MainWindow.h \
mapview/model/MapModelElement.h \
mapview/model/IHasAttributes.h \
mapview/model/IHasMAC.h \
mapview/model/IHasMaterial.h \
mapview/model/IHasName.h \
mapview/model/IHasObstacleType.h \
mapview/model/IHasPosition3D.h \
mapview/2D/MV2DElementFloorObstacleLine.h \
mapview/2D/MV2DElement.h \
@@ -121,7 +119,6 @@ HEADERS += MainWindow.h \
mapview/model/MMFloorBeacon.h \
mapview/model/MMFloorAccessPoints.h \
mapview/model/MMFloorBeacons.h \
mapview/model/IHasFile.h \
mapview/model/MMFloorUnderlayImage.h \
mapview/model/IHasParams.h \
mapview/model/MMFloorUnderlays.h \
@@ -141,7 +138,6 @@ HEADERS += MainWindow.h \
params/StairBuilder.h \
misc/GnuplotExport.h \
mapview/model/MMFloorObstacleDoor.h \
mapview/model/IHasDoorType.h \
mapview/3D/MV3DElementFloorObstacleDoor.h \
mapview/3D/misc/Plane.h \ mapview/2D/MapView2D.h \
mapview/2D/Painter.h \
@@ -208,7 +204,8 @@ HEADERS += MainWindow.h \
mapview/2D/tools/ToolNewPillar.h \
mapview/model/MMFloorObstacleWall.h \
mapview/2D/MV2DElementFloorObstacleWall.h \
mapview/2D/tools/ToolNewLine.h
mapview/2D/tools/ToolNewLine.h \
mapview/model/EElementParams.h
FORMS += MainWindow.ui

View File

@@ -127,7 +127,7 @@ MainController::MainController() {
//mapModel->load("/apps/paper/maps/museum/map43_svg.xml");
mapModel->load("/apps/paper/maps/shl/SHL46_nm.xml");
//mapModel->load("/apps/paper/maps/test/doors1.xml");
//mapModel->load("/apps/paper/maps/test/doors2.xml");
//mapModel->load("/mnt/sdcard/SHL41_nm.xml");

View File

@@ -18,23 +18,28 @@ int main(int argc, char *argv[]) {
QString str = R"(
QDockWidget > QWidget {
border: 1px solid #666;
background: #333;
}
/** title color */
QDockWidget {
color: #fff;
font-weight: bold;
}
QDockWidget::title {
/* text-align: left;
background: #ccc;
padding: 1px; */
text-align: left;
background: #666;
padding: 1px;
font-weight: bold;
}
QDockWidget::close-button, QDockWidget::float-button {
}
/* QDockWidget::title:hover {
background: #bbb;
}*/
)";
a.setStyleSheet(str);

View File

@@ -37,7 +37,7 @@ void MV2DElementFloorObstacleDoor::paint(Painter& p) {
// }
QPen pen;
pen.setColor(QColor(0.5,0.5,0.5));
pen.setColor(QColor(255,0,0));
pen.setStyle(Qt::PenStyle::DotLine);
p.setPenBrush(pen, Qt::NoBrush);

View File

@@ -7,6 +7,22 @@
#include <Indoor/floorplan/v2/Floorplan.h>
#include <stdio.h>
float getPosOnLine(const Floorplan::FloorObstacleWall* wall, const Point2 pos) {
Point2 perp = (wall->from - wall->to).perpendicular() * 100;
Line2 l1(pos-perp, pos+perp);
Line2 l2(wall->from, wall->to);
Point2 p;
float u = 0;
bool isects = intersects(l2, l1, true, p, &u);
if (u < 0.01) {u = 0.01;}
if (u > 0.99) {u = 0.99;}
return (isects) ? (u) : (NAN);
}
void drawDoorSwing(const Floorplan::FloorObstacleWall* wall, const Floorplan::FloorObstacleWallDoor* door, Painter& p, QPen& pen) {
@@ -126,8 +142,15 @@ ClickDist MV2DElementFloorObstacleWall::getMinDistanceXY(const Point2 p) const {
void MV2DElementFloorObstacleWall::mousePressed(MapView2D* v, const Point2 p) {
(void) v;
this->mouseNearLine = getPosOnLine(fo, p);
}
void MV2DElementFloorObstacleWall::paint(Painter& p) {
// convert wall's thickness from meter to pixels
const float thickness_px = p.s.ms(fo->thickness_m);
@@ -157,7 +180,7 @@ void MV2DElementFloorObstacleWall::paint(Painter& p) {
pts.push_back(fo->to);
auto comp = [&] (const Point2 p1, const Point2 p2) {
return pts.front().getDistance(p1) < pts.front().getDistance(p2);
return fo->from.getDistance(p1) < fo->from.getDistance(p2);
};
std::sort(pts.begin(), pts.end(), comp);
@@ -197,7 +220,14 @@ void MV2DElementFloorObstacleWall::paint(Painter& p) {
// obstacle length
p.setPenBrush(Qt::black, Qt::NoBrush);
p.drawLength(fo->from, fo->to, fo->from.getDistance(fo->to), thickness_px/2);
//p.drawLength(fo->from, fo->to, fo->from.getDistance(fo->to), thickness_px/2);
for (size_t i = 0; i < pts.size(); i+=1) {
const Point2 p1 = pts[i];
const Point2 p2 = pts[i+1];
const float len = p2.getDistance(p1);
p.drawLength(p1, p2, len, thickness_px/2);
}
}
@@ -245,21 +275,23 @@ void MV2DElementFloorObstacleWall::onNodeMove(MapView2D* v, const int userIdx, c
if (userIdx == 0) {fo->from.x = newPos.x; fo->from.y = newPos.y;}
if (userIdx == 1) {fo->to.x = newPos.x; fo->to.y = newPos.y;}
Point2 perp = (fo->from - fo->to).perpendicular() * 100;
Line2 l1(newPos-perp, newPos+perp);
Line2 l2(fo->from, fo->to);
// Point2 perp = (fo->from - fo->to).perpendicular() * 100;
// Line2 l1(newPos-perp, newPos+perp);
// Line2 l2(fo->from, fo->to);
Point2 p;
float u = 0;
bool isects = intersects(l2, l1, true, p, &u);
if (u < 0.01) {u = 0.01;}
if (u > 0.99) {u = 0.99;}
// Point2 p;
// float u = 0;
// bool isects = intersects(l2, l1, true, p, &u);
// if (u < 0.01) {u = 0.01;}
// if (u > 0.99) {u = 0.99;}
const float u = getPosOnLine(fo, newPos);
if (userIdx >= 1000 && userIdx < 2000) {
Floorplan::FloorObstacleWallDoor* door = fo->doors[userIdx-1000];
if (isects) {
if (!std::isnan(u)) {
door->atLinePos = u;
}
@@ -267,7 +299,7 @@ void MV2DElementFloorObstacleWall::onNodeMove(MapView2D* v, const int userIdx, c
Floorplan::FloorObstacleWallWindow* win = fo->windows[userIdx-2000];
if (isects) {
if (!std::isnan(u)) {
win->atLinePos = u;
}
@@ -285,7 +317,10 @@ void MV2DElementFloorObstacleWall::onNodeMoved(MapView2D* v, const int userIdx,
bool MV2DElementFloorObstacleWall::keyPressEvent(MapView2D* v, QKeyEvent* e) {
if (e->key() == Qt::Key_D) {
Floorplan::FloorObstacleWallDoor* door = new Floorplan::FloorObstacleWallDoor(Floorplan::DoorType::SWING, Floorplan::Material::WOOD, 0.5, 1.0, 2.1);
const float doorWidth = 0.9;
const float doorHeight = 2.1;
const float doorAt = std::isnan(mouseNearLine) ? (0.5) : (mouseNearLine);
Floorplan::FloorObstacleWallDoor* door = new Floorplan::FloorObstacleWallDoor(Floorplan::DoorType::SWING, Floorplan::Material::WOOD, doorAt, doorWidth, doorHeight);
fo->doors.push_back(door);
return true;
} else if (e->key() == Qt::Key_W) {

View File

@@ -14,6 +14,8 @@ private:
Floorplan::Floor* f;
Floorplan::FloorObstacleWall* fo;
float mouseNearLine = NAN;
public:
/** ctor */
@@ -40,6 +42,8 @@ public:
bool keyPressEvent(MapView2D* v, QKeyEvent* e) override;
void mousePressed(MapView2D* v, const Point2 p) override;
};
#endif // MV2DELEMENTFLOOROBSTACLEWALL_H

View File

@@ -154,7 +154,7 @@ void Painter::drawImage(const Point2 pt, const QImage& img) {
void Painter::drawLength(Point2 p1, Point2 p2, const float len, const float offset) {
if (p1.x < p2.x) {swap(p1, p2);}
const Point2 center_m = (p1 + p2) / 2;
const Point2 center_m = (p1 + p2) / 2 - Point2(0.5,0);
Point2 dir_px = (p2 - p1).perpendicular().normalized() * (5+offset);
if (dir_px.x <= 0) {dir_px = -dir_px;}
const Point2 pos_m = center_m + dir_px / getScaler().getScale();

View File

@@ -331,6 +331,8 @@ void MapView3D::draw() {
static RenderSettings rs = RenderSettings(new Shader(), this);
const Point3 c = center - floorplanRendererModel->getBBox().getCenter();
// view
QMatrix4x4 V;
@@ -339,7 +341,7 @@ void MapView3D::draw() {
V.rotate(rot.x, 1.0, 0.0, 0.0);
V.rotate(rot.y, 0.0, 1.0, 0.0);
V.rotate(rot.z, 0.0, 0.0, 1.0);
V.translate(center.x, center.y, center.z);
V.translate(c.x, c.y, c.z);
float farPlane = 200; // TODO

View File

@@ -70,6 +70,10 @@ Floorplan3D::FloorplanMesh& FloorplanRendererModel::getMesh() {
return mesh;
}
BBox3 FloorplanRendererModel::getBBox() const {
return bbox;
}
const RenderTriangle& FloorplanRendererModel::getTriaSolid() {
return triaSolid;
}
@@ -106,6 +110,10 @@ void FloorplanRendererModel::rebuild(Floorplan::IndoorMap* im) {
}
}
}
// update bbox
bbox = mesh.getBBox();
}
catch(const std::exception& e) {
std::cout << "Can't create 3D view. Failed to get mesh from model factory with error: '" << e.what() << "'" << std::endl;

View File

@@ -19,6 +19,8 @@ private:
RenderTriangle triaSolid;
RenderTriangle triaTransp;
BBox3 bbox;
int getMaterial(const Floorplan3D::Obstacle3D& o) const;
@@ -31,6 +33,8 @@ public:
Floorplan3D::FloorplanMesh& getMesh();
BBox3 getBBox() const;
const RenderTriangle& getTriaSolid();
const RenderTriangle& getTriaTransp();

View File

@@ -0,0 +1,31 @@
#ifndef EELEMENTPARAMS_H
#define EELEMENTPARAMS_H
#include <vector>
#include <string>
static inline std::vector<std::string> getDoorTypeStrings() {
return {
"unknown", "swing", "double swing", "slide", "double slide", "revolving"
};
}
static inline std::vector<std::string> getMaterialStrings() {
return {
"Unknown", "Concrete", "Wood", "Drywall", "Glass", "Metal", "Glass (metallized)"
};
}
static inline std::vector<std::string> getObstacleTypeStrings() {
return {
"unknown", "wall", "window", "handrail", "pillar",
};
}
static inline std::vector<std::string> getOutlineMethodStrings() {
return {
"add", "remove"
};
}
#endif // EELEMENTPARAMS_H

View File

@@ -1,16 +0,0 @@
#ifndef IHASDOORTYPE_H
#define IHASDOORTYPE_H
#include <Indoor/floorplan/v2/Floorplan.h>
class IHasDoorType {
public:
virtual void setDoorType(const Floorplan::DoorType t) = 0;
virtual Floorplan::DoorType getDoorType() const = 0;
};
#endif // IHASDOORTYPE_H

View File

@@ -1,17 +0,0 @@
#ifndef IHASFILE_H
#define IHASFILE_H
//#include <string>
//class IHasFile {
//public:
// virtual void setFileName(const std::string& file) = 0;
// virtual const std::string& getFileName() const = 0;
//};
#endif // IHASFILE_H

View File

@@ -1,15 +0,0 @@
#ifndef IHASMATERIAL_H
#define IHASMATERIAL_H
#include <Indoor/floorplan/v2/Floorplan.h>
class IHasMaterial {
public:
virtual void setMaterial(const Floorplan::Material m) = 0;
virtual Floorplan::Material getMaterial() const = 0;
};
#endif // IHASMATERIAL_H

View File

@@ -1,16 +0,0 @@
#ifndef IHASOBSTACLETYPE_H
#define IHASOBSTACLETYPE_H
#include <Indoor/floorplan/v2/Floorplan.h>
class IHasObstacleType {
public:
virtual void setObstacleType(const Floorplan::ObstacleType t) = 0;
virtual Floorplan::ObstacleType getObatcleType() const = 0;
};
#endif // IHASOBSTACLETYPE_H

View File

@@ -5,8 +5,7 @@
#include "MapModelElement.h"
#include "../2D/MapViewElementHelper.h"
#include "IHasMaterial.h"
#include "IHasObstacleType.h"
#include "EElementParams.h"
#include "IHasParams.h"
@@ -15,7 +14,7 @@
#include <Indoor/floorplan/v2/Floorplan.h>
class MMFloorObstacleCircle : public MapModelElement, public IHasMaterial, public IHasParams {
class MMFloorObstacleCircle : public MapModelElement, public IHasParams {
private:
@@ -30,8 +29,8 @@ public:
}
void setMaterial(const Floorplan::Material m) override {c->material = m;}
Floorplan::Material getMaterial() const override {return c->material;}
// 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;}
@@ -45,7 +44,7 @@ public:
/** get the number of parameters */
int getNumParams() const override {
return 2;
return 3;
}
/** get the description of the idx-th parameter */
@@ -53,6 +52,7 @@ public:
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");
}
}
@@ -62,6 +62,7 @@ public:
switch(idx) {
case 0: return c->radius;
case 1: return c->height;
case 2: return (int) c->material;
default: throw Exception("out of bounds");
}
}
@@ -71,6 +72,7 @@ public:
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");
}
}

View File

@@ -4,8 +4,7 @@
#include "MapModelElement.h"
#include "../2D/MapViewElementHelper.h"
#include "IHasMaterial.h"
#include "IHasDoorType.h"
#include "EElementParams.h"
#include "IHasParams.h"
#include "../2D/MV2DElementFloorObstacleDoor.h"
@@ -14,7 +13,8 @@
#include <Indoor/floorplan/v2/Floorplan.h>
class MMFloorObstacleDoor : public MapModelElement, public IHasMaterial, public IHasDoorType, public IHasParams {
class MMFloorObstacleDoor : public MapModelElement, public IHasParams {
public:
@@ -30,11 +30,11 @@ public:
}
void setMaterial(const Floorplan::Material m) override {fo->material = m;}
Floorplan::Material getMaterial() const override {return fo->material;}
// 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;}
// 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;}
@@ -46,7 +46,7 @@ public:
/** get the number of parameters */
int getNumParams() const override {
return 4;
return 5;
}
/** get the description of the idx-th parameter */
@@ -55,7 +55,8 @@ public:
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"});
case 3: return Param("type", ParamType::ENUM, getDoorTypeStrings());
case 4: return Param("material", ParamType::ENUM, getMaterialStrings());
default: throw Exception("out of bounds");
}
}
@@ -67,6 +68,7 @@ public:
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");
}
}
@@ -78,6 +80,7 @@ public:
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");
}
}

View File

@@ -4,8 +4,7 @@
#include "MapModelElement.h"
#include "../2D/MapViewElementHelper.h"
#include "IHasMaterial.h"
#include "IHasObstacleType.h"
#include "EElementParams.h"
#include "IHasParams.h"
#include "../2D/MV2DElementFloorObstacleLine.h"
@@ -13,7 +12,7 @@
#include <Indoor/floorplan/v2/Floorplan.h>
class MMFloorObstacleLine : public MapModelElement, public IHasMaterial, public IHasObstacleType, public IHasParams {
class MMFloorObstacleLine : public MapModelElement, public IHasParams {
public:
@@ -28,11 +27,11 @@ public:
;
}
void setMaterial(const Floorplan::Material m) override {fo->material = m;}
Floorplan::Material getMaterial() const override {return fo->material;}
// void setMaterial(const Floorplan::Material m) override {fo->material = m;}
// Floorplan::Material getMaterial() const override {return fo->material;}
void setObstacleType(const Floorplan::ObstacleType t) override {fo->type = t;}
Floorplan::ObstacleType getObatcleType() const override {return fo->type;}
// void setObstacleType(const Floorplan::ObstacleType t) override {fo->type = t;}
// Floorplan::ObstacleType getObatcleType() const override {return fo->type;}
MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;}
@@ -42,7 +41,7 @@ public:
}
int getNumParams() const override {
return 3;
return 5;
}
virtual Param getParamDesc(const int idx) const override {
@@ -50,6 +49,8 @@ public:
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 3: return Param("material", ParamType::ENUM, getMaterialStrings());
case 4: return Param("type", ParamType::ENUM, getObstacleTypeStrings());
}
throw 1;
}
@@ -59,6 +60,8 @@ public:
case 0: return fo->thickness_m;
case 1: return fo->height_m;
case 2: return fo->from.getDistance(fo->to);
case 3: return (int) fo->material;
case 4: return (int) fo->type;
}
throw 1;
}
@@ -68,6 +71,8 @@ public:
case 0: fo->thickness_m = val.toFloat(); return;
case 1: fo->height_m = val.toFloat(); return;
case 2: return;
case 3: fo->material = (Floorplan::Material) val.toInt(); return;
case 4: fo->type = (Floorplan::ObstacleType) val.toInt(); return;
}
}
};

View File

@@ -5,8 +5,7 @@
#include "MapModelElement.h"
#include "../2D/MapViewElementHelper.h"
#include "IHasMaterial.h"
#include "IHasDoorType.h"
#include "EElementParams.h"
#include "IHasParams.h"
#include "../2D/MV2DElementFloorObstacleObject.h"

View File

@@ -5,15 +5,14 @@
#include "MapModelElement.h"
#include "../2D/MapViewElementHelper.h"
#include "IHasMaterial.h"
#include "IHasObstacleType.h"
#include "EElementParams.h"
#include "IHasParams.h"
#include "../2D/MV2DElementFloorObstacleWall.h"
#include <Indoor/floorplan/v2/Floorplan.h>
class MMFloorObstacleWall : public MapModelElement, public IHasMaterial, public IHasObstacleType, public IHasParams {
class MMFloorObstacleWall : public MapModelElement, public IHasParams {
public:
@@ -28,11 +27,11 @@ public:
;
}
void setMaterial(const Floorplan::Material m) override {wall->material = m;}
Floorplan::Material getMaterial() const override {return wall->material;}
// 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;}
// 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;}
@@ -60,7 +59,7 @@ public:
int getNumParams() const override {
switch(getType()) {
case 0: return 3;
case 0: return 5;
case 1: return 4;
case 2: return 4;
}
@@ -70,9 +69,11 @@ public:
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 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);
@@ -93,9 +94,11 @@ public:
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 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;
@@ -116,9 +119,11 @@ public:
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 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;

View File

@@ -8,6 +8,7 @@
#include <Indoor/floorplan/v2/Floorplan.h>
#include "EElementParams.h"
/**
* describes one polygon within a floor's outline
@@ -31,20 +32,21 @@ public:
Floorplan::FloorOutlinePolygon* getPolygon() {return fo;}
Floorplan::OutlineMethod getMethod() const {return fo->method;}
void setMethod(const Floorplan::OutlineMethod m) {this->fo->method = m;}
// Floorplan::OutlineMethod getMethod() const {return fo->method;}
// void setMethod(const Floorplan::OutlineMethod m) {this->fo->method = m;}
MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;}
//MV3DElement* getMV3D() const override {return (MV3DElement*) &mv3d;}
virtual int getNumParams() const override {
return 2;
return 3;
}
virtual Param getParamDesc(const int idx) const override {
switch(idx) {
case 0: return Param("name", ParamType::STRING);
case 1: return Param("outdoor", ParamType::BOOL);
case 1: return Param("method", ParamType::ENUM, getOutlineMethodStrings());
case 2: return Param("outdoor", ParamType::BOOL);
}
throw 1;
}
@@ -52,7 +54,8 @@ public:
virtual ParamValue getParamValue(const int idx) const override {
switch(idx) {
case 0: return fo->name;
case 1: return fo->outdoor;
case 1: return (int) fo->method;
case 2: return fo->outdoor;
}
throw 1;
}
@@ -60,7 +63,8 @@ public:
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch(idx) {
case 0: fo->name = val.toString(); break;
case 1: fo->outdoor = val.toBool(); break;
case 1: fo->method = (Floorplan::OutlineMethod) val.toInt(); break;
case 2: fo->outdoor = val.toBool(); break;
}
}

View File

@@ -22,52 +22,52 @@
#include <QFileDialog>
#include <QCheckBox>
QComboBox* getMaterials() {
using namespace Floorplan;
QComboBox* cmbMaterial = new QComboBox();
for (int i = 0; i < (int)Material::_END; ++i) {
switch ((Material)i) {
case Material::CONCRETE: cmbMaterial->addItem("Concrete", i); break;
case Material::UNKNOWN: cmbMaterial->addItem("Unknown ", i); break;
case Material::DRYWALL: cmbMaterial->addItem("Drywall", i); break;
case Material::WOOD: cmbMaterial->addItem("Wood", i); break;
case Material::GLASS: cmbMaterial->addItem("Glass", i); break;
case Material::METAL: cmbMaterial->addItem("Metal", i); break;
case Material::METALLIZED_GLAS: cmbMaterial->addItem("Glass (metallized)", i); break;
case Material::_END: throw 1;
}
}
return cmbMaterial;
}
//QComboBox* getMaterials() {
// using namespace Floorplan;
// QComboBox* cmbMaterial = new QComboBox();
// for (int i = 0; i < (int)Material::_END; ++i) {
// switch ((Material)i) {
// case Material::CONCRETE: cmbMaterial->addItem("Concrete", i); break;
// case Material::UNKNOWN: cmbMaterial->addItem("Unknown ", i); break;
// case Material::DRYWALL: cmbMaterial->addItem("Drywall", i); break;
// case Material::WOOD: cmbMaterial->addItem("Wood", i); break;
// case Material::GLASS: cmbMaterial->addItem("Glass", i); break;
// case Material::METAL: cmbMaterial->addItem("Metal", i); break;
// case Material::METALLIZED_GLAS: cmbMaterial->addItem("Glass (metallized)", i); break;
// case Material::_END: throw 1;
// }
// }
// return cmbMaterial;
//}
QComboBox* getObstacleTypes() {
using namespace Floorplan;
QComboBox* cmb = new QComboBox();
for (int i = 0; i < (int)ObstacleType::_END; ++i) {
switch ((ObstacleType)i) {
case ObstacleType::UNKNOWN: cmb->addItem("Unknown ", i); break;
case ObstacleType::WALL: cmb->addItem("Wall", i); break;
case ObstacleType::WINDOW: cmb->addItem("Window", i); break;
case ObstacleType::HANDRAIL:cmb->addItem("Handrail", i); break;
case ObstacleType::PILLAR: cmb->addItem("Pillar", i); break;
case ObstacleType::_END: throw 1;
}
}
return cmb;
}
//QComboBox* getObstacleTypes() {
// using namespace Floorplan;
// QComboBox* cmb = new QComboBox();
// for (int i = 0; i < (int)ObstacleType::_END; ++i) {
// switch ((ObstacleType)i) {
// case ObstacleType::UNKNOWN: cmb->addItem("Unknown ", i); break;
// case ObstacleType::WALL: cmb->addItem("Wall", i); break;
// case ObstacleType::WINDOW: cmb->addItem("Window", i); break;
// case ObstacleType::HANDRAIL:cmb->addItem("Handrail", i); break;
// case ObstacleType::PILLAR: cmb->addItem("Pillar", i); break;
// case ObstacleType::_END: throw 1;
// }
// }
// return cmb;
//}
QComboBox* getOutlineMethods() {
using namespace Floorplan;
QComboBox* cmb = new QComboBox();
for (int i = 0; i < (int)OutlineMethod::_END; ++i) {
switch ((OutlineMethod)i) {
case OutlineMethod::ADD: cmb->addItem("add", i); break;
case OutlineMethod::REMOVE: cmb->addItem("remove ", i); break;
case OutlineMethod::_END: throw 1;
}
}
return cmb;
}
//QComboBox* getOutlineMethods() {
// using namespace Floorplan;
// QComboBox* cmb = new QComboBox();
// for (int i = 0; i < (int)OutlineMethod::_END; ++i) {
// switch ((OutlineMethod)i) {
// case OutlineMethod::ADD: cmb->addItem("add", i); break;
// case OutlineMethod::REMOVE: cmb->addItem("remove ", i); break;
// case OutlineMethod::_END: throw 1;
// }
// }
// return cmb;
//}
ElementParamWidget::ElementParamWidget(QWidget *parent) : QWidget(parent) {
@@ -104,50 +104,50 @@ void ElementParamWidget::refresh() {
MapModelElement* el = this->curElement;
// material? -> select in combo-box
{
IHasMaterial* elem = dynamic_cast<IHasMaterial*>(el);
if (elem) {
material.cmb = getMaterials();
material.lbl = new QLabel("material", this);
lay->addWidget(material.lbl,r,0);
lay->addWidget(material.cmb,r,1);
connect(material.cmb , SIGNAL(currentIndexChanged(int)), this, SLOT(onMaterialChange()));
material.cmb->setCurrentIndex((int)elem->getMaterial());
++r;
}
}
// // material? -> select in combo-box
// {
// IHasMaterial* elem = dynamic_cast<IHasMaterial*>(el);
// if (elem) {
// material.cmb = getMaterials();
// material.lbl = new QLabel("material", this);
// lay->addWidget(material.lbl,r,0);
// lay->addWidget(material.cmb,r,1);
// connect(material.cmb , SIGNAL(currentIndexChanged(int)), this, SLOT(onMaterialChange()));
// material.cmb->setCurrentIndex((int)elem->getMaterial());
// ++r;
// }
// }
// obstacle-type? -> select in combo-box
{
IHasObstacleType* elem = dynamic_cast<IHasObstacleType*>(el);
if (elem) {
obstacleType.cmb = getObstacleTypes();
obstacleType.lbl = new QLabel("type", this);
lay->addWidget(obstacleType.lbl,r,0);
lay->addWidget(obstacleType.cmb,r,1);
connect(obstacleType.cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(onObstacleTypeChange()));
obstacleType.cmb->setCurrentIndex((int)elem->getObatcleType());
++r;
}
}
// // obstacle-type? -> select in combo-box
// {
// IHasObstacleType* elem = dynamic_cast<IHasObstacleType*>(el);
// if (elem) {
// obstacleType.cmb = getObstacleTypes();
// obstacleType.lbl = new QLabel("type", this);
// lay->addWidget(obstacleType.lbl,r,0);
// lay->addWidget(obstacleType.cmb,r,1);
// connect(obstacleType.cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(onObstacleTypeChange()));
// obstacleType.cmb->setCurrentIndex((int)elem->getObatcleType());
// ++r;
// }
// }
// has outline method?
{
MMFloorOutlinePolygon* elem = dynamic_cast<MMFloorOutlinePolygon*>(el);
if (elem) {
QComboBox* cmb = getOutlineMethods();
QLabel* lbl = new QLabel("outline", this);
lay->addWidget(lbl,r,0);
lay->addWidget(cmb,r,1);
cmb->setCurrentIndex((int)elem->getMethod());
connect(cmb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [elem, cmb] (int idx) {
(void) idx;
elem->setMethod( (Floorplan::OutlineMethod) cmb->currentData().toInt() );
});
++r;
}
}
// // has outline method?
// {
// MMFloorOutlinePolygon* elem = dynamic_cast<MMFloorOutlinePolygon*>(el);
// if (elem) {
// QComboBox* cmb = getOutlineMethods();
// QLabel* lbl = new QLabel("outline", this);
// lay->addWidget(lbl,r,0);
// lay->addWidget(cmb,r,1);
// cmb->setCurrentIndex((int)elem->getMethod());
// connect(cmb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [elem, cmb] (int idx) {
// (void) idx;
// elem->setMethod( (Floorplan::OutlineMethod) cmb->currentData().toInt() );
// });
// ++r;
// }
// }
{ // does the element have "parameters" ?
IHasParams* elem = dynamic_cast<IHasParams*>(el);
@@ -185,14 +185,3 @@ void ElementParamWidget::refresh() {
}
void ElementParamWidget::onMaterialChange() {
IHasMaterial* el = dynamic_cast<IHasMaterial*>(this->curElement);
if (el) {el->setMaterial( (Floorplan::Material) material.cmb->currentData().toInt() );}
}
void ElementParamWidget::onObstacleTypeChange() {
IHasObstacleType* el = dynamic_cast<IHasObstacleType*>(this->curElement);
if (el) {el->setObstacleType((Floorplan::ObstacleType) obstacleType.cmb->currentData().toInt() );}
}

View File

@@ -51,8 +51,8 @@ public slots:
private slots:
void onMaterialChange();
void onObstacleTypeChange();
//void onMaterialChange();
//void onObstacleTypeChange();
};