added earth-registration support

This commit is contained in:
2017-03-21 21:12:52 +01:00
parent b7ee7d992a
commit d80d356dea
14 changed files with 331 additions and 3 deletions

View File

@@ -155,7 +155,11 @@ HEADERS += MainWindow.h \
mapview/2D/tools/ToolNewWall.h \
mapview/2D/tools/ToolNewStair.h \
mapview/2D/tools/ToolNewElevator.h \
mapview/2D/tools/ToolNewOutline.h
mapview/2D/tools/ToolNewOutline.h \
mapview/model/MMRegistration.h \
mapview/model/MMRegistrationPoint.h \
mapview/2D/MV2DElementRegistrationPoint.h \
mapview/3D/MV3DElementRegistrationPoint.h
FORMS += MainWindow.ui

View File

@@ -95,7 +95,7 @@ MainController::MainController() {
connect(mw, &MainWindow::onGridShowEdges, [&] (const bool show) {mw->getMapView3D()->getGridRenderer()->setShowEdges(show);} );
mapModel->load("../IndoorMap/maps/SHL35.xml");
mapModel->load("../IndoorMap/maps/SHL36.xml");
//mapModel->resize(0.983, 0.983, 1, -0.2, -0.3, 0);

View File

@@ -0,0 +1,107 @@
#ifndef MV2DELEMENTREGISTRATIONPOINT_H
#define MV2DELEMENTREGISTRATIONPOINT_H
#include "MV2DElement.h"
#include "HasMoveableNodes.h"
#include "MapViewElementHelper.h"
#include <Indoor/floorplan/v2/Floorplan.h>
#include "../../UIHelper.h"
/** one earth <-> map correspondence */
class MV2DElementRegistrationPoint : public MV2DElement, public HasMoveableNodes {
private:
//bool sel = false;
Floorplan::EarthPosMapPos* reg;
public:
/** ctor with the AP to render/edit */
MV2DElementRegistrationPoint(Floorplan::EarthPosMapPos* reg) : reg(reg) {;}
/** get the element's 3D bounding box */
BBox2 getBoundingBox() const override {
BBox2 bbox;
bbox.add(Point2(reg->posOnMap_m.x, reg->posOnMap_m.y));
bbox.grow(Point2(0.1, 0.1));
return bbox;
}
/** get the element's minimal distance (nearest whatsoever) to the given point */
ClickDist getMinDistanceXY(const Point2 p) const override {
return ClickDist(p.getDistance(reg->posOnMap_m.xy()), ClickDistType::DIRECT);
}
/** repaint me */
void paint(Painter& p) override {
static const QPixmap& pixmapUnfocused = UIHelper::getPixmapColored("registration", CFG::UNFOCUS_COLOR, 16);
static const QPixmap& pixmapFocused = UIHelper::getPixmapColored("registration", CFG::FOCUS_COLOR, 16);
static const QPixmap& pixmapSel = UIHelper::getPixmapColored("registration", CFG::SEL_COLOR, 16);
if (selectedUserIdx == 0) {
p.drawPixmap(reg->posOnMap_m.xy(), pixmapSel);
} else if (hasFocus()) {
p.drawPixmap(reg->posOnMap_m.xy(), pixmapFocused);
} else {
p.drawPixmap(reg->posOnMap_m.xy(), pixmapUnfocused);
}
// label
p.setPenBrush(Qt::black, Qt::NoBrush);
//p.drawDot(ap->pos.xy());
if (p.getScaler().getScale() >= 10) {
const std::string str = std::to_string(reg->posOnEarth.lat) + " " + std::to_string(reg->posOnEarth.lon);
p.p->drawText(p.getScaler().xms(reg->posOnMap_m.x) + 10, p.getScaler().yms(reg->posOnMap_m.y) + 5, str.c_str());
}
}
virtual std::vector<MoveableNode> getMoveableNodes() const override {
return { MoveableNode(0, reg->posOnMap_m.xy()) };
}
virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override {
(void) v;
if (userIdx == 0) {reg->posOnMap_m.x = newPos.x; reg->posOnMap_m.y = newPos.y;}
}
virtual void mousePressed(MapView2D* v, const Point2 p) override {
(void) v;
(void) p;
}
virtual void mouseMove(MapView2D* v, const Point2 p) override {
(void) v;
(void) p;
}
virtual void mouseReleased(MapView2D* v, const Point2 p) override {
(void) v;
(void) p;
}
virtual bool keyPressEvent(MapView2D* v, QKeyEvent *e) override {
(void) v;
(void) e;
return false;
}
virtual void onFocus() override {
;
}
virtual void onUnfocus() override {
;
}
};
#endif // MV2DELEMENTREGISTRATIONPOINT_H

View File

@@ -0,0 +1,34 @@
#ifndef MV3DELEMENTREGISTRATIONPOINT_H
#define MV3DELEMENTREGISTRATIONPOINT_H
#include <Indoor/floorplan/v2/Floorplan.h>
#include "misc/Cube.h"
#include "MV3DElement.h"
class MV3DElementRegistrationPoint : public MV3DElement {
Floorplan::EarthPosMapPos* reg;
public:
/** ctor */
MV3DElementRegistrationPoint(Floorplan::EarthPosMapPos* reg) : reg(reg) {
;
}
protected:
/** repaint me */
void paintGL() override {
Cube cube(reg->posOnMap_m, 0.5);
glColor3f(0,0,0);
cube.paintGL();
}
};
#endif // MV3DELEMENTREGISTRATIONPOINT_H

View File

@@ -10,6 +10,7 @@ enum class ParamType {
BOOL,
INT,
FLOAT,
DOUBLE,
STRING,
FILE,
POINT2,
@@ -23,6 +24,7 @@ private:
bool _bool;
int _int;
float _float;
double _double;
float _arr[3];
};
std::string _str;
@@ -35,6 +37,7 @@ public:
void setValue(const std::string& val) {_str = val;}
void setValue(const float val) {_float = val;}
void setValue(const double val) {_double = val;}
void setValue(const int val) {_int = val;}
void setValue(const bool val) {_bool = val;}
void setValue(const Point2 p) {_arr[0] = p.x; _arr[1] = p.y;}
@@ -44,6 +47,7 @@ public:
Point3 toPoint3() const {return Point3(_arr[0], _arr[1], _arr[2]);}
std::string toString() const {return _str;}
float toFloat() const {return _float;}
double toDouble() const {return _double;}
int toInt() const {return _int;}
bool toBool() const {return _bool;}

View File

@@ -0,0 +1,48 @@
#ifndef MMREGISTRATION_H
#define MMREGISTRATION_H
#include "MMRegistrationPoint.h"
#include <Indoor/floorplan/v2/Floorplan.h>
/**
* layer that contains registriation points: earth <-> map
*/
class MMRegistration : public MapLayer {
private:
Floorplan::IndoorMap* map;
public:
/** ctor */
MMRegistration(MapLayer* parent, Floorplan::IndoorMap* map) : MapLayer(parent, MapLayerType::REGISTRATION), map(map) {
// the registered points
for (Floorplan::EarthPosMapPos* reg : map->earthReg.correspondences) {
addElement(new MMRegistrationPoint(this, map, reg));
}
}
//TODO: check
MMRegistrationPoint* create(Floorplan::EarthPosMapPos* reg) {
// add to underlying model
map->earthReg.correspondences.push_back(reg);
// add to myself as element
MMRegistrationPoint* mm = new MMRegistrationPoint(this, map, reg);
addElement(mm);
return mm;
}
virtual std::string getLayerName() const override {return "registration";}
};
#endif // MMREGISTRATION_H

View File

@@ -0,0 +1,78 @@
#ifndef MMREGISTRATIONPOINT_H
#define MMREGISTRATIONPOINT_H
#include "IHasParams.h"
#include "MapModelElement.h"
#include "../2D/MV2DElementRegistrationPoint.h"
#include "../3D/MV3DElementRegistrationPoint.h"
#include <Indoor/floorplan/v2/Floorplan.h>
/**
* one earth <-> map correspondcen
*/
class MMRegistrationPoint : public MapModelElement, public IHasParams {
private:
Floorplan::IndoorMap* map;
Floorplan::EarthPosMapPos* reg;
MV2DElementRegistrationPoint mv2d;
MV3DElementRegistrationPoint mv3d;
std::string fileName;
public:
/** ctor */
MMRegistrationPoint(MapLayer* parent, Floorplan::IndoorMap* map, Floorplan::EarthPosMapPos* reg) :
MapModelElement(parent), map(map), reg(reg), mv2d(reg), mv3d(reg) {
;
}
MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;}
MV3DElement* getMV3D() const override {return (MV3DElement*) &mv3d;}
void deleteMe() const override {
;
}
int getNumParams() const override {
return 4;
}
virtual Param getParamDesc(const int idx) const override {
switch (idx) {
case 0: return Param("map", ParamType::POINT3);
case 1: return Param("lat", ParamType::DOUBLE);
case 2: return Param("lon", ParamType::DOUBLE);
case 3: return Param("alt", ParamType::FLOAT);
default: throw 1;
}
}
virtual ParamValue getParamValue(const int idx) const override {
switch(idx) {
case 0: return ParamValue(reg->posOnMap_m);
case 1: return ParamValue(reg->posOnEarth.lat);
case 2: return ParamValue(reg->posOnEarth.lon);
case 3: return ParamValue(reg->posOnEarth.height);
default: throw 1;
}
}
virtual void setParamValue(const int idx, const ParamValue& val) override {
switch (idx) {
case 0: reg->posOnMap_m = val.toPoint3(); break;
case 1: reg->posOnEarth.lat = val.toDouble(); break;
case 2: reg->posOnEarth.lon = val.toDouble(); break;
case 3: reg->posOnEarth.height = val.toFloat(); break;
default: throw 1;
}
}
};
#endif // MMREGISTRATIONPOINT_H

View File

@@ -3,6 +3,7 @@
#include "MapLayer.h"
#include "MMFloors.h"
#include "MMRegistration.h"
#include <Indoor/floorplan/v2/Floorplan.h>
@@ -23,6 +24,7 @@ public:
MMRoot(MapLayer* parent, Floorplan::IndoorMap* map) : MapLayer(parent), map(map) {
// all floors
new MMRegistration(this, map);
new MMFloors(this, map);
}

View File

@@ -13,6 +13,7 @@ class MapModelElement;
enum class MapLayerType {
UNKNOWN,
ROOT,
REGISTRATION,
FLOORS,
FLOOR,
FLOOR_GROUND,

View File

@@ -195,6 +195,21 @@ void ElementParamWidget::refresh() {
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() );
connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
const double 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() );

View File

@@ -13,6 +13,7 @@
#include "../mapview/model/MMFloorAccessPoint.h"
#include "../mapview/model/MMFloorBeacon.h"
#include "../mapview/model/MMFloorGroundTruthPoints.h"
#include "../mapview/model/MMRegistration.h"
#include "../mapview/2D/tools/ToolMeasure.h"
#include "../mapview/2D/tools/ToolSelector.h"
@@ -133,6 +134,15 @@ ToolBoxWidget::ToolBoxWidget(MapView2D* view, QWidget *parent) : QWidget(parent)
// EARTH REGISTRATION
btnEarthReg = new QPushButton(UIHelper::getIcon("registration"), "");
btnEarthReg->setMinimumSize(s,s);
lay->addWidget(btnEarthReg, r++, 0, 1,1,Qt::AlignTop);
connect(btnEarthReg, SIGNAL(clicked(bool)), this, SLOT(onNewEarthReg()));
// what to do when the main-tool is changed
connect(&view->getTools(), SIGNAL(mainToolChanged()), this, SLOT(onMainToolChanged()));
@@ -187,6 +197,8 @@ void ToolBoxWidget::setSelectedLayer(MapLayer *ml) {
btnImage->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_UNDERLAYS));
btnEarthReg->setEnabled(ml && (ml->getLayerType() == MapLayerType::REGISTRATION));
}
@@ -340,6 +352,18 @@ void ToolBoxWidget::onNewGTP() {
}
void ToolBoxWidget::onNewEarthReg() {
const Point2 center = view->getScaler().getCenter();
Floorplan::EarthPosMapPos* reg = new Floorplan::EarthPosMapPos(
EarthPos(50, 10, 300), Point3(center.x, center.y, 0)
);
MMRegistration* mmreg = (MMRegistration*) curLayer;
mmreg->create(reg);
}
void ToolBoxWidget::onNewImage() {
const Point2 center = view->getScaler().getCenter();

View File

@@ -47,7 +47,9 @@ private:
QPushButton* btnBeacon;
QPushButton* btnFingerprintLocation;
QPushButton* btnPOI;
QPushButton* btnGTP;
QPushButton* btnGTP;
QPushButton* btnEarthReg;
QPushButton* btnImage;
@@ -71,6 +73,8 @@ private slots:
void onNewImage();
void onNewEarthReg();
void onMainToolChanged();

View File

@@ -19,5 +19,6 @@
<file>res/icons/ruler.svg</file>
<file>res/icons/fingerprint.svg</file>
<file>res/icons/gtp.svg</file>
<file>res/icons/registration.svg</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 129 129" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 129 129">
<g>
<path d="m10.7,68.6h9c1.9,21.6 19.2,38.8 40.7,40.7v9c0,2.2 1.8,4.1 4.1,4.1 2.2,0 4.1-1.8 4.1-4.1v-9c21.6-1.9 38.8-19.2 40.7-40.7h9c2.2,0 4.1-1.8 4.1-4.1 0-2.2-1.8-4.1-4.1-4.1h-9c-1.9-21.6-19.2-38.8-40.7-40.7v-9c0-2.2-1.8-4.1-4.1-4.1-2.2,0-4.1,1.8-4.1,4.1v9c-21.6,1.9-38.8,19.2-40.7,40.7h-9c-2.3,0-4.1,1.8-4.1,4.1 3.55271e-15,2.3 1.9,4.1 4.1,4.1zm33.7-8.2h-16.5c1.9-17.1 15.5-30.7 32.5-32.5v16.5c0,2.2 1.8,4.1 4.1,4.1 2.2,0 4.1-1.8 4.1-4.1v-16.5c17.1,1.9 30.7,15.5 32.5,32.5h-16.5c-2.2,0-4.1,1.8-4.1,4.1 0,2.2 1.8,4.1 4.1,4.1h16.5c-1.9,17.1-15.5,30.7-32.5,32.5v-16.5c0-2.2-1.8-4.1-4.1-4.1-2.2,0-4.1,1.8-4.1,4.1v16.5c-17.1-1.9-30.7-15.5-32.5-32.5h16.5c2.2,0 4.1-1.8 4.1-4.1 0-2.2-1.9-4.1-4.1-4.1z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 917 B