1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008-2013 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef SPECTRUM_UPDATE_EVENTS_C
24 #define SPECTRUM_UPDATE_EVENTS_C
25 
26 #include <gnuradio/qtgui/spectrumUpdateEvents.h>
27 
SpectrumUpdateEvent(const float * fftPoints,const uint64_t numFFTDataPoints,const double * realTimeDomainPoints,const double * imagTimeDomainPoints,const uint64_t numTimeDomainDataPoints,const gr::high_res_timer_type dataTimestamp,const bool repeatDataFlag,const bool lastOfMultipleUpdateFlag,const gr::high_res_timer_type generatedTimestamp,const int droppedFFTFrames)28 SpectrumUpdateEvent::SpectrumUpdateEvent(const float* fftPoints,
29                                          const uint64_t numFFTDataPoints,
30                                          const double* realTimeDomainPoints,
31                                          const double* imagTimeDomainPoints,
32                                          const uint64_t numTimeDomainDataPoints,
33                                          const gr::high_res_timer_type dataTimestamp,
34                                          const bool repeatDataFlag,
35                                          const bool lastOfMultipleUpdateFlag,
36                                          const gr::high_res_timer_type generatedTimestamp,
37                                          const int droppedFFTFrames)
38     : QEvent(QEvent::Type(SpectrumUpdateEventType))
39 {
40     if (numFFTDataPoints < 1) {
41         _numFFTDataPoints = 1;
42     } else {
43         _numFFTDataPoints = numFFTDataPoints;
44     }
45 
46     if (numTimeDomainDataPoints < 1) {
47         _numTimeDomainDataPoints = 1;
48     } else {
49         _numTimeDomainDataPoints = numTimeDomainDataPoints;
50     }
51 
52     _fftPoints = new float[_numFFTDataPoints];
53     _fftPoints[0] = 0;
54     memcpy(_fftPoints, fftPoints, numFFTDataPoints * sizeof(float));
55 
56     _realDataTimeDomainPoints = new double[_numTimeDomainDataPoints];
57     memset(_realDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints * sizeof(double));
58     if (numTimeDomainDataPoints > 0) {
59         memcpy(_realDataTimeDomainPoints,
60                realTimeDomainPoints,
61                numTimeDomainDataPoints * sizeof(double));
62     }
63 
64     _imagDataTimeDomainPoints = new double[_numTimeDomainDataPoints];
65     memset(_imagDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints * sizeof(double));
66     if (numTimeDomainDataPoints > 0) {
67         memcpy(_imagDataTimeDomainPoints,
68                imagTimeDomainPoints,
69                numTimeDomainDataPoints * sizeof(double));
70     }
71     _dataTimestamp = dataTimestamp;
72     _repeatDataFlag = repeatDataFlag;
73     _lastOfMultipleUpdateFlag = lastOfMultipleUpdateFlag;
74     _eventGeneratedTimestamp = generatedTimestamp;
75     _droppedFFTFrames = droppedFFTFrames;
76 }
77 
~SpectrumUpdateEvent()78 SpectrumUpdateEvent::~SpectrumUpdateEvent()
79 {
80     delete[] _fftPoints;
81     delete[] _realDataTimeDomainPoints;
82     delete[] _imagDataTimeDomainPoints;
83 }
84 
getFFTPoints() const85 const float* SpectrumUpdateEvent::getFFTPoints() const { return _fftPoints; }
86 
getRealTimeDomainPoints() const87 const double* SpectrumUpdateEvent::getRealTimeDomainPoints() const
88 {
89     return _realDataTimeDomainPoints;
90 }
91 
getImagTimeDomainPoints() const92 const double* SpectrumUpdateEvent::getImagTimeDomainPoints() const
93 {
94     return _imagDataTimeDomainPoints;
95 }
96 
getNumFFTDataPoints() const97 uint64_t SpectrumUpdateEvent::getNumFFTDataPoints() const { return _numFFTDataPoints; }
98 
getNumTimeDomainDataPoints() const99 uint64_t SpectrumUpdateEvent::getNumTimeDomainDataPoints() const
100 {
101     return _numTimeDomainDataPoints;
102 }
103 
getDataTimestamp() const104 gr::high_res_timer_type SpectrumUpdateEvent::getDataTimestamp() const
105 {
106     return _dataTimestamp;
107 }
108 
getRepeatDataFlag() const109 bool SpectrumUpdateEvent::getRepeatDataFlag() const { return _repeatDataFlag; }
110 
getLastOfMultipleUpdateFlag() const111 bool SpectrumUpdateEvent::getLastOfMultipleUpdateFlag() const
112 {
113     return _lastOfMultipleUpdateFlag;
114 }
115 
getEventGeneratedTimestamp() const116 gr::high_res_timer_type SpectrumUpdateEvent::getEventGeneratedTimestamp() const
117 {
118     return _eventGeneratedTimestamp;
119 }
120 
getDroppedFFTFrames() const121 int SpectrumUpdateEvent::getDroppedFFTFrames() const { return _droppedFFTFrames; }
122 
SpectrumWindowCaptionEvent(const QString & newLbl)123 SpectrumWindowCaptionEvent::SpectrumWindowCaptionEvent(const QString& newLbl)
124     : QEvent(QEvent::Type(SpectrumWindowCaptionEventType))
125 {
126     _labelString = newLbl;
127 }
128 
~SpectrumWindowCaptionEvent()129 SpectrumWindowCaptionEvent::~SpectrumWindowCaptionEvent() {}
130 
getLabel()131 QString SpectrumWindowCaptionEvent::getLabel() { return _labelString; }
132 
SpectrumWindowResetEvent()133 SpectrumWindowResetEvent::SpectrumWindowResetEvent()
134     : QEvent(QEvent::Type(SpectrumWindowResetEventType))
135 {
136 }
137 
~SpectrumWindowResetEvent()138 SpectrumWindowResetEvent::~SpectrumWindowResetEvent() {}
139 
SpectrumFrequencyRangeEvent(const double centerFreq,const double startFreq,const double stopFreq)140 SpectrumFrequencyRangeEvent::SpectrumFrequencyRangeEvent(const double centerFreq,
141                                                          const double startFreq,
142                                                          const double stopFreq)
143     : QEvent(QEvent::Type(SpectrumFrequencyRangeEventType))
144 {
145     _centerFrequency = centerFreq;
146     _startFrequency = startFreq;
147     _stopFrequency = stopFreq;
148 }
149 
~SpectrumFrequencyRangeEvent()150 SpectrumFrequencyRangeEvent::~SpectrumFrequencyRangeEvent() {}
151 
GetCenterFrequency() const152 double SpectrumFrequencyRangeEvent::GetCenterFrequency() const
153 {
154     return _centerFrequency;
155 }
156 
GetStartFrequency() const157 double SpectrumFrequencyRangeEvent::GetStartFrequency() const { return _startFrequency; }
158 
GetStopFrequency() const159 double SpectrumFrequencyRangeEvent::GetStopFrequency() const { return _stopFrequency; }
160 
161 
162 /***************************************************************************/
163 
164 
TimeUpdateEvent(const std::vector<double * > timeDomainPoints,const uint64_t numTimeDomainDataPoints,const std::vector<std::vector<gr::tag_t>> tags)165 TimeUpdateEvent::TimeUpdateEvent(const std::vector<double*> timeDomainPoints,
166                                  const uint64_t numTimeDomainDataPoints,
167                                  const std::vector<std::vector<gr::tag_t>> tags)
168     : QEvent(QEvent::Type(SpectrumUpdateEventType))
169 {
170     if (numTimeDomainDataPoints < 1) {
171         _numTimeDomainDataPoints = 1;
172     } else {
173         _numTimeDomainDataPoints = numTimeDomainDataPoints;
174     }
175 
176     _nplots = timeDomainPoints.size();
177     for (size_t i = 0; i < _nplots; i++) {
178         _dataTimeDomainPoints.push_back(new double[_numTimeDomainDataPoints]);
179         if (numTimeDomainDataPoints > 0) {
180             memcpy(_dataTimeDomainPoints[i],
181                    timeDomainPoints[i],
182                    _numTimeDomainDataPoints * sizeof(double));
183         }
184     }
185 
186     _tags = tags;
187 }
188 
~TimeUpdateEvent()189 TimeUpdateEvent::~TimeUpdateEvent()
190 {
191     for (size_t i = 0; i < _nplots; i++) {
192         delete[] _dataTimeDomainPoints[i];
193     }
194 }
195 
getTimeDomainPoints() const196 const std::vector<double*> TimeUpdateEvent::getTimeDomainPoints() const
197 {
198     return _dataTimeDomainPoints;
199 }
200 
getNumTimeDomainDataPoints() const201 uint64_t TimeUpdateEvent::getNumTimeDomainDataPoints() const
202 {
203     return _numTimeDomainDataPoints;
204 }
205 
getTags() const206 const std::vector<std::vector<gr::tag_t>> TimeUpdateEvent::getTags() const
207 {
208     return _tags;
209 }
210 
211 /***************************************************************************/
212 
213 
FreqUpdateEvent(const std::vector<double * > dataPoints,const uint64_t numDataPoints)214 FreqUpdateEvent::FreqUpdateEvent(const std::vector<double*> dataPoints,
215                                  const uint64_t numDataPoints)
216     : QEvent(QEvent::Type(SpectrumUpdateEventType))
217 {
218     if (numDataPoints < 1) {
219         _numDataPoints = 1;
220     } else {
221         _numDataPoints = numDataPoints;
222     }
223 
224     _nplots = dataPoints.size();
225     for (size_t i = 0; i < _nplots; i++) {
226         _dataPoints.push_back(new double[_numDataPoints]);
227         if (numDataPoints > 0) {
228             memcpy(_dataPoints[i], dataPoints[i], _numDataPoints * sizeof(double));
229         }
230     }
231 }
232 
~FreqUpdateEvent()233 FreqUpdateEvent::~FreqUpdateEvent()
234 {
235     for (size_t i = 0; i < _nplots; i++) {
236         delete[] _dataPoints[i];
237     }
238 }
239 
getPoints() const240 const std::vector<double*> FreqUpdateEvent::getPoints() const { return _dataPoints; }
241 
getNumDataPoints() const242 uint64_t FreqUpdateEvent::getNumDataPoints() const { return _numDataPoints; }
243 
244 
SetFreqEvent(const double centerFreq,const double bandwidth)245 SetFreqEvent::SetFreqEvent(const double centerFreq, const double bandwidth)
246     : QEvent(QEvent::Type(SpectrumFrequencyRangeEventType))
247 {
248     _centerFrequency = centerFreq;
249     _bandwidth = bandwidth;
250 }
251 
~SetFreqEvent()252 SetFreqEvent::~SetFreqEvent() {}
253 
getCenterFrequency() const254 double SetFreqEvent::getCenterFrequency() const { return _centerFrequency; }
255 
getBandwidth() const256 double SetFreqEvent::getBandwidth() const { return _bandwidth; }
257 
258 
259 /***************************************************************************/
260 
261 
ConstUpdateEvent(const std::vector<double * > realDataPoints,const std::vector<double * > imagDataPoints,const uint64_t numDataPoints)262 ConstUpdateEvent::ConstUpdateEvent(const std::vector<double*> realDataPoints,
263                                    const std::vector<double*> imagDataPoints,
264                                    const uint64_t numDataPoints)
265     : QEvent(QEvent::Type(SpectrumUpdateEventType))
266 {
267     if (numDataPoints < 1) {
268         _numDataPoints = 1;
269     } else {
270         _numDataPoints = numDataPoints;
271     }
272 
273     _nplots = realDataPoints.size();
274     for (size_t i = 0; i < _nplots; i++) {
275         _realDataPoints.push_back(new double[_numDataPoints]);
276         _imagDataPoints.push_back(new double[_numDataPoints]);
277         if (numDataPoints > 0) {
278             memcpy(
279                 _realDataPoints[i], realDataPoints[i], _numDataPoints * sizeof(double));
280             memcpy(
281                 _imagDataPoints[i], imagDataPoints[i], _numDataPoints * sizeof(double));
282         }
283     }
284 }
285 
~ConstUpdateEvent()286 ConstUpdateEvent::~ConstUpdateEvent()
287 {
288     for (size_t i = 0; i < _nplots; i++) {
289         delete[] _realDataPoints[i];
290         delete[] _imagDataPoints[i];
291     }
292 }
293 
getRealPoints() const294 const std::vector<double*> ConstUpdateEvent::getRealPoints() const
295 {
296     return _realDataPoints;
297 }
298 
getImagPoints() const299 const std::vector<double*> ConstUpdateEvent::getImagPoints() const
300 {
301     return _imagDataPoints;
302 }
303 
getNumDataPoints() const304 uint64_t ConstUpdateEvent::getNumDataPoints() const { return _numDataPoints; }
305 
306 
307 /***************************************************************************/
308 
309 
WaterfallUpdateEvent(const std::vector<double * > dataPoints,const uint64_t numDataPoints,const gr::high_res_timer_type dataTimestamp)310 WaterfallUpdateEvent::WaterfallUpdateEvent(const std::vector<double*> dataPoints,
311                                            const uint64_t numDataPoints,
312                                            const gr::high_res_timer_type dataTimestamp)
313     : QEvent(QEvent::Type(SpectrumUpdateEventType))
314 {
315     if (numDataPoints < 1) {
316         _numDataPoints = 1;
317     } else {
318         _numDataPoints = numDataPoints;
319     }
320 
321     _nplots = dataPoints.size();
322     for (size_t i = 0; i < _nplots; i++) {
323         _dataPoints.push_back(new double[_numDataPoints]);
324         if (numDataPoints > 0) {
325             memcpy(_dataPoints[i], dataPoints[i], _numDataPoints * sizeof(double));
326         }
327     }
328 
329     _dataTimestamp = dataTimestamp;
330 }
331 
~WaterfallUpdateEvent()332 WaterfallUpdateEvent::~WaterfallUpdateEvent()
333 {
334     for (size_t i = 0; i < _nplots; i++) {
335         delete[] _dataPoints[i];
336     }
337 }
338 
getPoints() const339 const std::vector<double*> WaterfallUpdateEvent::getPoints() const { return _dataPoints; }
340 
getNumDataPoints() const341 uint64_t WaterfallUpdateEvent::getNumDataPoints() const { return _numDataPoints; }
342 
getDataTimestamp() const343 gr::high_res_timer_type WaterfallUpdateEvent::getDataTimestamp() const
344 {
345     return _dataTimestamp;
346 }
347 
348 
349 /***************************************************************************/
350 
351 
TimeRasterUpdateEvent(const std::vector<double * > dataPoints,const uint64_t numDataPoints)352 TimeRasterUpdateEvent::TimeRasterUpdateEvent(const std::vector<double*> dataPoints,
353                                              const uint64_t numDataPoints)
354     : QEvent(QEvent::Type(SpectrumUpdateEventType))
355 {
356     if (numDataPoints < 1) {
357         _numDataPoints = 1;
358     } else {
359         _numDataPoints = numDataPoints;
360     }
361 
362     _nplots = dataPoints.size();
363     for (size_t i = 0; i < _nplots; i++) {
364         _dataPoints.push_back(new double[_numDataPoints]);
365         if (numDataPoints > 0) {
366             memcpy(_dataPoints[i], dataPoints[i], _numDataPoints * sizeof(double));
367         }
368     }
369 }
370 
~TimeRasterUpdateEvent()371 TimeRasterUpdateEvent::~TimeRasterUpdateEvent()
372 {
373     for (size_t i = 0; i < _nplots; i++) {
374         delete[] _dataPoints[i];
375     }
376 }
377 
getPoints() const378 const std::vector<double*> TimeRasterUpdateEvent::getPoints() const
379 {
380     return _dataPoints;
381 }
382 
getNumDataPoints() const383 uint64_t TimeRasterUpdateEvent::getNumDataPoints() const { return _numDataPoints; }
384 
385 
TimeRasterSetSize(const double nrows,const double ncols)386 TimeRasterSetSize::TimeRasterSetSize(const double nrows, const double ncols)
387     : QEvent(QEvent::Type(SpectrumUpdateEventType + 1)), _nrows(nrows), _ncols(ncols)
388 {
389 }
390 
~TimeRasterSetSize()391 TimeRasterSetSize::~TimeRasterSetSize() {}
392 
nRows() const393 double TimeRasterSetSize::nRows() const { return _nrows; }
394 
nCols() const395 double TimeRasterSetSize::nCols() const { return _ncols; }
396 
397 /***************************************************************************/
398 
399 
HistogramUpdateEvent(const std::vector<double * > points,const uint64_t npoints)400 HistogramUpdateEvent::HistogramUpdateEvent(const std::vector<double*> points,
401                                            const uint64_t npoints)
402     : QEvent(QEvent::Type(SpectrumUpdateEventType))
403 {
404     if (npoints < 1) {
405         _npoints = 1;
406     } else {
407         _npoints = npoints;
408     }
409 
410     _nplots = points.size();
411     for (size_t i = 0; i < _nplots; i++) {
412         _points.push_back(new double[_npoints]);
413         if (npoints > 0) {
414             memcpy(_points[i], points[i], _npoints * sizeof(double));
415         }
416     }
417 }
418 
~HistogramUpdateEvent()419 HistogramUpdateEvent::~HistogramUpdateEvent()
420 {
421     for (size_t i = 0; i < _nplots; i++) {
422         delete[] _points[i];
423     }
424 }
425 
getDataPoints() const426 const std::vector<double*> HistogramUpdateEvent::getDataPoints() const { return _points; }
427 
getNumDataPoints() const428 uint64_t HistogramUpdateEvent::getNumDataPoints() const { return _npoints; }
429 
430 
HistogramSetAccumulator(const bool en)431 HistogramSetAccumulator::HistogramSetAccumulator(const bool en)
432     : QEvent(QEvent::Type(SpectrumUpdateEventType + 1)), _en(en)
433 {
434 }
435 
~HistogramSetAccumulator()436 HistogramSetAccumulator::~HistogramSetAccumulator() {}
437 
getAccumulator() const438 bool HistogramSetAccumulator::getAccumulator() const { return _en; }
439 
440 
441 /***************************************************************************/
442 
443 
NumberUpdateEvent(const std::vector<float> samples)444 NumberUpdateEvent::NumberUpdateEvent(const std::vector<float> samples)
445     : QEvent(QEvent::Type(SpectrumUpdateEventType))
446 {
447     _samples = samples;
448     _nplots = samples.size();
449 }
450 
~NumberUpdateEvent()451 NumberUpdateEvent::~NumberUpdateEvent() {}
452 
getSamples() const453 const std::vector<float> NumberUpdateEvent::getSamples() const { return _samples; }
454 
455 
456 #endif /* SPECTRUM_UPDATE_EVENTS_C */
457