Commit 99d25403 authored by LM's avatar LM

2D map now fully operational

parent 727d7397
......@@ -92,13 +92,8 @@ 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();
}
emit mapChanged();
}
}
void MapGraphicItem::ChildPosRefresh()
......@@ -117,13 +112,8 @@ 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();
}
emit mapChanged();
}
}
void MapGraphicItem::ConstructLastImage(int const& zoomdiff)
......
......@@ -229,6 +229,11 @@ namespace mapcontrol
* @param zoom
*/
void zoomChanged(double zoomtotal,double zoomreal,double zoomdigi);
/**
* @brief Fired when map changes in any visible way
*/
void mapChanged();
};
}
#endif // MAPGRAPHICITEM_H
......@@ -94,8 +94,7 @@ namespace mapcontrol
UAVItem* newUAV = new UAVItem(map,this);
newUAV->setParentItem(map);
UAVS.insert(id, newUAV);
QGraphicsItemGroup* waypointLine = new QGraphicsItemGroup();
waypointLine->setParentItem(map);
QGraphicsItemGroup* waypointLine = new QGraphicsItemGroup(map);
waypointLines.insert(id, waypointLine);
return newUAV;
}
......@@ -103,8 +102,7 @@ namespace mapcontrol
void OPMapWidget::AddUAV(int id, UAVItem* uav)
{
uav->setParentItem(map);
QGraphicsItemGroup* waypointLine = new QGraphicsItemGroup();
waypointLine->setParentItem(map);
QGraphicsItemGroup* waypointLine = new QGraphicsItemGroup(map);
waypointLines.insert(id, waypointLine);
UAVS.insert(id, uav);
}
......
......@@ -17,6 +17,9 @@ WaypointLineItem::WaypointLineItem(WayPointItem* wp1, WayPointItem* wp2, QColor
pen.setWidth(2);
setPen(pen);
point1 = wp1->Coord();
point2 = wp2->Coord();
// Pixel coordinates of the local points
core::Point localPoint1 = map->FromLatLngToLocal(wp1->Coord());
core::Point localPoint2 = map->FromLatLngToLocal(wp2->Coord());
......@@ -33,6 +36,7 @@ WaypointLineItem::WaypointLineItem(WayPointItem* wp1, WayPointItem* wp2, QColor
connect(wp2, SIGNAL(destroyed()), this, SLOT(deleteLater()));
// Map Zoom and move
connect(map, SIGNAL(mapChanged()), this, SLOT(updateWPValues()));
}
void WaypointLineItem::RefreshPos()
......@@ -45,10 +49,13 @@ void WaypointLineItem::RefreshPos()
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());
//QTimer::singleShot(0, this, SLOT(updateWPValues()));
core::Point localPoint1 = map->FromLatLngToLocal(point1);
core::Point localPoint2 = map->FromLatLngToLocal(point2);
if (!localPoint1.IsEmpty() && !localPoint2.IsEmpty())
{
setLine(localPoint1.X(), localPoint1.Y(), localPoint2.X(), localPoint2.Y());
}
}
}
......@@ -63,6 +70,8 @@ void WaypointLineItem::updateWPValues(WayPointItem* waypoint)
else
{
// Set new pixel coordinates based on new global coordinates
point1 = wp1->Coord();
point2 = wp2->Coord();
core::Point localPoint1 = map->FromLatLngToLocal(wp1->Coord());
core::Point localPoint2 = map->FromLatLngToLocal(wp2->Coord());
......@@ -70,6 +79,11 @@ void WaypointLineItem::updateWPValues(WayPointItem* waypoint)
}
}
void WaypointLineItem::updateWPValues()
{
updateWPValues(NULL);
}
int WaypointLineItem::type()const
{
return Type;
......
......@@ -23,6 +23,10 @@ public slots:
void updateWPValues(WayPointItem* waypoint);
/**
* @brief Update waypoint values
*/
void updateWPValues();
/**
* @brief Update waypoint values
*
*/
void RefreshPos();
......
......@@ -112,6 +112,8 @@ HDDisplay::HDDisplay(QStringList* plotList, QString title, QWidget *parent) :
this->setMinimumHeight(125);
this->setMinimumWidth(100);
scalingFactor = this->width()/vwidth;
// Refresh timer
refreshTimer->setInterval(180); //
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(triggerUpdate()));
......
......@@ -147,6 +147,7 @@ HUD::HUD(int width, int height, QWidget* parent)
setMinimumSize(80, 60);
// Set preferred size
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
scalingFactor = this->width()/vwidth;
// Fill with black background
QImage fill = QImage(width, height, QImage::Format_Indexed8);
......@@ -196,8 +197,6 @@ HUD::HUD(int width, int height, QWidget* parent)
createActions();
if (UASManager::instance()->getActiveUAS() != NULL) setActiveUAS(UASManager::instance()->getActiveUAS());
setVisible(false);
}
HUD::~HUD()
......
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