SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
channelmarker.cpp
Go to the documentation of this file.
1 #include "dsp/channelmarker.h"
3 
5  qRgb(0xc0, 0x00, 0x00),
6  qRgb(0x00, 0xc0, 0x00),
7  qRgb(0x00, 0x00, 0xc0),
8 
9  qRgb(0xc0, 0xc0, 0x00),
10  qRgb(0xc0, 0x00, 0xc0),
11  qRgb(0x00, 0xc0, 0xc0),
12 
13  qRgb(0xc0, 0x60, 0x00),
14  qRgb(0xc0, 0x00, 0x60),
15  qRgb(0x60, 0x00, 0xc0),
16 
17  qRgb(0x60, 0x00, 0x00),
18  qRgb(0x00, 0x60, 0x00),
19  qRgb(0x00, 0x00, 0x60),
20 
21  qRgb(0x60, 0x60, 0x00),
22  qRgb(0x60, 0x00, 0x60),
23  qRgb(0x00, 0x60, 0x60),
24 
25  0
26 };
28 
29 ChannelMarker::ChannelMarker(QObject* parent) :
30  QObject(parent),
31  m_centerFrequency(0),
32  m_bandwidth(0),
33  m_oppositeBandwidth(0),
34  m_lowCutoff(0),
35  m_sidebands(dsb),
36  m_visible(false),
37  m_highlighted(false),
38  m_color(m_colorTable[m_nextColor]),
39  m_movable(true),
40  m_fScaleDisplayType(FScaleDisplay_freq),
41  m_sourceOrSinkStream(true),
42  m_streamIndex(0)
43 {
44  ++m_nextColor;
45  if(m_colorTable[m_nextColor] == 0)
46  m_nextColor = 0;
47 }
48 
50 {
51  emit changedByAPI();
52 }
53 
54 void ChannelMarker::setTitle(const QString& title)
55 {
56  m_title = title;
57  emit changedByAPI();
58 }
59 
60 void ChannelMarker::setCenterFrequency(int centerFrequency)
61 {
62  m_centerFrequency = centerFrequency;
63  emit changedByAPI();
64 }
65 
67 {
68  m_centerFrequency = centerFrequency;
69  emit changedByCursor();
70 }
71 
72 void ChannelMarker::setBandwidth(int bandwidth)
73 {
74  m_bandwidth = bandwidth;
75  emit changedByAPI();
76 }
77 
79 {
80  m_oppositeBandwidth = bandwidth;
81  emit changedByAPI();
82 }
83 
84 void ChannelMarker::setLowCutoff(int lowCutoff)
85 {
86  m_lowCutoff = lowCutoff;
87  emit changedByAPI();
88 }
89 
91 {
92  m_sidebands = sidebands;
93  emit changedByAPI();
94 }
95 
96 void ChannelMarker::setVisible(bool visible)
97 {
98  m_visible = visible;
99  emit changedByAPI();
100 }
101 
102 void ChannelMarker::setHighlighted(bool highlighted)
103 {
104  m_highlighted = highlighted;
105  emit changedByAPI();
106 }
107 
109 {
110  m_highlighted = highlighted;
111  emit highlightedByCursor();
112 }
113 
114 void ChannelMarker::setColor(const QColor& color)
115 {
116  m_color = color;
117  emit changedByAPI();
118 }
119 
121 {
122  setTitle("Channel");
124  setColor(Qt::white);
126 }
127 
128 QByteArray ChannelMarker::serialize() const
129 {
130  SimpleSerializer s(1);
132  s.writeU32(2, getColor().rgb());
133  s.writeString(3, getTitle());
135  return s.final();
136 }
137 
138 bool ChannelMarker::deserialize(const QByteArray& data)
139 {
140  SimpleDeserializer d(data);
141 
142  if(!d.isValid())
143  {
144  resetToDefaults();
145  return false;
146  }
147 
148  if(d.getVersion() == 1)
149  {
150  quint32 u32tmp;
151  qint32 tmp;
152  QString strtmp;
153 
154  blockSignals(true);
155 
156  d.readS32(1, &tmp, 0);
157  setCenterFrequency(tmp);
158  if(d.readU32(2, &u32tmp)) {
159  setColor(u32tmp);
160  }
161  d.readString(3, &strtmp, "Channel");
162  setTitle(strtmp);
163  d.readS32(7, &tmp, 0);
164  if ((tmp >= 0) && (tmp < FScaleDisplay_none)) {
166  } else {
168  }
169 
170  blockSignals(false);
171 
172  return true;
173  }
174  else
175  {
176  resetToDefaults();
177  return false;
178  }
179 }
180 
enum ChannelMarker::frequencyScaleDisplay_e frequencyScaleDisplay_t
ChannelMarker(QObject *parent=NULL)
int getCenterFrequency() const
Definition: channelmarker.h:42
void setLowCutoff(int lowCutoff)
virtual QByteArray serialize() const
sidebands_t m_sidebands
Definition: channelmarker.h:94
frequencyScaleDisplay_t getFrequencyScaleDisplayType() const
Definition: channelmarker.h:70
QString m_title
Definition: channelmarker.h:87
void setFrequencyScaleDisplayType(frequencyScaleDisplay_t type)
Definition: channelmarker.h:69
void emitChangedByAPI()
void setOppositeBandwidth(int bandwidth)
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
bool readString(quint32 id, QString *result, const QString &def=QString::null) const
static QRgb m_colorTable[]
Definition: channelmarker.h:84
bool isValid() const
void resetToDefaults()
virtual bool deserialize(const QByteArray &data)
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
void setHighlighted(bool highlighted)
const QString & getTitle() const
Definition: channelmarker.h:38
enum ChannelMarker::sidebands_e sidebands_t
void writeS32(quint32 id, qint32 value)
void highlightedByCursor()
quint32 getVersion() const
static int m_nextColor
Definition: channelmarker.h:85
void writeU32(quint32 id, quint32 value)
void setCenterFrequencyByCursor(int centerFrequency)
void setColor(const QColor &color)
void setVisible(bool visible)
void setBandwidth(int bandwidth)
const QColor & getColor() const
Definition: channelmarker.h:64
void setTitle(const QString &title)
int m_oppositeBandwidth
Definition: channelmarker.h:92
void setHighlightedByCursor(bool highlighted)
void setCenterFrequency(int centerFrequency)
void setSidebands(sidebands_t sidebands)
void writeString(quint32 id, const QString &value)
const QByteArray & final()
void changedByAPI()
void changedByCursor()