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