From d87add18f1ba675475f0e52db34e5918af121abf Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 25 May 2013 16:12:13 +0200 Subject: [PATCH] Compile fixes, added warning for log replay --- src/ui/QGCMAVLinkLogPlayer.cc | 17 +++++++++++++++++ src/ui/QGCToolBar.cc | 17 ++++++++++++++++- src/ui/QGCToolBar.h | 4 ++++ src/ui/map3D/Pixhawk3DWidget.cc | 8 ++++---- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/ui/QGCMAVLinkLogPlayer.cc b/src/ui/QGCMAVLinkLogPlayer.cc index bc7a9d9..0b5a33c 100644 --- a/src/ui/QGCMAVLinkLogPlayer.cc +++ b/src/ui/QGCMAVLinkLogPlayer.cc @@ -3,6 +3,7 @@ #include #include "MainWindow.h" +#include "SerialLink.h" #include "QGCMAVLinkLogPlayer.h" #include "QGC.h" #include "ui_QGCMAVLinkLogPlayer.h" @@ -361,6 +362,22 @@ bool QGCMAVLinkLogPlayer::loadLogFile(const QString& file) // Reset current state reset(0); + // Check if a serial link is connected + + bool linkWarning = false; + foreach (LinkInterface* link, LinkManager::instance()->getLinks()) + { + SerialLink* s = dynamic_cast(link); + + if (s && s->isConnected()) + linkWarning = true; + } + + if (linkWarning) + MainWindow::instance()->showInfoMessage(tr("Active MAVLink links found"), tr("Currently other links are connected. It is recommended to disconnect any active link before replaying a log.")); + + play(); + return true; } } diff --git a/src/ui/QGCToolBar.cc b/src/ui/QGCToolBar.cc index ddf3705..c2bdac1 100644 --- a/src/ui/QGCToolBar.cc +++ b/src/ui/QGCToolBar.cc @@ -46,6 +46,16 @@ QGCToolBar::QGCToolBar(QWidget *parent) : // Do not load UI, wait for actions } +void QGCToolBar::globalPositionChanged(UASInterface* uas, double lat, double lon, double alt, quint64 usec) +{ + Q_UNUSED(uas); + Q_UNUSED(lat); + Q_UNUSED(lon); + Q_UNUSED(usec); + altitudeMSL = alt; + changed = true; +} + void QGCToolBar::heartbeatTimeout(bool timeout, unsigned int ms) { // set timeout label visible @@ -281,6 +291,7 @@ void QGCToolBar::setActiveUAS(UASInterface* active) disconnect(mav, SIGNAL(batteryChanged(UASInterface*,double,double,int)), this, SLOT(updateBatteryRemaining(UASInterface*,double,double,int))); disconnect(mav, SIGNAL(armingChanged(bool)), this, SLOT(updateArmingState(bool))); disconnect(mav, SIGNAL(heartbeatTimeout(bool, unsigned int)), this, SLOT(heartbeatTimeout(bool,unsigned int))); + disconnect(active, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(globalPositionChanged(UASInterface*,double,double,double,quint64))); if (mav->getWaypointManager()) { disconnect(mav->getWaypointManager(), SIGNAL(currentWaypointChanged(quint16)), this, SLOT(updateCurrentWaypoint(quint16))); @@ -298,6 +309,7 @@ void QGCToolBar::setActiveUAS(UASInterface* active) connect(active, SIGNAL(batteryChanged(UASInterface*,double,double,int)), this, SLOT(updateBatteryRemaining(UASInterface*,double,double,int))); connect(active, SIGNAL(armingChanged(bool)), this, SLOT(updateArmingState(bool))); connect(active, SIGNAL(heartbeatTimeout(bool, unsigned int)), this, SLOT(heartbeatTimeout(bool,unsigned int))); + connect(active, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(globalPositionChanged(UASInterface*,double,double,double,quint64))); if (active->getWaypointManager()) { connect(active->getWaypointManager(), SIGNAL(currentWaypointChanged(quint16)), this, SLOT(updateCurrentWaypoint(quint16))); @@ -314,6 +326,7 @@ void QGCToolBar::setActiveUAS(UASInterface* active) toolBarStateLabel->setText(mav->getShortState()); toolBarTimeoutLabel->setStyleSheet(QString("")); toolBarTimeoutLabel->setText(""); + toolBarDistLabel->setText(""); setSystemType(mav, mav->getSystemType()); } @@ -333,7 +346,9 @@ void QGCToolBar::updateArmingState(bool armed) void QGCToolBar::updateView() { if (!changed) return; - toolBarDistLabel->setText(tr("%1 m").arg(wpDistance, 6, 'f', 2, '0')); + //toolBarDistLabel->setText(tr("%1 m").arg(wpDistance, 6, 'f', 2, '0')); + // XXX add also rel altitude + toolBarDistLabel->setText(QString("%1 m MSL").arg(altitudeMSL, 6, 'f', 2, '0')); toolBarWpLabel->setText(tr("WP%1").arg(wpId)); toolBarBatteryBar->setValue(batteryPercent); if (batteryPercent < 30 && toolBarBatteryBar->value() >= 30) { diff --git a/src/ui/QGCToolBar.h b/src/ui/QGCToolBar.h index 99a9770..6abc0e1 100644 --- a/src/ui/QGCToolBar.h +++ b/src/ui/QGCToolBar.h @@ -74,6 +74,8 @@ public slots: void updateView(); /** @brief Update connection timeout time */ void heartbeatTimeout(bool timeout, unsigned int ms); + /** @brief Update global position */ + void globalPositionChanged(UASInterface* uas, double lat, double lon, double alt, quint64 usec); /** @brief Create or connect link */ void connectLink(bool connect); /** @brief Clear status string */ @@ -106,6 +108,8 @@ protected: float batteryVoltage; int wpId; double wpDistance; + float altitudeMSL; + float altitudeRel; QString state; QString mode; QString systemName; diff --git a/src/ui/map3D/Pixhawk3DWidget.cc b/src/ui/map3D/Pixhawk3DWidget.cc index 5828bd5..ee53543 100644 --- a/src/ui/map3D/Pixhawk3DWidget.cc +++ b/src/ui/map3D/Pixhawk3DWidget.cc @@ -834,7 +834,7 @@ Pixhawk3DWidget::moveWaypointPosition(void) return; } - const QVector waypoints = + const QList waypoints = mActiveUAS->getWaypointManager()->getWaypointEditableList(); Waypoint* waypoint = waypoints.at(mSelectedWpIndex); @@ -882,7 +882,7 @@ Pixhawk3DWidget::moveWaypointHeading(void) return; } - const QVector waypoints = + const QList waypoints = mActiveUAS->getWaypointManager()->getWaypointEditableList(); Waypoint* waypoint = waypoints.at(mSelectedWpIndex); @@ -929,7 +929,7 @@ Pixhawk3DWidget::setWaypointAltitude(void) } bool ok; - const QVector waypoints = + const QList waypoints = mActiveUAS->getWaypointManager()->getWaypointEditableList(); Waypoint* waypoint = waypoints.at(mSelectedWpIndex); @@ -960,7 +960,7 @@ Pixhawk3DWidget::clearAllWaypoints(void) { if (mActiveUAS) { - const QVector waypoints = + const QList waypoints = mActiveUAS->getWaypointManager()->getWaypointEditableList(); for (int i = waypoints.size() - 1; i >= 0; --i) {