mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-25 09:18:54 -05:00
Fixed time scale display on scope GUI
This commit is contained in:
parent
5a8c3d8e5b
commit
8924be1a31
@ -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,
|
||||
|
@ -55,19 +55,14 @@ public:
|
||||
void setDisplayGridIntensity(int intensity);
|
||||
|
||||
void newTrace(const std::vector<Complex>& 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
|
||||
|
@ -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);
|
||||
|
@ -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<<spanLog2);
|
||||
m_rate = m_channelAnalyzer->getSampleRate() / (1<<spanLog2);
|
||||
|
||||
std::cerr << "ChannelAnalyzerGUI::setNewRate: " << m_rate << std::endl;
|
||||
|
||||
if (ui->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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<Complex>& 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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user