a whole lotta work!!

- refactoring
- completely changed the tooling (adding elements)
- better re-use for more stable editing
- new elements
- ui adjustments
- LINT for stair-editing
- many more changes
This commit is contained in:
2016-08-29 19:05:46 +02:00
parent 86c76b1284
commit fa06320219
51 changed files with 880 additions and 318 deletions

View File

@@ -0,0 +1,81 @@
#ifndef MAPELEMENTHELPER_H
#define MAPELEMENTHELPER_H
#include <Indoor/geo/Point2.h>
#include <Indoor/geo/Point3.h>
#include <Indoor/geo/Line2.h>
#include <QColor>
#include <QPen>
#include <QBrush>
#include <Indoor/floorplan/v2/Floorplan.h>
/** configuration */
namespace CFG {
const float MOVE_SNAP_SIZE_M = 0.1f; // in meter (= map-space)
const int SEL_THRESHOLD_SIZE_PX = 15; // in screen-pixels (-> should depend on the current zoom)
const QColor FOCUS_COLOR = Qt::black;
const QColor UNFOCUS_COLOR = Qt::gray;
const QColor SEL_COLOR = Qt::blue;
}
/**
* contains some common helper-methods
*/
class MapElementHelper {
public:
/**
* get the minimal distance of dst to the line denoted by (p1, p2).
* this will generate line l perpendicular to (p1, p2)
* move l into dst
* and calculate the cut-point between l and (p1, p2)
*/
static float getLineDistanceXY(Point2 p1, Point2 p2, Point2 dst) {
// the line (p1, p2)
const Line2 line(p1, p2);
// 90 degree rotation L of the line (p1, p2)
const Point2 vec = (p1 - p2).perpendicular();
// the line L
const Line2 perb(dst-vec*100, dst+vec*100);
// calculate the cut betwen L and (p1,p2) (if any)
Point2 cut(0,0);
if (line.getSegmentIntersection(perb, cut)) {
// distance between cut-point and mouse
return cut.getDistance(dst);
} else {
// no cut detected
const float d1 = p1.getDistance(dst);
const float d2 = p2.getDistance(dst);
return std::min(d1, d2);
}
}
static QPen getPen(Floorplan::Material mat, Floorplan::ObstacleType type, bool focus) {
using namespace Floorplan;
QPen pen; pen.setColor(Qt::darkGray);
if (focus) {pen.setColor(Qt::black);}
if (mat == Material::CONCRETE) {pen.setWidth(3);}
if (mat == Material::GLASS) {pen.setStyle(Qt::PenStyle::DotLine);}
if (type == ObstacleType::HANDRAIL) {pen.setStyle(Qt::PenStyle::DashLine);}
if (type == ObstacleType::UNKNOWN) {pen.setColor(Qt::red); pen.setWidth(5);}
if (type == ObstacleType::PILLAR) {pen.setColor(Qt::red); pen.setWidth(5);}
return pen;
}
};
#endif // MAPELEMENTHELPER_H