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

59
mapview/2D/ClickDist.h Normal file
View File

@@ -0,0 +1,59 @@
#ifndef CLICKDIST_H
#define CLICKDIST_H
enum class ClickDistType {
UNKNOWN,
DIRECT, // e.g. distance between cursor and an edge-point, POI, AP, Beacon, ...
CUT, // e.g. distance between cursor and an obstacle-line
};
/** describes distances between mouse-cursor and objects within the 2D view */
struct ClickDist {
/** distance in pixels */
float dst_px;
/** distance type */
ClickDistType type;
/** ctor */
ClickDist(const float dst_px, const ClickDistType type) : dst_px(dst_px), type(type) {;}
/** max-dummy */
static ClickDist max() {return ClickDist(9999999, ClickDistType::UNKNOWN);}
/** distance comparison */
bool operator < (const ClickDist o) const {
return (this->dst_px * this->mod()) < (o.dst_px * o.mod());
}
/** multiply by constant */
ClickDist operator * (const float val) const {return ClickDist(dst_px*val, type);}
// /** weighted distance comparison based on ClickDistType */
// bool compare(const ClickDist o) const {
// return ((*this)*mod()) < (o*o.mod());
// }
private:
/**
* artificially modify the distance based on the given type.
* this enhances the selection in cases of equal distance
* like a POI residing dirctly one a line
*/
float mod() const {
switch (type) {
case ClickDistType::UNKNOWN: return 1.1;
case ClickDistType::CUT: return 1.0;
case ClickDistType::DIRECT: return 0.7;
default: throw "code error";
}
}
};
#endif // CLICKDIST_H