From e0699d97115c4f283eabeb6bbbf99498bd306e1c Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 14 Jul 2015 10:39:41 +0200 Subject: [PATCH] Align scope grid on ticks --- sdrbase/gui/glscope.cpp | 79 ++++++++++++++++++++++++++++++++++++-- sdrbase/gui/glscopegui.cpp | 14 +++---- 2 files changed, 83 insertions(+), 10 deletions(-) diff --git a/sdrbase/gui/glscope.cpp b/sdrbase/gui/glscope.cpp index f416604d1..c75aba7aa 100644 --- a/sdrbase/gui/glscope.cpp +++ b/sdrbase/gui/glscope.cpp @@ -22,6 +22,10 @@ GLScope::GLScope(QWidget* parent) : m_displayTrace(&m_rawTrace), m_oldTraceSize(-1), m_sampleRate(0), + m_amp1(1.0), + m_amp2(1.0), + m_ofs1(0.0), + m_ofs2(0.0), m_dspEngine(NULL), m_scopeVis(NULL), m_amp(1.0), @@ -29,7 +33,12 @@ GLScope::GLScope(QWidget* parent) : m_timeBase(1), m_timeOfsProMill(0), m_triggerChannel(ScopeVis::TriggerFreeRun), - m_displayGridIntensity(5) + m_triggerLevel(0.0), + m_displayGridIntensity(5), + m_left1ScaleTextureAllocated(false), + m_left2ScaleTextureAllocated(false), + m_bot1ScaleTextureAllocated(false), + m_bot2ScaleTextureAllocated(false) { setAttribute(Qt::WA_OpaquePaintEvent); connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick())); @@ -199,22 +208,54 @@ void GLScope::paintGL() glDisable(GL_BLEND); // paint grid + const ScaleEngine::TickList* tickList; + const ScaleEngine::Tick* tick; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLineWidth(1.0f); glColor4f(1, 1, 1, m_displayGridIntensity / 100.0); + // Horizontal Y1 + tickList = &m_y1Scale.getTickList(); + for(int i= 0; i < tickList->count(); i++) { + tick = &(*tickList)[i]; + if(tick->major) { + if(tick->textSize > 0) { + float y = tick->pos / m_y1Scale.getSize(); + glBegin(GL_LINE_LOOP); + glVertex2f(0, y); + glVertex2f(1, y); + glEnd(); + } + } + } + /* for(int i = 1; i < 10; i++) { glBegin(GL_LINE_LOOP); glVertex2f(0, i * 0.1); glVertex2f(1, i * 0.1); glEnd(); + }*/ + // Vertical X1 + tickList = &m_x1Scale.getTickList(); + for(int i= 0; i < tickList->count(); i++) { + tick = &(*tickList)[i]; + if(tick->major) { + if(tick->textSize > 0) { + float x = tick->pos / m_x1Scale.getSize(); + glBegin(GL_LINE_LOOP); + glVertex2f(x, 0); + glVertex2f(x, 1); + glEnd(); + } + } } + /* for(int i = 1; i < 10; i++) { glBegin(GL_LINE_LOOP); glVertex2f(i * 0.1, 0); glVertex2f(i * 0.1, 1); glEnd(); - } + }*/ glPopMatrix(); // paint left #1 scale @@ -338,22 +379,54 @@ void GLScope::paintGL() glDisable(GL_BLEND); // paint grid + const ScaleEngine::TickList* tickList; + const ScaleEngine::Tick* tick; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLineWidth(1.0f); glColor4f(1, 1, 1, m_displayGridIntensity / 100.0); + // Horizontal Y2 + tickList = &m_y2Scale.getTickList(); + for(int i= 0; i < tickList->count(); i++) { + tick = &(*tickList)[i]; + if(tick->major) { + if(tick->textSize > 0) { + float y = tick->pos / m_y2Scale.getSize(); + glBegin(GL_LINE_LOOP); + glVertex2f(0, y); + glVertex2f(1, y); + glEnd(); + } + } + } + /* for(int i = 1; i < 10; i++) { glBegin(GL_LINE_LOOP); glVertex2f(0, i * 0.1); glVertex2f(1, i * 0.1); glEnd(); + }*/ + // Vertical X2 + tickList = &m_x2Scale.getTickList(); + for(int i= 0; i < tickList->count(); i++) { + tick = &(*tickList)[i]; + if(tick->major) { + if(tick->textSize > 0) { + float x = tick->pos / m_x2Scale.getSize(); + glBegin(GL_LINE_LOOP); + glVertex2f(x, 0); + glVertex2f(x, 1); + glEnd(); + } + } } + /* for(int i = 1; i < 10; i++) { glBegin(GL_LINE_LOOP); glVertex2f(i * 0.1, 0); glVertex2f(i * 0.1, 1); glEnd(); - } + }*/ glPopMatrix(); // paint left #2 scale diff --git a/sdrbase/gui/glscopegui.cpp b/sdrbase/gui/glscopegui.cpp index f10354e2d..c0b0ff5c1 100644 --- a/sdrbase/gui/glscopegui.cpp +++ b/sdrbase/gui/glscopegui.cpp @@ -196,9 +196,9 @@ void GLScopeGUI::setTrigLevelDisplay() void GLScopeGUI::setAmpScaleDisplay() { if (m_glScope->getDataMode() == GLScope::ModeMagdBPha) { - ui->ampText->setText(tr("%1\ndB/div").arg(amps[m_amplification]*50.0, 0, 'f', 2)); + ui->ampText->setText(tr("%1\ndB").arg(amps[m_amplification]*500.0, 0, 'f', 1)); } else { - ui->ampText->setText(tr("%1\n/div").arg(amps[m_amplification], 0, 'f', 4)); + ui->ampText->setText(tr("%1").arg(amps[m_amplification]*10.0, 0, 'f', 3)); } } @@ -242,7 +242,7 @@ void GLScopeGUI::on_scope_sampleRateChanged(int) void GLScopeGUI::setTimeScaleDisplay() { m_sampleRate = m_glScope->getSampleRate(); - qreal t = (m_glScope->getTraceSize() * 0.1 / m_sampleRate) / (qreal)m_timeBase; + qreal t = (m_glScope->getTraceSize() * 1.0 / m_sampleRate) / (qreal)m_timeBase; /* std::cerr << "GLScopeGUI::setTimeScaleDisplay: sample rate: " << m_glScope->getSampleRate() @@ -251,12 +251,12 @@ void GLScopeGUI::setTimeScaleDisplay() << " glScope @" << m_glScope << std::endl; */ if(t < 0.000001) - ui->timeText->setText(tr("%1\nns/div").arg(t * 1000000000.0)); + ui->timeText->setText(tr("%1\nns").arg(t * 1000000000.0)); else if(t < 0.001) - ui->timeText->setText(tr("%1\nµs/div").arg(t * 1000000.0)); + ui->timeText->setText(tr("%1\nµs").arg(t * 1000000.0)); else if(t < 1.0) - ui->timeText->setText(tr("%1\nms/div").arg(t * 1000.0)); - else ui->timeText->setText(tr("%1\ns/div").arg(t * 1.0)); + ui->timeText->setText(tr("%1\nms").arg(t * 1000.0)); + else ui->timeText->setText(tr("%1\ns").arg(t * 1.0)); } void GLScopeGUI::setTimeOfsDisplay()