From b5a42dc48909eecd7ac614c3da73a9ecef6586a5 Mon Sep 17 00:00:00 2001 From: Jan NIJS Date: Fri, 23 Jun 2017 19:17:31 +0200 Subject: [PATCH] LP-536 Reorganize GPS display widget for a wider SNR widget. --- .../plugins/gpsdisplay/gpsdisplaywidget.ui | 500 ++++++++++-------- .../src/plugins/gpsdisplay/gpssnrwidget.cpp | 27 +- 2 files changed, 304 insertions(+), 223 deletions(-) diff --git a/ground/gcs/src/plugins/gpsdisplay/gpsdisplaywidget.ui b/ground/gcs/src/plugins/gpsdisplay/gpsdisplaywidget.ui index 6af532b91..c64359ddc 100644 --- a/ground/gcs/src/plugins/gpsdisplay/gpsdisplaywidget.ui +++ b/ground/gcs/src/plugins/gpsdisplay/gpsdisplaywidget.ui @@ -6,7 +6,7 @@ 0 0 - 609 + 664 606 @@ -47,164 +47,9 @@ true - - - - - - 0 - 0 - - - - - 400 - 140 - - - - - - - - - 236 - 236 - 236 - - - - - - - 237 - 237 - 237 - - - - - - - - - 236 - 236 - 236 - - - - - - - 237 - 237 - 237 - - - - - - - - - 236 - 236 - 236 - - - - - - - 236 - 236 - 236 - - - - - - - - <html><head/><body><p>Displays the SNR for each detected sat. GPS satellites are shown in green, GLONASS in cyan, BeiDou in red, Galileo in magenta and SBAS/QZSS in orange. Satellite number (PRN) is displayed inside the bar. Sat SNR is displayed above (in dBHz)</p></body></html> - - - false - - - QFrame::Panel - - - 0 - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - - - - - 0 - - - - - true - - - - 400 - 400 - - - - background-color: rgba(255, 255, 255, 0); - - - QFrame::Panel - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - - - 0 - 0 - 0 - - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - - - - + + + 0 @@ -284,6 +129,22 @@ + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 20 + 6 + + + + @@ -578,6 +439,18 @@ + + + 0 + 0 + + + + + 50 + 0 + + 100 @@ -659,6 +532,12 @@ + + + 100 + 0 + + Unknown @@ -755,71 +634,21 @@ - + 0 - + Qt::Horizontal - QSizePolicy::Preferred + QSizePolicy::Minimum - 9 - 20 - - - - - - - - - - Connect - - - - - - - Disconnect - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 9 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 0 + 18 20 @@ -875,7 +704,7 @@ - 20 + 40 20 @@ -885,6 +714,249 @@ + + + + 0 + + + + + true + + + + 400 + 400 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::Panel + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + 0 + 0 + 0 + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 9 + 20 + + + + + + + + + + Connect + + + + + + + Disconnect + + + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 9 + 20 + + + + + + + + + 1 + 0 + + + + + 850 + 110 + + + + + 0 + 0 + + + + + + + + + 236 + 236 + 236 + + + + + + + 237 + 237 + 237 + + + + + + + + + 236 + 236 + 236 + + + + + + + 237 + 237 + 237 + + + + + + + + + 236 + 236 + 236 + + + + + + + 236 + 236 + 236 + + + + + + + + <html><head/><body><p>Displays the SNR for each detected sat.</p> <ul><li> GPS satellites are shown in green</li><li> GLONASS in cyan</li><li> BeiDou in red</li><li> Galileo in magenta </li><li> SBAS/QZSS in orange <li></ul><p> Satellite number (PRN) is displayed inside the bar. <br/> Sat SNR is displayed above (in dBHz )</p></body></html> + + + false + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 9 + 20 + + + + + + diff --git a/ground/gcs/src/plugins/gpsdisplay/gpssnrwidget.cpp b/ground/gcs/src/plugins/gpsdisplay/gpssnrwidget.cpp index 10c552334..e67ea113d 100644 --- a/ground/gcs/src/plugins/gpsdisplay/gpssnrwidget.cpp +++ b/ground/gcs/src/plugins/gpsdisplay/gpssnrwidget.cpp @@ -18,13 +18,13 @@ GpsSnrWidget::GpsSnrWidget(QWidget *parent) : scene->addItem(boxes[i]); boxes[i]->hide(); - satTexts[i] = new QGraphicsSimpleTextItem("##", boxes[i]); + satTexts[i] = new QGraphicsSimpleTextItem("###", boxes[i]); satTexts[i]->setBrush(QColor("Black")); - satTexts[i]->setFont(QFont("Courier")); + satTexts[i]->setFont(QFont("Arial")); satSNRs[i] = new QGraphicsSimpleTextItem("##", boxes[i]); satSNRs[i]->setBrush(QColor("Black")); - satSNRs[i]->setFont(QFont("Courier")); + satSNRs[i]->setFont(QFont("Arial")); } } @@ -68,6 +68,8 @@ void GpsSnrWidget::updateSat(int index, int prn, int elevation, int azimuth, int drawSat(index); } +#define PRN_TEXTAREA_HEIGHT 20 + void GpsSnrWidget::drawSat(int index) { if (index >= MAX_SATTELITES) { @@ -93,11 +95,11 @@ void GpsSnrWidget::drawSat(int index) // 2 pixels, one on each side. qreal width = availableWidth - 2; // SNR = 1-99 (0 is special).. - qreal height = int((scene->height() / 99) * snr + 0.5); + qreal height = int(((scene->height() - PRN_TEXTAREA_HEIGHT) / 99) * snr + 0.5); // 1 for showing a pixel of white to the left. qreal x = availableWidth * index + 1; // Rember, 0 is at the top. - qreal y = scene->height() - height; + qreal y = scene->height() - height - PRN_TEXTAREA_HEIGHT; // Compensate for the extra pixel for the border. boxes[index]->setRect(0, 0, width - 1, height - 1); boxes[index]->setPos(x, y); @@ -122,6 +124,8 @@ void GpsSnrWidget::drawSat(int index) } else { boxes[index]->setBrush(QColor("Green")); } + + // Add leading 0 to PRN number QString prnString = QString().number(prn); if (prnString.length() == 1) { prnString = "0" + prnString; @@ -129,22 +133,27 @@ void GpsSnrWidget::drawSat(int index) satTexts[index]->setText(prnString); QRectF textRect = satTexts[index]->boundingRect(); + // Reposition PRN numbers below the bar and rescale QTransform matrix; - qreal scale = 0.85 * (boxRect.width() / textRect.width()); + // rescale based on the textRect height because it depends less on the number of digits: + qreal scale = 0.56 * (boxRect.width() / textRect.height()); matrix.translate(boxRect.width() / 2, boxRect.height()); matrix.scale(scale, scale); - matrix.translate(-textRect.width() / 2, -textRect.height()); + matrix.translate(-textRect.width() / 2, 0); satTexts[index]->setTransform(matrix, false); + // Add leading 0 to SNR values QString snrString = QString().number(snr); - if (snrString.length() == 1) { // Will probably never happen! + if (snrString.length() == 1) { snrString = "0" + snrString; } satSNRs[index]->setText(snrString); textRect = satSNRs[index]->boundingRect(); + // Reposition SNR levels above the bar and rescale matrix.reset(); - scale = 0.85 * (boxRect.width() / textRect.width()); + // rescale based on the textRect height because it depends less on the number of digits: + scale = 0.60 * (boxRect.width() / textRect.height()); matrix.translate(boxRect.width() / 2, 0); matrix.scale(scale, scale); matrix.translate(-textRect.width() / 2, -textRect.height());