Commit 99d25403 authored by LM's avatar LM

2D map now fully operational

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