2017-10-31 17:37:57 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// 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 //
|
2019-04-11 00:39:30 -04:00
|
|
|
// (at your option) any later version. //
|
2017-10-31 17:37:57 -04:00
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QMainWindow>
|
|
|
|
|
2018-12-09 18:52:05 -05:00
|
|
|
#include "device/deviceuiset.h"
|
2018-08-12 11:13:06 -04:00
|
|
|
#include "dsp/spectrumscopecombovis.h"
|
2017-10-31 17:37:57 -04:00
|
|
|
#include "dsp/spectrumvis.h"
|
2018-12-09 18:52:05 -05:00
|
|
|
#include "dsp/dspengine.h"
|
2019-11-24 04:12:58 -05:00
|
|
|
#include "dsp/dspcommands.h"
|
2017-10-31 17:37:57 -04:00
|
|
|
#include "gui/glspectrum.h"
|
2018-08-12 11:06:55 -04:00
|
|
|
#include "gui/glscope.h"
|
2018-05-19 19:10:08 -04:00
|
|
|
#include "gui/basicchannelsettingsdialog.h"
|
2017-10-31 17:37:57 -04:00
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "util/db.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
2018-12-09 18:52:05 -05:00
|
|
|
#include "ui_chanalyzergui.h"
|
2018-05-30 09:37:56 -04:00
|
|
|
#include "chanalyzer.h"
|
|
|
|
#include "chanalyzergui.h"
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
ChannelAnalyzerGUI* ChannelAnalyzerGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-05-30 09:37:56 -04:00
|
|
|
ChannelAnalyzerGUI* gui = new ChannelAnalyzerGUI(pluginAPI, deviceUISet, rxChannel);
|
2017-10-31 17:37:57 -04:00
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::destroy()
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::setName(const QString& name)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
setObjectName(name);
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
QString ChannelAnalyzerGUI::getName() const
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
return objectName();
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
qint64 ChannelAnalyzerGUI::getCenterFrequency() const
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
return m_channelMarker.getCenterFrequency();
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::setCenterFrequency(qint64 centerFrequency)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setCenterFrequency(centerFrequency);
|
2019-11-24 04:12:58 -05:00
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
2017-10-31 17:37:57 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::resetToDefaults()
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-05-19 19:10:08 -04:00
|
|
|
m_settings.resetToDefaults();
|
|
|
|
}
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::displaySettings()
|
2018-05-19 19:10:08 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.blockSignals(true);
|
2019-11-24 04:12:58 -05:00
|
|
|
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
2018-05-19 19:10:08 -04:00
|
|
|
m_channelMarker.setBandwidth(m_settings.m_bandwidth * 2);
|
|
|
|
m_channelMarker.setTitle(m_settings.m_title);
|
|
|
|
m_channelMarker.setLowCutoff(m_settings.m_lowCutoff);
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
if (m_settings.m_ssb)
|
|
|
|
{
|
|
|
|
if (m_settings.m_bandwidth < 0) {
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::lsb);
|
|
|
|
} else {
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::usb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::dsb);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only
|
|
|
|
|
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
setWindowTitle(m_channelMarker.getTitle());
|
|
|
|
|
|
|
|
blockApplySettings(true);
|
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
ui->useRationalDownsampler->setChecked(m_settings.m_rationalDownSample);
|
|
|
|
setSinkSampleRate();
|
2018-05-22 13:25:55 -04:00
|
|
|
if (m_settings.m_ssb) {
|
|
|
|
ui->BWLabel->setText("LP");
|
|
|
|
} else {
|
|
|
|
ui->BWLabel->setText("BP");
|
|
|
|
}
|
|
|
|
ui->ssb->setChecked(m_settings.m_ssb);
|
2018-05-19 19:10:08 -04:00
|
|
|
ui->BW->setValue(m_settings.m_bandwidth/100);
|
|
|
|
ui->lowCut->setValue(m_settings.m_lowCutoff/100);
|
2019-11-24 04:12:58 -05:00
|
|
|
ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset);
|
|
|
|
ui->log2Decim->setCurrentIndex(m_settings.m_log2Decim);
|
2018-05-19 20:24:38 -04:00
|
|
|
displayPLLSettings();
|
2018-05-20 13:41:36 -04:00
|
|
|
ui->signalSelect->setCurrentIndex((int) m_settings.m_inputType);
|
2018-05-21 20:20:36 -04:00
|
|
|
ui->rrcFilter->setChecked(m_settings.m_rrc);
|
|
|
|
QString rolloffStr = QString::number(m_settings.m_rrcRolloff/100.0, 'f', 2);
|
|
|
|
ui->rrcRolloffText->setText(rolloffStr);
|
2018-05-19 19:10:08 -04:00
|
|
|
|
|
|
|
blockApplySettings(false);
|
2018-05-19 20:24:38 -04:00
|
|
|
}
|
2018-05-19 19:10:08 -04:00
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::displayPLLSettings()
|
2018-05-19 20:24:38 -04:00
|
|
|
{
|
|
|
|
if (m_settings.m_fll)
|
|
|
|
{
|
|
|
|
ui->pllPskOrder->setCurrentIndex(5);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
for(; ((m_settings.m_pllPskOrder>>i) & 1) == 0; i++);
|
|
|
|
ui->pllPskOrder->setCurrentIndex(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->pll->setChecked(m_settings.m_pll);
|
2018-05-19 19:10:08 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::setSpectrumDisplay()
|
2018-05-19 19:10:08 -04:00
|
|
|
{
|
2019-11-24 04:12:58 -05:00
|
|
|
int sinkSampleRate = getSinkSampleRate();
|
|
|
|
qDebug("ChannelAnalyzerGUI::setSpectrumDisplay: m_sinkSampleRate: %d", sinkSampleRate);
|
2018-05-19 19:10:08 -04:00
|
|
|
if (m_settings.m_ssb)
|
|
|
|
{
|
2019-11-24 04:12:58 -05:00
|
|
|
ui->glSpectrum->setCenterFrequency(sinkSampleRate/4);
|
|
|
|
ui->glSpectrum->setSampleRate(sinkSampleRate/2);
|
2018-05-19 19:10:08 -04:00
|
|
|
ui->glSpectrum->setSsbSpectrum(true);
|
|
|
|
ui->glSpectrum->setLsbDisplay(ui->BW->value() < 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->glSpectrum->setCenterFrequency(0);
|
2019-11-24 04:12:58 -05:00
|
|
|
ui->glSpectrum->setSampleRate(sinkSampleRate);
|
2018-05-19 19:10:08 -04:00
|
|
|
ui->glSpectrum->setSsbSpectrum(false);
|
|
|
|
ui->glSpectrum->setLsbDisplay(false);
|
|
|
|
}
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
QByteArray ChannelAnalyzerGUI::serialize() const
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-05-19 19:10:08 -04:00
|
|
|
return m_settings.serialize();
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
bool ChannelAnalyzerGUI::deserialize(const QByteArray& data)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-05-19 19:10:08 -04:00
|
|
|
if(m_settings.deserialize(data))
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-05-19 19:10:08 -04:00
|
|
|
displaySettings();
|
|
|
|
applySettings(true); // will have true
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-31 17:37:57 -04:00
|
|
|
else
|
|
|
|
{
|
2018-05-19 19:10:08 -04:00
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true); // will have true
|
|
|
|
return false;
|
|
|
|
}
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
bool ChannelAnalyzerGUI::handleMessage(const Message& message)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2019-11-24 04:12:58 -05:00
|
|
|
if (DSPSignalNotification::match(message))
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2019-11-24 04:12:58 -05:00
|
|
|
DSPSignalNotification& cmd = (DSPSignalNotification&) message;
|
|
|
|
m_basebandSampleRate = cmd.getSampleRate();
|
|
|
|
setSinkSampleRate();
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::handleInputMessages()
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = getInputMessageQueue()->pop()) != 0)
|
|
|
|
{
|
|
|
|
qDebug("ChannelAnalyzerGUI::handleInputMessages: message: %s", message->getIdentifier());
|
|
|
|
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::channelMarkerChangedByCursor()
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2017-11-13 18:35:25 -05:00
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
2019-11-24 04:12:58 -05:00
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
2017-10-31 17:37:57 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::channelMarkerHighlightedByCursor()
|
2017-11-14 16:58:35 -05:00
|
|
|
{
|
|
|
|
setHighlighted(m_channelMarker.getHighlighted());
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::tick()
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-06-26 14:03:56 -04:00
|
|
|
m_channelPowerAvg(m_channelAnalyzer->getMagSqAvg());
|
|
|
|
double powDb = CalcDb::dbPower((double) m_channelPowerAvg);
|
|
|
|
ui->channelPower->setText(tr("%1 dB").arg(powDb, 0, 'f', 1));
|
2018-05-12 00:01:54 -04:00
|
|
|
|
|
|
|
if (m_channelAnalyzer->isPllLocked()) {
|
|
|
|
ui->pll->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
} else {
|
|
|
|
ui->pll->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
}
|
2018-05-18 13:03:54 -04:00
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
if (ui->pll->isChecked())
|
2018-05-18 13:03:54 -04:00
|
|
|
{
|
2019-05-03 22:54:16 -04:00
|
|
|
double sampleRate = ((double) m_channelAnalyzer->getChannelSampleRate()) / m_channelAnalyzer->getDecimation();
|
|
|
|
int freq = (m_channelAnalyzer->getPllFrequency() * sampleRate) / (2.0*M_PI);
|
2018-05-18 13:03:54 -04:00
|
|
|
ui->pll->setToolTip(tr("PLL lock. Freq = %1 Hz").arg(freq));
|
|
|
|
}
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
void ChannelAnalyzerGUI::on_rationalDownSamplerRate_changed(quint64 value)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2019-11-24 04:12:58 -05:00
|
|
|
m_settings.m_rationalDownSamplerRate = value;
|
|
|
|
setSinkSampleRate();
|
2018-05-19 19:10:08 -04:00
|
|
|
applySettings();
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::on_pll_toggled(bool checked)
|
2018-05-12 00:01:54 -04:00
|
|
|
{
|
2018-05-18 13:03:54 -04:00
|
|
|
if (!checked) {
|
|
|
|
ui->pll->setToolTip(tr("PLL lock"));
|
|
|
|
}
|
|
|
|
|
2018-05-19 20:24:38 -04:00
|
|
|
m_settings.m_pll = checked;
|
2018-05-12 00:01:54 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::on_pllPskOrder_currentIndexChanged(int index)
|
2018-05-14 14:47:23 -04:00
|
|
|
{
|
2018-05-19 20:24:38 -04:00
|
|
|
if (index < 5) {
|
2018-05-19 19:10:08 -04:00
|
|
|
m_settings.m_pllPskOrder = (1<<index);
|
|
|
|
}
|
2018-05-19 20:24:38 -04:00
|
|
|
|
|
|
|
m_settings.m_fll = (index == 5);
|
|
|
|
applySettings();
|
2018-05-14 14:47:23 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::on_useRationalDownsampler_toggled(bool checked)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2019-11-24 04:12:58 -05:00
|
|
|
m_settings.m_rationalDownSample = checked;
|
|
|
|
setSinkSampleRate();
|
2017-10-31 17:37:57 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::on_signalSelect_currentIndexChanged(int index)
|
2018-05-20 12:17:53 -04:00
|
|
|
{
|
2018-05-30 09:37:56 -04:00
|
|
|
m_settings.m_inputType = (ChannelAnalyzerSettings::InputType) index;
|
2019-10-27 17:25:05 -04:00
|
|
|
|
|
|
|
if (m_settings.m_inputType == ChannelAnalyzerSettings::InputAutoCorr) {
|
2019-11-24 04:12:58 -05:00
|
|
|
m_scopeVis->setTraceChunkSize(ChannelAnalyzerSink::m_corrFFTLen);
|
2019-10-27 17:25:05 -04:00
|
|
|
} else {
|
|
|
|
m_scopeVis->setTraceChunkSize(ScopeVis::m_traceChunkDefaultSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->scopeGUI->traceLengthChange();
|
2018-05-20 12:17:53 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::on_deltaFrequency_changed(qint64 value)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setCenterFrequency(value);
|
2019-11-24 04:12:58 -05:00
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
2017-11-14 19:58:44 -05:00
|
|
|
applySettings();
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::on_rrcFilter_toggled(bool checked)
|
2018-05-21 20:20:36 -04:00
|
|
|
{
|
|
|
|
m_settings.m_rrc = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::on_rrcRolloff_valueChanged(int value)
|
2018-05-21 20:20:36 -04:00
|
|
|
{
|
|
|
|
m_settings.m_rrcRolloff = value;
|
|
|
|
QString rolloffStr = QString::number(value/100.0, 'f', 2);
|
|
|
|
ui->rrcRolloffText->setText(rolloffStr);
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void ChannelAnalyzerGUI::on_BW_valueChanged(int value)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) value;
|
2018-05-19 19:10:08 -04:00
|
|
|
setFiltersUIBoundaries();
|
|
|
|
m_settings.m_bandwidth = ui->BW->value() * 100;
|
|
|
|
m_settings.m_lowCutoff = ui->lowCut->value() * 100;
|
|
|
|
applySettings();
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void ChannelAnalyzerGUI::on_lowCut_valueChanged(int value)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) value;
|
2018-05-19 19:10:08 -04:00
|
|
|
setFiltersUIBoundaries();
|
|
|
|
m_settings.m_bandwidth = ui->BW->value() * 100;
|
|
|
|
m_settings.m_lowCutoff = ui->lowCut->value() * 100;
|
2017-10-31 17:37:57 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
void ChannelAnalyzerGUI::on_log2Decim_currentIndexChanged(int index)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-05-19 19:10:08 -04:00
|
|
|
if ((index < 0) || (index > 6)) {
|
|
|
|
return;
|
|
|
|
}
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
m_settings.m_log2Decim = index;
|
|
|
|
setSinkSampleRate();
|
2018-05-19 19:10:08 -04:00
|
|
|
applySettings();
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::on_ssb_toggled(bool checked)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-05-19 19:10:08 -04:00
|
|
|
m_settings.m_ssb = checked;
|
2018-05-22 13:25:55 -04:00
|
|
|
if (checked) {
|
|
|
|
ui->BWLabel->setText("LP");
|
|
|
|
} else {
|
|
|
|
ui->BWLabel->setText("BP");
|
|
|
|
}
|
2018-05-19 19:10:08 -04:00
|
|
|
setFiltersUIBoundaries();
|
|
|
|
applySettings();
|
|
|
|
}
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void ChannelAnalyzerGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
2018-05-19 19:10:08 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) widget;
|
|
|
|
(void) rollDown;
|
2018-05-19 19:10:08 -04:00
|
|
|
}
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::onMenuDialogCalled(const QPoint& p)
|
2018-05-19 19:10:08 -04:00
|
|
|
{
|
2019-05-09 15:07:05 -04:00
|
|
|
if (m_contextMenuType == ContextMenuChannelSettings)
|
|
|
|
{
|
|
|
|
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
|
|
|
|
dialog.move(p);
|
|
|
|
dialog.exec();
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
2019-05-09 15:07:05 -04:00
|
|
|
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
|
|
|
|
m_settings.m_title = m_channelMarker.getTitle();
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2019-05-09 15:07:05 -04:00
|
|
|
setWindowTitle(m_settings.m_title);
|
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2019-05-09 15:07:05 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
resetContextMenuType();
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent) :
|
2017-10-31 17:37:57 -04:00
|
|
|
RollupWidget(parent),
|
2018-05-30 09:49:28 -04:00
|
|
|
ui(new Ui::ChannelAnalyzerGUI),
|
2017-10-31 17:37:57 -04:00
|
|
|
m_pluginAPI(pluginAPI),
|
|
|
|
m_deviceUISet(deviceUISet),
|
|
|
|
m_channelMarker(this),
|
|
|
|
m_doApplySettings(true),
|
2019-11-24 04:12:58 -05:00
|
|
|
m_basebandSampleRate(48000)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
2018-05-19 19:10:08 -04:00
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2020-04-30 03:57:05 -04:00
|
|
|
m_channelAnalyzer = (ChannelAnalyzer*) rxChannel; //new ChannelAnalyzer(m_deviceUISet->m_deviceSourceAPI);
|
|
|
|
m_spectrumVis = m_channelAnalyzer->getSpectrumVis();
|
|
|
|
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
|
2018-08-12 11:18:58 -04:00
|
|
|
m_scopeVis = new ScopeVis(ui->glScope);
|
2018-08-12 11:10:31 -04:00
|
|
|
m_spectrumScopeComboVis = new SpectrumScopeComboVis(m_spectrumVis, m_scopeVis);
|
2020-06-20 00:08:38 -04:00
|
|
|
m_channelAnalyzer->setSampleSink(m_spectrumScopeComboVis);
|
2017-10-31 17:37:57 -04:00
|
|
|
m_channelAnalyzer->setMessageQueueToGUI(getInputMessageQueue());
|
|
|
|
|
|
|
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
2020-07-01 07:14:48 -04:00
|
|
|
ui->deltaFrequency->setValueRange(false, 8, -99999999, 99999999);
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
ui->rationalDownSamplerRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
ui->glSpectrum->setCenterFrequency(m_basebandSampleRate/2);
|
|
|
|
ui->glSpectrum->setSampleRate(m_basebandSampleRate);
|
2017-10-31 17:37:57 -04:00
|
|
|
ui->glSpectrum->setDisplayWaterfall(true);
|
|
|
|
ui->glSpectrum->setDisplayMaxHold(true);
|
|
|
|
ui->glSpectrum->setSsbSpectrum(false);
|
|
|
|
ui->glSpectrum->setLsbDisplay(false);
|
|
|
|
|
|
|
|
ui->glSpectrum->connectTimer(MainWindow::getInstance()->getMasterTimer());
|
|
|
|
ui->glScope->connectTimer(MainWindow::getInstance()->getMasterTimer());
|
|
|
|
connect(&MainWindow::getInstance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
|
|
|
|
|
2017-11-13 18:35:25 -05:00
|
|
|
m_channelMarker.blockSignals(true);
|
2017-10-31 17:37:57 -04:00
|
|
|
m_channelMarker.setColor(Qt::gray);
|
2019-11-24 04:12:58 -05:00
|
|
|
m_channelMarker.setBandwidth(m_basebandSampleRate);
|
2017-10-31 17:37:57 -04:00
|
|
|
m_channelMarker.setSidebands(ChannelMarker::usb);
|
|
|
|
m_channelMarker.setCenterFrequency(0);
|
2018-05-30 05:49:54 -04:00
|
|
|
m_channelMarker.setTitle("Channel Analyzer");
|
2017-11-13 18:35:25 -05:00
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
m_channelMarker.setVisible(true); // activate signal on the last setting only
|
|
|
|
setTitleColor(m_channelMarker.getColor());
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
m_deviceUISet->registerRxChannelInstance(ChannelAnalyzer::m_channelIdURI, this);
|
2017-10-31 17:37:57 -04:00
|
|
|
m_deviceUISet->addChannelMarker(&m_channelMarker);
|
|
|
|
m_deviceUISet->addRollupWidget(this);
|
|
|
|
|
2020-04-30 20:33:50 -04:00
|
|
|
ui->spectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum);
|
2017-10-31 17:37:57 -04:00
|
|
|
ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope);
|
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
m_settings.setChannelMarker(&m_channelMarker);
|
|
|
|
m_settings.setSpectrumGUI(ui->spectrumGUI);
|
|
|
|
m_settings.setScopeGUI(ui->scopeGUI);
|
|
|
|
|
2017-11-13 18:35:25 -05:00
|
|
|
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
|
2017-11-14 16:58:35 -05:00
|
|
|
connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor()));
|
2017-10-31 17:37:57 -04:00
|
|
|
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
ChannelAnalyzerGUI::~ChannelAnalyzerGUI()
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
m_deviceUISet->removeRxChannelInstance(this);
|
2017-11-08 19:03:05 -05:00
|
|
|
delete m_channelAnalyzer; // TODO: check this: when the GUI closes it has to delete the demodulator
|
2017-10-31 17:37:57 -04:00
|
|
|
delete m_scopeVis;
|
|
|
|
delete m_spectrumScopeComboVis;
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2020-07-20 20:08:58 -04:00
|
|
|
int ChannelAnalyzerGUI::getSinkSampleRate()
|
|
|
|
{
|
|
|
|
return m_settings.m_rationalDownSample ?
|
|
|
|
m_settings.m_rationalDownSamplerRate
|
|
|
|
: m_basebandSampleRate / (1<<m_settings.m_log2Decim);
|
|
|
|
}
|
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
void ChannelAnalyzerGUI::setSinkSampleRate()
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2020-07-19 05:45:35 -04:00
|
|
|
unsigned int nominalSinkSampleRate = m_basebandSampleRate / (1<<m_settings.m_log2Decim);
|
2019-11-24 04:12:58 -05:00
|
|
|
|
2020-07-19 05:45:35 -04:00
|
|
|
ui->rationalDownSamplerRate->setValueRange(7, 0.5*nominalSinkSampleRate, nominalSinkSampleRate);
|
2019-11-24 04:12:58 -05:00
|
|
|
ui->rationalDownSamplerRate->setValue(m_settings.m_rationalDownSamplerRate);
|
2020-07-19 05:45:35 -04:00
|
|
|
m_settings.m_rationalDownSamplerRate = ui->rationalDownSamplerRate->getValueNew();
|
2019-11-24 04:12:58 -05:00
|
|
|
|
|
|
|
unsigned int sinkSampleRate = getSinkSampleRate();
|
|
|
|
|
2020-07-19 05:45:35 -04:00
|
|
|
qDebug("ChannelAnalyzerGUI::setSinkSampleRate: nominalSinkSampleRate: %u sinkSampleRate: %u",
|
|
|
|
nominalSinkSampleRate, sinkSampleRate);
|
2017-10-31 17:37:57 -04:00
|
|
|
|
|
|
|
setFiltersUIBoundaries();
|
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
QString s = QString::number(sinkSampleRate/1000.0, 'f', 1);
|
|
|
|
ui->sinkSampleRateText->setText(tr("%1 kS/s").arg(s));
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
m_scopeVis->setLiveRate(sinkSampleRate == 0 ? 48000 : sinkSampleRate);
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::setFiltersUIBoundaries()
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2019-11-24 04:12:58 -05:00
|
|
|
int sinkSampleRate = getSinkSampleRate();
|
2018-05-19 19:10:08 -04:00
|
|
|
bool dsb = !ui->ssb->isChecked();
|
|
|
|
int bw = ui->BW->value();
|
|
|
|
int lw = ui->lowCut->value();
|
2019-11-24 04:12:58 -05:00
|
|
|
int bwMax = sinkSampleRate / 200;
|
2017-11-10 23:10:15 -05:00
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
bw = bw < -bwMax ? -bwMax : bw > bwMax ? bwMax : bw;
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
if (bw < 0) {
|
|
|
|
lw = lw < bw+1 ? bw+1 : lw < 0 ? lw : 0;
|
|
|
|
} else if (bw > 0) {
|
|
|
|
lw = lw > bw-1 ? bw-1 : lw < 0 ? 0 : lw;
|
|
|
|
} else {
|
|
|
|
lw = 0;
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
if (dsb)
|
|
|
|
{
|
|
|
|
bw = bw < 0 ? -bw : bw;
|
|
|
|
lw = 0;
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
QString bwStr = QString::number(bw/10.0, 'f', 1);
|
|
|
|
QString lwStr = QString::number(lw/10.0, 'f', 1);
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
if (dsb) {
|
|
|
|
ui->BWText->setText(tr("%1%2k").arg(QChar(0xB1, 0x00)).arg(bwStr));
|
|
|
|
} else {
|
|
|
|
ui->BWText->setText(tr("%1k").arg(bwStr));
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
ui->lowCutText->setText(tr("%1k").arg(lwStr));
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
ui->BW->blockSignals(true);
|
|
|
|
ui->lowCut->blockSignals(true);
|
|
|
|
|
|
|
|
ui->BW->setMaximum(bwMax);
|
|
|
|
ui->BW->setMinimum(dsb ? 0 : -bwMax);
|
|
|
|
ui->BW->setValue(bw);
|
|
|
|
|
|
|
|
ui->lowCut->setMaximum(dsb ? 0 : bw);
|
|
|
|
ui->lowCut->setMinimum(dsb ? 0 : -bw);
|
|
|
|
ui->lowCut->setValue(lw);
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
ui->lowCut->blockSignals(false);
|
|
|
|
ui->BW->blockSignals(false);
|
|
|
|
|
|
|
|
setSpectrumDisplay();
|
|
|
|
|
|
|
|
m_channelMarker.setBandwidth(bw * 200);
|
|
|
|
m_channelMarker.setSidebands(dsb ? ChannelMarker::dsb : bw < 0 ? ChannelMarker::lsb : ChannelMarker::usb);
|
|
|
|
|
|
|
|
if (!dsb) {
|
|
|
|
m_channelMarker.setLowCutoff(lw * 100);
|
|
|
|
}
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::blockApplySettings(bool block)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
ui->glScope->blockSignals(block);
|
|
|
|
ui->glSpectrum->blockSignals(block);
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::applySettings(bool force)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
2018-05-30 09:37:56 -04:00
|
|
|
ChannelAnalyzer::MsgConfigureChannelAnalyzer* message =
|
|
|
|
ChannelAnalyzer::MsgConfigureChannelAnalyzer::create( m_settings, force);
|
2018-05-19 19:10:08 -04:00
|
|
|
m_channelAnalyzer->getInputMessageQueue()->push(message);
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::leaveEvent(QEvent*)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(false);
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::enterEvent(QEvent*)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(true);
|
|
|
|
}
|
|
|
|
|