worked on windows
This commit is contained in:
@@ -78,16 +78,19 @@ void drawDoor(const Floorplan::FloorObstacleWall* line, const Floorplan::FloorOb
|
||||
|
||||
void drawWindow(const Floorplan::FloorObstacleWall* wall, const Floorplan::FloorObstacleWallWindow* win, Painter& p) {
|
||||
|
||||
QPen pen;
|
||||
pen.setColor(QColor(0.5,0.5,0.5));
|
||||
pen.setWidth(3);
|
||||
pen.setStyle(Qt::PenStyle::DotLine);
|
||||
p.setPenBrush(pen, Qt::NoBrush);
|
||||
const Point2 ps = win->getStart(wall);
|
||||
const Point2 pe = win->getEnd(wall);
|
||||
const Point2 perp = (pe-ps).perpendicular().normalized();
|
||||
|
||||
const Point2 p1 = win->getStart(wall);
|
||||
const Point2 p2 = win->getEnd(wall);
|
||||
const float s = 0.06;
|
||||
const Point2 p1 = ps - perp*s;
|
||||
const Point2 p2 = pe - perp*s;
|
||||
const Point2 p3 = pe + perp*s;
|
||||
const Point2 p4 = ps + perp*s;
|
||||
|
||||
p.drawLine(p1, p2);
|
||||
std::vector<Point2> pts = {p1, p2, p3, p4, p1};
|
||||
p.setPenBrush(QColor(0,0,0), QColor(255,255,255));
|
||||
p.drawPolygon(pts);
|
||||
|
||||
}
|
||||
|
||||
@@ -135,20 +138,30 @@ void MV2DElementFloorObstacleWall::paint(Painter& p) {
|
||||
// draw the wall itself
|
||||
|
||||
// sort all doors by position on the line
|
||||
std::vector<Floorplan::FloorObstacleWallDoor*> doors = fo->doors;
|
||||
auto comp = [] (const Floorplan::FloorObstacleWallDoor* d1, const Floorplan::FloorObstacleWallDoor* d2) {
|
||||
return d1->atLinePos < d2->atLinePos;
|
||||
};
|
||||
std::sort(doors.begin(), doors.end(), comp);
|
||||
// std::vector<Floorplan::FloorObstacleWallDoor*> doors = fo->doors;
|
||||
// auto comp = [] (const Floorplan::FloorObstacleWallDoor* d1, const Floorplan::FloorObstacleWallDoor* d2) {
|
||||
// return d1->atLinePos < d2->atLinePos;
|
||||
// };
|
||||
// std::sort(doors.begin(), doors.end(), comp);
|
||||
|
||||
std::vector<Point2> pts;
|
||||
pts.push_back(fo->from);
|
||||
for (const Floorplan::FloorObstacleWallDoor* door : doors) {
|
||||
for (const Floorplan::FloorObstacleWallDoor* door : fo->doors) {
|
||||
pts.push_back(door->getStart(fo));
|
||||
pts.push_back(door->getEnd(fo));
|
||||
}
|
||||
for (const Floorplan::FloorObstacleWallWindow* win : fo->windows) {
|
||||
pts.push_back(win->getStart(fo));
|
||||
pts.push_back(win->getEnd(fo));
|
||||
}
|
||||
pts.push_back(fo->to);
|
||||
|
||||
auto comp = [&] (const Point2 p1, const Point2 p2) {
|
||||
return pts.front().getDistance(p1) < pts.front().getDistance(p2);
|
||||
};
|
||||
std::sort(pts.begin(), pts.end(), comp);
|
||||
|
||||
|
||||
for (size_t i = 0; i < pts.size(); i+=2) {
|
||||
p.drawLine(pts[i], pts[i+1]);
|
||||
}
|
||||
@@ -276,7 +289,7 @@ bool MV2DElementFloorObstacleWall::keyPressEvent(MapView2D* v, QKeyEvent* e) {
|
||||
fo->doors.push_back(door);
|
||||
return true;
|
||||
} else if (e->key() == Qt::Key_W) {
|
||||
Floorplan::FloorObstacleWallWindow* win = new Floorplan::FloorObstacleWallWindow(Floorplan::WindowType::UNKNOWN, Floorplan::Material::WOOD, 0.5, 0.5, 1.0, 1.0);
|
||||
Floorplan::FloorObstacleWallWindow* win = new Floorplan::FloorObstacleWallWindow(Floorplan::WindowType::UNKNOWN, Floorplan::Material::WOOD, 0.5, 1, 1.0, 1.0);
|
||||
fo->windows.push_back(win);
|
||||
return true;
|
||||
} else if (e->key() == Qt::Key_Delete && getSelectedNode() >= 1000) {
|
||||
|
||||
@@ -134,14 +134,14 @@ void Painter::drawPolygon(const std::vector<Point2>& points) {
|
||||
for (const Point2 p : points) {
|
||||
vec.push_back(QPointF(s.xms(p.x), s.yms(p.y)));
|
||||
}
|
||||
p->drawPolygon(vec.data(), vec.size());
|
||||
p->drawConvexPolygon(vec.data(), vec.size());
|
||||
}
|
||||
void Painter::drawPolygon(const std::vector<Point3>& points) {
|
||||
std::vector<QPointF> vec;
|
||||
for (const Point3 p : points) {
|
||||
vec.push_back(QPointF(s.xms(p.x), s.yms(p.y)));
|
||||
}
|
||||
p->drawPolygon(vec.data(), vec.size());
|
||||
p->drawConvexPolygon(vec.data(), vec.size());
|
||||
}
|
||||
|
||||
void Painter::drawPixmap(const Point2 pt, const QPixmap& img) {
|
||||
|
||||
Reference in New Issue
Block a user