1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

Channel Analyzer: set GUI sample rate at construction time. Fixes #649

This commit is contained in:
f4exb 2020-10-07 21:28:32 +02:00
parent de3299098f
commit 40bd300baf
6 changed files with 47 additions and 8 deletions

View File

@ -51,6 +51,7 @@ ChannelAnalyzer::ChannelAnalyzer(DeviceAPI *deviceAPI) :
ChannelAnalyzer::~ChannelAnalyzer()
{
qDebug("ChannelAnalyzer::~ChannelAnalyzer");
m_deviceAPI->removeChannelSinkAPI(this);
m_deviceAPI->removeChannelSink(this);
@ -59,6 +60,7 @@ ChannelAnalyzer::~ChannelAnalyzer()
}
delete m_basebandSink;
qDebug("ChannelAnalyzer::~ChannelAnalyzer: done");
}
void ChannelAnalyzer::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly)
@ -106,6 +108,7 @@ bool ChannelAnalyzer::handleMessage(const Message& cmd)
{
DSPSignalNotification& cfg = (DSPSignalNotification&) cmd;
m_basebandSampleRate = cfg.getSampleRate();
qDebug("ChannelAnalyzer::handleMessage: DSPSignalNotification: %d", m_basebandSampleRate);
m_centerFrequency = cfg.getCenterFrequency();
DSPSignalNotification *notif = new DSPSignalNotification(cfg);
m_basebandSink->getInputMessageQueue()->push(notif);

View File

@ -367,13 +367,15 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
m_scopeVis = new ScopeVis(ui->glScope);
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_channelAnalyzer = (ChannelAnalyzer*) rxChannel; //new ChannelAnalyzer(m_deviceUISet->m_deviceSourceAPI);
m_spectrumVis = m_channelAnalyzer->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_scopeVis = new ScopeVis(ui->glScope);
m_spectrumScopeComboVis = new SpectrumScopeComboVis(m_spectrumVis, m_scopeVis);
m_basebandSampleRate = m_channelAnalyzer->getChannelSampleRate();
m_channelAnalyzer->setSampleSink(m_spectrumScopeComboVis);
m_channelAnalyzer->setMessageQueueToGUI(getInputMessageQueue());
@ -424,9 +426,13 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device
ChannelAnalyzerGUI::~ChannelAnalyzerGUI()
{
delete m_scopeVis;
delete m_spectrumScopeComboVis;
qDebug("ChannelAnalyzerGUI::~ChannelAnalyzerGUI");
ui->glSpectrum->disconnectTimer();
ui->glScope->disconnectTimer();
delete ui;
delete m_spectrumScopeComboVis;
delete m_scopeVis;
qDebug("ChannelAnalyzerGUI::~ChannelAnalyzerGUI: done");
}
int ChannelAnalyzerGUI::getSinkSampleRate()

View File

@ -46,6 +46,7 @@ GLScope::GLScope(QWidget *parent) : QGLWidget(parent),
m_bufferIndex(0),
m_displayMode(DisplayX),
m_displayPolGrid(false),
m_masterTimer(nullptr),
m_dataChanged(0),
m_configChanged(false),
m_sampleRate(0),
@ -2022,6 +2023,18 @@ void GLScope::connectTimer(const QTimer &timer)
disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
connect(&timer, SIGNAL(timeout()), this, SLOT(tick()));
m_timer.stop();
m_masterTimer = &timer;
}
void GLScope::disconnectTimer()
{
qDebug() << "GLScope::disconnectTimer";
if (m_masterTimer) {
disconnect(m_masterTimer, SIGNAL(timeout()), this, SLOT(tick()));
}
m_masterTimer = nullptr;
}
void GLScope::cleanup()

View File

@ -55,6 +55,7 @@ public:
virtual ~GLScope();
void connectTimer(const QTimer& timer);
void disconnectTimer();
void setTraces(std::vector<ScopeVis::TraceData>* tracesData, std::vector<float *>* traces);
void newTraces(std::vector<float *>* traces, int traceIndex, std::vector<Projector::ProjectionType>* projectionTypes);
@ -145,6 +146,7 @@ private:
DisplayMode m_displayMode;
bool m_displayPolGrid;
QTimer m_timer;
const QTimer *m_masterTimer;
QMutex m_mutex;
QAtomicInt m_dataChanged;
bool m_configChanged;

View File

@ -37,6 +37,7 @@ GLSpectrum::GLSpectrum(QWidget* parent) :
QGLWidget(parent),
m_cursorState(CSNormal),
m_cursorChannel(0),
m_masterTimer(nullptr),
m_mouseInside(false),
m_changesPending(true),
m_centerFrequency(100000000),
@ -52,7 +53,7 @@ GLSpectrum::GLSpectrum(QWidget* parent) :
m_displayTraceIntensity(50),
m_invertedWaterfall(false),
m_displayMaxHold(false),
m_currentSpectrum(0),
m_currentSpectrum(nullptr),
m_displayCurrent(false),
m_leftMargin(0),
m_rightMargin(0),
@ -61,22 +62,22 @@ GLSpectrum::GLSpectrum(QWidget* parent) :
m_waterfallHeight(0),
m_frequencyScaleHeight(0),
m_bottomMargin(0),
m_waterfallBuffer(0),
m_waterfallBuffer(nullptr),
m_waterfallBufferPos(0),
m_waterfallTextureHeight(-1),
m_waterfallTexturePos(0),
m_displayWaterfall(true),
m_ssbSpectrum(false),
m_lsbDisplay(false),
m_histogramBuffer(0),
m_histogram(0),
m_histogramBuffer(nullptr),
m_histogram(nullptr),
m_displayHistogram(true),
m_displayChanged(false),
m_displaySourceOrSink(true),
m_displayStreamIndex(0),
m_matrixLoc(0),
m_colorLoc(0),
m_messageQueueToGUI(0)
m_messageQueueToGUI(nullptr)
{
setAutoFillBackground(false);
setAttribute(Qt::WA_OpaquePaintEvent, true);
@ -2281,9 +2282,21 @@ void GLSpectrum::connectTimer(const QTimer& timer)
qDebug() << "GLSpectrum::connectTimer";
disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
connect(&timer, SIGNAL(timeout()), this, SLOT(tick()));
m_masterTimer = &timer;
m_timer.stop();
}
void GLSpectrum::disconnectTimer()
{
qDebug() << "GLScope::disconnectTimer";
if (m_masterTimer) {
disconnect(m_masterTimer, SIGNAL(timeout()), this, SLOT(tick()));
}
m_masterTimer = nullptr;
}
void GLSpectrum::cleanup()
{
//makeCurrent();

View File

@ -108,6 +108,7 @@ public:
Real getWaterfallShare() const { return m_waterfallShare; }
void setWaterfallShare(Real waterfallShare);
void connectTimer(const QTimer& timer);
void disconnectTimer();
void setDisplayedStream(bool sourceOrSink, int streamIndex)
{
@ -235,6 +236,7 @@ private:
int m_cursorChannel;
QTimer m_timer;
const QTimer *m_masterTimer;
QMutex m_mutex;
bool m_mouseInside;
bool m_changesPending;