From 002b292656530a5c035739f036001917a95df09a Mon Sep 17 00:00:00 2001 From: Eric Price Date: Tue, 21 Mar 2017 10:13:22 +0100 Subject: [PATCH] LP-498 driveby Bugfix in map waypointitem methodology to "search for the home location" --- .../opmapcontrol/src/mapwidget/mapgraphicitem.h | 6 +- .../opmapcontrol/src/mapwidget/opmapwidget.cpp | 3 +- .../opmapcontrol/src/mapwidget/waypointitem.cpp | 67 +++++++++++----------- 3 files changed, 41 insertions(+), 35 deletions(-) diff --git a/ground/gcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h b/ground/gcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h index f14c43fbc..11e778e8a 100644 --- a/ground/gcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h +++ b/ground/gcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h @@ -2,7 +2,8 @@ ****************************************************************************** * * @file mapgraphicitem.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @brief The main graphicsItem used on the widget, contains the map and map logic * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -43,6 +44,7 @@ namespace mapcontrol { class WayPointItem; class OPMapWidget; +class HomeItem; /** * @brief The main graphicsItem used on the widget, contains the map and map logic * @@ -105,6 +107,8 @@ public: double ZoomDigi(); double ZoomTotal(); void setOverlayOpacity(qreal value); + + HomeItem *Home; protected: void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); diff --git a/ground/gcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp b/ground/gcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp index c9095b74f..ea1301a24 100644 --- a/ground/gcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp +++ b/ground/gcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp @@ -43,9 +43,10 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView mscene.addItem(map); this->setScene(&mscene); Home = new HomeItem(map, this); + map->Home = Home; Home->setParentItem(map); Home->setZValue(-1); - Nav = new NavItem(map, this); + Nav = new NavItem(map, this); Nav->setParentItem(map); Nav->setZValue(-1); setStyleSheet("QToolTip {font-size:8pt; color:blue;opacity: 223; padding:2px; border-width:2px; border-style:solid; border-color: rgb(170, 170, 127);border-radius:4px }"); diff --git a/ground/gcs/src/libs/opmapcontrol/src/mapwidget/waypointitem.cpp b/ground/gcs/src/libs/opmapcontrol/src/mapwidget/waypointitem.cpp index 7a187685c..25c5810a2 100644 --- a/ground/gcs/src/libs/opmapcontrol/src/mapwidget/waypointitem.cpp +++ b/ground/gcs/src/libs/opmapcontrol/src/mapwidget/waypointitem.cpp @@ -2,7 +2,8 @@ ****************************************************************************** * * @file waypointitem.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @brief A graphicsItem representing a WayPoint * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -43,15 +44,15 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & alti SetShowNumber(shownumber); RefreshToolTip(); RefreshPos(); - myHome = NULL; - QList list = map->childItems(); - foreach(QGraphicsItem * obj, list) { - HomeItem *h = qgraphicsitem_cast (obj); + myHome = map->Home; + // QList list = map->childItems(); WTF?!?!?!?!???????? + // foreach(QGraphicsItem * obj, list) { + // HomeItem *h = qgraphicsitem_cast (obj); - if (h) { - myHome = h; - } - } + // if (h) { + // myHome = h; + // } + // } if (myHome) { map->Projection()->offSetFromLatLngs(myHome->Coord(), coord, relativeCoord.distance, relativeCoord.bearing); @@ -87,15 +88,15 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint) : reached(fa SetShowNumber(shownumber); RefreshToolTip(); RefreshPos(); - myHome = NULL; - QList list = map->childItems(); - foreach(QGraphicsItem * obj, list) { - HomeItem *h = qgraphicsitem_cast (obj); + myHome = map->Home; + // QList list = map->childItems(); WTF?!?!?!?!???????? + // foreach(QGraphicsItem * obj, list) { + // HomeItem *h = qgraphicsitem_cast (obj); - if (h) { - myHome = h; - } - } + // if (h) { + // myHome = h; + // } + // } if (myHome) { coord = map->Projection()->translate(myHome->Coord(), relativeCoord.distance, relativeCoord.bearing); @@ -121,15 +122,15 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & alti SetShowNumber(shownumber); RefreshToolTip(); RefreshPos(); - myHome = NULL; - QList list = map->childItems(); - foreach(QGraphicsItem * obj, list) { - HomeItem *h = qgraphicsitem_cast (obj); + myHome = map->Home; + // QList list = map->childItems(); WTF?!?!?!?!???????? + // foreach(QGraphicsItem * obj, list) { + // HomeItem *h = qgraphicsitem_cast (obj); - if (h) { - myHome = h; - } - } + // if (h) { + // myHome = h; + // } + // } if (myHome) { map->Projection()->offSetFromLatLngs(myHome->Coord(), coord, relativeCoord.distance, relativeCoord.bearing); relativeCoord.altitudeRelative = Altitude() - myHome->Altitude(); @@ -143,15 +144,15 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & alti WayPointItem::WayPointItem(const distBearingAltitude &relativeCoordenate, const QString &description, MapGraphicItem *map) : relativeCoord(relativeCoordenate), reached(false), description(description), shownumber(true), isDragging(false), map(map) { - myHome = NULL; - QList list = map->childItems(); - foreach(QGraphicsItem * obj, list) { - HomeItem *h = qgraphicsitem_cast (obj); + myHome = map->Home; + // QList list = map->childItems(); WTF?!?!?!?!???????? + // foreach(QGraphicsItem * obj, list) { + // HomeItem *h = qgraphicsitem_cast (obj); - if (h) { - myHome = h; - } - } + // if (h) { + // myHome = h; + // } + // } if (myHome) { connect(myHome, SIGNAL(homePositionChanged(internals::PointLatLng, float)), this, SLOT(onHomePositionChanged(internals::PointLatLng, float))); coord = map->Projection()->translate(myHome->Coord(), relativeCoord.distance, relativeCoord.bearing); -- 2.11.4.GIT