From 501f5124def10ba868f6e6a7a1dba6284ab2e593 Mon Sep 17 00:00:00 2001 From: dongfang Date: Thu, 30 May 2013 09:34:35 +0200 Subject: [PATCH] PFD changes --- dongfang_notes.txt | 6 ++--- src/ui/MainWindow.cc | 31 +------------------------ src/ui/PrimaryFlightDisplay.cpp | 41 ++++++++++++++++++++++++--------- src/ui/PrimaryFlightDisplay.h | 14 +++++------ 4 files changed, 41 insertions(+), 51 deletions(-) diff --git a/dongfang_notes.txt b/dongfang_notes.txt index 432be852a..5fd920ed3 100644 --- a/dongfang_notes.txt +++ b/dongfang_notes.txt @@ -54,10 +54,10 @@ navModeChanged // System Status loadChanged Do we already have these in some form? Can they be merged? -batteryChanged -voltageChanged +batteryChanged (DONE) +voltageChanged (DONE) gpsLocalizationChanged -satelliteCountChanged +satelliteCountChanged (DONE) // Mission status currentWaypointChanged (on WaypointManager) diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 560bd44e9..99a6497b4 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -345,14 +345,7 @@ QString MainWindow::getWindowStateKey() return QString::number(currentView)+"_windowstate_" + UASManager::instance()->getActiveUAS()->getAutopilotTypeName(); } else -<<<<<<< HEAD - { - return QString::number(currentView)+"_windowstate"; - } -======= - return QString::number(currentView)+"_windowstate"; ->>>>>>> lorenz/master } QString MainWindow::getWindowGeometryKey() @@ -901,22 +894,7 @@ void MainWindow::showHILConfigurationWidget(UASInterface* uas) //createDockWidget(centerStack->currentWidget(),tool,"Unnamed Tool " + QString::number(ui.menuTools->actions().size()),"UNNAMED_TOOL_" + QString::number(ui.menuTools->actions().size())+"DOCK",currentView,Qt::BottomDockWidgetArea); QGCHilConfiguration* hconf = new QGCHilConfiguration(mav, this); -<<<<<<< HEAD - - QString hilDockName = tr("HIL Config (%1)").arg(uas->getUASName()); - createDockWidget(centerStack->currentWidget(),hconf,hilDockName,QString("HIL_CONFIG_%1").arg(uas->getUASID()),currentView,Qt::LeftDockWidgetArea); - //QDockWidget* hilDock = new QDockWidget(hilDockName, this); - //hilDock->setWidget(hconf); - //hilDock->setObjectName(QString("HIL_CONFIG_%1").arg(uas->getUASID())); - //addTool(hilDock, hilDockName, Qt::LeftDockWidgetArea); - //hilDocks.insert(mav->getUASID(), hilDock); - - //if (currentView != VIEW_SIMULATION) - // hilDock->hide(); - //else - // hilDock->show(); -======= - QString hilDockName = tr("HIL Config %1").arg(uas->getUASName()); + QString hilDockName = tr("HIL Config %1").arg(uas->getUASName()); QDockWidget* hilDock = createDockWidget(simView, hconf,hilDockName, hilDockName.toUpper().replace(" ", "_"),VIEW_SIMULATION,Qt::LeftDockWidgetArea); hilDocks.insert(mav->getUASID(), hilDock); @@ -924,7 +902,6 @@ void MainWindow::showHILConfigurationWidget(UASInterface* uas) // hilDock->hide(); // else // hilDock->show(); ->>>>>>> lorenz/master } } @@ -1772,14 +1749,8 @@ void MainWindow::UASCreated(UASInterface* uas) connect(uas, SIGNAL(systemSpecsChanged(int)), this, SLOT(UASSpecsChanged(int))); -<<<<<<< HEAD - // HIL - //We only want to show it when it's explicitly requested. This is now handled by loadViewState() - //showHILConfigurationWidget(uas); -======= // HIL showHILConfigurationWidget(uas); ->>>>>>> lorenz/master if (!linechartWidget) { diff --git a/src/ui/PrimaryFlightDisplay.cpp b/src/ui/PrimaryFlightDisplay.cpp index d9960ac5c..e1446f75d 100644 --- a/src/ui/PrimaryFlightDisplay.cpp +++ b/src/ui/PrimaryFlightDisplay.cpp @@ -63,6 +63,9 @@ PrimaryFlightDisplay::PrimaryFlightDisplay(int width, int height, QWidget *paren batteryCurrent(UNKNOWN_BATTERY), batteryCharge(UNKNOWN_BATTERY), + GPSFixType(UNKNOWN_GPSFIXTYPE), + satelliteCount(UNKNOWN_COUNT), + layout(FEATUREPANELS_IN_CORNERS), style(OPAGUE_TAPES), @@ -180,6 +183,9 @@ void PrimaryFlightDisplay::setActiveUAS(UASInterface* uas) disconnect(this->uas, SIGNAL(statusChanged(UASInterface*,QString,QString)), this, SLOT(updateState(UASInterface*,QString))); disconnect(this->uas, SIGNAL(modeChanged(int,QString,QString)), this, SLOT(updateMode(int,QString,QString))); disconnect(this->uas, SIGNAL(heartbeat(UASInterface*)), this, SLOT(receiveHeartbeat(UASInterface*))); + disconnect(this->uas, SIGNAL(armingChanged(bool)), this, SLOT(updateArmed(bool))); + disconnect(this->uas, SIGNAL(satelliteCountChanged(double, QString)), this, SLOT(updateSatelliteCount(double, QString))); + disconnect(this->uas, SIGNAL(localizationChanged(UASInterface* uas, int fix)), this, SLOT(updateGPSFixType(UASInterface*,int))); //disconnect(this->uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateLocalPosition(UASInterface*,double,double,double,quint64))); disconnect(this->uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,quint64))); @@ -198,6 +204,7 @@ void PrimaryFlightDisplay::setActiveUAS(UASInterface* uas) connect(uas, SIGNAL(modeChanged(int,QString,QString)), this, SLOT(updateMode(int,QString,QString))); connect(uas, SIGNAL(heartbeat(UASInterface*)), this, SLOT(receiveHeartbeat(UASInterface*))); connect(uas, SIGNAL(armingChanged(bool)), this, SLOT(updateArmed(bool))); + connect(uas, SIGNAL(satelliteCountChanged(double, QString)), this, SLOT(updateSatelliteCount(double, QString))); //connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateLocalPosition(UASInterface*,double,double,double,quint64))); connect(uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,quint64))); @@ -258,6 +265,16 @@ void PrimaryFlightDisplay::updateBattery(UASInterface* uas, double voltage, doub batteryCharge = percent; } +void PrimaryFlightDisplay::updateGPSFixType(UASInterface* uas, int fixType) { + Q_UNUSED(uas); + this->GPSFixType = fixType; +} + +void PrimaryFlightDisplay::updateSatelliteCount(double count, QString name) { + Q_UNUSED(uas) + this->satelliteCount = (int)count; +} + void PrimaryFlightDisplay::receiveHeartbeat(UASInterface*) { } @@ -950,10 +967,10 @@ void PrimaryFlightDisplay::drawVelocityMeter( float effectiveHalfHeight = h*0.45; float tickmarkLeft = 0.6*w; float tickmarkRight = 0.7*w; - float numbersLeft = 0.42*w; + float numbersRight = 0.42*w; float markerHalfHeight = 0.06*h; - float rightEdge = w-instrumentEdgePen.widthF()*2; - float markerTip = (tickmarkLeft*2+tickmarkRight)/3; + float leftEdge = instrumentEdgePen.widthF()*2; + float markerTip = (tickmarkLeft+tickmarkRight*2)/3; float start = airspeed - AIRSPEED_LINEAR_SPAN/2; float end = airspeed + AIRSPEED_LINEAR_SPAN/2; @@ -963,20 +980,22 @@ void PrimaryFlightDisplay::drawVelocityMeter( float y = (tickSpeed-airspeed)*effectiveHalfHeight/(AIRSPEED_LINEAR_SPAN/2); bool hasText = tickSpeed % AIRSPEED_LINEAR_MAJOR_RESOLUTION == 0; painter.resetTransform(); + painter.translate(area.left(), area.center().y() - y); painter.drawLine(tickmarkLeft, 0, tickmarkRight, 0); + if (hasText) { QString s_speed; s_speed.sprintf("%d", tickSpeed); - drawTextLeftCenter(painter, s_speed, mediumTextSize, numbersLeft, 0); + drawTextRightCenter(painter, s_speed, mediumTextSize, numbersRight, 0); } } QPainterPath markerPath(QPoint(markerTip, 0)); - markerPath.lineTo(markerTip+markerHalfHeight, markerHalfHeight); - markerPath.lineTo(rightEdge, markerHalfHeight); - markerPath.lineTo(rightEdge, -markerHalfHeight); - markerPath.lineTo(markerTip+markerHalfHeight, -markerHalfHeight); + markerPath.lineTo(markerTip-markerHalfHeight, markerHalfHeight); + markerPath.lineTo(leftEdge, markerHalfHeight); + markerPath.lineTo(leftEdge, -markerHalfHeight); + markerPath.lineTo(markerTip-markerHalfHeight, -markerHalfHeight); markerPath.closeSubpath(); painter.resetTransform(); @@ -993,8 +1012,8 @@ void PrimaryFlightDisplay::drawVelocityMeter( pen.setColor(Qt::white); painter.setPen(pen); QString s_alt; - s_alt.sprintf("%3.0f", airspeed); - float xCenter = (markerTip+rightEdge)/2; + s_alt.sprintf("%3.1f", airspeed); + float xCenter = (markerTip+leftEdge)/2; drawTextCenter(painter, s_alt, /* TAPES_TEXT_SIZE*width()*/ mediumTextSize, xCenter, 0); } @@ -1367,7 +1386,7 @@ void PrimaryFlightDisplay::doPaint() { // Y: 1 single margin below above gadget. drawAltimeter(painter, altimeterArea, aboveASLAltitude, 1000, 0); - drawAltimeter(painter, velocityMeterArea, aboveASLAltitude, 1000, 0); + drawVelocityMeter(painter, velocityMeterArea); drawSensorsStatsPanel(painter, sensorsStatsArea); drawLinkStatsPanel(painter, linkStatsArea); diff --git a/src/ui/PrimaryFlightDisplay.h b/src/ui/PrimaryFlightDisplay.h index 99ef22a28..fa3f0b6bf 100644 --- a/src/ui/PrimaryFlightDisplay.h +++ b/src/ui/PrimaryFlightDisplay.h @@ -88,6 +88,8 @@ #define UNKNOWN_ATTITUDE 0 #define UNKNOWN_ALTITUDE -1000 #define UNKNOWN_SPEED -1 +#define UNKNOWN_COUNT -1 +#define UNKNOWN_GPSFIXTYPE -1 class PrimaryFlightDisplay : public QWidget { @@ -111,6 +113,8 @@ public slots: void updateState(UASInterface*,QString); void updateMode(int id,QString mode, QString description); void updateLoad(UASInterface*, double); + void updateGPSFixType(UASInterface*,int); + void updateSatelliteCount(double count,QString sth); void selectWaypoint(int uasId, int id); protected: @@ -212,16 +216,12 @@ private: double batteryCurrent; double batteryCharge; + int GPSFixType; + int satelliteCount; + Layout layout; // The display layout. Style style; // The AI style (tapes translusent or opague) - /* This idea did not work - QPen whitePen; - QPen redPen; - QPen amberPen; - QPen greenPen; - QPen blackPen; - */ QColor redColor; QColor amberColor; -- 2.22.0