diff --git a/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp b/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp index 9575b890bc7c02290870135aeca6868cd4174754..a54417613fdc424c3301f328571ab4beedf52500 100644 --- a/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp +++ b/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp @@ -92,13 +92,8 @@ namespace mapcontrol GPSItem* wwww=qgraphicsitem_cast(i); if(wwww) wwww->RefreshPos(); - QGraphicsItemGroup* wwwww=qgraphicsitem_cast(i); - if(wwwww) - foreach(QGraphicsItem* i, wwwww->childItems()) - { - WaypointLineItem* line = qgraphicsitem_cast(i); - if (line) line->RefreshPos(); - } + + emit mapChanged(); } } void MapGraphicItem::ChildPosRefresh() @@ -117,13 +112,8 @@ namespace mapcontrol GPSItem* wwww=qgraphicsitem_cast(i); if(wwww) wwww->RefreshPos(); - QGraphicsItemGroup* wwwww=qgraphicsitem_cast(i); - if(wwwww) - foreach(QGraphicsItem* i, wwwww->childItems()) - { - WaypointLineItem* line = qgraphicsitem_cast(i); - if (line) line->RefreshPos(); - } + + emit mapChanged(); } } void MapGraphicItem::ConstructLastImage(int const& zoomdiff) diff --git a/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h b/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h index da846d31a21e0871565296d97a59b89bcd1b2433..96621d059ddd2a7d388edf0f4f81547b1500e41d 100644 --- a/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h +++ b/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h @@ -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 diff --git a/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp b/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp index f8f44e45a046919fc0a60fcf9e3b7a3e395366dd..18258cb8348a9c33354f21060458b6059c361a7e 100644 --- a/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp +++ b/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp @@ -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); } diff --git a/src/libs/opmapcontrol/src/mapwidget/waypointlineitem.cpp b/src/libs/opmapcontrol/src/mapwidget/waypointlineitem.cpp index 4e7605565ce126fccb793eaac01173c72c4a23b7..34811a9a55d3c81e640b8bc1f7b9ad0089732d28 100644 --- a/src/libs/opmapcontrol/src/mapwidget/waypointlineitem.cpp +++ b/src/libs/opmapcontrol/src/mapwidget/waypointlineitem.cpp @@ -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; diff --git a/src/libs/opmapcontrol/src/mapwidget/waypointlineitem.h b/src/libs/opmapcontrol/src/mapwidget/waypointlineitem.h index 807356ece6ce8e403a4efefe9624c0c0f4e585c5..e57a91b6a1e5df72766f9901a413a506dcdb4d1d 100644 --- a/src/libs/opmapcontrol/src/mapwidget/waypointlineitem.h +++ b/src/libs/opmapcontrol/src/mapwidget/waypointlineitem.h @@ -23,6 +23,10 @@ public slots: void updateWPValues(WayPointItem* waypoint); /** * @brief Update waypoint values + */ + void updateWPValues(); + /** + * @brief Update waypoint values * */ void RefreshPos(); diff --git a/src/ui/HDDisplay.cc b/src/ui/HDDisplay.cc index 1fe81518df07663fc4ac2e517810d6df962acc6f..8ee4b3c37964098253fc034ed07eaa3f7be7bf7f 100644 --- a/src/ui/HDDisplay.cc +++ b/src/ui/HDDisplay.cc @@ -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())); diff --git a/src/ui/HUD.cc b/src/ui/HUD.cc index 51001fec5afa0aebf3ecb6542ce21837a5ea1c60..82c68414a6954f84672a6220e40cde48d31f8c81 100644 --- a/src/ui/HUD.cc +++ b/src/ui/HUD.cc @@ -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()