GNU Radio Manual and C++ API Reference  3.7.13.4
The Free & Open Software Radio Ecosystem
DisplayPlot.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008-2012 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 DOMAIN_DISPLAY_PLOT_H
24 #define DOMAIN_DISPLAY_PLOT_H
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 <qwt_legend.h>
41 #include <gnuradio/qtgui/utils.h>
42 
43 #if QWT_VERSION >= 0x060000
44 #include <qwt_compat.h>
45 #endif
46 
47 typedef QList<QColor> QColorList;
48 Q_DECLARE_METATYPE ( QColorList )
49 
50 #if QWT_VERSION < 0x060100
51 #include <qwt_legend_item.h>
52 #else /* QWT_VERSION < 0x060100 */
53 #include <qwt_legend_data.h>
54 #include <qwt_legend_label.h>
55 #endif /* QWT_VERSION < 0x060100 */
56 
57 /*!
58  * \brief QWidget base plot to build QTGUI plotting tools.
59  * \ingroup qtgui_blk
60  */
61 class DisplayPlot:public QwtPlot
62 {
63  Q_OBJECT
64 
65  Q_PROPERTY ( QColor line_color1 READ getLineColor1 WRITE setLineColor1 )
66  Q_PROPERTY ( QColor line_color2 READ getLineColor2 WRITE setLineColor2 )
67  Q_PROPERTY ( QColor line_color3 READ getLineColor3 WRITE setLineColor3 )
68  Q_PROPERTY ( QColor line_color4 READ getLineColor4 WRITE setLineColor4 )
69  Q_PROPERTY ( QColor line_color5 READ getLineColor5 WRITE setLineColor5 )
70  Q_PROPERTY ( QColor line_color6 READ getLineColor6 WRITE setLineColor6 )
71  Q_PROPERTY ( QColor line_color7 READ getLineColor7 WRITE setLineColor7 )
72  Q_PROPERTY ( QColor line_color8 READ getLineColor8 WRITE setLineColor8 )
73  Q_PROPERTY ( QColor line_color9 READ getLineColor9 WRITE setLineColor9 )
74 
75  Q_PROPERTY ( int line_width1 READ getLineWidth1 WRITE setLineWidth1 )
76  Q_PROPERTY ( int line_width2 READ getLineWidth2 WRITE setLineWidth2 )
77  Q_PROPERTY ( int line_width3 READ getLineWidth3 WRITE setLineWidth3 )
78  Q_PROPERTY ( int line_width4 READ getLineWidth4 WRITE setLineWidth4 )
79  Q_PROPERTY ( int line_width5 READ getLineWidth5 WRITE setLineWidth5 )
80  Q_PROPERTY ( int line_width6 READ getLineWidth6 WRITE setLineWidth6 )
81  Q_PROPERTY ( int line_width7 READ getLineWidth7 WRITE setLineWidth7 )
82  Q_PROPERTY ( int line_width8 READ getLineWidth8 WRITE setLineWidth8 )
83  Q_PROPERTY ( int line_width9 READ getLineWidth9 WRITE setLineWidth9 )
84 
85  Q_PROPERTY ( Qt::PenStyle line_style1 READ getLineStyle1 WRITE setLineStyle1 )
86  Q_PROPERTY ( Qt::PenStyle line_style2 READ getLineStyle2 WRITE setLineStyle2 )
87  Q_PROPERTY ( Qt::PenStyle line_style3 READ getLineStyle3 WRITE setLineStyle3 )
88  Q_PROPERTY ( Qt::PenStyle line_style4 READ getLineStyle4 WRITE setLineStyle4 )
89  Q_PROPERTY ( Qt::PenStyle line_style5 READ getLineStyle5 WRITE setLineStyle5 )
90  Q_PROPERTY ( Qt::PenStyle line_style6 READ getLineStyle6 WRITE setLineStyle6 )
91  Q_PROPERTY ( Qt::PenStyle line_style7 READ getLineStyle7 WRITE setLineStyle7 )
92  Q_PROPERTY ( Qt::PenStyle line_style8 READ getLineStyle8 WRITE setLineStyle8 )
93  Q_PROPERTY ( Qt::PenStyle line_style9 READ getLineStyle9 WRITE setLineStyle9 )
94 
95  typedef QwtSymbol::Style QwtSymbolStyle;
96 
97  Q_ENUMS ( QwtSymbolStyle )
98  Q_PROPERTY ( QwtSymbolStyle line_marker1 READ getLineMarker1 WRITE setLineMarker1 )
99  Q_PROPERTY ( QwtSymbolStyle line_marker2 READ getLineMarker2 WRITE setLineMarker2 )
100  Q_PROPERTY ( QwtSymbolStyle line_marker3 READ getLineMarker3 WRITE setLineMarker3 )
101  Q_PROPERTY ( QwtSymbolStyle line_marker4 READ getLineMarker4 WRITE setLineMarker4 )
102  Q_PROPERTY ( QwtSymbolStyle line_marker5 READ getLineMarker5 WRITE setLineMarker5 )
103  Q_PROPERTY ( QwtSymbolStyle line_marker6 READ getLineMarker6 WRITE setLineMarker6 )
104  Q_PROPERTY ( QwtSymbolStyle line_marker7 READ getLineMarker7 WRITE setLineMarker7 )
105  Q_PROPERTY ( QwtSymbolStyle line_marker8 READ getLineMarker8 WRITE setLineMarker8 )
106  Q_PROPERTY ( QwtSymbolStyle line_marker9 READ getLineMarker9 WRITE setLineMarker9 )
107 
108  Q_PROPERTY ( int marker_alpha1 READ getMarkerAlpha1 WRITE setMarkerAlpha1 )
109  Q_PROPERTY ( int marker_alpha2 READ getMarkerAlpha2 WRITE setMarkerAlpha2 )
110  Q_PROPERTY ( int marker_alpha3 READ getMarkerAlpha3 WRITE setMarkerAlpha3 )
111  Q_PROPERTY ( int marker_alpha4 READ getMarkerAlpha4 WRITE setMarkerAlpha4 )
112  Q_PROPERTY ( int marker_alpha5 READ getMarkerAlpha5 WRITE setMarkerAlpha5 )
113  Q_PROPERTY ( int marker_alpha6 READ getMarkerAlpha6 WRITE setMarkerAlpha6 )
114  Q_PROPERTY ( int marker_alpha7 READ getMarkerAlpha7 WRITE setMarkerAlpha7 )
115  Q_PROPERTY ( int marker_alpha8 READ getMarkerAlpha8 WRITE setMarkerAlpha8 )
116  Q_PROPERTY ( int marker_alpha9 READ getMarkerAlpha9 WRITE setMarkerAlpha9 )
117 
118  Q_PROPERTY ( QColor zoomer_color READ getZoomerColor WRITE setZoomerColor )
119  Q_PROPERTY ( QColor palette_color READ getPaletteColor WRITE setPaletteColor )
123 
124 public:
125  DisplayPlot(int nplots, QWidget*);
126  virtual ~DisplayPlot();
127 
128  virtual void replot() = 0;
129 
130  const QColor getLineColor1 () const;
131  const QColor getLineColor2 () const;
132  const QColor getLineColor3 () const;
133  const QColor getLineColor4 () const;
134  const QColor getLineColor5 () const;
135  const QColor getLineColor6 () const;
136  const QColor getLineColor7 () const;
137  const QColor getLineColor8 () const;
138  const QColor getLineColor9 () const;
139 
140  int getLineWidth1 () const;
141  int getLineWidth2 () const;
142  int getLineWidth3 () const;
143  int getLineWidth4 () const;
144  int getLineWidth5 () const;
145  int getLineWidth6 () const;
146  int getLineWidth7 () const;
147  int getLineWidth8 () const;
148  int getLineWidth9 () const;
149 
150  const Qt::PenStyle getLineStyle1 () const;
151  const Qt::PenStyle getLineStyle2 () const;
152  const Qt::PenStyle getLineStyle3 () const;
153  const Qt::PenStyle getLineStyle4 () const;
154  const Qt::PenStyle getLineStyle5 () const;
155  const Qt::PenStyle getLineStyle6 () const;
156  const Qt::PenStyle getLineStyle7 () const;
157  const Qt::PenStyle getLineStyle8 () const;
158  const Qt::PenStyle getLineStyle9 () const;
159 
160  const QwtSymbol::Style getLineMarker1 () const;
161  const QwtSymbol::Style getLineMarker2 () const;
162  const QwtSymbol::Style getLineMarker3 () const;
163  const QwtSymbol::Style getLineMarker4 () const;
164  const QwtSymbol::Style getLineMarker5 () const;
165  const QwtSymbol::Style getLineMarker6 () const;
166  const QwtSymbol::Style getLineMarker7 () const;
167  const QwtSymbol::Style getLineMarker8 () const;
168  const QwtSymbol::Style getLineMarker9 () const;
169 
170  int getMarkerAlpha1 () const;
171  int getMarkerAlpha2 () const;
172  int getMarkerAlpha3 () const;
173  int getMarkerAlpha4 () const;
174  int getMarkerAlpha5 () const;
175  int getMarkerAlpha6 () const;
176  int getMarkerAlpha7 () const;
177  int getMarkerAlpha8 () const;
178  int getMarkerAlpha9 () const;
179 
180  QColor getZoomerColor() const;
181  QColor getPaletteColor() const;
182  int getAxisLabelFontSize(int axisId) const;
183  int getYaxisLabelFontSize() const;
184  int getXaxisLabelFontSize() const;
185  int getAxesLabelFontSize() const;
186 
187  // Make sure to create your won PlotNewData method in the derived
188  // class:
189  // void PlotNewData(...);
190 
191 public slots:
192  virtual void disableLegend();
193  virtual void setAxisLabels(bool en);
194  virtual void setYaxis(double min, double max);
195  virtual void setXaxis(double min, double max);
196  virtual void setLineLabel(int which, QString label);
197  virtual QString getLineLabel(int which);
198  virtual void setLineColor(int which, QColor color);
199  virtual QColor getLineColor(int which) const;
200  virtual void setLineWidth(int which, int width);
201  virtual int getLineWidth(int which) const;
202  virtual void setLineStyle(int which, Qt::PenStyle style);
203  virtual const Qt::PenStyle getLineStyle(int which) const;
204  virtual void setLineMarker(int which, QwtSymbol::Style marker);
205  virtual const QwtSymbol::Style getLineMarker(int which) const;
206  virtual void setMarkerAlpha(int which, int alpha);
207  virtual int getMarkerAlpha(int which) const;
208 
209  // Need a function for each curve for setting via stylesheet.
210  // Can't use preprocessor directives because we're inside a Q_OBJECT.
211  void setLineColor1 (QColor);
212  void setLineColor2 (QColor);
213  void setLineColor3 (QColor);
214  void setLineColor4 (QColor);
215  void setLineColor5 (QColor);
216  void setLineColor6 (QColor);
217  void setLineColor7 (QColor);
218  void setLineColor8 (QColor);
219  void setLineColor9 (QColor);
220 
221  void setLineWidth1 (int);
222  void setLineWidth2 (int);
223  void setLineWidth3 (int);
224  void setLineWidth4 (int);
225  void setLineWidth5 (int);
226  void setLineWidth6 (int);
227  void setLineWidth7 (int);
228  void setLineWidth8 (int);
229  void setLineWidth9 (int);
230 
231  void setLineStyle1 (Qt::PenStyle);
232  void setLineStyle2 (Qt::PenStyle);
233  void setLineStyle3 (Qt::PenStyle);
234  void setLineStyle4 (Qt::PenStyle);
235  void setLineStyle5 (Qt::PenStyle);
236  void setLineStyle6 (Qt::PenStyle);
237  void setLineStyle7 (Qt::PenStyle);
238  void setLineStyle8 (Qt::PenStyle);
239  void setLineStyle9 (Qt::PenStyle);
240 
241  void setLineMarker1 (QwtSymbol::Style);
242  void setLineMarker2 (QwtSymbol::Style);
243  void setLineMarker3 (QwtSymbol::Style);
244  void setLineMarker4 (QwtSymbol::Style);
245  void setLineMarker5 (QwtSymbol::Style);
246  void setLineMarker6 (QwtSymbol::Style);
247  void setLineMarker7 (QwtSymbol::Style);
248  void setLineMarker8 (QwtSymbol::Style);
249  void setLineMarker9 (QwtSymbol::Style);
250 
251  void setMarkerAlpha1 (int);
252  void setMarkerAlpha2 (int);
253  void setMarkerAlpha3 (int);
254  void setMarkerAlpha4 (int);
255  void setMarkerAlpha5 (int);
256  void setMarkerAlpha6 (int);
257  void setMarkerAlpha7 (int);
258  void setMarkerAlpha8 (int);
259  void setMarkerAlpha9 (int);
260 
261  void setZoomerColor(QColor c);
262  void setPaletteColor(QColor c);
263  void setAxisLabelFontSize(int axisId, int fs);
264  void setYaxisLabelFontSize(int fs);
265  void setXaxisLabelFontSize(int fs);
266  void setAxesLabelFontSize(int fs);
267 
268  void setStop(bool on);
269 
270  void resizeSlot(QSize *s);
271 
272  // Because of the preprocessing of slots in QT, these are not
273  // easily separated by the version check. Make one for each
274  // version until it's worked out.
275  void onPickerPointSelected(const QwtDoublePoint & p);
276  void onPickerPointSelected6(const QPointF & p);
277 
278 signals:
279  void plotPointSelected(const QPointF p);
280 
281 protected slots:
282  virtual void legendEntryChecked(QwtPlotItem *plotItem, bool on);
283  virtual void legendEntryChecked(const QVariant &plotItem, bool on, int index);
284 
285 protected:
286  int d_nplots;
287  std::vector<QwtPlotCurve*> d_plot_curve;
288 
289  QwtPlotPanner* d_panner;
290  QwtPlotZoomer* d_zoomer;
291 
293  QwtPlotMagnifier *d_magnifier;
294 
295  int64_t d_numPoints;
296 
297  bool d_stop;
298 
299  QList<QColor> d_trace_colors;
300 
302 };
303 
304 #endif /* DOMAIN_DISPLAY_PLOT_H */
int line_width3
Definition: DisplayPlot.h:77
void setLineStyle6(Qt::PenStyle)
const QColor getLineColor5() const
int getMarkerAlpha9() const
const Qt::PenStyle getLineStyle8() const
void setLineWidth9(int)
int getLineWidth2() const
void setLineStyle2(Qt::PenStyle)
int getMarkerAlpha1() const
int getLineWidth4() const
QColor line_color3
Definition: DisplayPlot.h:67
Qt::PenStyle line_style2
Definition: DisplayPlot.h:86
int getXaxisLabelFontSize() const
int line_width5
Definition: DisplayPlot.h:79
void setMarkerAlpha4(int)
QColor line_color6
Definition: DisplayPlot.h:70
int getLineWidth3() const
int d_nplots
Definition: DisplayPlot.h:286
const QColor getLineColor7() const
void setLineMarker1(QwtSymbol::Style)
QColor palette_color
Definition: DisplayPlot.h:119
void setLineWidth7(int)
int getMarkerAlpha4() const
QwtSymbolStyle line_marker7
Definition: DisplayPlot.h:104
QWidget base plot to build QTGUI plotting tools.
Definition: DisplayPlot.h:61
virtual void setXaxis(double min, double max)
void setLineWidth2(int)
int xaxis_label_font_size
Definition: DisplayPlot.h:121
QList< QColor > QColorList
Definition: DisplayPlot.h:47
const QColor getLineColor3() const
QwtSymbolStyle line_marker6
Definition: DisplayPlot.h:103
int getMarkerAlpha3() const
const QColor getLineColor4() const
float min(float a, float b)
const QwtSymbol::Style getLineMarker5() const
const QColor getLineColor2() const
virtual void setYaxis(double min, double max)
const Qt::PenStyle getLineStyle1() const
QwtPlotZoomer * d_zoomer
Definition: DisplayPlot.h:290
void setPaletteColor(QColor c)
void setLineStyle9(Qt::PenStyle)
void setLineStyle7(Qt::PenStyle)
void setLineMarker5(QwtSymbol::Style)
int marker_alpha5
Definition: DisplayPlot.h:112
QwtSymbolStyle line_marker1
Definition: DisplayPlot.h:98
void setLineWidth6(int)
QwtSymbolStyle line_marker8
Definition: DisplayPlot.h:105
Qt::PenStyle line_style7
Definition: DisplayPlot.h:91
virtual void legendEntryChecked(QwtPlotItem *plotItem, bool on)
virtual void setLineWidth(int which, int width)
STL namespace.
QwtPlotMagnifier * d_magnifier
Definition: DisplayPlot.h:293
QwtSymbolStyle line_marker2
Definition: DisplayPlot.h:99
int marker_alpha8
Definition: DisplayPlot.h:115
int getLineWidth6() const
void setAxisLabelFontSize(int axisId, int fs)
int line_width8
Definition: DisplayPlot.h:82
Qt::PenStyle line_style4
Definition: DisplayPlot.h:88
Qt::PenStyle line_style9
Definition: DisplayPlot.h:93
int marker_alpha3
Definition: DisplayPlot.h:110
void onPickerPointSelected6(const QPointF &p)
std::vector< QwtPlotCurve * > d_plot_curve
Definition: DisplayPlot.h:287
int line_width9
Definition: DisplayPlot.h:83
void setLineColor5(QColor)
void setMarkerAlpha9(int)
void setLineColor4(QColor)
QwtSymbolStyle line_marker4
Definition: DisplayPlot.h:101
int marker_alpha2
Definition: DisplayPlot.h:109
const QwtSymbol::Style getLineMarker2() const
virtual void setLineColor(int which, QColor color)
const Qt::PenStyle getLineStyle4() const
virtual void setLineLabel(int which, QString label)
void setLineMarker4(QwtSymbol::Style)
void resizeSlot(QSize *s)
const Qt::PenStyle getLineStyle3() const
int line_width1
Definition: DisplayPlot.h:75
int getMarkerAlpha6() const
QwtSymbolStyle line_marker3
Definition: DisplayPlot.h:100
const QwtSymbol::Style getLineMarker4() const
QList< QColor > d_trace_colors
Definition: DisplayPlot.h:299
void setZoomerColor(QColor c)
QColor line_color1
Definition: DisplayPlot.h:65
QColor line_color8
Definition: DisplayPlot.h:72
QColor line_color9
Definition: DisplayPlot.h:73
void plotPointSelected(const QPointF p)
void setLineWidth3(int)
QColor line_color7
Definition: DisplayPlot.h:71
Qt::PenStyle line_style3
Definition: DisplayPlot.h:87
void setLineColor3(QColor)
const Qt::PenStyle getLineStyle9() const
void setLineMarker7(QwtSymbol::Style)
int getMarkerAlpha2() const
int64_t d_numPoints
Definition: DisplayPlot.h:295
void setMarkerAlpha2(int)
void setLineMarker3(QwtSymbol::Style)
void onPickerPointSelected(const QwtDoublePoint &p)
void setLineColor7(QColor)
const QwtSymbol::Style getLineMarker7() const
virtual void setLineStyle(int which, Qt::PenStyle style)
const QwtSymbol::Style getLineMarker9() const
QColor line_color5
Definition: DisplayPlot.h:69
int getLineWidth5() const
void setLineWidth1(int)
void setLineMarker2(QwtSymbol::Style)
void setLineStyle3(Qt::PenStyle)
void setLineStyle4(Qt::PenStyle)
bool d_stop
Definition: DisplayPlot.h:297
virtual void replot()=0
QwtDblClickPlotPicker * d_picker
Definition: DisplayPlot.h:292
const QColor getLineColor9() const
void setYaxisLabelFontSize(int fs)
virtual void setMarkerAlpha(int which, int alpha)
int marker_alpha4
Definition: DisplayPlot.h:111
int getLineWidth7() const
void setAxesLabelFontSize(int fs)
virtual const QwtSymbol::Style getLineMarker(int which) const
int axes_label_font_size
Definition: DisplayPlot.h:122
const QColor getLineColor8() const
const Qt::PenStyle getLineStyle7() const
QwtSymbolStyle line_marker9
Definition: DisplayPlot.h:106
virtual int getLineWidth(int which) const
void setLineWidth5(int)
int getYaxisLabelFontSize() const
virtual void setLineMarker(int which, QwtSymbol::Style marker)
Qt::PenStyle line_style6
Definition: DisplayPlot.h:90
int marker_alpha9
Definition: DisplayPlot.h:116
void setLineWidth8(int)
virtual void disableLegend()
void setLineColor9(QColor)
void setMarkerAlpha5(int)
QColor getPaletteColor() const
QColor zoomer_color
Definition: DisplayPlot.h:118
int getLineWidth8() const
Qt::PenStyle line_style5
Definition: DisplayPlot.h:89
const QwtSymbol::Style getLineMarker6() const
int getLineWidth9() const
Qt::PenStyle line_style8
Definition: DisplayPlot.h:92
virtual void setAxisLabels(bool en)
void setMarkerAlpha3(int)
int getMarkerAlpha7() const
void setLineColor2(QColor)
Qt::PenStyle line_style1
Definition: DisplayPlot.h:85
int getAxisLabelFontSize(int axisId) const
void setMarkerAlpha8(int)
void setLineColor6(QColor)
int line_width6
Definition: DisplayPlot.h:80
void setStop(bool on)
const QwtSymbol::Style getLineMarker3() const
void setLineColor8(QColor)
const QColor getLineColor1() const
void setLineColor1(QColor)
int line_width4
Definition: DisplayPlot.h:78
QwtPlotPanner * d_panner
Definition: DisplayPlot.h:289
const QwtSymbol::Style getLineMarker8() const
Definition: utils.h:41
const Qt::PenStyle getLineStyle5() const
QwtSymbolStyle line_marker5
Definition: DisplayPlot.h:102
void setLineStyle8(Qt::PenStyle)
int marker_alpha1
Definition: DisplayPlot.h:108
void setMarkerAlpha7(int)
virtual int getMarkerAlpha(int which) const
int marker_alpha7
Definition: DisplayPlot.h:114
QColor line_color2
Definition: DisplayPlot.h:66
int yaxis_label_font_size
Definition: DisplayPlot.h:120
int line_width7
Definition: DisplayPlot.h:81
void setLineWidth4(int)
int getAxesLabelFontSize() const
virtual QColor getLineColor(int which) const
int getLineWidth1() const
void setXaxisLabelFontSize(int fs)
const QwtSymbol::Style getLineMarker1() const
const QColor getLineColor6() const
virtual QString getLineLabel(int which)
const Qt::PenStyle getLineStyle2() const
int marker_alpha6
Definition: DisplayPlot.h:113
QColor line_color4
Definition: DisplayPlot.h:68
void setMarkerAlpha6(int)
void setLineMarker8(QwtSymbol::Style)
void setLineMarker6(QwtSymbol::Style)
void setLineStyle5(Qt::PenStyle)
void setMarkerAlpha1(int)
int line_width2
Definition: DisplayPlot.h:76
void setLineStyle1(Qt::PenStyle)
int getMarkerAlpha5() const
int getMarkerAlpha8() const
virtual const Qt::PenStyle getLineStyle(int which) const
QColor getZoomerColor() const
void setLineMarker9(QwtSymbol::Style)
const Qt::PenStyle getLineStyle6() const
bool d_autoscale_state
Definition: DisplayPlot.h:301