1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-18 14:21:49 -05:00

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

This commit is contained in:
f4exb 2015-08-25 00:36:53 +02:00
parent bb8af9e409
commit 204b9ed309
2 changed files with 30 additions and 29 deletions

View File

@ -40,7 +40,7 @@ QString NFMDemodGUI::getName() const
qint64 NFMDemodGUI::getCenterFrequency() const qint64 NFMDemodGUI::getCenterFrequency() const
{ {
return m_channelMarker->getCenterFrequency(); return m_channelMarker.getCenterFrequency();
} }
void NFMDemodGUI::resetToDefaults() void NFMDemodGUI::resetToDefaults()
@ -60,12 +60,12 @@ void NFMDemodGUI::resetToDefaults()
QByteArray NFMDemodGUI::serialize() const QByteArray NFMDemodGUI::serialize() const
{ {
SimpleSerializer s(1); SimpleSerializer s(1);
s.writeS32(1, m_channelMarker->getCenterFrequency()); s.writeS32(1, m_channelMarker.getCenterFrequency());
s.writeS32(2, ui->rfBW->value()); s.writeS32(2, ui->rfBW->value());
s.writeS32(3, ui->afBW->value()); s.writeS32(3, ui->afBW->value());
s.writeS32(4, ui->volume->value()); s.writeS32(4, ui->volume->value());
s.writeS32(5, ui->squelch->value()); s.writeS32(5, ui->squelch->value());
s.writeU32(7, m_channelMarker->getColor().rgb()); s.writeU32(7, m_channelMarker.getColor().rgb());
s.writeS32(8, ui->ctcss->currentIndex()); s.writeS32(8, ui->ctcss->currentIndex());
return s.final(); return s.final();
} }
@ -87,10 +87,10 @@ bool NFMDemodGUI::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, 4); d.readS32(2, &tmp, 4);
ui->rfBW->setValue(tmp); ui->rfBW->setValue(tmp);
d.readS32(3, &tmp, 3); d.readS32(3, &tmp, 3);
@ -102,14 +102,14 @@ bool NFMDemodGUI::deserialize(const QByteArray& data)
if(d.readU32(7, &u32tmp)) if(d.readU32(7, &u32tmp))
{ {
m_channelMarker->setColor(u32tmp); m_channelMarker.setColor(u32tmp);
} }
d.readS32(8, &tmp, 0); d.readS32(8, &tmp, 0);
ui->ctcss->setCurrentIndex(tmp); ui->ctcss->setCurrentIndex(tmp);
blockApplySettings(false); blockApplySettings(false);
m_channelMarker->blockSignals(false); m_channelMarker.blockSignals(false);
applySettings(); applySettings();
return true; return true;
@ -133,12 +133,12 @@ void NFMDemodGUI::viewChanged()
void NFMDemodGUI::on_deltaMinus_clicked(bool minus) void NFMDemodGUI::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);
} }
} }
@ -146,18 +146,18 @@ void NFMDemodGUI::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);
} }
} }
void NFMDemodGUI::on_rfBW_valueChanged(int value) void NFMDemodGUI::on_rfBW_valueChanged(int value)
{ {
ui->rfBWText->setText(QString("%1 k").arg(m_rfBW[value] / 1000.0)); ui->rfBWText->setText(QString("%1 k").arg(m_rfBW[value] / 1000.0));
m_channelMarker->setBandwidth(m_rfBW[value]); m_channelMarker.setBandwidth(m_rfBW[value]);
applySettings(); applySettings();
} }
@ -200,7 +200,7 @@ void NFMDemodGUI::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();
} }
} }
@ -209,6 +209,7 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
RollupWidget(parent), RollupWidget(parent),
ui(new Ui::NFMDemodGUI), ui(new Ui::NFMDemodGUI),
m_pluginAPI(pluginAPI), m_pluginAPI(pluginAPI),
m_channelMarker(this),
m_basicSettingsShown(false), m_basicSettingsShown(false),
m_doApplySettings(true) m_doApplySettings(true)
{ {
@ -236,15 +237,15 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this); m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer); DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
m_channelMarker = new ChannelMarker(this); //m_channelMarker = new ChannelMarker(this);
m_channelMarker->setColor(Qt::red); m_channelMarker.setColor(Qt::red);
m_channelMarker->setBandwidth(12500); m_channelMarker.setBandwidth(12500);
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);
applySettings(); applySettings();
} }
@ -256,7 +257,7 @@ NFMDemodGUI::~NFMDemodGUI()
delete m_threadedChannelizer; delete m_threadedChannelizer;
delete m_channelizer; delete m_channelizer;
delete m_nfmDemod; delete m_nfmDemod;
delete m_channelMarker; //delete m_channelMarker;
delete ui; delete ui;
} }
@ -266,14 +267,14 @@ void NFMDemodGUI::applySettings()
{ {
qDebug() << "NFMDemodGUI::applySettings"; qDebug() << "NFMDemodGUI::applySettings";
setTitleColor(m_channelMarker->getColor()); setTitleColor(m_channelMarker.getColor());
m_channelizer->configure(m_channelizer->getInputMessageQueue(), m_channelizer->configure(m_channelizer->getInputMessageQueue(),
48000, 48000,
m_channelMarker->getCenterFrequency()); m_channelMarker.getCenterFrequency());
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_nfmDemod->configure(m_nfmDemod->getInputMessageQueue(), m_nfmDemod->configure(m_nfmDemod->getInputMessageQueue(),
m_rfBW[ui->rfBW->value()], m_rfBW[ui->rfBW->value()],
@ -286,14 +287,14 @@ void NFMDemodGUI::applySettings()
void NFMDemodGUI::leaveEvent(QEvent*) void NFMDemodGUI::leaveEvent(QEvent*)
{ {
blockApplySettings(true); blockApplySettings(true);
m_channelMarker->setHighlighted(false); m_channelMarker.setHighlighted(false);
blockApplySettings(false); blockApplySettings(false);
} }
void NFMDemodGUI::enterEvent(QEvent*) void NFMDemodGUI::enterEvent(QEvent*)
{ {
blockApplySettings(true); blockApplySettings(true);
m_channelMarker->setHighlighted(true); m_channelMarker.setHighlighted(true);
blockApplySettings(false); blockApplySettings(false);
} }

View File

@ -4,9 +4,9 @@
#include "gui/rollupwidget.h" #include "gui/rollupwidget.h"
#include "plugin/plugingui.h" #include "plugin/plugingui.h"
#include "dsp/dsptypes.h" #include "dsp/dsptypes.h"
#include "dsp/channelmarker.h"
class PluginAPI; class PluginAPI;
class ChannelMarker;
class ThreadedSampleSink; class ThreadedSampleSink;
class Channelizer; class Channelizer;
@ -49,7 +49,7 @@ private slots:
private: private:
Ui::NFMDemodGUI* ui; Ui::NFMDemodGUI* 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;