mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
Spectrum markers: implemented persistency (serialization/deserialization) using spectrum settings
This commit is contained in:
parent
ab314c814d
commit
79c1796cfe
@ -56,8 +56,12 @@ bool SpectrumHistogramMarker::deserialize(const QByteArray& data)
|
|||||||
m_markerType = (SpectrumMarkerType) tmp;
|
m_markerType = (SpectrumMarkerType) tmp;
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
d.readS32(4, &r, 255);
|
d.readS32(4, &r, 255);
|
||||||
|
m_markerColor.setRed(r);
|
||||||
d.readS32(5, &g, 255);
|
d.readS32(5, &g, 255);
|
||||||
|
m_markerColor.setGreen(g);
|
||||||
d.readS32(6, &b, 255);
|
d.readS32(6, &b, 255);
|
||||||
|
m_markerColor.setBlue(b);
|
||||||
|
|
||||||
d.readBool(7, &m_show);
|
d.readBool(7, &m_show);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -98,8 +102,11 @@ bool SpectrumWaterfallMarker::deserialize(const QByteArray& data)
|
|||||||
d.readFloat(2, &m_time, 0);
|
d.readFloat(2, &m_time, 0);
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
d.readS32(4, &r, 255);
|
d.readS32(4, &r, 255);
|
||||||
|
m_markerColor.setRed(r);
|
||||||
d.readS32(5, &g, 255);
|
d.readS32(5, &g, 255);
|
||||||
|
m_markerColor.setGreen(g);
|
||||||
d.readS32(6, &b, 255);
|
d.readS32(6, &b, 255);
|
||||||
|
m_markerColor.setBlue(b);
|
||||||
d.readBool(7, &m_show);
|
d.readBool(7, &m_show);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -86,6 +86,17 @@ QByteArray SpectrumSettings::serialize() const
|
|||||||
s.writeBool(24, m_ssb);
|
s.writeBool(24, m_ssb);
|
||||||
s.writeBool(25, m_usb);
|
s.writeBool(25, m_usb);
|
||||||
s.writeS32(26, m_fpsPeriodMs);
|
s.writeS32(26, m_fpsPeriodMs);
|
||||||
|
s.writeS32(100, m_histogramMarkers.size());
|
||||||
|
|
||||||
|
for (int i = 0; i < m_histogramMarkers.size(); i++) {
|
||||||
|
s.writeBlob(101+i, m_histogramMarkers[i].serialize());
|
||||||
|
}
|
||||||
|
|
||||||
|
s.writeS32(110, m_waterfallMarkers.size());
|
||||||
|
|
||||||
|
for (int i = 0; i < m_waterfallMarkers.size(); i++) {
|
||||||
|
s.writeBlob(111+i, m_waterfallMarkers[i].serialize());
|
||||||
|
}
|
||||||
|
|
||||||
return s.final();
|
return s.final();
|
||||||
}
|
}
|
||||||
@ -101,6 +112,7 @@ bool SpectrumSettings::deserialize(const QByteArray& data)
|
|||||||
|
|
||||||
int tmp;
|
int tmp;
|
||||||
uint32_t utmp;
|
uint32_t utmp;
|
||||||
|
QByteArray bytetmp;
|
||||||
|
|
||||||
if (d.getVersion() == 1)
|
if (d.getVersion() == 1)
|
||||||
{
|
{
|
||||||
@ -135,6 +147,35 @@ bool SpectrumSettings::deserialize(const QByteArray& data)
|
|||||||
d.readBool(25, &m_usb, true);
|
d.readBool(25, &m_usb, true);
|
||||||
d.readS32(26, &tmp, 50);
|
d.readS32(26, &tmp, 50);
|
||||||
m_fpsPeriodMs = tmp < 5 ? 5 : tmp > 500 ? 500 : tmp;
|
m_fpsPeriodMs = tmp < 5 ? 5 : tmp > 500 ? 500 : tmp;
|
||||||
|
int histogramMarkersSize;
|
||||||
|
|
||||||
|
d.readS32(100, &histogramMarkersSize, 0);
|
||||||
|
histogramMarkersSize = histogramMarkersSize < 0 ? 0 :
|
||||||
|
histogramMarkersSize > SpectrumHistogramMarker::m_maxNbOfMarkers ?
|
||||||
|
SpectrumHistogramMarker::m_maxNbOfMarkers : histogramMarkersSize;
|
||||||
|
m_histogramMarkers.clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < histogramMarkersSize; i++)
|
||||||
|
{
|
||||||
|
d.readBlob(101+i, &bytetmp);
|
||||||
|
m_histogramMarkers.push_back(SpectrumHistogramMarker());
|
||||||
|
m_histogramMarkers.back().deserialize(bytetmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
int waterfallMarkersSize;
|
||||||
|
|
||||||
|
d.readS32(110, &waterfallMarkersSize, 0);
|
||||||
|
waterfallMarkersSize = waterfallMarkersSize < 0 ? 0 :
|
||||||
|
waterfallMarkersSize > SpectrumWaterfallMarker::m_maxNbOfMarkers ?
|
||||||
|
SpectrumWaterfallMarker::m_maxNbOfMarkers : waterfallMarkersSize;
|
||||||
|
m_waterfallMarkers.clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < waterfallMarkersSize; i++)
|
||||||
|
{
|
||||||
|
d.readBlob(111+i, &bytetmp);
|
||||||
|
m_waterfallMarkers.push_back(SpectrumWaterfallMarker());
|
||||||
|
m_waterfallMarkers.back().deserialize(bytetmp);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,8 @@ public:
|
|||||||
bool m_usb; //!< USB display with increasing frequencies towads the right - else decreasing frequencies
|
bool m_usb; //!< USB display with increasing frequencies towads the right - else decreasing frequencies
|
||||||
QString m_wsSpectrumAddress;
|
QString m_wsSpectrumAddress;
|
||||||
uint16_t m_wsSpectrumPort;
|
uint16_t m_wsSpectrumPort;
|
||||||
|
QList<SpectrumHistogramMarker> m_histogramMarkers;
|
||||||
|
QList<SpectrumWaterfallMarker> m_waterfallMarkers;
|
||||||
static const int m_log2FFTSizeMin = 6; // 64
|
static const int m_log2FFTSizeMin = 6; // 64
|
||||||
static const int m_log2FFTSizeMax = 15; // 32k
|
static const int m_log2FFTSizeMax = 15; // 32k
|
||||||
|
|
||||||
@ -80,6 +82,9 @@ public:
|
|||||||
virtual QByteArray serialize() const;
|
virtual QByteArray serialize() const;
|
||||||
virtual bool deserialize(const QByteArray& data);
|
virtual bool deserialize(const QByteArray& data);
|
||||||
|
|
||||||
|
QList<SpectrumHistogramMarker>& getHistogramMarkers() { return m_histogramMarkers; }
|
||||||
|
QList<SpectrumWaterfallMarker>& getWaterfallMarkers() { return m_waterfallMarkers; }
|
||||||
|
|
||||||
static int getAveragingMaxScale(AveragingMode averagingMode); //!< Max power of 10 multiplier to 2,5,10 base ex: 2 -> 2,5,10,20,50,100,200,500,1000
|
static int getAveragingMaxScale(AveragingMode averagingMode); //!< Max power of 10 multiplier to 2,5,10 base ex: 2 -> 2,5,10,20,50,100,200,500,1000
|
||||||
static int getAveragingValue(int averagingIndex, AveragingMode averagingMode);
|
static int getAveragingValue(int averagingIndex, AveragingMode averagingMode);
|
||||||
static int getAveragingIndex(int averagingValue, AveragingMode averagingMode);
|
static int getAveragingIndex(int averagingValue, AveragingMode averagingMode);
|
||||||
|
@ -1171,6 +1171,10 @@ void GLSpectrum::paintGL()
|
|||||||
|
|
||||||
void GLSpectrum::drawSpectrumMarkers()
|
void GLSpectrum::drawSpectrumMarkers()
|
||||||
{
|
{
|
||||||
|
if (!m_currentSpectrum) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QVector4D lineColor(1.0f, 1.0f, 1.0f, 0.3f);
|
QVector4D lineColor(1.0f, 1.0f, 1.0f, 0.3f);
|
||||||
|
|
||||||
// paint histogram markers
|
// paint histogram markers
|
||||||
@ -2090,7 +2094,6 @@ void GLSpectrum::updateHistogramMarkers()
|
|||||||
m_histogramMarkers[i].m_fftBin = m_histogramMarkers[i].m_fftBin < 0 ?
|
m_histogramMarkers[i].m_fftBin = m_histogramMarkers[i].m_fftBin < 0 ?
|
||||||
0 : m_histogramMarkers[i].m_fftBin > m_fftSize - 1 ?
|
0 : m_histogramMarkers[i].m_fftBin > m_fftSize - 1 ?
|
||||||
m_fftSize - 1 : m_histogramMarkers[i].m_fftBin;
|
m_fftSize - 1 : m_histogramMarkers[i].m_fftBin;
|
||||||
qDebug("GLSpectrum::updateHistogramMarkers: %d: m_fftBin: %d", i, m_histogramMarkers[i].m_fftBin);
|
|
||||||
m_histogramMarkers[i].m_frequencyStr = displayScaled(
|
m_histogramMarkers[i].m_frequencyStr = displayScaled(
|
||||||
m_histogramMarkers[i].m_frequency,
|
m_histogramMarkers[i].m_frequency,
|
||||||
'f',
|
'f',
|
||||||
|
@ -92,6 +92,8 @@ void GLSpectrumGUI::resetToDefaults()
|
|||||||
|
|
||||||
QByteArray GLSpectrumGUI::serialize() const
|
QByteArray GLSpectrumGUI::serialize() const
|
||||||
{
|
{
|
||||||
|
const_cast<GLSpectrumGUI*>(this)->m_settings.getHistogramMarkers() = m_glSpectrum->getHistogramMarkers();
|
||||||
|
const_cast<GLSpectrumGUI*>(this)->m_settings.getWaterfallMarkers() = m_glSpectrum->getWaterfallMarkers();
|
||||||
return m_settings.serialize();
|
return m_settings.serialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,6 +101,8 @@ bool GLSpectrumGUI::deserialize(const QByteArray& data)
|
|||||||
{
|
{
|
||||||
if (m_settings.deserialize(data))
|
if (m_settings.deserialize(data))
|
||||||
{
|
{
|
||||||
|
m_glSpectrum->setHistogramMarkers(m_settings.getHistogramMarkers());
|
||||||
|
m_glSpectrum->setWaterfallMarkers(m_settings.getWaterfallMarkers());
|
||||||
setAveragingCombo();
|
setAveragingCombo();
|
||||||
displaySettings(); // ends with blockApplySettings(false)
|
displaySettings(); // ends with blockApplySettings(false)
|
||||||
applySettings();
|
applySettings();
|
||||||
|
Loading…
Reference in New Issue
Block a user