1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-24 10:50:29 -05:00

Deep redesign: SSB demod: allocalte channel marker on demod GUI object stack

This commit is contained in:
f4exb 2015-08-25 00:48:56 +02:00
parent 204b9ed309
commit 3e999fc2a9
2 changed files with 40 additions and 39 deletions

View File

@ -38,7 +38,7 @@ QString SSBDemodGUI::getName() const
qint64 SSBDemodGUI::getCenterFrequency() const qint64 SSBDemodGUI::getCenterFrequency() const
{ {
return m_channelMarker->getCenterFrequency(); return m_channelMarker.getCenterFrequency();
} }
void SSBDemodGUI::resetToDefaults() void SSBDemodGUI::resetToDefaults()
@ -57,11 +57,11 @@ void SSBDemodGUI::resetToDefaults()
QByteArray SSBDemodGUI::serialize() const QByteArray SSBDemodGUI::serialize() const
{ {
SimpleSerializer s(1); SimpleSerializer s(1);
s.writeS32(1, m_channelMarker->getCenterFrequency()); s.writeS32(1, m_channelMarker.getCenterFrequency());
s.writeS32(2, ui->BW->value()); s.writeS32(2, ui->BW->value());
s.writeS32(3, ui->volume->value()); s.writeS32(3, ui->volume->value());
s.writeBlob(4, ui->spectrumGUI->serialize()); s.writeBlob(4, ui->spectrumGUI->serialize());
s.writeU32(5, m_channelMarker->getColor().rgb()); s.writeU32(5, m_channelMarker.getColor().rgb());
s.writeS32(6, ui->lowCut->value()); s.writeS32(6, ui->lowCut->value());
s.writeS32(7, ui->spanLog2->value()); s.writeS32(7, ui->spanLog2->value());
return s.final(); return s.final();
@ -84,10 +84,10 @@ bool SSBDemodGUI::deserialize(const QByteArray& data)
qint32 tmp; qint32 tmp;
blockApplySettings(true); blockApplySettings(true);
m_channelMarker->blockSignals(true); m_channelMarker.blockSignals(true);
d.readS32(1, &tmp, 0); d.readS32(1, &tmp, 0);
m_channelMarker->setCenterFrequency(tmp); m_channelMarker.setCenterFrequency(tmp);
d.readS32(2, &tmp, 30); d.readS32(2, &tmp, 30);
ui->BW->setValue(tmp); ui->BW->setValue(tmp);
d.readS32(3, &tmp, 20); d.readS32(3, &tmp, 20);
@ -95,7 +95,7 @@ bool SSBDemodGUI::deserialize(const QByteArray& data)
d.readBlob(4, &bytetmp); d.readBlob(4, &bytetmp);
ui->spectrumGUI->deserialize(bytetmp); ui->spectrumGUI->deserialize(bytetmp);
if(d.readU32(5, &u32tmp)) if(d.readU32(5, &u32tmp))
m_channelMarker->setColor(u32tmp); m_channelMarker.setColor(u32tmp);
d.readS32(6, &tmp, 3); d.readS32(6, &tmp, 3);
ui->lowCut->setValue(tmp); ui->lowCut->setValue(tmp);
d.readS32(7, &tmp, 20); d.readS32(7, &tmp, 20);
@ -103,7 +103,7 @@ bool SSBDemodGUI::deserialize(const QByteArray& data)
setNewRate(tmp); setNewRate(tmp);
blockApplySettings(false); blockApplySettings(false);
m_channelMarker->blockSignals(false); m_channelMarker.blockSignals(false);
applySettings(); applySettings();
return true; return true;
@ -127,12 +127,12 @@ void SSBDemodGUI::viewChanged()
void SSBDemodGUI::on_deltaMinus_clicked(bool minus) void SSBDemodGUI::on_deltaMinus_clicked(bool minus)
{ {
int deltaFrequency = m_channelMarker->getCenterFrequency(); int deltaFrequency = m_channelMarker.getCenterFrequency();
bool minusDelta = (deltaFrequency < 0); bool minusDelta = (deltaFrequency < 0);
if (minus ^ minusDelta) // sign change if (minus ^ minusDelta) // sign change
{ {
m_channelMarker->setCenterFrequency(-deltaFrequency); m_channelMarker.setCenterFrequency(-deltaFrequency);
} }
} }
@ -140,11 +140,11 @@ void SSBDemodGUI::on_deltaFrequency_changed(quint64 value)
{ {
if (ui->deltaMinus->isChecked()) if (ui->deltaMinus->isChecked())
{ {
m_channelMarker->setCenterFrequency(-value); m_channelMarker.setCenterFrequency(-value);
} }
else else
{ {
m_channelMarker->setCenterFrequency(value); m_channelMarker.setCenterFrequency(value);
} }
} }
@ -152,23 +152,23 @@ void SSBDemodGUI::on_BW_valueChanged(int value)
{ {
QString s = QString::number(value/10.0, 'f', 1); QString s = QString::number(value/10.0, 'f', 1);
ui->BWText->setText(tr("%1k").arg(s)); ui->BWText->setText(tr("%1k").arg(s));
m_channelMarker->setBandwidth(value * 100 * 2); m_channelMarker.setBandwidth(value * 100 * 2);
if (value < 0) if (value < 0)
{ {
m_channelMarker->setSidebands(ChannelMarker::lsb); m_channelMarker.setSidebands(ChannelMarker::lsb);
} }
else else
{ {
m_channelMarker->setSidebands(ChannelMarker::usb); m_channelMarker.setSidebands(ChannelMarker::usb);
} }
on_lowCut_valueChanged(m_channelMarker->getLowCutoff()/100); on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100);
} }
int SSBDemodGUI::getEffectiveLowCutoff(int lowCutoff) int SSBDemodGUI::getEffectiveLowCutoff(int lowCutoff)
{ {
int ssbBW = m_channelMarker->getBandwidth() / 2; int ssbBW = m_channelMarker.getBandwidth() / 2;
int effectiveLowCutoff = lowCutoff; int effectiveLowCutoff = lowCutoff;
const int guard = 100; const int guard = 100;
@ -201,7 +201,7 @@ int SSBDemodGUI::getEffectiveLowCutoff(int lowCutoff)
void SSBDemodGUI::on_lowCut_valueChanged(int value) void SSBDemodGUI::on_lowCut_valueChanged(int value)
{ {
int lowCutoff = getEffectiveLowCutoff(value * 100); int lowCutoff = getEffectiveLowCutoff(value * 100);
m_channelMarker->setLowCutoff(lowCutoff); m_channelMarker.setLowCutoff(lowCutoff);
QString s = QString::number(lowCutoff/1000.0, 'f', 1); QString s = QString::number(lowCutoff/1000.0, 'f', 1);
ui->lowCutText->setText(tr("%1k").arg(s)); ui->lowCutText->setText(tr("%1k").arg(s));
ui->lowCut->setValue(lowCutoff/100); ui->lowCut->setValue(lowCutoff/100);
@ -236,7 +236,7 @@ void SSBDemodGUI::onMenuDoubleClicked()
if(!m_basicSettingsShown) if(!m_basicSettingsShown)
{ {
m_basicSettingsShown = true; m_basicSettingsShown = true;
BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(m_channelMarker, this); BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(&m_channelMarker, this);
bcsw->show(); bcsw->show();
} }
} }
@ -245,6 +245,7 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
RollupWidget(parent), RollupWidget(parent),
ui(new Ui::SSBDemodGUI), ui(new Ui::SSBDemodGUI),
m_pluginAPI(pluginAPI), m_pluginAPI(pluginAPI),
m_channelMarker(this),
m_basicSettingsShown(false), m_basicSettingsShown(false),
m_doApplySettings(true), m_doApplySettings(true),
m_rate(6000), m_rate(6000),
@ -270,14 +271,14 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
ui->glSpectrum->setSsbSpectrum(true); ui->glSpectrum->setSsbSpectrum(true);
ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer()); ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
m_channelMarker = new ChannelMarker(this); //m_channelMarker = new ChannelMarker(this);
m_channelMarker->setColor(Qt::green); m_channelMarker.setColor(Qt::green);
m_channelMarker->setBandwidth(m_rate); m_channelMarker.setBandwidth(m_rate);
m_channelMarker->setSidebands(ChannelMarker::usb); m_channelMarker.setSidebands(ChannelMarker::usb);
m_channelMarker->setCenterFrequency(0); m_channelMarker.setCenterFrequency(0);
m_channelMarker->setVisible(true); m_channelMarker.setVisible(true);
connect(m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged())); connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
m_pluginAPI->addChannelMarker(m_channelMarker); m_pluginAPI->addChannelMarker(&m_channelMarker);
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum); ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
@ -292,7 +293,7 @@ SSBDemodGUI::~SSBDemodGUI()
delete m_channelizer; delete m_channelizer;
delete m_ssbDemod; delete m_ssbDemod;
delete m_spectrumVis; delete m_spectrumVis;
delete m_channelMarker; //delete m_channelMarker;
delete ui; delete ui;
} }
@ -309,23 +310,23 @@ bool SSBDemodGUI::setNewRate(int spanLog2)
if (ui->BW->value() < -m_rate/100) if (ui->BW->value() < -m_rate/100)
{ {
ui->BW->setValue(-m_rate/100); ui->BW->setValue(-m_rate/100);
m_channelMarker->setBandwidth(-m_rate*2); m_channelMarker.setBandwidth(-m_rate*2);
} }
else if (ui->BW->value() > m_rate/100) else if (ui->BW->value() > m_rate/100)
{ {
ui->BW->setValue(m_rate/100); ui->BW->setValue(m_rate/100);
m_channelMarker->setBandwidth(m_rate*2); m_channelMarker.setBandwidth(m_rate*2);
} }
if (ui->lowCut->value() < -m_rate/100) if (ui->lowCut->value() < -m_rate/100)
{ {
ui->lowCut->setValue(-m_rate/100); ui->lowCut->setValue(-m_rate/100);
m_channelMarker->setLowCutoff(-m_rate); m_channelMarker.setLowCutoff(-m_rate);
} }
else if (ui->lowCut->value() > m_rate/100) else if (ui->lowCut->value() > m_rate/100)
{ {
ui->lowCut->setValue(m_rate/100); ui->lowCut->setValue(m_rate/100);
m_channelMarker->setLowCutoff(m_rate); m_channelMarker.setLowCutoff(m_rate);
} }
ui->BW->setMinimum(-m_rate/100); ui->BW->setMinimum(-m_rate/100);
@ -351,13 +352,13 @@ void SSBDemodGUI::applySettings()
{ {
if (m_doApplySettings) if (m_doApplySettings)
{ {
setTitleColor(m_channelMarker->getColor()); setTitleColor(m_channelMarker.getColor());
ui->deltaFrequency->setValue(abs(m_channelMarker->getCenterFrequency())); ui->deltaFrequency->setValue(abs(m_channelMarker.getCenterFrequency()));
ui->deltaMinus->setChecked(m_channelMarker->getCenterFrequency() < 0); ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0);
m_channelizer->configure(m_channelizer->getInputMessageQueue(), m_channelizer->configure(m_channelizer->getInputMessageQueue(),
48000, 48000,
m_channelMarker->getCenterFrequency()); m_channelMarker.getCenterFrequency());
m_ssbDemod->configure(m_ssbDemod->getInputMessageQueue(), m_ssbDemod->configure(m_ssbDemod->getInputMessageQueue(),
ui->BW->value() * 100.0, ui->BW->value() * 100.0,
@ -370,14 +371,14 @@ void SSBDemodGUI::applySettings()
void SSBDemodGUI::leaveEvent(QEvent*) void SSBDemodGUI::leaveEvent(QEvent*)
{ {
blockApplySettings(true); blockApplySettings(true);
m_channelMarker->setHighlighted(false); m_channelMarker.setHighlighted(false);
blockApplySettings(false); blockApplySettings(false);
} }
void SSBDemodGUI::enterEvent(QEvent*) void SSBDemodGUI::enterEvent(QEvent*)
{ {
blockApplySettings(true); blockApplySettings(true);
m_channelMarker->setHighlighted(true); m_channelMarker.setHighlighted(true);
blockApplySettings(false); blockApplySettings(false);
} }

View File

@ -3,9 +3,9 @@
#include "gui/rollupwidget.h" #include "gui/rollupwidget.h"
#include "plugin/plugingui.h" #include "plugin/plugingui.h"
#include "dsp/channelmarker.h"
class PluginAPI; class PluginAPI;
class ChannelMarker;
class AudioFifo; class AudioFifo;
class ThreadedSampleSink; class ThreadedSampleSink;
@ -48,7 +48,7 @@ private slots:
private: private:
Ui::SSBDemodGUI* ui; Ui::SSBDemodGUI* ui;
PluginAPI* m_pluginAPI; PluginAPI* m_pluginAPI;
ChannelMarker* m_channelMarker; ChannelMarker m_channelMarker;
bool m_basicSettingsShown; bool m_basicSettingsShown;
bool m_doApplySettings; bool m_doApplySettings;
int m_rate; int m_rate;