1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-17 23:28:50 -05:00

OpenGL modernization: GLSpectrum moved back to QGLWidget

This commit is contained in:
f4exb 2016-03-05 21:54:24 +01:00
parent 2b5fca79a6
commit 1126508b27
4 changed files with 391 additions and 11 deletions

View File

@ -23,6 +23,7 @@
#include <QTimer>
#include <QMutex>
#include <QFont>
#include <QMatrix4x4>
#include "dsp/dsptypes.h"
#include "dsp/scopevis.h"
#include "gui/scaleengine.h"
@ -137,32 +138,47 @@ private:
// graphics stuff
QRectF m_glScopeRect1;
QRectF m_glScopeRect2;
QMatrix4x4 m_glScopeMatrix1;
QMatrix4x4 m_glScopeMatrix2;
int m_displayGridIntensity;
int m_displayTraceIntensity;
QRectF m_glLeft1ScaleRect;
QRectF m_glRight1ScaleRect;
QRectF m_glLeft2ScaleRect;
QRectF m_glBot1ScaleRect;
QRectF m_glBot2ScaleRect;
QMatrix4x4 m_glLeft1ScaleMatrix;
QMatrix4x4 m_glRight1ScaleMatrix;
QMatrix4x4 m_glLeft2ScaleMatrix;
QMatrix4x4 m_glBot1ScaleMatrix;
QMatrix4x4 m_glBot2ScaleMatrix;
QPixmap m_left1ScalePixmap;
QPixmap m_left2ScalePixmap;
QPixmap m_bot1ScalePixmap;
QPixmap m_bot2ScalePixmap;
QPixmap m_powerOverlayPixmap1;
bool m_left1ScaleTextureAllocated;
bool m_left2ScaleTextureAllocated;
bool m_bot1ScaleTextureAllocated;
bool m_bot2ScaleTextureAllocated;
bool m_powerOverlayTextureAllocated1;
GLuint m_left1ScaleTexture;
GLuint m_left2ScaleTexture;
GLuint m_bot1ScaleTexture;
GLuint m_bot2ScaleTexture;
GLuint m_powerOverlayTexture1;
ScaleEngine m_x1Scale;
ScaleEngine m_x2Scale;
ScaleEngine m_y1Scale;
ScaleEngine m_y2Scale;
QFont m_powerOverlayFont;
void initializeGL();

View File

@ -27,6 +27,7 @@
#include <QOpenGLBuffer>
#include <QOpenGLVertexArrayObject>
#include <QMatrix4x4>
#include <QGLWidget>
#include "dsp/dsptypes.h"
#include "gui/scaleengine.h"
#include "gui/glshadersimple.h"
@ -36,7 +37,7 @@
class QOpenGLShaderProgram;
class SDRANGEL_API GLSpectrum : public QOpenGLWidget {
class SDRANGEL_API GLSpectrum : public QGLWidget {
Q_OBJECT
public:

View File

@ -255,10 +255,12 @@ void GLScope::paintGL()
glPushMatrix();
glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y(), 0);
glScalef(m_glScopeRect1.width(), m_glScopeRect1.height(), 1);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glLineWidth(1.0f);
glColor4f(1, 1, 1, 0.5);
#ifdef GL_DEPRECATED
glBegin(GL_LINE_LOOP);
glVertex2f(1, 1);
@ -274,27 +276,28 @@ void GLScope::paintGL()
0, 0,
1, 0
};
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINE_LOOP, 0, 4);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINE_LOOP, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
#endif
}
#endif
glDisable(GL_BLEND);
glPopMatrix();
glPushMatrix();
glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y(), 0);
glScalef(m_glScopeRect1.width(), m_glScopeRect1.height(), 1);
// 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);
if (m_mode == ModeIQPolar) {
glColor4f(1, 1, 0.25f, m_displayGridIntensity / 100.0);
} else {
@ -302,6 +305,7 @@ void GLScope::paintGL()
}
// Horizontal Y1
tickList = &m_y1Scale.getTickList();
#ifdef GL_DEPRECATED
for(int i= 0; i < tickList->count(); i++) {
tick = &(*tickList)[i];
@ -345,9 +349,16 @@ void GLScope::paintGL()
#endif
}
#endif
glPopMatrix();
glPushMatrix();
glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y(), 0);
glScalef(m_glScopeRect1.width(), m_glScopeRect1.height(), 1);
// Vertical X1
glColor4f(1, 1, 1, m_displayGridIntensity / 100.0);
tickList = &m_x1Scale.getTickList();
#ifdef GL_DEPRECATED
for(int i= 0; i < tickList->count(); i++) {
tick = &(*tickList)[i];
@ -1723,18 +1734,47 @@ void GLScope::applyConfig()
(float) (width() - 2*leftMargin - rightMargin) / (float) width(),
(float) scopeHeight / (float) height()
);
m_glScopeMatrix1.setToIdentity();
m_glScopeMatrix1.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glScopeMatrix1.scale (
(float) 2*(width() - 2*leftMargin - rightMargin) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
m_glBot1ScaleRect = QRectF(
(float) leftMargin / (float) width(),
(float) (scopeHeight + topMargin + 1) / (float) height(),
(float) (width() - 2*leftMargin - rightMargin) / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glBot1ScaleMatrix.setToIdentity();
m_glBot1ScaleMatrix.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height())
);
m_glBot1ScaleMatrix.scale (
(float) 2*(width() - 2*leftMargin - rightMargin) / (float) width(),
(float) -2*(botMargin - 1) / (float) height()
);
m_glRight1ScaleRect = QRectF(
(float) (width() - leftMargin) / (float) width(),
(float) topMargin / (float) height(),
(float) (leftMargin-1) / (float) width(),
(float) scopeHeight / (float) height()
);
m_glRight1ScaleMatrix.setToIdentity();
m_glRight1ScaleMatrix.translate (
-1.0f + ((float)(2*(width() - leftMargin)) / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glRight1ScaleMatrix.scale (
(float) 2*(leftMargin-1) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
}
else
{
@ -1744,13 +1784,33 @@ void GLScope::applyConfig()
(float) scopeWidth / (float) width(),
(float) scopeHeight / (float) height()
);
m_glScopeMatrix1.setToIdentity();
m_glScopeMatrix1.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glScopeMatrix1.scale (
(float) 2*scopeWidth / (float) width(),
(float) -2*scopeHeight / (float) height()
);
m_glBot1ScaleRect = QRectF(
(float) leftMargin / (float) width(),
(float) (scopeHeight + topMargin + 1) / (float) height(),
(float) scopeWidth / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glBot1ScaleMatrix.setToIdentity();
m_glBot1ScaleMatrix.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height())
);
m_glBot1ScaleMatrix.scale (
(float) 2*scopeWidth / (float) width(),
(float) -2*(botMargin - 1) / (float) height()
);
}
m_glLeft1ScaleRect = QRectF(
0,
(float) topMargin / (float) height(),
@ -1758,6 +1818,16 @@ void GLScope::applyConfig()
(float) scopeHeight / (float) height()
);
m_glLeft1ScaleMatrix.setToIdentity();
m_glLeft1ScaleMatrix.translate (
-1.0f,
1.0f - ((float) 2*topMargin / (float) height())
);
m_glLeft1ScaleMatrix.scale (
(float) 2*(leftMargin-1) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
{ // Y1 scale
m_y1Scale.setSize(scopeHeight);
@ -1839,18 +1909,47 @@ void GLScope::applyConfig()
(float) scopeDim / (float)width(),
(float) scopeDim / (float)height()
);
m_glScopeMatrix2.setToIdentity();
m_glScopeMatrix2.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*(botMargin + topMargin + scopeDim) / (float) height())
);
m_glScopeMatrix2.scale (
(float) 2*scopeDim / (float) width(),
(float) -2*scopeDim / (float) height()
);
m_glLeft2ScaleRect = QRectF(
0,
(float) (topMargin + scopeDim + botMargin) / (float) height(),
(float) (leftMargin-1) / (float) width(),
(float) scopeDim / (float) height()
);
m_glLeft2ScaleMatrix.setToIdentity();
m_glLeft2ScaleMatrix.translate (
-1.0f,
1.0f - ((float) 2*(topMargin + scopeDim + botMargin) / (float) height())
);
m_glLeft2ScaleMatrix.scale (
(float) 2*(leftMargin-1) / (float) width(),
(float) -2*scopeDim / (float) height()
);
m_glBot2ScaleRect = QRectF(
(float) leftMargin / (float) width(),
(float) (scopeDim + topMargin + scopeDim + botMargin + 1) / (float) height(),
(float) scopeDim / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glBot2ScaleMatrix.setToIdentity();
m_glBot2ScaleMatrix.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*(scopeDim + topMargin + scopeDim + botMargin + 1) / (float) height())
);
m_glBot2ScaleMatrix.scale (
(float) 2*scopeDim / (float) width(),
(float) -2*(botMargin - 1) / (float) height()
);
}
else
{
@ -1860,18 +1959,47 @@ void GLScope::applyConfig()
(float) scopeWidth / (float)width(),
(float) scopeHeight / (float)height()
);
m_glScopeMatrix2.setToIdentity();
m_glScopeMatrix2.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*(botMargin + topMargin + scopeHeight) / (float) height())
);
m_glScopeMatrix2.scale (
(float) 2*scopeWidth / (float) width(),
(float) -2*scopeHeight / (float) height()
);
m_glLeft2ScaleRect = QRectF(
0,
(float) (topMargin + scopeHeight + botMargin) / (float) height(),
(float) (leftMargin-1) / (float) width(),
(float) scopeHeight / (float) height()
);
m_glLeft2ScaleMatrix.setToIdentity();
m_glLeft2ScaleMatrix.translate (
-1.0f,
1.0f - ((float) 2*(topMargin + scopeHeight + botMargin) / (float) height())
);
m_glLeft2ScaleMatrix.scale (
(float) 2*(leftMargin-1) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
m_glBot2ScaleRect = QRectF(
(float) leftMargin / (float) width(),
(float) (scopeHeight + topMargin + scopeHeight + botMargin + 1) / (float) height(),
(float) scopeWidth / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glBot2ScaleMatrix.setToIdentity();
m_glBot2ScaleMatrix.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*(scopeHeight + topMargin + scopeHeight + botMargin + 1) / (float) height())
);
m_glBot2ScaleMatrix.scale (
(float) 2*scopeWidth / (float) width(),
(float) -2*(botMargin - 1) / (float) height()
);
}
{ // Y2 scale
m_y2Scale.setSize(scopeHeight);
@ -1969,18 +2097,47 @@ void GLScope::applyConfig()
(float) (scopeWidth-leftMargin) / (float) width(),
(float) scopeHeight / (float) height()
);
m_glScopeMatrix1.setToIdentity();
m_glScopeMatrix1.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glScopeMatrix1.scale (
(float) 2*(scopeWidth-leftMargin) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
m_glBot1ScaleRect = QRectF(
(float) leftMargin / (float) width(),
(float) (scopeHeight + topMargin + 1) / (float) height(),
(float) (scopeWidth-leftMargin) / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glBot1ScaleMatrix.setToIdentity();
m_glBot1ScaleMatrix.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height())
);
m_glBot1ScaleMatrix.scale (
(float) 2*(scopeWidth-leftMargin) / (float) width(),
(float) -2*(botMargin - 1) / (float) height()
);
m_glRight1ScaleRect = QRectF(
(float) (scopeWidth) / (float) width(),
(float) topMargin / (float) height(),
(float) (leftMargin-1) / (float) width(),
(float) scopeHeight / (float) height()
);
m_glRight1ScaleMatrix.setToIdentity();
m_glRight1ScaleMatrix.translate (
-1.0f + ((float) 2*scopeWidth / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glRight1ScaleMatrix.scale (
(float) 2*(leftMargin-1) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
}
else
{
@ -1990,13 +2147,33 @@ void GLScope::applyConfig()
(float) scopeWidth / (float) width(),
(float) scopeHeight / (float) height()
);
m_glScopeMatrix1.setToIdentity();
m_glScopeMatrix1.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glScopeMatrix1.scale (
(float) 2*scopeWidth / (float) width(),
(float) -2*scopeHeight / (float) height()
);
m_glBot1ScaleRect = QRectF(
(float) leftMargin / (float) width(),
(float) (scopeHeight + topMargin + 1) / (float) height(),
(float) scopeWidth / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glBot1ScaleMatrix.setToIdentity();
m_glBot1ScaleMatrix.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height())
);
m_glBot1ScaleMatrix.scale (
(float) 2*scopeWidth / (float) width(),
(float) -2*(botMargin - 1) / (float) height()
);
}
m_glLeft1ScaleRect = QRectF(
0,
(float) topMargin / (float) height(),
@ -2004,6 +2181,16 @@ void GLScope::applyConfig()
(float) scopeHeight / (float) height()
);
m_glLeft1ScaleMatrix.setToIdentity();
m_glLeft1ScaleMatrix.translate (
-1.0f,
1.0f - ((float) 2*topMargin / (float) height())
);
m_glLeft1ScaleMatrix.scale (
(float) 2*(leftMargin-1) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
{ // Y1 scale
m_y1Scale.setSize(scopeHeight);
@ -2085,18 +2272,47 @@ void GLScope::applyConfig()
(float) scopeDim / (float)width(),
(float)(height() - topMargin - botMargin) / (float)height()
);
m_glScopeMatrix2.setToIdentity();
m_glScopeMatrix2.translate (
-1.0f + ((float) 2*(leftMargin + scopeWidth + leftMargin) / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glScopeMatrix2.scale (
(float) 2*scopeDim / (float) width(),
(float) -2*(height() - topMargin - botMargin) / (float) height()
);
m_glLeft2ScaleRect = QRectF(
(float) (leftMargin + scopeWidth) / (float) width(),
(float) topMargin / (float) height(),
(float) (leftMargin-1) / (float) width(),
(float) scopeHeight / (float) height()
);
m_glLeft2ScaleMatrix.setToIdentity();
m_glLeft2ScaleMatrix.translate (
-1.0f + (float) 2*(leftMargin + scopeWidth) / (float) width(),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glLeft2ScaleMatrix.scale (
(float) 2*(leftMargin-1) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
m_glBot2ScaleRect = QRectF(
(float) (leftMargin + leftMargin + scopeWidth) / (float) width(),
(float) (scopeHeight + topMargin + 1) / (float) height(),
(float) scopeDim / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glBot2ScaleMatrix.setToIdentity();
m_glBot2ScaleMatrix.translate (
-1.0f + ((float) 2*(leftMargin + leftMargin + scopeWidth) / (float) width()),
1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height())
);
m_glBot2ScaleMatrix.scale (
(float) 2*scopeDim / (float) width(),
(float) -2*(botMargin - 1) / (float) height()
);
}
else
{
@ -2106,18 +2322,47 @@ void GLScope::applyConfig()
(float)((width() - leftMargin - leftMargin - rightMargin) / 2) / (float)width(),
(float)(height() - topMargin - botMargin) / (float)height()
);
m_glScopeMatrix2.setToIdentity();
m_glScopeMatrix2.translate (
-1.0f + ((float) 2*(leftMargin + leftMargin + ((width() - leftMargin - leftMargin - rightMargin) / 2)) / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glScopeMatrix2.scale (
(float) 2*((width() - leftMargin - leftMargin - rightMargin) / 2) / (float) width(),
(float) -2*(height() - topMargin - botMargin) / (float) height()
);
m_glLeft2ScaleRect = QRectF(
(float) (leftMargin + scopeWidth) / (float) width(),
(float) topMargin / (float) height(),
(float) (leftMargin-1) / (float) width(),
(float) scopeHeight / (float) height()
);
m_glLeft2ScaleMatrix.setToIdentity();
m_glLeft2ScaleMatrix.translate (
-1.0f + (float) 2*(leftMargin + scopeWidth) / (float) width(),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glLeft2ScaleMatrix.scale (
(float) 2*(leftMargin-1) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
m_glBot2ScaleRect = QRectF(
(float) (leftMargin + leftMargin + scopeWidth) / (float) width(),
(float) (scopeHeight + topMargin + 1) / (float) height(),
(float) scopeWidth / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glBot2ScaleMatrix.setToIdentity();
m_glBot2ScaleMatrix.translate (
-1.0f + ((float) 2*(leftMargin + leftMargin + scopeWidth) / (float) width()),
1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height())
);
m_glBot2ScaleMatrix.scale (
(float) 2*scopeWidth / (float) width(),
(float) -2*(botMargin - 1) / (float) height()
);
}
{ // Y2 scale
m_y2Scale.setSize(scopeHeight);
@ -2216,18 +2461,47 @@ void GLScope::applyConfig()
(float) (scopeWidth-leftMargin) / (float) width(),
(float) scopeHeight / (float) height()
);
m_glScopeMatrix1.setToIdentity();
m_glScopeMatrix1.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glScopeMatrix1.scale (
(float) 2*(scopeWidth-leftMargin) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
m_glBot1ScaleRect = QRectF(
(float) leftMargin / (float) width(),
(float) (scopeHeight + topMargin + 1) / (float) height(),
(float) (scopeWidth-leftMargin) / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glBot1ScaleMatrix.setToIdentity();
m_glBot1ScaleMatrix.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height())
);
m_glBot1ScaleMatrix.scale (
(float) 2*(scopeWidth-leftMargin) / (float) width(),
(float) -2*(botMargin - 1) / (float) height()
);
m_glRight1ScaleRect = QRectF(
(float) (width() - leftMargin) / (float) width(),
(float) topMargin / (float) height(),
(float) (leftMargin-1) / (float) width(),
(float) scopeHeight / (float) height()
);
m_glRight1ScaleMatrix.setToIdentity();
m_glRight1ScaleMatrix.translate (
-1.0f + ((float) (2*width() - leftMargin) / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glRight1ScaleMatrix.scale (
(float) 2*(leftMargin-1) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
}
else
{
@ -2237,13 +2511,33 @@ void GLScope::applyConfig()
(float) scopeWidth / (float) width(),
(float) scopeHeight / (float) height()
);
m_glScopeMatrix1.setToIdentity();
m_glScopeMatrix1.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glScopeMatrix1.scale (
(float) 2*scopeWidth / (float) width(),
(float) -2*scopeHeight / (float) height()
);
m_glBot1ScaleRect = QRectF(
(float) leftMargin / (float) width(),
(float) (scopeHeight + topMargin + 1) / (float) height(),
(float) scopeWidth / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glBot1ScaleMatrix.setToIdentity();
m_glBot1ScaleMatrix.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height())
);
m_glBot1ScaleMatrix.scale (
(float) 2*scopeWidth / (float) width(),
(float) -2*(botMargin - 1) / (float) height()
);
}
m_glLeft1ScaleRect = QRectF(
0,
(float) topMargin / (float) height(),
@ -2251,6 +2545,16 @@ void GLScope::applyConfig()
(float) scopeHeight / (float) height()
);
m_glLeft1ScaleMatrix.setToIdentity();
m_glLeft1ScaleMatrix.translate (
-1.0f,
1.0f - ((float) 2*topMargin / (float) height())
);
m_glLeft1ScaleMatrix.scale (
(float) 2*(leftMargin-1) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
{ // Y1 scale
m_y1Scale.setSize(scopeHeight);
@ -2376,18 +2680,47 @@ void GLScope::applyConfig()
(float) scopeDim / (float) width(),
(float) scopeDim / (float) height()
);
m_glScopeMatrix2.setToIdentity();
m_glScopeMatrix2.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glScopeMatrix2.scale (
(float) 2*scopeDim / (float) width(),
(float) -2*scopeDim / (float) height()
);
m_glLeft2ScaleRect = QRectF(
0,
(float) topMargin / (float) height(),
(float) (leftMargin-1) / (float) width(),
(float) scopeDim / (float) height()
);
m_glLeft2ScaleMatrix.setToIdentity();
m_glLeft2ScaleMatrix.translate (
-1.0f,
1.0f - ((float) 2*topMargin / (float) height())
);
m_glLeft2ScaleMatrix.scale (
(float) 2*(leftMargin-1) / (float) width(),
(float) -2*scopeDim / (float) height()
);
m_glBot2ScaleRect = QRectF(
(float) leftMargin / (float) width(),
(float) (scopeDim + topMargin + 1) / (float) height(),
(float) scopeDim / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glBot2ScaleMatrix.setToIdentity();
m_glBot2ScaleMatrix.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*(scopeDim + topMargin + 1) / (float) height())
);
m_glBot2ScaleMatrix.scale (
(float) 2*scopeDim / (float) width(),
(float) -2*(botMargin - 1) / (float) height()
);
}
else
{
@ -2397,18 +2730,47 @@ void GLScope::applyConfig()
(float) scopeWidth / (float) width(),
(float) scopeHeight / (float) height()
);
m_glScopeMatrix2.setToIdentity();
m_glScopeMatrix2.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*topMargin / (float) height())
);
m_glScopeMatrix2.scale (
(float) 2*scopeWidth / (float) width(),
(float) -2*scopeHeight / (float) height()
);
m_glLeft2ScaleRect = QRectF(
0,
(float) topMargin / (float) height(),
(float) (leftMargin-1) / (float) width(),
(float) scopeHeight / (float) height()
);
m_glLeft2ScaleMatrix.setToIdentity();
m_glLeft2ScaleMatrix.translate (
-1.0f,
1.0f - ((float) 2*topMargin / (float) height())
);
m_glLeft2ScaleMatrix.scale (
(float) 2*(leftMargin-1) / (float) width(),
(float) -2*scopeHeight / (float) height()
);
m_glBot2ScaleRect = QRectF(
(float) leftMargin / (float) width(),
(float) (scopeHeight + topMargin + 1) / (float) height(),
(float) scopeWidth / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glBot2ScaleMatrix.setToIdentity();
m_glBot2ScaleMatrix.translate (
-1.0f + ((float) 2*leftMargin / (float) width()),
1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height())
);
m_glBot2ScaleMatrix.scale (
(float) 2*scopeWidth / (float) width(),
(float) -2*(botMargin - 1) / (float) height()
);
}
{ // Y2 scale

View File

@ -28,6 +28,7 @@
#include <QDebug>
GLSpectrum::GLSpectrum(QWidget* parent) :
QGLWidget(parent),
m_cursorState(CSNormal),
m_mouseInside(false),
m_changesPending(true),
@ -2219,14 +2220,14 @@ void GLSpectrum::enterEvent(QEvent* event)
{
m_mouseInside = true;
update();
QOpenGLWidget::enterEvent(event);
QGLWidget::enterEvent(event);
}
void GLSpectrum::leaveEvent(QEvent* event)
{
m_mouseInside = false;
update();
QOpenGLWidget::enterEvent(event);
QGLWidget::enterEvent(event);
}
void GLSpectrum::tick()