fixed some issues
added new tools for creating APs, Beacons, GTP, POI, Fingerprints fixed selection issue changed new-element creation added missing layer parameters
This commit is contained in:
@@ -159,7 +159,12 @@ HEADERS += MainWindow.h \
|
||||
mapview/model/MMRegistration.h \
|
||||
mapview/model/MMRegistrationPoint.h \
|
||||
mapview/2D/MV2DElementRegistrationPoint.h \
|
||||
mapview/3D/MV3DElementRegistrationPoint.h
|
||||
mapview/3D/MV3DElementRegistrationPoint.h \
|
||||
mapview/2D/tools/ToolNewFingerprint.h \
|
||||
mapview/2D/tools/ToolNewAccessPoint.h \
|
||||
mapview/2D/tools/ToolNewBeacon.h \
|
||||
mapview/2D/tools/ToolNewGroundTruth.h \
|
||||
mapview/2D/tools/ToolNewPOI.h
|
||||
|
||||
|
||||
FORMS += MainWindow.ui
|
||||
|
||||
@@ -95,9 +95,10 @@ MainController::MainController() {
|
||||
connect(mw, &MainWindow::onGridNodeColorType, [&] () {mw->getMapView3D()->getGridRenderer()->setNodeColorMode(GridRendererColorMode::SHOW_NODE_TYPE);} );
|
||||
connect(mw, &MainWindow::onGridShowEdges, [&] (const bool show) {mw->getMapView3D()->getGridRenderer()->setShowEdges(show);} );
|
||||
|
||||
|
||||
mapModel->load("../IndoorMap/maps/SHL38_no_elev.xml");
|
||||
//mapModel->load("../IndoorMap/maps/SHL36_noel.xml");
|
||||
//mapModel->load("../IndoorMap/maps/SHL38_no_elev.xml");
|
||||
//mapModel->load("/apps/android/workspace/testmap.xml");
|
||||
mapModel->load("/mnt/data/workspaces/testmap.xml");
|
||||
|
||||
//mapModel->resize(0.983, 0.983, 1, -0.2, -0.3, 0);
|
||||
|
||||
@@ -112,7 +113,7 @@ MainController::MainController() {
|
||||
//mapModel->load("/mnt/data/workspaces/Indoor/tests/data/WalkHeadingMap.xml");
|
||||
//mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/test.xml");
|
||||
|
||||
// mapModel->startEmpty();
|
||||
//mapModel->startEmpty();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,27 +44,31 @@ public:
|
||||
if (selectedUserIdx == 1) {p.drawCircle(fo->to);}
|
||||
}
|
||||
|
||||
// convert wall's thickness from meter to pixels
|
||||
const float thickness_px = p.s.ms(fo->thickness_m);
|
||||
|
||||
p.setPenBrush(MapElementHelper::getPen(fo->material, fo->type, hasFocus()), Qt::NoBrush);
|
||||
// remember the old pen
|
||||
QPen pen = p.getPen();
|
||||
|
||||
// see notes within MapElementHelper!
|
||||
// lines only get thicker, but not longer!
|
||||
p.setPenBrush(MapElementHelper::getPen(fo->material, fo->type, hasFocus(), thickness_px), Qt::NoBrush);
|
||||
p.drawLine(fo->from, fo->to);
|
||||
|
||||
// // door?
|
||||
// if (fo->type == Floorplan::ObstacleType::DOOR) {
|
||||
// paintDoor(p);
|
||||
// } else {
|
||||
// p.setPenBrush(MapElementHelper::getPen(fo->material, fo->type, hasFocus()), Qt::NoBrush);
|
||||
// p.drawLine(fo->from, fo->to);
|
||||
// }
|
||||
// reset the old pen
|
||||
p.setPen(pen);
|
||||
|
||||
|
||||
// available endpoints
|
||||
if (hasFocus()) {
|
||||
|
||||
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));
|
||||
p.drawLength(fo->from, fo->to, fo->from.getDistance(fo->to), thickness_px/2);
|
||||
|
||||
} else {
|
||||
//p.setPenBrush(Qt::NoPen, Qt::black);
|
||||
|
||||
@@ -2,18 +2,20 @@
|
||||
#define MV2DELEMENTSTAIR_H
|
||||
|
||||
#include "MV2DElement.h"
|
||||
#include "HasMoveableNodes.h"
|
||||
|
||||
#include "MapViewElementHelper.h"
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
class MV2DElementStair : public MV2DElement {
|
||||
class MV2DElementStair : public MV2DElement, public HasMoveableNodes {
|
||||
|
||||
private:
|
||||
|
||||
bool sel = false;
|
||||
Floorplan::Floor* floor;
|
||||
Floorplan::Stair* stair;
|
||||
int selPart = -1;
|
||||
int selNode = -1;
|
||||
//int selPart = -1;
|
||||
//int selNode = -1;
|
||||
|
||||
public:
|
||||
|
||||
@@ -49,11 +51,8 @@ public:
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int getSelPart() const {return selPart;}
|
||||
int getSelNode() const {return selNode;}
|
||||
int getSelPart() const {return getSelectedNode() < 0 ? getSelectedNode() : getSelectedNode() / 2;}
|
||||
int getSelNode() const {return getSelectedNode() < 0 ? getSelectedNode() : getSelectedNode() % 2;}
|
||||
|
||||
static inline float clamp01(const float val) {
|
||||
if (val < 0) {return 0;}
|
||||
@@ -66,11 +65,6 @@ public:
|
||||
|
||||
Floorplan::StairFreeform* stair = dynamic_cast<Floorplan::StairFreeform*>(this->stair);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// if (sel) {
|
||||
// p.setPenBrush(Qt::black, CFG::SEL_COLOR);
|
||||
// p.drawCircle(stair->center);
|
||||
@@ -140,9 +134,9 @@ public:
|
||||
int cnt = 0;
|
||||
std::vector<Floorplan::StairPart> parts = stair->getParts();
|
||||
for (const Floorplan::StairPart& part : parts) {
|
||||
p.setPenBrush(Qt::black, (cnt == selPart && selNode == 0) ? CFG::SEL_COLOR : Qt::NoBrush); // part start
|
||||
p.setPenBrush(Qt::black, (cnt == getSelPart() && getSelNode() == 0) ? CFG::SEL_COLOR : Qt::NoBrush); // part start
|
||||
p.drawCircle(part.start.xy());
|
||||
p.setPenBrush(Qt::black, (cnt == selPart && selNode == 1) ? CFG::SEL_COLOR : Qt::NoBrush); // part end
|
||||
p.setPenBrush(Qt::black, (cnt == getSelPart() && getSelNode() == 1) ? CFG::SEL_COLOR : Qt::NoBrush); // part end
|
||||
p.drawRect(part.end.xy());
|
||||
p.setPenBrush(Qt::blue, Qt::NoBrush);
|
||||
Point2 ctr = (part.start+part.end).xy() / 2;
|
||||
@@ -160,54 +154,54 @@ public:
|
||||
|
||||
|
||||
|
||||
/** mouse pressed at the given point */
|
||||
virtual void mousePressed(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
// /** mouse pressed at the given point */
|
||||
// virtual void mousePressed(MapView2D* v, const Point2 p) override {
|
||||
// (void) v;
|
||||
// (void) p;
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
/** mouse moved to the given point */
|
||||
virtual void mouseMove(MapView2D* v, const Point2 _p) override {
|
||||
(void) v;
|
||||
if (selPart == -1) {return;}
|
||||
Floorplan::StairFreeform* stair = dynamic_cast<Floorplan::StairFreeform*>(this->stair);
|
||||
const Point2 p = v->getScaler().snap(_p);
|
||||
stair->parts[selPart][selNode].x = p.x;
|
||||
stair->parts[selPart][selNode].y = p.y;
|
||||
}
|
||||
// /** mouse moved to the given point */
|
||||
// virtual void mouseMove(MapView2D* v, const Point2 _p) override {
|
||||
// (void) v;
|
||||
// if (selPart == -1) {return;}
|
||||
// Floorplan::StairFreeform* stair = dynamic_cast<Floorplan::StairFreeform*>(this->stair);
|
||||
// const Point2 p = v->getScaler().snap(_p);
|
||||
// stair->parts[selPart][selNode].x = p.x;
|
||||
// stair->parts[selPart][selNode].y = p.y;
|
||||
// }
|
||||
|
||||
/** mouse released */
|
||||
virtual void mouseReleased(MapView2D* v, const Point2 _p) override {
|
||||
(void) v;
|
||||
(void) _p;
|
||||
// select a new point on mouse-release (more robust than on mouse-press)
|
||||
Floorplan::StairFreeform* stair = dynamic_cast<Floorplan::StairFreeform*>(this->stair);
|
||||
const float t = v->getScaler().sm(CFG::SEL_THRESHOLD_SIZE_PX);
|
||||
// auto comp = [&] (const Point3 a, const Point3 b) {return a.xy().getDistance(_p) < b.xy().getDistance(_p);};
|
||||
// auto it = std::min_element(stair->nodes.begin(), stair->nodes.end(), comp);
|
||||
// if (it == stair->nodes.end()) {selIdx = -1;} // none found -> skip
|
||||
// else if ((*it).xy().getDistance(_p) > t) {selIdx = -1;} // nearest distance is above threshold -> skip
|
||||
// else {selIdx = it - stair->nodes.begin();}
|
||||
// /** mouse released */
|
||||
// virtual void mouseReleased(MapView2D* v, const Point2 _p) override {
|
||||
// (void) v;
|
||||
// (void) _p;
|
||||
// // select a new point on mouse-release (more robust than on mouse-press)
|
||||
// Floorplan::StairFreeform* stair = dynamic_cast<Floorplan::StairFreeform*>(this->stair);
|
||||
// const float t = v->getScaler().sm(CFG::SEL_THRESHOLD_SIZE_PX);
|
||||
//// auto comp = [&] (const Point3 a, const Point3 b) {return a.xy().getDistance(_p) < b.xy().getDistance(_p);};
|
||||
//// auto it = std::min_element(stair->nodes.begin(), stair->nodes.end(), comp);
|
||||
//// if (it == stair->nodes.end()) {selIdx = -1;} // none found -> skip
|
||||
//// else if ((*it).xy().getDistance(_p) > t) {selIdx = -1;} // nearest distance is above threshold -> skip
|
||||
//// else {selIdx = it - stair->nodes.begin();}
|
||||
|
||||
float best = 999999;
|
||||
int minPart; int minNode;
|
||||
for (int part = 0; part < (int) stair->parts.size(); ++part) {
|
||||
for (int node = 0; node < 2; ++node) {
|
||||
const float dist = stair->parts[part][node].xy().getDistance(_p);
|
||||
if (dist < best) {best = dist; minPart = part; minNode = node;}
|
||||
}
|
||||
}
|
||||
// float best = 999999;
|
||||
// int minPart; int minNode;
|
||||
// for (int part = 0; part < (int) stair->parts.size(); ++part) {
|
||||
// for (int node = 0; node < 2; ++node) {
|
||||
// const float dist = stair->parts[part][node].xy().getDistance(_p);
|
||||
// if (dist < best) {best = dist; minPart = part; minNode = node;}
|
||||
// }
|
||||
// }
|
||||
|
||||
if (best <= t) {
|
||||
selPart = minPart; selNode = minNode;
|
||||
} else {
|
||||
selPart = -1; selNode = -1;
|
||||
}
|
||||
// if (best <= t) {
|
||||
// selPart = minPart; selNode = minNode;
|
||||
// } else {
|
||||
// selPart = -1; selNode = -1;
|
||||
// }
|
||||
|
||||
emit v->onElementChange(this);
|
||||
// emit v->onElementChange(this);
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
virtual bool keyPressEvent(MapView2D* v, QKeyEvent *e) override {
|
||||
(void) v;
|
||||
@@ -218,13 +212,13 @@ public:
|
||||
if (e->key() == Qt::Key_Delete) {
|
||||
|
||||
// delete the currently selected vertex?
|
||||
if (selPart != -1) {
|
||||
if (getSelPart() != -1) {
|
||||
// stair->nodes.erase(stair->nodes.begin() + selIdx);
|
||||
// selIdx = -1;
|
||||
// return true;
|
||||
}
|
||||
|
||||
} else if (e->key() == Qt::Key_Plus && selPart != -1) {
|
||||
} else if (e->key() == Qt::Key_Plus && getSelPart() != -1) {
|
||||
// int idx1 = selIdx;
|
||||
// int idx2 = (selIdx + 1) % stair->nodes.size();
|
||||
// int idxNew = idx2;
|
||||
@@ -232,11 +226,11 @@ public:
|
||||
// stair->nodes.insert(stair->nodes.begin() + idxNew, pNew);
|
||||
// selIdx = idxNew;
|
||||
// return true;
|
||||
const int idxNew = selPart + 1;
|
||||
const Point3 p0 = stair->parts[selPart][1];
|
||||
const int idxNew = getSelPart() + 1;
|
||||
const Point3 p0 = stair->parts[getSelPart()][1];
|
||||
const Point3 p1 = p0 + Point3(1,1,0);
|
||||
const Point3 p2 = p1 + Point3(2,2,0);
|
||||
const float w = stair->parts[selPart].width;
|
||||
const float w = stair->parts[getSelPart()].width;
|
||||
stair->parts.insert(stair->parts.begin() + idxNew, Floorplan::StairPart(p1, p2, w));
|
||||
return true;
|
||||
}
|
||||
@@ -247,14 +241,46 @@ public:
|
||||
}
|
||||
|
||||
virtual void onFocus() override {
|
||||
selPart = -1;
|
||||
selNode = -1;
|
||||
// TODO?
|
||||
}
|
||||
|
||||
virtual void onUnfocus() override {
|
||||
sel = false;
|
||||
}
|
||||
|
||||
virtual std::vector<MoveableNode> getMoveableNodes() const override {
|
||||
|
||||
std::vector<MoveableNode> nodes;
|
||||
Floorplan::StairFreeform* stair = dynamic_cast<Floorplan::StairFreeform*>(this->stair);
|
||||
|
||||
// get a list of all moveable nodes (2 per stair-part)
|
||||
int idx = 0;
|
||||
for (size_t part = 0; part < stair->parts.size(); ++part) {
|
||||
for (int node = 0; node < 2; ++node) {
|
||||
MoveableNode mn(idx++, stair->parts[part][node].xy());
|
||||
nodes.push_back(mn);
|
||||
}
|
||||
}
|
||||
|
||||
return nodes;
|
||||
|
||||
}
|
||||
|
||||
void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override {
|
||||
|
||||
(void) v;
|
||||
|
||||
// convert node-index back to stair-part and node-nr within stair-part
|
||||
const int selPart = userIdx / 2;
|
||||
const int selNode = userIdx % 2;
|
||||
|
||||
// move the node
|
||||
Floorplan::StairFreeform* stair = dynamic_cast<Floorplan::StairFreeform*>(this->stair);
|
||||
stair->parts[selPart][selNode].x = newPos.x;
|
||||
stair->parts[selPart][selNode].y = newPos.y;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // MV2DELEMENTSTAIR_H
|
||||
|
||||
@@ -65,15 +65,23 @@ public:
|
||||
|
||||
}
|
||||
|
||||
static QPen getPen(Floorplan::Material mat, Floorplan::ObstacleType type, bool focus) {
|
||||
static QPen getPen(Floorplan::Material mat, Floorplan::ObstacleType type, bool focus, float thickness_px) {
|
||||
|
||||
using namespace Floorplan;
|
||||
QPen pen; pen.setColor(Qt::darkGray);
|
||||
pen.setWidth(thickness_px);
|
||||
|
||||
// this one is very important!
|
||||
// as we change the line's width, the line also becomes longer
|
||||
// but, we do not want this! -> FlatCap
|
||||
pen.setCapStyle(Qt::FlatCap);
|
||||
|
||||
if (focus) {pen.setColor(Qt::black);}
|
||||
if (mat == Material::CONCRETE) {pen.setWidth(3);}
|
||||
if (mat == Material::CONCRETE) {;}
|
||||
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);}
|
||||
if (type == ObstacleType::UNKNOWN) {pen.setColor(Qt::red);}
|
||||
if (type == ObstacleType::PILLAR) {pen.setColor(Qt::red);}
|
||||
|
||||
return pen;
|
||||
}
|
||||
|
||||
@@ -120,10 +120,10 @@ 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) {
|
||||
void drawLength(Point2 p1, Point2 p2, const float len, const float offset = 0) {
|
||||
if (p1.x < p2.x) {swap(p1, p2);}
|
||||
const Point2 center_m = (p1 + p2) / 2;
|
||||
Point2 dir_px = (p2 - p1).perpendicular().normalized() * 5;
|
||||
Point2 dir_px = (p2 - p1).perpendicular().normalized() * (5+offset);
|
||||
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);
|
||||
@@ -138,6 +138,8 @@ public:
|
||||
void setPen(const Qt::PenStyle& pen) {p->setPen(pen); }
|
||||
|
||||
|
||||
const QPen& getPen() {return p->pen();}
|
||||
|
||||
|
||||
template <typename Pen, typename Brush> void setPenBrush(const Pen& pen, const Brush& brush) {setPen(pen); setBrush(brush);}
|
||||
|
||||
|
||||
47
mapview/2D/tools/ToolNewAccessPoint.h
Normal file
47
mapview/2D/tools/ToolNewAccessPoint.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef TOOLNEWACCESSPOINT_H
|
||||
#define TOOLNEWACCESSPOINT_H
|
||||
|
||||
#include "ToolNewElement.h"
|
||||
#include "../../model/MMFloorAccessPoint.h"
|
||||
#include "../../model/MMFloorAccessPoints.h"
|
||||
|
||||
class ToolNewAccessPoint : public ToolNewElement<Floorplan::AccessPoint, MMFloorAccessPoint> {
|
||||
|
||||
public:
|
||||
|
||||
ToolNewAccessPoint(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
|
||||
;
|
||||
}
|
||||
|
||||
void becomesActive() override {
|
||||
emit onHelpTextChange("left-click where to place a new access-point. right-click to end.");
|
||||
}
|
||||
|
||||
void becomesInactive() override {
|
||||
;
|
||||
}
|
||||
|
||||
const std::string getName() const override {
|
||||
return "new Access-Point";
|
||||
}
|
||||
|
||||
void moving(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse(const Point2 mapPoint) override {
|
||||
foEL = new Floorplan::AccessPoint("AP xx", "xx:xx:xx:xx:xx:xx", Point3(mapPoint.x, mapPoint.y, 2.0));
|
||||
MMFloorAccessPoints* obs = (MMFloorAccessPoints*)layer;
|
||||
mmEL = obs->createAP(foEL);
|
||||
}
|
||||
|
||||
void rightMouse(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
finalizeCurrent();
|
||||
disableMe();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // TOOLNEWACCESSPOINT_H
|
||||
47
mapview/2D/tools/ToolNewBeacon.h
Normal file
47
mapview/2D/tools/ToolNewBeacon.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef TOOLNEWBEACON_H
|
||||
#define TOOLNEWBEACON_H
|
||||
|
||||
#include "ToolNewElement.h"
|
||||
#include "../../model/MMFloorBeacon.h"
|
||||
#include "../../model/MMFloorBeacons.h"
|
||||
|
||||
class ToolNewBeacon : public ToolNewElement<Floorplan::Beacon, MMFloorBeacon> {
|
||||
|
||||
public:
|
||||
|
||||
ToolNewBeacon(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
|
||||
;
|
||||
}
|
||||
|
||||
void becomesActive() override {
|
||||
emit onHelpTextChange("left-click where to place a new beacon. right-click to end.");
|
||||
}
|
||||
|
||||
void becomesInactive() override {
|
||||
;
|
||||
}
|
||||
|
||||
const std::string getName() const override {
|
||||
return "new Beacon";
|
||||
}
|
||||
|
||||
void moving(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse(const Point2 mapPoint) override {
|
||||
foEL = new Floorplan::Beacon("Beacon xx", "xx:xx:xx:xx:xx:xx", Point3(mapPoint.x, mapPoint.y, 2));
|
||||
MMFloorBeacons* obs = (MMFloorBeacons*)layer;
|
||||
mmEL = obs->createBeacon(foEL);
|
||||
}
|
||||
|
||||
void rightMouse(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
finalizeCurrent();
|
||||
disableMe();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // TOOLNEWBEACON_H
|
||||
@@ -13,14 +13,49 @@ private:
|
||||
public:
|
||||
|
||||
ToolNewDoor(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
|
||||
create();
|
||||
//create();
|
||||
}
|
||||
|
||||
const std::string getName() const override {
|
||||
return "new Door";
|
||||
}
|
||||
|
||||
void createEmptyElement() override {
|
||||
/** mouse is currently moved */
|
||||
void moving(const Point2 mapPoint) override {
|
||||
|
||||
if (idx > 0) {
|
||||
setPoint(idx, mapPoint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse(const Point2 mapPoint) override {
|
||||
|
||||
(void) mapPoint;
|
||||
|
||||
if (idx == 0) {
|
||||
createEmptyElement();
|
||||
setPoint(idx, mapPoint);
|
||||
++idx;
|
||||
} else if (idx == 1) {
|
||||
setPoint(idx, mapPoint);
|
||||
finalizeCurrent();
|
||||
idx = 0;
|
||||
if (!addAnother) {disableMe();}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void rightMouse(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
finalizeCurrent();
|
||||
disableMe();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void createEmptyElement() {
|
||||
|
||||
foEL = new Floorplan::FloorObstacleDoor(Floorplan::DoorType::SWING, Floorplan::Material::WOOD, Point2(0, 0), Point2(0, 0));
|
||||
MMFloorObstacles* obs = (MMFloorObstacles*)layer;
|
||||
@@ -28,33 +63,13 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/** mouse is currently moved */
|
||||
void moving(const Point2 mapPoint) override {
|
||||
void setPoint(const int idx, const Point2 mapPoint) {
|
||||
|
||||
if (idx == 0) { foEL->from = mapPoint; foEL->to = mapPoint; }
|
||||
if (idx == 1) { foEL->to = mapPoint; }
|
||||
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse() override {
|
||||
|
||||
if (++idx == 2) {
|
||||
finalizeCurrent();
|
||||
if (addAnother) {
|
||||
idx = 0;
|
||||
create();
|
||||
} else {
|
||||
disableMe();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void rightMouse() override {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -48,24 +48,34 @@ public:
|
||||
}
|
||||
|
||||
virtual bool mouseMoveEvent(MapView2D* m, QMouseEvent* e) override {
|
||||
|
||||
// get location on screen and within map
|
||||
const Point2 onScreen(e->x(), e->y());
|
||||
Point2 onMap = m->getScaler().sm(onScreen);
|
||||
onMap = m->getScaler().snap(onMap);
|
||||
|
||||
moving(onMap);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
virtual bool mouseReleaseEvent(MapView2D* m, QMouseEvent* e) override {
|
||||
(void) m;
|
||||
|
||||
// get location on screen and within map
|
||||
const Point2 onScreen(e->x(), e->y());
|
||||
Point2 onMap = m->getScaler().sm(onScreen);
|
||||
onMap = m->getScaler().snap(onMap);
|
||||
|
||||
if (e->button() == Qt::MouseButton::LeftButton) {
|
||||
leftMouse();
|
||||
leftMouse(onMap);
|
||||
return true;
|
||||
} else if (e->button() == Qt::MouseButton::RightButton) {
|
||||
rightMouse();
|
||||
rightMouse(onMap);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
virtual bool keyPressEvent(MapView2D* m, QKeyEvent* e) override {
|
||||
@@ -81,22 +91,22 @@ public:
|
||||
protected:
|
||||
|
||||
/** all subclasses must create a new, empty element here */
|
||||
virtual void createEmptyElement() = 0;
|
||||
//virtual void createEmptyElement() = 0;
|
||||
|
||||
/** mouse is currently moved */
|
||||
virtual void moving(const Point2 mapPoint) = 0;
|
||||
|
||||
/** left mouse: usually: next part */
|
||||
virtual void leftMouse() = 0;
|
||||
virtual void leftMouse(const Point2 mapPoint) = 0;
|
||||
|
||||
/** right mouse: usually: done */
|
||||
virtual void rightMouse() = 0;
|
||||
virtual void rightMouse(const Point2 mapPoint) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
void create() {
|
||||
createEmptyElement();
|
||||
mmEL->getMV2D()->focus();
|
||||
//createEmptyElement();
|
||||
//mmEL->getMV2D()->focus();
|
||||
}
|
||||
|
||||
/** delete the currently edited element */
|
||||
@@ -107,8 +117,10 @@ protected:
|
||||
/** finalize the current element (if any) */
|
||||
void finalizeCurrent() {
|
||||
if (!mmEL) {return;}
|
||||
layer->changed(); // update the UI
|
||||
mmEL->getMV2D()->unfocus();
|
||||
mmEL = nullptr;
|
||||
layer->changed(); // update the UI
|
||||
}
|
||||
|
||||
/** finish creating new elements */
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
}
|
||||
|
||||
void becomesActive() override {
|
||||
create(); // start adding an new element
|
||||
//create(); // start adding an new element
|
||||
showHelp();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,53 @@ public:
|
||||
return "new Elevator";
|
||||
}
|
||||
|
||||
void createEmptyElement() override {
|
||||
|
||||
|
||||
/** mouse is currently moved */
|
||||
void moving(const Point2 mapPoint) override {
|
||||
if (idx > 0) {
|
||||
setPoint(idx, mapPoint);
|
||||
}
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse(const Point2 mapPoint) override {
|
||||
|
||||
(void) mapPoint;
|
||||
|
||||
if (idx == 0) {
|
||||
createEmptyElement();
|
||||
setPoint(idx, mapPoint);
|
||||
++idx;
|
||||
} else if (idx == 1) {
|
||||
setPoint(idx, mapPoint);
|
||||
++idx;
|
||||
} else if (idx == 2) {
|
||||
setPoint(idx, mapPoint);
|
||||
finalizeCurrent();
|
||||
disableMe();
|
||||
idx = 0;
|
||||
}
|
||||
|
||||
showHelp();
|
||||
|
||||
}
|
||||
|
||||
void rightMouse(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
}
|
||||
|
||||
void showHelp() {
|
||||
switch (idx) {
|
||||
case 0: emit onHelpTextChange("click at the right side of the elevator's door"); break;
|
||||
case 1: emit onHelpTextChange("click at the left side of the elevator's door"); break;
|
||||
case 2: emit onHelpTextChange("click at the left backside of the elevator"); break;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void createEmptyElement() {
|
||||
|
||||
foEL = new Floorplan::Elevator();
|
||||
MMFloorElevators* elevators = (MMFloorElevators*)layer;
|
||||
@@ -41,8 +87,7 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/** mouse is currently moved */
|
||||
void moving(const Point2 mapPoint) override {
|
||||
void setPoint(const int idx, const Point2 mapPoint) {
|
||||
|
||||
if (idx == 0) {
|
||||
p1 = mapPoint;
|
||||
@@ -62,28 +107,6 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse() override {
|
||||
++idx;
|
||||
if (idx == 3) {
|
||||
finalizeCurrent();
|
||||
disableMe();
|
||||
}
|
||||
showHelp();
|
||||
}
|
||||
|
||||
void rightMouse() override {
|
||||
;
|
||||
}
|
||||
|
||||
void showHelp() {
|
||||
switch (idx) {
|
||||
case 0: emit onHelpTextChange("click at the right side of the elevator's door"); break;
|
||||
case 1: emit onHelpTextChange("click at the left side of the elevator's door"); break;
|
||||
case 2: emit onHelpTextChange("click at the left backside of the elevator"); break;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
47
mapview/2D/tools/ToolNewFingerprint.h
Normal file
47
mapview/2D/tools/ToolNewFingerprint.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef TOOLNEWFINGERPRINT_H
|
||||
#define TOOLNEWFINGERPRINT_H
|
||||
|
||||
#include "ToolNewElement.h"
|
||||
#include "../../model/MMFloorFingerprintLocation.h"
|
||||
#include "../../model/MMFloorFingerprints.h"
|
||||
|
||||
class ToolNewFingerprint : public ToolNewElement<Floorplan::FingerprintLocation, MMFloorFingerprintLocation> {
|
||||
|
||||
public:
|
||||
|
||||
ToolNewFingerprint(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
|
||||
;
|
||||
}
|
||||
|
||||
void becomesActive() override {
|
||||
emit onHelpTextChange("left-click where to place a new fingerprint. right-click to end.");
|
||||
}
|
||||
|
||||
void becomesInactive() override {
|
||||
;
|
||||
}
|
||||
|
||||
const std::string getName() const override {
|
||||
return "new Fingerprint";
|
||||
}
|
||||
|
||||
void moving(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse(const Point2 mapPoint) override {
|
||||
foEL = new Floorplan::FingerprintLocation("FP xx", mapPoint, 1.3);
|
||||
MMFloorFingerprints* obs = (MMFloorFingerprints*)layer;
|
||||
mmEL = obs->create(foEL);
|
||||
}
|
||||
|
||||
void rightMouse(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
finalizeCurrent();
|
||||
disableMe();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // TOOLNEWFINGERPRINT_H
|
||||
49
mapview/2D/tools/ToolNewGroundTruth.h
Normal file
49
mapview/2D/tools/ToolNewGroundTruth.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef TOOLNEWGROUNDTRUTH_H
|
||||
#define TOOLNEWGROUNDTRUTH_H
|
||||
|
||||
|
||||
#include "ToolNewElement.h"
|
||||
#include "../../model/MMFloorGroundTruthPoint.h"
|
||||
#include "../../model/MMFloorGroundTruthPoints.h"
|
||||
|
||||
class ToolNewGroundTruth : public ToolNewElement<Floorplan::GroundTruthPoint, MMFloorGroundTruthPoint> {
|
||||
|
||||
public:
|
||||
|
||||
ToolNewGroundTruth(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
|
||||
;
|
||||
}
|
||||
|
||||
void becomesActive() override {
|
||||
emit onHelpTextChange("left-click where to place a new ground-truth-point. right-click to end.");
|
||||
}
|
||||
|
||||
void becomesInactive() override {
|
||||
;
|
||||
}
|
||||
|
||||
const std::string getName() const override {
|
||||
return "new GroundTruth";
|
||||
}
|
||||
|
||||
void moving(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse(const Point2 mapPoint) override {
|
||||
foEL = new Floorplan::GroundTruthPoint(0, Point3(mapPoint.x, mapPoint.y, 0));
|
||||
MMFloorGroundTruthPoints* obs = (MMFloorGroundTruthPoints*)layer;
|
||||
mmEL = obs->createGroundTruthPoint(foEL);
|
||||
}
|
||||
|
||||
void rightMouse(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
finalizeCurrent();
|
||||
disableMe();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // TOOLNEWGROUNDTRUTH_H
|
||||
@@ -15,7 +15,7 @@ private:
|
||||
public:
|
||||
|
||||
ToolNewOutline(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
|
||||
create();
|
||||
//create();
|
||||
}
|
||||
|
||||
const std::string getName() const override {
|
||||
@@ -26,32 +26,41 @@ public:
|
||||
emit onHelpTextChange("left-click for each edge of the outline. right-click to end");
|
||||
}
|
||||
|
||||
void createEmptyElement() override {
|
||||
|
||||
foEL = new Floorplan::FloorOutlinePolygon();
|
||||
foEL->poly.points.resize(1);
|
||||
foEL->outdoor = false;
|
||||
foEL->method = Floorplan::OutlineMethod::ADD;
|
||||
|
||||
MMFloorOutline* outlines = (MMFloorOutline*)layer;
|
||||
mmEL = outlines->create(foEL);
|
||||
|
||||
}
|
||||
|
||||
/** mouse is currently moved */
|
||||
void moving(const Point2 mapPoint) override {
|
||||
foEL->poly.points[idx] = mapPoint;
|
||||
if (idx > 0) {
|
||||
setPoint(idx, mapPoint);
|
||||
}
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse() override {
|
||||
void leftMouse(const Point2 mapPoint) override {
|
||||
|
||||
(void) mapPoint;
|
||||
|
||||
// 1st click
|
||||
if (idx == 0) {
|
||||
createEmptyElement();
|
||||
foEL->poly.points.resize(foEL->poly.points.size() + 1);
|
||||
} else {
|
||||
;
|
||||
}
|
||||
|
||||
foEL->poly.points.resize(foEL->poly.points.size() + 1);
|
||||
setPoint(idx, mapPoint); // current element (finished)
|
||||
++idx;
|
||||
foEL->poly.points.resize(idx+1);
|
||||
foEL->poly.points.back() = foEL->poly.points[idx-1];
|
||||
setPoint(idx, mapPoint); // new element (start at the current)
|
||||
|
||||
emit onHelpTextChange("left-click to add, right-click to end");
|
||||
|
||||
}
|
||||
|
||||
void rightMouse() override {
|
||||
void rightMouse(const Point2 mapPoint) override {
|
||||
|
||||
(void) mapPoint;
|
||||
|
||||
if (idx >= 3) {
|
||||
finalizeCurrent();
|
||||
} else {
|
||||
@@ -60,6 +69,22 @@ public:
|
||||
disableMe();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void setPoint(const int idx, const Point2 mapPoint) {
|
||||
foEL->poly.points[idx] = mapPoint;
|
||||
}
|
||||
|
||||
void createEmptyElement() {
|
||||
|
||||
foEL = new Floorplan::FloorOutlinePolygon();
|
||||
foEL->outdoor = false;
|
||||
foEL->method = Floorplan::OutlineMethod::ADD;
|
||||
|
||||
MMFloorOutline* outlines = (MMFloorOutline*)layer;
|
||||
mmEL = outlines->create(foEL);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
49
mapview/2D/tools/ToolNewPOI.h
Normal file
49
mapview/2D/tools/ToolNewPOI.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef TOOLNEWPOI_H
|
||||
#define TOOLNEWPOI_H
|
||||
|
||||
|
||||
#include "ToolNewElement.h"
|
||||
#include "../../model/MMFloorPOI.h"
|
||||
#include "../../model/MMFloorPOIs.h"
|
||||
|
||||
class ToolNewPOI : public ToolNewElement<Floorplan::POI, MMFloorPOI> {
|
||||
|
||||
public:
|
||||
|
||||
ToolNewPOI(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
|
||||
;
|
||||
}
|
||||
|
||||
void becomesActive() override {
|
||||
emit onHelpTextChange("left-click where to place a new POI. right-click to end.");
|
||||
}
|
||||
|
||||
void becomesInactive() override {
|
||||
;
|
||||
}
|
||||
|
||||
const std::string getName() const override {
|
||||
return "new Beacon";
|
||||
}
|
||||
|
||||
void moving(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse(const Point2 mapPoint) override {
|
||||
foEL = new Floorplan::POI(Floorplan::POIType::ROOM, "POI", mapPoint);
|
||||
MMFloorPOIs* obs = (MMFloorPOIs*)layer;
|
||||
mmEL = obs->createPOI(foEL);
|
||||
}
|
||||
|
||||
void rightMouse(const Point2 mapPoint) override {
|
||||
(void) mapPoint;
|
||||
finalizeCurrent();
|
||||
disableMe();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // TOOLNEWPOI_H
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
}
|
||||
|
||||
void becomesActive() override {
|
||||
create(); // start adding an new element
|
||||
//create(); // start adding an new element
|
||||
emit onHelpTextChange("click for the stair's starting point");
|
||||
}
|
||||
|
||||
@@ -30,23 +30,59 @@ public:
|
||||
return "new Stair";
|
||||
}
|
||||
|
||||
void createEmptyElement() override {
|
||||
|
||||
foEL = new Floorplan::StairFreeform();
|
||||
foEL->parts.resize(1);
|
||||
MMFloorStairs* stairs = (MMFloorStairs*)layer;
|
||||
mmEL = stairs->create(foEL);
|
||||
|
||||
}
|
||||
|
||||
/** mouse is currently moved */
|
||||
void moving(const Point2 mapPoint) override {
|
||||
|
||||
if (idx == 0) {
|
||||
if (idx > 0) {
|
||||
setPoint(idx, mapPoint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse(const Point2 mapPoint) override {
|
||||
|
||||
(void) mapPoint;
|
||||
|
||||
// start a new stair here
|
||||
if (idx == 0) {
|
||||
createEmptyElement();
|
||||
} else {
|
||||
;
|
||||
}
|
||||
|
||||
// add a new part to the stair
|
||||
Floorplan::StairPart sp;
|
||||
sp.connectWithPrev = false;
|
||||
sp.width = 1.5;
|
||||
foEL->parts.push_back(sp);
|
||||
|
||||
setPoint(idx, mapPoint); // current element (finished)
|
||||
++idx;
|
||||
setPoint(idx, mapPoint); // new element (start at the current)
|
||||
|
||||
emit onHelpTextChange("right-click: set end + start new part, left-click set end + finish");
|
||||
|
||||
}
|
||||
|
||||
void rightMouse(const Point2 mapPoint) override {
|
||||
|
||||
(void) mapPoint;
|
||||
|
||||
finalizeCurrent();
|
||||
disableMe();
|
||||
idx = 0;
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void setPoint(const int idx, const Point2 mapPoint) {
|
||||
|
||||
if (idx == 0) {
|
||||
Floorplan::StairPart& part = foEL->parts[0];
|
||||
part.connectWithPrev = false;
|
||||
part.width = 1.5;
|
||||
part.start = Point3(mapPoint.x, mapPoint.y, 0);
|
||||
part.end = part.start;
|
||||
|
||||
@@ -54,10 +90,9 @@ public:
|
||||
Floorplan::StairPart& part = foEL->parts[0];
|
||||
part.end = Point3(mapPoint.x, mapPoint.y, 0);
|
||||
|
||||
} else {
|
||||
} else if (idx > 1) {
|
||||
Floorplan::StairPart& p1 = foEL->parts[idx-2];
|
||||
Floorplan::StairPart& p2 = foEL->parts[idx-1];
|
||||
p2.width = 1.5;
|
||||
p2.start = p1.end;
|
||||
p2.end = Point3(mapPoint.x, mapPoint.y, 0);
|
||||
|
||||
@@ -65,16 +100,12 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse() override {
|
||||
++idx;
|
||||
foEL->parts.resize(idx);
|
||||
emit onHelpTextChange("right-click: set end + start new part, left-click set end + finish");
|
||||
}
|
||||
void createEmptyElement() {
|
||||
|
||||
foEL = new Floorplan::StairFreeform();
|
||||
MMFloorStairs* stairs = (MMFloorStairs*)layer;
|
||||
mmEL = stairs->create(foEL);
|
||||
|
||||
void rightMouse() override {
|
||||
finalizeCurrent();
|
||||
disableMe();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
}
|
||||
|
||||
void becomesActive() override {
|
||||
create(); // start adding an new element
|
||||
//create(); // start adding an new element
|
||||
}
|
||||
|
||||
void becomesInactive() override {
|
||||
@@ -30,7 +30,46 @@ public:
|
||||
return "new Wall";
|
||||
}
|
||||
|
||||
void createEmptyElement() override {
|
||||
|
||||
|
||||
/** mouse is currently moved */
|
||||
void moving(const Point2 mapPoint) override {
|
||||
|
||||
// live-moving of the ending point
|
||||
if (idx == 1) { foEL->to = mapPoint; }
|
||||
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse(const Point2 mapPoint) override {
|
||||
|
||||
// 1st click (where to start the line)
|
||||
if (idx == 0) {
|
||||
createEmptyElement();
|
||||
foEL->from = mapPoint; foEL->to = mapPoint;
|
||||
++idx;
|
||||
|
||||
// 2nd click (wehere the line ends)
|
||||
} else if (idx == 1) {
|
||||
finalizeCurrent();
|
||||
idx = 0;
|
||||
if (!addAnother) {disableMe();}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void rightMouse(const Point2 mapPoint) override {
|
||||
|
||||
(void) mapPoint;
|
||||
finalizeCurrent();
|
||||
disableMe();
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void createEmptyElement() {
|
||||
|
||||
foEL = new Floorplan::FloorObstacleLine(Floorplan::ObstacleType::WALL, Floorplan::Material::DRYWALL, Point2(0, 0), Point2(0, 0));
|
||||
MMFloorObstacles* obs = (MMFloorObstacles*)layer;
|
||||
@@ -38,33 +77,6 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/** mouse is currently moved */
|
||||
void moving(const Point2 mapPoint) override {
|
||||
|
||||
if (idx == 0) { foEL->from = mapPoint; foEL->to = mapPoint; }
|
||||
if (idx == 1) { foEL->to = mapPoint; }
|
||||
|
||||
}
|
||||
|
||||
/** next point */
|
||||
void leftMouse() override {
|
||||
|
||||
if (++idx == 2) {
|
||||
finalizeCurrent();
|
||||
if (addAnother) {
|
||||
idx = 0;
|
||||
create();
|
||||
} else {
|
||||
disableMe();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void rightMouse() override {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
* @return true if the focused element has changed. false otherwise
|
||||
*/
|
||||
bool focus(MapView2D* v, MapModelElement* el) {
|
||||
setFocused(v, el);
|
||||
return setFocused(v, el);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -72,40 +72,58 @@ private:
|
||||
|
||||
}
|
||||
|
||||
void processPress(MapView2D* m, const Point2 p, MapModelElement* elem) {
|
||||
void processPress(QMouseEvent* e, MapView2D* m, const Point2 p, MapModelElement* elem) {
|
||||
|
||||
MV2DElement* me = elem->getMV2D();
|
||||
if (!me) {return;}
|
||||
|
||||
// left mouse button?
|
||||
if (e->button() == Qt::MouseButton::LeftButton) {
|
||||
// element has selectedable nodes? try to select one
|
||||
if (dynamic_cast<HasMoveableNodes*>(me)) {
|
||||
if (selectNode(m, p, dynamic_cast<HasMoveableNodes*>(me))) {return;}
|
||||
}
|
||||
}
|
||||
|
||||
// let the element itself process all events
|
||||
me->mousePressed(m, p);
|
||||
|
||||
}
|
||||
|
||||
void processMove(MapView2D* m, const Point2 p, MapModelElement* elem) {
|
||||
void processMove(QMouseEvent* e, MapView2D* m, const Point2 p, MapModelElement* elem) {
|
||||
|
||||
(void) e;
|
||||
|
||||
MV2DElement* me = elem->getMV2D();
|
||||
if (!me) {return;}
|
||||
|
||||
// elements has selectedable nodes? try to process them
|
||||
if (dynamic_cast<HasMoveableNodes*>(me)) {
|
||||
if (moveNode(m, p, dynamic_cast<HasMoveableNodes*>(me))) {return;}
|
||||
}
|
||||
// left mouse button? [does not work for move-events?!]
|
||||
//if (e->button() == Qt::MouseButton::LeftButton) {
|
||||
// elements has selectedable nodes? try to move the selected one (if any)
|
||||
if (dynamic_cast<HasMoveableNodes*>(me)) {
|
||||
if (moveNode(m, p, dynamic_cast<HasMoveableNodes*>(me))) {return;}
|
||||
}
|
||||
//}
|
||||
|
||||
// otherwise: let the element itself process all events
|
||||
me->mouseMove(m, p);
|
||||
|
||||
}
|
||||
|
||||
void processRelease(MapView2D* m, const Point2 p, MapModelElement* elem) {
|
||||
void processRelease(QMouseEvent* e, MapView2D* m, const Point2 p, MapModelElement* elem) {
|
||||
|
||||
(void) e;
|
||||
|
||||
MV2DElement* me = elem->getMV2D();
|
||||
if (!me) {return;}
|
||||
|
||||
// element has selectedable nodes? try to process them
|
||||
if (dynamic_cast<HasMoveableNodes*>(me)) {
|
||||
if (selectNode(m, p, dynamic_cast<HasMoveableNodes*>(me))) {return;}
|
||||
}
|
||||
// // left mouse button?
|
||||
// if (e->button() == Qt::MouseButton::LeftButton) {
|
||||
// // element has selectedable nodes? try to select one
|
||||
// if (dynamic_cast<HasMoveableNodes*>(me)) {
|
||||
// if (selectNode(m, p, dynamic_cast<HasMoveableNodes*>(me))) {return;}
|
||||
// }
|
||||
// }
|
||||
|
||||
// otherwise: let the element itself process all events
|
||||
me->mouseReleased(m, p);
|
||||
@@ -124,6 +142,7 @@ private:
|
||||
// find the node nearest to p
|
||||
auto comp = [&] (const MoveableNode& n1, const MoveableNode& n2) {return n1.pos.getDistance(p) < n2.pos.getDistance(p);};
|
||||
auto lst = elem->getMoveableNodes();
|
||||
if (lst.empty()) {return false;} // nothing available!
|
||||
auto it = std::min_element(lst.begin(), lst.end(), comp);
|
||||
|
||||
// is the nearest point below the threshold?
|
||||
@@ -240,7 +259,7 @@ private:
|
||||
|
||||
// focus kept. provide the currently focused element with events
|
||||
if (focused) {
|
||||
processPress(m, p2, focused);
|
||||
processPress(e, m, p2, focused);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -258,7 +277,7 @@ private:
|
||||
if (mouseIsDown) {
|
||||
|
||||
// provide the focused element with the mouse event?
|
||||
if (focused) {processMove(m, p2, focused);}
|
||||
if (focused) {processMove(e, m, p2, focused);}
|
||||
|
||||
}
|
||||
|
||||
@@ -269,13 +288,14 @@ private:
|
||||
virtual bool mouseReleaseEvent(MapView2D* m, QMouseEvent* e) override {
|
||||
|
||||
const Scaler& s = m->getScaler();
|
||||
Point2 p2(s.xsm(e->x()), s.ysm(e->y()));
|
||||
const Point2 p2(s.xsm(e->x()), s.ysm(e->y()));
|
||||
|
||||
// provide the focused element with the mouse event?
|
||||
if (focused) {processRelease(m, p2, focused);}
|
||||
if (focused) {processRelease(e, m, p2, focused);}
|
||||
|
||||
mouseIsDown = false;
|
||||
|
||||
// not consumed
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@@ -169,6 +169,7 @@ void MapView3D::mouseMoveEvent(QMouseEvent* e) {
|
||||
}
|
||||
|
||||
void MapView3D::mouseReleaseEvent(QMouseEvent* e) {
|
||||
(void) e;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,18 @@ public:
|
||||
std::string getLayerName() const override {return "APs";}
|
||||
|
||||
//TODO: check
|
||||
void createAP(Floorplan::AccessPoint* ap) {
|
||||
MMFloorAccessPoint* createAP(Floorplan::AccessPoint* ap) {
|
||||
|
||||
// add to underlying model
|
||||
floor->accesspoints.push_back(ap);
|
||||
|
||||
// add to myself as element
|
||||
addElement(new MMFloorAccessPoint(this, floor, ap));
|
||||
//addElement(new MMFloorAccessPoint(this, floor, ap));
|
||||
|
||||
// add to myself as element
|
||||
MMFloorAccessPoint* mm = new MMFloorAccessPoint(this, floor, ap);
|
||||
addElement(mm);
|
||||
return mm;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,19 @@ public:
|
||||
std::string getLayerName() const override {return "Beacons";}
|
||||
|
||||
//TODO: check
|
||||
void createBeacon(Floorplan::Beacon* b) {
|
||||
MMFloorBeacon* createBeacon(Floorplan::Beacon* b) {
|
||||
|
||||
// add to underlying model
|
||||
floor->beacons.push_back(b);
|
||||
|
||||
// // add to myself as element
|
||||
// addElement(new MMFloorBeacon(this, floor, b));
|
||||
|
||||
// add to myself as element
|
||||
addElement(new MMFloorBeacon(this, floor, b));
|
||||
MMFloorBeacon* mm = new MMFloorBeacon(this, floor, b);
|
||||
addElement(mm);
|
||||
return mm;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -29,13 +29,18 @@ public:
|
||||
Floorplan::Floor* getFloor() {return floor;}
|
||||
|
||||
//TODO: check
|
||||
void createGroundTruthPoint(Floorplan::GroundTruthPoint* gtp) {
|
||||
MMFloorGroundTruthPoint* createGroundTruthPoint(Floorplan::GroundTruthPoint* gtp) {
|
||||
|
||||
// add to underlying model
|
||||
floor->gtpoints.push_back(gtp);
|
||||
|
||||
// add to myself as element
|
||||
addElement(new MMFloorGroundTruthPoint(this, floor, gtp));
|
||||
//addElement(new MMFloorGroundTruthPoint(this, floor, gtp));
|
||||
|
||||
// add to myself as element
|
||||
MMFloorGroundTruthPoint* mm = new MMFloorGroundTruthPoint(this, floor, gtp);
|
||||
addElement(mm);
|
||||
return mm;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -46,26 +46,29 @@ public:
|
||||
|
||||
|
||||
virtual int getNumParams() const override {
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return Param("length", ParamType::FLOAT, true);
|
||||
case 0: return Param("thickness (m)", ParamType::FLOAT);
|
||||
case 1: return Param("length", ParamType::FLOAT, true);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual ParamValue getParamValue(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return fo->from.getDistance(fo->to);
|
||||
case 0: return fo->thickness_m;
|
||||
case 1: return fo->from.getDistance(fo->to);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual void setParamValue(const int idx, const ParamValue& val) override {
|
||||
switch(idx) {
|
||||
case 0: break;
|
||||
case 0: fo->thickness_m = val.toFloat(); break;
|
||||
case 1: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,13 +29,18 @@ public:
|
||||
Floorplan::Floor* getFloor() {return floor;}
|
||||
|
||||
//TODO: check
|
||||
void createPOI(Floorplan::POI* poi) {
|
||||
MMFloorPOI* createPOI(Floorplan::POI* poi) {
|
||||
|
||||
// add to underlying model
|
||||
floor->pois.push_back(poi);
|
||||
|
||||
// add to myself as element
|
||||
addElement(new MMFloorPOI(this, floor, poi));
|
||||
//addElement(new MMFloorPOI(this, floor, poi));
|
||||
|
||||
// add to myself as element
|
||||
MMFloorPOI* mm = new MMFloorPOI(this, floor, poi);
|
||||
addElement(mm);
|
||||
return mm;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,13 @@ public:
|
||||
|
||||
// add to underlying model
|
||||
Floorplan::Floor* floor = new Floorplan::Floor();
|
||||
floor->name = "floor";
|
||||
map->floors.push_back(floor);
|
||||
|
||||
// defalut values
|
||||
floor->atHeight = 0;
|
||||
floor->height = 3;
|
||||
floor->name = "floor";
|
||||
|
||||
// add to UI model
|
||||
MMFloor* mmfloor = new MMFloor(this, map, floor);
|
||||
//elements.push_back(mmfloor);
|
||||
|
||||
@@ -139,6 +139,12 @@ public:
|
||||
|
||||
}
|
||||
|
||||
void changed() {
|
||||
for (MapLayerListener* listener : listeners) {
|
||||
listener->onLayerChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void onElemAdded(MapModelElement* e) {
|
||||
|
||||
@@ -56,6 +56,21 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::DOUBLE: {
|
||||
const std::string str = std::to_string(value.toDouble());
|
||||
if (param.readOnly) {
|
||||
lay->addWidget(new QLabel(str.c_str()),r,1);
|
||||
} else {
|
||||
QLineEdit* le = new QLineEdit( str.c_str() );
|
||||
le->connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
|
||||
const float val = str.toDouble();
|
||||
elem->setParamValue(i, ParamValue(val));
|
||||
});
|
||||
lay->addWidget(le,r,1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::INT: {
|
||||
const std::string str = std::to_string(value.toInt());
|
||||
QLineEdit* le = new QLineEdit( str.c_str() );
|
||||
@@ -83,6 +98,7 @@ public:
|
||||
QPushButton* btn = new QPushButton("<");
|
||||
btn->setMaximumSize(32,32);
|
||||
btn->connect(btn, &QPushButton::clicked, [i,elem,lblFile] (const bool checked) {
|
||||
(void) checked;
|
||||
QString res = QFileDialog::getOpenFileName();
|
||||
elem->setParamValue(i, ParamValue(res.toStdString()));
|
||||
lblFile->setText(res);
|
||||
@@ -102,6 +118,7 @@ public:
|
||||
laySub->addWidget(txtY,0,1);
|
||||
lay->addWidget(subWidget,r,1);
|
||||
auto onChange = [i,elem,txtX,txtY] (const QString& str) {
|
||||
(void) str;
|
||||
elem->setParamValue(i, ParamValue( Point2(txtX->text().toFloat(), txtY->text().toFloat()) ));
|
||||
};
|
||||
txtX->connect(txtX, &QLineEdit::textChanged, onChange);
|
||||
@@ -130,6 +147,9 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::NOT_AVAILABLE:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
++r;
|
||||
|
||||
@@ -66,7 +66,7 @@ void LayerParamWidget::setElement(MapLayer* l) {
|
||||
delete this->layout();
|
||||
this->lay = new QGridLayout();
|
||||
this->setLayout(lay);
|
||||
int r = 0;
|
||||
// int r = 0;
|
||||
|
||||
|
||||
// {
|
||||
|
||||
@@ -23,6 +23,11 @@
|
||||
#include "../mapview/2D/tools/ToolNewStair.h"
|
||||
#include "../mapview/2D/tools/ToolNewElevator.h"
|
||||
#include "../mapview/2D/tools/ToolNewOutline.h"
|
||||
#include "../mapview/2D/tools/ToolNewFingerprint.h"
|
||||
#include "../mapview/2D/tools/ToolNewGroundTruth.h"
|
||||
#include "../mapview/2D/tools/ToolNewAccessPoint.h"
|
||||
#include "../mapview/2D/tools/ToolNewBeacon.h"
|
||||
#include "../mapview/2D/tools/ToolNewPOI.h"
|
||||
|
||||
#include "../UIHelper.h"
|
||||
|
||||
@@ -175,6 +180,12 @@ void ToolBoxWidget::onMainToolChanged() {
|
||||
btnElevator->setStyleSheet( dynamic_cast<ToolNewElevator*>(t) ? styleSel : styleNor );
|
||||
btnStair->setStyleSheet( dynamic_cast<ToolNewStair*>(t) ? styleSel : styleNor );
|
||||
|
||||
btnFingerprintLocation->setStyleSheet( dynamic_cast<ToolNewFingerprint*>(t) ? styleSel : styleNor );
|
||||
btnGTP->setStyleSheet( dynamic_cast<ToolNewGroundTruth*>(t) ? styleSel : styleNor );
|
||||
btnWifi->setStyleSheet( dynamic_cast<ToolNewAccessPoint*>(t) ? styleSel : styleNor );
|
||||
btnBeacon->setStyleSheet( dynamic_cast<ToolNewBeacon*>(t) ? styleSel : styleNor );
|
||||
btnPOI->setStyleSheet( dynamic_cast<ToolNewPOI*>(t) ? styleSel : styleNor );
|
||||
|
||||
}
|
||||
|
||||
void ToolBoxWidget::setSelectedLayer(MapLayer *ml) {
|
||||
@@ -222,7 +233,6 @@ void ToolBoxWidget::onNewGround() {
|
||||
|
||||
view->getTools().setMain(new ToolNewOutline(view->getTools(), curLayer));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -295,35 +305,41 @@ void ToolBoxWidget::onNewElevator() {
|
||||
|
||||
void ToolBoxWidget::onNewAccessPoint() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
Floorplan::AccessPoint* ap = new Floorplan::AccessPoint(
|
||||
"noname", "00:00:00:00:00:00", Point3(center.x, center.y, 0)
|
||||
);
|
||||
// const Point2 center = view->getScaler().getCenter();
|
||||
// Floorplan::AccessPoint* ap = new Floorplan::AccessPoint(
|
||||
// "noname", "00:00:00:00:00:00", Point3(center.x, center.y, 0)
|
||||
// );
|
||||
|
||||
MMFloorAccessPoints* aps = (MMFloorAccessPoints*) curLayer;
|
||||
aps->createAP(ap);
|
||||
// MMFloorAccessPoints* aps = (MMFloorAccessPoints*) curLayer;
|
||||
// aps->createAP(ap);
|
||||
|
||||
view->getTools().setMain(new ToolNewAccessPoint(view->getTools(), curLayer));
|
||||
|
||||
}
|
||||
|
||||
void ToolBoxWidget::onNewBeacon() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
Floorplan::Beacon* b = new Floorplan::Beacon(
|
||||
"noname", "00:00:00:00:00:00", Point3(center.x, center.y, 0)
|
||||
);
|
||||
// const Point2 center = view->getScaler().getCenter();
|
||||
// Floorplan::Beacon* b = new Floorplan::Beacon(
|
||||
// "noname", "00:00:00:00:00:00", Point3(center.x, center.y, 0)
|
||||
// );
|
||||
|
||||
MMFloorBeacons* beacons = (MMFloorBeacons*) curLayer;
|
||||
beacons->createBeacon(b);
|
||||
// MMFloorBeacons* beacons = (MMFloorBeacons*) curLayer;
|
||||
// beacons->createBeacon(b);
|
||||
|
||||
view->getTools().setMain(new ToolNewBeacon(view->getTools(), curLayer));
|
||||
|
||||
}
|
||||
|
||||
void ToolBoxWidget::onNewFingerprintLocation() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
Floorplan::FingerprintLocation* fpl = new Floorplan::FingerprintLocation("noname", center, 0);
|
||||
// const Point2 center = view->getScaler().getCenter();
|
||||
// Floorplan::FingerprintLocation* fpl = new Floorplan::FingerprintLocation("noname", center, 0);
|
||||
|
||||
MMFloorFingerprints* fps = (MMFloorFingerprints*) curLayer;
|
||||
fps->create(fpl);
|
||||
// MMFloorFingerprints* fps = (MMFloorFingerprints*) curLayer;
|
||||
// fps->create(fpl);
|
||||
|
||||
view->getTools().setMain(new ToolNewFingerprint(view->getTools(), curLayer));
|
||||
|
||||
}
|
||||
|
||||
@@ -331,25 +347,29 @@ void ToolBoxWidget::onNewFingerprintLocation() {
|
||||
|
||||
void ToolBoxWidget::onNewPOI() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
Floorplan::POI* poi = new Floorplan::POI(
|
||||
Floorplan::POIType::ROOM, "noname", Point2(center.x, center.y)
|
||||
);
|
||||
// const Point2 center = view->getScaler().getCenter();
|
||||
// Floorplan::POI* poi = new Floorplan::POI(
|
||||
// Floorplan::POIType::ROOM, "noname", Point2(center.x, center.y)
|
||||
// );
|
||||
|
||||
MMFloorPOIs* pois = (MMFloorPOIs*) curLayer;
|
||||
pois->createPOI(poi);
|
||||
// MMFloorPOIs* pois = (MMFloorPOIs*) curLayer;
|
||||
// pois->createPOI(poi);
|
||||
|
||||
view->getTools().setMain(new ToolNewPOI(view->getTools(), curLayer));
|
||||
|
||||
}
|
||||
|
||||
void ToolBoxWidget::onNewGTP() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
Floorplan::GroundTruthPoint* gtp = new Floorplan::GroundTruthPoint(
|
||||
0, Point3(center.x, center.y, 0)
|
||||
);
|
||||
// const Point2 center = view->getScaler().getCenter();
|
||||
// Floorplan::GroundTruthPoint* gtp = new Floorplan::GroundTruthPoint(
|
||||
// 0, Point3(center.x, center.y, 0)
|
||||
// );
|
||||
|
||||
MMFloorGroundTruthPoints* gtps = (MMFloorGroundTruthPoints*) curLayer;
|
||||
gtps->createGroundTruthPoint(gtp);
|
||||
// MMFloorGroundTruthPoints* gtps = (MMFloorGroundTruthPoints*) curLayer;
|
||||
// gtps->createGroundTruthPoint(gtp);
|
||||
|
||||
view->getTools().setMain(new ToolNewGroundTruth(view->getTools(), curLayer));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user