mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
Spectrum markers: implemented marker serialization and deserialization
This commit is contained in:
parent
deafa0833b
commit
766647b754
@ -92,6 +92,7 @@ void GLSpectrumGUI::resetToDefaults()
|
|||||||
|
|
||||||
QByteArray GLSpectrumGUI::serialize() const
|
QByteArray GLSpectrumGUI::serialize() const
|
||||||
{
|
{
|
||||||
|
qDebug("GLSpectrumGUI::serialize: %p", m_glSpectrum);
|
||||||
return m_settings.serialize();
|
return m_settings.serialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
107
sdrgui/gui/spectrummarkers.cpp
Normal file
107
sdrgui/gui/spectrummarkers.cpp
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2021 Edouard Griffiths, F4EXB //
|
||||||
|
// //
|
||||||
|
// Symbol synchronizer or symbol clock recovery mostly encapsulating //
|
||||||
|
// liquid-dsp's symsync "object" //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// (at your option) any later version. //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "util/simpleserializer.h"
|
||||||
|
#include "spectrummarkers.h"
|
||||||
|
|
||||||
|
QByteArray SpectrumHistogramMarker::serialize() const
|
||||||
|
{
|
||||||
|
SimpleSerializer s(1);
|
||||||
|
|
||||||
|
s.writeFloat(1, m_frequency);
|
||||||
|
s.writeFloat(2, m_power);
|
||||||
|
s.writeS32(3, (int) m_markerType);
|
||||||
|
int r, g, b;
|
||||||
|
m_markerColor.getRgb(&r, &g, &b);
|
||||||
|
s.writeS32(4, r);
|
||||||
|
s.writeS32(5, g);
|
||||||
|
s.writeS32(6, b);
|
||||||
|
s.writeBool(7, m_show);
|
||||||
|
|
||||||
|
return s.final();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SpectrumHistogramMarker::deserialize(const QByteArray& data)
|
||||||
|
{
|
||||||
|
SimpleDeserializer d(data);
|
||||||
|
|
||||||
|
if (!d.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d.getVersion() == 1)
|
||||||
|
{
|
||||||
|
d.readFloat(1, &m_frequency, 0);
|
||||||
|
d.readFloat(2, &m_power, 0);
|
||||||
|
int r, g, b;
|
||||||
|
d.readS32(4, &r, 255);
|
||||||
|
d.readS32(5, &g, 255);
|
||||||
|
d.readS32(6, &b, 255);
|
||||||
|
d.readBool(7, &m_show);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray SpectrumWaterfallMarker::serialize() const
|
||||||
|
{
|
||||||
|
SimpleSerializer s(1);
|
||||||
|
|
||||||
|
s.writeFloat(1, m_frequency);
|
||||||
|
s.writeFloat(2, m_time);
|
||||||
|
int r, g, b;
|
||||||
|
m_markerColor.getRgb(&r, &g, &b);
|
||||||
|
s.writeS32(4, r);
|
||||||
|
s.writeS32(5, g);
|
||||||
|
s.writeS32(6, b);
|
||||||
|
s.writeBool(7, m_show);
|
||||||
|
|
||||||
|
return s.final();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SpectrumWaterfallMarker::deserialize(const QByteArray& data)
|
||||||
|
{
|
||||||
|
SimpleDeserializer d(data);
|
||||||
|
|
||||||
|
if (!d.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d.getVersion() == 1)
|
||||||
|
{
|
||||||
|
d.readFloat(1, &m_frequency, 0);
|
||||||
|
d.readFloat(2, &m_time, 0);
|
||||||
|
int r, g, b;
|
||||||
|
d.readS32(4, &r, 255);
|
||||||
|
d.readS32(5, &g, 255);
|
||||||
|
d.readS32(6, &b, 255);
|
||||||
|
d.readBool(7, &m_show);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -96,6 +96,9 @@ struct SpectrumHistogramMarker
|
|||||||
|
|
||||||
SpectrumHistogramMarker(const SpectrumHistogramMarker& other) = default;
|
SpectrumHistogramMarker(const SpectrumHistogramMarker& other) = default;
|
||||||
SpectrumHistogramMarker& operator=(const SpectrumHistogramMarker&) = default;
|
SpectrumHistogramMarker& operator=(const SpectrumHistogramMarker&) = default;
|
||||||
|
|
||||||
|
QByteArray serialize() const;
|
||||||
|
bool deserialize(const QByteArray& data);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SpectrumWaterfallMarker
|
struct SpectrumWaterfallMarker
|
||||||
@ -147,6 +150,9 @@ struct SpectrumWaterfallMarker
|
|||||||
|
|
||||||
SpectrumWaterfallMarker(const SpectrumWaterfallMarker& other) = default;
|
SpectrumWaterfallMarker(const SpectrumWaterfallMarker& other) = default;
|
||||||
SpectrumWaterfallMarker& operator=(const SpectrumWaterfallMarker&) = default;
|
SpectrumWaterfallMarker& operator=(const SpectrumWaterfallMarker&) = default;
|
||||||
|
|
||||||
|
QByteArray serialize() const;
|
||||||
|
bool deserialize(const QByteArray& data);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDE_SPECTRUMMARKERS_H
|
#endif // INCLUDE_SPECTRUMMARKERS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user