diff --git a/qgroundcontrol.pri b/qgroundcontrol.pri index 592d129c8351403150caf9579b2bed0453b741e5..dacd2ac3a39beecc608c04e6abfcf7b7cc8b4e78 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 39e0be4d7e9b94e2bf16507c15d4eb8c0abb2797..90898ee234d3d5064f0aa60d2b7c3fe108c88479 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 b1ba65fdd64b6e319b66ea93fee11935c8a2e85f..091b2f4474eb16f2e8165a4e091efebf839775a3 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 858650bab8ea1f0547d88e907a29d2a438ae784f..852c977c90e51f140f3ee7e1c9ee41b4c37d6ff1 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 00ac31c6d724e676365edf57e211d6e10f8a3674..c69a0be3ca2b18d1e888b4421cc19c169c57ae94 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 2c5a7aa3e7e3034170388080c187bebc11b79f97..d0c95be23ffc6d1a45c14d276383d140d5089bde 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 32d2e04734b0ef5efcd6212a880edf3fb8f42cc2..1909ed6abf5ac7286ae61d1fb065d73d09a1fbc8 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 c411654702c3d02e61946dfb1b6968c5775d54da..796bf5b2edeac473e58ed20891e6ace7049101d1 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 af37b350590b21dbe014110f8a7d243023df67c4..9fdea5469a70f2c72e69557e07f4550614417ac0 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());