gr-baz Package
FrequencyDisplayPlot.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008,2009,2010,2011 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 FREQUENCY_DISPLAY_PLOT_HPP
24 #define FREQUENCY_DISPLAY_PLOT_HPP
25 
26 #include <stdint.h>
27 #include <cstdio>
28 #include <qwt_plot.h>
29 #include <qwt_painter.h>
30 #include <qwt_plot_canvas.h>
31 #include <qwt_plot_curve.h>
32 #include <qwt_scale_engine.h>
33 #include <qwt_scale_widget.h>
34 #include <qwt_plot_zoomer.h>
35 #include <qwt_plot_panner.h>
36 #include <qwt_plot_marker.h>
37 #include <qwt_plot_magnifier.h>
38 #include <gruel/high_res_timer.h>
39 #include <qwt_symbol.h>
40 #include <qtgui_util.h>
41 
42 #if QWT_VERSION >= 0x060000
43 #include <qwt_compat.h>
44 #endif
45 
46 class FrequencyDisplayPlot:public QwtPlot{
47  Q_OBJECT
48 
49 public:
50  FrequencyDisplayPlot(QWidget*);
51  virtual ~FrequencyDisplayPlot();
52 
53  void SetFrequencyRange(const double, const double,
54  const double, const bool,
55  const double units=1000.0,
56  const std::string &strunits = "kHz");
57  double GetStartFrequency()const;
58  double GetStopFrequency()const;
59 
60  void PlotNewData(const double* dataPoints, const int64_t numDataPoints,
61  const double noiseFloorAmplitude, const double peakFrequency,
62  const double peakAmplitude, const double timeInterval);
63 
64  void ClearMaxData();
65  void ClearMinData();
66 
67  void SetMaxFFTVisible(const bool);
68  void SetMinFFTVisible(const bool);
69 
70  virtual void replot();
71 
72  void set_yaxis(double min, double max);
73 
74  void SetTraceColour (QColor);
75  void SetBGColour (QColor c);
76  void ShowCFMarker (const bool);
77 
78 public slots:
79  void resizeSlot( QSize *e );
80  void SetLowerIntensityLevel(const double);
81  void SetUpperIntensityLevel(const double);
82 
83  // Because of the preprocessing of slots in QT, these are no
84  // easily separated by the version check. Make one for each
85  // version until it's worked out.
86  void OnPickerPointSelected(const QwtDoublePoint & p);
87  void OnPickerPointSelected6(const QPointF & p);
88 
89 signals:
90  void plotPointSelected(const QPointF p);
91 
92 protected:
93 
94 private:
95 
96  void _resetXAxisPoints();
97 
98  double _startFrequency;
99  double _stopFrequency;
100  double _maxYAxis;
101  double _minYAxis;
102 
103  QwtPlotCurve* _fft_plot_curve;
104  QwtPlotCurve* _min_fft_plot_curve;
105  QwtPlotCurve* _max_fft_plot_curve;
106 
107  QwtPlotMarker* _lower_intensity_marker;
108  QwtPlotMarker* _upper_intensity_marker;
109 
110  QwtPlotPanner* _panner;
111  QwtPlotZoomer* _zoomer;
112 
113  QwtPlotMarker *_markerPeakAmplitude;
114  QwtPlotMarker *_markerNoiseFloorAmplitude;
115  QwtPlotMarker *_markerCF;
116 
117  QwtDblClickPlotPicker *_picker;
118 
119  QwtPlotMagnifier *_magnifier;
120 
121  double* _dataPoints;
122  double* _xAxisPoints;
123  int _xAxisMultiplier;
124 
125  double* _minFFTPoints;
126  double* _maxFFTPoints;
127  int64_t _numPoints;
128 
129  double _peakFrequency;
130  double _peakAmplitude;
131 
132  double _noiseFloorAmplitude;
133 
134  gruel::high_res_timer_type _lastReplot;
135 
136  bool _useCenterFrequencyFlag;
137 };
138 
139 #endif /* FREQUENCY_DISPLAY_PLOT_HPP */