mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-04-10 13:40:37 -04:00
OpenGL modernization: draw frequency scale overlays the new way
This commit is contained in:
parent
a3627dffd9
commit
c844a79a7a
@ -73,6 +73,7 @@ private:
|
||||
QRectF m_glRectDsb;
|
||||
QMatrix4x4 m_glMatrixWaterfall;
|
||||
QMatrix4x4 m_glMatrixDsbWaterfall;
|
||||
QMatrix4x4 m_glMatrixFreqScale;
|
||||
QRect m_rect;
|
||||
|
||||
ChannelMarkerState(ChannelMarker* channelMarker) :
|
||||
|
@ -661,24 +661,6 @@ void GLSpectrum::paintGL()
|
||||
|
||||
QVector4D color(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.3f);
|
||||
m_glShaderSimple.drawSurface(dv->m_glMatrixWaterfall, color, q3, 4);
|
||||
|
||||
// glPushMatrix();
|
||||
// glTranslatef(m_glWaterfallRect.x(), m_glWaterfallRect.y(), 0);
|
||||
// glScalef(m_glWaterfallRect.width(), m_glWaterfallRect.height(), 1);
|
||||
// glPushMatrix();
|
||||
// glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0);
|
||||
// glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1);
|
||||
// glEnable(GL_BLEND);
|
||||
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
// glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.3f);
|
||||
//
|
||||
// glEnableClientState(GL_VERTEX_ARRAY);
|
||||
// glVertexPointer(2, GL_FLOAT, 0, q3);
|
||||
// glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
// glDisableClientState(GL_VERTEX_ARRAY);
|
||||
// glDisable(GL_BLEND);
|
||||
// glPopMatrix();
|
||||
// glPopMatrix();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1051,29 +1033,34 @@ void GLSpectrum::paintGL()
|
||||
glPopMatrix();
|
||||
|
||||
// paint channels
|
||||
glPushMatrix();
|
||||
glTranslatef(m_glWaterfallRect.x(), m_glFrequencyScaleRect.y(), 0);
|
||||
glScalef(m_glWaterfallRect.width(), m_glFrequencyScaleRect.height(), 1);
|
||||
|
||||
// Effective bandwidth overlays
|
||||
for(int i = 0; i < m_channelMarkerStates.size(); ++i)
|
||||
{
|
||||
ChannelMarkerState* dv = m_channelMarkerStates[i];
|
||||
|
||||
// frequency scale channel overlay
|
||||
if(dv->m_channelMarker->getVisible())
|
||||
{
|
||||
#ifdef GL_DEPRECATED
|
||||
glPushMatrix();
|
||||
glTranslatef(m_glWaterfallRect.x(), m_glFrequencyScaleRect.y(), 0);
|
||||
glScalef(m_glWaterfallRect.width(), m_glFrequencyScaleRect.height(), 1);
|
||||
glPushMatrix();
|
||||
glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0);
|
||||
glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.5f);
|
||||
#ifdef GL_DEPRECATED
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(0, 0);
|
||||
glVertex2f(1, 0);
|
||||
glVertex2f(1, 0.5);
|
||||
glVertex2f(0, 0.5);
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
#else
|
||||
{
|
||||
GLfloat q3[] {
|
||||
@ -1082,21 +1069,11 @@ void GLSpectrum::paintGL()
|
||||
1, 0.5,
|
||||
0, 0.5
|
||||
};
|
||||
#ifdef GL_ANDROID
|
||||
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
|
||||
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
|
||||
#else
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, 0, q3);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
#endif
|
||||
|
||||
QVector4D color(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.5f);
|
||||
m_glShaderSimple.drawSurface(dv->m_glMatrixFreqScale, color, q3, 4);
|
||||
}
|
||||
#endif
|
||||
glDisable(GL_BLEND);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1108,40 +1085,34 @@ void GLSpectrum::paintGL()
|
||||
{
|
||||
if (dv->m_channelMarker->getHighlighted())
|
||||
{
|
||||
#ifdef GL_DEPRECATED
|
||||
glPushMatrix();
|
||||
glTranslatef(m_glWaterfallRect.x(), m_glFrequencyScaleRect.y(), 0);
|
||||
glScalef(m_glWaterfallRect.width(), m_glFrequencyScaleRect.height(), 1);
|
||||
glPushMatrix();
|
||||
glTranslatef(dv->m_glRectDsb.x(), dv->m_glRectDsb.y(), 0);
|
||||
glScalef(dv->m_glRectDsb.width(), dv->m_glRectDsb.height(), 1);
|
||||
glColor3f(0.8f, 0.8f, 0.6f);
|
||||
#ifdef GL_DEPRECATED
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2f(0.5, 0);
|
||||
glVertex2f(0.5, 1);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
#else
|
||||
{
|
||||
GLfloat q3[] {
|
||||
0.5, 0,
|
||||
0.5, 1
|
||||
};
|
||||
#ifdef GL_ANDROID
|
||||
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
|
||||
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
|
||||
glDrawArrays(GL_LINES, 0, 2);
|
||||
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
|
||||
#else
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, 0, q3);
|
||||
glDrawArrays(GL_LINES, 0, 2);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
#endif
|
||||
|
||||
QVector4D color(0.8f, 0.8f, 0.6f, 1.0f);
|
||||
m_glShaderSimple.drawSegments(dv->m_glMatrixFreqScale, color, q3, 2);
|
||||
}
|
||||
#endif
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
// paint max hold lines on top of histogram
|
||||
@ -1886,7 +1857,7 @@ void GLSpectrum::applyChanges()
|
||||
QMatrix4x4 glMatrixDsb;
|
||||
glMatrixDsb.setToIdentity();
|
||||
glMatrixDsb.translate(
|
||||
-1.0f + 2.0f * ((leftMargin + m_frequencyScale.getPosFromValue(xc - (dsbw/2)) / (float) width())),
|
||||
-1.0f + 2.0f * ((leftMargin + m_frequencyScale.getPosFromValue(xc - (dsbw/2))) / (float) width()),
|
||||
1.0f
|
||||
);
|
||||
glMatrixDsb.scale(
|
||||
@ -1925,6 +1896,17 @@ void GLSpectrum::applyChanges()
|
||||
(float) waterfallHeight / (float) height()
|
||||
);
|
||||
|
||||
dv->m_glMatrixFreqScale = glMatrix;
|
||||
dv->m_glMatrixFreqScale.translate(
|
||||
0.0f,
|
||||
(float) frequencyScaleTop / (float) height()
|
||||
);
|
||||
dv->m_glMatrixFreqScale.scale(
|
||||
(float) (width() - leftMargin - rightMargin) / (float) width(),
|
||||
(float) frequencyScaleHeight / (float) height()
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
dv->m_glRect.setRect(
|
||||
m_frequencyScale.getPosFromValue(m_centerFrequency + dv->m_channelMarker->getCenterFrequency() - dv->m_channelMarker->getBandwidth() / 2) / (float)(width() - leftMargin - rightMargin),
|
||||
|
Loading…
Reference in New Issue
Block a user