1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

LP-536 Reorganize GPS display widget for a wider SNR widget.

This commit is contained in:
Jan NIJS 2017-06-23 19:17:31 +02:00
parent 507ec08db8
commit b5a42dc489
2 changed files with 304 additions and 223 deletions

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>609</width> <width>664</width>
<height>606</height> <height>606</height>
</rect> </rect>
</property> </property>
@ -47,164 +47,9 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout" rowstretch="1,0" columnstretch="1,0"> <layout class="QGridLayout" name="gridLayout" rowstretch="3,0">
<item row="1" column="1"> <item row="0" column="0">
<widget class="GpsSnrWidget" name="gpsSnrWidget"> <layout class="QVBoxLayout" name="infoVerticalLayout" stretch="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>140</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>236</red>
<green>236</green>
<blue>236</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>237</red>
<green>237</green>
<blue>237</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>236</red>
<green>236</green>
<blue>236</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>237</red>
<green>237</green>
<blue>237</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>236</red>
<green>236</green>
<blue>236</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>236</red>
<green>236</green>
<blue>236</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="0,1">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="GpsConstellationWidget" name="gpsSky">
<property name="enabled">
<bool>true</bool>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>400</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(255, 255, 255, 0);</string>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="backgroundBrush">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="0" rowspan="2">
<layout class="QVBoxLayout" name="infoVerticalLayout" stretch="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
@ -284,6 +129,22 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer_9">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>6</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin"> <property name="topMargin">
@ -578,6 +439,18 @@
</item> </item>
<item> <item>
<widget class="QLabel" name="status_value"> <widget class="QLabel" name="status_value">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>100</width> <width>100</width>
@ -659,6 +532,12 @@
</item> </item>
<item> <item>
<widget class="QLabel" name="fix_value"> <widget class="QLabel" name="fix_value">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Unknown</string> <string>Unknown</string>
</property> </property>
@ -755,71 +634,21 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout2" stretch="0,0,0,0,0,0"> <layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0,0">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer_21">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType"> <property name="sizeType">
<enum>QSizePolicy::Preferred</enum> <enum>QSizePolicy::Minimum</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>9</width> <width>18</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="connectButton">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="disconnectButton">
<property name="text">
<string>Disconnect</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>9</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
@ -875,7 +704,7 @@
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>40</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
@ -885,6 +714,249 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="0,1">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="GpsConstellationWidget" name="gpsSky">
<property name="enabled">
<bool>true</bool>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>400</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(255, 255, 255, 0);</string>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="backgroundBrush">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout2">
<property name="spacing">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>9</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="connectButton">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="disconnectButton">
<property name="text">
<string>Disconnect</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>9</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="GpsSnrWidget" name="gpsSnrWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>850</width>
<height>110</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>236</red>
<green>236</green>
<blue>236</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>237</red>
<green>237</green>
<blue>237</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>236</red>
<green>236</green>
<blue>236</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>237</red>
<green>237</green>
<blue>237</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>236</red>
<green>236</green>
<blue>236</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>236</red>
<green>236</green>
<blue>236</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Displays the SNR for each detected sat.&lt;/p&gt; &lt;ul&gt;&lt;li&gt; GPS satellites are shown in green&lt;/li&gt;&lt;li&gt; GLONASS in cyan&lt;/li&gt;&lt;li&gt; BeiDou in red&lt;/li&gt;&lt;li&gt; Galileo in magenta &lt;/li&gt;&lt;li&gt; SBAS/QZSS in orange &lt;li&gt;&lt;/ul&gt;&lt;p&gt; Satellite number (PRN) is displayed inside the bar. &lt;br/&gt; Sat SNR is displayed above (in dBHz )&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>9</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QGroupBox" name="dataStreamGroupBox"> <widget class="QGroupBox" name="dataStreamGroupBox">

View File

@ -18,13 +18,13 @@ GpsSnrWidget::GpsSnrWidget(QWidget *parent) :
scene->addItem(boxes[i]); scene->addItem(boxes[i]);
boxes[i]->hide(); boxes[i]->hide();
satTexts[i] = new QGraphicsSimpleTextItem("##", boxes[i]); satTexts[i] = new QGraphicsSimpleTextItem("###", boxes[i]);
satTexts[i]->setBrush(QColor("Black")); satTexts[i]->setBrush(QColor("Black"));
satTexts[i]->setFont(QFont("Courier")); satTexts[i]->setFont(QFont("Arial"));
satSNRs[i] = new QGraphicsSimpleTextItem("##", boxes[i]); satSNRs[i] = new QGraphicsSimpleTextItem("##", boxes[i]);
satSNRs[i]->setBrush(QColor("Black")); 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); drawSat(index);
} }
#define PRN_TEXTAREA_HEIGHT 20
void GpsSnrWidget::drawSat(int index) void GpsSnrWidget::drawSat(int index)
{ {
if (index >= MAX_SATTELITES) { if (index >= MAX_SATTELITES) {
@ -93,11 +95,11 @@ void GpsSnrWidget::drawSat(int index)
// 2 pixels, one on each side. // 2 pixels, one on each side.
qreal width = availableWidth - 2; qreal width = availableWidth - 2;
// SNR = 1-99 (0 is special).. // 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. // 1 for showing a pixel of white to the left.
qreal x = availableWidth * index + 1; qreal x = availableWidth * index + 1;
// Rember, 0 is at the top. // 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. // Compensate for the extra pixel for the border.
boxes[index]->setRect(0, 0, width - 1, height - 1); boxes[index]->setRect(0, 0, width - 1, height - 1);
boxes[index]->setPos(x, y); boxes[index]->setPos(x, y);
@ -122,6 +124,8 @@ void GpsSnrWidget::drawSat(int index)
} else { } else {
boxes[index]->setBrush(QColor("Green")); boxes[index]->setBrush(QColor("Green"));
} }
// Add leading 0 to PRN number
QString prnString = QString().number(prn); QString prnString = QString().number(prn);
if (prnString.length() == 1) { if (prnString.length() == 1) {
prnString = "0" + prnString; prnString = "0" + prnString;
@ -129,22 +133,27 @@ void GpsSnrWidget::drawSat(int index)
satTexts[index]->setText(prnString); satTexts[index]->setText(prnString);
QRectF textRect = satTexts[index]->boundingRect(); QRectF textRect = satTexts[index]->boundingRect();
// Reposition PRN numbers below the bar and rescale
QTransform matrix; 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.translate(boxRect.width() / 2, boxRect.height());
matrix.scale(scale, scale); matrix.scale(scale, scale);
matrix.translate(-textRect.width() / 2, -textRect.height()); matrix.translate(-textRect.width() / 2, 0);
satTexts[index]->setTransform(matrix, false); satTexts[index]->setTransform(matrix, false);
// Add leading 0 to SNR values
QString snrString = QString().number(snr); QString snrString = QString().number(snr);
if (snrString.length() == 1) { // Will probably never happen! if (snrString.length() == 1) {
snrString = "0" + snrString; snrString = "0" + snrString;
} }
satSNRs[index]->setText(snrString); satSNRs[index]->setText(snrString);
textRect = satSNRs[index]->boundingRect(); textRect = satSNRs[index]->boundingRect();
// Reposition SNR levels above the bar and rescale
matrix.reset(); 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.translate(boxRect.width() / 2, 0);
matrix.scale(scale, scale); matrix.scale(scale, scale);
matrix.translate(-textRect.width() / 2, -textRect.height()); matrix.translate(-textRect.width() / 2, -textRect.height());