diff --git a/IndoorMap.pro b/IndoorMap.pro index 5f17cf7..df031da 100644 --- a/IndoorMap.pro +++ b/IndoorMap.pro @@ -140,7 +140,11 @@ HEADERS += MainWindow.h \ params/MetaEditModel.h \ mapview/model/MapLayerListener.h \ mapview/model/MapModelListener.h \ - mapview/model/MMFloorOutlinePolygonCombined.h + mapview/model/MMFloorOutlinePolygonCombined.h \ + mapview/model/MMFloorFingerprints.h \ + mapview/model/MMFloorFingerprintLocation.h \ + mapview/2D/MV2DElementFingerprintLocation.h \ + mapview/3D/MV3DElementFingerprintLocation.h FORMS += MainWindow.ui diff --git a/MainController.cpp b/MainController.cpp index b83a518..e389245 100644 --- a/MainController.cpp +++ b/MainController.cpp @@ -93,7 +93,7 @@ MainController::MainController() { connect(mw, &MainWindow::onGridShowEdges, [&] (const bool show) {mw->getMapView3D()->getGridRenderer()->setShowEdges(show);} ); - mapModel->load("../IndoorMap/maps/SHL26.xml"); + mapModel->load("../IndoorMap/maps/SHL28.xml"); //mapModel->load("../IndoorMap/maps/test.xml"); //mapModel->load("../IndoorMap/maps/APs.xml"); diff --git a/mapview/2D/MV2DElementFingerprintLocation.h b/mapview/2D/MV2DElementFingerprintLocation.h new file mode 100644 index 0000000..5a978d3 --- /dev/null +++ b/mapview/2D/MV2DElementFingerprintLocation.h @@ -0,0 +1,91 @@ +#ifndef MV2DELEMENTFINGERPRINTLOCATION_H +#define MV2DELEMENTFINGERPRINTLOCATION_H + + +#include "MV2DElement.h" +#include "HasMoveableNodes.h" + +#include "MapViewElementHelper.h" +#include + +#include "../../UIHelper.h" + +class MV2DElementFingerprintLocation : public MV2DElement, public HasMoveableNodes { + +private: + + Floorplan::FingerprintLocation* fpl; + +public: + + /** ctor with the AP to render/edit */ + MV2DElementFingerprintLocation(Floorplan::FingerprintLocation* fpl) : fpl(fpl) {;} + + + /** get the element's 2D bounding box */ + BBox2 getBoundingBox() const override { + BBox2 bbox; + bbox.add(Point2(fpl->posOnFloor.x, fpl->posOnFloor.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(fpl->posOnFloor), ClickDistType::DIRECT); + } + + /** repaint me */ + void paint(Painter& p) override { + + static const QPixmap& pixmapUnfocused = UIHelper::getPixmapColored("fingerprint", CFG::UNFOCUS_COLOR, 16); + static const QPixmap& pixmapFocused = UIHelper::getPixmapColored("fingerprint", CFG::FOCUS_COLOR, 16); + static const QPixmap& pixmapSel = UIHelper::getPixmapColored("fingerprint", CFG::SEL_COLOR, 16); + + + if (selectedUserIdx == 0) { + //p.setPenBrush(Qt::black, CFG::SEL_COLOR); + //p.drawCircle(ap->pos.xy()); + p.drawPixmap(fpl->posOnFloor, pixmapSel); + } else if (hasFocus()) { + //p.setPenBrush(Qt::black, Qt::NoBrush); + //p.drawCircle(ap->pos.xy()); + p.drawPixmap(fpl->posOnFloor, pixmapFocused); + } else { + //p.setPenBrush(Qt::gray, Qt::NoBrush); + //p.drawCircle(ap->pos.xy()); + p.drawPixmap(fpl->posOnFloor, pixmapUnfocused); + } + + // label + p.setPenBrush(Qt::black, Qt::NoBrush); + p.drawDot(fpl->posOnFloor); + + if (p.getScaler().getScale() >= 10) { + const std::string str = fpl->name; + p.p->drawText(p.getScaler().xms(fpl->posOnFloor.x) + 10, p.getScaler().yms(fpl->posOnFloor.y) + 5, str.c_str()); + } + + } + + virtual std::vector getMoveableNodes() const override { + return { MoveableNode(0, fpl->posOnFloor) }; + } + + virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) v; + if (userIdx == 0) {fpl->posOnFloor = newPos;} + } + + virtual void onFocus() override { + ; + } + + virtual void onUnfocus() override { + ; + } + +}; + + +#endif // MV2DELEMENTFINGERPRINTLOCATION_H diff --git a/mapview/3D/MV3DElementAccessPoint.h b/mapview/3D/MV3DElementAccessPoint.h index 45af97e..54cfff5 100644 --- a/mapview/3D/MV3DElementAccessPoint.h +++ b/mapview/3D/MV3DElementAccessPoint.h @@ -25,6 +25,7 @@ protected: void paintGL() override { Cube cube(ap->getPos(f), 0.25); + glColor3f(0,0,1); cube.paintGL(); } diff --git a/mapview/3D/MV3DElementFingerprintLocation.h b/mapview/3D/MV3DElementFingerprintLocation.h new file mode 100644 index 0000000..e39102e --- /dev/null +++ b/mapview/3D/MV3DElementFingerprintLocation.h @@ -0,0 +1,36 @@ +#ifndef MV3DELEMENTFINGERPRINTLOCATION_H +#define MV3DELEMENTFINGERPRINTLOCATION_H + + +#include + +#include "misc/Cube.h" +#include "MV3DElement.h" + +class MV3DElementFingerprintLocation : public MV3DElement { + + Floorplan::Floor* f; + Floorplan::FingerprintLocation* fpl; + +public: + + /** ctor */ + MV3DElementFingerprintLocation(Floorplan::Floor* f, Floorplan::FingerprintLocation* fpl) : f(f), fpl(fpl) { + ; + } + +protected: + + + /** repaint me */ + void paintGL() override { + + Cube cube(fpl->getPosition(*f), 0.15); + glColor3f(1,0,1); + cube.paintGL(); + + } + +}; + +#endif // MV3DELEMENTFINGERPRINTLOCATION_H diff --git a/mapview/3D/misc/Cube.h b/mapview/3D/misc/Cube.h index 7819a32..748a08a 100644 --- a/mapview/3D/misc/Cube.h +++ b/mapview/3D/misc/Cube.h @@ -25,8 +25,6 @@ public: glPushMatrix(); glTranslatef(pos.x, pos.z, pos.y); - glColor3f(0,0,1); - glBegin(GL_QUADS); // bottom diff --git a/mapview/model/MMFloor.h b/mapview/model/MMFloor.h index 8551ebe..3f2218a 100644 --- a/mapview/model/MMFloor.h +++ b/mapview/model/MMFloor.h @@ -6,6 +6,7 @@ #include "MMFloorObstacles.h" #include "MMFloorAccessPoints.h" #include "MMFloorBeacons.h" +#include "MMFloorFingerprints.h" #include "MMFloorUnderlays.h" #include "MMFloorPOIs.h" #include "MMFloorStairs.h" @@ -40,6 +41,7 @@ public: new MMFloorObstacles(this, floor); new MMFloorAccessPoints(this, floor); new MMFloorBeacons(this, floor); + new MMFloorFingerprints(this, floor); new MMFloorPOIs(this, floor); new MMFloorStairs(this, floor); new MMFloorElevators(this, floor); diff --git a/mapview/model/MMFloorFingerprintLocation.h b/mapview/model/MMFloorFingerprintLocation.h new file mode 100644 index 0000000..eeac267 --- /dev/null +++ b/mapview/model/MMFloorFingerprintLocation.h @@ -0,0 +1,78 @@ +#ifndef MMFLOORFINGERPRINTLOCATIONS_H +#define MMFLOORFINGERPRINTLOCATIONS_H + + +#include "MapModelElement.h" +#include "IHasParams.h" +#include "IHasEditableMeta.h" + +#include "../2D/MV2DElementFingerprintLocation.h" +#include "../3D/MV3DElementFingerprintLocation.h" + +#include + +class MMFloorFingerprintLocation : public MapModelElement, public IHasParams, public IHasEditableMeta { + +private: + + Floorplan::Floor* floor; + Floorplan::FingerprintLocation* fpl; + MV2DElementFingerprintLocation mv2d; + MV3DElementFingerprintLocation mv3d; + +public: + + MMFloorFingerprintLocation(MapLayer* parent, Floorplan::Floor* floor, Floorplan::FingerprintLocation* fpl) : + MapModelElement(parent), floor(floor), fpl(fpl), mv2d(fpl), mv3d(floor, fpl) { + + } + + virtual int getNumParams() const override { + return 3; + } + + virtual Param getParamDesc(const int idx) const override { + switch(idx) { + case 0: return Param("name", ParamType::STRING); + case 1: return Param("Position", ParamType::POINT2); + case 2: return Param("at height", ParamType::FLOAT); + } + throw 1; + } + + virtual ParamValue getParamValue(const int idx) const override { + switch(idx) { + case 0: return fpl->name; + case 1: return fpl->posOnFloor; + case 2: return fpl->heightAboveFloor; + } + throw 1; + } + + virtual void setParamValue(const int idx, const ParamValue& val) const override { + switch(idx) { + case 0: fpl->name = val.toString(); break; + case 1: fpl->posOnFloor = val.toPoint2(); break; + case 2: fpl->heightAboveFloor = val.toFloat(); break; + } + } + + virtual Floorplan::Meta* getMeta() override { + return fpl->getMeta(); + } + + virtual void setMeta(Floorplan::Meta* meta) override { + fpl->setMeta(meta); + } + + MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;} + MV3DElement* getMV3D() const override {return (MV3DElement*) &mv3d;} + + void deleteMe() const override { + parent->removeElement(this); + floor->fpLocations.erase(std::remove(floor->fpLocations.begin(), floor->fpLocations.end(), fpl), floor->fpLocations.end()); + } + +}; + +#endif // MMFLOORFINGERPRINTLOCATIONS_H diff --git a/mapview/model/MMFloorFingerprints.h b/mapview/model/MMFloorFingerprints.h new file mode 100644 index 0000000..39e1a2d --- /dev/null +++ b/mapview/model/MMFloorFingerprints.h @@ -0,0 +1,51 @@ +#ifndef MMFLOORFINGERPRINTS_H +#define MMFLOORFINGERPRINTS_H + + +#include "MapLayer.h" +#include "MMFloorFingerprintLocation.h" + +#include + +/** + * layer that contains all of one floor's fingerprints: + * locations, measurements?, other? + */ +class MMFloorFingerprints : public MapLayer { + + Floorplan::Floor* floor; + +public: + + /** ctor with the floor */ + MMFloorFingerprints(MapLayer* parent, Floorplan::Floor* floor) : MapLayer(parent, MapLayerType::FLOOR_FINGERPRINTS), floor(floor) { + + // the obstacles + for (Floorplan::FingerprintLocation* fpl : floor->fpLocations) { + addElement(new MMFloorFingerprintLocation(this, floor, fpl)); + } + + } + + /** get the corresponding floor from the underlying model */ + Floorplan::Floor* getFloor() {return floor;} + + //TODO: check + MMFloorFingerprintLocation* create(Floorplan::FingerprintLocation* fpl) { + + // add to underlying model + floor->fpLocations.push_back(fpl); + + // add to myself as element + MMFloorFingerprintLocation* mm = new MMFloorFingerprintLocation(this, floor, fpl); + addElement(mm); + return mm; + + } + + std::string getLayerName() const override {return "fingerprints";} + +}; + + +#endif // MMFLOORFINGERPRINTS_H diff --git a/mapview/model/MapLayer.h b/mapview/model/MapLayer.h index 832502e..6251262 100644 --- a/mapview/model/MapLayer.h +++ b/mapview/model/MapLayer.h @@ -19,6 +19,7 @@ enum class MapLayerType { FLOOR_OBSTACLES, FLOOR_BEACONS, FLOOR_ACCESS_POINTS, + FLOOR_FINGERPRINTS, FLOOR_ELEVATORS, FLOOR_UNDERLAYS, FLOOR_POIS, diff --git a/params/ToolBox.cpp b/params/ToolBox.cpp index 9266281..ba2cbf9 100644 --- a/params/ToolBox.cpp +++ b/params/ToolBox.cpp @@ -99,6 +99,12 @@ ToolBoxWidget::ToolBoxWidget(MapView2D* view, QWidget *parent) : QWidget(parent) lay->addWidget(btnBeacon, r++, 0, 1,1,Qt::AlignTop); connect(btnBeacon, SIGNAL(clicked(bool)), this, SLOT(onNewBeacon())); + // TRANSMITTER RELATED + btnFingerprintLocation = new QPushButton(UIHelper::getIcon("fingerprint"), ""); + btnFingerprintLocation->setMinimumSize(s,s); + lay->addWidget(btnFingerprintLocation, r++, 0, 1,1,Qt::AlignTop); + connect(btnFingerprintLocation, SIGNAL(clicked(bool)), this, SLOT(onNewFingerprintLocation())); + // IMAGES btnImage = new QPushButton(UIHelper::getIcon("image"), ""); btnImage->setMinimumSize(s,s); @@ -134,6 +140,7 @@ void ToolBoxWidget::setSelectedLayer(MapLayer *ml) { btnWifi->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_ACCESS_POINTS)); btnBeacon->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_BEACONS)); + btnFingerprintLocation->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_FINGERPRINTS)); btnPOI->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_POIS)); btnImage->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_UNDERLAYS)); @@ -464,6 +471,18 @@ void ToolBoxWidget::onNewBeacon() { } +void ToolBoxWidget::onNewFingerprintLocation() { + + const Point2 center = view->getScaler().getCenter(); + Floorplan::FingerprintLocation* fpl = new Floorplan::FingerprintLocation("noname", center, 0); + + MMFloorFingerprints* fps = (MMFloorFingerprints*) curLayer; + fps->create(fpl); + +} + + + void ToolBoxWidget::onNewPOI() { const Point2 center = view->getScaler().getCenter(); diff --git a/params/ToolBoxWidget.h b/params/ToolBoxWidget.h index 4814f1b..37b4bfc 100644 --- a/params/ToolBoxWidget.h +++ b/params/ToolBoxWidget.h @@ -45,6 +45,7 @@ private: QPushButton* btnWifi; QPushButton* btnBeacon; + QPushButton* btnFingerprintLocation; QPushButton* btnPOI; QPushButton* btnImage; @@ -63,6 +64,7 @@ private slots: void onNewAccessPoint(); void onNewBeacon(); + void onNewFingerprintLocation(); void onNewPOI(); void onNewImage(); diff --git a/res.qrc b/res.qrc index e7ab3e0..babfafb 100644 --- a/res.qrc +++ b/res.qrc @@ -17,5 +17,6 @@ res/icons/add.svg res/icons/remove.svg res/icons/ruler.svg + res/icons/fingerprint.svg diff --git a/res/icons/fingerprint.svg b/res/icons/fingerprint.svg new file mode 100644 index 0000000..4d4a0c0 --- /dev/null +++ b/res/icons/fingerprint.svg @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +