Added trace intensity control to spectrum analyzer

This commit is contained in:
f4exb 2015-07-18 17:53:57 +02:00
parent 15a5afad55
commit ad8be9875e
5 changed files with 199 additions and 199 deletions

View File

@ -48,6 +48,7 @@ public:
void setDisplayHistogram(bool display);
void setDisplayGrid(bool display);
void setDisplayGridIntensity(int intensity);
void setDisplayTraceIntensity(int intensity);
void addChannelMarker(ChannelMarker* channelMarker);
void removeChannelMarker(ChannelMarker* channelMarker);
@ -95,6 +96,7 @@ private:
bool m_displayGrid;
int m_displayGridIntensity;
int m_displayTraceIntensity;
bool m_invertedWaterfall;
std::vector<Real> m_maxHold;

View File

@ -42,6 +42,7 @@ private:
int m_histogramLateHoldoff;
int m_histogramStroke;
int m_displayGridIntensity;
int m_displayTraceIntensity;
bool m_displayWaterfall;
bool m_invertedWaterfall;
bool m_displayMaxHold;
@ -61,6 +62,7 @@ private slots:
void on_holdoff_valueChanged(int index);
void on_stroke_valueChanged(int index);
void on_gridIntensity_valueChanged(int index);
void on_traceIntensity_valueChanged(int index);
void on_waterfall_toggled(bool checked);
void on_histogram_toggled(bool checked);

View File

@ -34,6 +34,7 @@ GLSpectrum::GLSpectrum(QWidget* parent) :
m_fftSize(512),
m_displayGrid(true),
m_displayGridIntensity(5),
m_displayTraceIntensity(50),
m_invertedWaterfall(false),
m_displayMaxHold(false),
m_currentSpectrum(0),
@ -260,6 +261,19 @@ void GLSpectrum::setDisplayGridIntensity(int intensity)
m_displayGridIntensity = intensity;
if (m_displayGridIntensity > 100) {
m_displayGridIntensity = 100;
} else if (m_displayGridIntensity < 0) {
m_displayGridIntensity = 0;
}
update();
}
void GLSpectrum::setDisplayTraceIntensity(int intensity)
{
m_displayTraceIntensity = intensity;
if (m_displayTraceIntensity > 100) {
m_displayTraceIntensity = 100;
} else if (m_displayTraceIntensity < 0) {
m_displayTraceIntensity = 0;
}
update();
}
@ -768,7 +782,7 @@ void GLSpectrum::paintGL()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glLineWidth(1.0f);
glColor3f(1, 0, 0);
glColor4f(1, 0, 0, m_displayTraceIntensity / 100.0);
Real bottom = -m_powerRange;
glBegin(GL_LINE_STRIP);
for(int i = 0; i < m_fftSize; i++) {
@ -793,7 +807,7 @@ void GLSpectrum::paintGL()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glLineWidth(1.0f);
glColor3f(1.0f, 1.0f, 0.25f); // intense yellow
glColor4f(1.0f, 1.0f, 0.25f, m_displayTraceIntensity / 100.0); // intense yellow
Real bottom = -m_powerRange;
glBegin(GL_LINE_STRIP);
for(int i = 0; i < m_fftSize; i++) {

View File

@ -19,7 +19,8 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) :
m_decay(0),
m_histogramLateHoldoff(1),
m_histogramStroke(40),
m_displayGridIntensity(1),
m_displayGridIntensity(5),
m_displayTraceIntensity(50),
m_displayWaterfall(true),
m_invertedWaterfall(false),
m_displayMaxHold(false),
@ -87,6 +88,7 @@ QByteArray GLSpectrumGUI::serialize() const
s.writeS32(14, m_histogramLateHoldoff);
s.writeS32(15, m_histogramStroke);
s.writeBool(16, m_displayCurrent);
s.writeS32(17, m_displayTraceIntensity);
return s.final();
}
@ -112,10 +114,11 @@ bool GLSpectrumGUI::deserialize(const QByteArray& data)
d.readS32(10, &m_decay, 0);
d.readBool(11, &m_displayGrid, false);
d.readBool(12, &m_invert, true);
d.readS32(13, &m_displayGridIntensity, 0);
d.readS32(13, &m_displayGridIntensity, 5);
d.readS32(14, &m_histogramLateHoldoff, 1);
d.readS32(15, &m_histogramStroke, 40);
d.readBool(16, &m_displayCurrent, false);
d.readS32(17, &m_displayTraceIntensity, 50);
applySettings();
return true;
} else {
@ -150,6 +153,7 @@ void GLSpectrumGUI::applySettings()
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));
ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(m_displayTraceIntensity));
m_glSpectrum->setDisplayWaterfall(m_displayWaterfall);
m_glSpectrum->setInvertedWaterfall(m_invertedWaterfall);
@ -276,3 +280,11 @@ void GLSpectrumGUI::on_gridIntensity_valueChanged(int index)
if(m_glSpectrum != NULL)
m_glSpectrum->setDisplayGridIntensity(m_displayGridIntensity);
}
void GLSpectrumGUI::on_traceIntensity_valueChanged(int index)
{
m_displayTraceIntensity = index;
ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(m_displayTraceIntensity));
if(m_glSpectrum != NULL)
m_glSpectrum->setDisplayTraceIntensity(m_displayTraceIntensity);
}

View File

@ -7,13 +7,13 @@
<x>0</x>
<y>0</y>
<width>273</width>
<height>94</height>
<height>60</height>
</rect>
</property>
<property name="windowTitle">
<string>Oscilloscope</string>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0,0">
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0">
<property name="leftMargin">
<number>2</number>
</property>
@ -29,195 +29,7 @@
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="1">
<widget class="QLabel" name="label_18">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FFT Size</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="fftSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>FFT window function</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>128</string>
</property>
</item>
<item>
<property name="text">
<string>256</string>
</property>
</item>
<item>
<property name="text">
<string>512</string>
</property>
</item>
<item>
<property name="text">
<string>1k</string>
</property>
</item>
<item>
<property name="text">
<string>2k</string>
</property>
</item>
<item>
<property name="text">
<string>4k</string>
</property>
</item>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_20">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Range (dB)</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_17">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Window</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_19">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ref (dB)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="fftWindow">
<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>FFT window function</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>Bartlett</string>
</property>
</item>
<item>
<property name="text">
<string>Blackman-Harris</string>
</property>
</item>
<item>
<property name="text">
<string>Flat Top</string>
</property>
</item>
<item>
<property name="text">
<string>Hamming</string>
</property>
</item>
<item>
<property name="text">
<string>Hanning</string>
</property>
</item>
<item>
<property name="text">
<string>Rectangle</string>
</property>
</item>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="refLevel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>FFT window function</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QComboBox" name="levelRange">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>FFT window function</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="2" column="0" colspan="4">
<item row="3" column="0" colspan="3">
<layout class="QHBoxLayout" name="controlBtns">
<property name="spacing">
<number>3</number>
@ -522,6 +334,168 @@
</item>
</layout>
</item>
<item row="2" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="fftWindow">
<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>FFT window function</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>Bartlett</string>
</property>
</item>
<item>
<property name="text">
<string>Blackman-Harris</string>
</property>
</item>
<item>
<property name="text">
<string>Flat Top</string>
</property>
</item>
<item>
<property name="text">
<string>Hamming</string>
</property>
</item>
<item>
<property name="text">
<string>Hanning</string>
</property>
</item>
<item>
<property name="text">
<string>Rectangle</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="fftSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>FFT size</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>128</string>
</property>
</item>
<item>
<property name="text">
<string>256</string>
</property>
</item>
<item>
<property name="text">
<string>512</string>
</property>
</item>
<item>
<property name="text">
<string>1k</string>
</property>
</item>
<item>
<property name="text">
<string>2k</string>
</property>
</item>
<item>
<property name="text">
<string>4k</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="refLevel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Reference level</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="levelRange">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Range</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="traceIntensity">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Trace intensity</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>50</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
@ -532,10 +506,6 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>fftWindow</tabstop>
<tabstop>fftSize</tabstop>
<tabstop>refLevel</tabstop>
<tabstop>levelRange</tabstop>
<tabstop>histogram</tabstop>
<tabstop>maxHold</tabstop>
<tabstop>invert</tabstop>