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 //
|
|
|
|
// //
|
|
|
|
// 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 <device/devicesourceapi.h>
|
|
|
|
#include "device/deviceuiset.h"
|
|
|
|
#include <dsp/downchannelizer.h>
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QMainWindow>
|
|
|
|
|
|
|
|
#include "dsp/threadedbasebandsamplesink.h"
|
2018-05-30 09:42:33 -04:00
|
|
|
#include "ui_chanalyzergui.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"
|
|
|
|
#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 "dsp/dspengine.h"
|
|
|
|
#include "mainwindow.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);
|
2018-05-19 19:10:08 -04:00
|
|
|
m_settings.m_frequency = 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);
|
|
|
|
m_channelMarker.setCenterFrequency(m_settings.m_frequency);
|
|
|
|
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);
|
|
|
|
|
|
|
|
ui->useRationalDownsampler->setChecked(m_settings.m_downSample);
|
2018-05-19 20:24:38 -04:00
|
|
|
ui->channelSampleRate->setValue(m_settings.m_downSampleRate);
|
|
|
|
setNewFinalRate();
|
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);
|
|
|
|
ui->deltaFrequency->setValue(m_settings.m_frequency);
|
|
|
|
ui->spanLog2->setCurrentIndex(m_settings.m_spanLog2);
|
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
|
|
|
{
|
2018-05-30 09:49:28 -04:00
|
|
|
qDebug("ChannelAnalyzerGUI::setSpectrumDisplay: m_rate: %d", m_rate);
|
2018-05-19 19:10:08 -04:00
|
|
|
if (m_settings.m_ssb)
|
|
|
|
{
|
|
|
|
ui->glSpectrum->setCenterFrequency(m_rate/4);
|
|
|
|
ui->glSpectrum->setSampleRate(m_rate/2);
|
|
|
|
ui->glSpectrum->setSsbSpectrum(true);
|
|
|
|
ui->glSpectrum->setLsbDisplay(ui->BW->value() < 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->glSpectrum->setCenterFrequency(0);
|
|
|
|
ui->glSpectrum->setSampleRate(m_rate);
|
|
|
|
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
|
|
|
{
|
2018-05-30 09:37:56 -04:00
|
|
|
if (ChannelAnalyzer::MsgReportChannelSampleRateChanged::match(message))
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-05-30 09:49:28 -04:00
|
|
|
qDebug() << "ChannelAnalyzerGUI::handleMessage: MsgReportChannelSampleRateChanged";
|
2018-05-19 19:10:08 -04:00
|
|
|
ui->channelSampleRate->setValueRange(7, 2000U, m_channelAnalyzer->getInputSampleRate());
|
2018-05-19 20:24:38 -04:00
|
|
|
ui->channelSampleRate->setValue(m_settings.m_downSampleRate);
|
2018-05-19 19:10:08 -04:00
|
|
|
setNewFinalRate();
|
2017-11-10 23:10:15 -05:00
|
|
|
|
2017-10-31 17:37:57 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
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
|
|
|
{
|
|
|
|
int freq = (m_channelAnalyzer->getPllFrequency() * m_channelAnalyzer->getChannelSampleRate()) / (2.0*M_PI);
|
|
|
|
ui->pll->setToolTip(tr("PLL lock. Freq = %1 Hz").arg(freq));
|
|
|
|
}
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::on_channelSampleRate_changed(quint64 value)
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-05-19 19:10:08 -04:00
|
|
|
m_settings.m_downSampleRate = value;
|
|
|
|
setNewFinalRate();
|
|
|
|
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
|
|
|
{
|
2018-05-19 19:10:08 -04:00
|
|
|
m_settings.m_downSample = checked;
|
|
|
|
setNewFinalRate();
|
2017-10-31 17:37:57 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
int ChannelAnalyzerGUI::getRequestedChannelSampleRate()
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
|
|
|
if (ui->useRationalDownsampler->isChecked()) {
|
|
|
|
return ui->channelSampleRate->getValueNew();
|
|
|
|
} else {
|
|
|
|
return m_channelAnalyzer->getChannelizer()->getInputSampleRate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
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);
|
2018-05-19 19:10:08 -04:00
|
|
|
m_settings.m_frequency = 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();
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::on_spanLog2_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
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
m_settings.m_spanLog2 = index;
|
|
|
|
setNewFinalRate();
|
|
|
|
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
|
|
|
{
|
|
|
|
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
|
|
|
|
dialog.move(p);
|
|
|
|
dialog.exec();
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
m_settings.m_frequency = m_channelMarker.getCenterFrequency();
|
|
|
|
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
|
|
|
|
m_settings.m_title = m_channelMarker.getTitle();
|
2017-10-31 17:37:57 -04:00
|
|
|
|
2018-05-19 19:10:08 -04:00
|
|
|
setWindowTitle(m_settings.m_title);
|
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
2017-10-31 17:37:57 -04:00
|
|
|
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
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),
|
2018-05-19 19:10:08 -04:00
|
|
|
m_rate(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
|
|
|
|
2018-01-22 08:07:24 -05:00
|
|
|
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, 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);
|
|
|
|
m_channelAnalyzer = (ChannelAnalyzer*) rxChannel; //new ChannelAnalyzer(m_deviceUISet->m_deviceSourceAPI);
|
2017-10-31 17:37:57 -04:00
|
|
|
m_channelAnalyzer->setSampleSink(m_spectrumScopeComboVis);
|
|
|
|
m_channelAnalyzer->setMessageQueueToGUI(getInputMessageQueue());
|
|
|
|
|
|
|
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
|
|
|
|
|
|
|
ui->channelSampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
|
|
|
ui->channelSampleRate->setValueRange(7, 2000U, 9999999U);
|
|
|
|
|
|
|
|
ui->glSpectrum->setCenterFrequency(m_rate/2);
|
|
|
|
ui->glSpectrum->setSampleRate(m_rate);
|
|
|
|
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);
|
|
|
|
m_channelMarker.setBandwidth(m_rate);
|
|
|
|
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);
|
|
|
|
|
|
|
|
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
|
|
|
|
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_spectrumVis;
|
|
|
|
delete m_scopeVis;
|
|
|
|
delete m_spectrumScopeComboVis;
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerGUI::setNewFinalRate()
|
2017-10-31 17:37:57 -04:00
|
|
|
{
|
2018-05-19 19:10:08 -04:00
|
|
|
m_rate = getRequestedChannelSampleRate() / (1<<m_settings.m_spanLog2);
|
2017-10-31 17:37:57 -04:00
|
|
|
if (m_rate == 0) {
|
2018-05-19 19:10:08 -04:00
|
|
|
m_rate = 48000;
|
2017-10-31 17:37:57 -04:00
|
|
|
}
|
2018-05-30 09:49:28 -04:00
|
|
|
qDebug("ChannelAnalyzerGUI::setNewFinalRate: %d m_spanLog2: %d", m_rate, m_settings.m_spanLog2);
|
2017-10-31 17:37:57 -04:00
|
|
|
|
|
|
|
setFiltersUIBoundaries();
|
|
|
|
|
|
|
|
QString s = QString::number(m_rate/1000.0, 'f', 1);
|
|
|
|
ui->spanText->setText(tr("%1 kS/s").arg(s));
|
|
|
|
|
2018-10-20 04:41:49 -04:00
|
|
|
m_scopeVis->setLiveRate(getRequestedChannelSampleRate());
|
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
|
|
|
{
|
2018-05-19 19:10:08 -04:00
|
|
|
bool dsb = !ui->ssb->isChecked();
|
|
|
|
int bw = ui->BW->value();
|
|
|
|
int lw = ui->lowCut->value();
|
|
|
|
int bwMax = m_rate / 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)
|
|
|
|
{
|
|
|
|
int sampleRate = getRequestedChannelSampleRate();
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
ChannelAnalyzer::MsgConfigureChannelizer *msgChannelizer =
|
|
|
|
ChannelAnalyzer::MsgConfigureChannelizer::create(sampleRate, m_channelMarker.getCenterFrequency());
|
2017-10-31 17:37:57 -04:00
|
|
|
m_channelAnalyzer->getInputMessageQueue()->push(msgChannelizer);
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
ChannelAnalyzer::MsgConfigureChannelizer *msg =
|
|
|
|
ChannelAnalyzer::MsgConfigureChannelizer::create(sampleRate, m_channelMarker.getCenterFrequency());
|
2017-10-31 17:37:57 -04:00
|
|
|
m_channelAnalyzer->getInputMessageQueue()->push(msg);
|
|
|
|
|
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);
|
2018-10-20 04:41:49 -04:00
|
|
|
|
|
|
|
m_scopeVis->setLiveRateLog2Decim(m_settings.m_spanLog2);
|
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);
|
|
|
|
}
|
|
|
|
|