1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 13:51:47 -05:00

Align scope grid on ticks

This commit is contained in:
f4exb 2015-07-14 10:39:41 +02:00
parent 461da9142d
commit e0699d9711
2 changed files with 83 additions and 10 deletions

View File

@ -22,6 +22,10 @@ GLScope::GLScope(QWidget* parent) :
m_displayTrace(&m_rawTrace), m_displayTrace(&m_rawTrace),
m_oldTraceSize(-1), m_oldTraceSize(-1),
m_sampleRate(0), m_sampleRate(0),
m_amp1(1.0),
m_amp2(1.0),
m_ofs1(0.0),
m_ofs2(0.0),
m_dspEngine(NULL), m_dspEngine(NULL),
m_scopeVis(NULL), m_scopeVis(NULL),
m_amp(1.0), m_amp(1.0),
@ -29,7 +33,12 @@ GLScope::GLScope(QWidget* parent) :
m_timeBase(1), m_timeBase(1),
m_timeOfsProMill(0), m_timeOfsProMill(0),
m_triggerChannel(ScopeVis::TriggerFreeRun), 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); setAttribute(Qt::WA_OpaquePaintEvent);
connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick())); connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
@ -199,22 +208,54 @@ void GLScope::paintGL()
glDisable(GL_BLEND); glDisable(GL_BLEND);
// paint grid // paint grid
const ScaleEngine::TickList* tickList;
const ScaleEngine::Tick* tick;
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glLineWidth(1.0f); glLineWidth(1.0f);
glColor4f(1, 1, 1, m_displayGridIntensity / 100.0); 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++) { for(int i = 1; i < 10; i++) {
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
glVertex2f(0, i * 0.1); glVertex2f(0, i * 0.1);
glVertex2f(1, i * 0.1); glVertex2f(1, i * 0.1);
glEnd(); 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++) { for(int i = 1; i < 10; i++) {
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
glVertex2f(i * 0.1, 0); glVertex2f(i * 0.1, 0);
glVertex2f(i * 0.1, 1); glVertex2f(i * 0.1, 1);
glEnd(); glEnd();
} }*/
glPopMatrix(); glPopMatrix();
// paint left #1 scale // paint left #1 scale
@ -338,22 +379,54 @@ void GLScope::paintGL()
glDisable(GL_BLEND); glDisable(GL_BLEND);
// paint grid // paint grid
const ScaleEngine::TickList* tickList;
const ScaleEngine::Tick* tick;
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glLineWidth(1.0f); glLineWidth(1.0f);
glColor4f(1, 1, 1, m_displayGridIntensity / 100.0); 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++) { for(int i = 1; i < 10; i++) {
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
glVertex2f(0, i * 0.1); glVertex2f(0, i * 0.1);
glVertex2f(1, i * 0.1); glVertex2f(1, i * 0.1);
glEnd(); 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++) { for(int i = 1; i < 10; i++) {
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
glVertex2f(i * 0.1, 0); glVertex2f(i * 0.1, 0);
glVertex2f(i * 0.1, 1); glVertex2f(i * 0.1, 1);
glEnd(); glEnd();
} }*/
glPopMatrix(); glPopMatrix();
// paint left #2 scale // paint left #2 scale

View File

@ -196,9 +196,9 @@ void GLScopeGUI::setTrigLevelDisplay()
void GLScopeGUI::setAmpScaleDisplay() void GLScopeGUI::setAmpScaleDisplay()
{ {
if (m_glScope->getDataMode() == GLScope::ModeMagdBPha) { 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 { } 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() void GLScopeGUI::setTimeScaleDisplay()
{ {
m_sampleRate = m_glScope->getSampleRate(); 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: " std::cerr << "GLScopeGUI::setTimeScaleDisplay: sample rate: "
<< m_glScope->getSampleRate() << m_glScope->getSampleRate()
@ -251,12 +251,12 @@ void GLScopeGUI::setTimeScaleDisplay()
<< " glScope @" << m_glScope << std::endl; << " glScope @" << m_glScope << std::endl;
*/ */
if(t < 0.000001) 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) 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) else if(t < 1.0)
ui->timeText->setText(tr("%1\nms/div").arg(t * 1000.0)); ui->timeText->setText(tr("%1\nms").arg(t * 1000.0));
else ui->timeText->setText(tr("%1\ns/div").arg(t * 1.0)); else ui->timeText->setText(tr("%1\ns").arg(t * 1.0));
} }
void GLScopeGUI::setTimeOfsDisplay() void GLScopeGUI::setTimeOfsDisplay()