merged
This commit is contained in:
59
mapview/2D/ClickDist.h
Normal file
59
mapview/2D/ClickDist.h
Normal 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
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <Indoor/geo/BBox2.h>
|
||||
#include <Indoor/geo/Line2.h>
|
||||
|
||||
#include "ClickDist.h"
|
||||
|
||||
/**
|
||||
* represents one drawable, selectable, editable, ...
|
||||
* element shown within the MapView2D
|
||||
@@ -29,7 +31,7 @@ public:
|
||||
virtual BBox2 getBoundingBox() const = 0;
|
||||
|
||||
/** get the element's minimal distance (nearest whatsoever) to the given point */
|
||||
virtual float getMinDistanceXY(const Point2 p) const = 0;
|
||||
virtual ClickDist getMinDistanceXY(const Point2 p) const = 0;
|
||||
|
||||
/** repaint me */
|
||||
virtual void paint(Painter& p) = 0;
|
||||
|
||||
@@ -31,8 +31,8 @@ public:
|
||||
}
|
||||
|
||||
/** get the element's minimal distance (nearest whatsoever) to the given point */
|
||||
float getMinDistanceXY(const Point2 p) const override {
|
||||
return p.getDistance(ap->pos.xy());
|
||||
ClickDist getMinDistanceXY(const Point2 p) const override {
|
||||
return ClickDist(p.getDistance(ap->pos.xy()), ClickDistType::DIRECT);
|
||||
}
|
||||
|
||||
/** repaint me */
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
p.drawDot(ap->pos.xy());
|
||||
if (p.getScaler().getScale() >= 25) {
|
||||
const std::string str = ap->name + " (" + ap->name + ")";
|
||||
const std::string str = ap->name + " (" + ap->mac + ")";
|
||||
p.p->drawText(p.getScaler().xms(ap->pos.x) + 10, p.getScaler().yms(ap->pos.y) + 5, str.c_str());
|
||||
} else if (p.getScaler().getScale() >= 10) {
|
||||
const std::string str = ap->name;
|
||||
|
||||
@@ -29,8 +29,8 @@ public:
|
||||
}
|
||||
|
||||
/** get the element's minimal distance (nearest whatsoever) to the given point */
|
||||
float getMinDistanceXY(const Point2 p) const override {
|
||||
return p.getDistance(b->pos.xy());
|
||||
ClickDist getMinDistanceXY(const Point2 p) const override {
|
||||
return ClickDist(p.getDistance(b->pos.xy()), ClickDistType::DIRECT);
|
||||
}
|
||||
|
||||
/** repaint me */
|
||||
|
||||
@@ -30,11 +30,11 @@ 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 {
|
||||
// std::vector<Point2> points = elevator->getPoints().points;
|
||||
// points.push_back(elevator->center);
|
||||
// auto it minEl = std::min_element(points.begin(), points.end(),
|
||||
return p.getDistance(elevator->center);
|
||||
return ClickDist(p.getDistance(elevator->center), ClickDistType::DIRECT);
|
||||
}
|
||||
|
||||
/** repaint me */
|
||||
|
||||
@@ -27,8 +27,11 @@ public:
|
||||
}
|
||||
|
||||
/** get the element's minimal distance (nearest whatsoever) to the given point */
|
||||
float getMinDistanceXY(const Point2 p) const override {
|
||||
return std::min(p.getDistance(getSelPoints()[0]), p.getDistance(getSelPoints()[1]));
|
||||
ClickDist getMinDistanceXY(const Point2 p) const override {
|
||||
const ClickDist d1(p.getDistance(getSelPoints()[0]), ClickDistType::DIRECT);
|
||||
const ClickDist d2(p.getDistance(getSelPoints()[1]), ClickDistType::DIRECT);
|
||||
return std::min(d1, d2);
|
||||
//return std::min(p.getDistance(getSelPoints()[0]), p.getDistance(getSelPoints()[1]));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,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);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,12 @@ public:
|
||||
p.drawCircle(fo->to);
|
||||
}
|
||||
|
||||
// obstacle length
|
||||
if (hasFocus()) {
|
||||
p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
p.drawLength(fo->from, fo->to, fo->from.getDistance(fo->to));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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,33 +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_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 {
|
||||
;
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ public:
|
||||
}
|
||||
|
||||
/** get the element's minimal distance (nearest whatsoever) to the given point */
|
||||
float getMinDistanceXY(const Point2 p) const override {
|
||||
float min = 999999;
|
||||
ClickDist getMinDistanceXY(const Point2 p) const override {
|
||||
ClickDist min = ClickDist::max();
|
||||
for (int i = 0; i < (int)fo.poly.points.size()-1; ++i) {
|
||||
const Point2 p1 = fo.poly.points[i];
|
||||
const Point2 p2 = fo.poly.points[i+1];
|
||||
const float dst = MapElementHelper::getLineDistanceXY(p1, p2, p);
|
||||
const ClickDist dst = MapElementHelper::getLineDistanceXY(p1, p2, p);
|
||||
if (dst < min) {min = dst;}
|
||||
}
|
||||
return min;
|
||||
|
||||
@@ -42,9 +42,9 @@ 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 {
|
||||
(void) p;
|
||||
return CFG::SEL_THRESHOLD_SIZE_PX; // we do not know the distance from the image
|
||||
return ClickDist(CFG::SEL_THRESHOLD_SIZE_PX, ClickDistType::UNKNOWN); // we do not know the distance from the image
|
||||
}
|
||||
|
||||
virtual void onFocus() override {
|
||||
|
||||
@@ -30,8 +30,8 @@ public:
|
||||
}
|
||||
|
||||
/** get the element's minimal distance (nearest whatsoever) to the given point */
|
||||
float getMinDistanceXY(const Point2 p) const override {
|
||||
return p.getDistance(poi->pos);
|
||||
ClickDist getMinDistanceXY(const Point2 p) const override {
|
||||
return ClickDist(p.getDistance(poi->pos), ClickDistType::DIRECT);
|
||||
}
|
||||
|
||||
/** repaint me */
|
||||
|
||||
@@ -35,11 +35,11 @@ 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 {
|
||||
|
||||
auto comp = [p] (const Floorplan::StairPart& p1, const Floorplan::StairPart& p2) {
|
||||
const float d1 = MapElementHelper::getLineDistanceXY(p1.start.xy(), p1.end.xy(), p);
|
||||
const float d2 = MapElementHelper::getLineDistanceXY(p2.start.xy(), p2.end.xy(), p);
|
||||
const ClickDist d1 = MapElementHelper::getLineDistanceXY(p1.start.xy(), p1.end.xy(), p);
|
||||
const ClickDist d2 = MapElementHelper::getLineDistanceXY(p2.start.xy(), p2.end.xy(), p);
|
||||
return d1 < d2;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
#include "ClickDist.h"
|
||||
|
||||
/** configuration */
|
||||
namespace CFG {
|
||||
const float MOVE_SNAP_SIZE_M = 0.1f; // in meter (= map-space)
|
||||
@@ -33,7 +35,7 @@ public:
|
||||
* move l into dst
|
||||
* and calculate the cut-point between l and (p1, p2)
|
||||
*/
|
||||
static float getLineDistanceXY(Point2 p1, Point2 p2, Point2 dst) {
|
||||
static ClickDist getLineDistanceXY(Point2 p1, Point2 p2, Point2 dst) {
|
||||
|
||||
// the line (p1, p2)
|
||||
const Line2 line(p1, p2);
|
||||
@@ -46,20 +48,21 @@ public:
|
||||
|
||||
// calculate the cut betwen L and (p1,p2) (if any)
|
||||
Point2 cut(0,0);
|
||||
ClickDist cutDist(99999999, ClickDistType::CUT);
|
||||
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);
|
||||
cutDist.dst_px = cut.getDistance(dst);
|
||||
|
||||
}
|
||||
|
||||
// distance from endpoints
|
||||
const ClickDist d1(p1.getDistance(dst), ClickDistType::DIRECT);
|
||||
const ClickDist d2(p2.getDistance(dst), ClickDistType::DIRECT);
|
||||
|
||||
// return the nearest possibility:
|
||||
return std::min(d1, std::min(d2, cutDist));
|
||||
|
||||
}
|
||||
|
||||
static QPen getPen(Floorplan::Material mat, Floorplan::ObstacleType type, bool focus) {
|
||||
|
||||
@@ -69,6 +69,11 @@ public:
|
||||
p->drawEllipse(s.xms(center.x)-r, s.yms(center.y)-r, 2*r, 2*r);
|
||||
}
|
||||
|
||||
void drawCircle_px(const Point2 center, const float size_px) {
|
||||
int r = size_px;
|
||||
p->drawEllipse(s.xms(center.x)-r, s.yms(center.y)-r, 2*r, 2*r);
|
||||
}
|
||||
|
||||
void drawLine(const float x1, const float y1, const float x2, const float y2) {
|
||||
p->drawLine(s.xms(x1), s.yms(y1), s.xms(x2), s.yms(y2));
|
||||
}
|
||||
@@ -115,6 +120,16 @@ public:
|
||||
p->drawImage(s.xms(pt.x)-img.width()/2, s.yms(pt.y)-img.height()/2, img);
|
||||
}
|
||||
|
||||
void drawLength(Point2 p1, Point2 p2, const float len) {
|
||||
if (p1.x < p2.x) {swap(p1, p2);}
|
||||
const Point2 center_m = (p1 + p2) / 2;
|
||||
Point2 dir_px = (p2 - p1).perpendicular().normalized() * 5;
|
||||
if (dir_px.x <= 0) {dir_px = -dir_px;}
|
||||
const Point2 pos_m = center_m + dir_px / getScaler().getScale();
|
||||
char buf[64]; sprintf(buf, "%.1f", len);
|
||||
drawText(pos_m, buf);
|
||||
}
|
||||
|
||||
void setBrush(const QBrush& brush) { p->setBrush(brush); }
|
||||
void setBrush(const Qt::BrushStyle& brush) { p->setBrush(brush); }
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ public:
|
||||
Scaler& s = m->getScaler();
|
||||
|
||||
if (e->delta() < 0) {
|
||||
s.setScale(s.getScale() * 0.5);
|
||||
s.setScale(s.getScale() * 0.75);
|
||||
} else {
|
||||
s.setScale(s.getScale() / 0.5);
|
||||
s.setScale(s.getScale() / 0.75);
|
||||
}
|
||||
|
||||
if (s.getScale() > 1000) {s.setScale(1000);}
|
||||
|
||||
0
mapview/2D/tools/ToolMeasure.cpp
Normal file
0
mapview/2D/tools/ToolMeasure.cpp
Normal file
132
mapview/2D/tools/ToolMeasure.h
Normal file
132
mapview/2D/tools/ToolMeasure.h
Normal file
@@ -0,0 +1,132 @@
|
||||
#ifndef TOOLMEASURE_H
|
||||
#define TOOLMEASURE_H
|
||||
|
||||
|
||||
#include "Tool.h"
|
||||
#include "../MapView2D.h"
|
||||
|
||||
#include "../../model/MapModelElement.h"
|
||||
#include "../../model/MapModel.h"
|
||||
#include "../MapViewElementHelper.h"
|
||||
|
||||
|
||||
/**
|
||||
* this tool allows:
|
||||
* - selecting elements within the 2D view (focus/unfocus)
|
||||
* - selecting and moving nodes of elements inheriting from HasMoveableNodes
|
||||
*
|
||||
*/
|
||||
class ToolMeasure : public Tool {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/** register this tool into the given tools-queue */
|
||||
Tools& tools;
|
||||
Tool* oldMainTool;
|
||||
|
||||
std::vector<Point2> pts_m;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
ToolMeasure(Tools& tools) : tools(tools) {
|
||||
|
||||
oldMainTool = tools.getMain(); // keep the current tool to reset it later
|
||||
tools.setMain(this);
|
||||
|
||||
resetMe();
|
||||
|
||||
}
|
||||
|
||||
/** dtor */
|
||||
virtual ~ToolMeasure() {
|
||||
tools.setMain(oldMainTool); // reset to the previous tool
|
||||
}
|
||||
|
||||
const std::string getName() const {
|
||||
return "Measure";
|
||||
}
|
||||
|
||||
virtual bool mousePressEvent(MapView2D*, QMouseEvent* e) override {
|
||||
if (e->button() == Qt::MouseButton::LeftButton) {
|
||||
pts_m.push_back(pts_m.back());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool mouseMoveEvent(MapView2D* m, QMouseEvent* e) override {
|
||||
const Point2 onScreen(e->x(), e->y());
|
||||
Point2 onMap = m->getScaler().sm(onScreen);
|
||||
onMap = m->getScaler().snap(onMap);
|
||||
pts_m.back() = onMap;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool mouseReleaseEvent(MapView2D*, QMouseEvent* e) override {
|
||||
if (e->button() == Qt::MouseButton::LeftButton) {
|
||||
return true;
|
||||
} else if (e->button() == Qt::MouseButton::RightButton) {
|
||||
resetMe();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool keyPressEvent(MapView2D* m, QKeyEvent* e) override {
|
||||
(void) m;
|
||||
if (e->key() == Qt::Key_Escape) {
|
||||
disableMe();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void paintAfter(MapView2D*, Painter& p) override {
|
||||
|
||||
if (pts_m.size() < 1) {return;}
|
||||
|
||||
p.setPen(Qt::black);
|
||||
|
||||
for (const Point2 p_m : pts_m) {
|
||||
p.drawCircle(p_m);
|
||||
}
|
||||
|
||||
float totalLen_m = 0;
|
||||
for (size_t i = 0; i < pts_m.size() - 1; ++i) {
|
||||
const Point2 p1 = pts_m[i];
|
||||
const Point2 p2 = pts_m[i+1];
|
||||
const float len_m = p1.getDistance(p2);
|
||||
p.drawLine(p1, p2);
|
||||
p.drawLength(p1, p2, len_m);
|
||||
totalLen_m += len_m;
|
||||
}
|
||||
|
||||
if (pts_m.size() > 1) {
|
||||
emit onHelpTextChange("total length is: " + QString::number(totalLen_m) + "m | right-click to restart");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
void resetMe() {
|
||||
pts_m.resize(1);
|
||||
emit onHelpTextChange("select the starting point for measuring");
|
||||
}
|
||||
|
||||
/** finish creating new elements */
|
||||
void disableMe() {
|
||||
delete this; // see dtor!
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // TOOLMEASURE_H
|
||||
@@ -96,9 +96,19 @@ public:
|
||||
p.p->drawLine(mouseX, 0, mouseX, rs);
|
||||
|
||||
|
||||
|
||||
|
||||
p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
char buf[128];
|
||||
|
||||
// coordinates
|
||||
QRect ru(0,0,rs-1,rs-1);
|
||||
p.p->fillRect(ru, Qt::white);
|
||||
std::sprintf(buf, "%.1f", p.getScaler().xsm(this->mouseX));
|
||||
p.p->drawText(5,15, buf);
|
||||
std::sprintf(buf, "%.1f", p.getScaler().ysm(this->mouseY));
|
||||
p.p->drawText(5,30, buf);
|
||||
|
||||
// y-axis
|
||||
p.p->setClipRect(ry);
|
||||
for (float y = r.y0; y <= r.y1; y += step) {
|
||||
@@ -141,6 +151,8 @@ public:
|
||||
|
||||
p.p->setClipping(false);
|
||||
|
||||
|
||||
|
||||
// snapped dot
|
||||
const Point2 mouseOnScreen(mouseX, mouseY);
|
||||
const Point2 mouseInMap = p.s.sm(mouseOnScreen);
|
||||
|
||||
@@ -46,6 +46,15 @@ public:
|
||||
setFocused(m, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief change the currently focused element. throws an event.
|
||||
* @param el the to-be-focused element or null
|
||||
* @return true if the focused element has changed. false otherwise
|
||||
*/
|
||||
bool focus(MapView2D* v, MapModelElement* el) {
|
||||
setFocused(v, el);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void processUnfocus(MapView2D* m, MapModelElement* elem) {
|
||||
@@ -202,9 +211,11 @@ private:
|
||||
|
||||
const float g = m->getScaler().sm(15); // increase each BBox by 15 px (needed mainly for hor/ver lines)
|
||||
|
||||
#warning "which elements to select? among all currently visible? or only among the selected layer?"
|
||||
// get all elements with bounding-box matchings
|
||||
std::vector<MapModelElement*> possible;
|
||||
for (MapModelElement* el : m->getModel()->getSelectedLayerElements()) {
|
||||
// for (MapModelElement* el : m->getModel()->getSelectedLayerElements()) {
|
||||
for (MapModelElement* el : m->getModel()->getVisibleElements()) {
|
||||
if (!el->getMV2D()) {continue;}
|
||||
BBox2 bbox = el->getMV2D()->getBoundingBox(); // elements 2D bbox
|
||||
bbox.grow(Point2(g, g)); // grow a little (needed for straight lines)
|
||||
|
||||
Reference in New Issue
Block a user