| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-19 13:31:45 +01:00
										 |  |  | // Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
 | 
					
						
							|  |  |  | // written by Christian Daniel                                                   //
 | 
					
						
							|  |  |  | // Copyright (C) 2014 John Greb <karikoa@One.greyskull>                          //
 | 
					
						
							|  |  |  | // Copyright (C) 2015, 2017-2023 Edouard Griffiths, F4EXB <f4exb06@gmail.com>    //
 | 
					
						
							|  |  |  | // Copyright (C) 2018 beta-tester <alpha-beta-release@gmx.net>                   //
 | 
					
						
							|  |  |  | // Copyright (C) 2022-2023 Jon Beniston, M7RCE <jon@beniston.com>                //
 | 
					
						
							|  |  |  | // Copyright (C) 2023 Arne Jünemann <das-iro@das-iro.de>                         //
 | 
					
						
							|  |  |  | // Copyright (C) 2023 Daniele Forsi <iu5hkx@gmail.com>                           //
 | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // OpenGL interface modernization.                                               //
 | 
					
						
							|  |  |  | // See: http://doc.qt.io/qt-5/qopenglshaderprogram.html                          //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is free software; you can redistribute it and/or modify          //
 | 
					
						
							|  |  |  | // it under the terms of the GNU General Public License as published by          //
 | 
					
						
							|  |  |  | // the Free Software Foundation as version 3 of the License, or                  //
 | 
					
						
							|  |  |  | // (at your option) any later version.                                           //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful,               //
 | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | 
					
						
							|  |  |  | // GNU General Public License V3 for more details.                               //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU General Public License             //
 | 
					
						
							|  |  |  | // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 00:54:19 +02:00
										 |  |  | #include <QLineEdit>
 | 
					
						
							|  |  |  | #include <QToolTip>
 | 
					
						
							| 
									
										
										
										
											2022-09-26 13:30:58 +01:00
										 |  |  | #include <QFileDialog>
 | 
					
						
							|  |  |  | #include <QMessageBox>
 | 
					
						
							| 
									
										
										
										
											2022-10-01 20:58:21 +02:00
										 |  |  | #include <QScreen>
 | 
					
						
							| 
									
										
										
										
											2020-06-19 00:54:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | #include "gui/glspectrumgui.h"
 | 
					
						
							|  |  |  | #include "dsp/fftwindow.h"
 | 
					
						
							|  |  |  | #include "dsp/spectrumvis.h"
 | 
					
						
							|  |  |  | #include "gui/glspectrum.h"
 | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  | #include "gui/glspectrumview.h"
 | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:56 +02:00
										 |  |  | #include "gui/crightclickenabler.h"
 | 
					
						
							|  |  |  | #include "gui/wsspectrumsettingsdialog.h"
 | 
					
						
							| 
									
										
										
										
											2021-07-31 22:57:31 +02:00
										 |  |  | #include "gui/spectrummarkersdialog.h"
 | 
					
						
							| 
									
										
										
										
											2022-01-30 07:43:50 +01:00
										 |  |  | #include "gui/spectrumcalibrationpointsdialog.h"
 | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  | #include "gui/spectrummeasurementsdialog.h"
 | 
					
						
							| 
									
										
										
										
											2022-09-28 16:59:35 +01:00
										 |  |  | #include "gui/spectrummeasurements.h"
 | 
					
						
							| 
									
										
										
										
											2022-03-19 12:18:55 +01:00
										 |  |  | #include "gui/flowlayout.h"
 | 
					
						
							| 
									
										
										
										
											2022-12-20 14:39:39 +00:00
										 |  |  | #include "gui/dialogpositioner.h"
 | 
					
						
							|  |  |  | #include "gui/dialpopup.h"
 | 
					
						
							| 
									
										
										
										
											2022-06-18 12:35:44 +01:00
										 |  |  | #include "util/colormap.h"
 | 
					
						
							| 
									
										
										
										
											2021-02-10 08:34:42 +01:00
										 |  |  | #include "util/db.h"
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | #include "ui_glspectrumgui.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-07 11:54:16 +01:00
										 |  |  | const int GLSpectrumGUI::m_fpsMs[] = {500, 200, 100, 50, 20, 10, 5}; | 
					
						
							| 
									
										
										
										
											2021-02-12 00:53:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) : | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     QWidget(parent), | 
					
						
							|  |  |  |     ui(new Ui::GLSpectrumGUI), | 
					
						
							|  |  |  |     m_spectrumVis(nullptr), | 
					
						
							|  |  |  |     m_glSpectrum(nullptr), | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  |     m_doApplySettings(true), | 
					
						
							| 
									
										
										
										
											2022-09-29 15:25:04 +02:00
										 |  |  |     m_calibrationShiftdB(0.0), | 
					
						
							|  |  |  |     m_markersDialog(nullptr) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     ui->setupUi(this); | 
					
						
							| 
									
										
										
										
											2022-03-19 12:18:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Use the custom flow layout for the 3 main horizontal layouts (lines)
 | 
					
						
							| 
									
										
										
										
											2022-06-24 03:33:32 +02:00
										 |  |  |     ui->verticalLayout->removeItem(ui->Line6Layout); | 
					
						
							| 
									
										
										
										
											2022-09-25 10:50:56 +01:00
										 |  |  |     ui->verticalLayout->removeItem(ui->Line5Layout); | 
					
						
							| 
									
										
										
										
											2022-04-09 22:05:02 +02:00
										 |  |  |     ui->verticalLayout->removeItem(ui->Line4Layout); | 
					
						
							| 
									
										
										
										
											2022-03-19 12:18:55 +01:00
										 |  |  |     ui->verticalLayout->removeItem(ui->Line3Layout); | 
					
						
							|  |  |  |     ui->verticalLayout->removeItem(ui->Line2Layout); | 
					
						
							|  |  |  |     ui->verticalLayout->removeItem(ui->Line1Layout); | 
					
						
							| 
									
										
										
										
											2022-03-25 02:52:40 +01:00
										 |  |  |     FlowLayout *flowLayout = new FlowLayout(nullptr, 1, 1, 1); | 
					
						
							| 
									
										
										
										
											2022-03-19 12:18:55 +01:00
										 |  |  |     flowLayout->addItem(ui->Line1Layout); | 
					
						
							|  |  |  |     flowLayout->addItem(ui->Line2Layout); | 
					
						
							| 
									
										
										
										
											2022-06-24 03:33:32 +02:00
										 |  |  |     flowLayout->addItem(ui->Line3Layout); | 
					
						
							|  |  |  |     flowLayout->addItem(ui->Line4Layout); | 
					
						
							| 
									
										
										
										
											2022-06-23 21:22:35 +02:00
										 |  |  |     flowLayout->addItem(ui->Line5Layout); | 
					
						
							| 
									
										
										
										
											2022-06-24 03:33:32 +02:00
										 |  |  |     flowLayout->addItem(ui->Line6Layout); | 
					
						
							| 
									
										
										
										
											2022-03-19 12:18:55 +01:00
										 |  |  |     ui->verticalLayout->addItem(flowLayout); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     on_linscale_toggled(false); | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  |     //displayMeasurementGUI();
 | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 00:54:19 +02:00
										 |  |  |     QString levelStyle = QString( | 
					
						
							|  |  |  |         "QSpinBox {background-color: rgb(79, 79, 79);}" | 
					
						
							|  |  |  |         "QLineEdit {color: white; background-color: rgb(79, 79, 79); border: 1px solid gray; border-radius: 4px;}" | 
					
						
							| 
									
										
										
										
											2023-07-23 16:44:42 +02:00
										 |  |  |         "QTooltip {color: white; background-color: black;}" | 
					
						
							| 
									
										
										
										
											2020-06-19 00:54:19 +02:00
										 |  |  |     ); | 
					
						
							|  |  |  |     ui->refLevel->setStyleSheet(levelStyle); | 
					
						
							|  |  |  |     ui->levelRange->setStyleSheet(levelStyle); | 
					
						
							| 
									
										
										
										
											2021-02-10 08:34:42 +01:00
										 |  |  |     ui->fftOverlap->setStyleSheet(levelStyle); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-22 08:52:48 +01:00
										 |  |  |     ui->colorMap->addItems(ColorMap::getColorMapNames()); | 
					
						
							|  |  |  |     ui->colorMap->setCurrentText("Angel"); | 
					
						
							| 
									
										
										
										
											2022-06-18 12:35:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     connect(&m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     CRightClickEnabler *wsSpectrumRightClickEnabler = new CRightClickEnabler(ui->wsSpectrum); | 
					
						
							|  |  |  |     connect(wsSpectrumRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(openWebsocketSpectrumSettingsDialog(const QPoint &))); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-30 07:43:50 +01:00
										 |  |  |     CRightClickEnabler *calibrationPointsRightClickEnabler = new CRightClickEnabler(ui->calibration); | 
					
						
							|  |  |  |     connect(calibrationPointsRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(openCalibrationPointsDialog(const QPoint &))); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 14:39:39 +00:00
										 |  |  |     DialPopup::addPopupsToChildDials(this); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     displaySettings(); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     setAveragingCombo(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | GLSpectrumGUI::~GLSpectrumGUI() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-09-29 15:25:04 +02:00
										 |  |  |     if (m_markersDialog) { | 
					
						
							|  |  |  |         delete m_markersDialog; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     delete ui; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  | void GLSpectrumGUI::setBuddies(SpectrumVis* spectrumVis, GLSpectrum* glSpectrum) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_spectrumVis = spectrumVis; | 
					
						
							|  |  |  |     m_glSpectrum = glSpectrum; | 
					
						
							| 
									
										
										
										
											2021-02-15 13:49:51 +01:00
										 |  |  |     m_glSpectrum->setSpectrumVis(spectrumVis); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_glSpectrum->setMessageQueueToGUI(&m_messageQueue); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     m_spectrumVis->setMessageQueueToGUI(&m_messageQueue); | 
					
						
							| 
									
										
										
										
											2023-04-08 14:24:16 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::resetToDefaults() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     m_settings.resetToDefaults(); | 
					
						
							|  |  |  |     displaySettings(); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QByteArray GLSpectrumGUI::serialize() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2021-08-08 04:28:22 +02:00
										 |  |  |     const_cast<GLSpectrumGUI*>(this)->m_settings.getHistogramMarkers() = m_glSpectrum->getHistogramMarkers(); | 
					
						
							|  |  |  |     const_cast<GLSpectrumGUI*>(this)->m_settings.getWaterfallMarkers() = m_glSpectrum->getWaterfallMarkers(); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     return m_settings.serialize(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool GLSpectrumGUI::deserialize(const QByteArray& data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     if (m_settings.deserialize(data)) | 
					
						
							| 
									
										
										
										
											2019-08-11 01:27:19 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2021-08-08 04:28:22 +02:00
										 |  |  |         m_glSpectrum->setHistogramMarkers(m_settings.getHistogramMarkers()); | 
					
						
							|  |  |  |         m_glSpectrum->setWaterfallMarkers(m_settings.getWaterfallMarkers()); | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  |         setAveragingCombo(); | 
					
						
							| 
									
										
										
										
											2020-08-29 11:10:11 +02:00
										 |  |  |         displaySettings(); // ends with blockApplySettings(false)
 | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |         applySettings(); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-08-11 01:27:19 +02:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |         resetToDefaults(); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-01 00:20:14 +01:00
										 |  |  | void GLSpectrumGUI::formatTo(SWGSDRangel::SWGObject *swgObject) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.formatTo(swgObject); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::updateFrom(const QStringList& keys, const SWGSDRangel::SWGObject *swgObject) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.updateFrom(keys, swgObject); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::updateSettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     displaySettings(); | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  | void GLSpectrumGUI::displaySettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     blockApplySettings(true); | 
					
						
							| 
									
										
										
										
											2022-12-20 14:39:39 +00:00
										 |  |  |     ui->showAllControls->setChecked(m_settings.m_showAllControls); | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  |     ui->refLevel->setValue(m_settings.m_refLevel + m_calibrationShiftdB); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     ui->levelRange->setValue(m_settings.m_powerRange); | 
					
						
							|  |  |  |     ui->decay->setSliderPosition(m_settings.m_decay); | 
					
						
							|  |  |  |     ui->decayDivisor->setSliderPosition(m_settings.m_decayDivisor); | 
					
						
							|  |  |  |     ui->stroke->setSliderPosition(m_settings.m_histogramStroke); | 
					
						
							|  |  |  |     ui->waterfall->setChecked(m_settings.m_displayWaterfall); | 
					
						
							| 
									
										
										
										
											2022-06-18 12:35:44 +01:00
										 |  |  |     ui->spectrogram->setChecked(m_settings.m_display3DSpectrogram); | 
					
						
							|  |  |  |     ui->spectrogramStyle->setCurrentIndex((int) m_settings.m_3DSpectrogramStyle); | 
					
						
							| 
									
										
										
										
											2022-12-20 14:39:39 +00:00
										 |  |  |     ui->spectrogramStyle->setVisible(m_settings.m_display3DSpectrogram && m_settings.m_showAllControls); | 
					
						
							| 
									
										
										
										
											2022-06-22 08:52:48 +01:00
										 |  |  |     ui->colorMap->setCurrentText(m_settings.m_colorMap); | 
					
						
							| 
									
										
										
										
											2022-06-23 21:22:35 +02:00
										 |  |  |     ui->currentLine->blockSignals(true); | 
					
						
							|  |  |  |     ui->currentFill->blockSignals(true); | 
					
						
							|  |  |  |     ui->currentGradient->blockSignals(true); | 
					
						
							|  |  |  |     ui->currentLine->setChecked(m_settings.m_displayCurrent && (m_settings.m_spectrumStyle == SpectrumSettings::SpectrumStyle::Line)); | 
					
						
							|  |  |  |     ui->currentFill->setChecked(m_settings.m_displayCurrent && (m_settings.m_spectrumStyle == SpectrumSettings::SpectrumStyle::Fill)); | 
					
						
							|  |  |  |     ui->currentGradient->setChecked(m_settings.m_displayCurrent && (m_settings.m_spectrumStyle == SpectrumSettings::SpectrumStyle::Gradient)); | 
					
						
							|  |  |  |     ui->currentLine->blockSignals(false); | 
					
						
							|  |  |  |     ui->currentFill->blockSignals(false); | 
					
						
							|  |  |  |     ui->currentGradient->blockSignals(false); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     ui->maxHold->setChecked(m_settings.m_displayMaxHold); | 
					
						
							|  |  |  |     ui->histogram->setChecked(m_settings.m_displayHistogram); | 
					
						
							|  |  |  |     ui->invertWaterfall->setChecked(m_settings.m_invertedWaterfall); | 
					
						
							|  |  |  |     ui->grid->setChecked(m_settings.m_displayGrid); | 
					
						
							|  |  |  |     ui->gridIntensity->setSliderPosition(m_settings.m_displayGridIntensity); | 
					
						
							| 
									
										
										
										
											2022-10-16 04:48:07 +02:00
										 |  |  |     ui->truncateScale->setChecked(m_settings.m_truncateFreqScale); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->decay->setToolTip(QString("Decay: %1").arg(m_settings.m_decay)); | 
					
						
							|  |  |  |     ui->decayDivisor->setToolTip(QString("Decay divisor: %1").arg(m_settings.m_decayDivisor)); | 
					
						
							|  |  |  |     ui->stroke->setToolTip(QString("Stroke: %1").arg(m_settings.m_histogramStroke)); | 
					
						
							|  |  |  |     ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_settings.m_displayGridIntensity)); | 
					
						
							|  |  |  |     ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(m_settings.m_displayTraceIntensity)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->fftWindow->blockSignals(true); | 
					
						
							|  |  |  |     ui->averaging->blockSignals(true); | 
					
						
							|  |  |  |     ui->averagingMode->blockSignals(true); | 
					
						
							|  |  |  |     ui->linscale->blockSignals(true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->fftWindow->setCurrentIndex(m_settings.m_fftWindow); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int i = SpectrumSettings::m_log2FFTSizeMin; i <= SpectrumSettings::m_log2FFTSizeMax; i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_settings.m_fftSize == (1 << i)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             ui->fftSize->setCurrentIndex(i - SpectrumSettings::m_log2FFTSizeMin); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-03-12 15:31:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-21 07:20:56 +02:00
										 |  |  |     setFFTSizeToolitp(); | 
					
						
							| 
									
										
										
										
											2021-03-07 11:54:16 +01:00
										 |  |  |     unsigned int i = 0; | 
					
						
							| 
									
										
										
										
											2021-02-12 00:53:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-07 11:54:16 +01:00
										 |  |  |     for (; i < sizeof(m_fpsMs)/sizeof(m_fpsMs[0]); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_settings.m_fpsPeriodMs >= m_fpsMs[i]) { | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2021-02-12 00:53:18 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-07 11:54:16 +01:00
										 |  |  |     ui->fps->setCurrentIndex(i); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-09 07:12:32 +01:00
										 |  |  |     ui->fftOverlap->setValue(m_settings.m_fftOverlap); | 
					
						
							|  |  |  |     setMaximumOverlap(); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     ui->averaging->setCurrentIndex(m_settings.m_averagingIndex); | 
					
						
							|  |  |  |     ui->averagingMode->setCurrentIndex((int) m_settings.m_averagingMode); | 
					
						
							|  |  |  |     ui->linscale->setChecked(m_settings.m_linear); | 
					
						
							|  |  |  |     setAveragingToolitp(); | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  |     ui->calibration->setChecked(m_settings.m_useCalibration); | 
					
						
							| 
									
										
										
										
											2023-01-15 12:01:37 +00:00
										 |  |  |     ui->resetMeasurements->setVisible(m_settings.m_measurement >= SpectrumSettings::MeasurementChannelPower); | 
					
						
							| 
									
										
										
										
											2022-06-24 23:37:22 +01:00
										 |  |  |     displayGotoMarkers(); | 
					
						
							| 
									
										
										
										
											2022-12-20 14:39:39 +00:00
										 |  |  |     displayControls(); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->fftWindow->blockSignals(false); | 
					
						
							|  |  |  |     ui->averaging->blockSignals(false); | 
					
						
							|  |  |  |     ui->averagingMode->blockSignals(false); | 
					
						
							|  |  |  |     ui->linscale->blockSignals(false); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     blockApplySettings(false); | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     updateMeasurements(); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 14:39:39 +00:00
										 |  |  | void GLSpectrumGUI::displayControls() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->grid->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->gridIntensity->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->truncateScale->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->clearSpectrum->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->histogram->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->maxHold->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->decay->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->decayDivisor->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->stroke->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->currentLine->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->currentFill->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->currentGradient->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->traceIntensity->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->colorMap->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->invertWaterfall->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->waterfall->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->spectrogram->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->spectrogramStyle->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->fftWindow->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->fftSize->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->fftOverlap->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->fps->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->linscale->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->save->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->wsSpectrum->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->calibration->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  |     ui->markers->setVisible(m_settings.m_showAllControls); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-24 23:37:22 +01:00
										 |  |  | void GLSpectrumGUI::displayGotoMarkers() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->gotoMarker->clear(); | 
					
						
							|  |  |  |     ui->gotoMarker->addItem("Go to..."); | 
					
						
							| 
									
										
										
										
											2022-06-25 02:53:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-24 23:37:22 +01:00
										 |  |  |     for (auto marker : m_settings.m_annoationMarkers) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (marker.m_show != SpectrumAnnotationMarker::Hidden) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             qint64 freq = marker.m_startFrequency + marker.m_bandwidth/2; | 
					
						
							|  |  |  |             QString freqString = displayScaled(freq, 'f', 3, true); | 
					
						
							|  |  |  |             ui->gotoMarker->addItem(QString("%1 - %2").arg(marker.m_text).arg(freqString)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-06-25 02:53:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->gotoMarker->setVisible(m_glSpectrum && m_glSpectrum->isDeviceSpectrum() && (ui->gotoMarker->count() > 1)); | 
					
						
							| 
									
										
										
										
											2022-06-24 23:37:22 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString GLSpectrumGUI::displayScaled(int64_t value, char type, int precision, bool showMult) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int64_t posValue = (value < 0) ? -value : value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (posValue < 1000) { | 
					
						
							|  |  |  |         return tr("%1").arg(QString::number(value, type, precision)); | 
					
						
							|  |  |  |     } else if (posValue < 1000000) { | 
					
						
							|  |  |  |         return tr("%1%2").arg(QString::number(value / 1000.0, type, precision)).arg(showMult ? "k" : ""); | 
					
						
							|  |  |  |     } else if (posValue < 1000000000) { | 
					
						
							|  |  |  |         return tr("%1%2").arg(QString::number(value / 1000000.0, type, precision)).arg(showMult ? "M" : ""); | 
					
						
							|  |  |  |     } else if (posValue < 1000000000000) { | 
					
						
							|  |  |  |         return tr("%1%2").arg(QString::number(value / 1000000000.0, type, precision)).arg(showMult ? "G" : ""); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return tr("%1").arg(QString::number(value, 'e', precision)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-25 02:53:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  | void GLSpectrumGUI::blockApplySettings(bool block) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_doApplySettings = !block; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::applySettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!m_doApplySettings) { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_spectrumVis) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:56 +02:00
										 |  |  |         SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(m_settings, false); | 
					
						
							|  |  |  |         m_spectrumVis->getInputMessageQueue()->push(msg); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-20 10:32:21 +02:00
										 |  |  | void GLSpectrumGUI::applySpectrumSettings() | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     m_glSpectrum->setDisplayWaterfall(m_settings.m_displayWaterfall); | 
					
						
							| 
									
										
										
										
											2022-06-18 12:35:44 +01:00
										 |  |  |     m_glSpectrum->setDisplay3DSpectrogram(m_settings.m_display3DSpectrogram); | 
					
						
							|  |  |  |     m_glSpectrum->set3DSpectrogramStyle(m_settings.m_3DSpectrogramStyle); | 
					
						
							| 
									
										
										
										
											2022-06-22 08:52:48 +01:00
										 |  |  |     m_glSpectrum->setColorMapName(m_settings.m_colorMap); | 
					
						
							|  |  |  |     m_glSpectrum->setSpectrumStyle(m_settings.m_spectrumStyle); | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |     m_glSpectrum->setInvertedWaterfall(m_settings.m_invertedWaterfall); | 
					
						
							|  |  |  |     m_glSpectrum->setDisplayMaxHold(m_settings.m_displayMaxHold); | 
					
						
							|  |  |  |     m_glSpectrum->setDisplayCurrent(m_settings.m_displayCurrent); | 
					
						
							|  |  |  |     m_glSpectrum->setDisplayHistogram(m_settings.m_displayHistogram); | 
					
						
							|  |  |  |     m_glSpectrum->setDecay(m_settings.m_decay); | 
					
						
							|  |  |  |     m_glSpectrum->setDecayDivisor(m_settings.m_decayDivisor); | 
					
						
							|  |  |  |     m_glSpectrum->setHistoStroke(m_settings.m_histogramStroke); | 
					
						
							|  |  |  |     m_glSpectrum->setDisplayGrid(m_settings.m_displayGrid); | 
					
						
							|  |  |  |     m_glSpectrum->setDisplayGridIntensity(m_settings.m_displayGridIntensity); | 
					
						
							|  |  |  |     m_glSpectrum->setDisplayTraceIntensity(m_settings.m_displayTraceIntensity); | 
					
						
							| 
									
										
										
										
											2020-11-15 21:56:45 +01:00
										 |  |  |     m_glSpectrum->setWaterfallShare(m_settings.m_waterfallShare); | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-20 10:32:21 +02:00
										 |  |  |     if ((m_settings.m_averagingMode == SpectrumSettings::AvgModeFixed) || (m_settings.m_averagingMode == SpectrumSettings::AvgModeMax)) { | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  |         m_glSpectrum->setTimingRate(SpectrumSettings::getAveragingValue(m_settings.m_averagingIndex, m_settings.m_averagingMode) == 0 ? | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |             1 : | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  |            SpectrumSettings::getAveragingValue(m_settings.m_averagingIndex, m_settings.m_averagingMode)); | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |     } else { | 
					
						
							|  |  |  |         m_glSpectrum->setTimingRate(1); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Real refLevel = m_settings.m_linear ? pow(10.0, m_settings.m_refLevel/10.0) : m_settings.m_refLevel; | 
					
						
							|  |  |  |     Real powerRange = m_settings.m_linear ? pow(10.0, m_settings.m_refLevel/10.0) :  m_settings.m_powerRange; | 
					
						
							| 
									
										
										
										
											2023-04-08 14:24:16 +02:00
										 |  |  |     qDebug("GLSpectrumGUI::applySpectrumSettings: refLevel: %e powerRange: %e", refLevel, powerRange); | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |     m_glSpectrum->setReferenceLevel(refLevel); | 
					
						
							|  |  |  |     m_glSpectrum->setPowerRange(powerRange); | 
					
						
							| 
									
										
										
										
											2021-02-12 00:53:18 +01:00
										 |  |  |     m_glSpectrum->setFPSPeriodMs(m_settings.m_fpsPeriodMs); | 
					
						
							| 
									
										
										
										
											2022-10-16 04:48:07 +02:00
										 |  |  |     m_glSpectrum->setFreqScaleTruncationMode(m_settings.m_truncateFreqScale); | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |     m_glSpectrum->setLinear(m_settings.m_linear); | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  |     m_glSpectrum->setUseCalibration(m_settings.m_useCalibration); | 
					
						
							| 
									
										
										
										
											2022-01-15 19:19:47 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_glSpectrum->setHistogramMarkers(m_settings.m_histogramMarkers); | 
					
						
							|  |  |  |     m_glSpectrum->setWaterfallMarkers(m_settings.m_waterfallMarkers); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_glSpectrum->setAnnotationMarkers(m_settings.m_annoationMarkers); | 
					
						
							| 
									
										
										
										
											2022-01-22 06:57:46 +01:00
										 |  |  |     m_glSpectrum->setMarkersDisplay(m_settings.m_markersDisplay); | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  |     m_glSpectrum->setCalibrationPoints(m_settings.m_calibrationPoints); | 
					
						
							|  |  |  |     m_glSpectrum->setCalibrationInterpMode(m_settings.m_calibrationInterpMode); | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | void GLSpectrumGUI::on_fftWindow_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     qDebug("GLSpectrumGUI::on_fftWindow_currentIndexChanged: %d", index); | 
					
						
							|  |  |  |     m_settings.m_fftWindow = (FFTWindow::Function) index; | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::on_fftSize_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     qDebug("GLSpectrumGUI::on_fftSize_currentIndexChanged: %d", index); | 
					
						
							|  |  |  |     m_settings.m_fftSize = 1 << (SpectrumSettings::m_log2FFTSizeMin + index); | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  |     setAveragingCombo(); | 
					
						
							| 
									
										
										
										
											2021-02-09 07:12:32 +01:00
										 |  |  |     setMaximumOverlap(); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     applySettings(); | 
					
						
							|  |  |  |     setAveragingToolitp(); | 
					
						
							| 
									
										
										
										
											2021-04-21 07:20:56 +02:00
										 |  |  |     setFFTSizeToolitp(); | 
					
						
							| 
									
										
										
										
											2018-06-30 22:30:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-09 07:12:32 +01:00
										 |  |  | void GLSpectrumGUI::on_fftOverlap_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     qDebug("GLSpectrumGUI::on_fftOverlap_valueChanged: %d", value); | 
					
						
							|  |  |  |     m_settings.m_fftOverlap = value; | 
					
						
							|  |  |  |     setMaximumOverlap(); | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2021-02-09 07:39:03 +01:00
										 |  |  |     setAveragingToolitp(); | 
					
						
							| 
									
										
										
										
											2021-02-09 07:12:32 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-10 08:34:42 +01:00
										 |  |  | void GLSpectrumGUI::on_autoscale_clicked(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     (void) checked; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!m_spectrumVis) { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<Real> psd; | 
					
						
							| 
									
										
										
										
											2021-02-18 06:23:12 +01:00
										 |  |  |     m_spectrumVis->getZoomedPSDCopy(psd); | 
					
						
							| 
									
										
										
										
											2021-02-10 08:34:42 +01:00
										 |  |  |     int avgRange = m_settings.m_fftSize / 32; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (psd.size() < (unsigned int) avgRange) { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::sort(psd.begin(), psd.end()); | 
					
						
							| 
									
										
										
										
											2021-02-11 05:13:13 +01:00
										 |  |  |     float max = psd[psd.size() - 1]; | 
					
						
							|  |  |  |     float minSum = 0.0f; | 
					
						
							| 
									
										
										
										
											2021-02-10 08:34:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-11 05:13:13 +01:00
										 |  |  |     for (int i = 0; i < avgRange; i++) { | 
					
						
							| 
									
										
										
										
											2021-02-10 08:34:42 +01:00
										 |  |  |         minSum += psd[i]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     float minAvg = minSum / avgRange; | 
					
						
							|  |  |  |     int minLvl = CalcDb::dbPower(minAvg*2); | 
					
						
							| 
									
										
										
										
											2021-02-11 05:13:13 +01:00
										 |  |  |     int maxLvl = CalcDb::dbPower(max*10); | 
					
						
							| 
									
										
										
										
											2021-02-10 08:34:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_settings.m_refLevel = maxLvl; | 
					
						
							|  |  |  |     m_settings.m_powerRange = maxLvl - minLvl; | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  |     ui->refLevel->setValue(m_settings.m_refLevel + m_calibrationShiftdB); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     ui->levelRange->setValue(m_settings.m_powerRange); | 
					
						
							| 
									
										
										
										
											2021-02-10 08:34:42 +01:00
										 |  |  |     // qDebug("GLSpectrumGUI::on_autoscale_clicked: max: %d min %d max: %e min: %e",
 | 
					
						
							|  |  |  |     //     maxLvl, minLvl, maxAvg, minAvg);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-01 02:16:59 +02:00
										 |  |  | void GLSpectrumGUI::on_averagingMode_currentIndexChanged(int index) | 
					
						
							| 
									
										
										
										
											2018-06-30 22:30:42 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     qDebug("GLSpectrumGUI::on_averagingMode_currentIndexChanged: %d", index); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     m_settings.m_averagingMode = index < 0 ? | 
					
						
							| 
									
										
										
										
											2021-04-20 10:32:21 +02:00
										 |  |  |         SpectrumSettings::AvgModeNone : | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |         index > 3 ? | 
					
						
							| 
									
										
										
										
											2021-04-20 10:32:21 +02:00
										 |  |  |             SpectrumSettings::AvgModeMax : | 
					
						
							|  |  |  |             (SpectrumSettings::AveragingMode) index; | 
					
						
							| 
									
										
										
										
											2018-07-01 03:11:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-01 05:33:44 +02:00
										 |  |  |     setAveragingCombo(); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2021-02-13 10:01:55 +01:00
										 |  |  |     setAveragingToolitp(); | 
					
						
							| 
									
										
										
										
											2018-06-30 22:30:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::on_averaging_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     qDebug("GLSpectrumGUI::on_averaging_currentIndexChanged: %d", index); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     m_settings.m_averagingIndex = index; | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2018-07-01 20:48:30 +02:00
										 |  |  |     setAveragingToolitp(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-04 23:11:28 +02:00
										 |  |  | void GLSpectrumGUI::on_linscale_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     qDebug("GLSpectrumGUI::on_averaging_currentIndexChanged: %s", checked ? "lin" : "log"); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     m_settings.m_linear = checked; | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2018-07-04 23:11:28 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-02 00:35:47 +02:00
										 |  |  | void GLSpectrumGUI::on_wsSpectrum_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_spectrumVis) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         SpectrumVis::MsgConfigureWSpectrumOpenClose *msg = SpectrumVis::MsgConfigureWSpectrumOpenClose::create(checked); | 
					
						
							|  |  |  |         m_spectrumVis->getInputMessageQueue()->push(msg); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-31 22:57:31 +02:00
										 |  |  | void GLSpectrumGUI::on_markers_clicked(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     (void) checked; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 15:25:04 +02:00
										 |  |  |     if (!m_glSpectrum || m_markersDialog) { | 
					
						
							| 
									
										
										
										
											2021-07-31 22:57:31 +02:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 15:25:04 +02:00
										 |  |  |     m_markersDialog = new SpectrumMarkersDialog( | 
					
						
							| 
									
										
										
										
											2021-08-01 10:03:58 +02:00
										 |  |  |         m_glSpectrum->getHistogramMarkers(), | 
					
						
							|  |  |  |         m_glSpectrum->getWaterfallMarkers(), | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |         m_glSpectrum->getAnnotationMarkers(), | 
					
						
							| 
									
										
										
										
											2021-08-04 19:28:52 +02:00
										 |  |  |         m_glSpectrum->getMarkersDisplay(), | 
					
						
							| 
									
										
										
										
											2022-10-03 00:23:47 +02:00
										 |  |  |         m_glSpectrum->getHistogramFindPeaks(), | 
					
						
							| 
									
										
										
										
											2022-02-05 11:56:08 +01:00
										 |  |  |         m_calibrationShiftdB, | 
					
						
							| 
									
										
										
										
											2021-08-01 10:03:58 +02:00
										 |  |  |         this | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 15:25:04 +02:00
										 |  |  |     m_markersDialog->setCenterFrequency(m_glSpectrum->getCenterFrequency()); | 
					
						
							|  |  |  |     m_markersDialog->setPower(m_glSpectrum->getPowerMax() / 2.0f); | 
					
						
							|  |  |  |     m_markersDialog->setTime(m_glSpectrum->getTimeMax() / 2.0f); | 
					
						
							| 
									
										
										
										
											2021-07-31 22:57:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 15:25:04 +02:00
										 |  |  |     connect(m_markersDialog, SIGNAL(updateHistogram()), this, SLOT(updateHistogramMarkers())); | 
					
						
							|  |  |  |     connect(m_markersDialog, SIGNAL(updateWaterfall()), this, SLOT(updateWaterfallMarkers())); | 
					
						
							|  |  |  |     connect(m_markersDialog, SIGNAL(updateAnnotations()), this, SLOT(updateAnnotationMarkers())); | 
					
						
							|  |  |  |     connect(m_markersDialog, SIGNAL(updateMarkersDisplay()), this, SLOT(updateMarkersDisplay())); | 
					
						
							|  |  |  |     connect(m_markersDialog, SIGNAL(finished(int)), this, SLOT(closeMarkersDialog())); | 
					
						
							| 
									
										
										
										
											2021-07-31 22:57:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-01 07:32:55 +02:00
										 |  |  |     QPoint globalCursorPos = QCursor::pos(); | 
					
						
							| 
									
										
										
										
											2022-10-01 20:58:21 +02:00
										 |  |  |     QScreen *screen = QGuiApplication::screenAt(globalCursorPos); | 
					
						
							|  |  |  |     QRect mouseScreenGeometry = screen->geometry(); | 
					
						
							| 
									
										
										
										
											2022-10-01 07:32:55 +02:00
										 |  |  |     QPoint localCursorPos = globalCursorPos - mouseScreenGeometry.topLeft(); | 
					
						
							|  |  |  |     m_markersDialog->move(localCursorPos); | 
					
						
							| 
									
										
										
										
											2022-12-20 14:39:39 +00:00
										 |  |  |     new DialogPositioner(m_markersDialog, false); | 
					
						
							| 
									
										
										
										
											2022-10-01 07:32:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 15:25:04 +02:00
										 |  |  |     m_markersDialog->show(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-01-15 19:19:47 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 15:25:04 +02:00
										 |  |  | void GLSpectrumGUI::closeMarkersDialog() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-15 19:19:47 +01:00
										 |  |  |     m_settings.m_histogramMarkers = m_glSpectrum->getHistogramMarkers(); | 
					
						
							|  |  |  |     m_settings.m_waterfallMarkers = m_glSpectrum->getWaterfallMarkers(); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_annoationMarkers = m_glSpectrum->getAnnotationMarkers(); | 
					
						
							| 
									
										
										
										
											2022-01-22 06:57:46 +01:00
										 |  |  |     m_settings.m_markersDisplay = m_glSpectrum->getMarkersDisplay(); | 
					
						
							| 
									
										
										
										
											2022-01-15 19:19:47 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-25 02:53:11 +02:00
										 |  |  |     displayGotoMarkers(); | 
					
						
							| 
									
										
										
										
											2022-01-15 19:19:47 +01:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2022-09-29 15:25:04 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     delete m_markersDialog; | 
					
						
							|  |  |  |     m_markersDialog = nullptr; | 
					
						
							| 
									
										
										
										
											2021-07-31 22:57:31 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-26 18:03:14 +01:00
										 |  |  | // Save spectrum data to a CSV file
 | 
					
						
							| 
									
										
										
										
											2022-09-26 13:30:58 +01:00
										 |  |  | void GLSpectrumGUI::on_save_clicked(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-09-26 13:32:00 +01:00
										 |  |  |     (void) checked; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-26 13:30:58 +01:00
										 |  |  |     // Get filename to write
 | 
					
						
							| 
									
										
										
										
											2022-09-26 18:03:14 +01:00
										 |  |  |     QFileDialog fileDialog(nullptr, "Select file to save data to", "", "*.csv"); | 
					
						
							| 
									
										
										
										
											2022-09-26 13:30:58 +01:00
										 |  |  |     fileDialog.setAcceptMode(QFileDialog::AcceptSave); | 
					
						
							|  |  |  |     if (fileDialog.exec()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QStringList fileNames = fileDialog.selectedFiles(); | 
					
						
							|  |  |  |         if (fileNames.size() > 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             // Get spectrum data (This vector can be larger than fftSize)
 | 
					
						
							|  |  |  |             std::vector<Real> spectrum; | 
					
						
							|  |  |  |             m_spectrumVis->getPowerSpectrumCopy(spectrum); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // Write to text file
 | 
					
						
							|  |  |  |             QFile file(fileNames[0]); | 
					
						
							|  |  |  |             if (file.open(QIODevice::WriteOnly)) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QTextStream out(&file); | 
					
						
							| 
									
										
										
										
											2022-09-26 18:03:14 +01:00
										 |  |  |                 float frequency = m_glSpectrum->getCenterFrequency() - (m_glSpectrum->getSampleRate() / 2.0f); | 
					
						
							|  |  |  |                 float rbw = m_glSpectrum->getSampleRate() / (float)m_settings.m_fftSize; | 
					
						
							|  |  |  |                 out << "\"Frequency\",\"Power\"\n"; | 
					
						
							|  |  |  |                 for (int i = 0; i < m_settings.m_fftSize; i++) | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     out << frequency << "," << spectrum[i] << "\n"; | 
					
						
							|  |  |  |                     frequency += rbw; | 
					
						
							| 
									
										
										
										
											2022-09-26 13:30:58 +01:00
										 |  |  |                 } | 
					
						
							|  |  |  |                 file.close(); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QMessageBox::critical(this, "Spectrum", QString("Failed to open file %1").arg(fileNames[0])); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 00:54:19 +02:00
										 |  |  | void GLSpectrumGUI::on_refLevel_valueChanged(int value) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  |     m_settings.m_refLevel = value - m_calibrationShiftdB; | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 00:54:19 +02:00
										 |  |  | void GLSpectrumGUI::on_levelRange_valueChanged(int value) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_powerRange = value; | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-12 00:53:18 +01:00
										 |  |  | void GLSpectrumGUI::on_fps_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_fpsPeriodMs = m_fpsMs[index]; | 
					
						
							|  |  |  |     qDebug("GLSpectrumGUI::on_fps_currentIndexChanged: %d ms", m_settings.m_fpsPeriodMs); | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-15 08:48:02 +02:00
										 |  |  | void GLSpectrumGUI::on_decay_valueChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_decay = index; | 
					
						
							|  |  |  |     ui->decay->setToolTip(QString("Decay: %1").arg(m_settings.m_decay)); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2015-07-15 08:48:02 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-19 00:40:14 +02:00
										 |  |  | void GLSpectrumGUI::on_decayDivisor_valueChanged(int index) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_decayDivisor = index; | 
					
						
							|  |  |  |     ui->decayDivisor->setToolTip(QString("Decay divisor: %1").arg(m_settings.m_decayDivisor)); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2015-07-15 08:48:02 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::on_stroke_valueChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_histogramStroke = index; | 
					
						
							|  |  |  |     ui->stroke->setToolTip(QString("Stroke: %1").arg(m_settings.m_histogramStroke)); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-18 12:35:44 +01:00
										 |  |  | void GLSpectrumGUI::on_spectrogramStyle_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_3DSpectrogramStyle = (SpectrumSettings::SpectrogramStyle)index; | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-22 08:52:48 +01:00
										 |  |  | void GLSpectrumGUI::on_colorMap_currentIndexChanged(int index) | 
					
						
							| 
									
										
										
										
											2022-06-18 12:35:44 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     (void) index; | 
					
						
							| 
									
										
										
										
											2022-06-22 08:52:48 +01:00
										 |  |  |     m_settings.m_colorMap = ui->colorMap->currentText(); | 
					
						
							| 
									
										
										
										
											2022-06-18 12:35:44 +01:00
										 |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | void GLSpectrumGUI::on_waterfall_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_displayWaterfall = checked; | 
					
						
							| 
									
										
										
										
											2022-06-18 12:35:44 +01:00
										 |  |  |     if (checked) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         ui->spectrogram->setChecked(false); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::on_spectrogram_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_display3DSpectrogram = checked; | 
					
						
							|  |  |  |     if (checked) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         ui->waterfall->setChecked(false); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-12-20 14:39:39 +00:00
										 |  |  |     ui->spectrogramStyle->setVisible(m_settings.m_display3DSpectrogram && m_settings.m_showAllControls); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::on_histogram_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_displayHistogram = checked; | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::on_maxHold_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_displayMaxHold = checked; | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-23 21:22:35 +02:00
										 |  |  | void GLSpectrumGUI::on_currentLine_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->currentFill->blockSignals(true); | 
					
						
							|  |  |  |     ui->currentGradient->blockSignals(true); | 
					
						
							|  |  |  |     ui->currentFill->setChecked(false); | 
					
						
							|  |  |  |     ui->currentGradient->setChecked(false); | 
					
						
							|  |  |  |     ui->currentFill->blockSignals(false); | 
					
						
							|  |  |  |     ui->currentGradient->blockSignals(false); | 
					
						
							|  |  |  |     m_settings.m_spectrumStyle = SpectrumSettings::SpectrumStyle::Line; | 
					
						
							|  |  |  |     m_settings.m_displayCurrent = checked; | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::on_currentFill_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->currentLine->blockSignals(true); | 
					
						
							|  |  |  |     ui->currentGradient->blockSignals(true); | 
					
						
							|  |  |  |     ui->currentLine->setChecked(false); | 
					
						
							|  |  |  |     ui->currentGradient->setChecked(false); | 
					
						
							|  |  |  |     ui->currentLine->blockSignals(false); | 
					
						
							|  |  |  |     ui->currentGradient->blockSignals(false); | 
					
						
							|  |  |  |     m_settings.m_spectrumStyle = SpectrumSettings::SpectrumStyle::Fill; | 
					
						
							|  |  |  |     m_settings.m_displayCurrent = checked; | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::on_currentGradient_toggled(bool checked) | 
					
						
							| 
									
										
										
										
											2015-07-16 04:55:14 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-06-23 21:22:35 +02:00
										 |  |  |     ui->currentLine->blockSignals(true); | 
					
						
							|  |  |  |     ui->currentFill->blockSignals(true); | 
					
						
							|  |  |  |     ui->currentLine->setChecked(false); | 
					
						
							|  |  |  |     ui->currentFill->setChecked(false); | 
					
						
							|  |  |  |     ui->currentLine->blockSignals(false); | 
					
						
							|  |  |  |     ui->currentFill->blockSignals(false); | 
					
						
							|  |  |  |     m_settings.m_spectrumStyle = SpectrumSettings::SpectrumStyle::Gradient; | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_displayCurrent = checked; | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2015-07-16 04:55:14 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-10 16:38:12 +01:00
										 |  |  | void GLSpectrumGUI::on_invertWaterfall_toggled(bool checked) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_invertedWaterfall = checked; | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 14:39:39 +00:00
										 |  |  | void GLSpectrumGUI::on_showAllControls_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_showAllControls = checked; | 
					
						
							|  |  |  |     displayControls(); | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | void GLSpectrumGUI::on_grid_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_displayGrid = checked; | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-05-12 15:49:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::on_gridIntensity_valueChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_displayGridIntensity = index; | 
					
						
							|  |  |  |     ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_settings.m_displayGridIntensity)); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2015-05-12 15:49:03 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-18 17:53:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-16 04:48:07 +02:00
										 |  |  | void GLSpectrumGUI::on_truncateScale_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_truncateFreqScale = checked; | 
					
						
							|  |  |  |     qDebug("GLSpectrumGUI::on_truncateScale_toggled: m_truncateFreqScale: %s", (m_settings.m_truncateFreqScale ? "on" : "off")); | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-18 17:53:57 +02:00
										 |  |  | void GLSpectrumGUI::on_traceIntensity_valueChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     m_settings.m_displayTraceIntensity = index; | 
					
						
							|  |  |  |     ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(m_settings.m_displayTraceIntensity)); | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |     applySettings(); | 
					
						
							| 
									
										
										
										
											2015-07-18 17:53:57 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-24 01:09:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-12 18:36:27 +01:00
										 |  |  | void GLSpectrumGUI::on_clearSpectrum_clicked(bool checked) | 
					
						
							| 
									
										
										
										
											2015-07-24 01:09:03 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-11-12 18:36:27 +01:00
										 |  |  |     (void) checked; | 
					
						
							| 
									
										
										
										
											2020-03-12 15:31:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     if (m_glSpectrum) { | 
					
						
							|  |  |  |         m_glSpectrum->clearSpectrumHistogram(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-07-24 01:09:03 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-06-30 22:30:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 10:03:41 +02:00
										 |  |  | void GLSpectrumGUI::on_freeze_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SpectrumVis::MsgStartStop *msg = SpectrumVis::MsgStartStop::create(!checked); | 
					
						
							|  |  |  |     m_spectrumVis->getInputMessageQueue()->push(msg); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  | void GLSpectrumGUI::on_calibration_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_useCalibration = checked; | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-24 23:37:22 +01:00
										 |  |  | void GLSpectrumGUI::on_gotoMarker_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-11-17 14:41:55 +00:00
										 |  |  |     if (index <= 0) { | 
					
						
							| 
									
										
										
										
											2022-06-24 23:37:22 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     int i = 1; | 
					
						
							|  |  |  |     for (auto marker : m_settings.m_annoationMarkers) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (marker.m_show != SpectrumAnnotationMarker::Hidden) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (i == index) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 emit requestCenterFrequency(marker.m_startFrequency + marker.m_bandwidth/2); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             i++; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ui->gotoMarker->setCurrentIndex(0); // Redisplay "Goto..."
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-01 00:55:30 +02:00
										 |  |  | void GLSpectrumGUI::setAveragingCombo() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-10-16 23:56:09 +02:00
										 |  |  |     int index = ui->averaging->currentIndex(); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     ui->averaging->blockSignals(true); | 
					
						
							| 
									
										
										
										
											2018-07-01 00:55:30 +02:00
										 |  |  |     ui->averaging->clear(); | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  |     ui->averaging->addItem(QString("1")); | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  |     uint64_t maxAveraging = SpectrumSettings::getMaxAveragingValue(m_settings.m_fftSize, m_settings.m_averagingMode); | 
					
						
							| 
									
										
										
										
											2018-07-01 00:55:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  |     for (int i = 0; i <= SpectrumSettings::getAveragingMaxScale(m_settings.m_averagingMode); i++) | 
					
						
							| 
									
										
										
										
											2018-07-01 00:55:30 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         QString s; | 
					
						
							|  |  |  |         int m = pow(10.0, i); | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  |         uint64_t x = 2*m; | 
					
						
							|  |  |  |         if (x > maxAveraging) { | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-07-01 00:55:30 +02:00
										 |  |  |         setNumberStr(x, s); | 
					
						
							|  |  |  |         ui->averaging->addItem(s); | 
					
						
							|  |  |  |         x = 5*m; | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  |         if (x > maxAveraging) { | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-07-01 00:55:30 +02:00
										 |  |  |         setNumberStr(x, s); | 
					
						
							|  |  |  |         ui->averaging->addItem(s); | 
					
						
							|  |  |  |         x = 10*m; | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  |         if (x > maxAveraging) { | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-07-01 00:55:30 +02:00
										 |  |  |         setNumberStr(x, s); | 
					
						
							|  |  |  |         ui->averaging->addItem(s); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-10-16 23:56:09 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->averaging->setCurrentIndex(index >= ui->averaging->count() ? ui->averaging->count() - 1 : index); | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  |     ui->averaging->blockSignals(false); | 
					
						
							| 
									
										
										
										
											2018-07-01 00:55:30 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::setNumberStr(int n, QString& s) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (n < 1000) { | 
					
						
							|  |  |  |         s = tr("%1").arg(n); | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  |     } else if (n < 100000) { | 
					
						
							| 
									
										
										
										
											2018-07-01 00:55:30 +02:00
										 |  |  |         s = tr("%1k").arg(n/1000); | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  |     } else if (n < 1000000) { | 
					
						
							|  |  |  |         s = tr("%1e5").arg(n/100000); | 
					
						
							| 
									
										
										
										
											2018-07-01 00:55:30 +02:00
										 |  |  |     } else if (n < 1000000000) { | 
					
						
							|  |  |  |         s = tr("%1M").arg(n/1000000); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         s = tr("%1G").arg(n/1000000000); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-07-01 20:48:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::setNumberStr(float v, int decimalPlaces, QString& s) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (v < 1e-6) { | 
					
						
							|  |  |  |         s = tr("%1n").arg(v*1e9, 0, 'f', decimalPlaces); | 
					
						
							|  |  |  |     } else if (v < 1e-3) { | 
					
						
							|  |  |  |         s = tr("%1µ").arg(v*1e6, 0, 'f', decimalPlaces); | 
					
						
							|  |  |  |     } else if (v < 1.0) { | 
					
						
							|  |  |  |         s = tr("%1m").arg(v*1e3, 0, 'f', decimalPlaces); | 
					
						
							|  |  |  |     } else if (v < 1e3) { | 
					
						
							|  |  |  |         s = tr("%1").arg(v, 0, 'f', decimalPlaces); | 
					
						
							|  |  |  |     } else if (v < 1e6) { | 
					
						
							|  |  |  |         s = tr("%1k").arg(v*1e-3, 0, 'f', decimalPlaces); | 
					
						
							|  |  |  |     } else if (v < 1e9) { | 
					
						
							|  |  |  |         s = tr("%1M").arg(v*1e-6, 0, 'f', decimalPlaces); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         s = tr("%1G").arg(v*1e-9, 0, 'f', decimalPlaces); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::setAveragingToolitp() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_glSpectrum) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QString s; | 
					
						
							| 
									
										
										
										
											2021-04-20 10:32:21 +02:00
										 |  |  |         int averagingIndex = m_settings.m_averagingMode == SpectrumSettings::AvgModeNone ? 0 : m_settings.m_averagingIndex; | 
					
						
							| 
									
										
										
										
											2023-10-24 06:11:15 +02:00
										 |  |  |         float overlapFactor = (m_settings.m_fftSize - m_settings.m_fftOverlap) / (float)m_settings.m_fftSize; | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  |         float averagingTime = (m_settings.m_fftSize * (SpectrumSettings::getAveragingValue(averagingIndex, m_settings.m_averagingMode) == 0 ? | 
					
						
							| 
									
										
										
										
											2020-05-01 03:12:01 +02:00
										 |  |  |             1 : | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  |             SpectrumSettings::getAveragingValue(averagingIndex, m_settings.m_averagingMode))) / (float) m_glSpectrum->getSampleRate(); | 
					
						
							| 
									
										
										
										
											2021-02-09 07:39:03 +01:00
										 |  |  |         setNumberStr(averagingTime*overlapFactor, 2, s); | 
					
						
							| 
									
										
										
										
											2018-07-01 20:48:30 +02:00
										 |  |  |         ui->averaging->setToolTip(QString("Number of averaging samples (avg time: %1s)").arg(s)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->averaging->setToolTip(QString("Number of averaging samples")); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-21 07:20:56 +02:00
										 |  |  | void GLSpectrumGUI::setFFTSizeToolitp() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_glSpectrum) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QString s; | 
					
						
							|  |  |  |         setNumberStr((float) m_glSpectrum->getSampleRate() / m_settings.m_fftSize, 2, s); | 
					
						
							|  |  |  |         ui->fftSize->setToolTip(QString("FFT size (resolution: %1Hz)").arg(s)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->fftSize->setToolTip(QString("FFT size")); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-09 17:14:17 +01:00
										 |  |  | void GLSpectrumGUI::setFFTSize(int log2FFTSize) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2021-04-20 11:54:58 +02:00
										 |  |  |     ui->fftSize->setCurrentIndex( | 
					
						
							|  |  |  |         log2FFTSize < SpectrumSettings::m_log2FFTSizeMin ? | 
					
						
							|  |  |  |             0 | 
					
						
							|  |  |  |             : log2FFTSize > SpectrumSettings::m_log2FFTSizeMax ? | 
					
						
							|  |  |  |                 SpectrumSettings::m_log2FFTSizeMax - SpectrumSettings::m_log2FFTSizeMin | 
					
						
							|  |  |  |                 : log2FFTSize - SpectrumSettings::m_log2FFTSizeMin | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2020-11-09 17:14:17 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-09 07:12:32 +01:00
										 |  |  | void GLSpectrumGUI::setMaximumOverlap() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2023-10-23 15:23:35 +02:00
										 |  |  |     ui->fftOverlap->setMaximum(m_settings.m_fftSize -1); | 
					
						
							| 
									
										
										
										
											2021-02-09 07:12:32 +01:00
										 |  |  |     int value = ui->fftOverlap->value(); | 
					
						
							| 
									
										
										
										
											2021-02-10 08:34:42 +01:00
										 |  |  |     ui->fftOverlap->setValue(value); | 
					
						
							| 
									
										
										
										
											2023-10-23 14:48:40 +02:00
										 |  |  |     ui->fftOverlap->setToolTip(tr("FFT overlap %1 %").arg((value/(float)m_settings.m_fftSize)*100.0f)); | 
					
						
							| 
									
										
										
										
											2021-02-09 08:08:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (m_glSpectrum) { | 
					
						
							|  |  |  |         m_glSpectrum->setFFTOverlap(value); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-02-09 07:12:32 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-01 20:48:30 +02:00
										 |  |  | bool GLSpectrumGUI::handleMessage(const Message& message) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  |     if (GLSpectrumView::MsgReportSampleRate::match(message)) | 
					
						
							| 
									
										
										
										
											2018-07-01 20:48:30 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         setAveragingToolitp(); | 
					
						
							| 
									
										
										
										
											2021-04-21 07:20:56 +02:00
										 |  |  |         setFFTSizeToolitp(); | 
					
						
							| 
									
										
										
										
											2018-07-01 20:48:30 +02:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |     else if (SpectrumVis::MsgConfigureSpectrumVis::match(message)) | 
					
						
							| 
									
										
										
										
											2020-08-29 11:10:11 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |         SpectrumVis::MsgConfigureSpectrumVis& cfg = (SpectrumVis::MsgConfigureSpectrumVis&) message; | 
					
						
							|  |  |  |         m_settings = cfg.getSettings(); | 
					
						
							|  |  |  |         displaySettings(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_glSpectrum) { | 
					
						
							| 
									
										
										
										
											2021-04-20 10:32:21 +02:00
										 |  |  |             applySpectrumSettings(); | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2020-08-29 11:10:11 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |     else if (SpectrumVis::MsgConfigureWSpectrumOpenClose::match(message)) | 
					
						
							| 
									
										
										
										
											2020-07-10 00:08:42 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |         SpectrumVis::MsgConfigureWSpectrumOpenClose& notif = (SpectrumVis::MsgConfigureWSpectrumOpenClose&) message; | 
					
						
							|  |  |  |         ui->wsSpectrum->blockSignals(true); | 
					
						
							|  |  |  |         ui->wsSpectrum->doToggle(notif.getOpenClose()); | 
					
						
							|  |  |  |         ui->wsSpectrum->blockSignals(false); | 
					
						
							| 
									
										
										
										
											2020-07-10 00:08:42 +02:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  |     else if (GLSpectrumView::MsgReportWaterfallShare::match(message)) | 
					
						
							| 
									
										
										
										
											2020-11-15 21:56:45 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  |         const GLSpectrumView::MsgReportWaterfallShare& report = (const GLSpectrumView::MsgReportWaterfallShare&) message; | 
					
						
							| 
									
										
										
										
											2020-11-15 21:56:45 +01:00
										 |  |  |         m_settings.m_waterfallShare = report.getWaterfallShare(); | 
					
						
							| 
									
										
										
										
											2021-02-19 13:42:05 +01:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  |     else if (GLSpectrumView::MsgReportFFTOverlap::match(message)) | 
					
						
							| 
									
										
										
										
											2021-02-19 13:42:05 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  |         const GLSpectrumView::MsgReportFFTOverlap& report = (const GLSpectrumView::MsgReportFFTOverlap&) message; | 
					
						
							| 
									
										
										
										
											2021-02-19 13:42:05 +01:00
										 |  |  |         m_settings.m_fftOverlap = report.getOverlap(); | 
					
						
							|  |  |  |         ui->fftOverlap->blockSignals(true); | 
					
						
							|  |  |  |         ui->fftOverlap->setValue(m_settings.m_fftOverlap); | 
					
						
							|  |  |  |         ui->fftOverlap->blockSignals(false); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  |     else if (GLSpectrumView::MsgReportPowerScale::match(message)) | 
					
						
							| 
									
										
										
										
											2021-02-19 13:42:05 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  |         const GLSpectrumView::MsgReportPowerScale& report = (const GLSpectrumView::MsgReportPowerScale&) message; | 
					
						
							| 
									
										
										
										
											2021-02-19 13:42:05 +01:00
										 |  |  |         m_settings.m_refLevel = report.getRefLevel(); | 
					
						
							|  |  |  |         m_settings.m_powerRange = report.getRange(); | 
					
						
							|  |  |  |         ui->refLevel->blockSignals(true); | 
					
						
							|  |  |  |         ui->levelRange->blockSignals(true); | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  |         ui->refLevel->setValue(m_settings.m_refLevel + m_calibrationShiftdB); | 
					
						
							| 
									
										
										
										
											2021-02-19 13:42:05 +01:00
										 |  |  |         ui->levelRange->setValue(m_settings.m_powerRange); | 
					
						
							|  |  |  |         ui->levelRange->blockSignals(false); | 
					
						
							|  |  |  |         ui->refLevel->blockSignals(false); | 
					
						
							|  |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2020-11-15 21:56:45 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  |     else if (GLSpectrumView::MsgReportCalibrationShift::match(message)) | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  |         const GLSpectrumView::MsgReportCalibrationShift& report = (GLSpectrumView::MsgReportCalibrationShift&) message; | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  |         m_calibrationShiftdB = report.getCalibrationShiftdB(); | 
					
						
							|  |  |  |         ui->refLevel->blockSignals(true); | 
					
						
							|  |  |  |         ui->refLevel->setValue(m_settings.m_refLevel + m_calibrationShiftdB); | 
					
						
							|  |  |  |         ui->refLevel->blockSignals(false); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-10-01 20:58:21 +02:00
										 |  |  |     else if (GLSpectrumView::MsgReportHistogramMarkersChange::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_markersDialog) { | 
					
						
							|  |  |  |             m_markersDialog->updateHistogramMarkersDisplay(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (GLSpectrumView::MsgReportWaterfallMarkersChange::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_markersDialog) { | 
					
						
							|  |  |  |             m_markersDialog->updateWaterfallMarkersDisplay(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-11-15 21:56:45 +01:00
										 |  |  |     else if (SpectrumVis::MsgStartStop::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const SpectrumVis::MsgStartStop& msg = (SpectrumVis::MsgStartStop&) message; | 
					
						
							|  |  |  |         ui->freeze->blockSignals(true); | 
					
						
							|  |  |  |         ui->freeze->doToggle(!msg.getStartStop()); // this is a freeze so stop is true
 | 
					
						
							|  |  |  |         ui->freeze->blockSignals(false); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-07-01 20:48:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::handleInputMessages() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Message* message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while ((message = m_messageQueue.pop()) != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug("GLSpectrumGUI::handleInputMessages: message: %s", message->getIdentifier()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (handleMessage(*message)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             delete message; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::openWebsocketSpectrumSettingsDialog(const QPoint& p) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     WebsocketSpectrumSettingsDialog dialog(this); | 
					
						
							|  |  |  |     dialog.setAddress(m_settings.m_wsSpectrumAddress); | 
					
						
							|  |  |  |     dialog.setPort(m_settings.m_wsSpectrumPort); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     dialog.move(p); | 
					
						
							| 
									
										
										
										
											2022-12-20 14:39:39 +00:00
										 |  |  |     new DialogPositioner(&dialog, false); | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:56 +02:00
										 |  |  |     dialog.exec(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (dialog.hasChanged()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_wsSpectrumAddress = dialog.getAddress(); | 
					
						
							|  |  |  |         m_settings.m_wsSpectrumPort = dialog.getPort(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         applySettings(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-08-01 10:03:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-30 07:43:50 +01:00
										 |  |  | void GLSpectrumGUI::openCalibrationPointsDialog(const QPoint& p) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SpectrumCalibrationPointsDialog dialog( | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  |         m_glSpectrum->getCalibrationPoints(), | 
					
						
							|  |  |  |         m_glSpectrum->getCalibrationInterpMode(), | 
					
						
							| 
									
										
										
										
											2022-01-30 07:43:50 +01:00
										 |  |  |         m_glSpectrum->getHistogramMarkers().size() > 0 ? &m_glSpectrum->getHistogramMarkers()[0] : nullptr, | 
					
						
							|  |  |  |         this | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     dialog.setCenterFrequency(m_glSpectrum->getCenterFrequency()); | 
					
						
							|  |  |  |     connect(&dialog, SIGNAL(updateCalibrationPoints()), this, SLOT(updateCalibrationPoints())); | 
					
						
							|  |  |  |     dialog.move(p); | 
					
						
							| 
									
										
										
										
											2022-12-20 14:39:39 +00:00
										 |  |  |     new DialogPositioner(&dialog, false); | 
					
						
							| 
									
										
										
										
											2022-01-30 07:43:50 +01:00
										 |  |  |     dialog.exec(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_settings.m_histogramMarkers = m_glSpectrum->getHistogramMarkers(); | 
					
						
							|  |  |  |     m_settings.m_waterfallMarkers = m_glSpectrum->getWaterfallMarkers(); | 
					
						
							|  |  |  |     m_settings.m_annoationMarkers = m_glSpectrum->getAnnotationMarkers(); | 
					
						
							|  |  |  |     m_settings.m_markersDisplay = m_glSpectrum->getMarkersDisplay(); | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  |     m_settings.m_calibrationPoints = m_glSpectrum->getCalibrationPoints(); | 
					
						
							|  |  |  |     m_settings.m_calibrationInterpMode = m_glSpectrum->getCalibrationInterpMode(); | 
					
						
							| 
									
										
										
										
											2022-01-30 07:43:50 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-01 10:03:58 +02:00
										 |  |  | void GLSpectrumGUI::updateHistogramMarkers() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_glSpectrum) { | 
					
						
							|  |  |  |         m_glSpectrum->updateHistogramMarkers(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::updateWaterfallMarkers() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_glSpectrum) { | 
					
						
							|  |  |  |         m_glSpectrum->updateWaterfallMarkers(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::updateAnnotationMarkers() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_glSpectrum) { | 
					
						
							|  |  |  |         m_glSpectrum->updateAnnotationMarkers(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::updateMarkersDisplay() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_glSpectrum) { | 
					
						
							|  |  |  |         m_glSpectrum->updateMarkersDisplay(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-01-30 07:43:50 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void GLSpectrumGUI::updateCalibrationPoints() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_glSpectrum) { | 
					
						
							|  |  |  |         m_glSpectrum->updateCalibrationPoints(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-09-25 10:50:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-28 16:59:35 +01:00
										 |  |  | void GLSpectrumGUI::on_measure_clicked(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-01 20:58:21 +02:00
										 |  |  |     (void) checked; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  |     SpectrumMeasurementsDialog measurementsDialog( | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  |         m_glSpectrum, | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  |         &m_settings, | 
					
						
							|  |  |  |         this | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2022-09-25 10:50:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  |     connect(&measurementsDialog, &SpectrumMeasurementsDialog::updateMeasurements, this, &GLSpectrumGUI::updateMeasurements); | 
					
						
							| 
									
										
										
										
											2022-09-25 10:50:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  |     measurementsDialog.exec(); | 
					
						
							| 
									
										
										
										
											2022-09-25 10:50:56 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-15 12:01:37 +00:00
										 |  |  | void GLSpectrumGUI::on_resetMeasurements_clicked(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     (void) checked; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_glSpectrum) { | 
					
						
							|  |  |  |         m_glSpectrum->getMeasurements()->reset(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  | void GLSpectrumGUI::updateMeasurements() | 
					
						
							| 
									
										
										
										
											2022-09-28 16:59:35 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-01-15 12:01:37 +00:00
										 |  |  |     ui->resetMeasurements->setVisible(m_settings.m_measurement >= SpectrumSettings::MeasurementChannelPower); | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  |     if (m_glSpectrum) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-09-29 13:48:04 +01:00
										 |  |  |         m_glSpectrum->setMeasurementsVisible(m_settings.m_measurement != SpectrumSettings::MeasurementNone); | 
					
						
							|  |  |  |         m_glSpectrum->setMeasurementsPosition(m_settings.m_measurementsPosition); | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  |         m_glSpectrum->setMeasurementParams( | 
					
						
							|  |  |  |             m_settings.m_measurement, | 
					
						
							|  |  |  |             m_settings.m_measurementCenterFrequencyOffset, | 
					
						
							|  |  |  |             m_settings.m_measurementBandwidth, | 
					
						
							|  |  |  |             m_settings.m_measurementChSpacing, | 
					
						
							|  |  |  |             m_settings.m_measurementAdjChBandwidth, | 
					
						
							|  |  |  |             m_settings.m_measurementHarmonics, | 
					
						
							|  |  |  |             m_settings.m_measurementPeaks, | 
					
						
							|  |  |  |             m_settings.m_measurementHighlight, | 
					
						
							|  |  |  |             m_settings.m_measurementPrecision | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-28 16:59:35 +01:00
										 |  |  | } |