added support for pillars
minor fixes new 3D models
This commit is contained in:
@@ -32,8 +32,6 @@ public:
|
||||
return MapElementHelper::getLineDistanceXY(fo->from, fo->to, p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** repaint me */
|
||||
void paint(Painter& p) override {
|
||||
|
||||
@@ -58,7 +56,6 @@ public:
|
||||
// reset the old pen
|
||||
p.setPen(pen);
|
||||
|
||||
|
||||
// available endpoints
|
||||
if (hasFocus()) {
|
||||
|
||||
@@ -76,38 +73,8 @@ public:
|
||||
p.drawCircle_px(fo->to, 3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// void paintDoor(Painter& p) {
|
||||
|
||||
// QPen pen;
|
||||
// pen.setColor(QColor(0.5,0.5,0.5));
|
||||
// pen.setStyle(Qt::PenStyle::DotLine);
|
||||
// p.setPenBrush(pen, Qt::NoBrush);
|
||||
|
||||
|
||||
// // opening indicator
|
||||
// const float open = M_PI / 4;
|
||||
// const float len = (fo->to - fo->from).length();
|
||||
// const float angle1 = std::atan2(fo->to.y-fo->from.y, fo->to.x-fo->from.x);
|
||||
// const float angle2 = angle1 + open;
|
||||
// const Point2 pOpen = Point2( std::cos(angle2) * len, std::sin(angle2) * len ) + fo->from;
|
||||
|
||||
// p.drawLine(fo->from, fo->to);
|
||||
// p.drawLine(fo->from, pOpen);
|
||||
|
||||
// p.drawArc(fo->from, len, angle1, open);
|
||||
// //p.drawLine(fo->to, pOpen);
|
||||
|
||||
// // obstacle length
|
||||
// p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
// p.drawLength(fo->from, fo->to, fo->from.getDistance(fo->to));
|
||||
|
||||
// }
|
||||
|
||||
void onFocus() override {
|
||||
;
|
||||
}
|
||||
@@ -135,7 +102,6 @@ public:
|
||||
emit v->onElementChange(this);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // MV2DELEMENTFLOOROBSTACLELINE_H
|
||||
|
||||
@@ -77,12 +77,13 @@ public:
|
||||
pen.setCapStyle(Qt::FlatCap);
|
||||
|
||||
if (focus) {pen.setColor(Qt::black);}
|
||||
if (mat == Material::CONCRETE) {;}
|
||||
if (mat == Material::GLASS) {pen.setStyle(Qt::PenStyle::DotLine);}
|
||||
if (mat == Material::METAL) {pen.setColor(QColor(50, 50, 50));}
|
||||
if (type == ObstacleType::HANDRAIL) {pen.setStyle(Qt::PenStyle::DashLine);}
|
||||
if (type == ObstacleType::UNKNOWN) {pen.setColor(Qt::red);}
|
||||
if (type == ObstacleType::PILLAR) {pen.setColor(Qt::red);}
|
||||
if (mat == Material::CONCRETE) {;}
|
||||
if (mat == Material::GLASS) {pen.setStyle(Qt::PenStyle::DotLine);}
|
||||
if (mat == Material::METALLIZED_GLAS) {pen.setStyle(Qt::PenStyle::DotLine);}
|
||||
if (mat == Material::METAL) {pen.setColor(QColor(50, 50, 50));}
|
||||
if (type == ObstacleType::HANDRAIL) {pen.setStyle(Qt::PenStyle::DashLine);}
|
||||
if (type == ObstacleType::UNKNOWN) {pen.setColor(Qt::red);}
|
||||
if (type == ObstacleType::PILLAR) {pen.setColor(Qt::red);}
|
||||
|
||||
return pen;
|
||||
}
|
||||
|
||||
47
mapview/2D/tools/ToolNewPillar.h
Normal file
47
mapview/2D/tools/ToolNewPillar.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef TOOLNEWPILLAR_H
|
||||
#define TOOLNEWPILLAR_H
|
||||
|
||||
#include "ToolNewElement.h"
|
||||
#include "../../model/MMFloorObstacles.h"
|
||||
#include "../../model/MMFloorObstacleCircle.h"
|
||||
|
||||
class ToolNewPillar : public ToolNewElement<Floorplan::FloorObstacleCircle, MMFloorObstacleCircle> {
|
||||
|
||||
public:
|
||||
|
||||
ToolNewPillar(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
|
||||
;
|
||||
}
|
||||
|
||||
void becomesActive() override {
|
||||
emit onHelpTextChange("left-click where to place a new pillar. right-click to end.");
|
||||
}
|
||||
|
||||
void becomesInactive() override {
|
||||
;
|
||||
}
|
||||
|
||||
const std::string getName() const override {
|
||||
return "new Pillar";
|
||||
}
|
||||
|
||||
void moving(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
}
|
||||
|
||||
void leftMouse(const Point2 mapPoint) override {
|
||||
const Floorplan::Material mat = Floorplan::Material::CONCRETE; // default material
|
||||
foEL = new Floorplan::FloorObstacleCircle(mat, mapPoint.x, mapPoint.y, 0.2);//"", Point3(mapPoint.x, mapPoint.y, 0.0), Point3(0,0,0));
|
||||
MMFloorObstacles* obs = (MMFloorObstacles*)layer;
|
||||
mmEL = obs->createCircle(foEL);
|
||||
}
|
||||
|
||||
void rightMouse(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
finalizeCurrent();
|
||||
disableMe();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // TOOLNEWPILLAR_H
|
||||
@@ -113,12 +113,13 @@ MapView3D::MapView3D(QWidget *parent) : QOpenGLWidget(parent) {
|
||||
|
||||
auto format = QSurfaceFormat();
|
||||
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
format.setVersion(3, 4);
|
||||
//format.setVersion(3, 4);
|
||||
//format.setSamples(2);
|
||||
//format.setProfile(QSurfaceFormat::CompatibilityProfile);
|
||||
//format.setOption(QSurfaceFormat::DebugContext);
|
||||
format.setSamples(2);
|
||||
format.setProfile(QSurfaceFormat::CompatibilityProfile);
|
||||
format.setOption(QSurfaceFormat::DebugContext);
|
||||
|
||||
setFormat(format);
|
||||
setFormat(format);
|
||||
|
||||
auto ver = format.version();
|
||||
std::cout << "OpenGL Context Version: " << ver.first << "." << ver.second << std::endl;
|
||||
|
||||
@@ -38,11 +38,14 @@ private:
|
||||
Material(140,140,140,255), // door (wood)
|
||||
|
||||
Material(128,128,128,255), // concrete
|
||||
Material(200,200,255,96), // glass
|
||||
Material(240,240,255,96), // glass
|
||||
Material(170,170,255,96), // glass (metallized)
|
||||
Material(170,120,60,255), // wood
|
||||
Material(200,200,200,255), // drywall
|
||||
|
||||
Material(255,255,255,255), // default
|
||||
Material(255,255,255,255), // object
|
||||
|
||||
Material(235,235,235,255), // default
|
||||
|
||||
};
|
||||
|
||||
@@ -52,16 +55,19 @@ private:
|
||||
if (o.type == Ray3D::Obstacle3D::Type::GROUND_INDOOR) {return 1;}
|
||||
if (o.type == Ray3D::Obstacle3D::Type::STAIR) {return 2;}
|
||||
if (o.type == Ray3D::Obstacle3D::Type::HANDRAIL) {return 3;}
|
||||
if (o.type == Ray3D::Obstacle3D::Type::OBJECT) {return 11;}
|
||||
|
||||
if (o.type == Ray3D::Obstacle3D::Type::DOOR && o.mat == Floorplan::Material::GLASS) {return 4;}
|
||||
if (o.type == Ray3D::Obstacle3D::Type::DOOR) {return 5;}
|
||||
|
||||
if (o.mat == Floorplan::Material::CONCRETE) {return 6;}
|
||||
if (o.mat == Floorplan::Material::GLASS) {return 7;}
|
||||
if (o.mat == Floorplan::Material::WOOD) {return 8;}
|
||||
if (o.mat == Floorplan::Material::DRYWALL) {return 9;}
|
||||
if (o.mat == Floorplan::Material::METALLIZED_GLAS) {return 8;}
|
||||
|
||||
return 10;
|
||||
if (o.mat == Floorplan::Material::WOOD) {return 9;}
|
||||
if (o.mat == Floorplan::Material::DRYWALL) {return 10;}
|
||||
|
||||
return 12;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ QNavMeshSettings::QNavMeshSettings(NM::NavMeshSettings* settings, QWidget* paren
|
||||
lay->addWidget(new QLabel("min region size"), row, 0);
|
||||
QLabel* lblMinRegionSize = new QLabel("");
|
||||
lay->addWidget(lblMinRegionSize, row, 2);
|
||||
QSlider* sldRegionMinSize = new QSlider(Qt::Orientation::Horizontal); sldRegionMinSize->setMinimum(400); sldRegionMinSize->setMaximum(10000);
|
||||
QSlider* sldRegionMinSize = new QSlider(Qt::Orientation::Horizontal); sldRegionMinSize->setMinimum(400); sldRegionMinSize->setMaximum(99900);
|
||||
connect(sldRegionMinSize, &QSlider::valueChanged, [settings, sldRegionMinSize, lblMinRegionSize] () {
|
||||
settings->regionMinSize = sldRegionMinSize->value() / 100.0f;
|
||||
lblMinRegionSize->setText(QString("%1 m").arg(settings->regionMinSize, 5, 'f', 2, 0));
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
#include "IHasMaterial.h"
|
||||
#include "IHasObstacleType.h"
|
||||
|
||||
#include "IHasParams.h"
|
||||
|
||||
#include "../2D/MV2DElementFloorObstacleCircle.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
|
||||
class MMFloorObstacleCircle : public MapModelElement, public IHasMaterial {
|
||||
class MMFloorObstacleCircle : public MapModelElement, public IHasMaterial, public IHasParams {
|
||||
|
||||
private:
|
||||
|
||||
@@ -41,6 +43,38 @@ public:
|
||||
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 2;
|
||||
}
|
||||
|
||||
/** 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);
|
||||
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;
|
||||
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;
|
||||
default: throw Exception("out of bounds");
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // MAPMODELELEMENTFLOOROBSTACLECIRCLE_H
|
||||
|
||||
@@ -77,13 +77,15 @@ public:
|
||||
}
|
||||
|
||||
//TODO: check
|
||||
void createCircle(Floorplan::FloorObstacleCircle* obs) {
|
||||
MMFloorObstacleCircle* createCircle(Floorplan::FloorObstacleCircle* obs) {
|
||||
|
||||
// add to underlying model
|
||||
floor->obstacles.push_back(obs);
|
||||
|
||||
// add to myself as element
|
||||
addElement(new MMFloorObstacleCircle(this, floor, obs));
|
||||
MMFloorObstacleCircle* mm = new MMFloorObstacleCircle(this, floor, obs);
|
||||
addElement(mm);
|
||||
return mm;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user