gr-baz Package
TimeDomainDisplayPlot.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 TIME_DOMAIN_DISPLAY_PLOT_HPP
24 #define TIME_DOMAIN_DISPLAY_PLOT_HPP
25 
26 #include <stdint.h>
27 #include <cstdio>
28 #include <vector>
29 #include <qwt_plot.h>
30 #include <qwt_painter.h>
31 #include <qwt_plot_canvas.h>
32 #include <qwt_plot_curve.h>
33 #include <qwt_scale_engine.h>
34 #include <qwt_scale_widget.h>
35 #include <qwt_plot_zoomer.h>
36 #include <qwt_plot_panner.h>
37 #include <qwt_plot_magnifier.h>
38 #include <qwt_plot_marker.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 TimeDomainDisplayPlot:public QwtPlot{
47  Q_OBJECT
48 
49 public:
50  TimeDomainDisplayPlot(int nplots, QWidget*);
51  virtual ~TimeDomainDisplayPlot();
52 
53  void PlotNewData(const std::vector<double*> dataPoints,
54  const int64_t numDataPoints, const double timeInterval);
55 
56  virtual void replot();
57 
58 public slots:
59  void setYaxis(double min, double max);
60  void setXaxis(double min, double max);
61  void setTitle(int which, QString title);
62  void setColor(int which, QString color);
63 
64  void resizeSlot( QSize *s );
65  void SetSampleRate(double sr, double units,
66  const std::string &strunits);
67 
68  // Because of the preprocessing of slots in QT, these are no
69  // easily separated by the version check. Make one for each
70  // version until it's worked out.
71  void OnPickerPointSelected(const QwtDoublePoint & p);
72  void OnPickerPointSelected6(const QPointF & p);
73 
74 signals:
75  void plotPointSelected(const QPointF p);
76 
77 protected slots:
78  void LegendEntryChecked(QwtPlotItem *plotItem, bool on);
79 
80 protected:
81 
82 private:
83  void _resetXAxisPoints();
84 
85  int _nplots;
86  std::vector<QwtPlotCurve*> _plot_curve;
87 
88  QwtPlotPanner* _panner;
89  QwtPlotZoomer* _zoomer;
90 
91  QwtDblClickPlotPicker *_picker;
92  QwtPlotMagnifier *_magnifier;
93 
94  std::vector<double*> _dataPoints;
95  double* _xAxisPoints;
96 
97  double _sampleRate;
98 
99  int64_t _numPoints;
100 };
101 
102 #endif /* TIME_DOMAIN_DISPLAY_PLOT_HPP */