Commit 727d7397 authored by lm's avatar lm

Working towards correct line updates - not tested yet, might create runtime issues

parent 0b385b47
......@@ -28,6 +28,7 @@
#include "gpsitem.h"
#include "homeitem.h"
#include "mapgraphicitem.h"
#include "waypointlineitem.h"
namespace mapcontrol
{
......@@ -91,6 +92,13 @@ namespace mapcontrol
GPSItem* wwww=qgraphicsitem_cast<GPSItem*>(i);
if(wwww)
wwww->RefreshPos();
QGraphicsItemGroup* wwwww=qgraphicsitem_cast<QGraphicsItemGroup*>(i);
if(wwwww)
foreach(QGraphicsItem* i, wwwww->childItems())
{
WaypointLineItem* line = qgraphicsitem_cast<WaypointLineItem*>(i);
if (line) line->RefreshPos();
}
}
}
void MapGraphicItem::ChildPosRefresh()
......@@ -109,6 +117,13 @@ namespace mapcontrol
GPSItem* wwww=qgraphicsitem_cast<GPSItem*>(i);
if(wwww)
wwww->RefreshPos();
QGraphicsItemGroup* wwwww=qgraphicsitem_cast<QGraphicsItemGroup*>(i);
if(wwwww)
foreach(QGraphicsItem* i, wwwww->childItems())
{
WaypointLineItem* line = qgraphicsitem_cast<WaypointLineItem*>(i);
if (line) line->RefreshPos();
}
}
}
void MapGraphicItem::ConstructLastImage(int const& zoomdiff)
......
......@@ -35,6 +35,23 @@ WaypointLineItem::WaypointLineItem(WayPointItem* wp1, WayPointItem* wp2, QColor
// Map Zoom and move
}
void WaypointLineItem::RefreshPos()
{
// Delete if either waypoint got deleted
if (!wp1 || !wp2)
{
this->deleteLater();
}
else
{
// Set new pixel coordinates based on new global coordinates
core::Point localPoint1 = map->FromLatLngToLocal(wp1->Coord());
core::Point localPoint2 = map->FromLatLngToLocal(wp2->Coord());
setLine(localPoint1.X(), localPoint1.Y(), localPoint2.X(), localPoint2.Y());
}
}
void WaypointLineItem::updateWPValues(WayPointItem* waypoint)
{
Q_UNUSED(waypoint);
......
......@@ -21,6 +21,11 @@ public slots:
* @param waypoint The waypoint object that just changed
*/
void updateWPValues(WayPointItem* waypoint);
/**
* @brief Update waypoint values
*
*/
void RefreshPos();
protected:
internals::PointLatLng point1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment