diff --git a/IndoorMap.pro b/IndoorMap.pro index 58812b1..cf39935 100644 --- a/IndoorMap.pro +++ b/IndoorMap.pro @@ -22,12 +22,12 @@ INCLUDEPATH += \ SOURCES += \ - lib/gpc/gpc.cpp \ - main.cpp \ - MainWindow.cpp \ + lib/gpc/gpc.cpp \ + main.cpp \ + MainWindow.cpp \ MainController.cpp \ - mapview/2D/tools/ToolSelector.cpp \ - mapview/2D/tools/Tool.cpp \ + mapview/2D/tools/ToolSelector.cpp \ + mapview/2D/tools/Tool.cpp \ mapview/MapView2D.cpp \ params/ElementParamWidget.cpp \ params/LayerParamWidget.cpp \ @@ -35,7 +35,7 @@ SOURCES += \ params/ToolBox.cpp \ mapview/model/MapModel.cpp \ tree/MapTreeModel.cpp \ - mapview/3D/MapView3D.cpp \ + mapview/3D/MapView3D.cpp \ params/StairBuilder.cpp \ mapview/2D/tools/Tools.cpp \ params/LayerTree.cpp \ @@ -62,24 +62,24 @@ HEADERS += MainWindow.h \ mapview/model/IHasName.h \ mapview/model/IHasObstacleType.h \ mapview/model/IHasPosition3D.h \ - mapview/2D/MV2DElementFloorObstacleLine.h \ - mapview/2D/MV2DElement.h \ - mapview/2D/MV2DElementFloorOutlinePolygon.h \ - mapview/2D/MV2DElementBeacon.h \ - mapview/2D/MV2DElementAccessPoint.h \ - mapview/2D/MV2DElementFloorObstacleCircle.h \ - mapview/2D/MV2DElementFloorObstacleDoor.h \ - mapview/2D/MapViewElementHelper.h \ - mapview/2D/MV2DElementFloorUnderlay.h \ - mapview/2D/MV2DElementPOI.h \ - mapview/2D/MV2DElementStair.h \ - mapview/2D/tools/ToolMoveMap.h \ - mapview/2D/tools/Tools.h \ - mapview/2D/tools/ToolRuler.h \ - mapview/2D/tools/ToolMapZoom.h \ - mapview/2D/tools/ToolSelector.h \ - mapview/2D/tools/ToolMapGrid.h \ - mapview/2D/tools/Tool.h \ + mapview/2D/MV2DElementFloorObstacleLine.h \ + mapview/2D/MV2DElement.h \ + mapview/2D/MV2DElementFloorOutlinePolygon.h \ + mapview/2D/MV2DElementBeacon.h \ + mapview/2D/MV2DElementAccessPoint.h \ + mapview/2D/MV2DElementFloorObstacleCircle.h \ + mapview/2D/MV2DElementFloorObstacleDoor.h \ + mapview/2D/MapViewElementHelper.h \ + mapview/2D/MV2DElementFloorUnderlay.h \ + mapview/2D/MV2DElementPOI.h \ + mapview/2D/MV2DElementStair.h \ + mapview/2D/tools/ToolMoveMap.h \ + mapview/2D/tools/Tools.h \ + mapview/2D/tools/ToolRuler.h \ + mapview/2D/tools/ToolMapZoom.h \ + mapview/2D/tools/ToolSelector.h \ + mapview/2D/tools/ToolMapGrid.h \ + mapview/2D/tools/Tool.h \ mapview/model/MMFloorObstacleCircle.h \ mapview/model/MMFloorObstacleLine.h \ mapview/model/MMFloorOutlinePolygon.h \ @@ -109,7 +109,7 @@ HEADERS += MainWindow.h \ mapview/3D/misc/Polygon.h \ mapview/grid/MapView3DGrid.h \ mapview/grid/MapModelGrid.h \ - mapview/3DGrid/GridModel.h \ + mapview/3DGrid/GridModel.h \ mapview/3DGrid/GridRenderer.h \ mapview/3DGrid/MyNode.h \ mapview/3D/MV3DElementStair.h \ @@ -126,8 +126,8 @@ HEADERS += MainWindow.h \ mapview/3D/misc/Plane.h \ mapview/elements/HasMoveableNodes.h \ mapview/2D/MapView2D.h \ - mapview/2D/Painter.h \ - mapview/2D/Scaler.h \ + mapview/2D/Painter.h \ + mapview/2D/Scaler.h \ mapview/2D/MV2DElementElevator.h \ mapview/model/MMFloorElevators.h \ mapview/model/MMFloorElevator.h \ @@ -140,7 +140,7 @@ HEADERS += MainWindow.h \ params/MetaEditModel.h \ mapview/model/MapLayerListener.h \ mapview/model/MapModelListener.h \ - mapview/model/MMFloorOutlinePolygonCombined.h\ + mapview/model/MMFloorOutlinePolygonCombined.h \ mapview/model/MMFloorGroundTruthPoints.h \ mapview/model/MMFloorGroundTruthPoint.h \ mapview/2D/MV2DElementGroundTruthPoint.h diff --git a/MainController.cpp b/MainController.cpp index cd567b2..92e438a 100644 --- a/MainController.cpp +++ b/MainController.cpp @@ -93,76 +93,91 @@ MainController::MainController() { connect(mw, &MainWindow::onGridShowEdges, [&] (const bool show) {mw->getMapView3D()->getGridRenderer()->setShowEdges(show);} ); - mapModel->load("../IndoorMap/maps/SHL26.xml"); + //mapModel->load("../IndoorMap/maps/SHL26.xml"); //mapModel->load("../IndoorMap/maps/test.xml"); //mapModel->load("../IndoorMap/maps/APs.xml"); //mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/CAR/CAR9.xml"); - mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UAH/UAH9.xml"); + //mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UAH/UAH9.xml"); //mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UJI-TI/UJI-TI4.xml"); //mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UJI-UB/UJI-UB4.xml"); //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(); } +void MainController::onLayerChanged(MapLayer* layer) { + (void) layer; + mw->getMapView2D()->update(); + mw->getMapView3D()->update(); +} + +void MainController::onLayerElementAdded(MapLayer* layer, MapModelElement* elem) { + (void) layer; + mapSelector->focus(mw->getMapView2D(), elem); +} + +void MainController::onLayerElementRemoved(MapLayer* layer, const MapModelElement* elem) { + (void) layer; + (void) elem; +} + +void MainController::onLayerVisibilityChanged(MapLayer *layer, const bool visible) { + (void) layer; + (void) visible; +} + void MainController::onShow3DFloorplan() { - mw->getMapView3D()->showFloorplan(); + mw->getMapView3D()->showFloorplan(); } void MainController::onShow3DGrid() { - mw->getMapView3D()->showGrid(); + mw->getMapView3D()->showGrid(); } void MainController::layerSelected(QModelIndex idx) { - mw->getMapView2D()->layerChange(); - MapLayer* ml = static_cast(idx.internalPointer()); - mapModel->setSelectedLayer(ml); - mw->getMapView2D()->layerChange(); - mw->getMapView3D()->layerChange(); - mw->getLayerParamWidget()->setElement(ml); - mw->getToolBoxWidget()->setSelectedLayer(ml); + mw->getMapView2D()->layerChange(); + MapLayer* ml = static_cast(idx.internalPointer()); + mapModel->setSelectedLayer(ml); + mw->getMapView2D()->layerChange(); + mw->getMapView3D()->layerChange(); + mw->getLayerParamWidget()->setElement(ml); + mw->getToolBoxWidget()->setSelectedLayer(ml); } - void MainController::curMapElementChanged() { - mw->getElementParamWidget()->refresh(); + mw->getElementParamWidget()->refresh(); } void MainController::mapElementSelected(MapModelElement* el) { - mw->getElementParamWidget()->setElement(el); + mw->getElementParamWidget()->setElement(el); } void MainController::onMapModelAboutToReset() { - mw->getLayerParamWidget()->setElement(nullptr); - mw->getToolBoxWidget()->setSelectedLayer(nullptr); - mw->getMapView2D()->update(); + mw->getLayerParamWidget()->setElement(nullptr); + mw->getToolBoxWidget()->setSelectedLayer(nullptr); + mw->getMapView2D()->update(); } void MainController::onMapModelNeedsRepaint() { - mw->getMapView2D()->update(); + mw->getMapView2D()->update(); } void MainController::onMapModelReset() { - mw->getTree()->expandAll(); + mw->getTree()->expandAll(); } void MainController::onLoad() { - - QString file = QFileDialog::getOpenFileName(mw, "open a map"); - if (file != "") { - mapModel->load(file.toStdString()); - } + QString file = QFileDialog::getOpenFileName(mw, "open a map"); + if (file != "") { + mapModel->load(file.toStdString()); + } } void MainController::onSave() { - - QString file = QFileDialog::getSaveFileName(mw, "save the map"); - if (file != "") { - mapModel->save(file.toStdString()); - } - + QString file = QFileDialog::getSaveFileName(mw, "save the map"); + if (file != "") { + mapModel->save(file.toStdString()); + } } - - diff --git a/mapview/2D/MV2DElementGroundTruthPoint.h b/mapview/2D/MV2DElementGroundTruthPoint.h index 7821366..39631cf 100644 --- a/mapview/2D/MV2DElementGroundTruthPoint.h +++ b/mapview/2D/MV2DElementGroundTruthPoint.h @@ -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(gtp->pos); + ClickDist getMinDistanceXY(const Point2 p) const override { + return ClickDist(p.getDistance(gtp->pos), ClickDistType::DIRECT); } /** repaint me */ diff --git a/mapview/model/MMFloorGroundTruthPoints.h b/mapview/model/MMFloorGroundTruthPoints.h index 48831b7..38ec3a6 100644 --- a/mapview/model/MMFloorGroundTruthPoints.h +++ b/mapview/model/MMFloorGroundTruthPoints.h @@ -20,7 +20,7 @@ public: // the POIs for (Floorplan::GroundTruthPoint* gtp : floor->gtpoints) { - elements.push_back(new MMFloorGroundTruthPoint(this, floor, gtp)); + addElement(new MMFloorGroundTruthPoint(this, floor, gtp)); } } @@ -35,7 +35,7 @@ public: floor->gtpoints.push_back(gtp); // add to myself as element - elements.push_back(new MMFloorGroundTruthPoint(this, floor, gtp)); + addElement(new MMFloorGroundTruthPoint(this, floor, gtp)); }