mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-11-04 05:30:32 -05:00 
			
		
		
		
	GLSpectrum: implement power tracking histogram markers
This commit is contained in:
		
							parent
							
								
									9f8ce82287
								
							
						
					
					
						commit
						6036f62ae4
					
				@ -1143,23 +1143,35 @@ void GLSpectrum::drawMarkers()
 | 
				
			|||||||
    // paint histogram markers
 | 
					    // paint histogram markers
 | 
				
			||||||
    if (m_histogramMarkers.size() > 0)
 | 
					    if (m_histogramMarkers.size() > 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // crosshairs
 | 
					 | 
				
			||||||
        for (int i = 0; i < m_histogramMarkers.size(); i++)
 | 
					        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[] {
 | 
					            GLfloat h[] {
 | 
				
			||||||
                (float) m_histogramMarkers.at(i).m_point.x(), 0,
 | 
					                (float) m_histogramMarkers.at(i).m_point.x(), 0,
 | 
				
			||||||
                (float) m_histogramMarkers.at(i).m_point.x(), 1
 | 
					                (float) m_histogramMarkers.at(i).m_point.x(), 1
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, markerColor, h, 2);
 | 
					            m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, markerColor, h, 2);
 | 
				
			||||||
            GLfloat v[] {
 | 
					            GLfloat v[] {
 | 
				
			||||||
                0, (float) m_histogramMarkers.at(i).m_point.y(),
 | 
					                0, (float) ypoint.y(),
 | 
				
			||||||
                1, (float) m_histogramMarkers.at(i).m_point.y()
 | 
					                1, (float) ypoint.y()
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, markerColor, v, 2);
 | 
					            m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, markerColor, v, 2);
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
			// text
 | 
								// text
 | 
				
			||||||
        for (int i = 0; i < m_histogramMarkers.size(); i++)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (i == 0)
 | 
					            if (i == 0)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                drawTextOverlay(
 | 
					                drawTextOverlay(
 | 
				
			||||||
@ -1172,17 +1184,28 @@ void GLSpectrum::drawMarkers()
 | 
				
			|||||||
                    !m_invertedWaterfall && (m_waterfallHeight != 0),
 | 
					                    !m_invertedWaterfall && (m_waterfallHeight != 0),
 | 
				
			||||||
                    m_histogramRect);
 | 
					                    m_histogramRect);
 | 
				
			||||||
                drawTextOverlay(
 | 
					                drawTextOverlay(
 | 
				
			||||||
                    m_histogramMarkers.at(i).m_powerStr,
 | 
					                    powerStr,
 | 
				
			||||||
                    QColor(255, 255, 255, 192),
 | 
					                    QColor(255, 255, 255, 192),
 | 
				
			||||||
                    m_textOverlayFont,
 | 
					                    m_textOverlayFont,
 | 
				
			||||||
                    0,
 | 
					                    0,
 | 
				
			||||||
                    m_histogramMarkers.at(i).m_point.y() * m_histogramRect.height(),
 | 
					                    ypoint.y() * m_histogramRect.height(),
 | 
				
			||||||
                    true,
 | 
					                    true,
 | 
				
			||||||
                    m_histogramMarkers.at(i).m_point.y() < 0.5f,
 | 
					                    ypoint.y() < 0.5f,
 | 
				
			||||||
                    m_histogramRect);
 | 
					                    m_histogramRect);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            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(
 | 
					                drawTextOverlay(
 | 
				
			||||||
                    m_histogramMarkers.at(i).m_deltaFrequencyStr,
 | 
					                    m_histogramMarkers.at(i).m_deltaFrequencyStr,
 | 
				
			||||||
                    QColor(255, 255, 255, 192),
 | 
					                    QColor(255, 255, 255, 192),
 | 
				
			||||||
@ -1193,13 +1216,13 @@ void GLSpectrum::drawMarkers()
 | 
				
			|||||||
                    (m_invertedWaterfall || (m_waterfallHeight == 0)),
 | 
					                    (m_invertedWaterfall || (m_waterfallHeight == 0)),
 | 
				
			||||||
                    m_histogramRect);
 | 
					                    m_histogramRect);
 | 
				
			||||||
                drawTextOverlay(
 | 
					                drawTextOverlay(
 | 
				
			||||||
                    m_histogramMarkers.at(i).m_deltaPowerStr,
 | 
					                    deltaPowerStr,
 | 
				
			||||||
                    QColor(255, 255, 255, 192),
 | 
					                    QColor(255, 255, 255, 192),
 | 
				
			||||||
                    m_textOverlayFont,
 | 
					                    m_textOverlayFont,
 | 
				
			||||||
                    m_histogramRect.width(),
 | 
					                    m_histogramRect.width(),
 | 
				
			||||||
                    m_histogramMarkers.at(i).m_point.y() * m_histogramRect.height(),
 | 
					                    ypoint.y() * m_histogramRect.height(),
 | 
				
			||||||
                    false,
 | 
					                    false,
 | 
				
			||||||
                    m_histogramMarkers.at(i).m_point.y() < 0.5f,
 | 
					                    ypoint.y() < 0.5f,
 | 
				
			||||||
                    m_histogramRect);
 | 
					                    m_histogramRect);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -175,11 +175,18 @@ private:
 | 
				
			|||||||
		CSChannel,
 | 
							CSChannel,
 | 
				
			||||||
		CSChannelMoving
 | 
							CSChannelMoving
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    enum HistogramMarkerType {
 | 
				
			||||||
 | 
					        HistogramMarkerTypeManual,
 | 
				
			||||||
 | 
					        HistogramMarkerTypePower
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    struct HistogramMarker {
 | 
					    struct HistogramMarker {
 | 
				
			||||||
        QPointF m_point;
 | 
					        QPointF m_point;
 | 
				
			||||||
        float m_frequency;
 | 
					        float m_frequency;
 | 
				
			||||||
        int m_fftBin;
 | 
					        int m_fftBin;
 | 
				
			||||||
        float m_power;
 | 
					        float m_power;
 | 
				
			||||||
 | 
					        HistogramMarkerType m_markerType;
 | 
				
			||||||
        QString m_frequencyStr;
 | 
					        QString m_frequencyStr;
 | 
				
			||||||
        QString m_powerStr;
 | 
					        QString m_powerStr;
 | 
				
			||||||
        QString m_deltaFrequencyStr;
 | 
					        QString m_deltaFrequencyStr;
 | 
				
			||||||
@ -189,6 +196,7 @@ private:
 | 
				
			|||||||
            m_frequency(0),
 | 
					            m_frequency(0),
 | 
				
			||||||
            m_fftBin(0),
 | 
					            m_fftBin(0),
 | 
				
			||||||
            m_power(0),
 | 
					            m_power(0),
 | 
				
			||||||
 | 
					            m_markerType(HistogramMarkerTypeManual),
 | 
				
			||||||
            m_frequencyStr(),
 | 
					            m_frequencyStr(),
 | 
				
			||||||
            m_powerStr(),
 | 
					            m_powerStr(),
 | 
				
			||||||
            m_deltaFrequencyStr(),
 | 
					            m_deltaFrequencyStr(),
 | 
				
			||||||
@ -199,6 +207,7 @@ private:
 | 
				
			|||||||
            float frequency,
 | 
					            float frequency,
 | 
				
			||||||
            int   fftBin,
 | 
					            int   fftBin,
 | 
				
			||||||
            float power,
 | 
					            float power,
 | 
				
			||||||
 | 
					            HistogramMarkerType markerType,
 | 
				
			||||||
            const QString& frequencyStr,
 | 
					            const QString& frequencyStr,
 | 
				
			||||||
            const QString& powerStr,
 | 
					            const QString& powerStr,
 | 
				
			||||||
            const QString& deltaFrequencyStr,
 | 
					            const QString& deltaFrequencyStr,
 | 
				
			||||||
@ -208,6 +217,7 @@ private:
 | 
				
			|||||||
            m_frequency(frequency),
 | 
					            m_frequency(frequency),
 | 
				
			||||||
            m_fftBin(fftBin),
 | 
					            m_fftBin(fftBin),
 | 
				
			||||||
            m_power(power),
 | 
					            m_power(power),
 | 
				
			||||||
 | 
					            m_markerType(markerType),
 | 
				
			||||||
            m_frequencyStr(frequencyStr),
 | 
					            m_frequencyStr(frequencyStr),
 | 
				
			||||||
            m_powerStr(powerStr),
 | 
					            m_powerStr(powerStr),
 | 
				
			||||||
            m_deltaFrequencyStr(deltaFrequencyStr),
 | 
					            m_deltaFrequencyStr(deltaFrequencyStr),
 | 
				
			||||||
@ -218,6 +228,7 @@ private:
 | 
				
			|||||||
            m_frequency(other.m_frequency),
 | 
					            m_frequency(other.m_frequency),
 | 
				
			||||||
            m_fftBin(other.m_fftBin),
 | 
					            m_fftBin(other.m_fftBin),
 | 
				
			||||||
            m_power(other.m_power),
 | 
					            m_power(other.m_power),
 | 
				
			||||||
 | 
					            m_markerType(other.m_markerType),
 | 
				
			||||||
            m_frequencyStr(other.m_frequencyStr),
 | 
					            m_frequencyStr(other.m_frequencyStr),
 | 
				
			||||||
            m_powerStr(other.m_powerStr),
 | 
					            m_powerStr(other.m_powerStr),
 | 
				
			||||||
            m_deltaFrequencyStr(other.m_deltaFrequencyStr),
 | 
					            m_deltaFrequencyStr(other.m_deltaFrequencyStr),
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user