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

GLSpectrum: implement power tracking histogram markers

This commit is contained in:
f4exb 2021-07-22 08:48:26 +02:00
parent 9f8ce82287
commit 6036f62ae4
2 changed files with 47 additions and 13 deletions

View File

@ -1143,23 +1143,35 @@ void GLSpectrum::drawMarkers()
// paint histogram markers
if (m_histogramMarkers.size() > 0)
{
// crosshairs
for (int i = 0; i < m_histogramMarkers.size(); i++)
{
QPointF ypoint = m_histogramMarkers.at(i).m_point;
QString powerStr = m_histogramMarkers.at(i).m_powerStr;
if (m_histogramMarkers.at(i).m_markerType == HistogramMarkerTypePower)
{
ypoint.ry() =
(m_powerScale.getRangeMax() - m_currentSpectrum[m_histogramMarkers.at(i).m_fftBin]) / m_powerScale.getRange();
powerStr = displayScaledF(
m_currentSpectrum[m_histogramMarkers.at(i).m_fftBin],
m_linear ? 'e' : 'f',
m_linear ? 3 : 1,
false
);
}
// crosshairs
GLfloat h[] {
(float) m_histogramMarkers.at(i).m_point.x(), 0,
(float) m_histogramMarkers.at(i).m_point.x(), 1
};
m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, markerColor, h, 2);
GLfloat v[] {
0, (float) m_histogramMarkers.at(i).m_point.y(),
1, (float) m_histogramMarkers.at(i).m_point.y()
0, (float) ypoint.y(),
1, (float) ypoint.y()
};
m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, markerColor, v, 2);
}
// text
for (int i = 0; i < m_histogramMarkers.size(); i++)
{
// text
if (i == 0)
{
drawTextOverlay(
@ -1172,17 +1184,28 @@ void GLSpectrum::drawMarkers()
!m_invertedWaterfall && (m_waterfallHeight != 0),
m_histogramRect);
drawTextOverlay(
m_histogramMarkers.at(i).m_powerStr,
powerStr,
QColor(255, 255, 255, 192),
m_textOverlayFont,
0,
m_histogramMarkers.at(i).m_point.y() * m_histogramRect.height(),
ypoint.y() * m_histogramRect.height(),
true,
m_histogramMarkers.at(i).m_point.y() < 0.5f,
ypoint.y() < 0.5f,
m_histogramRect);
}
else
{
float power0 = m_histogramMarkers.at(0).m_markerType == HistogramMarkerTypePower ?
m_currentSpectrum[m_histogramMarkers.at(0).m_fftBin] :
m_histogramMarkers.at(0).m_power;
float poweri = m_histogramMarkers.at(i).m_markerType == HistogramMarkerTypePower ?
m_currentSpectrum[m_histogramMarkers.at(i).m_fftBin] :
m_histogramMarkers.at(i).m_power;
QString deltaPowerStr = displayScaledF(
poweri - power0,
m_linear ? 'e' : 'f',
m_linear ? 3 : 1,
false);
drawTextOverlay(
m_histogramMarkers.at(i).m_deltaFrequencyStr,
QColor(255, 255, 255, 192),
@ -1193,13 +1216,13 @@ void GLSpectrum::drawMarkers()
(m_invertedWaterfall || (m_waterfallHeight == 0)),
m_histogramRect);
drawTextOverlay(
m_histogramMarkers.at(i).m_deltaPowerStr,
deltaPowerStr,
QColor(255, 255, 255, 192),
m_textOverlayFont,
m_histogramRect.width(),
m_histogramMarkers.at(i).m_point.y() * m_histogramRect.height(),
ypoint.y() * m_histogramRect.height(),
false,
m_histogramMarkers.at(i).m_point.y() < 0.5f,
ypoint.y() < 0.5f,
m_histogramRect);
}
}

View File

@ -175,11 +175,18 @@ private:
CSChannel,
CSChannelMoving
};
enum HistogramMarkerType {
HistogramMarkerTypeManual,
HistogramMarkerTypePower
};
struct HistogramMarker {
QPointF m_point;
float m_frequency;
int m_fftBin;
float m_power;
HistogramMarkerType m_markerType;
QString m_frequencyStr;
QString m_powerStr;
QString m_deltaFrequencyStr;
@ -189,6 +196,7 @@ private:
m_frequency(0),
m_fftBin(0),
m_power(0),
m_markerType(HistogramMarkerTypeManual),
m_frequencyStr(),
m_powerStr(),
m_deltaFrequencyStr(),
@ -199,6 +207,7 @@ private:
float frequency,
int fftBin,
float power,
HistogramMarkerType markerType,
const QString& frequencyStr,
const QString& powerStr,
const QString& deltaFrequencyStr,
@ -208,6 +217,7 @@ private:
m_frequency(frequency),
m_fftBin(fftBin),
m_power(power),
m_markerType(markerType),
m_frequencyStr(frequencyStr),
m_powerStr(powerStr),
m_deltaFrequencyStr(deltaFrequencyStr),
@ -218,6 +228,7 @@ private:
m_frequency(other.m_frequency),
m_fftBin(other.m_fftBin),
m_power(other.m_power),
m_markerType(other.m_markerType),
m_frequencyStr(other.m_frequencyStr),
m_powerStr(other.m_powerStr),
m_deltaFrequencyStr(other.m_deltaFrequencyStr),