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