added earth-registration support
This commit is contained in:
107
mapview/2D/MV2DElementRegistrationPoint.h
Normal file
107
mapview/2D/MV2DElementRegistrationPoint.h
Normal 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
|
||||
34
mapview/3D/MV3DElementRegistrationPoint.h
Normal file
34
mapview/3D/MV3DElementRegistrationPoint.h
Normal 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
|
||||
@@ -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;}
|
||||
|
||||
|
||||
48
mapview/model/MMRegistration.h
Normal file
48
mapview/model/MMRegistration.h
Normal 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
|
||||
78
mapview/model/MMRegistrationPoint.h
Normal file
78
mapview/model/MMRegistrationPoint.h
Normal 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
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ class MapModelElement;
|
||||
enum class MapLayerType {
|
||||
UNKNOWN,
|
||||
ROOT,
|
||||
REGISTRATION,
|
||||
FLOORS,
|
||||
FLOOR,
|
||||
FLOOR_GROUND,
|
||||
|
||||
Reference in New Issue
Block a user