2015-10-03 23:28:11 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2015 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-06-21 06:46:47 -04:00
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include "ui_chanalyzergui.h"
|
2015-08-21 02:54:28 -04:00
|
|
|
#include "dsp/threadedsamplesink.h"
|
2015-06-21 06:46:47 -04:00
|
|
|
#include "dsp/channelizer.h"
|
2015-06-23 14:05:28 -04:00
|
|
|
#include "dsp/spectrumscopecombovis.h"
|
2015-06-21 06:46:47 -04:00
|
|
|
#include "dsp/spectrumvis.h"
|
2015-06-21 22:16:27 -04:00
|
|
|
#include "dsp/scopevis.h"
|
2015-06-21 06:46:47 -04:00
|
|
|
#include "gui/glspectrum.h"
|
2015-06-21 22:16:27 -04:00
|
|
|
#include "gui/glscope.h"
|
2015-06-21 06:46:47 -04:00
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
2015-10-03 23:28:11 -04:00
|
|
|
#include "util/db.h"
|
2015-06-21 06:46:47 -04:00
|
|
|
#include "gui/basicchannelsettingswidget.h"
|
2015-08-17 02:29:34 -04:00
|
|
|
#include "dsp/dspengine.h"
|
2015-07-31 22:07:09 -04:00
|
|
|
#include "mainwindow.h"
|
2015-06-21 06:46:47 -04:00
|
|
|
|
|
|
|
#include "chanalyzer.h"
|
|
|
|
#include "chanalyzergui.h"
|
|
|
|
|
|
|
|
ChannelAnalyzerGUI* ChannelAnalyzerGUI::create(PluginAPI* pluginAPI)
|
|
|
|
{
|
|
|
|
ChannelAnalyzerGUI* gui = new ChannelAnalyzerGUI(pluginAPI);
|
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerGUI::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerGUI::setName(const QString& name)
|
|
|
|
{
|
|
|
|
setObjectName(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ChannelAnalyzerGUI::getName() const
|
|
|
|
{
|
|
|
|
return objectName();
|
|
|
|
}
|
|
|
|
|
2015-07-18 20:07:40 -04:00
|
|
|
qint64 ChannelAnalyzerGUI::getCenterFrequency() const
|
|
|
|
{
|
2015-08-24 17:50:52 -04:00
|
|
|
return m_channelMarker.getCenterFrequency();
|
2015-07-18 20:07:40 -04:00
|
|
|
}
|
|
|
|
|
2015-09-28 21:35:14 -04:00
|
|
|
void ChannelAnalyzerGUI::setCenterFrequency(qint64 centerFrequency)
|
|
|
|
{
|
|
|
|
m_channelMarker.setCenterFrequency(centerFrequency);
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2015-06-21 06:46:47 -04:00
|
|
|
void ChannelAnalyzerGUI::resetToDefaults()
|
|
|
|
{
|
2015-08-18 19:02:52 -04:00
|
|
|
blockApplySettings(true);
|
|
|
|
|
2015-06-21 06:46:47 -04:00
|
|
|
ui->BW->setValue(30);
|
|
|
|
ui->deltaFrequency->setValue(0);
|
|
|
|
ui->spanLog2->setValue(3);
|
2015-08-18 19:02:52 -04:00
|
|
|
|
|
|
|
blockApplySettings(false);
|
2015-06-21 06:46:47 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray ChannelAnalyzerGUI::serialize() const
|
|
|
|
{
|
|
|
|
SimpleSerializer s(1);
|
2015-08-24 17:50:52 -04:00
|
|
|
s.writeS32(1, m_channelMarker.getCenterFrequency());
|
2015-06-21 06:46:47 -04:00
|
|
|
s.writeS32(2, ui->BW->value());
|
|
|
|
s.writeBlob(3, ui->spectrumGUI->serialize());
|
2015-08-24 17:50:52 -04:00
|
|
|
s.writeU32(4, m_channelMarker.getColor().rgb());
|
2015-06-21 06:46:47 -04:00
|
|
|
s.writeS32(5, ui->lowCut->value());
|
|
|
|
s.writeS32(6, ui->spanLog2->value());
|
2015-06-21 07:03:12 -04:00
|
|
|
s.writeBool(7, ui->ssb->isChecked());
|
2015-06-23 16:52:27 -04:00
|
|
|
s.writeBlob(8, ui->scopeGUI->serialize());
|
2015-06-21 06:46:47 -04:00
|
|
|
return s.final();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ChannelAnalyzerGUI::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
SimpleDeserializer d(data);
|
|
|
|
|
2015-08-18 19:02:52 -04:00
|
|
|
if(!d.isValid())
|
|
|
|
{
|
2015-06-21 06:46:47 -04:00
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-18 19:02:52 -04:00
|
|
|
if(d.getVersion() == 1)
|
|
|
|
{
|
2015-06-21 06:46:47 -04:00
|
|
|
QByteArray bytetmp;
|
|
|
|
quint32 u32tmp;
|
2015-10-09 02:55:22 -04:00
|
|
|
qint32 tmp, bw, lowCut;
|
2015-06-21 07:03:12 -04:00
|
|
|
bool tmpBool;
|
2015-08-18 19:02:52 -04:00
|
|
|
|
|
|
|
blockApplySettings(true);
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.blockSignals(true);
|
2015-08-18 19:02:52 -04:00
|
|
|
|
2015-06-21 06:46:47 -04:00
|
|
|
d.readS32(1, &tmp, 0);
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setCenterFrequency(tmp);
|
2015-10-09 02:55:22 -04:00
|
|
|
d.readS32(2, &bw, 30);
|
|
|
|
ui->BW->setValue(bw);
|
2015-06-21 06:46:47 -04:00
|
|
|
d.readBlob(3, &bytetmp);
|
|
|
|
ui->spectrumGUI->deserialize(bytetmp);
|
2015-08-24 17:50:52 -04:00
|
|
|
|
2015-06-21 06:46:47 -04:00
|
|
|
if(d.readU32(4, &u32tmp))
|
2015-08-24 17:50:52 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setColor(u32tmp);
|
|
|
|
}
|
|
|
|
|
2015-10-09 02:55:22 -04:00
|
|
|
d.readS32(5, &lowCut, 3);
|
|
|
|
ui->lowCut->setValue(lowCut);
|
2015-06-21 06:46:47 -04:00
|
|
|
d.readS32(6, &tmp, 20);
|
|
|
|
ui->spanLog2->setValue(tmp);
|
|
|
|
setNewRate(tmp);
|
2015-06-21 07:03:12 -04:00
|
|
|
d.readBool(7, &tmpBool, false);
|
|
|
|
ui->ssb->setChecked(tmpBool);
|
2015-06-23 16:52:27 -04:00
|
|
|
d.readBlob(8, &bytetmp);
|
|
|
|
ui->scopeGUI->deserialize(bytetmp);
|
2015-08-18 19:02:52 -04:00
|
|
|
|
|
|
|
blockApplySettings(false);
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.blockSignals(false);
|
2015-08-18 19:02:52 -04:00
|
|
|
|
2015-10-09 02:55:22 -04:00
|
|
|
ui->BW->setValue(bw);
|
|
|
|
ui->lowCut->setValue(lowCut); // does applySettings();
|
|
|
|
|
2015-06-21 06:46:47 -04:00
|
|
|
return true;
|
2015-08-18 19:02:52 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-21 06:46:47 -04:00
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-17 02:29:34 -04:00
|
|
|
bool ChannelAnalyzerGUI::handleMessage(const Message& message)
|
2015-06-21 06:46:47 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerGUI::viewChanged()
|
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2015-10-03 23:28:11 -04:00
|
|
|
void ChannelAnalyzerGUI::tick()
|
|
|
|
{
|
|
|
|
Real powDb = CalcDb::dbPower(m_channelAnalyzer->getMagSq());
|
|
|
|
m_channelPowerDbAvg.feed(powDb);
|
|
|
|
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
|
|
|
|
}
|
|
|
|
|
2015-07-12 03:32:54 -04:00
|
|
|
void ChannelAnalyzerGUI::channelSampleRateChanged()
|
|
|
|
{
|
|
|
|
setNewRate(m_spanLog2);
|
|
|
|
}
|
|
|
|
|
2015-10-03 23:28:11 -04:00
|
|
|
void ChannelAnalyzerGUI::on_deltaMinus_toggled(bool minus)
|
2015-06-21 06:46:47 -04:00
|
|
|
{
|
2015-08-24 17:50:52 -04:00
|
|
|
int deltaFrequency = m_channelMarker.getCenterFrequency();
|
2015-06-21 06:46:47 -04:00
|
|
|
bool minusDelta = (deltaFrequency < 0);
|
|
|
|
|
|
|
|
if (minus ^ minusDelta) // sign change
|
|
|
|
{
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setCenterFrequency(-deltaFrequency);
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerGUI::on_deltaFrequency_changed(quint64 value)
|
|
|
|
{
|
|
|
|
if (ui->deltaMinus->isChecked()) {
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setCenterFrequency(-value);
|
2015-06-21 06:46:47 -04:00
|
|
|
} else {
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setCenterFrequency(value);
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerGUI::on_BW_valueChanged(int value)
|
|
|
|
{
|
|
|
|
QString s = QString::number(value/10.0, 'f', 1);
|
|
|
|
ui->BWText->setText(tr("%1k").arg(s));
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setBandwidth(value * 100 * 2);
|
2015-06-21 06:46:47 -04:00
|
|
|
|
2015-06-21 14:58:35 -04:00
|
|
|
if (ui->ssb->isChecked())
|
|
|
|
{
|
|
|
|
if (value < 0) {
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setSidebands(ChannelMarker::lsb);
|
2015-06-21 14:58:35 -04:00
|
|
|
} else {
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setSidebands(ChannelMarker::usb);
|
2015-06-21 14:58:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setSidebands(ChannelMarker::dsb);
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
|
2015-08-24 17:50:52 -04:00
|
|
|
on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100);
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int ChannelAnalyzerGUI::getEffectiveLowCutoff(int lowCutoff)
|
|
|
|
{
|
2015-08-24 17:50:52 -04:00
|
|
|
int ssbBW = m_channelMarker.getBandwidth() / 2;
|
2015-06-21 06:46:47 -04:00
|
|
|
int effectiveLowCutoff = lowCutoff;
|
|
|
|
const int guard = 100;
|
|
|
|
|
|
|
|
if (ssbBW < 0) {
|
|
|
|
if (effectiveLowCutoff < ssbBW + guard) {
|
|
|
|
effectiveLowCutoff = ssbBW + guard;
|
|
|
|
}
|
|
|
|
if (effectiveLowCutoff > 0) {
|
|
|
|
effectiveLowCutoff = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (effectiveLowCutoff > ssbBW - guard) {
|
|
|
|
effectiveLowCutoff = ssbBW - guard;
|
|
|
|
}
|
|
|
|
if (effectiveLowCutoff < 0) {
|
|
|
|
effectiveLowCutoff = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return effectiveLowCutoff;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerGUI::on_lowCut_valueChanged(int value)
|
|
|
|
{
|
|
|
|
int lowCutoff = getEffectiveLowCutoff(value * 100);
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setLowCutoff(lowCutoff);
|
2015-06-21 06:46:47 -04:00
|
|
|
QString s = QString::number(lowCutoff/1000.0, 'f', 1);
|
|
|
|
ui->lowCutText->setText(tr("%1k").arg(s));
|
|
|
|
ui->lowCut->setValue(lowCutoff/100);
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerGUI::on_spanLog2_valueChanged(int value)
|
|
|
|
{
|
|
|
|
if (setNewRate(value)) {
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerGUI::on_ssb_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (checked)
|
|
|
|
{
|
|
|
|
if (ui->BW->value() < 0) {
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setSidebands(ChannelMarker::lsb);
|
2015-06-21 06:46:47 -04:00
|
|
|
} else {
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setSidebands(ChannelMarker::usb);
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
|
2015-07-16 16:31:12 -04:00
|
|
|
ui->glSpectrum->setCenterFrequency(m_rate/4);
|
|
|
|
ui->glSpectrum->setSampleRate(m_rate/2);
|
2015-06-21 06:46:47 -04:00
|
|
|
ui->glSpectrum->setSsbSpectrum(true);
|
|
|
|
|
2015-08-24 17:50:52 -04:00
|
|
|
on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100);
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setSidebands(ChannelMarker::dsb);
|
2015-06-21 06:46:47 -04:00
|
|
|
|
|
|
|
ui->glSpectrum->setCenterFrequency(0);
|
2015-07-16 16:31:12 -04:00
|
|
|
ui->glSpectrum->setSampleRate(m_rate);
|
2015-06-21 06:46:47 -04:00
|
|
|
ui->glSpectrum->setSsbSpectrum(false);
|
|
|
|
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
if((widget == ui->spectrumContainer) && (m_ssbDemod != NULL))
|
|
|
|
m_ssbDemod->setSpectrum(m_threadedSampleSink->getMessageQueue(), rollDown);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerGUI::onMenuDoubleClicked()
|
|
|
|
{
|
|
|
|
if(!m_basicSettingsShown) {
|
|
|
|
m_basicSettingsShown = true;
|
2015-08-24 17:50:52 -04:00
|
|
|
BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(&m_channelMarker, this);
|
2015-06-21 06:46:47 -04:00
|
|
|
bcsw->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, QWidget* parent) :
|
|
|
|
RollupWidget(parent),
|
|
|
|
ui(new Ui::ChannelAnalyzerGUI),
|
|
|
|
m_pluginAPI(pluginAPI),
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker(this),
|
2015-06-21 06:46:47 -04:00
|
|
|
m_basicSettingsShown(false),
|
2015-08-18 19:02:52 -04:00
|
|
|
m_doApplySettings(true),
|
2015-06-21 06:46:47 -04:00
|
|
|
m_rate(6000),
|
2015-10-03 23:28:11 -04:00
|
|
|
m_spanLog2(3),
|
2015-10-04 21:32:00 -04:00
|
|
|
m_channelPowerDbAvg(40,0)
|
2015-06-21 06:46:47 -04:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
|
|
|
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
|
|
|
|
|
|
|
|
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
|
2015-06-21 22:16:27 -04:00
|
|
|
m_scopeVis = new ScopeVis(ui->glScope);
|
2015-06-23 14:05:28 -04:00
|
|
|
m_spectrumScopeComboVis = new SpectrumScopeComboVis(m_spectrumVis, m_scopeVis);
|
|
|
|
m_channelAnalyzer = new ChannelAnalyzer(m_spectrumScopeComboVis);
|
2015-06-21 06:46:47 -04:00
|
|
|
m_channelizer = new Channelizer(m_channelAnalyzer);
|
2015-08-21 02:54:28 -04:00
|
|
|
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
|
2015-07-12 03:32:54 -04:00
|
|
|
connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged()));
|
2015-08-21 02:54:28 -04:00
|
|
|
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
|
2015-06-21 06:46:47 -04:00
|
|
|
|
2015-07-26 13:06:00 -04:00
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
|
2015-09-27 22:13:37 -04:00
|
|
|
ui->deltaFrequency->setValueRange(7, 0U, 9999999U);
|
2015-07-26 13:06:00 -04:00
|
|
|
|
2015-06-21 06:46:47 -04:00
|
|
|
ui->glSpectrum->setCenterFrequency(m_rate/2);
|
|
|
|
ui->glSpectrum->setSampleRate(m_rate);
|
|
|
|
ui->glSpectrum->setDisplayWaterfall(true);
|
|
|
|
ui->glSpectrum->setDisplayMaxHold(true);
|
|
|
|
ui->glSpectrum->setSsbSpectrum(true);
|
2015-07-31 22:07:09 -04:00
|
|
|
|
2015-10-03 23:28:11 -04:00
|
|
|
ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
|
2015-07-31 22:07:09 -04:00
|
|
|
ui->glScope->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
|
2015-10-03 23:28:11 -04:00
|
|
|
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
|
2015-06-21 06:46:47 -04:00
|
|
|
|
2015-08-24 17:50:52 -04:00
|
|
|
//m_channelMarker = new ChannelMarker(this);
|
|
|
|
m_channelMarker.setColor(Qt::gray);
|
|
|
|
m_channelMarker.setBandwidth(m_rate);
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::usb);
|
|
|
|
m_channelMarker.setCenterFrequency(0);
|
|
|
|
m_channelMarker.setVisible(true);
|
|
|
|
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
|
|
|
|
m_pluginAPI->addChannelMarker(&m_channelMarker);
|
2015-06-21 06:46:47 -04:00
|
|
|
|
2015-08-17 02:29:34 -04:00
|
|
|
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
|
|
|
|
ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope);
|
2015-06-21 06:46:47 -04:00
|
|
|
|
|
|
|
applySettings();
|
2015-10-21 21:42:27 -04:00
|
|
|
setNewRate(m_spanLog2);
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ChannelAnalyzerGUI::~ChannelAnalyzerGUI()
|
|
|
|
{
|
|
|
|
m_pluginAPI->removeChannelInstance(this);
|
2015-08-21 02:54:28 -04:00
|
|
|
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
|
|
|
|
delete m_threadedChannelizer;
|
2015-06-21 06:46:47 -04:00
|
|
|
delete m_channelizer;
|
|
|
|
delete m_channelAnalyzer;
|
|
|
|
delete m_spectrumVis;
|
2015-06-21 22:16:27 -04:00
|
|
|
delete m_scopeVis;
|
2015-06-23 14:05:28 -04:00
|
|
|
delete m_spectrumScopeComboVis;
|
2015-08-24 17:50:52 -04:00
|
|
|
//delete m_channelMarker;
|
2015-06-21 06:46:47 -04:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ChannelAnalyzerGUI::setNewRate(int spanLog2)
|
|
|
|
{
|
2015-10-21 21:42:27 -04:00
|
|
|
qDebug("ChannelAnalyzerGUI::setNewRate");
|
|
|
|
|
2015-07-16 19:08:51 -04:00
|
|
|
if ((spanLog2 < 0) || (spanLog2 > 6)) {
|
2015-06-21 06:46:47 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_spanLog2 = spanLog2;
|
2015-06-21 14:58:35 -04:00
|
|
|
//m_rate = 48000 / (1<<spanLog2);
|
|
|
|
m_rate = m_channelAnalyzer->getSampleRate() / (1<<spanLog2);
|
2015-08-18 19:02:52 -04:00
|
|
|
|
2016-01-13 15:19:10 -05:00
|
|
|
if (ui->BW->value() < -m_rate/200) {
|
|
|
|
ui->BW->setValue(-m_rate/200);
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setBandwidth(-m_rate*2);
|
2016-01-13 15:19:10 -05:00
|
|
|
} else if (ui->BW->value() > m_rate/200) {
|
|
|
|
ui->BW->setValue(m_rate/200);
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setBandwidth(m_rate*2);
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
|
2016-01-13 15:19:10 -05:00
|
|
|
if (ui->lowCut->value() < -m_rate/200) {
|
|
|
|
ui->lowCut->setValue(-m_rate/200);
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setLowCutoff(-m_rate);
|
2016-01-13 15:19:10 -05:00
|
|
|
} else if (ui->lowCut->value() > m_rate/200) {
|
|
|
|
ui->lowCut->setValue(m_rate/200);
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setLowCutoff(m_rate);
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
|
2016-01-13 15:19:10 -05:00
|
|
|
ui->BW->setMinimum(-m_rate/200);
|
|
|
|
ui->lowCut->setMinimum(-m_rate/200);
|
|
|
|
ui->BW->setMaximum(m_rate/200);
|
|
|
|
ui->lowCut->setMaximum(m_rate/200);
|
2015-06-21 06:46:47 -04:00
|
|
|
|
|
|
|
QString s = QString::number(m_rate/1000.0, 'f', 1);
|
|
|
|
ui->spanText->setText(tr("%1k").arg(s));
|
|
|
|
|
|
|
|
if (ui->ssb->isChecked())
|
|
|
|
{
|
|
|
|
if (ui->BW->value() < 0) {
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setSidebands(ChannelMarker::lsb);
|
2015-06-21 06:46:47 -04:00
|
|
|
} else {
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setSidebands(ChannelMarker::usb);
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
|
2015-07-16 16:31:12 -04:00
|
|
|
ui->glSpectrum->setCenterFrequency(m_rate/4);
|
|
|
|
ui->glSpectrum->setSampleRate(m_rate/2);
|
2015-06-21 06:46:47 -04:00
|
|
|
ui->glSpectrum->setSsbSpectrum(true);
|
2015-07-16 16:31:12 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setSidebands(ChannelMarker::dsb);
|
2015-06-21 06:46:47 -04:00
|
|
|
|
|
|
|
ui->glSpectrum->setCenterFrequency(0);
|
2015-07-16 16:31:12 -04:00
|
|
|
ui->glSpectrum->setSampleRate(m_rate);
|
2015-06-21 06:46:47 -04:00
|
|
|
ui->glSpectrum->setSsbSpectrum(false);
|
|
|
|
}
|
|
|
|
|
2015-07-16 16:31:12 -04:00
|
|
|
ui->glScope->setSampleRate(m_rate);
|
|
|
|
m_scopeVis->setSampleRate(m_rate);
|
|
|
|
|
2015-06-21 06:46:47 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-18 19:02:52 -04:00
|
|
|
void ChannelAnalyzerGUI::blockApplySettings(bool block)
|
|
|
|
{
|
|
|
|
ui->glScope->blockSignals(block);
|
|
|
|
ui->glSpectrum->blockSignals(block);
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
2015-06-21 06:46:47 -04:00
|
|
|
void ChannelAnalyzerGUI::applySettings()
|
|
|
|
{
|
2015-08-23 22:09:36 -04:00
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
2015-08-24 17:50:52 -04:00
|
|
|
setTitleColor(m_channelMarker.getColor());
|
|
|
|
ui->deltaFrequency->setValue(abs(m_channelMarker.getCenterFrequency()));
|
|
|
|
ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0);
|
2015-08-23 22:09:36 -04:00
|
|
|
|
|
|
|
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
|
|
|
|
m_channelizer->getInputSampleRate(),
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.getCenterFrequency());
|
2015-08-23 22:09:36 -04:00
|
|
|
|
|
|
|
m_channelAnalyzer->configure(m_channelAnalyzer->getInputMessageQueue(),
|
|
|
|
ui->BW->value() * 100.0,
|
|
|
|
ui->lowCut->value() * 100.0,
|
|
|
|
m_spanLog2,
|
|
|
|
ui->ssb->isChecked());
|
|
|
|
}
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerGUI::leaveEvent(QEvent*)
|
|
|
|
{
|
2015-08-18 19:02:52 -04:00
|
|
|
blockApplySettings(true);
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setHighlighted(false);
|
2015-08-18 19:02:52 -04:00
|
|
|
blockApplySettings(false);
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerGUI::enterEvent(QEvent*)
|
|
|
|
{
|
2015-08-18 19:02:52 -04:00
|
|
|
blockApplySettings(true);
|
2015-08-24 17:50:52 -04:00
|
|
|
m_channelMarker.setHighlighted(true);
|
2015-08-18 19:02:52 -04:00
|
|
|
blockApplySettings(false);
|
2015-06-21 06:46:47 -04:00
|
|
|
}
|
|
|
|
|