1 /* -*- c++ -*- */ 2 /* 3 * Copyright 2008-2014 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_H 24 #define SPECTRUM_UPDATE_EVENTS_H 25 26 #include <gnuradio/high_res_timer.h> 27 #include <gnuradio/qtgui/api.h> 28 #include <gnuradio/tags.h> 29 #include <stdint.h> 30 #include <QEvent> 31 #include <QString> 32 #include <complex> 33 #include <vector> 34 35 static const int SpectrumUpdateEventType = 10005; 36 static const int SpectrumWindowCaptionEventType = 10008; 37 static const int SpectrumWindowResetEventType = 10009; 38 static const int SpectrumFrequencyRangeEventType = 10010; 39 40 class SpectrumUpdateEvent : public QEvent 41 { 42 43 public: 44 SpectrumUpdateEvent(const float* fftPoints, 45 const uint64_t numFFTDataPoints, 46 const double* realTimeDomainPoints, 47 const double* imagTimeDomainPoints, 48 const uint64_t numTimeDomainDataPoints, 49 const gr::high_res_timer_type dataTimestamp, 50 const bool repeatDataFlag, 51 const bool lastOfMultipleUpdateFlag, 52 const gr::high_res_timer_type generatedTimestamp, 53 const int droppedFFTFrames); 54 55 ~SpectrumUpdateEvent(); 56 57 const float* getFFTPoints() const; 58 const double* getRealTimeDomainPoints() const; 59 const double* getImagTimeDomainPoints() const; 60 uint64_t getNumFFTDataPoints() const; 61 uint64_t getNumTimeDomainDataPoints() const; 62 gr::high_res_timer_type getDataTimestamp() const; 63 bool getRepeatDataFlag() const; 64 bool getLastOfMultipleUpdateFlag() const; 65 gr::high_res_timer_type getEventGeneratedTimestamp() const; 66 int getDroppedFFTFrames() const; 67 68 protected: 69 private: 70 float* _fftPoints; 71 double* _realDataTimeDomainPoints; 72 double* _imagDataTimeDomainPoints; 73 uint64_t _numFFTDataPoints; 74 uint64_t _numTimeDomainDataPoints; 75 gr::high_res_timer_type _dataTimestamp; 76 bool _repeatDataFlag; 77 bool _lastOfMultipleUpdateFlag; 78 gr::high_res_timer_type _eventGeneratedTimestamp; 79 int _droppedFFTFrames; 80 }; 81 82 class SpectrumWindowCaptionEvent : public QEvent 83 { 84 public: 85 SpectrumWindowCaptionEvent(const QString&); 86 ~SpectrumWindowCaptionEvent(); 87 QString getLabel(); 88 89 protected: 90 private: 91 QString _labelString; 92 }; 93 94 class SpectrumWindowResetEvent : public QEvent 95 { 96 public: 97 SpectrumWindowResetEvent(); 98 ~SpectrumWindowResetEvent(); 99 100 protected: 101 private: 102 }; 103 104 class SpectrumFrequencyRangeEvent : public QEvent 105 { 106 public: 107 SpectrumFrequencyRangeEvent(const double, const double, const double); 108 ~SpectrumFrequencyRangeEvent(); 109 double GetCenterFrequency() const; 110 double GetStartFrequency() const; 111 double GetStopFrequency() const; 112 113 protected: 114 private: 115 double _centerFrequency; 116 double _startFrequency; 117 double _stopFrequency; 118 }; 119 120 121 class TimeUpdateEvent : public QEvent 122 { 123 public: 124 TimeUpdateEvent(const std::vector<double*> timeDomainPoints, 125 const uint64_t numTimeDomainDataPoints, 126 const std::vector<std::vector<gr::tag_t>> tags); 127 128 ~TimeUpdateEvent(); 129 130 int which() const; 131 const std::vector<double*> getTimeDomainPoints() const; 132 uint64_t getNumTimeDomainDataPoints() const; 133 bool getRepeatDataFlag() const; 134 135 const std::vector<std::vector<gr::tag_t>> getTags() const; 136 Type()137 static QEvent::Type Type() { return QEvent::Type(SpectrumUpdateEventType); } 138 139 protected: 140 private: 141 size_t _nplots; 142 std::vector<double*> _dataTimeDomainPoints; 143 uint64_t _numTimeDomainDataPoints; 144 std::vector<std::vector<gr::tag_t>> _tags; 145 }; 146 147 148 /********************************************************************/ 149 150 151 class FreqUpdateEvent : public QEvent 152 { 153 public: 154 FreqUpdateEvent(const std::vector<double*> dataPoints, const uint64_t numDataPoints); 155 156 ~FreqUpdateEvent(); 157 158 int which() const; 159 const std::vector<double*> getPoints() const; 160 uint64_t getNumDataPoints() const; 161 bool getRepeatDataFlag() const; 162 Type()163 static QEvent::Type Type() { return QEvent::Type(SpectrumUpdateEventType); } 164 165 protected: 166 private: 167 size_t _nplots; 168 std::vector<double*> _dataPoints; 169 uint64_t _numDataPoints; 170 }; 171 172 173 class SetFreqEvent : public QEvent 174 { 175 public: 176 SetFreqEvent(const double, const double); 177 ~SetFreqEvent(); 178 double getCenterFrequency() const; 179 double getBandwidth() const; 180 181 private: 182 double _centerFrequency; 183 double _bandwidth; 184 }; 185 186 187 /********************************************************************/ 188 189 190 class QTGUI_API ConstUpdateEvent : public QEvent 191 { 192 public: 193 ConstUpdateEvent(const std::vector<double*> realDataPoints, 194 const std::vector<double*> imagDataPoints, 195 const uint64_t numDataPoints); 196 197 ~ConstUpdateEvent(); 198 199 int which() const; 200 const std::vector<double*> getRealPoints() const; 201 const std::vector<double*> getImagPoints() const; 202 uint64_t getNumDataPoints() const; 203 bool getRepeatDataFlag() const; 204 Type()205 static QEvent::Type Type() { return QEvent::Type(SpectrumUpdateEventType); } 206 207 protected: 208 private: 209 size_t _nplots; 210 std::vector<double*> _realDataPoints; 211 std::vector<double*> _imagDataPoints; 212 uint64_t _numDataPoints; 213 }; 214 215 216 /********************************************************************/ 217 218 219 class WaterfallUpdateEvent : public QEvent 220 { 221 public: 222 WaterfallUpdateEvent(const std::vector<double*> dataPoints, 223 const uint64_t numDataPoints, 224 const gr::high_res_timer_type dataTimestamp); 225 226 ~WaterfallUpdateEvent(); 227 228 int which() const; 229 const std::vector<double*> getPoints() const; 230 uint64_t getNumDataPoints() const; 231 bool getRepeatDataFlag() const; 232 233 gr::high_res_timer_type getDataTimestamp() const; 234 Type()235 static QEvent::Type Type() { return QEvent::Type(SpectrumUpdateEventType); } 236 237 protected: 238 private: 239 size_t _nplots; 240 std::vector<double*> _dataPoints; 241 uint64_t _numDataPoints; 242 243 gr::high_res_timer_type _dataTimestamp; 244 }; 245 246 247 /********************************************************************/ 248 249 250 class TimeRasterUpdateEvent : public QEvent 251 { 252 public: 253 TimeRasterUpdateEvent(const std::vector<double*> dataPoints, 254 const uint64_t numDataPoints); 255 ~TimeRasterUpdateEvent(); 256 257 int which() const; 258 const std::vector<double*> getPoints() const; 259 uint64_t getNumDataPoints() const; 260 bool getRepeatDataFlag() const; 261 Type()262 static QEvent::Type Type() { return QEvent::Type(SpectrumUpdateEventType); } 263 264 protected: 265 private: 266 size_t _nplots; 267 std::vector<double*> _dataPoints; 268 uint64_t _numDataPoints; 269 }; 270 271 272 class TimeRasterSetSize : public QEvent 273 { 274 public: 275 TimeRasterSetSize(const double nrows, const double ncols); 276 ~TimeRasterSetSize(); 277 278 double nRows() const; 279 double nCols() const; 280 Type()281 static QEvent::Type Type() { return QEvent::Type(SpectrumUpdateEventType + 1); } 282 283 private: 284 double _nrows; 285 double _ncols; 286 }; 287 288 289 /********************************************************************/ 290 291 292 class HistogramUpdateEvent : public QEvent 293 { 294 public: 295 HistogramUpdateEvent(const std::vector<double*> points, const uint64_t npoints); 296 297 ~HistogramUpdateEvent(); 298 299 int which() const; 300 const std::vector<double*> getDataPoints() const; 301 uint64_t getNumDataPoints() const; 302 bool getRepeatDataFlag() const; 303 Type()304 static QEvent::Type Type() { return QEvent::Type(SpectrumUpdateEventType); } 305 306 protected: 307 private: 308 size_t _nplots; 309 std::vector<double*> _points; 310 uint64_t _npoints; 311 }; 312 313 314 class HistogramSetAccumulator : public QEvent 315 { 316 public: 317 HistogramSetAccumulator(const bool en); 318 ~HistogramSetAccumulator(); 319 320 bool getAccumulator() const; 321 Type()322 static QEvent::Type Type() { return QEvent::Type(SpectrumUpdateEventType + 1); } 323 324 private: 325 bool _en; 326 }; 327 328 class HistogramClearEvent : public QEvent 329 { 330 public: HistogramClearEvent()331 HistogramClearEvent() : QEvent(QEvent::Type(SpectrumUpdateEventType + 2)) {} 332 ~HistogramClearEvent()333 ~HistogramClearEvent() {} 334 Type()335 static QEvent::Type Type() { return QEvent::Type(SpectrumUpdateEventType + 2); } 336 }; 337 338 339 /********************************************************************/ 340 341 342 class NumberUpdateEvent : public QEvent 343 { 344 public: 345 NumberUpdateEvent(const std::vector<float> samples); 346 ~NumberUpdateEvent(); 347 348 int which() const; 349 const std::vector<float> getSamples() const; 350 Type()351 static QEvent::Type Type() { return QEvent::Type(SpectrumUpdateEventType); } 352 353 protected: 354 private: 355 size_t _nplots; 356 std::vector<float> _samples; 357 }; 358 359 360 #endif /* SPECTRUM_UPDATE_EVENTS_H */ 361