1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-09-03 13:47:50 -04:00

Channel Analyzer: display trace max and average power. Interim state #2

This commit is contained in:
f4exb 2015-10-28 09:27:51 +01:00
parent ed6e078cff
commit 70700ee4dc
2 changed files with 37 additions and 3 deletions

View File

@ -29,6 +29,7 @@
class DSPEngine;
class ScopeVis;
class QPainter;
class SDRANGEL_API GLScope: public QGLWidget {
Q_OBJECT
@ -124,18 +125,22 @@ private:
QRectF m_glLeft2ScaleRect;
QRectF m_glBot1ScaleRect;
QRectF m_glBot2ScaleRect;
QRectF m_glPowerOverlay1;
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;
@ -149,7 +154,7 @@ private:
void handleMode();
void applyConfig();
void drawPowerOverlay();
void drawPowerOverlay(QPainter *painter);
protected slots:
void tick();

View File

@ -422,7 +422,9 @@ void GLScope::paintGL()
{
if (m_nbPow > 0)
{
qDebug("%.1f %.1f", 10.0f * log10f(m_maxPow), 10.0f * log10f(m_sumPow / m_nbPow));
QPainter painter(this);
drawPowerOverlay(&painter);
painter.end();
}
}
@ -805,9 +807,21 @@ void GLScope::handleMode()
}
}
void GLScope::drawPowerOverlay()
void GLScope::drawPowerOverlay(QPainter *painter)
{
//qDebug("%.1f %.1f", 10.0f * log10f(m_maxPow), 10.0f * log10f(m_sumPow / m_nbPow));
double maxPow = 10.0f * log10f(m_maxPow);
double avgPow = 10.0f * log10f(m_sumPow / m_nbPow);
double peakToAvgPow = maxPow - avgPow;
QString text("test");
QFontMetrics metrics = QFontMetrics(font());
QRect rect = metrics.boundingRect(0, 0, width(), int(height()*0.125), Qt::AlignLeft | Qt::TextWordWrap, text);
painter->setRenderHint(QPainter::TextAntialiasing);
painter->fillRect(QRect(0, 0, width(), rect.height()), QColor(0, 0, 0, 127));
painter->setPen(Qt::white);
painter->drawText(0, 0, rect.width(), rect.height(), Qt::AlignLeft | Qt::TextWordWrap, text);
}
void GLScope::applyConfig()
@ -816,11 +830,14 @@ void GLScope::applyConfig()
QFontMetrics fm(font());
int M = fm.width("-");
int H = fm.height();
int topMargin = 5;
int botMargin = 20;
int leftMargin = 35;
int rightMargin = 5;
int powerOverlayWidth = 20*M;
int powerOverlayHeight = 2*H;
float pow_floor = -100.0 + m_ofs * 100.0;
float pow_range = 100.0 / m_amp;
@ -905,6 +922,12 @@ void GLScope::applyConfig()
(float) scopeWidth / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glPowerOverlay1 = QRectF(
(float) leftMargin / (float) width(),
(float) topMargin / (float) height(),
(float) powerOverlayWidth / (float) width(),
(float) powerOverlayHeight / (float) height()
);
{ // Y1 scale
m_y1Scale.setSize(scopeHeight);
@ -1090,6 +1113,12 @@ void GLScope::applyConfig()
(float) scopeWidth / (float) width(),
(float) (botMargin - 1) / (float) height()
);
m_glPowerOverlay1 = QRectF(
(float) leftMargin / (float) width(),
(float) topMargin / (float) height(),
(float) powerOverlayWidth / (float) width(),
(float) powerOverlayHeight / (float) height()
);
{ // Y1 scale
m_y1Scale.setSize(scopeHeight);