From d22409fdb45767685c0cf2eea9f9f152da9e380e Mon Sep 17 00:00:00 2001 From: Mariano Lizarraga Date: Tue, 7 Dec 2010 15:15:59 -0600 Subject: [PATCH] Fixed bug in collecting global waypoints from the autopilot --- src/ui/MapWidget.cc | 14 ++++++++++++++ src/ui/MapWidget.h | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ui/MapWidget.cc b/src/ui/MapWidget.cc index 5d1fa5e..1f244dd 100644 --- a/src/ui/MapWidget.cc +++ b/src/ui/MapWidget.cc @@ -407,6 +407,7 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina void MapWidget::createWaypointGraphAtMap(const QPointF coordinate) { + if (!wpExists(coordinate)){ // Create waypoint name QString str; @@ -425,6 +426,8 @@ void MapWidget::createWaypointGraphAtMap(const QPointF coordinate) { tempCirclePoint = new Waypoint2DIcon(coordinate.x(), coordinate.y(), 20, str, qmapcontrol::Point::Middle); } + + mc->layer("Waypoints")->addGeometry(tempCirclePoint); Point* tempPoint = new Point(coordinate.x(), coordinate.y(),str); @@ -436,11 +439,22 @@ void MapWidget::createWaypointGraphAtMap(const QPointF coordinate) // Refresh the screen mc->updateRequestNew(); + } //// // emit signal mouse was clicked // emit captureMapCoordinateClick(coordinate); } +int MapWidget::wpExists(const QPointF coordinate){ + for (int i = 0; i < wps.size(); i++){ + if (wps.at(i)->latitude() == coordinate.y() && + wps.at(i)->longitude()== coordinate.x()){ + return 1; + } + } + return 0; +} + void MapWidget::captureGeometryClick(Geometry* geom, QPoint point) { diff --git a/src/ui/MapWidget.h b/src/ui/MapWidget.h index dd94190..66125a4 100644 --- a/src/ui/MapWidget.h +++ b/src/ui/MapWidget.h @@ -144,7 +144,7 @@ private: QHash wpIndex; qmapcontrol::LineString* path; QPen* pointPen; - + int wpExists(const QPointF coordinate); bool waypointIsDrag;