From c2f4dc0deebbe4760d001ccb8c62eac26dffc3eb Mon Sep 17 00:00:00 2001 From: LM Date: Thu, 26 Jan 2012 18:09:40 +0100 Subject: [PATCH] Small compile fixes, fixed image copy calls for non-visible Huds --- qgroundcontrol.pri | 2 ++ src/ui/HUD.cc | 11 +++--- src/ui/MAVLinkDecoder.cc | 3 +- src/ui/QGCFirmwareUpdate.h | 14 ++++++++ src/ui/QGCToolBar.cc | 4 +-- src/ui/map/QGCMapWidget.cc | 62 ++++++++++++++++++++++++++++++++++ src/ui/map/QGCMapWidget.h | 4 +++ src/ui/map3D/Pixhawk3DWidget.h | 14 ++++++++ src/ui/map3D/Q3DWidget.cc | 8 ++++- 9 files changed, 114 insertions(+), 8 deletions(-) diff --git a/qgroundcontrol.pri b/qgroundcontrol.pri index 592d129c8..dacd2ac3a 100644 --- a/qgroundcontrol.pri +++ b/qgroundcontrol.pri @@ -250,6 +250,7 @@ message("Compiling for linux 32") -lOpenThreads DEFINES += QGC_OSG_ENABLED + DEFINES += QGC_OSG_QT_ENABLED } exists(/usr/local/include/google/protobuf) { @@ -333,6 +334,7 @@ linux-g++-64 { -lOpenThreads DEFINES += QGC_OSG_ENABLED + DEFINES += QGC_OSG_QT_ENABLED } exists(/usr/local/include/google/protobuf) { diff --git a/src/ui/HUD.cc b/src/ui/HUD.cc index 39e0be4d7..90898ee23 100644 --- a/src/ui/HUD.cc +++ b/src/ui/HUD.cc @@ -1431,10 +1431,13 @@ void HUD::setPixels(int imgid, const unsigned char* imageData, int length, int s void HUD::copyImage() { - qDebug() << "HUD::copyImage()"; - UAS* u = dynamic_cast(this->uas); - if (u) + if (isVisible()) { - this->glImage = QGLWidget::convertToGLFormat(u->getImage()); + qDebug() << "HUD::copyImage()"; + UAS* u = dynamic_cast(this->uas); + if (u) + { + this->glImage = QGLWidget::convertToGLFormat(u->getImage()); + } } } diff --git a/src/ui/MAVLinkDecoder.cc b/src/ui/MAVLinkDecoder.cc index b1ba65fdd..091b2f447 100644 --- a/src/ui/MAVLinkDecoder.cc +++ b/src/ui/MAVLinkDecoder.cc @@ -27,8 +27,9 @@ MAVLinkDecoder::MAVLinkDecoder(MAVLinkProtocol* protocol, QObject *parent) : messageFilter.insert(MAVLINK_MSG_ID_MISSION_ITEM, false); messageFilter.insert(MAVLINK_MSG_ID_MISSION_COUNT, false); messageFilter.insert(MAVLINK_MSG_ID_MISSION_ACK, false); - #ifdef MAVLINK_ENABLED_PIXHAWK messageFilter.insert(MAVLINK_MSG_ID_DATA_STREAM, false); + #ifdef MAVLINK_ENABLED_PIXHAWK + messageFilter.insert(MAVLINK_MSG_ID_ENCAPSULATED_DATA, false); messageFilter.insert(MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE, false); #endif messageFilter.insert(MAVLINK_MSG_ID_EXTENDED_MESSAGE, false); diff --git a/src/ui/QGCFirmwareUpdate.h b/src/ui/QGCFirmwareUpdate.h index 858650bab..852c977c9 100644 --- a/src/ui/QGCFirmwareUpdate.h +++ b/src/ui/QGCFirmwareUpdate.h @@ -17,9 +17,23 @@ public: protected: void changeEvent(QEvent *e); + void showEvent(QShowEvent* event) + { + QWidget::showEvent(event); + emit visibilityChanged(true); + } + + void hideEvent(QHideEvent* event) + { + QWidget::hideEvent(event); + emit visibilityChanged(false); + } private: Ui::QGCFirmwareUpdate *ui; + +signals: + void visibilityChanged(bool visible); }; #endif // QGCFIRMWAREUPDATE_H diff --git a/src/ui/QGCToolBar.cc b/src/ui/QGCToolBar.cc index 00ac31c6d..c69a0be3c 100644 --- a/src/ui/QGCToolBar.cc +++ b/src/ui/QGCToolBar.cc @@ -374,6 +374,6 @@ void QGCToolBar::receiveTextMessage(int uasid, int componentid, int severity, QS QGCToolBar::~QGCToolBar() { - delete toggleLoggingAction; - delete logReplayAction; + if (toggleLoggingAction) toggleLoggingAction->deleteLater(); + if (logReplayAction) logReplayAction->deleteLater(); } diff --git a/src/ui/map/QGCMapWidget.cc b/src/ui/map/QGCMapWidget.cc index 2c5a7aa3e..d0c95be23 100644 --- a/src/ui/map/QGCMapWidget.cc +++ b/src/ui/map/QGCMapWidget.cc @@ -284,6 +284,68 @@ void QGCMapWidget::updateGlobalPosition() } } +void QGCMapWidget::updateLocalPosition() +{ + QList systems = UASManager::instance()->getUASList(); + foreach (UASInterface* system, systems) + { + // Get reference to graphic UAV item + mapcontrol::UAVItem* uav = GetUAV(system->getUASID()); + // Check if reference is valid, else create a new one + if (uav == NULL) + { + MAV2DIcon* newUAV = new MAV2DIcon(map, this, system); + AddUAV(system->getUASID(), newUAV); + uav = newUAV; + uav->SetTrailTime(1); + uav->SetTrailDistance(5); + uav->SetTrailType(mapcontrol::UAVTrailType::ByTimeElapsed); + } + + // Set new lat/lon position of UAV icon + double latitude = UASManager::instance()->getHomeLatitude(); + double longitude = UASManager::instance()->getHomeLongitude(); + double altitude = UASManager::instance()->getHomeAltitude(); + internals::PointLatLng pos_lat_lon = internals::PointLatLng(system->getLatitude(), system->getLongitude()); + uav->SetUAVPos(pos_lat_lon, system->getAltitude()); + // Follow status + if (followUAVEnabled && system->getUASID() == followUAVID) SetCurrentPosition(pos_lat_lon); + // Convert from radians to degrees and apply + uav->SetUAVHeading((system->getYaw()/M_PI)*180.0f); + } +} + +void QGCMapWidget::updateLocalPositionEstimates() +{ + QList systems = UASManager::instance()->getUASList(); + foreach (UASInterface* system, systems) + { + // Get reference to graphic UAV item + mapcontrol::UAVItem* uav = GetUAV(system->getUASID()); + // Check if reference is valid, else create a new one + if (uav == NULL) + { + MAV2DIcon* newUAV = new MAV2DIcon(map, this, system); + AddUAV(system->getUASID(), newUAV); + uav = newUAV; + uav->SetTrailTime(1); + uav->SetTrailDistance(5); + uav->SetTrailType(mapcontrol::UAVTrailType::ByTimeElapsed); + } + + // Set new lat/lon position of UAV icon + double latitude = UASManager::instance()->getHomeLatitude(); + double longitude = UASManager::instance()->getHomeLongitude(); + double altitude = UASManager::instance()->getHomeAltitude(); + internals::PointLatLng pos_lat_lon = internals::PointLatLng(system->getLatitude(), system->getLongitude()); + uav->SetUAVPos(pos_lat_lon, system->getAltitude()); + // Follow status + if (followUAVEnabled && system->getUASID() == followUAVID) SetCurrentPosition(pos_lat_lon); + // Convert from radians to degrees and apply + uav->SetUAVHeading((system->getYaw()/M_PI)*180.0f); + } +} + void QGCMapWidget::updateSystemSpecs(int uas) { diff --git a/src/ui/map/QGCMapWidget.h b/src/ui/map/QGCMapWidget.h index 32d2e0473..1909ed6ab 100644 --- a/src/ui/map/QGCMapWidget.h +++ b/src/ui/map/QGCMapWidget.h @@ -46,6 +46,10 @@ public slots: void updateGlobalPosition(UASInterface* uas, double lat, double lon, double alt, quint64 usec); /** @brief Update the global position of all systems */ void updateGlobalPosition(); + /** @brief Update the local position and draw it converted to GPS reference */ + void updateLocalPosition(); + /** @brief Update the local position estimates (individual sensors) and draw it converted to GPS reference */ + void updateLocalPositionEstimates(); /** @brief Update the type, size, etc. of this system */ void updateSystemSpecs(int uas); /** @brief Change current system in focus / editing */ diff --git a/src/ui/map3D/Pixhawk3DWidget.h b/src/ui/map3D/Pixhawk3DWidget.h index c41165470..796bf5b2e 100644 --- a/src/ui/map3D/Pixhawk3DWidget.h +++ b/src/ui/map3D/Pixhawk3DWidget.h @@ -85,9 +85,23 @@ protected: virtual void display(void); virtual void keyPressEvent(QKeyEvent* event); virtual void mousePressEvent(QMouseEvent* event); + void showEvent(QShowEvent* event) + { + QWidget::showEvent(event); + emit visibilityChanged(true); + } + + void hideEvent(QHideEvent* event) + { + QWidget::hideEvent(event); + emit visibilityChanged(false); + } UASInterface* uas; +signals: + void visibilityChanged(bool visible); + private: void getPose(double& x, double& y, double& z, double& roll, double& pitch, double& yaw, diff --git a/src/ui/map3D/Q3DWidget.cc b/src/ui/map3D/Q3DWidget.cc index af37b3505..9fdea5469 100644 --- a/src/ui/map3D/Q3DWidget.cc +++ b/src/ui/map3D/Q3DWidget.cc @@ -35,7 +35,9 @@ This file is part of the QGROUNDCONTROL project #include #include #include +#ifdef QGC_OSG_QT_ENABLED #include +#endif #ifdef Q_OS_MACX #include #endif @@ -57,9 +59,13 @@ Q3DWidget::Q3DWidget(QWidget* parent) cameraParams.cameraFov = 30.0f; cameraParams.minClipRange = 1.0f; cameraParams.maxClipRange = 10000.0f; - +#ifdef QGC_OSG_QT_ENABLED osg::ref_ptr fontImpl; fontImpl = new osgQt::QFontImplementation(QFont(":/general/vera.ttf")); +#else + osg::ref_ptr fontImpl; + fontImpl = 0;//new osgText::Font::Font("images/Vera.ttf"); +#endif font = new osgText::Font(fontImpl); osgGW = new osgViewer::GraphicsWindowEmbedded(0, 0, width(), height()); -- 2.22.0