new helper methods

improved elememt-selection
changed some parameters
show length for selected obstacles/doors
minor fixes
This commit is contained in:
2017-01-05 09:41:47 +01:00
parent 535e410ae9
commit 2297a76c53
17 changed files with 160 additions and 56 deletions

View File

@@ -6,6 +6,7 @@
#include "MapViewElementHelper.h"
#include <Indoor/floorplan/v2/Floorplan.h>
#include <stdio.h>
class MV2DElementFloorObstacleLine : public MV2DElement, public HasMoveableNodes {
@@ -27,7 +28,7 @@ public:
}
/** get the element's minimal distance (nearest whatsoever) to the given point */
float getMinDistanceXY(const Point2 p) const override {
ClickDist getMinDistanceXY(const Point2 p) const override {
return MapElementHelper::getLineDistanceXY(fo->from, fo->to, p);
}
@@ -60,37 +61,49 @@ public:
p.setPenBrush(Qt::black, Qt::NoBrush);
p.drawCircle(fo->from);
p.drawCircle(fo->to);
// obstacle length
p.setPenBrush(Qt::black, Qt::NoBrush);
p.drawLength(fo->from, fo->to, fo->from.getDistance(fo->to));
} else {
//p.setPenBrush(Qt::NoPen, Qt::black);
p.drawCircle(fo->from, 0.1);
p.drawCircle(fo->to, 0.1);
p.drawCircle_px(fo->from, 3);
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);
}
// 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 {
;
}