mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-29 13:32:26 -04:00
Time scale on scope view #1
This commit is contained in:
parent
133e072b19
commit
83b2f53ee5
@ -106,11 +106,21 @@ private:
|
|||||||
QRectF m_glBot1ScaleRect;
|
QRectF m_glBot1ScaleRect;
|
||||||
QRectF m_glBot2ScaleRect;
|
QRectF m_glBot2ScaleRect;
|
||||||
QPixmap m_left1ScalePixmap;
|
QPixmap m_left1ScalePixmap;
|
||||||
|
QPixmap m_left2ScalePixmap;
|
||||||
|
QPixmap m_bot1ScalePixmap;
|
||||||
|
QPixmap m_bot2ScalePixmap;
|
||||||
bool m_left1ScaleTextureAllocated;
|
bool m_left1ScaleTextureAllocated;
|
||||||
GLuint m_leftScaleTexture;
|
bool m_left2ScaleTextureAllocated;
|
||||||
ScaleEngine m_timeScale;
|
bool m_bot1ScaleTextureAllocated;
|
||||||
ScaleEngine m_powerScale;
|
bool m_bot2ScaleTextureAllocated;
|
||||||
ScaleEngine m_amplitudeScale;
|
GLuint m_left1ScaleTexture;
|
||||||
|
GLuint m_left2ScaleTexture;
|
||||||
|
GLuint m_bot1ScaleTexture;
|
||||||
|
GLuint m_bot2ScaleTexture;
|
||||||
|
ScaleEngine m_x1Scale;
|
||||||
|
ScaleEngine m_x2Scale;
|
||||||
|
ScaleEngine m_y1Scale;
|
||||||
|
ScaleEngine m_y2Scale;
|
||||||
|
|
||||||
void initializeGL();
|
void initializeGL();
|
||||||
void resizeGL(int width, int height);
|
void resizeGL(int width, int height);
|
||||||
|
@ -33,8 +33,14 @@ GLScope::GLScope(QWidget* parent) :
|
|||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
|
connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
|
||||||
m_timer.start(50);
|
m_timer.start(50);
|
||||||
m_powerScale.setFont(font());
|
m_y1Scale.setFont(font());
|
||||||
m_powerScale.setOrientation(Qt::Vertical);
|
m_y1Scale.setOrientation(Qt::Vertical);
|
||||||
|
m_y2Scale.setFont(font());
|
||||||
|
m_y2Scale.setOrientation(Qt::Vertical);
|
||||||
|
m_x1Scale.setFont(font());
|
||||||
|
m_x1Scale.setOrientation(Qt::Horizontal);
|
||||||
|
m_x2Scale.setFont(font());
|
||||||
|
m_x2Scale.setOrientation(Qt::Horizontal);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLScope::~GLScope()
|
GLScope::~GLScope()
|
||||||
@ -76,12 +82,14 @@ void GLScope::setAmpOfs(Real ampOfs)
|
|||||||
void GLScope::setTimeBase(int timeBase)
|
void GLScope::setTimeBase(int timeBase)
|
||||||
{
|
{
|
||||||
m_timeBase = timeBase;
|
m_timeBase = timeBase;
|
||||||
|
m_configChanged = true;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLScope::setTimeOfsProMill(int timeOfsProMill)
|
void GLScope::setTimeOfsProMill(int timeOfsProMill)
|
||||||
{
|
{
|
||||||
m_timeOfsProMill = timeOfsProMill;
|
m_timeOfsProMill = timeOfsProMill;
|
||||||
|
m_configChanged = true;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,17 +203,38 @@ void GLScope::paintGL()
|
|||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
// paint left scale
|
// paint left #1 scale
|
||||||
glBindTexture(GL_TEXTURE_2D, m_leftScaleTexture);
|
glBindTexture(GL_TEXTURE_2D, m_left1ScaleTexture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(m_glLeft1ScaleRect.x(), m_glLeft1ScaleRect.y(), 0);
|
glTranslatef(m_glLeft1ScaleRect.x(), m_glLeft1ScaleRect.y(), 0);
|
||||||
glScalef(m_glLeft1ScaleRect.width(), m_glLeft1ScaleRect.height(), 1);
|
glScalef(m_glLeft1ScaleRect.width(), m_glLeft1ScaleRect.height(), 1);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(0, 1);
|
||||||
|
glVertex2f(0, 1);
|
||||||
|
glTexCoord2f(1, 1);
|
||||||
|
glVertex2f(1, 1);
|
||||||
|
glTexCoord2f(1, 0);
|
||||||
|
glVertex2f(1, 0);
|
||||||
|
glTexCoord2f(0, 0);
|
||||||
|
glVertex2f(0, 0);
|
||||||
|
glEnd();
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
// paint bottom #1 scale
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_bot1ScaleTexture);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(m_glBot1ScaleRect.x(), m_glBot1ScaleRect.y(), 0);
|
||||||
|
glScalef(m_glBot1ScaleRect.width(), m_glBot1ScaleRect.height(), 1);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
@ -504,44 +533,52 @@ void GLScope::applyConfig()
|
|||||||
int leftMargin = 35;
|
int leftMargin = 35;
|
||||||
int rightMargin = 5;
|
int rightMargin = 5;
|
||||||
|
|
||||||
|
float pow_floor = -100.0 + m_ofs * 100.0;
|
||||||
|
float pow_range = 100.0 / m_amp;
|
||||||
|
float amp_range = 2.0 / m_amp;
|
||||||
|
float t_start = (m_timeOfsProMill / 1000.0) * ((float) m_displayTrace->size() / m_sampleRate);
|
||||||
|
float t_len = ((float) m_displayTrace->size() / m_sampleRate) / (float) m_timeBase;
|
||||||
|
|
||||||
// QRectF(x, y, w, h); (x, y) = top left corner
|
// QRectF(x, y, w, h); (x, y) = top left corner
|
||||||
|
|
||||||
if(m_orientation == Qt::Vertical) {
|
if(m_orientation == Qt::Vertical) {
|
||||||
int scopeHeight = (height() - botMargin - botMargin - topMargin) / 2;
|
int scopeHeight = (height() - botMargin - botMargin - topMargin) / 2;
|
||||||
|
int scopeWidth = width() - leftMargin - rightMargin;
|
||||||
m_glScopeRect1 = QRectF(
|
m_glScopeRect1 = QRectF(
|
||||||
(float)leftMargin / (float)width(),
|
(float) leftMargin / (float) width(),
|
||||||
(float)topMargin / (float)height(),
|
(float) topMargin / (float) height(),
|
||||||
(float)(width() - leftMargin - rightMargin) / (float)width(),
|
(float) scopeWidth / (float) width(),
|
||||||
(float) scopeHeight / (float) height()
|
(float) scopeHeight / (float) height()
|
||||||
);
|
);
|
||||||
m_glLeft1ScaleRect = QRectF(
|
m_glLeft1ScaleRect = QRectF(
|
||||||
0,
|
0,
|
||||||
(float)topMargin / (float)height(),
|
(float) topMargin / (float) height(),
|
||||||
(float)(leftMargin-1) / (float)width(),
|
(float) (leftMargin-1) / (float) width(),
|
||||||
(float) scopeHeight / (float) height()
|
(float) scopeHeight / (float) height()
|
||||||
);
|
);
|
||||||
{ // Scales
|
m_glBot1ScaleRect = QRectF(
|
||||||
float pow_floor = -100.0 + m_ofs * 100.0;
|
(float) leftMargin / (float) width(),
|
||||||
float pow_range = 100.0 / m_amp;
|
(float) (scopeHeight + topMargin + 1) / (float) height(),
|
||||||
float amp_range = 2.0 / m_amp;
|
(float) scopeWidth/ (float) width(),
|
||||||
|
(float) (botMargin - 1) / (float) height()
|
||||||
m_powerScale.setSize(scopeHeight);
|
);
|
||||||
m_powerScale.setRange(Unit::Decibel, pow_floor, pow_floor + pow_range);
|
{ // Y1 scale
|
||||||
|
m_y1Scale.setSize(scopeHeight);
|
||||||
//std::cerr << "Vertical: " << width() << "x" << scopeHeight << " amp:" << m_amp << std::endl;
|
m_y1Scale.setRange(Unit::Decibel, pow_floor, pow_floor + pow_range);
|
||||||
|
|
||||||
m_left1ScalePixmap = QPixmap(
|
m_left1ScalePixmap = QPixmap(
|
||||||
leftMargin - 1,
|
leftMargin - 1,
|
||||||
scopeHeight
|
scopeHeight
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const ScaleEngine::TickList* tickList;
|
||||||
|
const ScaleEngine::Tick* tick;
|
||||||
|
|
||||||
m_left1ScalePixmap.fill(Qt::black);
|
m_left1ScalePixmap.fill(Qt::black);
|
||||||
QPainter painter(&m_left1ScalePixmap);
|
QPainter painter(&m_left1ScalePixmap);
|
||||||
painter.setPen(QColor(0xf0, 0xf0, 0xff));
|
painter.setPen(QColor(0xf0, 0xf0, 0xff));
|
||||||
painter.setFont(font());
|
painter.setFont(font());
|
||||||
const ScaleEngine::TickList* tickList;
|
tickList = &m_y1Scale.getTickList();
|
||||||
const ScaleEngine::Tick* tick;
|
|
||||||
tickList = &m_powerScale.getTickList();
|
|
||||||
|
|
||||||
for(int i = 0; i < tickList->count(); i++) {
|
for(int i = 0; i < tickList->count(); i++) {
|
||||||
tick = &(*tickList)[i];
|
tick = &(*tickList)[i];
|
||||||
@ -553,17 +590,51 @@ void GLScope::applyConfig()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//painter.drawText(QPointF(2, 2), "0");
|
|
||||||
|
|
||||||
if (m_left1ScaleTextureAllocated)
|
if (m_left1ScaleTextureAllocated)
|
||||||
deleteTexture(m_left1ScaleTextureAllocated);
|
deleteTexture(m_left1ScaleTexture);
|
||||||
m_leftScaleTexture = bindTexture(m_left1ScalePixmap,
|
m_left1ScaleTexture = bindTexture(m_left1ScalePixmap,
|
||||||
GL_TEXTURE_2D,
|
GL_TEXTURE_2D,
|
||||||
GL_RGBA,
|
GL_RGBA,
|
||||||
QGLContext::LinearFilteringBindOption |
|
QGLContext::LinearFilteringBindOption |
|
||||||
QGLContext::MipmapBindOption);
|
QGLContext::MipmapBindOption);
|
||||||
m_left1ScaleTextureAllocated = true;
|
m_left1ScaleTextureAllocated = true;
|
||||||
}
|
} // Y1 scale
|
||||||
|
{ // X1 scale
|
||||||
|
m_x1Scale.setSize(scopeWidth);
|
||||||
|
m_x1Scale.setRange(Unit::Time, t_start, t_start + t_len);
|
||||||
|
|
||||||
|
m_bot1ScalePixmap = QPixmap(
|
||||||
|
scopeWidth,
|
||||||
|
botMargin - 1
|
||||||
|
);
|
||||||
|
|
||||||
|
const ScaleEngine::TickList* tickList;
|
||||||
|
const ScaleEngine::Tick* tick;
|
||||||
|
|
||||||
|
m_bot1ScalePixmap.fill(Qt::black);
|
||||||
|
QPainter painter(&m_bot1ScalePixmap);
|
||||||
|
painter.setPen(QColor(0xf0, 0xf0, 0xff));
|
||||||
|
painter.setFont(font());
|
||||||
|
tickList = &m_x1Scale.getTickList();
|
||||||
|
|
||||||
|
for(int i = 0; i < tickList->count(); i++) {
|
||||||
|
tick = &(*tickList)[i];
|
||||||
|
if(tick->major) {
|
||||||
|
if(tick->textSize > 0) {
|
||||||
|
painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_bot1ScaleTextureAllocated)
|
||||||
|
deleteTexture(m_bot1ScaleTexture);
|
||||||
|
m_bot1ScaleTexture = bindTexture(m_bot1ScalePixmap,
|
||||||
|
GL_TEXTURE_2D,
|
||||||
|
GL_RGBA,
|
||||||
|
QGLContext::LinearFilteringBindOption |
|
||||||
|
QGLContext::MipmapBindOption);
|
||||||
|
m_bot1ScaleTextureAllocated = true;
|
||||||
|
} // X1 scale
|
||||||
|
|
||||||
m_glScopeRect2 = QRectF(
|
m_glScopeRect2 = QRectF(
|
||||||
(float)leftMargin / (float)width(),
|
(float)leftMargin / (float)width(),
|
||||||
@ -575,40 +646,44 @@ void GLScope::applyConfig()
|
|||||||
else // Horizontal
|
else // Horizontal
|
||||||
{
|
{
|
||||||
int scopeHeight = height() - topMargin - botMargin;
|
int scopeHeight = height() - topMargin - botMargin;
|
||||||
|
int scopeWidth = (width() - rightMargin)/2 - leftMargin;
|
||||||
m_glScopeRect1 = QRectF(
|
m_glScopeRect1 = QRectF(
|
||||||
(float)leftMargin / (float)width(),
|
(float) leftMargin / (float) width(),
|
||||||
(float)topMargin / (float)height(),
|
(float) topMargin / (float) height(),
|
||||||
(float)((width() - leftMargin - leftMargin - rightMargin) / 2) / (float)width(),
|
(float) scopeWidth / (float) width(),
|
||||||
(float) scopeHeight / (float) height()
|
(float) scopeHeight / (float) height()
|
||||||
);
|
);
|
||||||
m_glLeft1ScaleRect = QRectF(
|
m_glLeft1ScaleRect = QRectF(
|
||||||
0,
|
0,
|
||||||
(float)topMargin / (float)height(),
|
(float) topMargin / (float) height(),
|
||||||
(float)(leftMargin-1) / (float)width(),
|
(float) (leftMargin-1) / (float) width(),
|
||||||
(float) scopeHeight / (float) height()
|
(float) scopeHeight / (float) height()
|
||||||
);
|
);
|
||||||
{ // Scales
|
m_glBot1ScaleRect = QRectF(
|
||||||
|
(float) leftMargin / (float) width(),
|
||||||
|
(float) (scopeHeight + topMargin + 1) / (float) height(),
|
||||||
|
(float) scopeWidth / (float) width(),
|
||||||
|
(float) (botMargin - 1) / (float) height()
|
||||||
|
);
|
||||||
|
{ // Y1 scale
|
||||||
//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;
|
m_y1Scale.setSize(scopeHeight);
|
||||||
float pow_range = 100.0 / m_amp;
|
m_y1Scale.setRange(Unit::Decibel, pow_floor, pow_floor + pow_range);
|
||||||
float amp_range = 2.0 / m_amp;
|
|
||||||
|
|
||||||
m_powerScale.setSize(scopeHeight);
|
|
||||||
m_powerScale.setRange(Unit::Decibel, pow_floor, pow_floor + pow_range);
|
|
||||||
|
|
||||||
m_left1ScalePixmap = QPixmap(
|
m_left1ScalePixmap = QPixmap(
|
||||||
leftMargin - 1,
|
leftMargin - 1,
|
||||||
scopeHeight
|
scopeHeight
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const ScaleEngine::TickList* tickList;
|
||||||
|
const ScaleEngine::Tick* tick;
|
||||||
|
|
||||||
m_left1ScalePixmap.fill(Qt::black);
|
m_left1ScalePixmap.fill(Qt::black);
|
||||||
QPainter painter(&m_left1ScalePixmap);
|
QPainter painter(&m_left1ScalePixmap);
|
||||||
painter.setPen(QColor(0xf0, 0xf0, 0xff));
|
painter.setPen(QColor(0xf0, 0xf0, 0xff));
|
||||||
painter.setFont(font());
|
painter.setFont(font());
|
||||||
const ScaleEngine::TickList* tickList;
|
tickList = &m_y1Scale.getTickList();
|
||||||
const ScaleEngine::Tick* tick;
|
|
||||||
tickList = &m_powerScale.getTickList();
|
|
||||||
|
|
||||||
for(int i = 0; i < tickList->count(); i++) {
|
for(int i = 0; i < tickList->count(); i++) {
|
||||||
tick = &(*tickList)[i];
|
tick = &(*tickList)[i];
|
||||||
@ -620,17 +695,51 @@ void GLScope::applyConfig()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//painter.drawText(QPointF(2, 2), "0");
|
|
||||||
|
|
||||||
if (m_left1ScaleTextureAllocated)
|
if (m_left1ScaleTextureAllocated)
|
||||||
deleteTexture(m_left1ScaleTextureAllocated);
|
deleteTexture(m_left1ScaleTextureAllocated);
|
||||||
m_leftScaleTexture = bindTexture(m_left1ScalePixmap,
|
m_left1ScaleTexture = bindTexture(m_left1ScalePixmap,
|
||||||
GL_TEXTURE_2D,
|
GL_TEXTURE_2D,
|
||||||
GL_RGBA,
|
GL_RGBA,
|
||||||
QGLContext::LinearFilteringBindOption |
|
QGLContext::LinearFilteringBindOption |
|
||||||
QGLContext::MipmapBindOption);
|
QGLContext::MipmapBindOption);
|
||||||
m_left1ScaleTextureAllocated = true;
|
m_left1ScaleTextureAllocated = true;
|
||||||
}
|
} // Y1 scale
|
||||||
|
{ // X1 scale
|
||||||
|
m_x1Scale.setSize(scopeWidth);
|
||||||
|
m_x1Scale.setRange(Unit::Time, t_start, t_start + t_len);
|
||||||
|
|
||||||
|
m_bot1ScalePixmap = QPixmap(
|
||||||
|
scopeWidth,
|
||||||
|
botMargin - 1
|
||||||
|
);
|
||||||
|
|
||||||
|
const ScaleEngine::TickList* tickList;
|
||||||
|
const ScaleEngine::Tick* tick;
|
||||||
|
|
||||||
|
m_bot1ScalePixmap.fill(Qt::black);
|
||||||
|
QPainter painter(&m_bot1ScalePixmap);
|
||||||
|
painter.setPen(QColor(0xf0, 0xf0, 0xff));
|
||||||
|
painter.setFont(font());
|
||||||
|
tickList = &m_x1Scale.getTickList();
|
||||||
|
|
||||||
|
for(int i = 0; i < tickList->count(); i++) {
|
||||||
|
tick = &(*tickList)[i];
|
||||||
|
if(tick->major) {
|
||||||
|
if(tick->textSize > 0) {
|
||||||
|
painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_bot1ScaleTextureAllocated)
|
||||||
|
deleteTexture(m_bot1ScaleTexture);
|
||||||
|
m_bot1ScaleTexture = bindTexture(m_bot1ScalePixmap,
|
||||||
|
GL_TEXTURE_2D,
|
||||||
|
GL_RGBA,
|
||||||
|
QGLContext::LinearFilteringBindOption |
|
||||||
|
QGLContext::MipmapBindOption);
|
||||||
|
m_bot1ScaleTextureAllocated = true;
|
||||||
|
} // X1 scale
|
||||||
|
|
||||||
m_glScopeRect2 = QRectF(
|
m_glScopeRect2 = QRectF(
|
||||||
(float)(leftMargin + leftMargin + ((width() - leftMargin - leftMargin - rightMargin) / 2)) / (float)width(),
|
(float)(leftMargin + leftMargin + ((width() - leftMargin - leftMargin - rightMargin) / 2)) / (float)width(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user