From ebca05a8a12665be514cb10416dab64842b47018 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Tue, 3 May 2022 14:53:56 +0100 Subject: [PATCH] localizer GUI updates. Add QSplitter to allow area for table & map to be adjusted. Remove obsolete OurAirports button. Add workaround for QT Map redraw bug. Automatically update VOR channels when channels are added or removed. Remove Nav Id from table as it doesn't mean anything from a user's perspective. --- plugins/feature/vorlocalizer/readme.md | 5 - .../feature/vorlocalizer/vorlocalizergui.cpp | 68 +++- .../feature/vorlocalizer/vorlocalizergui.h | 7 +- .../feature/vorlocalizer/vorlocalizergui.ui | 365 +++++++----------- .../vorlocalizer/vorlocalizersettings.h | 19 +- 5 files changed, 223 insertions(+), 241 deletions(-) diff --git a/plugins/feature/vorlocalizer/readme.md b/plugins/feature/vorlocalizer/readme.md index 057424524..d26641daa 100644 --- a/plugins/feature/vorlocalizer/readme.md +++ b/plugins/feature/vorlocalizer/readme.md @@ -55,10 +55,6 @@ Channels may be used in round robin turns if their number is not enough to cover When there is more than one turn for a device valid radial directions are averaged and the resulting average is used during the round robin loop. Averaging also takes place for reference and variable signal levels. -

9: Refresh VOR demodulators list and allocation

- -Use this button to (re)scan the available VOR demodulators in the SDRangel instance and (re)run the round robin allocation. -

B: VOR Table

The VOR table displays information about selected VORs. To select or deselect a VOR, double click it on the map. The information displayed includes: @@ -67,7 +63,6 @@ The VOR table displays information about selected VORs. To select or deselect a * Name - The name of the VOR. For example: 'LONDON'. * Freq (MHz) - The center frequency the VOR transmits on in MHz. The frequency is highlighted in green when the VOR is serviced by a demodulator. -* Nav Id - This is the VOR unique identifier from the VOR database. * Ident - A 2 or 3 character identifier for the VOR. For example: 'LON'. * Morse - The Morse code identifier for the VOR. For example: '.-.. --- -.' * RX Ident - This contains the demodulated ident. If it matches the expected ident, it will be displayed in green, if not, it will be displayed in red. If an ident is received that is not 2 or 3 characters, it will not be displayed, but the last received ident will be displayed in yellow. diff --git a/plugins/feature/vorlocalizer/vorlocalizergui.cpp b/plugins/feature/vorlocalizer/vorlocalizergui.cpp index 7ea8815b9..fb8d1356a 100644 --- a/plugins/feature/vorlocalizer/vorlocalizergui.cpp +++ b/plugins/feature/vorlocalizer/vorlocalizergui.cpp @@ -137,7 +137,6 @@ VORGUI::VORGUI(NavAid *navAid, VORLocalizerGUI *gui) : // These are deleted by QTableWidget m_nameItem = new QTableWidgetItem(); m_frequencyItem = new QTableWidgetItem(); - m_navIdItem = new QTableWidgetItem(); m_radialItem = new QTableWidgetItem(); m_identItem = new QTableWidgetItem(); m_morseItem = new QTableWidgetItem(); @@ -358,7 +357,6 @@ void VORLocalizerGUI::resizeTable() ui->vorData->setRowCount(row + 1); ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_NAME, new QTableWidgetItem("White Sulphur Springs")); ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_FREQUENCY, new QTableWidgetItem("Freq (MHz) ")); - ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_NAVID, new QTableWidgetItem("99999999")); ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_IDENT, new QTableWidgetItem("Ident ")); ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_MORSE, new QTableWidgetItem(Morse::toSpacedUnicode(morse))); ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_RADIAL, new QTableWidgetItem("Radial (o) ")); @@ -432,8 +430,6 @@ void VORLocalizerGUI::selectVOR(VORGUI *vorGUI, bool selected) ui->vorData->setRowCount(row + 1); ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_NAME, vorGUI->m_nameItem); ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_FREQUENCY, vorGUI->m_frequencyItem); - ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_NAVID, vorGUI->m_navIdItem); - ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_IDENT, vorGUI->m_identItem); ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_MORSE, vorGUI->m_morseItem); ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_RADIAL, vorGUI->m_radialItem); ui->vorData->setItem(row, VORLocalizerSettings::VOR_COL_RX_IDENT, vorGUI->m_rxIdentItem); @@ -562,7 +558,6 @@ bool VORLocalizerGUI::handleMessage(const Message& message) bool validRadial = report.getValidRadial(); vorGUI->m_radialItem->setData(Qt::DisplayRole, std::round(report.getRadial())); - vorGUI->m_navIdItem->setData(Qt::DisplayRole, subChannelId); if (validRadial) { vorGUI->m_radialItem->setForeground(QBrush(Qt::white)); @@ -780,7 +775,7 @@ void VORLocalizerGUI::on_centerShift_valueChanged(int value) applySettings(); } -void VORLocalizerGUI::on_channelsRefresh_clicked() +void VORLocalizerGUI::channelsRefresh() { if (m_doApplySettings) { @@ -915,7 +910,6 @@ VORLocalizerGUI::VORLocalizerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISe // Read in VOR information if it exists readNavAids(); - ui->getOurAirportsVORDB->setVisible(false); // Resize the table using dummy data resizeTable(); @@ -950,11 +944,24 @@ VORLocalizerGUI::VORLocalizerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISe displaySettings(); applySettings(true); + + connect(&m_redrawMapTimer, &QTimer::timeout, this, &VORLocalizerGUI::redrawMap); + m_redrawMapTimer.setSingleShot(true); + ui->map->installEventFilter(this); + makeUIConnections(); + + // Update channel list when added/removed + connect(MainCore::instance(), &MainCore::channelAdded, this, &VORLocalizerGUI::channelsRefresh); + connect(MainCore::instance(), &MainCore::channelRemoved, this, &VORLocalizerGUI::channelsRefresh); + // List already opened channels + channelsRefresh(); } VORLocalizerGUI::~VORLocalizerGUI() { + disconnect(&m_redrawMapTimer, &QTimer::timeout, this, &VORLocalizerGUI::redrawMap); + m_redrawMapTimer.stop(); delete ui; qDeleteAll(m_vors); } @@ -1117,6 +1124,52 @@ void VORLocalizerGUI::preferenceChanged(int elementType) } } +void VORLocalizerGUI::redrawMap() +{ + // An awful workaround for https://bugreports.qt.io/browse/QTBUG-100333 + // Also used in ADS-B demod + QQuickItem *item = ui->map->rootObject(); + if (item) + { + QObject *object = item->findChild("map"); + if (object) + { + double zoom = object->property("zoomLevel").value(); + object->setProperty("zoomLevel", QVariant::fromValue(zoom+1)); + object->setProperty("zoomLevel", QVariant::fromValue(zoom)); + } + } +} + +void VORLocalizerGUI::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) + { + // Workaround for https://bugreports.qt.io/browse/QTBUG-100333 + // MapQuickItems can be in wrong position when window is first displayed + m_redrawMapTimer.start(500); + } +} + +bool VORLocalizerGUI::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == ui->map) + { + if (event->type() == QEvent::Resize) + { + // Workaround for https://bugreports.qt.io/browse/QTBUG-100333 + // MapQuickItems can be in wrong position after vertical resize + QResizeEvent *resizeEvent = static_cast(event); + QSize oldSize = resizeEvent->oldSize(); + QSize size = resizeEvent->size(); + if (oldSize.height() != size.height()) { + redrawMap(); + } + } + } + return false; +} + void VORLocalizerGUI::makeUIConnections() { QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &VORLocalizerGUI::on_startStop_toggled); @@ -1124,5 +1177,4 @@ void VORLocalizerGUI::makeUIConnections() QObject::connect(ui->magDecAdjust, &ButtonSwitch::toggled, this, &VORLocalizerGUI::on_magDecAdjust_toggled); QObject::connect(ui->rrTime, &QDial::valueChanged, this, &VORLocalizerGUI::on_rrTime_valueChanged); QObject::connect(ui->centerShift, &QDial::valueChanged, this, &VORLocalizerGUI::on_centerShift_valueChanged); - QObject::connect(ui->channelsRefresh, &QPushButton::clicked, this, &VORLocalizerGUI::on_channelsRefresh_clicked); } diff --git a/plugins/feature/vorlocalizer/vorlocalizergui.h b/plugins/feature/vorlocalizer/vorlocalizergui.h index a6169e53b..20c953f31 100644 --- a/plugins/feature/vorlocalizer/vorlocalizergui.h +++ b/plugins/feature/vorlocalizer/vorlocalizergui.h @@ -64,7 +64,6 @@ public: QTableWidgetItem *m_nameItem; QTableWidgetItem *m_frequencyItem; - QTableWidgetItem *m_navIdItem; QTableWidgetItem *m_identItem; QTableWidgetItem *m_morseItem; QTableWidgetItem *m_radialItem; @@ -249,6 +248,7 @@ private: QTimer m_statusTimer; int m_lastFeatureState; int m_rrSecondsCount; + QTimer m_redrawMapTimer; explicit VORLocalizerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature, QWidget* parent = nullptr); virtual ~VORLocalizerGUI(); @@ -257,6 +257,7 @@ private: void applySettings(bool force = false); void displaySettings(); bool handleMessage(const Message& message); + void redrawMap(); void makeUIConnections(); void resizeTable(); @@ -274,7 +275,7 @@ private slots: void on_magDecAdjust_toggled(bool checked); void on_rrTime_valueChanged(int value); void on_centerShift_valueChanged(int value); - void on_channelsRefresh_clicked(); + void channelsRefresh(); void vorData_sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex); void vorData_sectionResized(int logicalIndex, int oldSize, int newSize); void columnSelectMenu(QPoint pos); @@ -288,6 +289,8 @@ private slots: void downloadError(const QString& error); void downloadNavAidsFinished(); void preferenceChanged(int elementType); + virtual void showEvent(QShowEvent *event); + virtual bool eventFilter(QObject *obj, QEvent *event); }; #endif // INCLUDE_VORLOCALIZERGUI_H diff --git a/plugins/feature/vorlocalizer/vorlocalizergui.ui b/plugins/feature/vorlocalizer/vorlocalizergui.ui index 4efe999be..62180fc6b 100644 --- a/plugins/feature/vorlocalizer/vorlocalizergui.ui +++ b/plugins/feature/vorlocalizer/vorlocalizergui.ui @@ -6,7 +6,7 @@ 0 0 - 462 + 470 850 @@ -40,7 +40,7 @@ 0 0 461 - 61 + 31 @@ -85,23 +85,6 @@ - - - - true - - - Download OurAirports VOR database - - - - - - - :/demodvor/icons/vor.png:/demodvor/icons/vor.png - - - @@ -136,6 +119,13 @@ + + + + Qt::Vertical + + + @@ -223,6 +213,13 @@ QToolTip{background-color: white; color: black;} + + + + Qt::Vertical + + + @@ -275,22 +272,12 @@ QToolTip{background-color: white; color: black;} - + - Qt::Horizontal + Qt::Vertical - - - 40 - 20 - - - + - - - - @@ -306,27 +293,7 @@ QToolTip{background-color: white; color: black;} - - - - 24 - 16777215 - - - - Refresh VOR channels available - - - - - - - :/recycle.png:/recycle.png - - - - - + Qt::Horizontal @@ -345,14 +312,14 @@ QToolTip{background-color: white; color: black;} - 0 - 110 - 461 - 145 + 10 + 50 + 441 + 710 - + 0 0 @@ -366,178 +333,146 @@ QToolTip{background-color: white; color: black;} VORs - - - 2 - + - 3 + 0 - 3 + 0 - 3 + 0 - 3 + 0 - - - QAbstractItemView::NoEditTriggers - - - - Name - - - Name of the VOR - - - - - Freq (MHz) - - - Frequency of the VOR in MHz - - - - - Nav Id - - - Offset of the VOR's frequency from the current center frequency. Red indicates out of range. - - - - - Ident - - - Ident for the VOR - - - - - Morse - - - Morse code ident for the VOR - - - - - RX Ident - - - Received ident - - - - - RX Morse - - - Received Morse code ident - - - - - Radial (°) - - - Calculated radial from the VOR - - - - - Ref (dB) - - - Magnitude of received reference signal in dB - - - - - Var (dB) - - - Magnitude of received variable signal in dB - - - - - Mute - - - Mute/unmute audio from selected VORs - - - - - - - - - - 0 - 258 - 461 - 581 - - - - - 0 - 0 - - - - Map - - - - 2 - - - 3 - - - 3 - - - 3 - - - 3 - - - + 0 0 - - - 100 - 500 - - - - VOR map - - - QQuickWidget::SizeRootObjectToView - - - - - + + Qt::Vertical + + + + 0 + 1 + + + + QAbstractItemView::NoEditTriggers + + + + Name + + + Name of the VOR + + + + + Freq (MHz) + + + Frequency of the VOR in MHz + + + + + Ident + + + Ident for the VOR + + + + + Morse + + + Morse code ident for the VOR + + + + + RX Ident + + + Received ident + + + + + RX Morse + + + Received Morse code ident + + + + + Radial (°) + + + Calculated radial from the VOR + + + + + Ref (dB) + + + Magnitude of received reference signal in dB + + + + + Var (dB) + + + Magnitude of received variable signal in dB + + + + + Mute + + + Mute/unmute audio from selected VORs + + + + + + + 0 + 4 + + + + + 100 + 500 + + + + VOR map + + + QQuickWidget::SizeRootObjectToView + + + + + + + @@ -562,9 +497,7 @@ QToolTip{background-color: white; color: black;} - getOurAirportsVORDB vorData - map diff --git a/plugins/feature/vorlocalizer/vorlocalizersettings.h b/plugins/feature/vorlocalizer/vorlocalizersettings.h index c34a0f790..0c50e3beb 100644 --- a/plugins/feature/vorlocalizer/vorlocalizersettings.h +++ b/plugins/feature/vorlocalizer/vorlocalizersettings.h @@ -77,18 +77,17 @@ struct VORLocalizerSettings int m_workspaceIndex; QByteArray m_geometryBytes; - static const int VORDEMOD_COLUMNS = 11; + static const int VORDEMOD_COLUMNS = 10; static const int VOR_COL_NAME = 0; static const int VOR_COL_FREQUENCY = 1; - static const int VOR_COL_NAVID = 2; - static const int VOR_COL_IDENT = 3; - static const int VOR_COL_MORSE = 4; - static const int VOR_COL_RX_IDENT = 5; - static const int VOR_COL_RX_MORSE = 6; - static const int VOR_COL_RADIAL = 7; - static const int VOR_COL_REF_MAG = 8; - static const int VOR_COL_VAR_MAG = 9; - static const int VOR_COL_MUTE = 10; + static const int VOR_COL_IDENT = 2; + static const int VOR_COL_MORSE = 3; + static const int VOR_COL_RX_IDENT = 4; + static const int VOR_COL_RX_MORSE = 5; + static const int VOR_COL_RADIAL = 6; + static const int VOR_COL_REF_MAG = 7; + static const int VOR_COL_VAR_MAG = 8; + static const int VOR_COL_MUTE = 9; int m_columnIndexes[VORDEMOD_COLUMNS];//!< How the columns are ordered in the table int m_columnSizes[VORDEMOD_COLUMNS]; //!< Size of the coumns in the table