diff --git a/include-gpl/dsp/scopevis.h b/include-gpl/dsp/scopevis.h index 71b212491..2e45915fa 100644 --- a/include-gpl/dsp/scopevis.h +++ b/include-gpl/dsp/scopevis.h @@ -25,6 +25,9 @@ public: bool handleMessageKeep(Message* message); bool handleMessage(Message* message); + void setSampleRate(int sampleRate); + int getSampleRate() const { return m_sampleRate; } + private: enum TriggerState { Untriggered, diff --git a/include-gpl/gui/glscope.h b/include-gpl/gui/glscope.h index e9aea6232..8f6a4a7cc 100644 --- a/include-gpl/gui/glscope.h +++ b/include-gpl/gui/glscope.h @@ -55,19 +55,14 @@ public: void setDisplayGridIntensity(int intensity); void newTrace(const std::vector& trace, int sampleRate); - int getTraceSize() const { return m_rawTrace.size(); } - void setSampleRate(int sampleRate) { - m_sampleRate = sampleRate; - } - - int getSampleRate() const { - return m_sampleRate; - } + void setSampleRate(int sampleRate); + int getSampleRate() const { return m_sampleRate; } signals: void traceSizeChanged(int); + void sampleRateChanged(int); private: // state diff --git a/include-gpl/gui/glscopegui.h b/include-gpl/gui/glscopegui.h index 587a37e5e..90176d815 100644 --- a/include-gpl/gui/glscopegui.h +++ b/include-gpl/gui/glscopegui.h @@ -48,11 +48,13 @@ private: int m_displayGridIntensity; void applySettings(); + void setTimeScaleDisplay(); private slots: void on_amp_valueChanged(int value); void on_ampOfs_valueChanged(int value); void on_scope_traceSizeChanged(int value); + void on_scope_sampleRateChanged(int value); void on_time_valueChanged(int value); void on_timeOfs_valueChanged(int value); void on_dataMode_currentIndexChanged(int index); diff --git a/plugins/channel/chanalyzer/chanalyzergui.cpp b/plugins/channel/chanalyzer/chanalyzergui.cpp index 3c0dd9c5d..3969b6ff9 100644 --- a/plugins/channel/chanalyzer/chanalyzergui.cpp +++ b/plugins/channel/chanalyzer/chanalyzergui.cpp @@ -276,7 +276,6 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, QWidget* parent) : ui->spectrumGUI->setBuddies(m_threadedSampleSink->getMessageQueue(), m_spectrumVis, ui->glSpectrum); ui->scopeGUI->setBuddies(m_threadedSampleSink->getMessageQueue(), m_scopeVis, ui->glScope); - std::cerr << "ui->glScope: " << ui->glScope->getSampleRate() << std::endl; applySettings(); } @@ -305,8 +304,6 @@ bool ChannelAnalyzerGUI::setNewRate(int spanLog2) //m_rate = 48000 / (1<getSampleRate() / (1<BW->value() < -m_rate/100) { ui->BW->setValue(-m_rate/100); m_channelMarker->setBandwidth(-m_rate*2); @@ -343,6 +340,7 @@ bool ChannelAnalyzerGUI::setNewRate(int spanLog2) ui->glSpectrum->setSampleRate(m_rate); ui->glSpectrum->setSsbSpectrum(true); ui->glScope->setSampleRate(m_rate); + m_scopeVis->setSampleRate(m_rate); } else { m_channelMarker->setSidebands(ChannelMarker::dsb); @@ -350,6 +348,7 @@ bool ChannelAnalyzerGUI::setNewRate(int spanLog2) ui->glSpectrum->setSampleRate(2*m_rate); ui->glSpectrum->setSsbSpectrum(false); ui->glScope->setSampleRate(2*m_rate); + m_scopeVis->setSampleRate(2*m_rate); } return true; diff --git a/sdrbase/dsp/scopevis.cpp b/sdrbase/dsp/scopevis.cpp index b261cd96a..429e70fc0 100644 --- a/sdrbase/dsp/scopevis.cpp +++ b/sdrbase/dsp/scopevis.cpp @@ -7,7 +7,7 @@ ScopeVis::ScopeVis(GLScope* glScope) : m_glScope(glScope), - m_trace(100000), + m_trace(96000), m_fill(0), m_triggerState(Untriggered), m_triggerChannel(TriggerFreeRun), @@ -152,3 +152,8 @@ bool ScopeVis::handleMessage(Message* message) return done; } + +void ScopeVis::setSampleRate(int sampleRate) +{ + m_sampleRate = sampleRate; +} diff --git a/sdrbase/gui/glscope.cpp b/sdrbase/gui/glscope.cpp index 73ef8f17d..a1dacca67 100644 --- a/sdrbase/gui/glscope.cpp +++ b/sdrbase/gui/glscope.cpp @@ -54,6 +54,11 @@ void GLScope::setDSPEngine(DSPEngine* dspEngine) } } +void GLScope::setSampleRate(int sampleRate) { + m_sampleRate = sampleRate; + emit sampleRateChanged(m_sampleRate); +} + void GLScope::setAmp(Real amp) { m_amp = amp; @@ -114,7 +119,7 @@ void GLScope::newTrace(const std::vector& trace, int sampleRate) m_rawTrace = trace; - m_sampleRate = sampleRate; + m_sampleRate = sampleRate; // sampleRate comes from scopeVis m_dataChanged = true; m_mutex.unlock(); @@ -523,7 +528,7 @@ void GLScope::applyConfig() m_powerScale.setSize(scopeHeight); m_powerScale.setRange(Unit::Decibel, pow_floor, pow_floor + pow_range); - std::cerr << "Vertical: " << width() << "x" << scopeHeight << " amp:" << m_amp << std::endl; + //std::cerr << "Vertical: " << width() << "x" << scopeHeight << " amp:" << m_amp << std::endl; m_left1ScalePixmap = QPixmap( leftMargin - 1, @@ -541,7 +546,7 @@ void GLScope::applyConfig() tick = &(*tickList)[i]; if(tick->major) { if(tick->textSize > 0) { - std::cerr << (tick->text).toStdString() << " @ " << tick->textPos << std::endl; + //std::cerr << (tick->text).toStdString() << " @ " << tick->textPos << std::endl; painter.drawText(QPointF(leftMargin - M - tick->textSize, topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); } } @@ -582,7 +587,7 @@ void GLScope::applyConfig() (float) scopeHeight / (float) height() ); { // Scales - std::cerr << "Horizontal: " << width() << "x" << scopeHeight << " amp:" << m_amp << std::endl; + //std::cerr << "Horizontal: " << width() << "x" << scopeHeight << " amp:" << m_amp << std::endl; float pow_floor = -100.0 + m_ofs * 100.0; float pow_range = 100.0 / m_amp; @@ -607,7 +612,7 @@ void GLScope::applyConfig() tick = &(*tickList)[i]; if(tick->major) { if(tick->textSize > 0) { - std::cerr << (tick->text).toStdString() << " @ " << tick->textPos << std::endl; + //std::cerr << (tick->text).toStdString() << " @ " << tick->textPos << std::endl; painter.drawText(QPointF(leftMargin - M - tick->textSize, topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); } } diff --git a/sdrbase/gui/glscopegui.cpp b/sdrbase/gui/glscopegui.cpp index a67a91e29..188522c64 100644 --- a/sdrbase/gui/glscopegui.cpp +++ b/sdrbase/gui/glscopegui.cpp @@ -33,17 +33,18 @@ GLScopeGUI::~GLScopeGUI() void GLScopeGUI::setBuddies(MessageQueue* messageQueue, ScopeVis* scopeVis, GLScope* glScope) { - std::cerr << "GLScopeGUI::setBuddies: scopeVis @" << scopeVis << std::endl; m_messageQueue = messageQueue; m_scopeVis = scopeVis; m_glScope = glScope; + connect(m_glScope, SIGNAL(traceSizeChanged(int)), this, SLOT(on_scope_traceSizeChanged(int))); + connect(m_glScope, SIGNAL(sampleRateChanged(int)), this, SLOT(on_scope_sampleRateChanged(int))); applySettings(); } void GLScopeGUI::setSampleRate(int sampleRate) { m_sampleRate = sampleRate; - on_scope_traceSizeChanged(0); + setTimeScaleDisplay(); } void GLScopeGUI::resetToDefaults() @@ -134,9 +135,25 @@ void GLScopeGUI::on_ampOfs_valueChanged(int value) void GLScopeGUI::on_scope_traceSizeChanged(int) { - std::cerr << "GLScopeGUI::on_scope_traceSizeChanged: sample rate: " << m_glScope->getSampleRate() << std::endl; + setTimeScaleDisplay(); +} + +void GLScopeGUI::on_scope_sampleRateChanged(int) +{ + setTimeScaleDisplay(); +} + +void GLScopeGUI::setTimeScaleDisplay() +{ m_sampleRate = m_glScope->getSampleRate(); qreal t = (m_glScope->getTraceSize() * 0.1 / m_sampleRate) / (qreal)m_timeBase; + /* + std::cerr << "GLScopeGUI::setTimeScaleDisplay: sample rate: " + << m_glScope->getSampleRate() + << " traceSize: " << m_glScope->getTraceSize() + << " timeBase: " << m_timeBase + << " glScope @" << m_glScope << std::endl; + */ if(t < 0.000001) ui->timeText->setText(tr("%1\nns/div").arg(t * 1000000000.0)); else if(t < 0.001) @@ -149,7 +166,7 @@ void GLScopeGUI::on_scope_traceSizeChanged(int) void GLScopeGUI::on_time_valueChanged(int value) { m_timeBase = value; - on_scope_traceSizeChanged(0); + setTimeScaleDisplay(); m_glScope->setTimeBase(m_timeBase); }