diff options
Diffstat (limited to 'gr-qtgui/include/gnuradio')
35 files changed, 4828 insertions, 0 deletions
diff --git a/gr-qtgui/include/gnuradio/qtgui/CMakeLists.txt b/gr-qtgui/include/gnuradio/qtgui/CMakeLists.txt new file mode 100644 index 0000000000..8f95837fec --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/CMakeLists.txt @@ -0,0 +1,61 @@ +# Copyright 2010-2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +# Install the header files +######################################################################## +install(FILES + api.h + CMakeLists.txt + constellationdisplayform.h + ConstellationDisplayPlot.h + const_sink_c.h + displayform.h + DisplayPlot.h + form_menus.h + freqdisplayform.h + freq_sink_c.h + freq_sink_f.h + FrequencyDisplayPlot.h + plot_raster.h + plot_waterfall.h + qtgui_types.h + sink_c.h + sink_f.h + spectrumdisplayform.h + SpectrumGUIClass.h + spectrumUpdateEvents.h + timedisplayform.h + TimeDomainDisplayPlot.h + timerasterdisplayform.h + TimeRasterDisplayPlot.h + timeRasterGlobalData.h + time_raster_sink_b.h + time_raster_sink_f.h + time_sink_c.h + time_sink_f.h + utils.h + waterfalldisplayform.h + WaterfallDisplayPlot.h + waterfallGlobalData.h + waterfall_sink_c.h + waterfall_sink_f.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/qtgui + COMPONENT "qtgui_devel" +) diff --git a/gr-qtgui/include/gnuradio/qtgui/ConstellationDisplayPlot.h b/gr-qtgui/include/gnuradio/qtgui/ConstellationDisplayPlot.h new file mode 100644 index 0000000000..52a74b6d40 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/ConstellationDisplayPlot.h @@ -0,0 +1,74 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008-2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef CONSTELLATION_DISPLAY_PLOT_H +#define CONSTELLATION_DISPLAY_PLOT_H + +#include <stdint.h> +#include <cstdio> +#include <vector> +#include <gnuradio/qtgui/DisplayPlot.h> + +/*! + * \brief QWidget for displaying constellaton (I&Q) plots. + * \ingroup qtgui_blk + */ +class ConstellationDisplayPlot : public DisplayPlot +{ + Q_OBJECT + +public: + ConstellationDisplayPlot(int nplots, QWidget*); + virtual ~ConstellationDisplayPlot(); + + void plotNewData(const std::vector<double*> realDataPoints, + const std::vector<double*> imagDataPoints, + const int64_t numDataPoints, + const double timeInterval); + + // Old method to be removed + void plotNewData(const double* realDataPoints, + const double* imagDataPoints, + const int64_t numDataPoints, + const double timeInterval); + + void replot(); + + void set_xaxis(double min, double max); + void set_yaxis(double min, double max); + void set_axis(double xmin, double xmax, + double ymin, double ymax); + void set_pen_size(int size); + +public slots: + void setAutoScale(bool state); + +private: + void _autoScale(double bottom, double top); + + std::vector<double*> _realDataPoints; + std::vector<double*> _imagDataPoints; + + int64_t _penSize; +}; + +#endif /* CONSTELLATION_DISPLAY_PLOT_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/DisplayPlot.h b/gr-qtgui/include/gnuradio/qtgui/DisplayPlot.h new file mode 100644 index 0000000000..bafc712aac --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/DisplayPlot.h @@ -0,0 +1,291 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008-2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef DOMAIN_DISPLAY_PLOT_H +#define DOMAIN_DISPLAY_PLOT_H + +#include <stdint.h> +#include <cstdio> +#include <vector> +#include <qwt_plot.h> +#include <qwt_painter.h> +#include <qwt_plot_canvas.h> +#include <qwt_plot_curve.h> +#include <qwt_scale_engine.h> +#include <qwt_scale_widget.h> +#include <qwt_plot_zoomer.h> +#include <qwt_plot_panner.h> +#include <qwt_plot_magnifier.h> +#include <qwt_plot_marker.h> +#include <qwt_symbol.h> +#include <gnuradio/qtgui/utils.h> + +#if QWT_VERSION >= 0x060000 +#include <qwt_compat.h> +#endif + +typedef QList<QColor> QColorList; +Q_DECLARE_METATYPE ( QColorList ) + +/*! + * \brief QWidget base plot to build QTGUI plotting tools. + * \ingroup qtgui_blk + */ +class DisplayPlot:public QwtPlot{ + Q_OBJECT + + Q_PROPERTY ( QColor line_color1 READ getLineColor1 WRITE setLineColor1 ) + Q_PROPERTY ( QColor line_color2 READ getLineColor2 WRITE setLineColor2 ) + Q_PROPERTY ( QColor line_color3 READ getLineColor3 WRITE setLineColor3 ) + Q_PROPERTY ( QColor line_color4 READ getLineColor4 WRITE setLineColor4 ) + Q_PROPERTY ( QColor line_color5 READ getLineColor5 WRITE setLineColor5 ) + Q_PROPERTY ( QColor line_color6 READ getLineColor6 WRITE setLineColor6 ) + Q_PROPERTY ( QColor line_color7 READ getLineColor7 WRITE setLineColor7 ) + Q_PROPERTY ( QColor line_color8 READ getLineColor8 WRITE setLineColor8 ) + Q_PROPERTY ( QColor line_color9 READ getLineColor9 WRITE setLineColor9 ) + + Q_PROPERTY ( int line_width1 READ getLineWidth1 WRITE setLineWidth1 ) + Q_PROPERTY ( int line_width2 READ getLineWidth2 WRITE setLineWidth2 ) + Q_PROPERTY ( int line_width3 READ getLineWidth3 WRITE setLineWidth3 ) + Q_PROPERTY ( int line_width4 READ getLineWidth4 WRITE setLineWidth4 ) + Q_PROPERTY ( int line_width5 READ getLineWidth5 WRITE setLineWidth5 ) + Q_PROPERTY ( int line_width6 READ getLineWidth6 WRITE setLineWidth6 ) + Q_PROPERTY ( int line_width7 READ getLineWidth7 WRITE setLineWidth7 ) + Q_PROPERTY ( int line_width8 READ getLineWidth8 WRITE setLineWidth8 ) + Q_PROPERTY ( int line_width9 READ getLineWidth9 WRITE setLineWidth9 ) + + Q_PROPERTY ( Qt::PenStyle line_style1 READ getLineStyle1 WRITE setLineStyle1 ) + Q_PROPERTY ( Qt::PenStyle line_style2 READ getLineStyle2 WRITE setLineStyle2 ) + Q_PROPERTY ( Qt::PenStyle line_style3 READ getLineStyle3 WRITE setLineStyle3 ) + Q_PROPERTY ( Qt::PenStyle line_style4 READ getLineStyle4 WRITE setLineStyle4 ) + Q_PROPERTY ( Qt::PenStyle line_style5 READ getLineStyle5 WRITE setLineStyle5 ) + Q_PROPERTY ( Qt::PenStyle line_style6 READ getLineStyle6 WRITE setLineStyle6 ) + Q_PROPERTY ( Qt::PenStyle line_style7 READ getLineStyle7 WRITE setLineStyle7 ) + Q_PROPERTY ( Qt::PenStyle line_style8 READ getLineStyle8 WRITE setLineStyle8 ) + Q_PROPERTY ( Qt::PenStyle line_style9 READ getLineStyle9 WRITE setLineStyle9 ) + + typedef QwtSymbol::Style QwtSymbolStyle; + + Q_ENUMS ( QwtSymbolStyle ) + Q_PROPERTY ( QwtSymbolStyle line_marker1 READ getLineMarker1 WRITE setLineMarker1 ) + Q_PROPERTY ( QwtSymbolStyle line_marker2 READ getLineMarker2 WRITE setLineMarker2 ) + Q_PROPERTY ( QwtSymbolStyle line_marker3 READ getLineMarker3 WRITE setLineMarker3 ) + Q_PROPERTY ( QwtSymbolStyle line_marker4 READ getLineMarker4 WRITE setLineMarker4 ) + Q_PROPERTY ( QwtSymbolStyle line_marker5 READ getLineMarker5 WRITE setLineMarker5 ) + Q_PROPERTY ( QwtSymbolStyle line_marker6 READ getLineMarker6 WRITE setLineMarker6 ) + Q_PROPERTY ( QwtSymbolStyle line_marker7 READ getLineMarker7 WRITE setLineMarker7 ) + Q_PROPERTY ( QwtSymbolStyle line_marker8 READ getLineMarker8 WRITE setLineMarker8 ) + Q_PROPERTY ( QwtSymbolStyle line_marker9 READ getLineMarker9 WRITE setLineMarker9 ) + + Q_PROPERTY ( int marker_alpha1 READ getMarkerAlpha1 WRITE setMarkerAlpha1 ) + Q_PROPERTY ( int marker_alpha2 READ getMarkerAlpha2 WRITE setMarkerAlpha2 ) + Q_PROPERTY ( int marker_alpha3 READ getMarkerAlpha3 WRITE setMarkerAlpha3 ) + Q_PROPERTY ( int marker_alpha4 READ getMarkerAlpha4 WRITE setMarkerAlpha4 ) + Q_PROPERTY ( int marker_alpha5 READ getMarkerAlpha5 WRITE setMarkerAlpha5 ) + Q_PROPERTY ( int marker_alpha6 READ getMarkerAlpha6 WRITE setMarkerAlpha6 ) + Q_PROPERTY ( int marker_alpha7 READ getMarkerAlpha7 WRITE setMarkerAlpha7 ) + Q_PROPERTY ( int marker_alpha8 READ getMarkerAlpha8 WRITE setMarkerAlpha8 ) + Q_PROPERTY ( int marker_alpha9 READ getMarkerAlpha9 WRITE setMarkerAlpha9 ) + + Q_PROPERTY ( QColor zoomer_color READ getZoomerColor WRITE setZoomerColor ) + Q_PROPERTY ( QColor palette_color READ getPaletteColor WRITE setPaletteColor ) + Q_PROPERTY ( int yaxis_label_font_size READ getYaxisLabelFontSize WRITE setYaxisLabelFontSize ) + Q_PROPERTY ( int xaxis_label_font_size READ getXaxisLabelFontSize WRITE setXaxisLabelFontSize ) + Q_PROPERTY ( int axes_label_font_size READ getAxesLabelFontSize WRITE setAxesLabelFontSize ) + +public: + DisplayPlot(int nplots, QWidget*); + virtual ~DisplayPlot(); + + virtual void replot() = 0; + + const QColor getLineColor1 () const; + const QColor getLineColor2 () const; + const QColor getLineColor3 () const; + const QColor getLineColor4 () const; + const QColor getLineColor5 () const; + const QColor getLineColor6 () const; + const QColor getLineColor7 () const; + const QColor getLineColor8 () const; + const QColor getLineColor9 () const; + + int getLineWidth1 () const; + int getLineWidth2 () const; + int getLineWidth3 () const; + int getLineWidth4 () const; + int getLineWidth5 () const; + int getLineWidth6 () const; + int getLineWidth7 () const; + int getLineWidth8 () const; + int getLineWidth9 () const; + + const Qt::PenStyle getLineStyle1 () const; + const Qt::PenStyle getLineStyle2 () const; + const Qt::PenStyle getLineStyle3 () const; + const Qt::PenStyle getLineStyle4 () const; + const Qt::PenStyle getLineStyle5 () const; + const Qt::PenStyle getLineStyle6 () const; + const Qt::PenStyle getLineStyle7 () const; + const Qt::PenStyle getLineStyle8 () const; + const Qt::PenStyle getLineStyle9 () const; + + const QwtSymbol::Style getLineMarker1 () const; + const QwtSymbol::Style getLineMarker2 () const; + const QwtSymbol::Style getLineMarker3 () const; + const QwtSymbol::Style getLineMarker4 () const; + const QwtSymbol::Style getLineMarker5 () const; + const QwtSymbol::Style getLineMarker6 () const; + const QwtSymbol::Style getLineMarker7 () const; + const QwtSymbol::Style getLineMarker8 () const; + const QwtSymbol::Style getLineMarker9 () const; + + int getMarkerAlpha1 () const; + int getMarkerAlpha2 () const; + int getMarkerAlpha3 () const; + int getMarkerAlpha4 () const; + int getMarkerAlpha5 () const; + int getMarkerAlpha6 () const; + int getMarkerAlpha7 () const; + int getMarkerAlpha8 () const; + int getMarkerAlpha9 () const; + + QColor getZoomerColor() const; + QColor getPaletteColor() const; + int getAxisLabelFontSize(int axisId) const; + int getYaxisLabelFontSize() const; + int getXaxisLabelFontSize() const; + int getAxesLabelFontSize() const; + + // Make sure to create your won PlotNewData method in the derived + // class: + // void PlotNewData(...); + +public slots: + void setYaxis(double min, double max); + void setXaxis(double min, double max); + void setLineLabel(int which, QString label); + QString getLineLabel(int which); + void setLineColor(int which, QColor color); + QColor getLineColor(int which) const; + void setLineWidth(int which, int width); + int getLineWidth(int which) const; + void setLineStyle(int which, Qt::PenStyle style); + const Qt::PenStyle getLineStyle(int which) const; + void setLineMarker(int which, QwtSymbol::Style marker); + const QwtSymbol::Style getLineMarker(int which) const; + void setMarkerAlpha(int which, int alpha); + int getMarkerAlpha(int which) const; + // Need a function for each curve for setting via stylesheet. + // Can't use preprocessor directives because we're inside a Q_OBJECT. + void setLineColor1 (QColor); + void setLineColor2 (QColor); + void setLineColor3 (QColor); + void setLineColor4 (QColor); + void setLineColor5 (QColor); + void setLineColor6 (QColor); + void setLineColor7 (QColor); + void setLineColor8 (QColor); + void setLineColor9 (QColor); + + void setLineWidth1 (int); + void setLineWidth2 (int); + void setLineWidth3 (int); + void setLineWidth4 (int); + void setLineWidth5 (int); + void setLineWidth6 (int); + void setLineWidth7 (int); + void setLineWidth8 (int); + void setLineWidth9 (int); + + void setLineStyle1 (Qt::PenStyle); + void setLineStyle2 (Qt::PenStyle); + void setLineStyle3 (Qt::PenStyle); + void setLineStyle4 (Qt::PenStyle); + void setLineStyle5 (Qt::PenStyle); + void setLineStyle6 (Qt::PenStyle); + void setLineStyle7 (Qt::PenStyle); + void setLineStyle8 (Qt::PenStyle); + void setLineStyle9 (Qt::PenStyle); + + void setLineMarker1 (QwtSymbol::Style); + void setLineMarker2 (QwtSymbol::Style); + void setLineMarker3 (QwtSymbol::Style); + void setLineMarker4 (QwtSymbol::Style); + void setLineMarker5 (QwtSymbol::Style); + void setLineMarker6 (QwtSymbol::Style); + void setLineMarker7 (QwtSymbol::Style); + void setLineMarker8 (QwtSymbol::Style); + void setLineMarker9 (QwtSymbol::Style); + + void setMarkerAlpha1 (int); + void setMarkerAlpha2 (int); + void setMarkerAlpha3 (int); + void setMarkerAlpha4 (int); + void setMarkerAlpha5 (int); + void setMarkerAlpha6 (int); + void setMarkerAlpha7 (int); + void setMarkerAlpha8 (int); + void setMarkerAlpha9 (int); + + void setZoomerColor(QColor c); + void setPaletteColor(QColor c); + void setAxisLabelFontSize(int axisId, int fs); + void setYaxisLabelFontSize(int fs); + void setXaxisLabelFontSize(int fs); + void setAxesLabelFontSize(int fs); + + void setStop(bool on); + + void resizeSlot(QSize *s); + + // Because of the preprocessing of slots in QT, these are not + // easily separated by the version check. Make one for each + // version until it's worked out. + void onPickerPointSelected(const QwtDoublePoint & p); + void onPickerPointSelected6(const QPointF & p); + +signals: + void plotPointSelected(const QPointF p); + +protected slots: + void legendEntryChecked(QwtPlotItem *plotItem, bool on); + +protected: + int _nplots; + std::vector<QwtPlotCurve*> _plot_curve; + + QwtPlotPanner* _panner; + QwtPlotZoomer* _zoomer; + + QwtDblClickPlotPicker *_picker; + QwtPlotMagnifier *_magnifier; + + int64_t _numPoints; + + bool _stop; + + QList<QColor> _trace_colors; + + bool _autoscale_state; +}; + +#endif /* DOMAIN_DISPLAY_PLOT_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/FrequencyDisplayPlot.h b/gr-qtgui/include/gnuradio/qtgui/FrequencyDisplayPlot.h new file mode 100644 index 0000000000..220dcd7546 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/FrequencyDisplayPlot.h @@ -0,0 +1,164 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008-2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef FREQUENCY_DISPLAY_PLOT_HPP +#define FREQUENCY_DISPLAY_PLOT_HPP + +#include <stdint.h> +#include <cstdio> +#include <vector> +#include <gnuradio/qtgui/DisplayPlot.h> + +/*! + * \brief QWidget for displaying frequency domain (PSD) plots. + * \ingroup qtgui_blk + */ +class FrequencyDisplayPlot: public DisplayPlot +{ + Q_OBJECT + + Q_PROPERTY ( QColor min_fft_color READ getMinFFTColor WRITE setMinFFTColor ) + Q_PROPERTY ( QColor max_fft_color READ getMaxFFTColor WRITE setMaxFFTColor ) + Q_PROPERTY ( bool min_fft_visible READ getMinFFTVisible WRITE setMinFFTVisible ) + Q_PROPERTY ( bool max_fft_visible READ getMaxFFTVisible WRITE setMaxFFTVisible ) + Q_PROPERTY ( QColor marker_lower_intensity_color READ getMarkerLowerIntensityColor WRITE setMarkerLowerIntensityColor ) + Q_PROPERTY ( bool marker_lower_intensity_visible READ getMarkerLowerIntensityVisible WRITE setMarkerLowerIntensityVisible ) + Q_PROPERTY ( QColor marker_upper_intensity_color READ getMarkerUpperIntensityColor WRITE setMarkerUpperIntensityColor ) + Q_PROPERTY ( bool marker_upper_intensity_visible READ getMarkerUpperIntensityVisible WRITE setMarkerUpperIntensityVisible ) + Q_PROPERTY ( QColor marker_peak_amplitude_color READ getMarkerPeakAmplitudeColor WRITE setMarkerPeakAmplitudeColor ) + Q_PROPERTY ( QColor marker_noise_floor_amplitude_color READ getMarkerNoiseFloorAmplitudeColor WRITE setMarkerNoiseFloorAmplitudeColor ) + Q_PROPERTY ( bool marker_noise_floor_amplitude_visible READ getMarkerNoiseFloorAmplitudeVisible WRITE setMarkerNoiseFloorAmplitudeVisible ) + Q_PROPERTY ( QColor marker_CF_color READ getMarkerCFColor WRITE setMarkerCFColor ) + +public: + FrequencyDisplayPlot(int nplots, QWidget*); + virtual ~FrequencyDisplayPlot(); + + void setFrequencyRange(const double, const double, + const double units=1000.0, + const std::string &strunits = "kHz"); + double getStartFrequency()const; + double getStopFrequency()const; + + void plotNewData(const std::vector<double*> dataPoints, + const int64_t numDataPoints, + const double noiseFloorAmplitude, const double peakFrequency, + const double peakAmplitude, const double timeInterval); + + // Old method to be removed + void plotNewData(const double* dataPoints, + const int64_t numDataPoints, + const double noiseFloorAmplitude, const double peakFrequency, + const double peakAmplitude, const double timeInterval); + + void clearMaxData(); + void clearMinData(); + + void replot(); + + void setYaxis(double min, double max); + + void setTraceColour (QColor); + void setBGColour (QColor c); + void showCFMarker (const bool); + + const bool getMaxFFTVisible() const; + const bool getMinFFTVisible() const; + const QColor getMinFFTColor() const; + const QColor getMaxFFTColor() const; + const QColor getMarkerLowerIntensityColor () const; + const bool getMarkerLowerIntensityVisible () const; + const QColor getMarkerUpperIntensityColor () const; + const bool getMarkerUpperIntensityVisible () const; + const QColor getMarkerPeakAmplitudeColor () const; + const bool getMarkerNoiseFloorAmplitudeVisible () const; + const QColor getMarkerNoiseFloorAmplitudeColor () const; + const QColor getMarkerCFColor () const; + +public slots: + void setMaxFFTVisible(const bool); + void setMinFFTVisible(const bool); + void setMinFFTColor (QColor c); + void setMaxFFTColor (QColor c); + void setMarkerLowerIntensityColor (QColor c); + void setMarkerLowerIntensityVisible (bool visible); + void setMarkerUpperIntensityColor (QColor c); + void setMarkerUpperIntensityVisible (bool visible); + void setMarkerPeakAmplitudeColor (QColor c); + void setMarkerNoiseFloorAmplitudeVisible (bool visible); + void setMarkerNoiseFloorAmplitudeColor (QColor c); + void setMarkerCFColor (QColor c); + + void setLowerIntensityLevel(const double); + void setUpperIntensityLevel(const double); + + void onPickerPointSelected(const QwtDoublePoint & p); + void onPickerPointSelected6(const QPointF & p); + + void setAutoScale(bool state); + +private: + void _resetXAxisPoints(); + void _autoScale(double bottom, double top); + + std::vector<double*> _dataPoints; + + QwtPlotCurve* _min_fft_plot_curve; + QwtPlotCurve* _max_fft_plot_curve; + QColor _min_fft_color; + bool _min_fft_visible; + QColor _max_fft_color; + bool _max_fft_visible; + QColor _marker_lower_intensity_color; + bool _marker_lower_intensity_visible; + QColor _marker_upper_intensity_color; + bool _marker_upper_intensity_visible; + QColor _marker_peak_amplitude_color; + QColor _marker_noise_floor_amplitude_color; + bool _marker_noise_floor_amplitude_visible; + QColor _marker_CF_color; + + double _startFrequency; + double _stopFrequency; + double _maxYAxis; + double _minYAxis; + + QwtPlotMarker* _lower_intensity_marker; + QwtPlotMarker* _upper_intensity_marker; + + QwtPlotMarker *_markerPeakAmplitude; + QwtPlotMarker *_markerNoiseFloorAmplitude; + QwtPlotMarker *_markerCF; + + double* _xAxisPoints; + int _xAxisMultiplier; + + double* _minFFTPoints; + double* _maxFFTPoints; + + double _peakFrequency; + double _peakAmplitude; + + double _noiseFloorAmplitude; +}; + +#endif /* FREQUENCY_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/include/gnuradio/qtgui/SpectrumGUIClass.h b/gr-qtgui/include/gnuradio/qtgui/SpectrumGUIClass.h new file mode 100644 index 0000000000..f95ab6477a --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/SpectrumGUIClass.h @@ -0,0 +1,134 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008-2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef SPECTRUM_GUI_CLASS_HPP +#define SPECTRUM_GUI_CLASS_HPP + +#include <gnuradio/thread/thread.h> +#include <qwidget.h> +#include <qapplication.h> +#include <qlabel.h> +#include <qslider.h> +#include <gnuradio/qtgui/spectrumUpdateEvents.h> + +class SpectrumDisplayForm; +#include <gnuradio/qtgui/spectrumdisplayform.h> + +#include <cmath> + +#include <complex> +#include <vector> +#include <string> + +/*! + * \brief QWidget class for controlling plotting. + * \ingroup qtgui_blk + */ +class SpectrumGUIClass +{ +public: + SpectrumGUIClass(const uint64_t maxDataSize, const uint64_t fftSize, + const double newCenterFrequency, + const double newStartFrequency, + const double newStopFrequency); + ~SpectrumGUIClass(); + void reset(); + + void openSpectrumWindow(QWidget*, + const bool frequency=true, const bool waterfall=true, + const bool time=true, const bool constellation=true); + void setDisplayTitle(const std::string); + + bool getWindowOpenFlag(); + void setWindowOpenFlag(const bool); + + void setFrequencyRange(const double, const double, const double); + double getStartFrequency(); + double getStopFrequency(); + double getCenterFrequency(); + + void updateWindow(const bool, const float*, + const uint64_t, const float*, + const uint64_t, const float*, + const uint64_t, + const gr::high_res_timer_type, const bool); + + float getPowerValue(); + void setPowerValue(const float); + + int getWindowType(); + void setWindowType(const int); + + int getFFTSize(); + int getFFTSizeIndex(); + void setFFTSize(const int); + + gr::high_res_timer_type getLastGUIUpdateTime(); + void setLastGUIUpdateTime(const gr::high_res_timer_type); + + unsigned int getPendingGUIUpdateEvents(); + void incrementPendingGUIUpdateEvents(); + void decrementPendingGUIUpdateEvents(); + void resetPendingGUIUpdateEvents(); + + static const long MAX_FFT_SIZE; + static const long MIN_FFT_SIZE; + + QWidget* qwidget(); + + void setTimeDomainAxis(double min, double max); + void setConstellationAxis(double xmin, double xmax, + double ymin, double ymax); + void setConstellationPenSize(int size); + void setFrequencyAxis(double min, double max); + + void setUpdateTime(double t); + +protected: + +private: + + gr::thread::mutex d_mutex; + int64_t _dataPoints; + std::string _title; + double _centerFrequency; + double _startFrequency; + double _stopFrequency; + float _powerValue; + bool _windowOpennedFlag; + int _windowType; + int64_t _lastDataPointCount; + int _fftSize; + gr::high_res_timer_type _lastGUIUpdateTime; + unsigned int _pendingGUIUpdateEventsCount; + int _droppedEntriesCount; + bool _fftBuffersCreatedFlag; + double _updateTime; + + SpectrumDisplayForm* _spectrumDisplayForm; + + float* _fftPoints; + double* _realTimeDomainPoints; + double* _imagTimeDomainPoints; +}; + +#endif /* SPECTRUM_GUI_CLASS_HPP */ diff --git a/gr-qtgui/include/gnuradio/qtgui/TimeDomainDisplayPlot.h b/gr-qtgui/include/gnuradio/qtgui/TimeDomainDisplayPlot.h new file mode 100644 index 0000000000..1ef5ddd85c --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/TimeDomainDisplayPlot.h @@ -0,0 +1,71 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008-2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef TIME_DOMAIN_DISPLAY_PLOT_H +#define TIME_DOMAIN_DISPLAY_PLOT_H + +#include <stdint.h> +#include <cstdio> +#include <vector> +#include <gnuradio/qtgui/DisplayPlot.h> + +/*! + * \brief QWidget for displaying time domain plots. + * \ingroup qtgui_blk + */ +class TimeDomainDisplayPlot: public DisplayPlot +{ + Q_OBJECT + +public: + TimeDomainDisplayPlot(int nplots, QWidget*); + virtual ~TimeDomainDisplayPlot(); + + void plotNewData(const std::vector<double*> dataPoints, + const int64_t numDataPoints, const double timeInterval); + + void replot(); + + void stemPlot(bool en); + +public slots: + void setSampleRate(double sr, double units, + const std::string &strunits); + + void setAutoScale(bool state); + void setSemilogx(bool en); + void setSemilogy(bool en); + +private: + void _resetXAxisPoints(); + void _autoScale(double bottom, double top); + + std::vector<double*> _dataPoints; + double* _xAxisPoints; + + double _sampleRate; + + bool d_semilogx; + bool d_semilogy; +}; + +#endif /* TIME_DOMAIN_DISPLAY_PLOT_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/TimeRasterDisplayPlot.h b/gr-qtgui/include/gnuradio/qtgui/TimeRasterDisplayPlot.h new file mode 100644 index 0000000000..f22028c3c9 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/TimeRasterDisplayPlot.h @@ -0,0 +1,108 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef TIMERASTER_DISPLAY_PLOT_H +#define TIMERASTER_DISPLAY_PLOT_H + +#include <stdint.h> +#include <cstdio> +#include <vector> +#include <qwt_plot_rasteritem.h> +#include <gnuradio/qtgui/DisplayPlot.h> +#include <gnuradio/qtgui/timeRasterGlobalData.h> +#include <gnuradio/qtgui/plot_raster.h> +#include <gnuradio/high_res_timer.h> + +#if QWT_VERSION < 0x060000 +#include <gnuradio/qtgui/plot_waterfall.h> +#else +#include <qwt_compat.h> +#endif + +/*! + * \brief QWidget for time raster (time vs. time) plots. + * \ingroup qtgui_blk + */ +class TimeRasterDisplayPlot: public DisplayPlot +{ + Q_OBJECT + +public: + TimeRasterDisplayPlot(int nplots, + double samp_rate, + double rows, double cols, + QWidget*); + virtual ~TimeRasterDisplayPlot(); + + void reset(); + + void setNumRows(double rows); + void setNumCols(double cols); + void setAlpha(int which, int alpha); + void setSampleRate(double samprate); + + double numRows() const; + double numCols() const; + + int getAlpha(int which); + + void setPlotDimensions(const double rows, const double cols, + const double units, const std::string &strunits); + + void plotNewData(const std::vector<double*> dataPoints, + const int64_t numDataPoints); + + void plotNewData(const double* dataPoints, + const int64_t numDataPoints); + + void setIntensityRange(const double minIntensity, + const double maxIntensity); + + void replot(void); + + int getIntensityColorMapType(int) const; + void setIntensityColorMapType(const int, const int, const QColor, const QColor); + const QColor getUserDefinedLowIntensityColor() const; + const QColor getUserDefinedHighIntensityColor() const; + + double getMinIntensity(int which) const; + double getMaxIntensity(int which) const; + +signals: + void updatedLowerIntensityLevel(const double); + void updatedUpperIntensityLevel(const double); + +private: + void _updateIntensityRangeDisplay(); + + std::vector<TimeRasterData*> d_data; + std::vector<PlotTimeRaster*> d_raster; + + double d_samp_rate; + double d_rows, d_cols; + + std::vector<int> d_color_map_type; + QColor d_low_intensity; + QColor d_high_intensity; +}; + +#endif /* TIMERASTER_DISPLAY_PLOT_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/WaterfallDisplayPlot.h b/gr-qtgui/include/gnuradio/qtgui/WaterfallDisplayPlot.h new file mode 100644 index 0000000000..62ea41a87c --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/WaterfallDisplayPlot.h @@ -0,0 +1,125 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008-2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef WATERFALL_DISPLAY_PLOT_H +#define WATERFALL_DISPLAY_PLOT_H + +#include <stdint.h> +#include <cstdio> +#include <vector> +#include <qwt_plot_spectrogram.h> +#include <gnuradio/qtgui/DisplayPlot.h> +#include <gnuradio/qtgui/waterfallGlobalData.h> +#include <gnuradio/high_res_timer.h> + +#if QWT_VERSION < 0x060000 +#include <gnuradio/qtgui/plot_waterfall.h> +#else +#include <qwt_compat.h> +#endif + +/*! + * \brief QWidget for displaying waterfall (spectrogram) plots. + * \ingroup qtgui_blk + */ +class WaterfallDisplayPlot: public DisplayPlot +{ + Q_OBJECT + + Q_PROPERTY ( int intensity_color_map_type1 READ getIntensityColorMapType1 WRITE setIntensityColorMapType1 ) + Q_PROPERTY ( QColor low_intensity_color READ getUserDefinedLowIntensityColor WRITE setUserDefinedLowIntensityColor ) + Q_PROPERTY ( QColor high_intensity_color READ getUserDefinedHighIntensityColor WRITE setUserDefinedHighIntensityColor ) + + +public: + WaterfallDisplayPlot(int nplots, QWidget*); + virtual ~WaterfallDisplayPlot(); + + void resetAxis(); + + void setFrequencyRange(const double, const double, + const double units=1000.0, + const std::string &strunits = "kHz"); + double getStartFrequency() const; + double getStopFrequency() const; + + void plotNewData(const std::vector<double*> dataPoints, + const int64_t numDataPoints, + const double timePerFFT, + const gr::high_res_timer_type timestamp, + const int droppedFrames); + + // to be removed + void plotNewData(const double* dataPoints, + const int64_t numDataPoints, + const double timePerFFT, + const gr::high_res_timer_type timestamp, + const int droppedFrames); + + void setIntensityRange(const double minIntensity, const double maxIntensity); + double getMinIntensity(int which) const; + double getMaxIntensity(int which) const; + + void replot(void); + void clearData(); + + int getIntensityColorMapType(int) const; + int getIntensityColorMapType1() const; + const QColor getUserDefinedLowIntensityColor() const; + const QColor getUserDefinedHighIntensityColor() const; + + int getAlpha(int which); + void setAlpha(int which, int alpha); + +public slots: + void setIntensityColorMapType(const int, const int, const QColor, const QColor); + void setIntensityColorMapType1(int); + void setUserDefinedLowIntensityColor(QColor); + void setUserDefinedHighIntensityColor(QColor); + +signals: + void updatedLowerIntensityLevel(const double); + void updatedUpperIntensityLevel(const double); + +private: + void _updateIntensityRangeDisplay(); + + double _startFrequency; + double _stopFrequency; + int _xAxisMultiplier; + + std::vector<WaterfallData*> d_data; + +#if QWT_VERSION < 0x060000 + std::vector<PlotWaterfall*> d_spectrogram; +#else + std::vector<QwtPlotSpectrogram*> d_spectrogram; +#endif + + gr::high_res_timer_type _lastReplot; + + std::vector<int> _intensityColorMapType; + QColor _userDefinedLowIntensityColor; + QColor _userDefinedHighIntensityColor; +}; + +#endif /* WATERFALL_DISPLAY_PLOT_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/api.h b/gr-qtgui/include/gnuradio/qtgui/api.h new file mode 100644 index 0000000000..0a05544842 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/api.h @@ -0,0 +1,33 @@ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_API_H +#define INCLUDED_QTGUI_API_H + +#include <gnuradio/attributes.h> + +#ifdef gnuradio_qtgui_EXPORTS +# define QTGUI_API __GR_ATTR_EXPORT +#else +# define QTGUI_API __GR_ATTR_IMPORT +#endif + +#endif /* INCLUDED_QTGUI_API_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/const_sink_c.h b/gr-qtgui/include/gnuradio/qtgui/const_sink_c.h new file mode 100644 index 0000000000..d430b6ffdd --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/const_sink_c.h @@ -0,0 +1,100 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_CONST_SINK_C_H +#define INCLUDED_QTGUI_CONST_SINK_C_H + +#include <Python.h> +#include <gnuradio/qtgui/api.h> +#include <gnuradio/sync_block.h> +#include <qapplication.h> +#include <gnuradio/filter/firdes.h> + +namespace gr { + namespace qtgui { + + /*! + * \brief A graphical sink to display the IQ constellation of multiple signals. + * \ingroup instrumentation_blk + * \ingroup qtgui_blk + * + * \details + * This is a QT-based graphical sink the takes set of a complex + * streams and plots them on an IQ constellation plot. + */ + class QTGUI_API const_sink_c : virtual public sync_block + { + public: + // gr::qtgui::const_sink_c::sptr + typedef boost::shared_ptr<const_sink_c> sptr; + + /*! + * \brief Build a complex PSD sink. + * + * \param size number of points to plot at once + * \param name title for the plot + * \param nconnections number of signals connected to sink + * \param parent a QWidget parent object, if any + */ + static sptr make(int size, + const std::string &name, + int nconnections=1, + QWidget *parent=NULL); + + virtual void exec_() = 0; + virtual PyObject* pyqwidget() = 0; + + virtual void set_y_axis(double min, double max) = 0; + virtual void set_x_axis(double min, double max) = 0; + + virtual void set_update_time(double t) = 0; + virtual void set_title(const std::string &title) = 0; + virtual void set_line_label(int which, const std::string &label) = 0; + virtual void set_line_color(int which, const std::string &color) = 0; + virtual void set_line_width(int which, int width) = 0; + virtual void set_line_style(int which, int style) = 0; + virtual void set_line_marker(int which, int marker) = 0; + virtual void set_nsamps(const int newsize) = 0; + virtual void set_line_alpha(int which, double alpha) = 0; + + virtual std::string title() = 0; + virtual std::string line_label(int which) = 0; + virtual std::string line_color(int which) = 0; + virtual int line_width(int which) = 0; + virtual int line_style(int which) = 0; + virtual int line_marker(int which) = 0; + virtual double line_alpha(int which) = 0; + + virtual void set_size(int width, int height) = 0; + + virtual void enable_menu(bool en=true) = 0; + virtual void enable_autoscale(bool en) = 0; + virtual int nsamps() const = 0; + virtual void reset() = 0; + + QApplication *d_qApplication; + }; + + } /* namespace qtgui */ +} /* namespace gr */ + +#endif /* INCLUDED_QTGUI_CONST_SINK_C_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/constellationdisplayform.h b/gr-qtgui/include/gnuradio/qtgui/constellationdisplayform.h new file mode 100644 index 0000000000..8e04218ed0 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/constellationdisplayform.h @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef CONSTELLATION_DISPLAY_FORM_H +#define CONSTELLATION_DISPLAY_FORM_H + +#include <gnuradio/qtgui/spectrumUpdateEvents.h> +#include <gnuradio/qtgui/ConstellationDisplayPlot.h> +#include <QtGui/QtGui> +#include <vector> + +#include <gnuradio/qtgui/displayform.h> + +/*! + * \brief DisplayForm child for managing constellaton (I&Q) plots. + * \ingroup qtgui_blk + */ +class ConstellationDisplayForm : public DisplayForm +{ + Q_OBJECT + +public: + ConstellationDisplayForm(int nplots=1, QWidget* parent = 0); + ~ConstellationDisplayForm(); + + ConstellationDisplayPlot* getPlot(); + + int getNPoints() const; + +public slots: + void customEvent(QEvent * e); + void setNPoints(const int); + + void setSampleRate(const QString &samprate); + void setYaxis(double min, double max); + void setXaxis(double min, double max); + void autoScale(bool en); + +private slots: + void newData(const QEvent*); + +private: + QIntValidator* _intValidator; + int d_npoints; +}; + +#endif /* CONSTELLATION_DISPLAY_FORM_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/displayform.h b/gr-qtgui/include/gnuradio/qtgui/displayform.h new file mode 100644 index 0000000000..df0d5a94d6 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/displayform.h @@ -0,0 +1,135 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef DISPLAY_FORM_H +#define DISPLAY_FORM_H + +#include <gnuradio/qtgui/spectrumUpdateEvents.h> +#include <QtGui/QtGui> +#include <vector> + +#include <qwt_plot_grid.h> +#include <qwt_plot_layout.h> + +#include <gnuradio/qtgui/DisplayPlot.h> +#include <gnuradio/qtgui/form_menus.h> + +/*! + * \brief Base class for setting up and managing QTGUI plot forms. + * \ingroup qtgui_blk + */ +class DisplayForm : public QWidget +{ + Q_OBJECT + + public: + DisplayForm(int nplots=1, QWidget* parent = 0); + ~DisplayForm(); + + virtual DisplayPlot* getPlot() = 0; + void Reset(); + bool isClosed() const; + + void enableMenu(bool en=true); + +public slots: + void resizeEvent( QResizeEvent * e ); + void mousePressEvent( QMouseEvent * e); + virtual void customEvent( QEvent * e ) = 0; + + void closeEvent( QCloseEvent * e ); + + void setUpdateTime(double t); + + void setTitle(const QString &title); + void setLineLabel(int which, const QString &label); + void setLineColor(int which, const QString &color); + void setLineWidth(int which, int width); + void setLineStyle(int which, Qt::PenStyle style); + void setLineMarker(int which, QwtSymbol::Style style); + void setMarkerAlpha(int which, int alpha); + + QString title(); + QString lineLabel(int which); + QString lineColor(int which); + int lineWidth(int which); + Qt::PenStyle lineStyle(int which); + QwtSymbol::Style lineMarker(int which); + int markerAlpha(int which); + + virtual void setSampleRate(const QString &rate) = 0; + + void setStop(bool on); + void setStop(); + + void setGrid(bool on); + + void saveFigure(); + +private slots: + virtual void newData(const QEvent*) = 0; + virtual void autoScale(bool) = 0; + void updateGuiTimer(); + + void onPlotPointSelected(const QPointF p); + +signals: + void plotPointSelected(const QPointF p, int type); + +protected: + bool _isclosed; + + int _nplots; + + QGridLayout *_layout; + DisplayPlot* _displayPlot; + bool _systemSpecifiedFlag; + + QwtPlotGrid *_grid; + + bool _menu_on; + QMenu *_menu; + + QAction *_stop_act; + bool _stop_state; + QAction *_grid_act; + bool _grid_state; + + QAction *_autoscale_act; + bool _autoscale_state; + + QList<QMenu*> _lines_menu; + QList<LineTitleAction*> _line_title_act; + QList<LineColorMenu*> _line_color_menu; + QList<LineWidthMenu*> _line_width_menu; + QList<LineStyleMenu*> _line_style_menu; + QList<LineMarkerMenu*> _line_marker_menu; + QList<MarkerAlphaMenu*> _marker_alpha_menu; + + PopupMenu *_samp_rate_act; + QAction *_save_act; + + QTimer *d_displayTimer; + double d_update_time; +}; + +#endif /* DISPLAY_FORM_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/form_menus.h b/gr-qtgui/include/gnuradio/qtgui/form_menus.h new file mode 100644 index 0000000000..1158f337a2 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/form_menus.h @@ -0,0 +1,1001 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef FORM_MENUS_H +#define FORM_MENUS_H + +#include <stdexcept> +#include <vector> +#include <QtGui/QtGui> +#include <qwt_symbol.h> +#include <gnuradio/filter/firdes.h> +#include <gnuradio/qtgui/qtgui_types.h> + +class LineColorMenu: public QMenu +{ + Q_OBJECT + +public: + LineColorMenu(int which, QWidget *parent) + : QMenu("Line Color", parent), d_which(which) + { + d_act.push_back(new QAction("Blue", this)); + d_act.push_back(new QAction("Red", this)); + d_act.push_back(new QAction("Green", this)); + d_act.push_back(new QAction("Black", this)); + d_act.push_back(new QAction("Cyan", this)); + d_act.push_back(new QAction("Magenta", this)); + d_act.push_back(new QAction("Yellow", this)); + d_act.push_back(new QAction("Gray", this)); + d_act.push_back(new QAction("Dark Red", this)); + d_act.push_back(new QAction("Dark Green", this)); + d_act.push_back(new QAction("Dark Blue", this)); + d_act.push_back(new QAction("Dark Gray", this)); + + connect(d_act[0], SIGNAL(triggered()), this, SLOT(getBlue())); + connect(d_act[1], SIGNAL(triggered()), this, SLOT(getRed())); + connect(d_act[2], SIGNAL(triggered()), this, SLOT(getGreen())); + connect(d_act[3], SIGNAL(triggered()), this, SLOT(getBlack())); + connect(d_act[4], SIGNAL(triggered()), this, SLOT(getCyan())); + connect(d_act[5], SIGNAL(triggered()), this, SLOT(getMagenta())); + connect(d_act[6], SIGNAL(triggered()), this, SLOT(getYellow())); + connect(d_act[7], SIGNAL(triggered()), this, SLOT(getGray())); + connect(d_act[8], SIGNAL(triggered()), this, SLOT(getDarkRed())); + connect(d_act[9], SIGNAL(triggered()), this, SLOT(getDarkGreen())); + connect(d_act[10], SIGNAL(triggered()), this, SLOT(getDarkBlue())); + connect(d_act[11], SIGNAL(triggered()), this, SLOT(getDarkGray())); + + QListIterator<QAction*> i(d_act); + while(i.hasNext()) { + QAction *a = i.next(); + addAction(a); + } + } + + ~LineColorMenu() + {} + + int getNumActions() const + { + return d_act.size(); + } + + QAction * getAction(int which) + { + if(which < d_act.size()) + return d_act[which]; + else + throw std::runtime_error("LineColorMenu::getAction: which out of range.\n"); + } + +signals: + void whichTrigger(int which, const QString &name); + +public slots: + void getBlue() { emit whichTrigger(d_which, "blue"); } + void getRed() { emit whichTrigger(d_which, "red"); } + void getGreen() { emit whichTrigger(d_which, "green"); } + void getBlack() { emit whichTrigger(d_which, "black"); } + void getCyan() { emit whichTrigger(d_which, "cyan"); } + void getMagenta() { emit whichTrigger(d_which, "magenta"); } + void getYellow() { emit whichTrigger(d_which, "yellow"); } + void getGray() { emit whichTrigger(d_which, "gray"); } + void getDarkRed() { emit whichTrigger(d_which, "darkred"); } + void getDarkGreen() { emit whichTrigger(d_which, "darkgreen"); } + void getDarkBlue() { emit whichTrigger(d_which, "darkblue"); } + void getDarkGray() { emit whichTrigger(d_which, "darkgray"); } + +private: + QList<QAction *> d_act; + int d_which; +}; + + +/********************************************************************/ + + +class LineWidthMenu: public QMenu +{ + Q_OBJECT + +public: + LineWidthMenu(int which, QWidget *parent) + : QMenu("Line Width", parent), d_which(which) + { + d_act.push_back(new QAction("1", this)); + d_act.push_back(new QAction("2", this)); + d_act.push_back(new QAction("3", this)); + d_act.push_back(new QAction("4", this)); + d_act.push_back(new QAction("5", this)); + d_act.push_back(new QAction("6", this)); + d_act.push_back(new QAction("7", this)); + d_act.push_back(new QAction("8", this)); + d_act.push_back(new QAction("9", this)); + d_act.push_back(new QAction("10", this)); + + connect(d_act[0], SIGNAL(triggered()), this, SLOT(getOne())); + connect(d_act[1], SIGNAL(triggered()), this, SLOT(getTwo())); + connect(d_act[2], SIGNAL(triggered()), this, SLOT(getThree())); + connect(d_act[3], SIGNAL(triggered()), this, SLOT(getFour())); + connect(d_act[4], SIGNAL(triggered()), this, SLOT(getFive())); + connect(d_act[5], SIGNAL(triggered()), this, SLOT(getSix())); + connect(d_act[6], SIGNAL(triggered()), this, SLOT(getSeven())); + connect(d_act[7], SIGNAL(triggered()), this, SLOT(getEight())); + connect(d_act[8], SIGNAL(triggered()), this, SLOT(getNine())); + connect(d_act[9], SIGNAL(triggered()), this, SLOT(getTen())); + + QListIterator<QAction*> i(d_act); + while(i.hasNext()) { + QAction *a = i.next(); + addAction(a); + } + } + + ~LineWidthMenu() + {} + + int getNumActions() const + { + return d_act.size(); + } + + QAction * getAction(int which) + { + if(which < d_act.size()) + return d_act[which]; + else + throw std::runtime_error("LineWidthMenu::getAction: which out of range.\n"); + } + +signals: + void whichTrigger(int which, int width); + +public slots: + void getOne() { emit whichTrigger(d_which, 1); } + void getTwo() { emit whichTrigger(d_which, 2); } + void getThree() { emit whichTrigger(d_which, 3); } + void getFour() { emit whichTrigger(d_which, 4); } + void getFive() { emit whichTrigger(d_which, 5); } + void getSix() { emit whichTrigger(d_which, 6); } + void getSeven() { emit whichTrigger(d_which, 7); } + void getEight() { emit whichTrigger(d_which, 8); } + void getNine() { emit whichTrigger(d_which, 9); } + void getTen() { emit whichTrigger(d_which, 10); } + +private: + QList<QAction *> d_act; + int d_which; +}; + + +/********************************************************************/ + + +class LineStyleMenu: public QMenu +{ + Q_OBJECT + +public: + LineStyleMenu(int which, QWidget *parent) + : QMenu("Line Style", parent), d_which(which) + { + d_act.push_back(new QAction("None", this)); + d_act.push_back(new QAction("Solid", this)); + d_act.push_back(new QAction("Dash", this)); + d_act.push_back(new QAction("Dots", this)); + d_act.push_back(new QAction("Dash-Dot", this)); + d_act.push_back(new QAction("Dash-Dot-Dot", this)); + + connect(d_act[0], SIGNAL(triggered()), this, SLOT(getNone())); + connect(d_act[1], SIGNAL(triggered()), this, SLOT(getSolid())); + connect(d_act[2], SIGNAL(triggered()), this, SLOT(getDash())); + connect(d_act[3], SIGNAL(triggered()), this, SLOT(getDots())); + connect(d_act[4], SIGNAL(triggered()), this, SLOT(getDashDot())); + connect(d_act[5], SIGNAL(triggered()), this, SLOT(getDashDotDot())); + + QListIterator<QAction*> i(d_act); + while(i.hasNext()) { + QAction *a = i.next(); + addAction(a); + } + } + + ~LineStyleMenu() + {} + + int getNumActions() const + { + return d_act.size(); + } + + QAction * getAction(int which) + { + if(which < d_act.size()) + return d_act[which]; + else + throw std::runtime_error("LineStyleMenu::getAction: which out of range.\n"); + } + +signals: + void whichTrigger(int which, Qt::PenStyle); + +public slots: + void getNone() { emit whichTrigger(d_which, Qt::NoPen); } + void getSolid() { emit whichTrigger(d_which, Qt::SolidLine); } + void getDash() { emit whichTrigger(d_which, Qt::DashLine); } + void getDots() { emit whichTrigger(d_which, Qt::DotLine); } + void getDashDot() { emit whichTrigger(d_which, Qt::DashDotLine); } + void getDashDotDot() { emit whichTrigger(d_which, Qt::DashDotDotLine); } + +private: + QList<QAction *> d_act; + int d_which; +}; + + +/********************************************************************/ + + +class LineMarkerMenu: public QMenu +{ + Q_OBJECT + +public: + LineMarkerMenu(int which, QWidget *parent) + : QMenu("Line Marker", parent), d_which(which) + { + d_act.push_back(new QAction("None", this)); + d_act.push_back(new QAction("Circle", this)); + d_act.push_back(new QAction("Rectangle", this)); + d_act.push_back(new QAction("Diamond", this)); + d_act.push_back(new QAction("Triangle", this)); + d_act.push_back(new QAction("Down Triangle", this)); + d_act.push_back(new QAction("Left Triangle", this)); + d_act.push_back(new QAction("Right Triangle", this)); + d_act.push_back(new QAction("Cross", this)); + d_act.push_back(new QAction("X-Cross", this)); + d_act.push_back(new QAction("Horiz. Line", this)); + d_act.push_back(new QAction("Vert. Line", this)); + d_act.push_back(new QAction("Star 1", this)); + d_act.push_back(new QAction("Star 2", this)); + d_act.push_back(new QAction("Hexagon", this)); + + connect(d_act[0], SIGNAL(triggered()), this, SLOT(getNone())); + connect(d_act[1], SIGNAL(triggered()), this, SLOT(getCircle())); + connect(d_act[2], SIGNAL(triggered()), this, SLOT(getRect())); + connect(d_act[3], SIGNAL(triggered()), this, SLOT(getDiamond())); + connect(d_act[4], SIGNAL(triggered()), this, SLOT(getTriangle())); + connect(d_act[5], SIGNAL(triggered()), this, SLOT(getDTriangle())); + connect(d_act[6], SIGNAL(triggered()), this, SLOT(getLTriangle())); + connect(d_act[7], SIGNAL(triggered()), this, SLOT(getRTriangle())); + connect(d_act[8], SIGNAL(triggered()), this, SLOT(getCross())); + connect(d_act[9], SIGNAL(triggered()), this, SLOT(getXCross())); + connect(d_act[10], SIGNAL(triggered()), this, SLOT(getHLine())); + connect(d_act[11], SIGNAL(triggered()), this, SLOT(getVLine())); + connect(d_act[12], SIGNAL(triggered()), this, SLOT(getStar1())); + connect(d_act[13], SIGNAL(triggered()), this, SLOT(getStar2())); + connect(d_act[14], SIGNAL(triggered()), this, SLOT(getHexagon())); + + QListIterator<QAction*> i(d_act); + while(i.hasNext()) { + QAction *a = i.next(); + addAction(a); + } + } + + ~LineMarkerMenu() + {} + + int getNumActions() const + { + return d_act.size(); + } + + QAction * getAction(int which) + { + if(which < d_act.size()) + return d_act[which]; + else + throw std::runtime_error("LineMarkerMenu::getAction: which out of range.\n"); + } + +signals: + void whichTrigger(int which, QwtSymbol::Style); + +public slots: + void getNone() { emit whichTrigger(d_which, QwtSymbol::NoSymbol); } + void getCircle() { emit whichTrigger(d_which, QwtSymbol::Ellipse); } + void getRect() { emit whichTrigger(d_which, QwtSymbol::Rect); } + void getDiamond() { emit whichTrigger(d_which, QwtSymbol::Diamond); } + void getTriangle() { emit whichTrigger(d_which, QwtSymbol::Triangle); } + void getDTriangle() { emit whichTrigger(d_which, QwtSymbol::DTriangle); } + void getLTriangle() { emit whichTrigger(d_which, QwtSymbol::LTriangle); } + void getRTriangle() { emit whichTrigger(d_which, QwtSymbol::RTriangle); } + void getCross() { emit whichTrigger(d_which, QwtSymbol::Cross); } + void getXCross() { emit whichTrigger(d_which, QwtSymbol::XCross); } + void getHLine() { emit whichTrigger(d_which, QwtSymbol::HLine); } + void getVLine() { emit whichTrigger(d_which, QwtSymbol::VLine); } + void getStar1() { emit whichTrigger(d_which, QwtSymbol::Star1); } + void getStar2() { emit whichTrigger(d_which, QwtSymbol::Star2); } + void getHexagon() { emit whichTrigger(d_which, QwtSymbol::Hexagon); } + +private: + QList<QAction *> d_act; + int d_which; +}; + + +/********************************************************************/ + + +class MarkerAlphaMenu: public QMenu +{ + Q_OBJECT + +public: + MarkerAlphaMenu(int which, QWidget *parent) + : QMenu("Line Transparency", parent), d_which(which) + { + d_act.push_back(new QAction("None", this)); + d_act.push_back(new QAction("Low", this)); + d_act.push_back(new QAction("Medium", this)); + d_act.push_back(new QAction("High", this)); + d_act.push_back(new QAction("Off", this)); + + connect(d_act[0], SIGNAL(triggered()), this, SLOT(getNone())); + connect(d_act[1], SIGNAL(triggered()), this, SLOT(getLow())); + connect(d_act[2], SIGNAL(triggered()), this, SLOT(getMedium())); + connect(d_act[3], SIGNAL(triggered()), this, SLOT(getHigh())); + connect(d_act[4], SIGNAL(triggered()), this, SLOT(getOff())); + + QListIterator<QAction*> i(d_act); + while(i.hasNext()) { + QAction *a = i.next(); + addAction(a); + } + } + + ~MarkerAlphaMenu() + {} + + int getNumActions() const + { + return d_act.size(); + } + + QAction * getAction(int which) + { + if(which < d_act.size()) + return d_act[which]; + else + throw std::runtime_error("MarkerAlphaMenu::getAction: which out of range.\n"); + } + +signals: + void whichTrigger(int which, int); + +public slots: + void getNone() { emit whichTrigger(d_which, 255); } + void getLow() { emit whichTrigger(d_which, 200); } + void getMedium() { emit whichTrigger(d_which, 125); } + void getHigh() { emit whichTrigger(d_which, 50); } + void getOff() { emit whichTrigger(d_which, 0); } + +private: + QList<QAction *> d_act; + int d_which; +}; + + +/********************************************************************/ + + +class LineTitleAction: public QAction +{ + Q_OBJECT + +public: + LineTitleAction(int which, QWidget *parent) + : QAction("Line Title", parent), d_which(which) + { + d_diag = new QDialog(parent); + d_diag->setModal(true); + + d_text = new QLineEdit(); + + QGridLayout *layout = new QGridLayout(d_diag); + QPushButton *btn_ok = new QPushButton(tr("OK")); + QPushButton *btn_cancel = new QPushButton(tr("Cancel")); + + layout->addWidget(d_text, 0, 0, 1, 2); + layout->addWidget(btn_ok, 1, 0); + layout->addWidget(btn_cancel, 1, 1); + + connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText())); + connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close())); + + connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag())); + } + + ~LineTitleAction() + {} + +signals: + void whichTrigger(int which, const QString &text); + +public slots: + void getTextDiag() + { + d_diag->exec(); + } + +private slots: + void getText() + { + emit whichTrigger(d_which, d_text->text()); + d_diag->accept(); + } + +private: + int d_which; + + QDialog *d_diag; + QLineEdit *d_text; +}; + + +/********************************************************************/ + + +class OtherAction: public QAction +{ + Q_OBJECT + +public: + OtherAction(QWidget *parent) + : QAction("Other", parent) + { + d_diag = new QDialog(parent); + d_diag->setModal(true); + + d_text = new QLineEdit(); + + QGridLayout *layout = new QGridLayout(d_diag); + QPushButton *btn_ok = new QPushButton(tr("OK")); + QPushButton *btn_cancel = new QPushButton(tr("Cancel")); + + layout->addWidget(d_text, 0, 0, 1, 2); + layout->addWidget(btn_ok, 1, 0); + layout->addWidget(btn_cancel, 1, 1); + + connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText())); + connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close())); + + connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag())); + } + + ~OtherAction() + {} + +signals: + void whichTrigger(const QString &text); + +public slots: + void getTextDiag() + { + d_diag->exec(); + } + +private slots: + void getText() + { + emit whichTrigger(d_text->text()); + d_diag->accept(); + } + +private: + QDialog *d_diag; + QLineEdit *d_text; +}; + +/********************************************************************/ + + +class OtherDualAction: public QAction +{ + Q_OBJECT + +public: + OtherDualAction(QString label0, QString label1, QWidget *parent) + : QAction("Other", parent) + { + d_diag = new QDialog(parent); + d_diag->setModal(true); + + d_text0 = new QLineEdit(); + d_text1 = new QLineEdit(); + + QLabel *_label0 = new QLabel(label0); + QLabel *_label1 = new QLabel(label1); + + QGridLayout *layout = new QGridLayout(d_diag); + QPushButton *btn_ok = new QPushButton(tr("OK")); + QPushButton *btn_cancel = new QPushButton(tr("Cancel")); + + layout->addWidget(_label0, 0, 0, 1, 2); + layout->addWidget(_label1, 1, 0, 1, 2); + + layout->addWidget(d_text0, 0, 1, 1, 2); + layout->addWidget(d_text1, 1, 1, 1, 2); + layout->addWidget(btn_ok, 2, 0); + layout->addWidget(btn_cancel, 2, 1); + + connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText())); + connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close())); + + connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag())); + } + + ~OtherDualAction() + {} + +signals: + void whichTrigger(const QString &text0, const QString &text1); + +public slots: + void getTextDiag() + { + d_diag->exec(); + } + +private slots: + void getText() + { + emit whichTrigger(d_text0->text(), d_text1->text()); + d_diag->accept(); + } + +private: + QDialog *d_diag; + QLineEdit *d_text0; + QLineEdit *d_text1; +}; + + +/********************************************************************/ + + +class FFTSizeMenu: public QMenu +{ + Q_OBJECT + +public: + FFTSizeMenu(QWidget *parent) + : QMenu("FFT Size", parent) + { + d_act.push_back(new QAction("32", this)); + d_act.push_back(new QAction("64", this)); + d_act.push_back(new QAction("128", this)); + d_act.push_back(new QAction("256", this)); + d_act.push_back(new QAction("512", this)); + d_act.push_back(new QAction("1024", this)); + d_act.push_back(new QAction("2048", this)); + d_act.push_back(new QAction("4096", this)); + d_act.push_back(new QAction("8192", this)); + d_act.push_back(new QAction("16384", this)); + d_act.push_back(new QAction("32768", this)); + d_act.push_back(new OtherAction(this)); + + connect(d_act[0], SIGNAL(triggered()), this, SLOT(get05())); + connect(d_act[1], SIGNAL(triggered()), this, SLOT(get06())); + connect(d_act[2], SIGNAL(triggered()), this, SLOT(get07())); + connect(d_act[3], SIGNAL(triggered()), this, SLOT(get08())); + connect(d_act[4], SIGNAL(triggered()), this, SLOT(get09())); + connect(d_act[5], SIGNAL(triggered()), this, SLOT(get10())); + connect(d_act[6], SIGNAL(triggered()), this, SLOT(get11())); + connect(d_act[7], SIGNAL(triggered()), this, SLOT(get12())); + connect(d_act[8], SIGNAL(triggered()), this, SLOT(get13())); + connect(d_act[9], SIGNAL(triggered()), this, SLOT(get14())); + connect(d_act[10], SIGNAL(triggered()), this, SLOT(get15())); + connect(d_act[11], SIGNAL(whichTrigger(const QString&)), + this, SLOT(getOther(const QString&))); + + QListIterator<QAction*> i(d_act); + while(i.hasNext()) { + QAction *a = i.next(); + addAction(a); + } + } + + ~FFTSizeMenu() + {} + + int getNumActions() const + { + return d_act.size(); + } + + QAction * getAction(int which) + { + if(which < d_act.size()) + return d_act[which]; + else + throw std::runtime_error("FFTSizeMenu::getAction: which out of range.\n"); + } + + signals: + void whichTrigger(int size); + + public slots: + void get05() { emit whichTrigger(32); } + void get06() { emit whichTrigger(64); } + void get07() { emit whichTrigger(128); } + void get08() { emit whichTrigger(256); } + void get09() { emit whichTrigger(512); } + void get10() { emit whichTrigger(1024); } + void get11() { emit whichTrigger(2048); } + void get12() { emit whichTrigger(4096); } + void get13() { emit whichTrigger(8192); } + void get14() { emit whichTrigger(16384); } + void get15() { emit whichTrigger(32768); } + void getOther(const QString &str) + { + int value = str.toInt(); + emit whichTrigger(value); + } + +private: + QList<QAction *> d_act; + OtherAction *d_other; +}; + + +/********************************************************************/ + + +class FFTAverageMenu: public QMenu +{ + Q_OBJECT + +public: + FFTAverageMenu(QWidget *parent) + : QMenu("FFT Average", parent) + { + d_act.push_back(new QAction("Off", this)); + d_act.push_back(new QAction("High", this)); + d_act.push_back(new QAction("Medium", this)); + d_act.push_back(new QAction("Low", this)); + d_act.push_back(new OtherAction(this)); + + connect(d_act[0], SIGNAL(triggered()), this, SLOT(getOff())); + connect(d_act[1], SIGNAL(triggered()), this, SLOT(getHigh())); + connect(d_act[2], SIGNAL(triggered()), this, SLOT(getMedium())); + connect(d_act[3], SIGNAL(triggered()), this, SLOT(getLow())); + connect(d_act[4], SIGNAL(whichTrigger(const QString&)), + this, SLOT(getOther(const QString&))); + + QListIterator<QAction*> i(d_act); + while(i.hasNext()) { + QAction *a = i.next(); + addAction(a); + } + } + + ~FFTAverageMenu() + {} + + int getNumActions() const + { + return d_act.size(); + } + + QAction * getAction(int which) + { + if(which < d_act.size()) + return d_act[which]; + else + throw std::runtime_error("FFTSizeMenu::getAction: which out of range.\n"); + } + + signals: + void whichTrigger(float alpha); + + public slots: + void getOff() { emit whichTrigger(1.0); } + void getHigh() { emit whichTrigger(0.05); } + void getMedium() { emit whichTrigger(0.1); } + void getLow() { emit whichTrigger(0.2); } + void getOther(const QString &str) + { + float value = str.toFloat(); + emit whichTrigger(value); + } + +private: + QList<QAction *> d_act; + OtherAction *d_other; +}; + + +/********************************************************************/ + + +class FFTWindowMenu: public QMenu +{ + Q_OBJECT + +public: + FFTWindowMenu(QWidget *parent) + : QMenu("FFT Window", parent) + { + d_act.push_back(new QAction("None", this)); + d_act.push_back(new QAction("Hamming", this)); + d_act.push_back(new QAction("Hann", this)); + d_act.push_back(new QAction("Blackman", this)); + d_act.push_back(new QAction("Blackman-harris", this)); + d_act.push_back(new QAction("Rectangular", this)); + d_act.push_back(new QAction("Kaiser", this)); + + connect(d_act[0], SIGNAL(triggered()), this, SLOT(getNone())); + connect(d_act[1], SIGNAL(triggered()), this, SLOT(getHamming())); + connect(d_act[2], SIGNAL(triggered()), this, SLOT(getHann())); + connect(d_act[3], SIGNAL(triggered()), this, SLOT(getBlackman())); + connect(d_act[4], SIGNAL(triggered()), this, SLOT(getBlackmanharris())); + connect(d_act[5], SIGNAL(triggered()), this, SLOT(getRectangular())); + connect(d_act[6], SIGNAL(triggered()), this, SLOT(getKaiser())); + + QListIterator<QAction*> i(d_act); + while(i.hasNext()) { + QAction *a = i.next(); + addAction(a); + } + } + + ~FFTWindowMenu() + {} + + int getNumActions() const + { + return d_act.size(); + } + + QAction * getAction(int which) + { + if(which < d_act.size()) + return d_act[which]; + else + throw std::runtime_error("FFTWindowMenu::getAction: which out of range.\n"); + } + +signals: + void whichTrigger(const gr::filter::firdes::win_type type); + +public slots: + void getNone() { emit whichTrigger(gr::filter::firdes::WIN_NONE); } + void getHamming() { emit whichTrigger(gr::filter::firdes::WIN_HAMMING); } + void getHann() { emit whichTrigger(gr::filter::firdes::WIN_HANN); } + void getBlackman() { emit whichTrigger(gr::filter::firdes::WIN_BLACKMAN); } + void getBlackmanharris() { emit whichTrigger(gr::filter::firdes::WIN_BLACKMAN_hARRIS); } + void getRectangular() { emit whichTrigger(gr::filter::firdes::WIN_RECTANGULAR); } + void getKaiser() { emit whichTrigger(gr::filter::firdes::WIN_KAISER); } + +private: + QList<QAction *> d_act; + int d_which; +}; + + +/********************************************************************/ + + +class NPointsMenu: public QAction +{ + Q_OBJECT + +public: + NPointsMenu(QWidget *parent) + : QAction("Number of Points", parent) + { + d_diag = new QDialog(parent); + d_diag->setModal(true); + + d_text = new QLineEdit(); + + QGridLayout *layout = new QGridLayout(d_diag); + QPushButton *btn_ok = new QPushButton(tr("OK")); + QPushButton *btn_cancel = new QPushButton(tr("Cancel")); + + layout->addWidget(d_text, 0, 0, 1, 2); + layout->addWidget(btn_ok, 1, 0); + layout->addWidget(btn_cancel, 1, 1); + + connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText())); + connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close())); + + connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag())); + } + + ~NPointsMenu() + {} + +signals: + void whichTrigger(const int npts); + +public slots: + void getTextDiag() + { + d_diag->show(); + } + +private slots: + void getText() + { + emit whichTrigger(d_text->text().toInt()); + d_diag->accept(); + } + +private: + QDialog *d_diag; + QLineEdit *d_text; +}; + + +/********************************************************************/ + + +class ColorMapMenu: public QMenu +{ + Q_OBJECT + +public: + ColorMapMenu(int which, QWidget *parent) + : QMenu("Color Map", parent), d_which(which) + { + d_act.push_back(new QAction("Multi-Color", this)); + d_act.push_back(new QAction("White Hot", this)); + d_act.push_back(new QAction("Black Hot", this)); + d_act.push_back(new QAction("Incandescent", this)); + d_act.push_back(new QAction("Other", this)); + //d_act.push_back(new OtherDualAction("Min Intensity: ", "Max Intensity: ", this)); + + connect(d_act[0], SIGNAL(triggered()), this, SLOT(getMultiColor())); + connect(d_act[1], SIGNAL(triggered()), this, SLOT(getWhiteHot())); + connect(d_act[2], SIGNAL(triggered()), this, SLOT(getBlackHot())); + connect(d_act[3], SIGNAL(triggered()), this, SLOT(getIncandescent())); + connect(d_act[4], SIGNAL(triggered()), this, SLOT(getOther())); + + QListIterator<QAction*> i(d_act); + while(i.hasNext()) { + QAction *a = i.next(); + addAction(a); + } + + d_max_value = QColor("white"); + d_min_value = QColor("white"); + } + + ~ColorMapMenu() + {} + + int getNumActions() const + { + return d_act.size(); + } + + QAction * getAction(int which) + { + if(which < d_act.size()) + return d_act[which]; + else + throw std::runtime_error("ColorMapMenu::getAction: which out of range.\n"); + } + + signals: + void whichTrigger(int which, const int type, + const QColor &min_color=QColor(), + const QColor &max_color=QColor()); + + public slots: + void getMultiColor() { emit whichTrigger(d_which, INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR); } + void getWhiteHot() { emit whichTrigger(d_which, INTENSITY_COLOR_MAP_TYPE_WHITE_HOT); } + void getBlackHot() { emit whichTrigger(d_which, INTENSITY_COLOR_MAP_TYPE_BLACK_HOT); } + void getIncandescent() { emit whichTrigger(d_which, INTENSITY_COLOR_MAP_TYPE_INCANDESCENT); } + //void getOther(d_which, const QString &min_str, const QString &max_str) + void getOther() + { + QMessageBox::information(this, "Set low and high intensities", + "In the next windows, select the low and then the high intensity colors.", + QMessageBox::Ok); + d_min_value = QColorDialog::getColor(d_min_value, this); + d_max_value = QColorDialog::getColor(d_max_value, this); + + emit whichTrigger(d_which, INTENSITY_COLOR_MAP_TYPE_USER_DEFINED, + d_min_value, d_max_value); + } + +private: + QList<QAction *> d_act; + OtherDualAction *d_other; + QColor d_max_value, d_min_value; + int d_which; +}; + + +/********************************************************************/ + + +class PopupMenu: public QAction +{ + Q_OBJECT + +public: + PopupMenu(QString desc, QWidget *parent) + : QAction(desc, parent) + { + d_diag = new QDialog(parent); + d_diag->setModal(true); + + d_text = new QLineEdit(); + + QGridLayout *layout = new QGridLayout(d_diag); + QPushButton *btn_ok = new QPushButton(tr("OK")); + QPushButton *btn_cancel = new QPushButton(tr("Cancel")); + + layout->addWidget(d_text, 0, 0, 1, 2); + layout->addWidget(btn_ok, 1, 0); + layout->addWidget(btn_cancel, 1, 1); + + connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText())); + connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close())); + + connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag())); + } + + ~PopupMenu() + {} + +signals: + void whichTrigger(const QString data); + +public slots: + void getTextDiag() + { + d_diag->show(); + } + +private slots: + void getText() + { + emit whichTrigger(d_text->text()); + d_diag->accept(); + } + +private: + QDialog *d_diag; + QLineEdit *d_text; +}; + + +/********************************************************************/ + + +#endif /* FORM_MENUS_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/freq_sink_c.h b/gr-qtgui/include/gnuradio/qtgui/freq_sink_c.h new file mode 100644 index 0000000000..667ee95e18 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/freq_sink_c.h @@ -0,0 +1,114 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_FREQ_SINK_C_H +#define INCLUDED_QTGUI_FREQ_SINK_C_H + +#include <Python.h> +#include <gnuradio/qtgui/api.h> +#include <gnuradio/sync_block.h> +#include <qapplication.h> +#include <gnuradio/filter/firdes.h> + +namespace gr { + namespace qtgui { + + /*! + * \brief A graphical sink to display multiple signals in frequency. + * \ingroup instrumentation_blk + * \ingroup qtgui_blk + * + * \details + * This is a QT-based graphical sink the takes set of a complex + * streams and plots the PSD. Each signal is plotted with a + * different color, and the \a set_title and \a set_color + * functions can be used to change the lable and color for a given + * input number. + */ + class QTGUI_API freq_sink_c : virtual public sync_block + { + public: + // gr::qtgui::freq_sink_c::sptr + typedef boost::shared_ptr<freq_sink_c> sptr; + + /*! + * \brief Build a complex PSD sink. + * + * \param fftsize size of the FFT to compute and display + * \param wintype type of window to apply (see gnuradio/filter/firdes.h) + * \param fc center frequency of signal (use for x-axis labels) + * \param bw bandwidth of signal (used to set x-axis labels) + * \param name title for the plot + * \param nconnections number of signals connected to sink + * \param parent a QWidget parent object, if any + */ + static sptr make(int fftsize, int wintype, + double fc, double bw, + const std::string &name, + int nconnections=1, + QWidget *parent=NULL); + + virtual void exec_() = 0; + virtual PyObject* pyqwidget() = 0; + + virtual void set_fft_size(const int fftsize) = 0; + virtual int fft_size() const = 0; + virtual void set_fft_average(const float fftavg) = 0; + virtual float fft_average() const = 0; + virtual void set_fft_window(const gr::filter::firdes::win_type win) = 0; + virtual gr::filter::firdes::win_type fft_window() = 0; + + virtual void set_frequency_range(const double centerfreq, const double bandwidth) = 0; + virtual void set_y_axis(double min, double max) = 0; + + virtual void set_update_time(double t) = 0; + + virtual void set_title(const std::string &title) = 0; + virtual void set_line_label(int which, const std::string &label) = 0; + virtual void set_line_color(int which, const std::string &color) = 0; + virtual void set_line_width(int which, int width) = 0; + virtual void set_line_style(int which, int style) = 0; + virtual void set_line_marker(int which, int marker) = 0; + virtual void set_line_alpha(int which, double alpha) = 0; + + virtual std::string title() = 0; + virtual std::string line_label(int which) = 0; + virtual std::string line_color(int which) = 0; + virtual int line_width(int which) = 0; + virtual int line_style(int which) = 0; + virtual int line_marker(int which) = 0; + virtual double line_alpha(int which) = 0; + + virtual void set_size(int width, int height) = 0; + + virtual void enable_menu(bool en=true) = 0; + virtual void enable_grid(bool en=true) = 0; + virtual void enable_autoscale(bool en=true) = 0; + virtual void reset() = 0; + + QApplication *d_qApplication; + }; + + } /* namespace qtgui */ +} /* namespace gr */ + +#endif /* INCLUDED_QTGUI_FREQ_SINK_C_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h b/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h new file mode 100644 index 0000000000..77e9159fe3 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h @@ -0,0 +1,113 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_FREQ_SINK_F_H +#define INCLUDED_QTGUI_FREQ_SINK_F_H + +#include <Python.h> +#include <gnuradio/qtgui/api.h> +#include <gnuradio/sync_block.h> +#include <qapplication.h> +#include <gnuradio/filter/firdes.h> + +namespace gr { + namespace qtgui { + + /*! + * \brief A graphical sink to display multiple signals in frequency. + * \ingroup instrumentation_blk + * \ingroup qtgui_blk + * + * \details + * This is a QT-based graphical sink the takes set of a floating + * point streams and plots the PSD. Each signal is plotted with a + * different color, and the \a set_title and \a set_color + * functions can be used to change the lable and color for a given + * input number. + */ + class QTGUI_API freq_sink_f : virtual public sync_block + { + public: + // gr::qtgui::freq_sink_f::sptr + typedef boost::shared_ptr<freq_sink_f> sptr; + + /*! + * \brief Build a floating point PSD sink. + * + * \param fftsize size of the FFT to compute and display + * \param wintype type of window to apply (see gnuradio/filter/firdes.h) + * \param fc center frequency of signal (use for x-axis labels) + * \param bw bandwidth of signal (used to set x-axis labels) + * \param name title for the plot + * \param nconnections number of signals connected to sink + * \param parent a QWidget parent object, if any + */ + static sptr make(int fftsize, int wintype, + double fc, double bw, + const std::string &name, + int nconnections=1, + QWidget *parent=NULL); + + virtual void exec_() = 0; + virtual PyObject* pyqwidget() = 0; + + virtual void set_fft_size(const int fftsize) = 0; + virtual int fft_size() const = 0; + virtual void set_fft_average(const float fftavg) = 0; + virtual float fft_average() const = 0; + virtual void set_fft_window(const gr::filter::firdes::win_type win) = 0; + virtual gr::filter::firdes::win_type fft_window() = 0; + + virtual void set_frequency_range(const double centerfreq, const double bandwidth) = 0; + virtual void set_y_axis(double min, double max) = 0; + + virtual void set_update_time(double t) = 0; + virtual void set_title(const std::string &title) = 0; + virtual void set_line_label(int which, const std::string &label) = 0; + virtual void set_line_color(int which, const std::string &color) = 0; + virtual void set_line_width(int which, int width) = 0; + virtual void set_line_style(int which, int style) = 0; + virtual void set_line_marker(int which, int marker) = 0; + virtual void set_line_alpha(int which, double alpha) = 0; + + virtual std::string title() = 0; + virtual std::string line_label(int which) = 0; + virtual std::string line_color(int which) = 0; + virtual int line_width(int which) = 0; + virtual int line_style(int which) = 0; + virtual int line_marker(int which) = 0; + virtual double line_alpha(int which) = 0; + + virtual void set_size(int width, int height) = 0; + + virtual void enable_menu(bool en=true) = 0; + virtual void enable_grid(bool en=true) = 0; + virtual void enable_autoscale(bool en=true) = 0; + virtual void reset() = 0; + + QApplication *d_qApplication; + }; + + } /* namespace qtgui */ +} /* namespace gr */ + +#endif /* INCLUDED_QTGUI_FREQ_SINK_F_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/freqdisplayform.h b/gr-qtgui/include/gnuradio/qtgui/freqdisplayform.h new file mode 100644 index 0000000000..48dd1a6377 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/freqdisplayform.h @@ -0,0 +1,78 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef FREQ_DISPLAY_FORM_H +#define FREQ_DISPLAY_FORM_H + +#include <gnuradio/qtgui/spectrumUpdateEvents.h> +#include <gnuradio/qtgui/FrequencyDisplayPlot.h> +#include <QtGui/QtGui> +#include <vector> +#include <gnuradio/filter/firdes.h> + +#include <gnuradio/qtgui/displayform.h> + +/*! + * \brief DisplayForm child for managing frequency (PSD) plots. + * \ingroup qtgui_blk + */ +class FreqDisplayForm : public DisplayForm +{ + Q_OBJECT + + public: + FreqDisplayForm(int nplots=1, QWidget* parent = 0); + ~FreqDisplayForm(); + + FrequencyDisplayPlot* getPlot(); + + int getFFTSize() const; + float getFFTAverage() const; + gr::filter::firdes::win_type getFFTWindowType() const; + +public slots: + void customEvent(QEvent *e); + + void setSampleRate(const QString &samprate); + void setFFTSize(const int); + void setFFTAverage(const float); + void setFFTWindowType(const gr::filter::firdes::win_type); + + void setFrequencyRange(const double centerfreq, + const double bandwidth); + void setYaxis(double min, double max); + void autoScale(bool en); + +private slots: + void newData(const QEvent *updateEvent); + +private: + uint64_t _numRealDataPoints; + QIntValidator* _intValidator; + + double _samp_rate, _center_freq; + int _fftsize; + float _fftavg; + gr::filter::firdes::win_type _fftwintype; +}; + +#endif /* FREQ_DISPLAY_FORM_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/plot_raster.h b/gr-qtgui/include/gnuradio/qtgui/plot_raster.h new file mode 100644 index 0000000000..6352e9f0db --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/plot_raster.h @@ -0,0 +1,94 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef PLOT_TIMERASTER_H +#define PLOT_TIMERASTER_H + +#include <qglobal.h> +#include <gnuradio/qtgui/timeRasterGlobalData.h> +#include <qwt_plot_rasteritem.h> + +#if QWT_VERSION >= 0x060000 +#include <qwt_point_3d.h> // doesn't seem necessary, but is... +#include <qwt_compat.h> +#endif + +class QwtColorMap; + +/*! + * \brief A plot item, which displays a time raster. + * \ingroup qtgui_blk + * + * \details + * A time raster displays threedimenional data, where the 3rd dimension + * (the intensity) is displayed using colors. The colors are calculated + * from the values using a color map. + * + * \sa QwtRasterData, QwtColorMap + */ +class PlotTimeRaster: public QwtPlotRasterItem +{ +public: + explicit PlotTimeRaster(const QString &title = QString::null); + virtual ~PlotTimeRaster(); + + const TimeRasterData* data()const; + + void setData(TimeRasterData *data); + + void setColorMap(const QwtColorMap *map); + + const QwtColorMap &colorMap() const; + +#if QWT_VERSION < 0x060000 + virtual QwtDoubleRect boundingRect() const; + virtual QSize rasterHint(const QwtDoubleRect &) const; + virtual QwtDoubleInterval interval(Qt::Axis ax) const; +#else + virtual QwtInterval interval(Qt::Axis ax) const; +#endif + + virtual int rtti() const; + + virtual void draw(QPainter *p, + const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRect &rect) const; + +protected: +#if QWT_VERSION < 0x060000 + QImage renderImage(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtDoubleRect &rect) const; +#else + QImage renderImage(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &rect, + const QSize &size=QSize(0,0)) const; +#endif + +private: + class PrivateData; + PrivateData *d_data; +}; + +#endif diff --git a/gr-qtgui/include/gnuradio/qtgui/plot_waterfall.h b/gr-qtgui/include/gnuradio/qtgui/plot_waterfall.h new file mode 100644 index 0000000000..bd550ec676 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/plot_waterfall.h @@ -0,0 +1,90 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008-2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef PLOT_WATERFALL_H +#define PLOT_WATERFALL_H + +#include <qglobal.h> +#include <gnuradio/qtgui/waterfallGlobalData.h> +#include <qwt_plot_rasteritem.h> + +#if QWT_VERSION >= 0x060000 +#include <qwt_point_3d.h> // doesn't seem necessary, but is... +#include <qwt_compat.h> +#endif + +class QwtColorMap; + +/*! + * \brief A plot item, which displays a waterfall spectrogram + * \ingroup qtgui_blk + * + * \details + * A waterfall displays threedimenional data, where the 3rd dimension + * (the intensity) is displayed using colors. The colors are calculated + * from the values using a color map. + * + * \sa QwtRasterData, QwtColorMap + */ +class PlotWaterfall: public QwtPlotRasterItem +{ +public: + explicit PlotWaterfall(WaterfallData* data, + const QString &title = QString::null); + virtual ~PlotWaterfall(); + + const WaterfallData* data()const; + + void setColorMap(const QwtColorMap &); + + const QwtColorMap &colorMap() const; + +#if QWT_VERSION < 0x060000 + virtual QwtDoubleRect boundingRect() const; + virtual QSize rasterHint(const QwtDoubleRect &) const; +#endif + + virtual int rtti() const; + + virtual void draw(QPainter *p, + const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRect &rect) const; + +protected: +#if QWT_VERSION < 0x060000 + QImage renderImage(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtDoubleRect &rect) const; +#else + QImage renderImage(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &rect, + const QSize &size=QSize(0,0)) const; +#endif + +private: + class PrivateData; + PrivateData *d_data; +}; + +#endif diff --git a/gr-qtgui/include/gnuradio/qtgui/qtgui_types.h b/gr-qtgui/include/gnuradio/qtgui/qtgui_types.h new file mode 100644 index 0000000000..f71ab9eda3 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/qtgui_types.h @@ -0,0 +1,196 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QTGUI_TYPES_H +#define QTGUI_TYPES_H + +#include <qwt_color_map.h> +#include <qwt_scale_draw.h> +#include <gnuradio/high_res_timer.h> + +class FreqOffsetAndPrecisionClass +{ +public: + FreqOffsetAndPrecisionClass(const int freqPrecision) + { + _frequencyPrecision = freqPrecision; + _centerFrequency = 0; + } + + virtual ~FreqOffsetAndPrecisionClass() + { + } + + virtual unsigned int getFrequencyPrecision() const + { + return _frequencyPrecision; + } + + virtual void setFrequencyPrecision(const unsigned int newPrecision) + { + _frequencyPrecision = newPrecision; + } + + virtual double getCenterFrequency() const + { + return _centerFrequency; + } + + virtual void setCenterFrequency(const double newFreq) + { + _centerFrequency = newFreq; + } + +protected: + +private: + unsigned int _frequencyPrecision; + double _centerFrequency; +}; + +class TimeScaleData +{ +public: + TimeScaleData() + { + _zeroTime = 0; + _secondsPerLine = 1.0; + } + + virtual ~TimeScaleData() + { + } + + virtual gr::high_res_timer_type getZeroTime() const + { + return _zeroTime; + } + + virtual void setZeroTime(const gr::high_res_timer_type newTime) + { + _zeroTime = newTime - gr::high_res_timer_epoch(); + } + + virtual void setSecondsPerLine(const double newTime) + { + _secondsPerLine = newTime; + } + + virtual double getSecondsPerLine() const + { + return _secondsPerLine; + } + + +protected: + +private: + gr::high_res_timer_type _zeroTime; + double _secondsPerLine; + +}; + +/*********************************************************************** + * Text scale widget to provide X (freq) axis text + **********************************************************************/ +class FreqDisplayScaleDraw: public QwtScaleDraw, FreqOffsetAndPrecisionClass +{ +public: + FreqDisplayScaleDraw(const unsigned int precision) + : QwtScaleDraw(), FreqOffsetAndPrecisionClass(precision) + { + } + + virtual QwtText label(double value) const + { + return QString("%1").arg(value, 0, 'f', getFrequencyPrecision()); + } + + virtual void initiateUpdate(void) + { + invalidateCache(); + } + +protected: + +private: + +}; + +enum{ + INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR = 0, + INTENSITY_COLOR_MAP_TYPE_WHITE_HOT = 1, + INTENSITY_COLOR_MAP_TYPE_BLACK_HOT = 2, + INTENSITY_COLOR_MAP_TYPE_INCANDESCENT = 3, + INTENSITY_COLOR_MAP_TYPE_USER_DEFINED = 4 +}; + +class ColorMap_MultiColor: public QwtLinearColorMap +{ +public: + ColorMap_MultiColor(): + QwtLinearColorMap(Qt::darkCyan, Qt::white) + { + addColorStop(0.25, Qt::cyan); + addColorStop(0.5, Qt::yellow); + addColorStop(0.75, Qt::red); + } +}; + +class ColorMap_WhiteHot: public QwtLinearColorMap +{ +public: + ColorMap_WhiteHot(): + QwtLinearColorMap(Qt::black, Qt::white) + { + } +}; + +class ColorMap_BlackHot: public QwtLinearColorMap +{ +public: + ColorMap_BlackHot(): + QwtLinearColorMap(Qt::white, Qt::black) + { + } +}; + +class ColorMap_Incandescent: public QwtLinearColorMap +{ +public: + ColorMap_Incandescent(): + QwtLinearColorMap(Qt::black, Qt::white) + { + addColorStop(0.5, Qt::darkRed); + } +}; + +class ColorMap_UserDefined: public QwtLinearColorMap +{ +public: + ColorMap_UserDefined(QColor low, QColor high): + QwtLinearColorMap(low, high) + { + } +}; + +#endif //QTGUI_TYPES_H diff --git a/gr-qtgui/include/gnuradio/qtgui/sink_c.h b/gr-qtgui/include/gnuradio/qtgui/sink_c.h new file mode 100644 index 0000000000..9b30e74c95 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/sink_c.h @@ -0,0 +1,99 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009,2011,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_SINK_C_H +#define INCLUDED_QTGUI_SINK_C_H + +#include <Python.h> +#include <gnuradio/qtgui/api.h> +#include <gnuradio/block.h> +#include <qapplication.h> +#include <qwt_symbol.h> + + +namespace gr { + namespace qtgui { + + /*! + * \brief A graphical sink to display freq, spec, time, and const plots. + * \ingroup instrumentation_blk + * \ingroup qtgui_blk + * + * \details + * This is a QT-based graphical sink the takes a complex stream and + * plots it. The default action is to plot the signal as a PSD (FFT), + * spectrogram (waterfall), time domain I&Q, and constellation (I + * vs. Q) plots. The plots may be turned off by setting the + * appropriate boolean value in the constructor to False. + */ + + class QTGUI_API sink_c : virtual public block + { + public: + // gr::qtgui::sink_c::sptr + typedef boost::shared_ptr<sink_c> sptr; + + /*! + * \brief Build a complex qtgui sink. + * + * \param fftsize size of the FFT to compute and display + * \param wintype type of window to apply (see gnuradio/filter/firdes.h) + * \param fc center frequency of signal (use for x-axis labels) + * \param bw bandwidth of signal (used to set x-axis labels) + * \param name title for the plot + * \param plotfreq Toggle frequency plot on/off + * \param plotwaterfall Toggle waterfall plot on/off + * \param plottime Toggle time plot on/off + * \param plotconst Toggle constellation plot on/off + * \param parent a QWidget parent object, if any + */ + static sptr make(int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plottime, bool plotconst, + QWidget *parent=NULL); + + virtual void exec_() = 0; + virtual PyObject* pyqwidget() = 0; + + virtual void set_fft_size(const int fftsize) = 0; + virtual int fft_size() const = 0; + + virtual void set_frequency_range(const double centerfreq, + const double bandwidth) = 0; + virtual void set_fft_power_db(double min, double max) = 0; + + //void set_time_domain_axis(double min, double max); + //void set_constellation_axis(double xmin, double xmax, + // double ymin, double ymax); + //void set_constellation_pen_size(int size); + + virtual void set_update_time(double t) = 0; + + QApplication *d_qApplication; + }; + + } /* namespace qtgui */ +} /* namespace gr */ + +#endif /* INCLUDED_QTGUI_SINK_C_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/sink_f.h b/gr-qtgui/include/gnuradio/qtgui/sink_f.h new file mode 100644 index 0000000000..99e499421b --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/sink_f.h @@ -0,0 +1,99 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009,2011,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_SINK_F_H +#define INCLUDED_QTGUI_SINK_F_H + +#include <Python.h> +#include <gnuradio/qtgui/api.h> +#include <gnuradio/block.h> +#include <qapplication.h> +#include <qwt_symbol.h> + + +namespace gr { + namespace qtgui { + + /*! + * \brief A graphical sink to display freq, spec, and time. + * \ingroup instrumentation_blk + * \ingroup qtgui_blk + * + * \details + * This is a QT-based graphical sink the takes a float stream and + * plots it. The default action is to plot the signal as a PSD (FFT), + * spectrogram (waterfall), and time domain plots. The plots may be + * turned off by setting the appropriate boolean value in the + * constructor to False. + */ + + class QTGUI_API sink_f : virtual public block + { + public: + // gr::qtgui::sink_f::sptr + typedef boost::shared_ptr<sink_f> sptr; + + /*! + * \brief Build a floating point qtgui sink. + * + * \param fftsize size of the FFT to compute and display + * \param wintype type of window to apply (see gnuradio/filter/firdes.h) + * \param fc center frequency of signal (use for x-axis labels) + * \param bw bandwidth of signal (used to set x-axis labels) + * \param name title for the plot + * \param plotfreq Toggle frequency plot on/off + * \param plotwaterfall Toggle waterfall plot on/off + * \param plottime Toggle time plot on/off + * \param plotconst Toggle constellation plot on/off + * \param parent a QWidget parent object, if any + */ + static sptr make(int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plottime, bool plotconst, + QWidget *parent=NULL); + + virtual void exec_() = 0; + virtual PyObject* pyqwidget() = 0; + + virtual void set_fft_size(const int fftsize) = 0; + virtual int fft_size() const = 0; + + virtual void set_frequency_range(const double centerfreq, + const double bandwidth) = 0; + virtual void set_fft_power_db(double min, double max) = 0; + + //void set_time_domain_axis(double min, double max); + //void set_constellation_axis(double xmin, double xmax, + // double ymin, double ymax); + //void set_constellation_pen_size(int size); + + virtual void set_update_time(double t) = 0; + + QApplication *d_qApplication; + }; + + } /* namespace qtgui */ +} /* namespace gr */ + +#endif /* INCLUDED_QTGUI_SINK_F_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/spectrumUpdateEvents.h b/gr-qtgui/include/gnuradio/qtgui/spectrumUpdateEvents.h new file mode 100644 index 0000000000..361610d095 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/spectrumUpdateEvents.h @@ -0,0 +1,264 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef SPECTRUM_UPDATE_EVENTS_H +#define SPECTRUM_UPDATE_EVENTS_H + +#include <stdint.h> +#include <QEvent> +#include <QString> +#include <complex> +#include <vector> +#include <gnuradio/high_res_timer.h> + +static const int SpectrumUpdateEventType = 10005; +static const int SpectrumWindowCaptionEventType = 10008; +static const int SpectrumWindowResetEventType = 10009; +static const int SpectrumFrequencyRangeEventType = 10010; + +class SpectrumUpdateEvent:public QEvent{ + +public: + SpectrumUpdateEvent(const float* fftPoints, + const uint64_t numFFTDataPoints, + const double* realTimeDomainPoints, + const double* imagTimeDomainPoints, + const uint64_t numTimeDomainDataPoints, + const gr::high_res_timer_type dataTimestamp, + const bool repeatDataFlag, + const bool lastOfMultipleUpdateFlag, + const gr::high_res_timer_type generatedTimestamp, + const int droppedFFTFrames); + + ~SpectrumUpdateEvent(); + + const float* getFFTPoints() const; + const double* getRealTimeDomainPoints() const; + const double* getImagTimeDomainPoints() const; + uint64_t getNumFFTDataPoints() const; + uint64_t getNumTimeDomainDataPoints() const; + gr::high_res_timer_type getDataTimestamp() const; + bool getRepeatDataFlag() const; + bool getLastOfMultipleUpdateFlag() const; + gr::high_res_timer_type getEventGeneratedTimestamp() const; + int getDroppedFFTFrames() const; + +protected: + +private: + float* _fftPoints; + double* _realDataTimeDomainPoints; + double* _imagDataTimeDomainPoints; + uint64_t _numFFTDataPoints; + uint64_t _numTimeDomainDataPoints; + gr::high_res_timer_type _dataTimestamp; + bool _repeatDataFlag; + bool _lastOfMultipleUpdateFlag; + gr::high_res_timer_type _eventGeneratedTimestamp; + int _droppedFFTFrames; +}; + +class SpectrumWindowCaptionEvent:public QEvent{ +public: + SpectrumWindowCaptionEvent(const QString&); + ~SpectrumWindowCaptionEvent(); + QString getLabel(); + +protected: + +private: + QString _labelString; +}; + +class SpectrumWindowResetEvent:public QEvent{ +public: + SpectrumWindowResetEvent(); + ~SpectrumWindowResetEvent(); + +protected: + +private: + +}; + +class SpectrumFrequencyRangeEvent:public QEvent{ +public: + SpectrumFrequencyRangeEvent(const double, const double, const double); + ~SpectrumFrequencyRangeEvent(); + double GetCenterFrequency()const; + double GetStartFrequency()const; + double GetStopFrequency()const; + +protected: + +private: + double _centerFrequency; + double _startFrequency; + double _stopFrequency; +}; + + +class TimeUpdateEvent: public QEvent +{ +public: + TimeUpdateEvent(const std::vector<double*> timeDomainPoints, + const uint64_t numTimeDomainDataPoints); + + ~TimeUpdateEvent(); + + int which() const; + const std::vector<double*> getTimeDomainPoints() const; + uint64_t getNumTimeDomainDataPoints() const; + bool getRepeatDataFlag() const; + + static QEvent::Type Type() + { return QEvent::Type(SpectrumUpdateEventType); } + +protected: + +private: + size_t _nplots; + std::vector<double*> _dataTimeDomainPoints; + uint64_t _numTimeDomainDataPoints; +}; + + +/********************************************************************/ + + +class FreqUpdateEvent: public QEvent +{ +public: + FreqUpdateEvent(const std::vector<double*> dataPoints, + const uint64_t numDataPoints); + + ~FreqUpdateEvent(); + + int which() const; + const std::vector<double*> getPoints() const; + uint64_t getNumDataPoints() const; + bool getRepeatDataFlag() const; + + static QEvent::Type Type() + { return QEvent::Type(SpectrumUpdateEventType); } + +protected: + +private: + size_t _nplots; + std::vector<double*> _dataPoints; + uint64_t _numDataPoints; +}; + + +/********************************************************************/ + + +class ConstUpdateEvent: public QEvent +{ +public: + ConstUpdateEvent(const std::vector<double*> realDataPoints, + const std::vector<double*> imagDataPoints, + const uint64_t numDataPoints); + + ~ConstUpdateEvent(); + + int which() const; + const std::vector<double*> getRealPoints() const; + const std::vector<double*> getImagPoints() const; + uint64_t getNumDataPoints() const; + bool getRepeatDataFlag() const; + + static QEvent::Type Type() + { return QEvent::Type(SpectrumUpdateEventType); } + +protected: + +private: + size_t _nplots; + std::vector<double*> _realDataPoints; + std::vector<double*> _imagDataPoints; + uint64_t _numDataPoints; +}; + + +/********************************************************************/ + + +class WaterfallUpdateEvent: public QEvent +{ +public: + WaterfallUpdateEvent(const std::vector<double*> dataPoints, + const uint64_t numDataPoints, + const gr::high_res_timer_type dataTimestamp); + + ~WaterfallUpdateEvent(); + + int which() const; + const std::vector<double*> getPoints() const; + uint64_t getNumDataPoints() const; + bool getRepeatDataFlag() const; + + gr::high_res_timer_type getDataTimestamp() const; + + static QEvent::Type Type() + { return QEvent::Type(SpectrumUpdateEventType); } + +protected: + +private: + size_t _nplots; + std::vector<double*> _dataPoints; + uint64_t _numDataPoints; + + gr::high_res_timer_type _dataTimestamp; +}; + + +/********************************************************************/ + + +class TimeRasterUpdateEvent: public QEvent +{ +public: + TimeRasterUpdateEvent(const std::vector<double*> dataPoints, + const uint64_t numDataPoints); + ~TimeRasterUpdateEvent(); + + int which() const; + const std::vector<double*> getPoints() const; + uint64_t getNumDataPoints() const; + bool getRepeatDataFlag() const; + + static QEvent::Type Type() + { return QEvent::Type(SpectrumUpdateEventType); } + +protected: + +private: + size_t _nplots; + std::vector<double*> _dataPoints; + uint64_t _numDataPoints; +}; + + +#endif /* SPECTRUM_UPDATE_EVENTS_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/spectrumdisplayform.h b/gr-qtgui/include/gnuradio/qtgui/spectrumdisplayform.h new file mode 100644 index 0000000000..6b43661cb4 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/spectrumdisplayform.h @@ -0,0 +1,139 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008-2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef SPECTRUM_DISPLAY_FORM_H +#define SPECTRUM_DISPLAY_FORM_H + +#include <spectrumdisplayform.ui.h> + +class SpectrumGUIClass; +#include <gnuradio/qtgui/SpectrumGUIClass.h> + +#include <gnuradio/qtgui/SpectrumGUIClass.h> +#include <gnuradio/qtgui/FrequencyDisplayPlot.h> +#include <gnuradio/qtgui/WaterfallDisplayPlot.h> +#include <gnuradio/qtgui/TimeDomainDisplayPlot.h> +#include <gnuradio/qtgui/ConstellationDisplayPlot.h> +#include <QValidator> +#include <QTimer> +#include <vector> + +class SpectrumDisplayForm : public QWidget, public Ui::SpectrumDisplayForm +{ + Q_OBJECT + + public: + SpectrumDisplayForm(QWidget* parent = 0); + ~SpectrumDisplayForm(); + + void setSystem(SpectrumGUIClass * newSystem, const uint64_t numFFTDataPoints, + const uint64_t numTimeDomainDataPoints); + + int getAverageCount(); + void setAverageCount(const int newCount); + void reset(); + void averageDataReset(); + void resizeBuffers(const uint64_t numFFTDataPoints, + const uint64_t numTimeDomainDataPoints); + +public slots: + void resizeEvent(QResizeEvent * e); + void customEvent(QEvent * e); + void avgLineEdit_valueChanged(int valueString); + void maxHoldCheckBox_toggled(bool newState); + void minHoldCheckBox_toggled(bool newState); + void minHoldResetBtn_clicked(); + void maxHoldResetBtn_clicked(); + void tabChanged(int index); + + void setFrequencyRange(const double newCenterFrequency, + const double newStartFrequency, + const double newStopFrequency); + void closeEvent(QCloseEvent * e); + void windowTypeChanged(int newItem); + void useRFFrequenciesCB(bool useRFFlag); + void waterfallMaximumIntensityChangedCB(double); + void waterfallMinimumIntensityChangedCB(double); + void waterfallIntensityColorTypeChanged(int); + void waterfallAutoScaleBtnCB(); + void fftComboBoxSelectedCB(const QString&); + + void toggleTabFrequency(const bool state); + void toggleTabWaterfall(const bool state); + void toggleTabTime(const bool state); + void toggleTabConstellation(const bool state); + + void setTimeDomainAxis(double min, double max); + void setConstellationAxis(double xmin, double xmax, + double ymin, double ymax); + void setConstellationPenSize(int size); + void setFrequencyAxis(double min, double max); + void setUpdateTime(double t); + +private slots: + void newFrequencyData(const SpectrumUpdateEvent*); + void updateGuiTimer(); + + void onFFTPlotPointSelected(const QPointF p); + void onWFallPlotPointSelected(const QPointF p); + void onTimePlotPointSelected(const QPointF p); + void onConstPlotPointSelected(const QPointF p); + +signals: + void plotPointSelected(const QPointF p, int type); + +private: + void _averageHistory(const double * newBuffer); + + int _historyEntryCount; + int _historyEntry; + std::vector<double*>* _historyVector; + double* _averagedValues; + uint64_t _numRealDataPoints; + double* _realFFTDataPoints; + QIntValidator* _intValidator; + FrequencyDisplayPlot* _frequencyDisplayPlot; + WaterfallDisplayPlot* _waterfallDisplayPlot; + TimeDomainDisplayPlot* _timeDomainDisplayPlot; + ConstellationDisplayPlot* _constellationDisplayPlot; + SpectrumGUIClass* _system; + bool _systemSpecifiedFlag; + double _centerFrequency; + double _startFrequency; + double _noiseFloorAmplitude; + double _peakFrequency; + double _peakAmplitude; + double _stopFrequency; + + //SpectrumUpdateEvent _lastSpectrumEvent; + + // whether or not to use a particular display + int d_plot_fft; + int d_plot_waterfall; + int d_plot_time; + int d_plot_constellation; + + QTimer *displayTimer; + double d_update_time; +}; + +#endif /* SPECTRUM_DISPLAY_FORM_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/timeRasterGlobalData.h b/gr-qtgui/include/gnuradio/qtgui/timeRasterGlobalData.h new file mode 100644 index 0000000000..0a414432d1 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/timeRasterGlobalData.h @@ -0,0 +1,78 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef TIMERASTER_GLOBAL_DATA_HPP +#define TIMERASTER_GLOBAL_DATA_HPP + +#include <qwt_raster_data.h> +#include <inttypes.h> + +#if QWT_VERSION >= 0x060000 +#include <qwt_point_3d.h> // doesn't seem necessary, but is... +#include <qwt_compat.h> +#endif + +class TimeRasterData: public QwtRasterData +{ +public: + TimeRasterData(const double rows, const double cols); + virtual ~TimeRasterData(); + + virtual void reset(); + virtual void copy(const TimeRasterData*); + + virtual void resizeData(const double rows, const double cols); + + virtual QwtRasterData *copy() const; + +#if QWT_VERSION < 0x060000 + virtual QwtDoubleInterval range() const; + virtual void setRange(const QwtDoubleInterval&); +#endif + + virtual double value(double x, double y) const; + + virtual double getNumCols()const; + virtual double getNumRows()const; + + virtual void addData(const double*, const int); + + void incrementResidual(); + +protected: + + double* d_data; + double d_rows, d_cols; + double d_resid; + int d_nitems, d_totalitems, d_data_size; + +#if QWT_VERSION < 0x060000 + QwtDoubleInterval d_intensityRange; +#else + QwtInterval d_intensityRange; +#endif + +private: + +}; + +#endif /* TIMERASTER_GLOBAL_DATA_HPP */ diff --git a/gr-qtgui/include/gnuradio/qtgui/time_raster_sink_b.h b/gr-qtgui/include/gnuradio/qtgui/time_raster_sink_b.h new file mode 100644 index 0000000000..22130e56aa --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/time_raster_sink_b.h @@ -0,0 +1,122 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_TIME_RASTER_SINK_B_H +#define INCLUDED_QTGUI_TIME_RASTER_SINK_B_H + +#include <Python.h> +#include <gnuradio/qtgui/api.h> +#include <gnuradio/sync_block.h> +#include <qapplication.h> +#include <qwt_symbol.h> + +namespace gr { + namespace qtgui { + + /*! + * \brief A graphical sink to display multiple signals on a + * time_raster plot. + * \ingroup instrumentation_blk + * \ingroup qtgui_blk + * + * \details + * This is a QT-based graphical sink that takes in byte + * streams and plots a time_raster (spectrogram) plot. + * + * Input stream: This expects a bit stream (0, 1 in the LSB of a + * byte). It will display packed bytes but the display will have + * to be autoscaled. + */ + class QTGUI_API time_raster_sink_b : virtual public sync_block + { + public: + // gr::qtgui::time_raster_sink_b::sptr + typedef boost::shared_ptr<time_raster_sink_b> sptr; + + /*! + * \brief Build a bit time raster sink. + * + * \param samp_rate sample rate of signal + * \param cols number of cols to plot + * \param rows number of rows to plot + * \param mult vector of floats as a scaling multiplier for each input stream + * \param offset vector of floats as an offset for each input stream + * \param name title for the plot + * \param nconnections number of streams connected + * \param parent a QWidget parent object, if any + */ + static sptr make(double samp_rate, + double rows, double cols, + const std::vector<float> &mult, + const std::vector<float> &offset, + const std::string &name, + int nconnections=1, + QWidget *parent=NULL); + + virtual void exec_() = 0; + virtual PyObject* pyqwidget() = 0; + + virtual void set_update_time(double t) = 0; + virtual void set_title(const std::string &title) = 0; + virtual void set_line_label(int which, const std::string &lable) = 0; + virtual void set_line_color(int which, const std::string &color) = 0; + virtual void set_line_width(int which, int width) = 0; + virtual void set_line_style(int which, Qt::PenStyle style) = 0; + virtual void set_line_marker(int which, QwtSymbol::Style marker) = 0; + virtual void set_line_alpha(int which, double alpha) = 0; + virtual void set_color_map(int which, const int color) = 0; + + virtual std::string title() = 0; + virtual std::string line_label(int which) = 0; + virtual std::string line_color(int which) = 0; + virtual int line_width(int which) = 0; + virtual int line_style(int which) = 0; + virtual int line_marker(int which) = 0; + virtual double line_alpha(int which) = 0; + virtual int color_map(int which) = 0; + + virtual void set_size(int width, int height) = 0; + + virtual void set_samp_rate(const double samp_rate) = 0; + virtual void set_num_rows(double rows) = 0; + virtual void set_num_cols(double cols) = 0; + + virtual double num_rows() = 0; + virtual double num_cols() = 0; + + virtual void set_multiplier(const std::vector<float> &mult) = 0; + virtual void set_offset(const std::vector<float> &offset) = 0; + + virtual void set_intensity_range(float min, float max) = 0; + + virtual void enable_menu(bool en) = 0; + virtual void enable_grid(bool en) = 0; + virtual void enable_autoscale(bool en) = 0; + virtual void reset() = 0; + + QApplication *d_qApplication; + }; + + } /* namespace qtgui */ +} /* namespace gr */ + +#endif /* INCLUDED_QTGUI_TIME_RASTER_SINK_B_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/time_raster_sink_f.h b/gr-qtgui/include/gnuradio/qtgui/time_raster_sink_f.h new file mode 100644 index 0000000000..5a82587074 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/time_raster_sink_f.h @@ -0,0 +1,119 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_TIME_RASTER_SINK_F_H +#define INCLUDED_QTGUI_TIME_RASTER_SINK_F_H + +#include <Python.h> +#include <gnuradio/qtgui/api.h> +#include <gnuradio/sync_block.h> +#include <qapplication.h> +#include <qwt_symbol.h> + +namespace gr { + namespace qtgui { + + /*! + * \brief A graphical sink to display multiple signals on a + * time_raster plot. + * \ingroup instrumentation_blk + * \ingroup qtgui_blk + * + * \details + * This is a QT-based graphical sink that takes set of a floating + * point streams and plots a time_raster (spectrogram) plot. + * + */ + class QTGUI_API time_raster_sink_f : virtual public sync_block + { + public: + // gr::qtgui::time_raster_sink_f::sptr + typedef boost::shared_ptr<time_raster_sink_f> sptr; + + /*! + * \brief Build a floating point time raster sink. + * + * \param samp_rate sample rate of signal + * \param cols number of cols to plot + * \param rows number of rows to plot + * \param mult vector of floats as a scaling multiplier for each input stream + * \param offset vector of floats as an offset for each input stream + * \param name title for the plot + * \param nconnections number of streams connected + * \param parent a QWidget parent object, if any + */ + static sptr make(double samp_rate, + double rows, double cols, + const std::vector<float> &mult, + const std::vector<float> &offset, + const std::string &name, + int nconnections=1, + QWidget *parent=NULL); + + virtual void exec_() = 0; + virtual PyObject* pyqwidget() = 0; + + virtual void set_update_time(double t) = 0; + virtual void set_title(const std::string &title) = 0; + virtual void set_line_label(int which, const std::string &lable) = 0; + virtual void set_line_color(int which, const std::string &color) = 0; + virtual void set_line_width(int which, int width) = 0; + virtual void set_line_style(int which, Qt::PenStyle style) = 0; + virtual void set_line_marker(int which, QwtSymbol::Style marker) = 0; + virtual void set_line_alpha(int which, double alpha) = 0; + virtual void set_color_map(int which, const int color) = 0; + + virtual std::string title() = 0; + virtual std::string line_label(int which) = 0; + virtual std::string line_color(int which) = 0; + virtual int line_width(int which) = 0; + virtual int line_style(int which) = 0; + virtual int line_marker(int which) = 0; + virtual double line_alpha(int which) = 0; + virtual int color_map(int which) = 0; + + virtual void set_size(int width, int height) = 0; + + virtual void set_samp_rate(const double samp_rate) = 0; + virtual void set_num_rows(double rows) = 0; + virtual void set_num_cols(double cols) = 0; + + virtual double num_rows() = 0; + virtual double num_cols() = 0; + + virtual void set_multiplier(const std::vector<float> &mult) = 0; + virtual void set_offset(const std::vector<float> &offset) = 0; + + virtual void set_intensity_range(float min, float max) = 0; + + virtual void enable_menu(bool en) = 0; + virtual void enable_grid(bool en) = 0; + virtual void enable_autoscale(bool en) = 0; + virtual void reset() = 0; + + QApplication *d_qApplication; + }; + + } /* namespace qtgui */ +} /* namespace gr */ + +#endif /* INCLUDED_QTGUI_TIME_RASTER_SINK_F_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/time_sink_c.h b/gr-qtgui/include/gnuradio/qtgui/time_sink_c.h new file mode 100644 index 0000000000..8563cf5cd1 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/time_sink_c.h @@ -0,0 +1,107 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_TIME_SINK_C_H +#define INCLUDED_QTGUI_TIME_SINK_C_H + +#include <Python.h> +#include <gnuradio/qtgui/api.h> +#include <gnuradio/sync_block.h> +#include <qapplication.h> + +namespace gr { + namespace qtgui { + + /*! + * \brief A graphical sink to display multiple signals in time. + * \ingroup instrumentation_blk + * \ingroup qtgui_blk + * + * \details + * This is a QT-based graphical sink the takes set of a complex + * streams and plots them in the time domain. For each signal, both + * the signal's I and Q parts are plotted, and they are all plotted + * with a different color, and the \a set_title and \a set_color + * functions can be used to change the lable and color for a given + * input number. + */ + class QTGUI_API time_sink_c : virtual public sync_block + { + public: + // gr::qtgui::time_sink_c::sptr + typedef boost::shared_ptr<time_sink_c> sptr; + + /*! + * \brief Build complex time sink + * + * \param size number of points to plot at once + * \param samp_rate sample rate (used to set x-axis labels) + * \param name title for the plot + * \param nconnections number of signals connected to sink + * \param parent a QWidget parent object, if any + */ + static sptr make(int size, double samp_rate, + const std::string &name, + int nconnections=1, + QWidget *parent=NULL); + + virtual void exec_() = 0; + virtual PyObject* pyqwidget() = 0; + + virtual void set_y_axis(double min, double max) = 0; + virtual void set_update_time(double t) = 0; + virtual void set_title(const std::string &title) = 0; + virtual void set_line_label(int which, const std::string &label) = 0; + virtual void set_line_color(int which, const std::string &color) = 0; + virtual void set_line_width(int which, int width) = 0; + virtual void set_line_style(int which, int style) = 0; + virtual void set_line_marker(int which, int marker) = 0; + virtual void set_nsamps(const int newsize) = 0; + virtual void set_samp_rate(const double samp_rate) = 0; + virtual void set_line_alpha(int which, double alpha) = 0; + + virtual std::string title() = 0; + virtual std::string line_label(int which) = 0; + virtual std::string line_color(int which) = 0; + virtual int line_width(int which) = 0; + virtual int line_style(int which) = 0; + virtual int line_marker(int which) = 0; + virtual double line_alpha(int which) = 0; + + virtual void set_size(int width, int height) = 0; + + virtual void enable_menu(bool en=true) = 0; + virtual void enable_grid(bool en=true) = 0; + virtual void enable_autoscale(bool en=true) = 0; + virtual void enable_stem_plot(bool en=true) = 0; + virtual void enable_semilogx(bool en=true) = 0; + virtual void enable_semilogy(bool en=true) = 0; + virtual int nsamps() const = 0; + virtual void reset() = 0; + + QApplication *d_qApplication; + }; + + } /* namespace qtgui */ +} /* namespace gr */ + +#endif /* INCLUDED_QTGUI_TIME_SINK_C_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/time_sink_f.h b/gr-qtgui/include/gnuradio/qtgui/time_sink_f.h new file mode 100644 index 0000000000..f9457f7a72 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/time_sink_f.h @@ -0,0 +1,105 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_TIME_SINK_F_H +#define INCLUDED_QTGUI_TIME_SINK_F_H + +#include <Python.h> +#include <gnuradio/qtgui/api.h> +#include <gnuradio/sync_block.h> +#include <qapplication.h> + +namespace gr { + namespace qtgui { + + /*! + * \brief A graphical sink to display multiple signals in time. + * \ingroup instrumentation_blk + * \ingroup qtgui_blk + * + * \details + * This is a QT-based graphical sink the takes set of a float streams + * and plots them in the time domain. Each signal is plotted with a + * different color, and the \a set_title and \a set_color functions + * can be used to change the lable and color for a given input number. + */ + class QTGUI_API time_sink_f : virtual public sync_block + { + public: + // gr::qtgui::time_sink_f::sptr + typedef boost::shared_ptr<time_sink_f> sptr; + + /*! + * \brief Build floating point time sink + * + * \param size number of points to plot at once + * \param samp_rate sample rate (used to set x-axis labels) + * \param name title for the plot + * \param nconnections number of signals connected to sink + * \param parent a QWidget parent object, if any + */ + static sptr make(int size, double samp_rate, + const std::string &name, + int nconnections=1, + QWidget *parent=NULL); + + virtual void exec_() = 0; + virtual PyObject* pyqwidget() = 0; + + virtual void set_y_axis(double min, double max) = 0; + virtual void set_update_time(double t) = 0; + virtual void set_title(const std::string &title) = 0; + virtual void set_line_label(int which, const std::string &line) = 0; + virtual void set_line_color(int which, const std::string &color) = 0; + virtual void set_line_width(int which, int width) = 0; + virtual void set_line_style(int which, int style) = 0; + virtual void set_line_marker(int which, int marker) = 0; + virtual void set_nsamps(const int newsize) = 0; + virtual void set_samp_rate(const double samp_rate) = 0; + virtual void set_line_alpha(int which, double alpha) = 0; + + virtual std::string title() = 0; + virtual std::string line_label(int which) = 0; + virtual std::string line_color(int which) = 0; + virtual int line_width(int which) = 0; + virtual int line_style(int which) = 0; + virtual int line_marker(int which) = 0; + virtual double line_alpha(int which) = 0; + + virtual void set_size(int width, int height) = 0; + + virtual void enable_menu(bool en=true) = 0; + virtual void enable_grid(bool en=true) = 0; + virtual void enable_autoscale(bool en=true) = 0; + virtual void enable_stem_plot(bool en=true) = 0; + virtual void enable_semilogx(bool en=true) = 0; + virtual void enable_semilogy(bool en=true) = 0; + virtual int nsamps() const = 0; + virtual void reset() = 0; + + QApplication *d_qApplication; + }; + + } /* namespace qtgui */ +} /* namespace gr */ + +#endif /* INCLUDED_QTGUI_TIME_SINK_F_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/timedisplayform.h b/gr-qtgui/include/gnuradio/qtgui/timedisplayform.h new file mode 100644 index 0000000000..07118a4baa --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/timedisplayform.h @@ -0,0 +1,81 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef TIME_DISPLAY_FORM_H +#define TIME_DISPLAY_FORM_H + +#include <gnuradio/qtgui/spectrumUpdateEvents.h> +#include <gnuradio/qtgui/TimeDomainDisplayPlot.h> +#include <QtGui/QtGui> +#include <vector> + +#include <gnuradio/qtgui/displayform.h> + +/*! + * \brief DisplayForm child for managing time domain plots. + * \ingroup qtgui_blk + */ +class TimeDisplayForm : public DisplayForm +{ + Q_OBJECT + + public: + TimeDisplayForm(int nplots=1, QWidget* parent = 0); + ~TimeDisplayForm(); + + TimeDomainDisplayPlot* getPlot(); + + int getNPoints() const; + +public slots: + void customEvent(QEvent * e); + + void setSampleRate(const double samprate); + void setSampleRate(const QString &samprate); + void setYaxis(double min, double max); + void setNPoints(const int); + void setStem(bool en); + void autoScale(bool en); + void setSemilogx(bool en); + void setSemilogy(bool en); + +private slots: + void newData(const QEvent*); + +private: + QIntValidator* _intValidator; + + double _startFrequency; + double _stopFrequency; + + int d_npoints; + + bool d_stem; + bool d_semilogx; + bool d_semilogy; + + QAction *d_stemmenu; + QAction *d_semilogxmenu; + QAction *d_semilogymenu; +}; + +#endif /* TIME_DISPLAY_FORM_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/timerasterdisplayform.h b/gr-qtgui/include/gnuradio/qtgui/timerasterdisplayform.h new file mode 100644 index 0000000000..24933c3c05 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/timerasterdisplayform.h @@ -0,0 +1,93 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef TIMERASTER_DISPLAY_FORM_H +#define TIMERASTER_DISPLAY_FORM_H + +#include <gnuradio/qtgui/spectrumUpdateEvents.h> +#include <gnuradio/qtgui/TimeRasterDisplayPlot.h> +#include <QtGui/QtGui> +#include <vector> +#include <gnuradio/filter/firdes.h> + +#include <gnuradio/qtgui/displayform.h> + +/*! + * \brief DisplayForm child for managing time raster plots. + * \ingroup qtgui_blk + */ +class TimeRasterDisplayForm : public DisplayForm +{ + Q_OBJECT + + public: + TimeRasterDisplayForm(int nplots=1, + double samp_rate=1, + double rows=1, + double cols=1, + double zmax=1, + QWidget* parent = 0); + ~TimeRasterDisplayForm(); + + TimeRasterDisplayPlot* getPlot(); + + double numRows(); + double numCols(); + + int getColorMap(int which); + int getAlpha(int which); + double getMinIntensity(int which); + double getMaxIntensity(int which); + +public slots: + void customEvent(QEvent *e); + + void setNumRows(double rows); + void setNumCols(double cols); + + void setNumRows(QString rows); + void setNumCols(QString cols); + + void setSampleRate(const double samprate); + void setSampleRate(const QString &rate); + + void setIntensityRange(const double minIntensity, + const double maxIntensity); + + void setColorMap(int which, + const int newType, + const QColor lowColor=QColor("white"), + const QColor highColor=QColor("white")); + + void setAlpha(int which, int alpha); + + void autoScale(bool en=false); + +private slots: + void newData(const QEvent *updateEvent); + +private: + double _min_val; + double _max_val; +}; + +#endif /* TIMERASTER_DISPLAY_FORM_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/utils.h b/gr-qtgui/include/gnuradio/qtgui/utils.h new file mode 100644 index 0000000000..c4271288fa --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/utils.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_UTILS_H +#define INCLUDED_QTGUI_UTILS_H + +#include <qevent.h> +#include <gnuradio/qtgui/api.h> +#include <qwt_plot_picker.h> +#include <qwt_picker_machine.h> + +class QTGUI_API QwtDblClickPlotPicker: public QwtPlotPicker +{ +public: + QwtDblClickPlotPicker(QwtPlotCanvas *); + ~QwtDblClickPlotPicker(); + + virtual QwtPickerMachine * stateMachine(int) const; +}; + +class QTGUI_API QwtPickerDblClickPointMachine: public QwtPickerMachine +{ +public: + QwtPickerDblClickPointMachine(); + ~QwtPickerDblClickPointMachine(); + +#if QWT_VERSION < 0x060000 + virtual CommandList +#else + virtual QList<QwtPickerMachine::Command> +#endif + transition( const QwtEventPattern &eventPattern, + const QEvent *e); +}; + +#endif /* INCLUDED_QTGUI_UTILS_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfallGlobalData.h b/gr-qtgui/include/gnuradio/qtgui/waterfallGlobalData.h new file mode 100644 index 0000000000..8ab9590d0b --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/waterfallGlobalData.h @@ -0,0 +1,81 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef WATERFALL_GLOBAL_DATA_HPP +#define WATERFALL_GLOBAL_DATA_HPP + +#include <qwt_raster_data.h> +#include <inttypes.h> + +#if QWT_VERSION >= 0x060000 +#include <qwt_point_3d.h> // doesn't seem necessary, but is... +#include <qwt_compat.h> +#endif + +class WaterfallData: public QwtRasterData +{ +public: + WaterfallData(const double, const double, const uint64_t, const unsigned int); + virtual ~WaterfallData(); + + virtual void reset(); + virtual void copy(const WaterfallData*); + + virtual void resizeData(const double, const double, const uint64_t); + + virtual QwtRasterData *copy() const; + +#if QWT_VERSION < 0x060000 + virtual QwtDoubleInterval range() const; + virtual void setRange(const QwtDoubleInterval&); +#endif + + virtual double value(double x, double y) const; + + virtual uint64_t getNumFFTPoints()const; + virtual void addFFTData(const double*, const uint64_t, const int); + + virtual double* getSpectrumDataBuffer()const; + virtual void setSpectrumDataBuffer(const double*); + + virtual int getNumLinesToUpdate()const; + virtual void setNumLinesToUpdate(const int); + virtual void incrementNumLinesToUpdate(); + +protected: + + double* _spectrumData; + uint64_t _fftPoints; + uint64_t _historyLength; + int _numLinesToUpdate; + +#if QWT_VERSION < 0x060000 + QwtDoubleInterval _intensityRange; +#else + QwtInterval _intensityRange; +#endif + +private: + +}; + +#endif /* WATERFALL_GLOBAL_DATA_HPP */ diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h new file mode 100644 index 0000000000..74b94bb4b4 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h @@ -0,0 +1,120 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_WATERFALL_SINK_C_H +#define INCLUDED_QTGUI_WATERFALL_SINK_C_H + +#include <Python.h> +#include <gnuradio/qtgui/api.h> +#include <gnuradio/sync_block.h> +#include <qapplication.h> +#include <gnuradio/filter/firdes.h> + +namespace gr { + namespace qtgui { + + /*! + * \brief A graphical sink to display multiple signals on a + * waterfall (spectrogram) plot. + * \ingroup instrumentation_blk + * \ingroup qtgui_blk + * + * \details + * This is a QT-based graphical sink the takes set of a complex + * streams and plots a waterfall (spectrogram) plot. + * + * Note that unlike the other qtgui sinks, this one does not + * support multiple input streams. We have yet to figure out a + * good way to display multiple, independent signals on this kind + * of a plot. If there are any suggestions or examples of this, we + * would love to see them. Otherwise, to display multiple signals + * here, it's probably best to sum the signals together and + * connect that here. + */ + class QTGUI_API waterfall_sink_c : virtual public sync_block + { + public: + // gr::qtgui::waterfall_sink_c::sptr + typedef boost::shared_ptr<waterfall_sink_c> sptr; + + + /*! + * \brief Build a complex waterfall sink. + * + * \param size size of the FFT to compute and display + * \param wintype type of window to apply (see gnuradio/filter/firdes.h) + * \param fc center frequency of signal (use for x-axis labels) + * \param bw bandwidth of signal (used to set x-axis labels) + * \param name title for the plot + * \param nconnections number of signals to be connected to the sink + * \param parent a QWidget parent object, if any + */ + static sptr make(int size, int wintype, + double fc, double bw, + const std::string &name, + int nconnections=1, + QWidget *parent=NULL); + + virtual void exec_() = 0; + virtual PyObject* pyqwidget() = 0; + + virtual void clear_data() = 0; + + virtual void set_fft_size(const int fftsize) = 0; + virtual int fft_size() const = 0; + virtual void set_fft_average(const float fftavg) = 0; + virtual float fft_average() const = 0; + virtual void set_fft_window(const gr::filter::firdes::win_type win) = 0; + virtual gr::filter::firdes::win_type fft_window() = 0; + + virtual void set_frequency_range(const double centerfreq, + const double bandwidth) = 0; + virtual void set_intensity_range(const double min, + const double max) = 0; + + virtual void set_update_time(double t) = 0; + virtual void set_title(const std::string &title) = 0; + virtual void set_line_label(int which, const std::string &line) = 0; + virtual void set_line_alpha(int which, double alpha) = 0; + virtual void set_color_map(int which, const int color) = 0; + + virtual std::string title() = 0; + virtual std::string line_label(int which) = 0; + virtual double line_alpha(int which) = 0; + virtual int color_map(int which) = 0; + + virtual void set_size(int width, int height) = 0; + + virtual void auto_scale() = 0; + virtual double min_intensity(int which) = 0; + virtual double max_intensity(int which) = 0; + + virtual void enable_menu(bool en=true) = 0; + virtual void enable_grid(bool en=true) = 0; + + QApplication *d_qApplication; + }; + + } /* namespace qtgui */ +} /* namespace gr */ + +#endif /* INCLUDED_QTGUI_WATERFALL_SINK_C_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h new file mode 100644 index 0000000000..8b6fce2651 --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h @@ -0,0 +1,119 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QTGUI_WATERFALL_SINK_F_H +#define INCLUDED_QTGUI_WATERFALL_SINK_F_H + +#include <Python.h> +#include <gnuradio/qtgui/api.h> +#include <gnuradio/sync_block.h> +#include <qapplication.h> +#include <gnuradio/filter/firdes.h> + +namespace gr { + namespace qtgui { + + /*! + * \brief A graphical sink to display multiple signals on a + * waterfall (spectrogram) plot. + * \ingroup instrumentation_blk + * \ingroup qtgui_blk + * + * \details + * This is a QT-based graphical sink the takes set of a floating + * point streams and plots a waterfall (spectrogram) plot. + * + * Note that unlike the other qtgui sinks, this one does not + * support multiple input streams. We have yet to figure out a + * good way to display multiple, independent signals on this kind + * of a plot. If there are any suggestions or examples of this, we + * would love to see them. Otherwise, to display multiple signals + * here, it's probably best to sum the signals together and + * connect that here. + */ + class QTGUI_API waterfall_sink_f : virtual public sync_block + { + public: + // gr::qtgui::waterfall_sink_f::sptr + typedef boost::shared_ptr<waterfall_sink_f> sptr; + + /*! + * \brief Build a floating point waterfall sink. + * + * \param size size of the FFT to compute and display + * \param wintype type of window to apply (see gnuradio/filter/firdes.h) + * \param fc center frequency of signal (use for x-axis labels) + * \param bw bandwidth of signal (used to set x-axis labels) + * \param name title for the plot + * \param nconnections number of signals to be connected to the sink + * \param parent a QWidget parent object, if any + */ + static sptr make(int size, int wintype, + double fc, double bw, + const std::string &name, + int nconnections=1, + QWidget *parent=NULL); + + virtual void exec_() = 0; + virtual PyObject* pyqwidget() = 0; + + virtual void clear_data() = 0; + + virtual void set_fft_size(const int fftsize) = 0; + virtual int fft_size() const = 0; + virtual void set_fft_average(const float fftavg) = 0; + virtual float fft_average() const = 0; + virtual void set_fft_window(const gr::filter::firdes::win_type win) = 0; + virtual gr::filter::firdes::win_type fft_window() = 0; + + virtual void set_frequency_range(const double centerfreq, + const double bandwidth) = 0; + virtual void set_intensity_range(const double min, + const double max) = 0; + + virtual void set_update_time(double t) = 0; + virtual void set_title(const std::string &title) = 0; + virtual void set_line_label(int which, const std::string &line) = 0; + virtual void set_line_alpha(int which, double alpha) = 0; + virtual void set_color_map(int which, const int color) = 0; + + virtual std::string title() = 0; + virtual std::string line_label(int which) = 0; + virtual double line_alpha(int which) = 0; + virtual int color_map(int which) = 0; + + virtual void set_size(int width, int height) = 0; + + virtual void auto_scale() = 0; + virtual double min_intensity(int which) = 0; + virtual double max_intensity(int which) = 0; + + virtual void enable_menu(bool en=true) = 0; + virtual void enable_grid(bool en=true) = 0; + + QApplication *d_qApplication; + }; + + } /* namespace qtgui */ +} /* namespace gr */ + +#endif /* INCLUDED_QTGUI_WATERFALL_SINK_F_H */ diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h b/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h new file mode 100644 index 0000000000..8d78bb015a --- /dev/null +++ b/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h @@ -0,0 +1,99 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef WATERFALL_DISPLAY_FORM_H +#define WATERFALL_DISPLAY_FORM_H + +#include <gnuradio/qtgui/spectrumUpdateEvents.h> +#include <gnuradio/qtgui/WaterfallDisplayPlot.h> +#include <QtGui/QtGui> +#include <vector> +#include <gnuradio/filter/firdes.h> + +#include <gnuradio/qtgui/displayform.h> + +/*! + * \brief DisplayForm child for managing waterfall (spectrogram) plots. + * \ingroup qtgui_blk + */ +class WaterfallDisplayForm : public DisplayForm +{ + Q_OBJECT + + public: + WaterfallDisplayForm(int nplots=1, QWidget* parent = 0); + ~WaterfallDisplayForm(); + + WaterfallDisplayPlot* getPlot(); + + int getFFTSize() const; + float getFFTAverage() const; + gr::filter::firdes::win_type getFFTWindowType() const; + + int getColorMap(int which); + int getAlpha(int which); + double getMinIntensity(int which); + double getMaxIntensity(int which); + + void clearData(); + +public slots: + void customEvent(QEvent *e); + + void setSampleRate(const QString &samprate); + void setFFTSize(const int); + void setFFTAverage(const float); + void setFFTWindowType(const gr::filter::firdes::win_type); + + void setFrequencyRange(const double centerfreq, + const double bandwidth); + + void setIntensityRange(const double minIntensity, + const double maxIntensity); + + void setAlpha(int which, int alpha); + + void setColorMap(int which, + const int newType, + const QColor lowColor=QColor("white"), + const QColor highColor=QColor("white")); + + void autoScale(bool en=false); + +private slots: + void newData(const QEvent *updateEvent); + +private: + uint64_t _numRealDataPoints; + QIntValidator* _intValidator; + + double _samp_rate, _center_freq; + double _time_per_slice; + int _fftsize; + float _fftavg; + gr::filter::firdes::win_type _fftwintype; + + double _min_val; + double _max_val; +}; + +#endif /* WATERFALL_DISPLAY_FORM_H */ |