1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

LP-498 driveby Bugfix in map waypointitem methodology to "search for the home location"

This commit is contained in:
Eric Price 2017-03-21 10:13:22 +01:00
parent 95fc31a6c8
commit 002b292656
3 changed files with 41 additions and 35 deletions

View File

@ -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);

View File

@ -43,6 +43,7 @@ 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);

View File

@ -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<QGraphicsItem *> list = map->childItems();
foreach(QGraphicsItem * obj, list) {
HomeItem *h = qgraphicsitem_cast <HomeItem *>(obj);
myHome = map->Home;
// QList<QGraphicsItem *> list = map->childItems(); WTF?!?!?!?!????????
// foreach(QGraphicsItem * obj, list) {
// HomeItem *h = qgraphicsitem_cast <HomeItem *>(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<QGraphicsItem *> list = map->childItems();
foreach(QGraphicsItem * obj, list) {
HomeItem *h = qgraphicsitem_cast <HomeItem *>(obj);
myHome = map->Home;
// QList<QGraphicsItem *> list = map->childItems(); WTF?!?!?!?!????????
// foreach(QGraphicsItem * obj, list) {
// HomeItem *h = qgraphicsitem_cast <HomeItem *>(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<QGraphicsItem *> list = map->childItems();
foreach(QGraphicsItem * obj, list) {
HomeItem *h = qgraphicsitem_cast <HomeItem *>(obj);
myHome = map->Home;
// QList<QGraphicsItem *> list = map->childItems(); WTF?!?!?!?!????????
// foreach(QGraphicsItem * obj, list) {
// HomeItem *h = qgraphicsitem_cast <HomeItem *>(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<QGraphicsItem *> list = map->childItems();
foreach(QGraphicsItem * obj, list) {
HomeItem *h = qgraphicsitem_cast <HomeItem *>(obj);
myHome = map->Home;
// QList<QGraphicsItem *> list = map->childItems(); WTF?!?!?!?!????????
// foreach(QGraphicsItem * obj, list) {
// HomeItem *h = qgraphicsitem_cast <HomeItem *>(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);