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

Corrected timescale of waterfall when spectrum is SSB

This commit is contained in:
f4exb 2015-06-12 02:49:29 +02:00
parent 7727ae7a36
commit ce60c0b53e
3 changed files with 74 additions and 17 deletions

View File

@ -39,6 +39,7 @@ public:
void setPowerRange(Real powerRange); void setPowerRange(Real powerRange);
void setDecay(int decay); void setDecay(int decay);
void setDisplayWaterfall(bool display); void setDisplayWaterfall(bool display);
void setSsbSpectrum(bool ssbSpectrum);
void setInvertedWaterfall(bool inv); void setInvertedWaterfall(bool inv);
void setDisplayMaxHold(bool display); void setDisplayMaxHold(bool display);
void setDisplayHistogram(bool display); void setDisplayHistogram(bool display);
@ -120,6 +121,7 @@ private:
int m_waterfallTexturePos; int m_waterfallTexturePos;
QRectF m_glWaterfallRect; QRectF m_glWaterfallRect;
bool m_displayWaterfall; bool m_displayWaterfall;
bool m_ssbSpectrum;
QRgb m_histogramPalette[240]; QRgb m_histogramPalette[240];
QImage* m_histogramBuffer; QImage* m_histogramBuffer;

View File

@ -230,6 +230,7 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
ui->glSpectrum->setSampleRate(m_rate); ui->glSpectrum->setSampleRate(m_rate);
ui->glSpectrum->setDisplayWaterfall(true); ui->glSpectrum->setDisplayWaterfall(true);
ui->glSpectrum->setDisplayMaxHold(true); ui->glSpectrum->setDisplayMaxHold(true);
ui->glSpectrum->setSsbSpectrum(true);
m_channelMarker = new ChannelMarker(this); m_channelMarker = new ChannelMarker(this);
m_channelMarker->setColor(Qt::green); m_channelMarker->setColor(Qt::green);

View File

@ -42,6 +42,7 @@ GLSpectrum::GLSpectrum(QWidget* parent) :
m_waterfallTextureAllocated(false), m_waterfallTextureAllocated(false),
m_waterfallTextureHeight(-1), m_waterfallTextureHeight(-1),
m_displayWaterfall(true), m_displayWaterfall(true),
m_ssbSpectrum(false),
m_histogramBuffer(NULL), m_histogramBuffer(NULL),
m_histogram(NULL), m_histogram(NULL),
m_histogramHoldoff(NULL), m_histogramHoldoff(NULL),
@ -188,6 +189,12 @@ void GLSpectrum::setDisplayWaterfall(bool display)
update(); update();
} }
void GLSpectrum::setSsbSpectrum(bool ssbSpectrum)
{
m_ssbSpectrum = ssbSpectrum;
update();
}
void GLSpectrum::setInvertedWaterfall(bool inv) void GLSpectrum::setInvertedWaterfall(bool inv)
{ {
m_invertedWaterfall = inv; m_invertedWaterfall = inv;
@ -873,16 +880,24 @@ void GLSpectrum::applyChanges()
int leftMargin; int leftMargin;
int rightMargin = fm.width("000"); int rightMargin = fm.width("000");
if(m_displayWaterfall && (m_displayHistogram | m_displayMaxHold)) { if(m_displayWaterfall && (m_displayHistogram | m_displayMaxHold))
{
waterfallHeight = height() * m_waterfallShare - 1; waterfallHeight = height() * m_waterfallShare - 1;
if(waterfallHeight < 0) if(waterfallHeight < 0)
{
waterfallHeight = 0; waterfallHeight = 0;
if(!m_invertedWaterfall) { }
if(!m_invertedWaterfall)
{
waterfallTop = topMargin; waterfallTop = topMargin;
frequencyScaleTop = waterfallTop + waterfallHeight + 1; frequencyScaleTop = waterfallTop + waterfallHeight + 1;
histogramTop = waterfallTop + waterfallHeight + frequencyScaleHeight + 1; histogramTop = waterfallTop + waterfallHeight + frequencyScaleHeight + 1;
histogramHeight = height() - topMargin - waterfallHeight - frequencyScaleHeight - bottomMargin; histogramHeight = height() - topMargin - waterfallHeight - frequencyScaleHeight - bottomMargin;
} else { }
else
{
histogramTop = topMargin; histogramTop = topMargin;
histogramHeight = height() - topMargin - waterfallHeight - frequencyScaleHeight - bottomMargin; histogramHeight = height() - topMargin - waterfallHeight - frequencyScaleHeight - bottomMargin;
waterfallTop = histogramTop + histogramHeight + frequencyScaleHeight + 1; waterfallTop = histogramTop + histogramHeight + frequencyScaleHeight + 1;
@ -890,18 +905,34 @@ void GLSpectrum::applyChanges()
} }
m_timeScale.setSize(waterfallHeight); m_timeScale.setSize(waterfallHeight);
if(m_sampleRate > 0) {
if(m_sampleRate > 0)
{
float scaleDiv = (float)m_sampleRate * (m_ssbSpectrum ? 2 : 1);
if(!m_invertedWaterfall) if(!m_invertedWaterfall)
m_timeScale.setRange(Unit::Time, (waterfallHeight * m_fftSize) / (float)m_sampleRate, 0); {
else m_timeScale.setRange(Unit::Time, 0, (waterfallHeight * m_fftSize) / (float)m_sampleRate); m_timeScale.setRange(Unit::Time, (waterfallHeight * m_fftSize) / scaleDiv, 0);
} else { }
else
{
m_timeScale.setRange(Unit::Time, 0, (waterfallHeight * m_fftSize) / scaleDiv);
}
}
else
{
m_timeScale.setRange(Unit::Time, 0, 1); m_timeScale.setRange(Unit::Time, 0, 1);
} }
m_powerScale.setSize(histogramHeight); m_powerScale.setSize(histogramHeight);
m_powerScale.setRange(Unit::Decibel, m_referenceLevel - m_powerRange, m_referenceLevel); m_powerScale.setRange(Unit::Decibel, m_referenceLevel - m_powerRange, m_referenceLevel);
leftMargin = m_timeScale.getScaleWidth(); leftMargin = m_timeScale.getScaleWidth();
if(m_powerScale.getScaleWidth() > leftMargin) if(m_powerScale.getScaleWidth() > leftMargin)
{
leftMargin = m_powerScale.getScaleWidth(); leftMargin = m_powerScale.getScaleWidth();
}
leftMargin += 2 * M; leftMargin += 2 * M;
m_frequencyScale.setSize(width() - leftMargin - rightMargin); m_frequencyScale.setSize(width() - leftMargin - rightMargin);
@ -940,7 +971,9 @@ void GLSpectrum::applyChanges()
(float)(leftMargin - 1) / (float)width(), (float)(leftMargin - 1) / (float)width(),
(float)1 (float)1
); );
} else if(m_displayWaterfall) { }
else if(m_displayWaterfall)
{
bottomMargin = frequencyScaleHeight; bottomMargin = frequencyScaleHeight;
waterfallTop = topMargin; waterfallTop = topMargin;
waterfallHeight = height() - topMargin - frequencyScaleHeight; waterfallHeight = height() - topMargin - frequencyScaleHeight;
@ -948,15 +981,32 @@ void GLSpectrum::applyChanges()
histogramTop = 0; histogramTop = 0;
m_timeScale.setSize(waterfallHeight); m_timeScale.setSize(waterfallHeight);
if(m_sampleRate > 0) {
if(m_sampleRate > 0)
{
float scaleDiv = (float)m_sampleRate * (m_ssbSpectrum ? 2 : 1);
if(!m_invertedWaterfall) if(!m_invertedWaterfall)
m_timeScale.setRange(Unit::Time, (waterfallHeight * m_fftSize) / (float)m_sampleRate, 0); {
else m_timeScale.setRange(Unit::Time, 0, (waterfallHeight * m_fftSize) / (float)m_sampleRate); m_timeScale.setRange(Unit::Time, (waterfallHeight * m_fftSize) / scaleDiv, 0);
} else { }
if(!m_invertedWaterfall) else
m_timeScale.setRange(Unit::Time, 10, 0); {
else m_timeScale.setRange(Unit::Time, 0, 10); m_timeScale.setRange(Unit::Time, 0, (waterfallHeight * m_fftSize) / scaleDiv);
}
} }
else
{
if(!m_invertedWaterfall)
{
m_timeScale.setRange(Unit::Time, 10, 0);
}
else
{
m_timeScale.setRange(Unit::Time, 0, 10);
}
}
leftMargin = m_timeScale.getScaleWidth(); leftMargin = m_timeScale.getScaleWidth();
leftMargin += 2 * M; leftMargin += 2 * M;
@ -989,7 +1039,9 @@ void GLSpectrum::applyChanges()
(float)(leftMargin - 1) / (float)width(), (float)(leftMargin - 1) / (float)width(),
(float)1 (float)1
); );
} else if(m_displayHistogram || m_displayMaxHold) { }
else if(m_displayHistogram || m_displayMaxHold)
{
bottomMargin = frequencyScaleHeight; bottomMargin = frequencyScaleHeight;
frequencyScaleTop = height() - bottomMargin; frequencyScaleTop = height() - bottomMargin;
histogramTop = topMargin - 1; histogramTop = topMargin - 1;
@ -1030,7 +1082,9 @@ void GLSpectrum::applyChanges()
(float)(leftMargin - 1) / (float)width(), (float)(leftMargin - 1) / (float)width(),
(float)1 (float)1
); );
} else { }
else
{
leftMargin = 2; leftMargin = 2;
waterfallHeight = 0; waterfallHeight = 0;
} }