diff --git a/src/ui/map3D/GLOverlayGeode.cc b/src/ui/map3D/GLOverlayGeode.cc index b92556c0d72de6b4ce3999d87d6303828088d657..fdf183788007c02e29539944dcd583b9e10eb111 100644 --- a/src/ui/map3D/GLOverlayGeode.cc +++ b/src/ui/map3D/GLOverlayGeode.cc @@ -2,6 +2,7 @@ GLOverlayGeode::GLOverlayGeode() : mDrawable(new GLOverlayDrawable) + , mMessageTimestamp(0.0) { addDrawable(mDrawable); } @@ -21,6 +22,18 @@ GLOverlayGeode::coordinateFrameType(void) const return mCoordinateFrameType; } +void +GLOverlayGeode::setMessageTimestamp(qreal timestamp) +{ + mMessageTimestamp = timestamp; +} + +qreal +GLOverlayGeode::messageTimestamp(void) const +{ + return mMessageTimestamp; +} + GLOverlayGeode::GLOverlayDrawable::GLOverlayDrawable() { setUseDisplayList(true); diff --git a/src/ui/map3D/GLOverlayGeode.h b/src/ui/map3D/GLOverlayGeode.h index d84647ab0e66b72d57d2ff0bbaa7dde2b9e7e51d..d70227c8d9dbf9d0001d2116b60c5cdbbe741450 100644 --- a/src/ui/map3D/GLOverlayGeode.h +++ b/src/ui/map3D/GLOverlayGeode.h @@ -3,6 +3,7 @@ #include #include +#include class GLOverlayGeode : public osg::Geode { @@ -13,6 +14,9 @@ public: px::GLOverlay::CoordinateFrameType coordinateFrameType(void) const; + void setMessageTimestamp(qreal timestamp); + qreal messageTimestamp(void) const; + private: class GLOverlayDrawable : public osg::Drawable { @@ -39,6 +43,7 @@ private: osg::ref_ptr mDrawable; px::GLOverlay::CoordinateFrameType mCoordinateFrameType; + qreal mMessageTimestamp; }; #endif // GLOVERLAYGEODE_H diff --git a/src/ui/map3D/Pixhawk3DWidget.cc b/src/ui/map3D/Pixhawk3DWidget.cc index 081ede5dc87464635723c75fd2079aa94a3d686d..f6be32e30f76016d7d4c89119663218e2cfabde5 100644 --- a/src/ui/map3D/Pixhawk3DWidget.cc +++ b/src/ui/map3D/Pixhawk3DWidget.cc @@ -563,7 +563,8 @@ Pixhawk3DWidget::addOverlay(UASInterface *uas) SystemContainer& systemData = mSystemContainerMap[systemId]; - px::GLOverlay overlay = uas->getOverlay(); + qreal receivedTimestamp; + px::GLOverlay overlay = uas->getOverlay(receivedTimestamp); QString overlayName = QString::fromStdString(overlay.name()); @@ -580,7 +581,9 @@ Pixhawk3DWidget::addOverlay(UASInterface *uas) emit overlayCreatedSignal(systemId, overlayName); } - systemData.overlayNodeMap()[overlayName]->setOverlay(overlay); + osg::ref_ptr& overlayNode = systemData.overlayNodeMap()[overlayName]; + overlayNode->setOverlay(overlay); + overlayNode->setMessageTimestamp(receivedTimestamp); } #endif @@ -953,11 +956,15 @@ Pixhawk3DWidget::update(void) bool displayOverlay = systemViewParams->displayOverlay().value(itOverlay.key()); bool visible; - visible = (overlayNode->coordinateFrameType() == px::GLOverlay::GLOBAL) && displayOverlay; + visible = (overlayNode->coordinateFrameType() == px::GLOverlay::GLOBAL) && + displayOverlay && + (QGC::groundTimeSeconds() - overlayNode->messageTimestamp() < kMessageTimeout); allocentricMap->setChildValue(overlayNode, visible); - visible = (overlayNode->coordinateFrameType() == px::GLOverlay::LOCAL) && displayOverlay; + visible = (overlayNode->coordinateFrameType() == px::GLOverlay::LOCAL) && + displayOverlay && + (QGC::groundTimeSeconds() - overlayNode->messageTimestamp() < kMessageTimeout);; rollingMap->setChildValue(overlayNode, visible); }