GNU Radio 3.7.1 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2008-2012 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef DOMAIN_DISPLAY_PLOT_H 00024 #define DOMAIN_DISPLAY_PLOT_H 00025 00026 #include <stdint.h> 00027 #include <cstdio> 00028 #include <vector> 00029 #include <qwt_plot.h> 00030 #include <qwt_painter.h> 00031 #include <qwt_plot_canvas.h> 00032 #include <qwt_plot_curve.h> 00033 #include <qwt_scale_engine.h> 00034 #include <qwt_scale_widget.h> 00035 #include <qwt_plot_zoomer.h> 00036 #include <qwt_plot_panner.h> 00037 #include <qwt_plot_magnifier.h> 00038 #include <qwt_plot_marker.h> 00039 #include <qwt_symbol.h> 00040 #include <gnuradio/qtgui/utils.h> 00041 00042 #if QWT_VERSION >= 0x060000 00043 #include <qwt_compat.h> 00044 #endif 00045 00046 typedef QList<QColor> QColorList; 00047 Q_DECLARE_METATYPE ( QColorList ) 00048 00049 /*! 00050 * \brief QWidget base plot to build QTGUI plotting tools. 00051 * \ingroup qtgui_blk 00052 */ 00053 class DisplayPlot:public QwtPlot{ 00054 Q_OBJECT 00055 00056 Q_PROPERTY ( QColor line_color1 READ getLineColor1 WRITE setLineColor1 ) 00057 Q_PROPERTY ( QColor line_color2 READ getLineColor2 WRITE setLineColor2 ) 00058 Q_PROPERTY ( QColor line_color3 READ getLineColor3 WRITE setLineColor3 ) 00059 Q_PROPERTY ( QColor line_color4 READ getLineColor4 WRITE setLineColor4 ) 00060 Q_PROPERTY ( QColor line_color5 READ getLineColor5 WRITE setLineColor5 ) 00061 Q_PROPERTY ( QColor line_color6 READ getLineColor6 WRITE setLineColor6 ) 00062 Q_PROPERTY ( QColor line_color7 READ getLineColor7 WRITE setLineColor7 ) 00063 Q_PROPERTY ( QColor line_color8 READ getLineColor8 WRITE setLineColor8 ) 00064 Q_PROPERTY ( QColor line_color9 READ getLineColor9 WRITE setLineColor9 ) 00065 00066 Q_PROPERTY ( int line_width1 READ getLineWidth1 WRITE setLineWidth1 ) 00067 Q_PROPERTY ( int line_width2 READ getLineWidth2 WRITE setLineWidth2 ) 00068 Q_PROPERTY ( int line_width3 READ getLineWidth3 WRITE setLineWidth3 ) 00069 Q_PROPERTY ( int line_width4 READ getLineWidth4 WRITE setLineWidth4 ) 00070 Q_PROPERTY ( int line_width5 READ getLineWidth5 WRITE setLineWidth5 ) 00071 Q_PROPERTY ( int line_width6 READ getLineWidth6 WRITE setLineWidth6 ) 00072 Q_PROPERTY ( int line_width7 READ getLineWidth7 WRITE setLineWidth7 ) 00073 Q_PROPERTY ( int line_width8 READ getLineWidth8 WRITE setLineWidth8 ) 00074 Q_PROPERTY ( int line_width9 READ getLineWidth9 WRITE setLineWidth9 ) 00075 00076 Q_PROPERTY ( Qt::PenStyle line_style1 READ getLineStyle1 WRITE setLineStyle1 ) 00077 Q_PROPERTY ( Qt::PenStyle line_style2 READ getLineStyle2 WRITE setLineStyle2 ) 00078 Q_PROPERTY ( Qt::PenStyle line_style3 READ getLineStyle3 WRITE setLineStyle3 ) 00079 Q_PROPERTY ( Qt::PenStyle line_style4 READ getLineStyle4 WRITE setLineStyle4 ) 00080 Q_PROPERTY ( Qt::PenStyle line_style5 READ getLineStyle5 WRITE setLineStyle5 ) 00081 Q_PROPERTY ( Qt::PenStyle line_style6 READ getLineStyle6 WRITE setLineStyle6 ) 00082 Q_PROPERTY ( Qt::PenStyle line_style7 READ getLineStyle7 WRITE setLineStyle7 ) 00083 Q_PROPERTY ( Qt::PenStyle line_style8 READ getLineStyle8 WRITE setLineStyle8 ) 00084 Q_PROPERTY ( Qt::PenStyle line_style9 READ getLineStyle9 WRITE setLineStyle9 ) 00085 00086 typedef QwtSymbol::Style QwtSymbolStyle; 00087 00088 Q_ENUMS ( QwtSymbolStyle ) 00089 Q_PROPERTY ( QwtSymbolStyle line_marker1 READ getLineMarker1 WRITE setLineMarker1 ) 00090 Q_PROPERTY ( QwtSymbolStyle line_marker2 READ getLineMarker2 WRITE setLineMarker2 ) 00091 Q_PROPERTY ( QwtSymbolStyle line_marker3 READ getLineMarker3 WRITE setLineMarker3 ) 00092 Q_PROPERTY ( QwtSymbolStyle line_marker4 READ getLineMarker4 WRITE setLineMarker4 ) 00093 Q_PROPERTY ( QwtSymbolStyle line_marker5 READ getLineMarker5 WRITE setLineMarker5 ) 00094 Q_PROPERTY ( QwtSymbolStyle line_marker6 READ getLineMarker6 WRITE setLineMarker6 ) 00095 Q_PROPERTY ( QwtSymbolStyle line_marker7 READ getLineMarker7 WRITE setLineMarker7 ) 00096 Q_PROPERTY ( QwtSymbolStyle line_marker8 READ getLineMarker8 WRITE setLineMarker8 ) 00097 Q_PROPERTY ( QwtSymbolStyle line_marker9 READ getLineMarker9 WRITE setLineMarker9 ) 00098 00099 Q_PROPERTY ( int marker_alpha1 READ getMarkerAlpha1 WRITE setMarkerAlpha1 ) 00100 Q_PROPERTY ( int marker_alpha2 READ getMarkerAlpha2 WRITE setMarkerAlpha2 ) 00101 Q_PROPERTY ( int marker_alpha3 READ getMarkerAlpha3 WRITE setMarkerAlpha3 ) 00102 Q_PROPERTY ( int marker_alpha4 READ getMarkerAlpha4 WRITE setMarkerAlpha4 ) 00103 Q_PROPERTY ( int marker_alpha5 READ getMarkerAlpha5 WRITE setMarkerAlpha5 ) 00104 Q_PROPERTY ( int marker_alpha6 READ getMarkerAlpha6 WRITE setMarkerAlpha6 ) 00105 Q_PROPERTY ( int marker_alpha7 READ getMarkerAlpha7 WRITE setMarkerAlpha7 ) 00106 Q_PROPERTY ( int marker_alpha8 READ getMarkerAlpha8 WRITE setMarkerAlpha8 ) 00107 Q_PROPERTY ( int marker_alpha9 READ getMarkerAlpha9 WRITE setMarkerAlpha9 ) 00108 00109 Q_PROPERTY ( QColor zoomer_color READ getZoomerColor WRITE setZoomerColor ) 00110 Q_PROPERTY ( QColor palette_color READ getPaletteColor WRITE setPaletteColor ) 00111 Q_PROPERTY ( int yaxis_label_font_size READ getYaxisLabelFontSize WRITE setYaxisLabelFontSize ) 00112 Q_PROPERTY ( int xaxis_label_font_size READ getXaxisLabelFontSize WRITE setXaxisLabelFontSize ) 00113 Q_PROPERTY ( int axes_label_font_size READ getAxesLabelFontSize WRITE setAxesLabelFontSize ) 00114 00115 public: 00116 DisplayPlot(int nplots, QWidget*); 00117 virtual ~DisplayPlot(); 00118 00119 virtual void replot() = 0; 00120 00121 const QColor getLineColor1 () const; 00122 const QColor getLineColor2 () const; 00123 const QColor getLineColor3 () const; 00124 const QColor getLineColor4 () const; 00125 const QColor getLineColor5 () const; 00126 const QColor getLineColor6 () const; 00127 const QColor getLineColor7 () const; 00128 const QColor getLineColor8 () const; 00129 const QColor getLineColor9 () const; 00130 00131 int getLineWidth1 () const; 00132 int getLineWidth2 () const; 00133 int getLineWidth3 () const; 00134 int getLineWidth4 () const; 00135 int getLineWidth5 () const; 00136 int getLineWidth6 () const; 00137 int getLineWidth7 () const; 00138 int getLineWidth8 () const; 00139 int getLineWidth9 () const; 00140 00141 const Qt::PenStyle getLineStyle1 () const; 00142 const Qt::PenStyle getLineStyle2 () const; 00143 const Qt::PenStyle getLineStyle3 () const; 00144 const Qt::PenStyle getLineStyle4 () const; 00145 const Qt::PenStyle getLineStyle5 () const; 00146 const Qt::PenStyle getLineStyle6 () const; 00147 const Qt::PenStyle getLineStyle7 () const; 00148 const Qt::PenStyle getLineStyle8 () const; 00149 const Qt::PenStyle getLineStyle9 () const; 00150 00151 const QwtSymbol::Style getLineMarker1 () const; 00152 const QwtSymbol::Style getLineMarker2 () const; 00153 const QwtSymbol::Style getLineMarker3 () const; 00154 const QwtSymbol::Style getLineMarker4 () const; 00155 const QwtSymbol::Style getLineMarker5 () const; 00156 const QwtSymbol::Style getLineMarker6 () const; 00157 const QwtSymbol::Style getLineMarker7 () const; 00158 const QwtSymbol::Style getLineMarker8 () const; 00159 const QwtSymbol::Style getLineMarker9 () const; 00160 00161 int getMarkerAlpha1 () const; 00162 int getMarkerAlpha2 () const; 00163 int getMarkerAlpha3 () const; 00164 int getMarkerAlpha4 () const; 00165 int getMarkerAlpha5 () const; 00166 int getMarkerAlpha6 () const; 00167 int getMarkerAlpha7 () const; 00168 int getMarkerAlpha8 () const; 00169 int getMarkerAlpha9 () const; 00170 00171 QColor getZoomerColor() const; 00172 QColor getPaletteColor() const; 00173 int getAxisLabelFontSize(int axisId) const; 00174 int getYaxisLabelFontSize() const; 00175 int getXaxisLabelFontSize() const; 00176 int getAxesLabelFontSize() const; 00177 00178 // Make sure to create your won PlotNewData method in the derived 00179 // class: 00180 // void PlotNewData(...); 00181 00182 public slots: 00183 virtual void setYaxis(double min, double max); 00184 virtual void setXaxis(double min, double max); 00185 virtual void setLineLabel(int which, QString label); 00186 virtual QString getLineLabel(int which); 00187 virtual void setLineColor(int which, QColor color); 00188 virtual QColor getLineColor(int which) const; 00189 virtual void setLineWidth(int which, int width); 00190 virtual int getLineWidth(int which) const; 00191 virtual void setLineStyle(int which, Qt::PenStyle style); 00192 virtual const Qt::PenStyle getLineStyle(int which) const; 00193 virtual void setLineMarker(int which, QwtSymbol::Style marker); 00194 virtual const QwtSymbol::Style getLineMarker(int which) const; 00195 virtual void setMarkerAlpha(int which, int alpha); 00196 virtual int getMarkerAlpha(int which) const; 00197 00198 // Need a function for each curve for setting via stylesheet. 00199 // Can't use preprocessor directives because we're inside a Q_OBJECT. 00200 void setLineColor1 (QColor); 00201 void setLineColor2 (QColor); 00202 void setLineColor3 (QColor); 00203 void setLineColor4 (QColor); 00204 void setLineColor5 (QColor); 00205 void setLineColor6 (QColor); 00206 void setLineColor7 (QColor); 00207 void setLineColor8 (QColor); 00208 void setLineColor9 (QColor); 00209 00210 void setLineWidth1 (int); 00211 void setLineWidth2 (int); 00212 void setLineWidth3 (int); 00213 void setLineWidth4 (int); 00214 void setLineWidth5 (int); 00215 void setLineWidth6 (int); 00216 void setLineWidth7 (int); 00217 void setLineWidth8 (int); 00218 void setLineWidth9 (int); 00219 00220 void setLineStyle1 (Qt::PenStyle); 00221 void setLineStyle2 (Qt::PenStyle); 00222 void setLineStyle3 (Qt::PenStyle); 00223 void setLineStyle4 (Qt::PenStyle); 00224 void setLineStyle5 (Qt::PenStyle); 00225 void setLineStyle6 (Qt::PenStyle); 00226 void setLineStyle7 (Qt::PenStyle); 00227 void setLineStyle8 (Qt::PenStyle); 00228 void setLineStyle9 (Qt::PenStyle); 00229 00230 void setLineMarker1 (QwtSymbol::Style); 00231 void setLineMarker2 (QwtSymbol::Style); 00232 void setLineMarker3 (QwtSymbol::Style); 00233 void setLineMarker4 (QwtSymbol::Style); 00234 void setLineMarker5 (QwtSymbol::Style); 00235 void setLineMarker6 (QwtSymbol::Style); 00236 void setLineMarker7 (QwtSymbol::Style); 00237 void setLineMarker8 (QwtSymbol::Style); 00238 void setLineMarker9 (QwtSymbol::Style); 00239 00240 void setMarkerAlpha1 (int); 00241 void setMarkerAlpha2 (int); 00242 void setMarkerAlpha3 (int); 00243 void setMarkerAlpha4 (int); 00244 void setMarkerAlpha5 (int); 00245 void setMarkerAlpha6 (int); 00246 void setMarkerAlpha7 (int); 00247 void setMarkerAlpha8 (int); 00248 void setMarkerAlpha9 (int); 00249 00250 void setZoomerColor(QColor c); 00251 void setPaletteColor(QColor c); 00252 void setAxisLabelFontSize(int axisId, int fs); 00253 void setYaxisLabelFontSize(int fs); 00254 void setXaxisLabelFontSize(int fs); 00255 void setAxesLabelFontSize(int fs); 00256 00257 void setStop(bool on); 00258 00259 void resizeSlot(QSize *s); 00260 00261 // Because of the preprocessing of slots in QT, these are not 00262 // easily separated by the version check. Make one for each 00263 // version until it's worked out. 00264 void onPickerPointSelected(const QwtDoublePoint & p); 00265 void onPickerPointSelected6(const QPointF & p); 00266 00267 signals: 00268 void plotPointSelected(const QPointF p); 00269 00270 protected slots: 00271 void legendEntryChecked(QwtPlotItem *plotItem, bool on); 00272 00273 protected: 00274 int _nplots; 00275 std::vector<QwtPlotCurve*> _plot_curve; 00276 00277 QwtPlotPanner* _panner; 00278 QwtPlotZoomer* _zoomer; 00279 00280 QwtDblClickPlotPicker *_picker; 00281 QwtPlotMagnifier *_magnifier; 00282 00283 int64_t _numPoints; 00284 00285 bool _stop; 00286 00287 QList<QColor> _trace_colors; 00288 00289 bool _autoscale_state; 00290 }; 00291 00292 #endif /* DOMAIN_DISPLAY_PLOT_H */