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.
SWGGLSpectrum.cpp
Go to the documentation of this file.
1 
14 #include "SWGGLSpectrum.h"
15 
16 #include "SWGHelpers.h"
17 
18 #include <QJsonDocument>
19 #include <QJsonArray>
20 #include <QObject>
21 #include <QDebug>
22 
23 namespace SWGSDRangel {
24 
26  init();
27  this->fromJson(*json);
28 }
29 
31  fft_size = 0;
32  m_fft_size_isSet = false;
33  fft_overlap = 0;
34  m_fft_overlap_isSet = false;
35  m_fft_window = 0;
36  m_m_fft_window_isSet = false;
37  ref_level = 0.0f;
38  m_ref_level_isSet = false;
39  power_range = 0.0f;
40  m_power_range_isSet = false;
45  display_max_hold = 0;
49  decay = 0;
50  m_decay_isSet = false;
51  display_grid = 0;
52  m_display_grid_isSet = false;
53  invert = 0;
54  m_invert_isSet = false;
57  decay_divisor = 0;
58  m_decay_divisor_isSet = false;
59  histogram_stroke = 0;
61  display_current = 0;
65  waterfall_share = 0.0f;
67  averaging_mode = 0;
68  m_averaging_mode_isSet = false;
69  averaging_value = 0;
71  linear = 0;
72  m_linear_isSet = false;
73 }
74 
76  this->cleanup();
77 }
78 
79 void
81  fft_size = 0;
82  m_fft_size_isSet = false;
83  fft_overlap = 0;
84  m_fft_overlap_isSet = false;
85  m_fft_window = 0;
86  m_m_fft_window_isSet = false;
87  ref_level = 0.0f;
88  m_ref_level_isSet = false;
89  power_range = 0.0f;
90  m_power_range_isSet = false;
95  display_max_hold = 0;
99  decay = 0;
100  m_decay_isSet = false;
101  display_grid = 0;
102  m_display_grid_isSet = false;
103  invert = 0;
104  m_invert_isSet = false;
107  decay_divisor = 0;
108  m_decay_divisor_isSet = false;
109  histogram_stroke = 0;
110  m_histogram_stroke_isSet = false;
111  display_current = 0;
112  m_display_current_isSet = false;
115  waterfall_share = 0.0f;
116  m_waterfall_share_isSet = false;
117  averaging_mode = 0;
118  m_averaging_mode_isSet = false;
119  averaging_value = 0;
120  m_averaging_value_isSet = false;
121  linear = 0;
122  m_linear_isSet = false;
123 }
124 
125 void
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 }
149 
151 SWGGLSpectrum::fromJson(QString &json) {
152  QByteArray array (json.toStdString().c_str());
153  QJsonDocument doc = QJsonDocument::fromJson(array);
154  QJsonObject jsonObject = doc.object();
155  this->fromJsonObject(jsonObject);
156  return this;
157 }
158 
159 void
160 SWGGLSpectrum::fromJsonObject(QJsonObject &pJson) {
161  ::SWGSDRangel::setValue(&fft_size, pJson["fftSize"], "qint32", "");
162 
163  ::SWGSDRangel::setValue(&fft_overlap, pJson["fftOverlap"], "qint32", "");
164 
165  ::SWGSDRangel::setValue(&m_fft_window, pJson["m_fftWindow"], "qint32", "");
166 
167  ::SWGSDRangel::setValue(&ref_level, pJson["refLevel"], "float", "");
168 
169  ::SWGSDRangel::setValue(&power_range, pJson["powerRange"], "float", "");
170 
171  ::SWGSDRangel::setValue(&display_waterfall, pJson["displayWaterfall"], "qint32", "");
172 
173  ::SWGSDRangel::setValue(&inverted_waterfall, pJson["invertedWaterfall"], "qint32", "");
174 
175  ::SWGSDRangel::setValue(&display_max_hold, pJson["displayMaxHold"], "qint32", "");
176 
177  ::SWGSDRangel::setValue(&display_histogram, pJson["displayHistogram"], "qint32", "");
178 
179  ::SWGSDRangel::setValue(&decay, pJson["decay"], "qint32", "");
180 
181  ::SWGSDRangel::setValue(&display_grid, pJson["displayGrid"], "qint32", "");
182 
183  ::SWGSDRangel::setValue(&invert, pJson["invert"], "qint32", "");
184 
185  ::SWGSDRangel::setValue(&display_grid_intensity, pJson["displayGridIntensity"], "qint32", "");
186 
187  ::SWGSDRangel::setValue(&decay_divisor, pJson["decayDivisor"], "qint32", "");
188 
189  ::SWGSDRangel::setValue(&histogram_stroke, pJson["histogramStroke"], "qint32", "");
190 
191  ::SWGSDRangel::setValue(&display_current, pJson["displayCurrent"], "qint32", "");
192 
193  ::SWGSDRangel::setValue(&display_trace_intensity, pJson["displayTraceIntensity"], "qint32", "");
194 
195  ::SWGSDRangel::setValue(&waterfall_share, pJson["waterfallShare"], "float", "");
196 
197  ::SWGSDRangel::setValue(&averaging_mode, pJson["averagingMode"], "qint32", "");
198 
199  ::SWGSDRangel::setValue(&averaging_value, pJson["averagingValue"], "qint32", "");
200 
201  ::SWGSDRangel::setValue(&linear, pJson["linear"], "qint32", "");
202 
203 }
204 
205 QString
207 {
208  QJsonObject* obj = this->asJsonObject();
209 
210  QJsonDocument doc(*obj);
211  QByteArray bytes = doc.toJson();
212  delete obj;
213  return QString(bytes);
214 }
215 
216 QJsonObject*
218  QJsonObject* obj = new QJsonObject();
219  if(m_fft_size_isSet){
220  obj->insert("fftSize", QJsonValue(fft_size));
221  }
223  obj->insert("fftOverlap", QJsonValue(fft_overlap));
224  }
226  obj->insert("m_fftWindow", QJsonValue(m_fft_window));
227  }
228  if(m_ref_level_isSet){
229  obj->insert("refLevel", QJsonValue(ref_level));
230  }
232  obj->insert("powerRange", QJsonValue(power_range));
233  }
235  obj->insert("displayWaterfall", QJsonValue(display_waterfall));
236  }
238  obj->insert("invertedWaterfall", QJsonValue(inverted_waterfall));
239  }
241  obj->insert("displayMaxHold", QJsonValue(display_max_hold));
242  }
244  obj->insert("displayHistogram", QJsonValue(display_histogram));
245  }
246  if(m_decay_isSet){
247  obj->insert("decay", QJsonValue(decay));
248  }
250  obj->insert("displayGrid", QJsonValue(display_grid));
251  }
252  if(m_invert_isSet){
253  obj->insert("invert", QJsonValue(invert));
254  }
256  obj->insert("displayGridIntensity", QJsonValue(display_grid_intensity));
257  }
259  obj->insert("decayDivisor", QJsonValue(decay_divisor));
260  }
262  obj->insert("histogramStroke", QJsonValue(histogram_stroke));
263  }
265  obj->insert("displayCurrent", QJsonValue(display_current));
266  }
268  obj->insert("displayTraceIntensity", QJsonValue(display_trace_intensity));
269  }
271  obj->insert("waterfallShare", QJsonValue(waterfall_share));
272  }
274  obj->insert("averagingMode", QJsonValue(averaging_mode));
275  }
277  obj->insert("averagingValue", QJsonValue(averaging_value));
278  }
279  if(m_linear_isSet){
280  obj->insert("linear", QJsonValue(linear));
281  }
282 
283  return obj;
284 }
285 
286 qint32
288  return fft_size;
289 }
290 void
292  this->fft_size = fft_size;
293  this->m_fft_size_isSet = true;
294 }
295 
296 qint32
298  return fft_overlap;
299 }
300 void
302  this->fft_overlap = fft_overlap;
303  this->m_fft_overlap_isSet = true;
304 }
305 
306 qint32
308  return m_fft_window;
309 }
310 void
312  this->m_fft_window = m_fft_window;
313  this->m_m_fft_window_isSet = true;
314 }
315 
316 float
318  return ref_level;
319 }
320 void
322  this->ref_level = ref_level;
323  this->m_ref_level_isSet = true;
324 }
325 
326 float
328  return power_range;
329 }
330 void
332  this->power_range = power_range;
333  this->m_power_range_isSet = true;
334 }
335 
336 qint32
338  return display_waterfall;
339 }
340 void
342  this->display_waterfall = display_waterfall;
343  this->m_display_waterfall_isSet = true;
344 }
345 
346 qint32
348  return inverted_waterfall;
349 }
350 void
352  this->inverted_waterfall = inverted_waterfall;
353  this->m_inverted_waterfall_isSet = true;
354 }
355 
356 qint32
358  return display_max_hold;
359 }
360 void
362  this->display_max_hold = display_max_hold;
363  this->m_display_max_hold_isSet = true;
364 }
365 
366 qint32
368  return display_histogram;
369 }
370 void
372  this->display_histogram = display_histogram;
373  this->m_display_histogram_isSet = true;
374 }
375 
376 qint32
378  return decay;
379 }
380 void
382  this->decay = decay;
383  this->m_decay_isSet = true;
384 }
385 
386 qint32
388  return display_grid;
389 }
390 void
392  this->display_grid = display_grid;
393  this->m_display_grid_isSet = true;
394 }
395 
396 qint32
398  return invert;
399 }
400 void
402  this->invert = invert;
403  this->m_invert_isSet = true;
404 }
405 
406 qint32
408  return display_grid_intensity;
409 }
410 void
412  this->display_grid_intensity = display_grid_intensity;
413  this->m_display_grid_intensity_isSet = true;
414 }
415 
416 qint32
418  return decay_divisor;
419 }
420 void
422  this->decay_divisor = decay_divisor;
423  this->m_decay_divisor_isSet = true;
424 }
425 
426 qint32
428  return histogram_stroke;
429 }
430 void
432  this->histogram_stroke = histogram_stroke;
433  this->m_histogram_stroke_isSet = true;
434 }
435 
436 qint32
438  return display_current;
439 }
440 void
442  this->display_current = display_current;
443  this->m_display_current_isSet = true;
444 }
445 
446 qint32
449 }
450 void
452  this->display_trace_intensity = display_trace_intensity;
453  this->m_display_trace_intensity_isSet = true;
454 }
455 
456 float
458  return waterfall_share;
459 }
460 void
462  this->waterfall_share = waterfall_share;
463  this->m_waterfall_share_isSet = true;
464 }
465 
466 qint32
468  return averaging_mode;
469 }
470 void
472  this->averaging_mode = averaging_mode;
473  this->m_averaging_mode_isSet = true;
474 }
475 
476 qint32
478  return averaging_value;
479 }
480 void
482  this->averaging_value = averaging_value;
483  this->m_averaging_value_isSet = true;
484 }
485 
486 qint32
488  return linear;
489 }
490 void
492  this->linear = linear;
493  this->m_linear_isSet = true;
494 }
495 
496 
497 bool
499  bool isObjectUpdated = false;
500  do{
501  if(m_fft_size_isSet){ isObjectUpdated = true; break;}
502  if(m_fft_overlap_isSet){ isObjectUpdated = true; break;}
503  if(m_m_fft_window_isSet){ isObjectUpdated = true; break;}
504  if(m_ref_level_isSet){ isObjectUpdated = true; break;}
505  if(m_power_range_isSet){ isObjectUpdated = true; break;}
506  if(m_display_waterfall_isSet){ isObjectUpdated = true; break;}
507  if(m_inverted_waterfall_isSet){ isObjectUpdated = true; break;}
508  if(m_display_max_hold_isSet){ isObjectUpdated = true; break;}
509  if(m_display_histogram_isSet){ isObjectUpdated = true; break;}
510  if(m_decay_isSet){ isObjectUpdated = true; break;}
511  if(m_display_grid_isSet){ isObjectUpdated = true; break;}
512  if(m_invert_isSet){ isObjectUpdated = true; break;}
513  if(m_display_grid_intensity_isSet){ isObjectUpdated = true; break;}
514  if(m_decay_divisor_isSet){ isObjectUpdated = true; break;}
515  if(m_histogram_stroke_isSet){ isObjectUpdated = true; break;}
516  if(m_display_current_isSet){ isObjectUpdated = true; break;}
517  if(m_display_trace_intensity_isSet){ isObjectUpdated = true; break;}
518  if(m_waterfall_share_isSet){ isObjectUpdated = true; break;}
519  if(m_averaging_mode_isSet){ isObjectUpdated = true; break;}
520  if(m_averaging_value_isSet){ isObjectUpdated = true; break;}
521  if(m_linear_isSet){ isObjectUpdated = true; break;}
522  }while(false);
523  return isObjectUpdated;
524 }
525 }
526 
void setLinear(qint32 linear)
void setInvert(qint32 invert)
void setDisplayWaterfall(qint32 display_waterfall)
virtual QString asJson() override
virtual QJsonObject * asJsonObject() override
void setRefLevel(float ref_level)
void setAveragingValue(qint32 averaging_value)
virtual bool isSet() override
void setFftSize(qint32 fft_size)
void setDisplayTraceIntensity(qint32 display_trace_intensity)
void setDisplayCurrent(qint32 display_current)
void setWaterfallShare(float waterfall_share)
void setDecayDivisor(qint32 decay_divisor)
void setInvertedWaterfall(qint32 inverted_waterfall)
void setDecay(qint32 decay)
virtual void fromJsonObject(QJsonObject &json) override
void setAveragingMode(qint32 averaging_mode)
void setMFftWindow(qint32 m_fft_window)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setFftOverlap(qint32 fft_overlap)
void setDisplayGrid(qint32 display_grid)
void setPowerRange(float power_range)
void setDisplayHistogram(qint32 display_histogram)
void setDisplayGridIntensity(qint32 display_grid_intensity)
void setDisplayMaxHold(qint32 display_max_hold)
virtual SWGGLSpectrum * fromJson(QString &jsonString) override
void setHistogramStroke(qint32 histogram_stroke)