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

Refactoring spectrum histogram display #1

This commit is contained in:
f4exb 2015-07-15 08:48:02 +02:00
parent 347360db90
commit 528b11ebd1
5 changed files with 119 additions and 108 deletions

View File

@ -132,6 +132,7 @@ private:
int m_histogramHoldoffBase;
int m_histogramHoldoffCount;
int m_histogramLateHoldoff;
int m_histogramStroke;
QRectF m_glHistogramRect;
bool m_displayHistogram;

View File

@ -39,6 +39,8 @@ private:
Real m_refLevel;
Real m_powerRange;
int m_decay;
int m_histogramLateHoldoff;
int m_histogramStroke;
int m_displayGridIntensity;
bool m_displayWaterfall;
bool m_invertedWaterfall;
@ -54,7 +56,9 @@ private slots:
void on_fftSize_currentIndexChanged(int index);
void on_refLevel_currentIndexChanged(int index);
void on_levelRange_currentIndexChanged(int index);
void on_decay_currentIndexChanged(int index);
void on_decay_valueChanged(int index);
void on_holdoff_valueChanged(int index);
void on_stroke_valueChanged(int index);
void on_gridIntensity_valueChanged(int index);
void on_waterfall_toggled(bool checked);

View File

@ -86,9 +86,10 @@ GLSpectrum::GLSpectrum(QWidget* parent) :
((quint8*)&m_histogramPalette[i])[2] = c.blue();
((quint8*)&m_histogramPalette[i])[3] = c.alpha();
}
m_histogramHoldoffBase = 4;
m_histogramHoldoffBase = 1; // was 4
m_histogramHoldoffCount = m_histogramHoldoffBase;
m_histogramLateHoldoff = 20;
m_histogramLateHoldoff = 1; // was 20
m_histogramStroke = 40; // was 4
m_timeScale.setFont(font());
m_timeScale.setOrientation(Qt::Vertical);
@ -332,7 +333,7 @@ void GLSpectrum::updateHistogram(const std::vector<Real>& spectrum)
m_histogramHoldoffCount = m_histogramHoldoffBase;
}
//#define NO_AVX
#define NO_AVX
#ifdef NO_AVX
for(int i = 0; i < m_fftSize; i++) {
int v = (int)((spectrum[i] - m_referenceLevel) * 100.0 / m_powerRange + 100.0);
@ -340,7 +341,7 @@ void GLSpectrum::updateHistogram(const std::vector<Real>& spectrum)
if((v >= 0) && (v <= 99)) {
b = m_histogram + i * 100 + v;
if(*b < 220)
*b += 4;
*b += m_histogramStroke; // was 4
else if(*b < 239)
*b += 1;
}

View File

@ -17,6 +17,8 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) :
m_refLevel(0),
m_powerRange(100),
m_decay(0),
m_histogramLateHoldoff(1),
m_histogramStroke(40),
m_displayGridIntensity(1),
m_displayWaterfall(true),
m_invertedWaterfall(false),
@ -53,6 +55,8 @@ void GLSpectrumGUI::resetToDefaults()
m_refLevel = 0;
m_powerRange = 100;
m_decay = 0;
m_histogramLateHoldoff = 1;
m_histogramStroke = 40;
m_displayGridIntensity = 5,
m_displayWaterfall = true;
m_invertedWaterfall = false;
@ -76,9 +80,11 @@ QByteArray GLSpectrumGUI::serialize() const
s.writeBool(8, m_displayMaxHold);
s.writeBool(9, m_displayHistogram);
s.writeS32(10, m_decay);
s.writeS32(13, m_displayGridIntensity);
s.writeBool(11, m_displayGrid);
s.writeBool(12, m_invert);
s.writeS32(13, m_displayGridIntensity);
s.writeS32(14, m_histogramLateHoldoff);
s.writeS32(15, m_histogramStroke);
return s.final();
}
@ -102,9 +108,11 @@ bool GLSpectrumGUI::deserialize(const QByteArray& data)
d.readBool(8, &m_displayMaxHold, false);
d.readBool(9, &m_displayHistogram, false);
d.readS32(10, &m_decay, 0);
d.readS32(13, &m_displayGridIntensity, 0);
d.readBool(11, &m_displayGrid, false);
d.readBool(12, &m_invert, true);
d.readS32(13, &m_displayGridIntensity, 0);
d.readS32(14, &m_histogramLateHoldoff, 1);
d.readS32(15, &m_histogramStroke, 40);
applySettings();
return true;
} else {
@ -124,7 +132,9 @@ void GLSpectrumGUI::applySettings()
}
ui->refLevel->setCurrentIndex(-m_refLevel / 5);
ui->levelRange->setCurrentIndex((100 - m_powerRange) / 5);
ui->decay->setCurrentIndex(m_decay + 2);
ui->decay->setSliderPosition(m_decay);
ui->holdoff->setSliderPosition(m_histogramLateHoldoff);
ui->stroke->setSliderPosition(m_histogramStroke);
ui->waterfall->setChecked(m_displayWaterfall);
ui->maxHold->setChecked(m_displayMaxHold);
ui->histogram->setChecked(m_displayHistogram);
@ -132,6 +142,11 @@ void GLSpectrumGUI::applySettings()
ui->grid->setChecked(m_displayGrid);
ui->gridIntensity->setSliderPosition(m_displayGridIntensity);
ui->decay->setToolTip(QString("Decay: %1").arg(m_decay));
ui->holdoff->setToolTip(QString("Holdoff: %1").arg(m_histogramLateHoldoff));
ui->stroke->setToolTip(QString("Stroke: %1").arg(m_histogramStroke));
ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_displayGridIntensity));
m_glSpectrum->setDisplayWaterfall(m_displayWaterfall);
m_glSpectrum->setInvertedWaterfall(m_invertedWaterfall);
m_glSpectrum->setDisplayMaxHold(m_displayMaxHold);
@ -173,9 +188,32 @@ void GLSpectrumGUI::on_levelRange_currentIndexChanged(int index)
m_glSpectrum->setPowerRange(m_powerRange);
}
void GLSpectrumGUI::on_decay_currentIndexChanged(int index)
void GLSpectrumGUI::on_decay_valueChanged(int index)
{
m_decay = index - 2;
m_decay = index;
ui->decay->setToolTip(QString("Decay: %1").arg(m_decay));
if(m_glSpectrum != NULL)
m_glSpectrum->setDecay(m_decay);
}
void GLSpectrumGUI::on_holdoff_valueChanged(int index)
{
if (index < 1) {
return;
}
m_histogramLateHoldoff = index;
ui->holdoff->setToolTip(QString("Holdoff: %1").arg(m_histogramLateHoldoff));
if(m_glSpectrum != NULL)
m_glSpectrum->setDecay(m_decay);
}
void GLSpectrumGUI::on_stroke_valueChanged(int index)
{
if (index < 4) {
return;
}
m_histogramStroke = index;
ui->stroke->setToolTip(QString("Stroke: %1").arg(m_histogramStroke));
if(m_glSpectrum != NULL)
m_glSpectrum->setDecay(m_decay);
}
@ -218,6 +256,7 @@ void GLSpectrumGUI::on_grid_toggled(bool checked)
void GLSpectrumGUI::on_gridIntensity_valueChanged(int index)
{
m_displayGridIntensity = index;
ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_displayGridIntensity));
if(m_glSpectrum != NULL)
m_glSpectrum->setDisplayGridIntensity(m_displayGridIntensity);
}

View File

@ -217,107 +217,74 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QComboBox" name="decay">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Decay adjust</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>-2</string>
</property>
</item>
<item>
<property name="text">
<string>-1</string>
</property>
</item>
<item>
<property name="text">
<string>0</string>
</property>
</item>
<item>
<property name="text">
<string>+1</string>
</property>
</item>
<item>
<property name="text">
<string>+2</string>
</property>
</item>
<item>
<property name="text">
<string>+3</string>
</property>
</item>
<item>
<property name="text">
<string>+4</string>
</property>
</item>
<item>
<property name="text">
<string>+5</string>
</property>
</item>
<item>
<property name="text">
<string>+6</string>
</property>
</item>
<item>
<property name="text">
<string>+7</string>
</property>
</item>
<item>
<property name="text">
<string>+8</string>
</property>
</item>
<item>
<property name="text">
<string>+9</string>
</property>
</item>
<item>
<property name="text">
<string>+10</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1" colspan="3">
<item row="2" column="0" colspan="4">
<layout class="QHBoxLayout" name="controlBtns">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QDial" name="decay">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Decay:</string>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="holdoff">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Holdoff:</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="stroke">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Stroke:</string>
</property>
<property name="minimum">
<number>4</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="waterfall">
<property name="sizePolicy">
@ -534,7 +501,6 @@
<tabstop>fftSize</tabstop>
<tabstop>refLevel</tabstop>
<tabstop>levelRange</tabstop>
<tabstop>decay</tabstop>
<tabstop>waterfall</tabstop>
<tabstop>histogram</tabstop>
<tabstop>maxHold</tabstop>