From befadabc2f18b483c71250adfd7dbf42f66b16f0 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 12:55:16 -0400 Subject: gr-qtgui: restructuring qtgui directory to new layout. --- gr-qtgui/lib/ConstellationDisplayPlot.cc | 193 +++++++ gr-qtgui/lib/ConstellationDisplayPlot.h | 61 +++ gr-qtgui/lib/FrequencyDisplayPlot.cc | 439 +++++++++++++++ gr-qtgui/lib/FrequencyDisplayPlot.h | 92 ++++ gr-qtgui/lib/Makefile.am | 110 ++++ gr-qtgui/lib/Makefile.swig.gen | 145 +++++ gr-qtgui/lib/SpectrumGUIClass.cc | 468 ++++++++++++++++ gr-qtgui/lib/SpectrumGUIClass.h | 111 ++++ gr-qtgui/lib/TimeDomainDisplayPlot.cc | 276 ++++++++++ gr-qtgui/lib/TimeDomainDisplayPlot.h | 65 +++ gr-qtgui/lib/WaterfallDisplayPlot.cc | 547 +++++++++++++++++++ gr-qtgui/lib/WaterfallDisplayPlot.h | 84 +++ gr-qtgui/lib/highResTimeFunctions.h | 299 ++++++++++ gr-qtgui/lib/plot_waterfall.cc | 325 +++++++++++ gr-qtgui/lib/plot_waterfall.h | 52 ++ gr-qtgui/lib/qtgui.h | 71 +++ gr-qtgui/lib/qtgui.i | 131 +++++ gr-qtgui/lib/qtgui_sink_c.cc | 326 +++++++++++ gr-qtgui/lib/qtgui_sink_c.h | 127 +++++ gr-qtgui/lib/qtgui_sink_f.cc | 321 +++++++++++ gr-qtgui/lib/qtgui_sink_f.h | 125 +++++ gr-qtgui/lib/spectrumUpdateEvents.cc | 180 ++++++ gr-qtgui/lib/spectrumUpdateEvents.h | 92 ++++ gr-qtgui/lib/spectrumdisplayform.cc | 691 +++++++++++++++++++++++ gr-qtgui/lib/spectrumdisplayform.h | 114 ++++ gr-qtgui/lib/spectrumdisplayform.ui | 788 +++++++++++++++++++++++++++ gr-qtgui/lib/waterfallGlobalData.cc | 164 ++++++ gr-qtgui/lib/waterfallGlobalData.h | 47 ++ gr-qtgui/src/lib/ConstellationDisplayPlot.cc | 193 ------- gr-qtgui/src/lib/ConstellationDisplayPlot.h | 61 --- gr-qtgui/src/lib/FrequencyDisplayPlot.cc | 439 --------------- gr-qtgui/src/lib/FrequencyDisplayPlot.h | 92 ---- gr-qtgui/src/lib/Makefile.am | 110 ---- gr-qtgui/src/lib/Makefile.swig.gen | 145 ----- gr-qtgui/src/lib/SpectrumGUIClass.cc | 468 ---------------- gr-qtgui/src/lib/SpectrumGUIClass.h | 111 ---- gr-qtgui/src/lib/TimeDomainDisplayPlot.cc | 276 ---------- gr-qtgui/src/lib/TimeDomainDisplayPlot.h | 65 --- gr-qtgui/src/lib/WaterfallDisplayPlot.cc | 547 ------------------- gr-qtgui/src/lib/WaterfallDisplayPlot.h | 84 --- gr-qtgui/src/lib/highResTimeFunctions.h | 299 ---------- gr-qtgui/src/lib/plot_waterfall.cc | 325 ----------- gr-qtgui/src/lib/plot_waterfall.h | 52 -- gr-qtgui/src/lib/qtgui.h | 71 --- gr-qtgui/src/lib/qtgui.i | 131 ----- gr-qtgui/src/lib/qtgui_sink_c.cc | 326 ----------- gr-qtgui/src/lib/qtgui_sink_c.h | 127 ----- gr-qtgui/src/lib/qtgui_sink_f.cc | 321 ----------- gr-qtgui/src/lib/qtgui_sink_f.h | 125 ----- gr-qtgui/src/lib/spectrumUpdateEvents.cc | 180 ------ gr-qtgui/src/lib/spectrumUpdateEvents.h | 92 ---- gr-qtgui/src/lib/spectrumdisplayform.cc | 691 ----------------------- gr-qtgui/src/lib/spectrumdisplayform.h | 114 ---- gr-qtgui/src/lib/spectrumdisplayform.ui | 788 --------------------------- gr-qtgui/src/lib/waterfallGlobalData.cc | 164 ------ gr-qtgui/src/lib/waterfallGlobalData.h | 47 -- 56 files changed, 6444 insertions(+), 6444 deletions(-) create mode 100644 gr-qtgui/lib/ConstellationDisplayPlot.cc create mode 100644 gr-qtgui/lib/ConstellationDisplayPlot.h create mode 100644 gr-qtgui/lib/FrequencyDisplayPlot.cc create mode 100644 gr-qtgui/lib/FrequencyDisplayPlot.h create mode 100644 gr-qtgui/lib/Makefile.am create mode 100644 gr-qtgui/lib/Makefile.swig.gen create mode 100644 gr-qtgui/lib/SpectrumGUIClass.cc create mode 100644 gr-qtgui/lib/SpectrumGUIClass.h create mode 100644 gr-qtgui/lib/TimeDomainDisplayPlot.cc create mode 100644 gr-qtgui/lib/TimeDomainDisplayPlot.h create mode 100644 gr-qtgui/lib/WaterfallDisplayPlot.cc create mode 100644 gr-qtgui/lib/WaterfallDisplayPlot.h create mode 100644 gr-qtgui/lib/highResTimeFunctions.h create mode 100644 gr-qtgui/lib/plot_waterfall.cc create mode 100644 gr-qtgui/lib/plot_waterfall.h create mode 100644 gr-qtgui/lib/qtgui.h create mode 100644 gr-qtgui/lib/qtgui.i create mode 100644 gr-qtgui/lib/qtgui_sink_c.cc create mode 100644 gr-qtgui/lib/qtgui_sink_c.h create mode 100644 gr-qtgui/lib/qtgui_sink_f.cc create mode 100644 gr-qtgui/lib/qtgui_sink_f.h create mode 100644 gr-qtgui/lib/spectrumUpdateEvents.cc create mode 100644 gr-qtgui/lib/spectrumUpdateEvents.h create mode 100644 gr-qtgui/lib/spectrumdisplayform.cc create mode 100644 gr-qtgui/lib/spectrumdisplayform.h create mode 100644 gr-qtgui/lib/spectrumdisplayform.ui create mode 100644 gr-qtgui/lib/waterfallGlobalData.cc create mode 100644 gr-qtgui/lib/waterfallGlobalData.h delete mode 100644 gr-qtgui/src/lib/ConstellationDisplayPlot.cc delete mode 100644 gr-qtgui/src/lib/ConstellationDisplayPlot.h delete mode 100644 gr-qtgui/src/lib/FrequencyDisplayPlot.cc delete mode 100644 gr-qtgui/src/lib/FrequencyDisplayPlot.h delete mode 100644 gr-qtgui/src/lib/Makefile.am delete mode 100644 gr-qtgui/src/lib/Makefile.swig.gen delete mode 100644 gr-qtgui/src/lib/SpectrumGUIClass.cc delete mode 100644 gr-qtgui/src/lib/SpectrumGUIClass.h delete mode 100644 gr-qtgui/src/lib/TimeDomainDisplayPlot.cc delete mode 100644 gr-qtgui/src/lib/TimeDomainDisplayPlot.h delete mode 100644 gr-qtgui/src/lib/WaterfallDisplayPlot.cc delete mode 100644 gr-qtgui/src/lib/WaterfallDisplayPlot.h delete mode 100644 gr-qtgui/src/lib/highResTimeFunctions.h delete mode 100644 gr-qtgui/src/lib/plot_waterfall.cc delete mode 100644 gr-qtgui/src/lib/plot_waterfall.h delete mode 100644 gr-qtgui/src/lib/qtgui.h delete mode 100644 gr-qtgui/src/lib/qtgui.i delete mode 100644 gr-qtgui/src/lib/qtgui_sink_c.cc delete mode 100644 gr-qtgui/src/lib/qtgui_sink_c.h delete mode 100644 gr-qtgui/src/lib/qtgui_sink_f.cc delete mode 100644 gr-qtgui/src/lib/qtgui_sink_f.h delete mode 100644 gr-qtgui/src/lib/spectrumUpdateEvents.cc delete mode 100644 gr-qtgui/src/lib/spectrumUpdateEvents.h delete mode 100644 gr-qtgui/src/lib/spectrumdisplayform.cc delete mode 100644 gr-qtgui/src/lib/spectrumdisplayform.h delete mode 100644 gr-qtgui/src/lib/spectrumdisplayform.ui delete mode 100644 gr-qtgui/src/lib/waterfallGlobalData.cc delete mode 100644 gr-qtgui/src/lib/waterfallGlobalData.h diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.cc b/gr-qtgui/lib/ConstellationDisplayPlot.cc new file mode 100644 index 000000000..9ad5bdd3c --- /dev/null +++ b/gr-qtgui/lib/ConstellationDisplayPlot.cc @@ -0,0 +1,193 @@ +#ifndef CONSTELLATION_DISPLAY_PLOT_C +#define CONSTELLATION_DISPLAY_PLOT_C + +#include + +#include +#include + + +class ConstellationDisplayZoomer: public QwtPlotZoomer +{ +public: + ConstellationDisplayZoomer(QwtPlotCanvas* canvas):QwtPlotZoomer(canvas) + { + setTrackerMode(QwtPicker::AlwaysOn); + } + + virtual ~ConstellationDisplayZoomer(){ + + } + + virtual void updateTrackerText(){ + updateDisplay(); + } + +protected: + using QwtPlotZoomer::trackerText; + virtual QwtText trackerText( const QwtDoublePoint& p ) const + { + QwtText t(QString("(%1, %2)").arg(p.x(), 0, 'f', 4). + arg(p.y(), 0, 'f', 4)); + return t; + } +}; + +ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent) + : QwtPlot(parent) +{ + timespec_reset(&_lastReplot); + + resize(parent->width(), parent->height()); + + _numPoints = 1024; + _penSize = 5; + _realDataPoints = new double[_numPoints]; + _imagDataPoints = new double[_numPoints]; + + // Disable polygon clipping + QwtPainter::setDeviceClipping(false); + + // We don't need the cache here + canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); + canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); + + QPalette palette; + palette.setColor(canvas()->backgroundRole(), QColor("white")); + canvas()->setPalette(palette); + + setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine); + set_xaxis(-2.0, 2.0); + setAxisTitle(QwtPlot::xBottom, "In-phase"); + + setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine); + set_yaxis(-2.0, 2.0); + setAxisTitle(QwtPlot::yLeft, "Quadrature"); + + // Automatically deleted when parent is deleted + _plot_curve = new QwtPlotCurve("Constellation Points"); + _plot_curve->attach(this); + _plot_curve->setPen(QPen(Qt::blue, _penSize, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + _plot_curve->setStyle(QwtPlotCurve::Dots); + _plot_curve->setRawData(_realDataPoints, _imagDataPoints, _numPoints); + + memset(_realDataPoints, 0x0, _numPoints*sizeof(double)); + memset(_imagDataPoints, 0x0, _numPoints*sizeof(double)); + + replot(); + + _zoomer = new ConstellationDisplayZoomer(canvas()); +#if QT_VERSION < 0x040000 + _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, + Qt::RightButton, Qt::ControlModifier); +#else + _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, + Qt::RightButton, Qt::ControlModifier); +#endif + _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, + Qt::RightButton); + + _panner = new QwtPlotPanner(canvas()); + _panner->setAxisEnabled(QwtPlot::yRight, false); + _panner->setMouseButton(Qt::MidButton); + + // Avoid jumping when labels with more/less digits + // appear/disappear when scrolling vertically + + const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); + QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); + sd->setMinimumExtent( fm.width("100.00") ); + + const QColor c(Qt::darkRed); + _zoomer->setRubberBandPen(c); + _zoomer->setTrackerPen(c); + + connect(this, SIGNAL( legendChecked(QwtPlotItem *, bool ) ), + this, SLOT( LegendEntryChecked(QwtPlotItem *, bool ) )); +} + +ConstellationDisplayPlot::~ConstellationDisplayPlot() +{ + delete[] _realDataPoints; + delete[] _imagDataPoints; + + // _fft_plot_curves deleted when parent deleted + // _zoomer and _panner deleted when parent deleted +} + +void +ConstellationDisplayPlot::set_pen_size(int size) +{ + if(size > 0 && size < 30){ + _penSize = size; + _plot_curve->setPen(QPen(Qt::blue, _penSize, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + } +} + + +void +ConstellationDisplayPlot::set_xaxis(double min, double max) +{ + setAxisScale(QwtPlot::xBottom, min, max); +} + +void +ConstellationDisplayPlot::set_yaxis(double min, double max) +{ + setAxisScale(QwtPlot::yLeft, min, max); +} + +void +ConstellationDisplayPlot::set_axis(double xmin, double xmax, + double ymin, double ymax) +{ + set_xaxis(xmin, xmax); + set_yaxis(ymin, ymax); +} + +void ConstellationDisplayPlot::replot() +{ + QwtPlot::replot(); +} + +void +ConstellationDisplayPlot::resizeSlot( QSize *s ) +{ + resize(s->width(), s->height()); +} + +void ConstellationDisplayPlot::PlotNewData(const double* realDataPoints, + const double* imagDataPoints, + const int64_t numDataPoints, + const double timeInterval) +{ + if((numDataPoints > 0) && + (diff_timespec(get_highres_clock(), _lastReplot) > timeInterval)) { + + if(numDataPoints != _numPoints){ + _numPoints = numDataPoints; + + delete[] _realDataPoints; + delete[] _imagDataPoints; + _realDataPoints = new double[_numPoints]; + _imagDataPoints = new double[_numPoints]; + + _plot_curve->setRawData(_realDataPoints, _imagDataPoints, _numPoints); + } + + memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double)); + memcpy(_imagDataPoints, imagDataPoints, numDataPoints*sizeof(double)); + + replot(); + + _lastReplot = get_highres_clock(); + } +} + +void +ConstellationDisplayPlot::LegendEntryChecked(QwtPlotItem* plotItem, bool on) +{ + plotItem->setVisible(!on); +} + +#endif /* CONSTELLATION_DISPLAY_PLOT_C */ diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.h b/gr-qtgui/lib/ConstellationDisplayPlot.h new file mode 100644 index 000000000..a441a8bfe --- /dev/null +++ b/gr-qtgui/lib/ConstellationDisplayPlot.h @@ -0,0 +1,61 @@ +#ifndef CONSTELLATION_DISPLAY_PLOT_HPP +#define CONSTELLATION_DISPLAY_PLOT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class ConstellationDisplayPlot : public QwtPlot +{ + Q_OBJECT + +public: + ConstellationDisplayPlot(QWidget*); + virtual ~ConstellationDisplayPlot(); + + void PlotNewData(const double* realDataPoints, + const double* imagDataPoints, + const int64_t numDataPoints, + const double timeInterval); + + virtual 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 resizeSlot( QSize *s ); + +protected slots: + void LegendEntryChecked(QwtPlotItem *plotItem, bool on); + +protected: + +private: + QwtPlotCurve* _plot_curve; + + QwtPlotPanner* _panner; + QwtPlotZoomer* _zoomer; + + double* _realDataPoints; + double* _imagDataPoints; + + timespec _lastReplot; + + int64_t _numPoints; + int64_t _penSize; +}; + +#endif /* CONSTELLATION_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.cc b/gr-qtgui/lib/FrequencyDisplayPlot.cc new file mode 100644 index 000000000..d150e2e4c --- /dev/null +++ b/gr-qtgui/lib/FrequencyDisplayPlot.cc @@ -0,0 +1,439 @@ +#ifndef FREQUENCY_DISPLAY_PLOT_C +#define FREQUENCY_DISPLAY_PLOT_C + +#include + +#include + +class FreqPrecisionClass +{ +public: + FreqPrecisionClass(const int freqPrecision) + { + _frequencyPrecision = freqPrecision; + } + + virtual ~FreqPrecisionClass() + { + } + + virtual unsigned int GetFrequencyPrecision() const + { + return _frequencyPrecision; + } + + virtual void SetFrequencyPrecision(const unsigned int newPrecision) + { + _frequencyPrecision = newPrecision; + } +protected: + unsigned int _frequencyPrecision; + +private: + +}; + +class FreqDisplayScaleDraw: public QwtScaleDraw, public FreqPrecisionClass +{ +public: + FreqDisplayScaleDraw(const unsigned int precision) + : QwtScaleDraw(), FreqPrecisionClass(precision) + { + } + + virtual ~FreqDisplayScaleDraw() + { + } + + virtual QwtText label(double value) const + { + return QString("%1").arg(value, 0, 'f', GetFrequencyPrecision()); + } + +protected: + +private: + +}; + +class FreqDisplayZoomer: public QwtPlotZoomer, public FreqPrecisionClass +{ +public: + FreqDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision) + : QwtPlotZoomer(canvas),FreqPrecisionClass(freqPrecision) + { + setTrackerMode(QwtPicker::AlwaysOn); + } + + virtual ~FreqDisplayZoomer(){ + + } + + virtual void updateTrackerText(){ + updateDisplay(); + } + + void SetUnitType(const std::string &type) + { + _unitType = type; + } + +protected: + using QwtPlotZoomer::trackerText; + virtual QwtText trackerText( const QwtDoublePoint& p ) const + { + QwtText t(QString("%1 %2, %3 dB"). + arg(p.x(), 0, 'f', GetFrequencyPrecision()). + arg(_unitType.c_str()).arg(p.y(), 0, 'f', 2)); + return t; + } + +private: + std::string _unitType; +}; + +FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent) + : QwtPlot(parent) +{ + _startFrequency = 0; + _stopFrequency = 4000; + + timespec_reset(&_lastReplot); + + resize(parent->width(), parent->height()); + + _useCenterFrequencyFlag = false; + + _numPoints = 1024; + _dataPoints = new double[_numPoints]; + _minFFTPoints = new double[_numPoints]; + _maxFFTPoints = new double[_numPoints]; + _xAxisPoints = new double[_numPoints]; + + // Disable polygon clipping + QwtPainter::setDeviceClipping(false); + + // We don't need the cache here + canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); + canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); + + QPalette palette; + palette.setColor(canvas()->backgroundRole(), QColor("white")); + canvas()->setPalette(palette); + + setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)"); + setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0)); + + _minYAxis = -120; + _maxYAxis = 10; + setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine); + setAxisScale(QwtPlot::yLeft, _minYAxis, _maxYAxis); + setAxisTitle(QwtPlot::yLeft, "Power (dB)"); + + // Automatically deleted when parent is deleted + _fft_plot_curve = new QwtPlotCurve("Power Spectrum"); + _fft_plot_curve->attach(this); + _fft_plot_curve->setPen(QPen(Qt::blue)); + _fft_plot_curve->setRawData(_xAxisPoints, _dataPoints, _numPoints); + + _min_fft_plot_curve = new QwtPlotCurve("Minimum Power"); + _min_fft_plot_curve->attach(this); + _min_fft_plot_curve->setPen(QPen(Qt::magenta)); + _min_fft_plot_curve->setRawData(_xAxisPoints, _minFFTPoints, _numPoints); + _min_fft_plot_curve->setVisible(false); + + _max_fft_plot_curve = new QwtPlotCurve("Maximum Power"); + _max_fft_plot_curve->attach(this); + _max_fft_plot_curve->setPen(QPen(Qt::darkYellow)); + _max_fft_plot_curve->setRawData(_xAxisPoints, _maxFFTPoints, _numPoints); + _max_fft_plot_curve->setVisible(false); + + _lower_intensity_marker = new QwtPlotMarker(); + _lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine); + _lower_intensity_marker->setLinePen(QPen(Qt::cyan)); + _lower_intensity_marker->attach(this); + + _upper_intensity_marker = new QwtPlotMarker(); + _upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine); + _upper_intensity_marker->setLinePen(QPen(Qt::green, 0, Qt::DotLine)); + _upper_intensity_marker->attach(this); + + memset(_dataPoints, 0x0, _numPoints*sizeof(double)); + memset(_xAxisPoints, 0x0, _numPoints*sizeof(double)); + + for(int64_t number = 0; number < _numPoints; number++){ + _minFFTPoints[number] = 200.0; + _maxFFTPoints[number] = -280.0; + } + + // set up peak marker + QwtSymbol symbol; + + _markerPeakAmplitude = new QwtPlotMarker(); + _markerPeakAmplitude->setLinePen(QPen(Qt::yellow)); + symbol.setStyle(QwtSymbol::Diamond); + symbol.setSize(8); + symbol.setPen(QPen(Qt::yellow)); + symbol.setBrush(QBrush(Qt::yellow)); + _markerPeakAmplitude->setSymbol(symbol); + _markerPeakAmplitude->attach(this); + + _markerNoiseFloorAmplitude = new QwtPlotMarker(); + _markerNoiseFloorAmplitude->setLineStyle(QwtPlotMarker::HLine); + _markerNoiseFloorAmplitude->setLinePen(QPen(Qt::darkRed, 0, Qt::DotLine)); + _markerNoiseFloorAmplitude->attach(this); + + _peakFrequency = 0; + _peakAmplitude = -HUGE_VAL; + + _noiseFloorAmplitude = -HUGE_VAL; + + replot(); + + _zoomer = new FreqDisplayZoomer(canvas(), 0); +#if QT_VERSION < 0x040000 + _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, + Qt::RightButton, Qt::ControlModifier); +#else + _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, + Qt::RightButton, Qt::ControlModifier); +#endif + _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, + Qt::RightButton); + + _panner = new QwtPlotPanner(canvas()); + _panner->setAxisEnabled(QwtPlot::yRight, false); + _panner->setMouseButton(Qt::MidButton); + + // Avoid jumping when labels with more/less digits + // appear/disappear when scrolling vertically + + const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); + QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); + sd->setMinimumExtent( fm.width("100.00") ); + + const QColor c(Qt::darkRed); + _zoomer->setRubberBandPen(c); + _zoomer->setTrackerPen(c); + + // Do this after the zoomer has been built + _resetXAxisPoints(); +} + +FrequencyDisplayPlot::~FrequencyDisplayPlot() +{ + delete[] _dataPoints; + delete[] _maxFFTPoints; + delete[] _minFFTPoints; + delete[] _xAxisPoints; + + // _fft_plot_curves deleted when parent deleted + // _zoomer and _panner deleted when parent deleted +} + +void +FrequencyDisplayPlot::set_yaxis(double min, double max) +{ + // Get the new max/min values for the plot + _minYAxis = min; + _maxYAxis = max; + + // Set the axis max/min to the new values + setAxisScale(QwtPlot::yLeft, _minYAxis, _maxYAxis); + + // Reset the base zoom level to the new axis scale set here + _zoomer->setZoomBase(); +} + +void +FrequencyDisplayPlot::SetFrequencyRange(const double constStartFreq, + const double constStopFreq, + const double constCenterFreq, + const bool useCenterFrequencyFlag, + const double units, const std::string &strunits) +{ + double startFreq = constStartFreq / units; + double stopFreq = constStopFreq / units; + double centerFreq = constCenterFreq / units; + + _useCenterFrequencyFlag = useCenterFrequencyFlag; + + if(_useCenterFrequencyFlag){ + startFreq = (startFreq + centerFreq); + stopFreq = (stopFreq + centerFreq); + } + + bool reset = false; + if((startFreq != _startFrequency) || (stopFreq != _stopFrequency)) + reset = true; + + if(stopFreq > startFreq) { + _startFrequency = startFreq; + _stopFrequency = stopFreq; + + if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){ + double display_units = ceil(log10(units)/2.0); + setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(display_units)); + setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str())); + + if(reset) + _resetXAxisPoints(); + + ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(display_units); + ((FreqDisplayZoomer*)_zoomer)->SetUnitType(strunits); + } + } +} + + +double +FrequencyDisplayPlot::GetStartFrequency() const +{ + return _startFrequency; +} + +double +FrequencyDisplayPlot::GetStopFrequency() const +{ + return _stopFrequency; +} + +void +FrequencyDisplayPlot::replot() +{ + _markerNoiseFloorAmplitude->setYValue(_noiseFloorAmplitude); + + // Make sure to take into account the start frequency + if(_useCenterFrequencyFlag){ + _markerPeakAmplitude->setXValue((_peakFrequency/1000.0) + _startFrequency); + } + else{ + _markerPeakAmplitude->setXValue(_peakFrequency + _startFrequency); + } + _markerPeakAmplitude->setYValue(_peakAmplitude); + + QwtPlot::replot(); +} + +void +FrequencyDisplayPlot::resizeSlot( QSize *s ) +{ + resize(s->width(), s->height()); +} + +void +FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDataPoints, + const double noiseFloorAmplitude, const double peakFrequency, + const double peakAmplitude, const double timeInterval) +{ + // Only update plot if there is data and if the time interval has elapsed + if((numDataPoints > 0) && + (diff_timespec(get_highres_clock(), _lastReplot) > timeInterval)) { + + if(numDataPoints != _numPoints) { + _numPoints = numDataPoints; + + delete[] _dataPoints; + delete[] _minFFTPoints; + delete[] _maxFFTPoints; + delete[] _xAxisPoints; + _dataPoints = new double[_numPoints]; + _xAxisPoints = new double[_numPoints]; + _minFFTPoints = new double[_numPoints]; + _maxFFTPoints = new double[_numPoints]; + + _fft_plot_curve->setRawData(_xAxisPoints, _dataPoints, _numPoints); + _min_fft_plot_curve->setRawData(_xAxisPoints, _minFFTPoints, _numPoints); + _max_fft_plot_curve->setRawData(_xAxisPoints, _maxFFTPoints, _numPoints); + + _resetXAxisPoints(); + ClearMaxData(); + ClearMinData(); + } + + memcpy(_dataPoints, dataPoints, numDataPoints*sizeof(double)); + for(int64_t point = 0; point < numDataPoints; point++){ + if(dataPoints[point] < _minFFTPoints[point]){ + _minFFTPoints[point] = dataPoints[point]; + } + if(dataPoints[point] > _maxFFTPoints[point]){ + _maxFFTPoints[point] = dataPoints[point]; + } + } + + _noiseFloorAmplitude = noiseFloorAmplitude; + _peakFrequency = peakFrequency; + _peakAmplitude = peakAmplitude; + + SetUpperIntensityLevel(_peakAmplitude); + + replot(); + + _lastReplot = get_highres_clock(); + } +} + +void +FrequencyDisplayPlot::ClearMaxData() +{ + for(int64_t number = 0; number < _numPoints; number++){ + _maxFFTPoints[number] = _minYAxis; + } +} + +void +FrequencyDisplayPlot::ClearMinData() +{ + for(int64_t number = 0; number < _numPoints; number++){ + _minFFTPoints[number] = _maxYAxis; + } +} + +void +FrequencyDisplayPlot::SetMaxFFTVisible(const bool visibleFlag) +{ + _max_fft_plot_curve->setVisible(visibleFlag); +} + +void +FrequencyDisplayPlot::SetMinFFTVisible(const bool visibleFlag) +{ + _min_fft_plot_curve->setVisible(visibleFlag); +} + +void +FrequencyDisplayPlot::_resetXAxisPoints() +{ + double fft_bin_size = (_stopFrequency-_startFrequency) / static_cast(_numPoints); + double freqValue = _startFrequency; + for(int64_t loc = 0; loc < _numPoints; loc++){ + _xAxisPoints[loc] = freqValue; + freqValue += fft_bin_size; + } + + setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); + + // Set up zoomer base for maximum unzoom x-axis + // and reset to maximum unzoom level + QwtDoubleRect zbase = _zoomer->zoomBase(); + zbase.setLeft(_startFrequency); + zbase.setRight(_stopFrequency); + _zoomer->zoom(zbase); + _zoomer->setZoomBase(zbase); + _zoomer->zoom(0); +} + +void +FrequencyDisplayPlot::SetLowerIntensityLevel(const double lowerIntensityLevel) +{ + _lower_intensity_marker->setYValue( lowerIntensityLevel ); +} + +void +FrequencyDisplayPlot::SetUpperIntensityLevel(const double upperIntensityLevel) +{ + _upper_intensity_marker->setYValue( upperIntensityLevel ); +} + + +#endif /* FREQUENCY_DISPLAY_PLOT_C */ diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.h b/gr-qtgui/lib/FrequencyDisplayPlot.h new file mode 100644 index 000000000..3c22c1397 --- /dev/null +++ b/gr-qtgui/lib/FrequencyDisplayPlot.h @@ -0,0 +1,92 @@ +#ifndef FREQUENCY_DISPLAY_PLOT_HPP +#define FREQUENCY_DISPLAY_PLOT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class FrequencyDisplayPlot:public QwtPlot{ + Q_OBJECT + +public: + FrequencyDisplayPlot(QWidget*); + virtual ~FrequencyDisplayPlot(); + + void SetFrequencyRange(const double, const double, + const double, const bool, + const double units=1000.0, + const std::string &strunits = "kHz"); + double GetStartFrequency()const; + double GetStopFrequency()const; + + 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 SetMaxFFTVisible(const bool); + void SetMinFFTVisible(const bool); + + virtual void replot(); + + void set_yaxis(double min, double max); + +public slots: + void resizeSlot( QSize *e ); + void SetLowerIntensityLevel(const double); + void SetUpperIntensityLevel(const double); + +protected: + +private: + + void _resetXAxisPoints(); + + double _startFrequency; + double _stopFrequency; + double _maxYAxis; + double _minYAxis; + + QwtPlotCurve* _fft_plot_curve; + QwtPlotCurve* _min_fft_plot_curve; + QwtPlotCurve* _max_fft_plot_curve; + + QwtPlotMarker* _lower_intensity_marker; + QwtPlotMarker* _upper_intensity_marker; + + QwtPlotPanner* _panner; + QwtPlotZoomer* _zoomer; + + QwtPlotMarker *_markerPeakAmplitude; + QwtPlotMarker *_markerNoiseFloorAmplitude; + + double* _dataPoints; + double* _xAxisPoints; + + double* _minFFTPoints; + double* _maxFFTPoints; + int64_t _numPoints; + + double _peakFrequency; + double _peakAmplitude; + + double _noiseFloorAmplitude; + + timespec _lastReplot; + + bool _useCenterFrequencyFlag; +}; + +#endif /* FREQUENCY_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/lib/Makefile.am b/gr-qtgui/lib/Makefile.am new file mode 100644 index 000000000..446a07fd0 --- /dev/null +++ b/gr-qtgui/lib/Makefile.am @@ -0,0 +1,110 @@ +# +# Copyright 2008,2009,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. +# + +include $(top_srcdir)/Makefile.common +include $(top_srcdir)/Makefile.swig + +EXTRA_DIST += spectrumdisplayform.ui + +AM_CPPFLAGS = -I. $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ + $(QT_INCLUDES) $(BOOST_CPPFLAGS) $(WITH_INCLUDES) + +# Only include these files in the build if qtgui passes configure checks +# This is mostly to help make distcheck pass +QMAKE_SOURCES = \ + spectrumdisplayform.moc.cc \ + FrequencyDisplayPlot.moc.cc \ + TimeDomainDisplayPlot.moc.cc \ + WaterfallDisplayPlot.moc.cc \ + ConstellationDisplayPlot.moc.cc \ + spectrumdisplayform.ui.h + +BUILT_SOURCES += $(QMAKE_SOURCES) + +# Build the normal library for C++ apps to link against +lib_LTLIBRARIES = libgnuradio-qtgui.la + +# These are the source files that go into the shared library +libgnuradio_qtgui_la_SOURCES = \ + FrequencyDisplayPlot.cc \ + TimeDomainDisplayPlot.cc \ + WaterfallDisplayPlot.cc \ + waterfallGlobalData.cc \ + ConstellationDisplayPlot.cc \ + spectrumdisplayform.cc \ + SpectrumGUIClass.cc \ + spectrumUpdateEvents.cc \ + plot_waterfall.cc \ + qtgui_sink_c.cc \ + qtgui_sink_f.cc + +nodist_libgnuradio_qtgui_la_SOURCES=$(QMAKE_SOURCES) + +# These headers get installed in ${prefix}/include/gnuradio +grinclude_HEADERS = \ + FrequencyDisplayPlot.h \ + TimeDomainDisplayPlot.h \ + WaterfallDisplayPlot.h \ + waterfallGlobalData.h \ + ConstellationDisplayPlot.h \ + highResTimeFunctions.h \ + plot_waterfall.h \ + spectrumdisplayform.h \ + SpectrumGUIClass.h \ + spectrumUpdateEvents.h \ + qtgui.h \ + qtgui_sink_c.h \ + qtgui_sink_f.h + +QT_MOC_FLAGS=-DQT_SHARED -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB +%.moc.cc : %.h + $(QT_MOC_EXEC) $(QT_MOC_FLAGS) -p $(srcdir) $< -o $@ + +%.ui.h : %.ui + $(QT_UIC_EXEC) $< -o $@ + +# magic flags +libgnuradio_qtgui_la_LDFLAGS = $(NO_UNDEFINED) $(BOOST_LDFLAGS) $(LTVERSIONFLAGS) + +libgnuradio_qtgui_la_LIBADD = \ + $(GNURADIO_CORE_LA) \ + $(BOOST_THREAD_LIB) \ + $(BOOST_DATE_TIME_LIB) \ + -lstdc++ \ + $(QT_LIBS) + + +############################## +# SWIG interfaces and libraries + +TOP_SWIG_IFILES = \ + qtgui.i + +# Install so that they end up available as: +# import gnuradio.qtgui +# This ends up at: +# ${prefix}/lib/python${python_version}/site-packages/gnuradio +qtgui_pythondir_category = \ + gnuradio/qtgui + +# additional libraries for linking with the SWIG-generated library +qtgui_la_swig_libadd = \ + libgnuradio-qtgui.la diff --git a/gr-qtgui/lib/Makefile.swig.gen b/gr-qtgui/lib/Makefile.swig.gen new file mode 100644 index 000000000..9c4c0b58c --- /dev/null +++ b/gr-qtgui/lib/Makefile.swig.gen @@ -0,0 +1,145 @@ +# -*- Makefile -*- +# +# Copyright 2009 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. +# + +# Makefile.swig.gen for qtgui.i + +## Default install locations for these files: +## +## Default location for the Python directory is: +## ${prefix}/lib/python${python_version}/site-packages/[category]/qtgui +## Default location for the Python exec directory is: +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/qtgui +## +## The following can be overloaded to change the install location, but +## this has to be done in the including Makefile.am -before- +## Makefile.swig is included. + +qtgui_pythondir_category ?= gnuradio/qtgui +qtgui_pylibdir_category ?= $(qtgui_pythondir_category) +qtgui_pythondir = $(pythondir)/$(qtgui_pythondir_category) +qtgui_pylibdir = $(pyexecdir)/$(qtgui_pylibdir_category) + +# The .so libraries for the guile modules get installed whereever guile +# is installed, usually /usr/lib/guile/gnuradio/ +# FIXME: determince whether these should be installed with gnuradio. +qtgui_scmlibdir = $(libdir) + +# The scm files for the guile modules get installed where ever guile +# is installed, usually /usr/share/guile/site/qtgui +# FIXME: determince whether these should be installed with gnuradio. +qtgui_scmdir = $(guiledir) + +## SWIG headers are always installed into the same directory. + +qtgui_swigincludedir = $(swigincludedir) + +## This is a template file for a "generated" Makefile addition (in +## this case, "Makefile.swig.gen"). By including the top-level +## Makefile.swig, this file will be used to generate the SWIG +## dependencies. Assign the variable TOP_SWIG_FILES to be the list of +## SWIG .i files to generated wrappings for; there can be more than 1 +## so long as the names are unique (no sorting is done on the +## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i +## file will generate .cc, .py, and possibly .h files -- meaning that +## all of these files will have the same base name (that provided for +## the SWIG .i file). +## +## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the +## right thing. For more info, see < +## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > + +## Other cleaned files: dependency files generated by SWIG or this Makefile + +MOSTLYCLEANFILES += $(DEPDIR)/*.S* + +## Various SWIG variables. These can be overloaded in the including +## Makefile.am by setting the variable value there, then including +## Makefile.swig . + +qtgui_swiginclude_HEADERS = \ + qtgui.i \ + $(qtgui_swiginclude_headers) + +if PYTHON +qtgui_pylib_LTLIBRARIES = \ + _qtgui.la + +_qtgui_la_SOURCES = \ + python/qtgui.cc \ + $(qtgui_la_swig_sources) + +qtgui_python_PYTHON = \ + qtgui.py \ + $(qtgui_python) + +_qtgui_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(qtgui_la_swig_libadd) + +_qtgui_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(qtgui_la_swig_ldflags) + +_qtgui_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(qtgui_la_swig_cxxflags) + +python/qtgui.cc: qtgui.py +qtgui.py: qtgui.i + +# Include the python dependencies for this file +-include python/qtgui.d + +endif # end of if python + +if GUILE + +qtgui_scmlib_LTLIBRARIES = \ + libguile-gnuradio-qtgui.la +libguile_gnuradio_qtgui_la_SOURCES = \ + guile/qtgui.cc \ + $(qtgui_la_swig_sources) +nobase_qtgui_scm_DATA = \ + gnuradio/qtgui.scm \ + gnuradio/qtgui-primitive.scm +libguile_gnuradio_qtgui_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(qtgui_la_swig_libadd) +libguile_gnuradio_qtgui_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(qtgui_la_swig_ldflags) +libguile_gnuradio_qtgui_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(qtgui_la_swig_cxxflags) + +guile/qtgui.cc: gnuradio/qtgui.scm +gnuradio/qtgui.scm: qtgui.i +gnuradio/qtgui-primitive.scm: gnuradio/qtgui.scm + +# Include the guile dependencies for this file +-include guile/qtgui.d + +endif # end of GUILE + + diff --git a/gr-qtgui/lib/SpectrumGUIClass.cc b/gr-qtgui/lib/SpectrumGUIClass.cc new file mode 100644 index 000000000..052730fc2 --- /dev/null +++ b/gr-qtgui/lib/SpectrumGUIClass.cc @@ -0,0 +1,468 @@ +#ifndef SPECTRUM_GUI_CLASS_CPP +#define SPECTRUM_GUI_CLASS_CPP + +#include +//Added by qt3to4: +#include +#include + +const long SpectrumGUIClass::MAX_FFT_SIZE = 32768; +const long SpectrumGUIClass::MIN_FFT_SIZE = 1024; + +SpectrumGUIClass::SpectrumGUIClass(const uint64_t maxDataSize, + const uint64_t fftSize, + const double newCenterFrequency, + const double newStartFrequency, + const double newStopFrequency) +{ + _dataPoints = maxDataSize; + if(_dataPoints < 2){ + _dataPoints = 2; + } + _lastDataPointCount = _dataPoints; + + _fftSize = fftSize; + + _pendingGUIUpdateEventsCount = 0; + _droppedEntriesCount = 0; + + _centerFrequency = newCenterFrequency; + _startFrequency = newStartFrequency; + _stopFrequency = newStopFrequency; + + _windowType = 5; + + timespec_reset(&_lastGUIUpdateTime); + + _windowOpennedFlag = false; + _fftBuffersCreatedFlag = false; + + // Create Mutex Lock + //_windowStateLock = new MutexClass("_windowStateLock"); + + _powerValue = 1; +} + +SpectrumGUIClass::~SpectrumGUIClass() +{ + if(GetWindowOpenFlag()){ + delete _spectrumDisplayForm; + } + + if(_fftBuffersCreatedFlag){ + delete[] _fftPoints; + delete[] _realTimeDomainPoints; + delete[] _imagTimeDomainPoints; + } + + //delete _windowStateLock; +} + +void +SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, + const bool frequency, const bool waterfall, + const bool time, const bool constellation, + const bool use_openGL) +{ + //_windowStateLock->Lock(); + + if(!_windowOpennedFlag){ + + if(!_fftBuffersCreatedFlag){ + _fftPoints = new std::complex[_dataPoints]; + _realTimeDomainPoints = new double[_dataPoints]; + _imagTimeDomainPoints = new double[_dataPoints]; + _fftBuffersCreatedFlag = true; + + + memset(_fftPoints, 0x0, _dataPoints*sizeof(std::complex)); + memset(_realTimeDomainPoints, 0x0, _dataPoints*sizeof(double)); + memset(_imagTimeDomainPoints, 0x0, _dataPoints*sizeof(double)); + } + + // Called from the Event Thread + _spectrumDisplayForm = new SpectrumDisplayForm(use_openGL, parent); + + // Toggle Windows on/off + _spectrumDisplayForm->ToggleTabFrequency(frequency); + _spectrumDisplayForm->ToggleTabWaterfall(waterfall); + _spectrumDisplayForm->ToggleTabTime(time); + _spectrumDisplayForm->ToggleTabConstellation(constellation); + + _windowOpennedFlag = true; + + _spectrumDisplayForm->setSystem(this, _dataPoints, _fftSize); + + qApp->processEvents(); + } + + //_windowStateLock->Unlock(); + + SetDisplayTitle(_title); + Reset(); + + qApp->postEvent(_spectrumDisplayForm, + new QEvent(QEvent::Type(QEvent::User+3))); + + qApp->processEvents(); + + timespec_reset(&_lastGUIUpdateTime); + + // Draw Blank Display + UpdateWindow(false, NULL, 0, NULL, 0, NULL, 0, get_highres_clock(), true); + + // Set up the initial frequency axis settings + SetFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency); + + // GUI Thread only + qApp->processEvents(); +} + +void +SpectrumGUIClass::Reset() +{ + if(GetWindowOpenFlag()) { + qApp->postEvent(_spectrumDisplayForm, + new SpectrumFrequencyRangeEvent(_centerFrequency, + _startFrequency, + _stopFrequency)); + qApp->postEvent(_spectrumDisplayForm, new SpectrumWindowResetEvent()); + } + _droppedEntriesCount = 0; + // Call the following function the the Spectrum Window Reset Event window + // ResetPendingGUIUpdateEvents(); +} + +void +SpectrumGUIClass::SetDisplayTitle(const std::string newString) +{ + _title.assign(newString); + + if(GetWindowOpenFlag()){ + qApp->postEvent(_spectrumDisplayForm, + new SpectrumWindowCaptionEvent(_title.c_str())); + } +} + +bool +SpectrumGUIClass::GetWindowOpenFlag() +{ + bool returnFlag = false; + //_windowStateLock->Lock(); + returnFlag = _windowOpennedFlag; + //_windowStateLock->Unlock(); + return returnFlag; +} + + +void +SpectrumGUIClass::SetWindowOpenFlag(const bool newFlag) +{ + //_windowStateLock->Lock(); + _windowOpennedFlag = newFlag; + //_windowStateLock->Unlock(); +} + +void +SpectrumGUIClass::SetFrequencyRange(const double centerFreq, + const double startFreq, + const double stopFreq) +{ + //_windowStateLock->Lock(); + _centerFrequency = centerFreq; + _startFrequency = startFreq; + _stopFrequency = stopFreq; + + _spectrumDisplayForm->SetFrequencyRange(_centerFrequency, + _startFrequency, + _stopFrequency); + //_windowStateLock->Unlock(); +} + +double +SpectrumGUIClass::GetStartFrequency() const +{ + double returnValue = 0.0; + //_windowStateLock->Lock(); + returnValue = _startFrequency; + //_windowStateLock->Unlock(); + return returnValue; +} + +double +SpectrumGUIClass::GetStopFrequency() const +{ + double returnValue = 0.0; + //_windowStateLock->Lock(); + returnValue = _stopFrequency; + //_windowStateLock->Unlock(); + return returnValue; +} + +double +SpectrumGUIClass::GetCenterFrequency() const +{ + double returnValue = 0.0; + //_windowStateLock->Lock(); + returnValue = _centerFrequency; + //_windowStateLock->Unlock(); + return returnValue; +} + + +void +SpectrumGUIClass::UpdateWindow(const bool updateDisplayFlag, + const std::complex* fftBuffer, + const uint64_t inputBufferSize, + const float* realTimeDomainData, + const uint64_t realTimeDomainDataSize, + const float* complexTimeDomainData, + const uint64_t complexTimeDomainDataSize, + const timespec timestamp, + const bool lastOfMultipleFFTUpdateFlag) +{ + int64_t bufferSize = inputBufferSize; + bool repeatDataFlag = false; + if(bufferSize > _dataPoints){ + bufferSize = _dataPoints; + } + int64_t timeDomainBufferSize = 0; + + if(updateDisplayFlag){ + if((fftBuffer != NULL) && (bufferSize > 0)){ + memcpy(_fftPoints, fftBuffer, bufferSize * sizeof(std::complex)); + } + + // Can't do a memcpy since ths is going from float to double data type + if((realTimeDomainData != NULL) && (realTimeDomainDataSize > 0)){ + const float* realTimeDomainDataPtr = realTimeDomainData; + + double* realTimeDomainPointsPtr = _realTimeDomainPoints; + timeDomainBufferSize = realTimeDomainDataSize; + + memset( _imagTimeDomainPoints, 0x0, realTimeDomainDataSize*sizeof(double)); + for( uint64_t number = 0; number < realTimeDomainDataSize; number++){ + *realTimeDomainPointsPtr++ = *realTimeDomainDataPtr++; + } + } + + // Can't do a memcpy since ths is going from float to double data type + if((complexTimeDomainData != NULL) && (complexTimeDomainDataSize > 0)){ + const float* complexTimeDomainDataPtr = complexTimeDomainData; + + double* realTimeDomainPointsPtr = _realTimeDomainPoints; + double* imagTimeDomainPointsPtr = _imagTimeDomainPoints; + + timeDomainBufferSize = complexTimeDomainDataSize; + for( uint64_t number = 0; number < complexTimeDomainDataSize; number++){ + *realTimeDomainPointsPtr++ = *complexTimeDomainDataPtr++; + *imagTimeDomainPointsPtr++ = *complexTimeDomainDataPtr++; + } + } + } + + // If bufferSize is zero, then just update the display by sending over the old data + if(bufferSize < 1){ + bufferSize = _lastDataPointCount; + repeatDataFlag = true; + } + else{ + // Since there is data this time, update the count + _lastDataPointCount = bufferSize; + } + + const timespec currentTime = get_highres_clock(); + const timespec lastUpdateGUITime = GetLastGUIUpdateTime(); + + if((diff_timespec(currentTime, lastUpdateGUITime) > (4*_updateTime)) && + (GetPendingGUIUpdateEvents() > 0) && !timespec_empty(&lastUpdateGUITime)) { + // Do not update the display if too much data is pending to be displayed + _droppedEntriesCount++; + } + else{ + // Draw the Data + IncrementPendingGUIUpdateEvents(); + qApp->postEvent(_spectrumDisplayForm, + new SpectrumUpdateEvent(_fftPoints, bufferSize, + _realTimeDomainPoints, + _imagTimeDomainPoints, + timeDomainBufferSize, + timestamp, + repeatDataFlag, + lastOfMultipleFFTUpdateFlag, + currentTime, + _droppedEntriesCount)); + + // Only reset the dropped entries counter if this is not + // repeat data since repeat data is dropped by the display systems + if(!repeatDataFlag){ + _droppedEntriesCount = 0; + } + } +} + +float +SpectrumGUIClass::GetPowerValue() const +{ + float returnValue = 0; + //_windowStateLock->Lock(); + returnValue = _powerValue; + //_windowStateLock->Unlock(); + return returnValue; +} + +void +SpectrumGUIClass::SetPowerValue(const float value) +{ + //_windowStateLock->Lock(); + _powerValue = value; + //_windowStateLock->Unlock(); +} + +int +SpectrumGUIClass::GetWindowType() const +{ + int returnValue = 0; + //_windowStateLock->Lock(); + returnValue = _windowType; + //_windowStateLock->Unlock(); + return returnValue; +} + +void +SpectrumGUIClass::SetWindowType(const int newType) +{ + //_windowStateLock->Lock(); + _windowType = newType; + //_windowStateLock->Unlock(); +} + +int +SpectrumGUIClass::GetFFTSize() const +{ + int returnValue = 0; + //_windowStateLock->Lock(); + returnValue = _fftSize; + //_windowStateLock->Unlock(); + return returnValue; +} + +int +SpectrumGUIClass::GetFFTSizeIndex() const +{ + int fftsize = GetFFTSize(); + switch(fftsize) { + case(1024): return 0; break; + case(2048): return 1; break; + case(4096): return 2; break; + case(8192): return 3; break; + case(16384): return 3; break; + case(32768): return 3; break; + default: return 0; + } +} + +void +SpectrumGUIClass::SetFFTSize(const int newSize) +{ + //_windowStateLock->Lock(); + _fftSize = newSize; + //_windowStateLock->Unlock(); +} + +timespec +SpectrumGUIClass::GetLastGUIUpdateTime() const +{ + timespec returnValue; + //_windowStateLock->Lock(); + returnValue = _lastGUIUpdateTime; + //_windowStateLock->Unlock(); + return returnValue; +} + +void +SpectrumGUIClass::SetLastGUIUpdateTime(const timespec newTime) +{ + //_windowStateLock->Lock(); + _lastGUIUpdateTime = newTime; + //_windowStateLock->Unlock(); +} + +unsigned int +SpectrumGUIClass::GetPendingGUIUpdateEvents() const +{ + unsigned int returnValue = 0; + //_windowStateLock->Lock(); + returnValue = _pendingGUIUpdateEventsCount; + //_windowStateLock->Unlock(); + return returnValue; +} + +void +SpectrumGUIClass::IncrementPendingGUIUpdateEvents() +{ + //_windowStateLock->Lock(); + _pendingGUIUpdateEventsCount++; + //_windowStateLock->Unlock(); +} + +void +SpectrumGUIClass::DecrementPendingGUIUpdateEvents() +{ + //_windowStateLock->Lock(); + if(_pendingGUIUpdateEventsCount > 0){ + _pendingGUIUpdateEventsCount--; + } + //_windowStateLock->Unlock(); +} + +void +SpectrumGUIClass::ResetPendingGUIUpdateEvents() +{ + //_windowStateLock->Lock(); + _pendingGUIUpdateEventsCount = 0; + //_windowStateLock->Unlock(); +} + + +QWidget* +SpectrumGUIClass::qwidget() +{ + return (QWidget*)_spectrumDisplayForm; +} + +void +SpectrumGUIClass::SetTimeDomainAxis(double min, double max) +{ + _spectrumDisplayForm->SetTimeDomainAxis(min, max); +} + +void +SpectrumGUIClass::SetConstellationAxis(double xmin, double xmax, + double ymin, double ymax) +{ + _spectrumDisplayForm->SetConstellationAxis(xmin, xmax, ymin, ymax); + +} + +void +SpectrumGUIClass::SetConstellationPenSize(int size){ + _spectrumDisplayForm->SetConstellationPenSize(size); +} + + +void +SpectrumGUIClass::SetFrequencyAxis(double min, double max) +{ + _spectrumDisplayForm->SetFrequencyAxis(min, max); +} + +void +SpectrumGUIClass::SetUpdateTime(double t) +{ + _updateTime = t; + _spectrumDisplayForm->SetUpdateTime(_updateTime); +} + + +#endif /* SPECTRUM_GUI_CLASS_CPP */ diff --git a/gr-qtgui/lib/SpectrumGUIClass.h b/gr-qtgui/lib/SpectrumGUIClass.h new file mode 100644 index 000000000..57a749a6a --- /dev/null +++ b/gr-qtgui/lib/SpectrumGUIClass.h @@ -0,0 +1,111 @@ +#ifndef SPECTRUM_GUI_CLASS_HPP +#define SPECTRUM_GUI_CLASS_HPP + +//#include +#include +#include +#include +#include +#include + +//#include + +class SpectrumDisplayForm; +#include + +#include + +#include +#include +#include + +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, + const bool use_openGL=true); + void SetDisplayTitle(const std::string); + + bool GetWindowOpenFlag(); + void SetWindowOpenFlag(const bool); + + void SetFrequencyRange(const double, const double, const double); + double GetStartFrequency()const; + double GetStopFrequency()const; + double GetCenterFrequency()const; + + void UpdateWindow(const bool, const std::complex*, + const uint64_t, const float*, + const uint64_t, const float*, + const uint64_t, + const timespec, const bool); + + float GetPowerValue()const; + void SetPowerValue(const float); + + int GetWindowType()const; + void SetWindowType(const int); + + int GetFFTSize()const; + int GetFFTSizeIndex()const; + void SetFFTSize(const int); + + timespec GetLastGUIUpdateTime()const; + void SetLastGUIUpdateTime(const timespec); + + unsigned int GetPendingGUIUpdateEvents()const; + 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: + + //MutexClass* _windowStateLock; + int64_t _dataPoints; + std::string _title; + double _centerFrequency; + double _startFrequency; + double _stopFrequency; + float _powerValue; + bool _windowOpennedFlag; + int _windowType; + int64_t _lastDataPointCount; + int _fftSize; + timespec _lastGUIUpdateTime; + unsigned int _pendingGUIUpdateEventsCount; + int _droppedEntriesCount; + bool _fftBuffersCreatedFlag; + double _updateTime; + + SpectrumDisplayForm* _spectrumDisplayForm; + + std::complex* _fftPoints; + double* _realTimeDomainPoints; + double* _imagTimeDomainPoints; +}; + +#endif /* SPECTRUM_GUI_CLASS_HPP */ diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc new file mode 100644 index 000000000..9c98cec5b --- /dev/null +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -0,0 +1,276 @@ +#ifndef TIME_DOMAIN_DISPLAY_PLOT_C +#define TIME_DOMAIN_DISPLAY_PLOT_C + +#include + +#include +#include + + +class TimePrecisionClass +{ +public: + TimePrecisionClass(const int timePrecision) + { + _timePrecision = timePrecision; + } + + virtual ~TimePrecisionClass() + { + } + + virtual unsigned int GetTimePrecision() const + { + return _timePrecision; + } + + virtual void SetTimePrecision(const unsigned int newPrecision) + { + _timePrecision = newPrecision; + } +protected: + unsigned int _timePrecision; +}; + + +class TimeDomainDisplayZoomer: public QwtPlotZoomer, public TimePrecisionClass +{ +public: + TimeDomainDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int timePrecision) + : QwtPlotZoomer(canvas),TimePrecisionClass(timePrecision) + { + setTrackerMode(QwtPicker::AlwaysOn); + } + + virtual ~TimeDomainDisplayZoomer(){ + + } + + virtual void updateTrackerText(){ + updateDisplay(); + } + + void SetUnitType(const std::string &type) + { + _unitType = type; + } + +protected: + using QwtPlotZoomer::trackerText; + virtual QwtText trackerText( const QwtDoublePoint& p ) const + { + QwtText t(QString("%1 %2, %3 V").arg(p.x(), 0, 'f', GetTimePrecision()). + arg(_unitType.c_str()). + arg(p.y(), 0, 'f', 4)); + + return t; + } + +private: + std::string _unitType; +}; + +TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent) +{ + timespec_reset(&_lastReplot); + + resize(parent->width(), parent->height()); + + _numPoints = 1024; + _realDataPoints = new double[_numPoints]; + _imagDataPoints = new double[_numPoints]; + _xAxisPoints = new double[_numPoints]; + + _zoomer = new TimeDomainDisplayZoomer(canvas(), 0); + + // Disable polygon clipping + QwtPainter::setDeviceClipping(false); + + // We don't need the cache here + canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); + canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); + + QPalette palette; + palette.setColor(canvas()->backgroundRole(), QColor("white")); + canvas()->setPalette(palette); + + setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine); + set_xaxis(0, _numPoints); + setAxisTitle(QwtPlot::xBottom, "Time (sec)"); + + setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine); + set_yaxis(-2.0, 2.0); + setAxisTitle(QwtPlot::yLeft, "Normalized Voltage"); + + // Automatically deleted when parent is deleted + _real_plot_curve = new QwtPlotCurve("Real Data"); + _real_plot_curve->attach(this); + _real_plot_curve->setPen(QPen(Qt::blue)); + _real_plot_curve->setRawData(_xAxisPoints, _realDataPoints, _numPoints); + + _imag_plot_curve = new QwtPlotCurve("Imaginary Data"); + _imag_plot_curve->attach(this); + _imag_plot_curve->setPen(QPen(Qt::magenta)); + _imag_plot_curve->setRawData(_xAxisPoints, _imagDataPoints, _numPoints); + // _imag_plot_curve->setVisible(false); + + memset(_realDataPoints, 0x0, _numPoints*sizeof(double)); + memset(_imagDataPoints, 0x0, _numPoints*sizeof(double)); + memset(_xAxisPoints, 0x0, _numPoints*sizeof(double)); + + _sampleRate = 1; + _resetXAxisPoints(); + + replot(); + +#if QT_VERSION < 0x040000 + _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, + Qt::RightButton, Qt::ControlModifier); +#else + _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, + Qt::RightButton, Qt::ControlModifier); +#endif + _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, + Qt::RightButton); + + _panner = new QwtPlotPanner(canvas()); + _panner->setAxisEnabled(QwtPlot::yRight, false); + _panner->setMouseButton(Qt::MidButton); + + // Avoid jumping when labels with more/less digits + // appear/disappear when scrolling vertically + + const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); + QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); + sd->setMinimumExtent( fm.width("100.00") ); + + const QColor c(Qt::darkRed); + _zoomer->setRubberBandPen(c); + _zoomer->setTrackerPen(c); + + QwtLegend* legendDisplay = new QwtLegend(this); + legendDisplay->setItemMode(QwtLegend::CheckableItem); + insertLegend(legendDisplay); + + connect(this, SIGNAL( legendChecked(QwtPlotItem *, bool ) ), + this, SLOT( LegendEntryChecked(QwtPlotItem *, bool ) )); +} + +TimeDomainDisplayPlot::~TimeDomainDisplayPlot(){ + delete[] _realDataPoints; + delete[] _imagDataPoints; + delete[] _xAxisPoints; + + // _fft_plot_curves deleted when parent deleted + // _zoomer and _panner deleted when parent deleted +} + +void +TimeDomainDisplayPlot::set_yaxis(double min, double max) +{ + setAxisScale(QwtPlot::yLeft, min, max); + _zoomer->setZoomBase(); +} + +void +TimeDomainDisplayPlot::set_xaxis(double min, double max) +{ + setAxisScale(QwtPlot::xBottom, min, max); + _zoomer->setZoomBase(); +} + + +void TimeDomainDisplayPlot::replot() +{ + QwtPlot::replot(); +} + +void +TimeDomainDisplayPlot::resizeSlot( QSize *s ) +{ + resize(s->width(), s->height()); +} + +void TimeDomainDisplayPlot::PlotNewData(const double* realDataPoints, + const double* imagDataPoints, + const int64_t numDataPoints, + const double timeInterval) +{ + if((numDataPoints > 0) && + (diff_timespec(get_highres_clock(), _lastReplot) > timeInterval)) { + + if(numDataPoints != _numPoints){ + _numPoints = numDataPoints; + + delete[] _realDataPoints; + delete[] _imagDataPoints; + delete[] _xAxisPoints; + _realDataPoints = new double[_numPoints]; + _imagDataPoints = new double[_numPoints]; + _xAxisPoints = new double[_numPoints]; + + _real_plot_curve->setRawData(_xAxisPoints, _realDataPoints, _numPoints); + _imag_plot_curve->setRawData(_xAxisPoints, _imagDataPoints, _numPoints); + + set_xaxis(0, numDataPoints); + + _resetXAxisPoints(); + } + + memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double)); + memcpy(_imagDataPoints, imagDataPoints, numDataPoints*sizeof(double)); + + replot(); + + _lastReplot = get_highres_clock(); + } +} + +void TimeDomainDisplayPlot::SetImaginaryDataVisible(const bool visibleFlag) +{ + _imag_plot_curve->setVisible(visibleFlag); +} + +void TimeDomainDisplayPlot::_resetXAxisPoints() +{ + double delt = 1.0/_sampleRate; + for(long loc = 0; loc < _numPoints; loc++){ + _xAxisPoints[loc] = loc*delt; + } + setAxisScale(QwtPlot::xBottom, 0, _numPoints*delt); + + // Set up zoomer base for maximum unzoom x-axis + // and reset to maximum unzoom level + QwtDoubleRect zbase = _zoomer->zoomBase(); + zbase.setLeft(0); + zbase.setRight(_numPoints*delt); + _zoomer->zoom(zbase); + _zoomer->setZoomBase(zbase); + _zoomer->zoom(0); +} + +void TimeDomainDisplayPlot::LegendEntryChecked(QwtPlotItem* plotItem, bool on) +{ + plotItem->setVisible(!on); +} + +void +TimeDomainDisplayPlot::SetSampleRate(double sr, double units, + const std::string &strunits) +{ + double newsr = sr/units; + if(newsr != _sampleRate) { + _sampleRate = sr/units; + _resetXAxisPoints(); + + // While we could change the displayed sigfigs based on the unit being + // displayed, I think it looks better by just setting it to 4 regardless. + //double display_units = ceil(log10(units)/2.0); + double display_units = 4; + setAxisTitle(QwtPlot::xBottom, QString("Time (%1)").arg(strunits.c_str())); + ((TimeDomainDisplayZoomer*)_zoomer)->SetTimePrecision(display_units); + ((TimeDomainDisplayZoomer*)_zoomer)->SetUnitType(strunits); + } +} + +#endif /* TIME_DOMAIN_DISPLAY_PLOT_C */ diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.h b/gr-qtgui/lib/TimeDomainDisplayPlot.h new file mode 100644 index 000000000..952b5c8cf --- /dev/null +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.h @@ -0,0 +1,65 @@ +#ifndef TIME_DOMAIN_DISPLAY_PLOT_HPP +#define TIME_DOMAIN_DISPLAY_PLOT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class TimeDomainDisplayPlot:public QwtPlot{ + Q_OBJECT + +public: + TimeDomainDisplayPlot(QWidget*); + virtual ~TimeDomainDisplayPlot(); + + void PlotNewData(const double* realDataPoints, const double* imagDataPoints, + const int64_t numDataPoints, const double timeInterval); + + void SetImaginaryDataVisible(const bool); + + virtual void replot(); + + void set_yaxis(double min, double max); + void set_xaxis(double min, double max); + +public slots: + void resizeSlot( QSize *s ); + void SetSampleRate(double sr, double units, + const std::string &strunits); + +protected slots: + void LegendEntryChecked(QwtPlotItem *plotItem, bool on); + +protected: + +private: + void _resetXAxisPoints(); + + QwtPlotCurve* _real_plot_curve; + QwtPlotCurve* _imag_plot_curve; + + QwtPlotPanner* _panner; + QwtPlotZoomer* _zoomer; + + double* _realDataPoints; + double* _imagDataPoints; + double* _xAxisPoints; + + double _sampleRate; + + timespec _lastReplot; + + int64_t _numPoints; +}; + +#endif /* TIME_DOMAIN_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc new file mode 100644 index 000000000..a8e5361e7 --- /dev/null +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -0,0 +1,547 @@ +#ifndef WATERFALL_DISPLAY_PLOT_C +#define WATERFALL_DISPLAY_PLOT_C + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +namespace pt = boost::posix_time; + +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: + unsigned int _frequencyPrecision; + double _centerFrequency; + +private: + +}; + +class WaterfallFreqDisplayScaleDraw: public QwtScaleDraw, public FreqOffsetAndPrecisionClass{ +public: + WaterfallFreqDisplayScaleDraw(const unsigned int precision) + : QwtScaleDraw(), FreqOffsetAndPrecisionClass(precision) + { + } + + virtual ~WaterfallFreqDisplayScaleDraw() + { + } + + QwtText label(double value) const + { + return QString("%1").arg(value, 0, 'f', GetFrequencyPrecision()); + } + + virtual void initiateUpdate() + { + invalidateCache(); + } + +protected: + +private: + +}; + +class TimeScaleData +{ +public: + TimeScaleData() + { + timespec_reset(&_zeroTime); + _secondsPerLine = 1.0; + } + + virtual ~TimeScaleData() + { + } + + virtual timespec GetZeroTime() const + { + return _zeroTime; + } + + virtual void SetZeroTime(const timespec newTime) + { + _zeroTime = newTime; + } + + virtual void SetSecondsPerLine(const double newTime) + { + _secondsPerLine = newTime; + } + + virtual double GetSecondsPerLine() const + { + return _secondsPerLine; + } + + +protected: + timespec _zeroTime; + double _secondsPerLine; + +private: + +}; + +class QwtTimeScaleDraw: public QwtScaleDraw, public TimeScaleData +{ +public: + QwtTimeScaleDraw():QwtScaleDraw(),TimeScaleData() + { + } + + virtual ~QwtTimeScaleDraw() + { + } + + virtual QwtText label(double value) const + { + timespec lineTime = timespec_add(GetZeroTime(), (-value) * GetSecondsPerLine()); + std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); + + // lops off the YYYY-mmm-DD part of the string + int ind = time_str.find(" "); + if(ind != std::string::npos) + time_str = time_str.substr(ind); + return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); + } + + virtual void initiateUpdate() + { + // Do this in one call rather than when zeroTime and secondsPerLine + // updates is to prevent the display from being updated too often... + invalidateCache(); + } + +protected: + +private: + +}; + +class WaterfallZoomer: public QwtPlotZoomer, public TimeScaleData, + public FreqOffsetAndPrecisionClass +{ +public: + WaterfallZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision) + : QwtPlotZoomer(canvas), TimeScaleData(), + FreqOffsetAndPrecisionClass(freqPrecision) + { + setTrackerMode(QwtPicker::AlwaysOn); + } + + virtual ~WaterfallZoomer() + { + } + + virtual void updateTrackerText() + { + updateDisplay(); + } + + void SetUnitType(const std::string &type) + { + _unitType = type; + } + +protected: + using QwtPlotZoomer::trackerText; + virtual QwtText trackerText( const QwtDoublePoint& p ) const + { + timespec lineTime = timespec_add(GetZeroTime(), (-p.y()) * GetSecondsPerLine()); + std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); + + // lops off the YYYY-mmm-DD part of the string + int ind = time_str.find(" "); + if(ind != std::string::npos) + time_str = time_str.substr(ind); + QString yLabel(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); + + QwtText t(QString("%1 %2, %3"). + arg(p.x(), 0, 'f', GetFrequencyPrecision()). + arg(_unitType.c_str()).arg(yLabel)); + return t; + } + +private: + std::string _unitType; +}; + + +WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) + : QwtPlot(parent) +{ + _zoomer = NULL; + _startFrequency = 0; + _stopFrequency = 4000; + + resize(parent->width(), parent->height()); + _numPoints = 1024; + + _waterfallData = new WaterfallData(_startFrequency, _stopFrequency, _numPoints, 200); + + QPalette palette; + palette.setColor(canvas()->backgroundRole(), QColor("white")); + canvas()->setPalette(palette); + + setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)"); + setAxisScaleDraw(QwtPlot::xBottom, new WaterfallFreqDisplayScaleDraw(0)); + + setAxisTitle(QwtPlot::yLeft, "Time"); + setAxisScaleDraw(QwtPlot::yLeft, new QwtTimeScaleDraw()); + + timespec_reset(&_lastReplot); + + d_spectrogram = new PlotWaterfall(_waterfallData, "Waterfall Display"); + + _intensityColorMapType = INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR; + + QwtLinearColorMap colorMap(Qt::darkCyan, Qt::white); + colorMap.addColorStop(0.25, Qt::cyan); + colorMap.addColorStop(0.5, Qt::yellow); + colorMap.addColorStop(0.75, Qt::red); + + d_spectrogram->setColorMap(colorMap); + + d_spectrogram->attach(this); + + // LeftButton for the zooming + // MidButton for the panning + // RightButton: zoom out by 1 + // Ctrl+RighButton: zoom out to full size + + _zoomer = new WaterfallZoomer(canvas(), 0); +#if QT_VERSION < 0x040000 + _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, + Qt::RightButton, Qt::ControlModifier); +#else + _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, + Qt::RightButton, Qt::ControlModifier); +#endif + _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, + Qt::RightButton); + + _panner = new QwtPlotPanner(canvas()); + _panner->setAxisEnabled(QwtPlot::yRight, false); + _panner->setMouseButton(Qt::MidButton); + + // Avoid jumping when labels with more/less digits + // appear/disappear when scrolling vertically + + const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); + QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); + sd->setMinimumExtent( fm.width("100.00") ); + + const QColor c(Qt::white); + _zoomer->setRubberBandPen(c); + _zoomer->setTrackerPen(c); + + _UpdateIntensityRangeDisplay(); +} + +WaterfallDisplayPlot::~WaterfallDisplayPlot() +{ + delete _waterfallData; + delete d_spectrogram; +} + +void +WaterfallDisplayPlot::Reset() +{ + _waterfallData->ResizeData(_startFrequency, _stopFrequency, _numPoints); + _waterfallData->Reset(); + + setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); + + // Load up the new base zoom settings + QwtDoubleRect newSize = _zoomer->zoomBase(); + newSize.setLeft(_startFrequency); + newSize.setWidth(_stopFrequency-_startFrequency); + _zoomer->zoom(newSize); + _zoomer->setZoomBase(newSize); + _zoomer->zoom(0); +} + +void +WaterfallDisplayPlot::SetFrequencyRange(const double constStartFreq, + const double constStopFreq, + const double constCenterFreq, + const bool useCenterFrequencyFlag, + const double units, const std::string &strunits) +{ + double startFreq = constStartFreq / units; + double stopFreq = constStopFreq / units; + double centerFreq = constCenterFreq / units; + + _useCenterFrequencyFlag = useCenterFrequencyFlag; + + if(_useCenterFrequencyFlag){ + startFreq = (startFreq + centerFreq); + stopFreq = (stopFreq + centerFreq); + } + + bool reset = false; + if((startFreq != _startFrequency) || (stopFreq != _stopFrequency)) + reset = true; + + if(stopFreq > startFreq) { + _startFrequency = startFreq; + _stopFrequency = stopFreq; + + if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){ + double display_units = ceil(log10(units)/2.0); + setAxisScaleDraw(QwtPlot::xBottom, new WaterfallFreqDisplayScaleDraw(display_units)); + setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str())); + + if(reset) { + Reset(); + } + + ((WaterfallZoomer*)_zoomer)->SetFrequencyPrecision(display_units); + ((WaterfallZoomer*)_zoomer)->SetUnitType(strunits); + } + } +} + + +double +WaterfallDisplayPlot::GetStartFrequency() const +{ + return _startFrequency; +} + +double +WaterfallDisplayPlot::GetStopFrequency() const +{ + return _stopFrequency; +} + +void +WaterfallDisplayPlot::PlotNewData(const double* dataPoints, + const int64_t numDataPoints, + const double timePerFFT, + const timespec timestamp, + const int droppedFrames) +{ + if(numDataPoints > 0){ + if(numDataPoints != _numPoints){ + _numPoints = numDataPoints; + + Reset(); + + d_spectrogram->invalidateCache(); + d_spectrogram->itemChanged(); + + if(isVisible()){ + replot(); + } + + _lastReplot = get_highres_clock(); + } + + if(diff_timespec(get_highres_clock(), _lastReplot) > timePerFFT) { + //FIXME: We may want to average the data between these updates to smooth display + _waterfallData->addFFTData(dataPoints, numDataPoints, droppedFrames); + _waterfallData->IncrementNumLinesToUpdate(); + + QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); + timeScale->SetSecondsPerLine(timePerFFT); + timeScale->SetZeroTime(timestamp); + + ((WaterfallZoomer*)_zoomer)->SetSecondsPerLine(timePerFFT); + ((WaterfallZoomer*)_zoomer)->SetZeroTime(timestamp); + + d_spectrogram->invalidateCache(); + d_spectrogram->itemChanged(); + + replot(); + + _lastReplot = get_highres_clock(); + } + } +} + +void +WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, + const double maxIntensity) +{ + _waterfallData->setRange(QwtDoubleInterval(minIntensity, maxIntensity)); + + emit UpdatedLowerIntensityLevel(minIntensity); + emit UpdatedUpperIntensityLevel(maxIntensity); + + _UpdateIntensityRangeDisplay(); +} + +void +WaterfallDisplayPlot::replot() +{ + QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); + timeScale->initiateUpdate(); + + WaterfallFreqDisplayScaleDraw* freqScale = (WaterfallFreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom); + freqScale->initiateUpdate(); + + // Update the time axis display + if(axisWidget(QwtPlot::yLeft) != NULL){ + axisWidget(QwtPlot::yLeft)->update(); + } + + // Update the Frequency Offset Display + if(axisWidget(QwtPlot::xBottom) != NULL){ + axisWidget(QwtPlot::xBottom)->update(); + } + + if(_zoomer != NULL){ + ((WaterfallZoomer*)_zoomer)->updateTrackerText(); + } + + QwtPlot::replot(); +} + +void +WaterfallDisplayPlot::resizeSlot( QSize *s ) +{ + resize(s->width(), s->height()); +} + +int +WaterfallDisplayPlot::GetIntensityColorMapType() const +{ + return _intensityColorMapType; +} + +void +WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, + const QColor lowColor, + const QColor highColor) +{ + if((_intensityColorMapType != newType) || + ((newType == INTENSITY_COLOR_MAP_TYPE_USER_DEFINED) && + (lowColor.isValid() && highColor.isValid()))){ + switch(newType){ + case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:{ + _intensityColorMapType = newType; + QwtLinearColorMap colorMap(Qt::darkCyan, Qt::white); + colorMap.addColorStop(0.25, Qt::cyan); + colorMap.addColorStop(0.5, Qt::yellow); + colorMap.addColorStop(0.75, Qt::red); + d_spectrogram->setColorMap(colorMap); + break; + } + case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:{ + _intensityColorMapType = newType; + QwtLinearColorMap colorMap(Qt::black, Qt::white); + d_spectrogram->setColorMap(colorMap); + break; + } + case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:{ + _intensityColorMapType = newType; + QwtLinearColorMap colorMap(Qt::white, Qt::black); + d_spectrogram->setColorMap(colorMap); + break; + } + case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:{ + _intensityColorMapType = newType; + QwtLinearColorMap colorMap(Qt::black, Qt::white); + colorMap.addColorStop(0.5, Qt::darkRed); + d_spectrogram->setColorMap(colorMap); + break; + } + case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:{ + _userDefinedLowIntensityColor = lowColor; + _userDefinedHighIntensityColor = highColor; + _intensityColorMapType = newType; + QwtLinearColorMap colorMap(_userDefinedLowIntensityColor, _userDefinedHighIntensityColor); + d_spectrogram->setColorMap(colorMap); + break; + } + default: break; + } + + _UpdateIntensityRangeDisplay(); + } +} + +const QColor +WaterfallDisplayPlot::GetUserDefinedLowIntensityColor() const +{ + return _userDefinedLowIntensityColor; +} + +const QColor +WaterfallDisplayPlot::GetUserDefinedHighIntensityColor() const +{ + return _userDefinedHighIntensityColor; +} + +void +WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() +{ + QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight); + rightAxis->setTitle("Intensity (dB)"); + rightAxis->setColorBarEnabled(true); + rightAxis->setColorMap(d_spectrogram->data()->range(), + d_spectrogram->colorMap()); + + setAxisScale(QwtPlot::yRight, + d_spectrogram->data()->range().minValue(), + d_spectrogram->data()->range().maxValue() ); + enableAxis(QwtPlot::yRight); + + plotLayout()->setAlignCanvasToScales(true); + + // Tell the display to redraw everything + d_spectrogram->invalidateCache(); + d_spectrogram->itemChanged(); + + // Draw again + replot(); + + // Update the last replot timer + _lastReplot = get_highres_clock(); +} + +#endif /* WATERFALL_DISPLAY_PLOT_C */ diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.h b/gr-qtgui/lib/WaterfallDisplayPlot.h new file mode 100644 index 000000000..6b4e978bb --- /dev/null +++ b/gr-qtgui/lib/WaterfallDisplayPlot.h @@ -0,0 +1,84 @@ +#ifndef WATERFALL_DISPLAY_PLOT_HPP +#define WATERFALL_DISPLAY_PLOT_HPP + +#include +#include +#include +#include +#include + +#include + +#include + +class WaterfallDisplayPlot:public QwtPlot{ + Q_OBJECT + +public: + WaterfallDisplayPlot(QWidget*); + virtual ~WaterfallDisplayPlot(); + + void Reset(); + + void SetFrequencyRange(const double, const double, + const double, const bool, + const double units=1000.0, + const std::string &strunits = "kHz"); + double GetStartFrequency()const; + double GetStopFrequency()const; + + void PlotNewData(const double* dataPoints, const int64_t numDataPoints, + const double timePerFFT, const timespec timestamp, + const int droppedFrames); + + void SetIntensityRange(const double minIntensity, const double maxIntensity); + + virtual void replot(void); + + int GetIntensityColorMapType()const; + void SetIntensityColorMapType( const int, const QColor, const QColor ); + const QColor GetUserDefinedLowIntensityColor()const; + const QColor GetUserDefinedHighIntensityColor()const; + + 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 + }; + +public slots: + void resizeSlot( QSize *s ); + +signals: + void UpdatedLowerIntensityLevel(const double); + void UpdatedUpperIntensityLevel(const double); + +protected: + +private: + void _UpdateIntensityRangeDisplay(); + + double _startFrequency; + double _stopFrequency; + + PlotWaterfall *d_spectrogram; + + QwtPlotPanner* _panner; + QwtPlotZoomer* _zoomer; + + WaterfallData* _waterfallData; + + timespec _lastReplot; + + bool _useCenterFrequencyFlag; + + int64_t _numPoints; + + int _intensityColorMapType; + QColor _userDefinedLowIntensityColor; + QColor _userDefinedHighIntensityColor; +}; + +#endif /* WATERFALL_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/lib/highResTimeFunctions.h b/gr-qtgui/lib/highResTimeFunctions.h new file mode 100644 index 000000000..251bbad8b --- /dev/null +++ b/gr-qtgui/lib/highResTimeFunctions.h @@ -0,0 +1,299 @@ +#ifndef HIGH_RES_TIME_FUNCTIONS_H +#define HIGH_RES_TIME_FUNCTIONS_H + +#include +#include +#include +/* Requires the librt and libm libraries */ + +static const long NSEC_PER_SEC = 1000000000L; + +static inline bool +timespec_greater(const struct timespec* t1, + const struct timespec* t0) +{ + return ((t1->tv_sec > t0->tv_sec) || + ((t1->tv_sec == t0->tv_sec) && + (t1->tv_nsec > t0->tv_nsec))); +} + +static inline bool +timespec_greater(const struct timespec t1, + const struct timespec t0) +{ + return ((t1.tv_sec > t0.tv_sec) || + ((t1.tv_sec == t0.tv_sec) && + (t1.tv_nsec > t0.tv_nsec))); +} + +static inline bool +timespec_less(const struct timespec* t1, + const struct timespec* t0) +{ + return ((t1->tv_sec < t0->tv_sec) || + ((t1->tv_sec == t0->tv_sec) && + (t1->tv_nsec < t0->tv_nsec))); +} + +static inline bool +timespec_less(const struct timespec t1, + const struct timespec t0) +{ + return ((t1.tv_sec < t0.tv_sec) || + ((t1.tv_sec == t0.tv_sec) && + (t1.tv_nsec < t0.tv_nsec))); +} + +static inline bool +timespec_equal(const struct timespec* t1, + const struct timespec* t0) +{ + return ((t1->tv_sec == t0->tv_sec) && + (t1->tv_nsec == t0->tv_nsec)); +} + +static inline bool +timespec_equal(const struct timespec t1, + const struct timespec t0) +{ + return ((t1.tv_sec == t0.tv_sec) && + (t1.tv_nsec == t0.tv_nsec)); +} + +static inline void +timespec_reset(struct timespec* ret) +{ + ret->tv_sec = 0; + ret->tv_nsec = 0; +} + +static inline void +set_normalized_timespec(struct timespec *ts, + time_t sec, long nsec) +{ + while (nsec > NSEC_PER_SEC) { + nsec -= NSEC_PER_SEC; + ++sec; + } + while(nsec < 0) { + nsec += NSEC_PER_SEC; + --sec; + } + ts->tv_sec = sec; + ts->tv_nsec = nsec; +} + +static inline struct timespec +convert_to_timespec(const double timeValue) +{ + struct timespec ret; + double seconds = 0; + long nsec = static_cast(modf(timeValue, &seconds) * + static_cast(NSEC_PER_SEC)); + time_t sec = static_cast(seconds); + + set_normalized_timespec(&ret, sec, nsec); + + return ret; +} + +static inline double +convert_from_timespec(const timespec actual) +{ + return (static_cast(actual.tv_sec) + + (static_cast(actual.tv_nsec) / + static_cast(NSEC_PER_SEC))); +} + +static inline void +timespec_add(struct timespec *ret, + const struct timespec* t1, + const struct timespec* t0) +{ + time_t sec = t1->tv_sec + t0->tv_sec; + long nsec = t1->tv_nsec + t0->tv_nsec; + + set_normalized_timespec(ret, sec, nsec); +} + +static inline void +timespec_add(struct timespec *ret, + const struct timespec t1, + const struct timespec t0) +{ + return timespec_add(ret, &t1, &t0); +} + +static inline struct timespec +timespec_add(const struct timespec t1, + const struct timespec t0) +{ + struct timespec ret; + timespec_add(&ret, &t1, &t0); + return ret; +} + +static inline struct timespec +timespec_add(const struct timespec t1, + const double time0) +{ + struct timespec ret; + struct timespec t0; + t0 = convert_to_timespec(time0); + + timespec_add(&ret, &t1, &t0); + + return ret; +} + +static inline void +timespec_subtract(struct timespec *ret, + const struct timespec* t1, + const struct timespec* t0) +{ + time_t sec = t1->tv_sec - t0->tv_sec; + long nsec = t1->tv_nsec - t0->tv_nsec; + + set_normalized_timespec(ret, sec, nsec); +} + +static inline void +timespec_subtract(struct timespec *ret, + const struct timespec t1, + const struct timespec t0) +{ + return timespec_subtract(ret, &t1, &t0); +} + +static inline struct timespec +timespec_subtract(const struct timespec t1, + const struct timespec t0) +{ + struct timespec ret; + timespec_subtract(&ret, &t1, &t0); + return ret; +} + +static inline struct timespec +timespec_subtract(const struct timespec t1, + const double time0) +{ + struct timespec ret; + struct timespec t0; + t0 = convert_to_timespec(time0); + + timespec_subtract(&ret, &t1, &t0); + + return ret; +} + +static inline double +diff_timespec(struct timespec* ret, + const struct timespec *t1, + const struct timespec* t0) +{ + struct timespec actual; + time_t sec = 0; + long nsec = 0; + + if(timespec_greater(t1, t0)){ + sec = t1->tv_sec - t0->tv_sec; + nsec = t1->tv_nsec - t0->tv_nsec; + + set_normalized_timespec(&actual, sec, nsec); + + if(ret != NULL){ + ret->tv_sec = actual.tv_sec; + ret->tv_nsec = actual.tv_nsec; + } + + return convert_from_timespec(actual); + } + else{ + sec = t0->tv_sec - t1->tv_sec; + nsec = t0->tv_nsec - t1->tv_nsec; + + // Do nothing with the ret value as the ret value + // would have to store a negative, which it can't. + + set_normalized_timespec(&actual, sec, nsec); + + return (-convert_from_timespec(actual)); + } +} + +static inline double +diff_timespec(struct timespec* ret, + const struct timespec t1, + const struct timespec t0) +{ + return diff_timespec(ret, &t1, &t0); +} + +static inline double +diff_timespec(const struct timespec t1, + const struct timespec t0) +{ + return diff_timespec(NULL, &t1, &t0); +} + + +static inline double +diff_timespec(const struct timespec* t1, + const struct timespec* t0) +{ + return diff_timespec(NULL, t1, t0); +} + + +#ifdef CLOCK_REALTIME +// If we can use clock_gettime, use it; +// otherwise, use gettimeofday +static inline void +get_highres_clock(struct timespec* ret) +{ + if(clock_gettime(CLOCK_REALTIME, ret) != 0){ + // Unable to get high resolution time - + // fail over to low resolution time + timeval lowResTime; + gettimeofday(&lowResTime, NULL); + ret->tv_sec = lowResTime.tv_sec; + ret->tv_nsec = lowResTime.tv_usec*1000; + } +} + +#else + +// Trick timer functions into thinking it has an nsec timer +// but only use the low resolution (usec) timer. +static inline void +get_highres_clock(struct timespec* ret) +{ + timeval lowResTime; + gettimeofday(&lowResTime, NULL); + ret->tv_sec = lowResTime.tv_sec; + ret->tv_nsec = lowResTime.tv_usec*1000; +} +#endif + +static inline struct timespec +get_highres_clock() +{ + struct timespec ret; + get_highres_clock(&ret); + return ret; +} + +static inline bool +timespec_empty(const struct timespec* ret) +{ + return ( (ret->tv_sec == 0 ) && (ret->tv_nsec == 0) ); +} + +static inline bool +timespec_empty(const struct timespec ret) +{ + return timespec_empty(&ret); +} + +#endif /* HIGH_RES_TIME_FUNCTIONS_H */ diff --git a/gr-qtgui/lib/plot_waterfall.cc b/gr-qtgui/lib/plot_waterfall.cc new file mode 100644 index 000000000..2b1447e03 --- /dev/null +++ b/gr-qtgui/lib/plot_waterfall.cc @@ -0,0 +1,325 @@ +#include +#include +#include +#include "qwt_painter.h" +#include "qwt_double_interval.h" +#include "qwt_scale_map.h" +#include "qwt_color_map.h" +#include "plot_waterfall.h" + +#if QT_VERSION < 0x040000 +typedef Q3ValueVector QwtColorTable; +#else +typedef QVector QwtColorTable; +#endif + + +class PlotWaterfallImage: public QImage +{ + // This class hides some Qt3/Qt4 API differences +public: + PlotWaterfallImage(const QSize &size, QwtColorMap::Format format): +#if QT_VERSION < 0x040000 + QImage(size, format == QwtColorMap::RGB ? 32 : 8) +#else + QImage(size, format == QwtColorMap::RGB + ? QImage::Format_ARGB32 : QImage::Format_Indexed8 ) +#endif + { + } + + PlotWaterfallImage(const QImage &other): + QImage(other) + { + } + + void initColorTable(const QImage& other) + { +#if QT_VERSION < 0x040000 + const unsigned int numColors = other.numColors(); + + setNumColors(numColors); + for ( unsigned int i = 0; i < numColors; i++ ) + setColor(i, other.color(i)); +#else + setColorTable(other.colorTable()); +#endif + } + +#if QT_VERSION < 0x040000 + + void setColorTable(const QwtColorTable &colorTable) + { + setNumColors(colorTable.size()); + for ( unsigned int i = 0; i < colorTable.size(); i++ ) + setColor(i, colorTable[i]); + } + + QwtColorTable colorTable() const + { + QwtColorTable table(numColors()); + for ( int i = 0; i < numColors(); i++ ) + table[i] = color(i); + + return table; + } +#endif +}; + +class PlotWaterfall::PrivateData +{ +public: + PrivateData() + { + data = NULL; + colorMap = new QwtLinearColorMap(); + } + ~PrivateData() + { + delete colorMap; + } + + WaterfallData *data; + QwtColorMap *colorMap; +}; + +/*! + Sets the following item attributes: + - QwtPlotItem::AutoScale: true + - QwtPlotItem::Legend: false + + The z value is initialized by 8.0. + + \param title Title + + \sa QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ() +*/ +PlotWaterfall::PlotWaterfall(WaterfallData* data, const QString &title): + QwtPlotRasterItem(title) +{ + d_data = new PrivateData(); + d_data->data = data; + +// setCachePolicy(QwtPlotRasterItem::PaintCache); + + setItemAttribute(QwtPlotItem::AutoScale, true); + setItemAttribute(QwtPlotItem::Legend, false); + + setZ(8.0); +} + +//! Destructor +PlotWaterfall::~PlotWaterfall() +{ + delete d_data; +} + +const WaterfallData* PlotWaterfall::data()const{ + return d_data->data; +} + +//! \return QwtPlotItem::Rtti_PlotSpectrogram +int PlotWaterfall::rtti() const +{ + return QwtPlotItem::Rtti_PlotSpectrogram; +} + +/*! + Change the color map + + Often it is useful to display the mapping between intensities and + colors as an additional plot axis, showing a color bar. + + \param colorMap Color Map + + \sa colorMap(), QwtScaleWidget::setColorBarEnabled(), + QwtScaleWidget::setColorMap() +*/ +void PlotWaterfall::setColorMap(const QwtColorMap &colorMap) +{ + delete d_data->colorMap; + d_data->colorMap = colorMap.copy(); + + invalidateCache(); + itemChanged(); +} + +/*! + \return Color Map used for mapping the intensity values to colors + \sa setColorMap() +*/ +const QwtColorMap &PlotWaterfall::colorMap() const +{ + return *d_data->colorMap; +} +/*! + \return Bounding rect of the data + \sa QwtRasterData::boundingRect +*/ +QwtDoubleRect PlotWaterfall::boundingRect() const +{ + return d_data->data->boundingRect(); +} + +/*! + \brief Returns the recommended raster for a given rect. + + F.e the raster hint is used to limit the resolution of + the image that is rendered. + + \param rect Rect for the raster hint + \return data().rasterHint(rect) +*/ +QSize PlotWaterfall::rasterHint(const QwtDoubleRect &rect) const +{ + return d_data->data->rasterHint(rect); +} + +/*! + \brief Render an image from the data and color map. + + The area is translated into a rect of the paint device. + For each pixel of this rect the intensity is mapped + into a color. + + \param xMap X-Scale Map + \param yMap Y-Scale Map + \param area Area that should be rendered in scale coordinates. + + \return A QImage::Format_Indexed8 or QImage::Format_ARGB32 depending + on the color map. + + \sa QwtRasterData::intensity(), QwtColorMap::rgb(), + QwtColorMap::colorIndex() +*/ +QImage PlotWaterfall::renderImage( + const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtDoubleRect &area) const +{ + if ( area.isEmpty() ) + return QImage(); + + QRect rect = transform(xMap, yMap, area); + + QwtScaleMap xxMap = xMap; + QwtScaleMap yyMap = yMap; + + const QSize res = d_data->data->rasterHint(area); + if ( res.isValid() ) + { + /* + It is useless to render an image with a higher resolution + than the data offers. Of course someone will have to + scale this image later into the size of the given rect, but f.e. + in case of postscript this will done on the printer. + */ + rect.setSize(rect.size().boundedTo(res)); + + int px1 = rect.x(); + int px2 = rect.x() + rect.width(); + if ( xMap.p1() > xMap.p2() ) + qSwap(px1, px2); + + double sx1 = area.x(); + double sx2 = area.x() + area.width(); + if ( xMap.s1() > xMap.s2() ) + qSwap(sx1, sx2); + + int py1 = rect.y(); + int py2 = rect.y() + rect.height(); + if ( yMap.p1() > yMap.p2() ) + qSwap(py1, py2); + + double sy1 = area.y(); + double sy2 = area.y() + area.height(); + if ( yMap.s1() > yMap.s2() ) + qSwap(sy1, sy2); + + xxMap.setPaintInterval(px1, px2); + xxMap.setScaleInterval(sx1, sx2); + yyMap.setPaintInterval(py1, py2); + yyMap.setScaleInterval(sy1, sy2); + } + + PlotWaterfallImage image(rect.size(), d_data->colorMap->format()); + + const QwtDoubleInterval intensityRange = d_data->data->range(); + if ( !intensityRange.isValid() ) + return image; + + d_data->data->initRaster(area, rect.size()); + + if ( d_data->colorMap->format() == QwtColorMap::RGB ) + { + for ( int y = rect.top(); y <= rect.bottom(); y++ ) + { + const double ty = yyMap.invTransform(y); + + QRgb *line = (QRgb *)image.scanLine(y - rect.top()); + for ( int x = rect.left(); x <= rect.right(); x++ ) + { + const double tx = xxMap.invTransform(x); + + *line++ = d_data->colorMap->rgb(intensityRange, + d_data->data->value(tx, ty)); + } + } + } + else if ( d_data->colorMap->format() == QwtColorMap::Indexed ) + { + image.setColorTable(d_data->colorMap->colorTable(intensityRange)); + + for ( int y = rect.top(); y <= rect.bottom(); y++ ) + { + const double ty = yyMap.invTransform(y); + + unsigned char *line = image.scanLine(y - rect.top()); + for ( int x = rect.left(); x <= rect.right(); x++ ) + { + const double tx = xxMap.invTransform(x); + + *line++ = d_data->colorMap->colorIndex(intensityRange, + d_data->data->value(tx, ty)); + } + } + } + + d_data->data->discardRaster(); + + // Mirror the image in case of inverted maps + + const bool hInvert = xxMap.p1() > xxMap.p2(); + const bool vInvert = yyMap.p1() < yyMap.p2(); + if ( hInvert || vInvert ) + { +#ifdef __GNUC__ +#endif +#if QT_VERSION < 0x040000 + image = image.mirror(hInvert, vInvert); +#else + image = image.mirrored(hInvert, vInvert); +#endif + } + + return image; +} + +/*! + \brief Draw the spectrogram + + \param painter Painter + \param xMap Maps x-values into pixel coordinates. + \param yMap Maps y-values into pixel coordinates. + \param canvasRect Contents rect of the canvas in painter coordinates + + \sa setDisplayMode, renderImage, + QwtPlotRasterItem::draw, drawContourLines +*/ + +void PlotWaterfall::draw(QPainter *painter, + const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRect &canvasRect) const +{ + QwtPlotRasterItem::draw(painter, xMap, yMap, canvasRect); +} + diff --git a/gr-qtgui/lib/plot_waterfall.h b/gr-qtgui/lib/plot_waterfall.h new file mode 100644 index 000000000..a11461611 --- /dev/null +++ b/gr-qtgui/lib/plot_waterfall.h @@ -0,0 +1,52 @@ +#ifndef PLOT_WATERFALL_H +#define PLOT_WATERFALL_H + +#include +#include + +#include "qwt_valuelist.h" +#include "qwt_plot_rasteritem.h" + +class QwtColorMap; + +/*! + \brief A plot item, which displays a waterfall spectrogram + + 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; + + virtual QwtDoubleRect boundingRect() const; + virtual QSize rasterHint(const QwtDoubleRect &) const; + + virtual int rtti() const; + + virtual void draw(QPainter *p, + const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRect &rect) const; + +protected: + virtual QImage renderImage( + const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtDoubleRect &rect) const; + +private: + class PrivateData; + PrivateData *d_data; +}; + +#endif diff --git a/gr-qtgui/lib/qtgui.h b/gr-qtgui/lib/qtgui.h new file mode 100644 index 000000000..9831697ac --- /dev/null +++ b/gr-qtgui/lib/qtgui.h @@ -0,0 +1,71 @@ +/* -*- 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 INCLUDED_QTGUI_H +#define INCLUDED_QTGUI_H + +#include +#include +#include "SpectrumGUIClass.h" + +class qtgui_event : public QEvent +{ +private: + gruel::mutex &d_mutex; + +public: + qtgui_event(gruel::mutex &mutex) + : QEvent((QEvent::Type)(QEvent::User+101)), + d_mutex(mutex) + { + //nop + } + + void lock() + { + d_mutex.lock(); + } + + void unlock() + { + d_mutex.unlock(); + } +}; + +class qtgui_obj : public QObject +{ +public: + qtgui_obj(QObject *p) + : QObject(p) + { + } + + void customEvent(QEvent *e) + { + if(e->type() == (QEvent::Type)(QEvent::User+101)) { + qtgui_event *qt = (qtgui_event*)e; + qt->unlock(); + } + } +}; + +#endif /* INCLUDED_QTGUI_H */ diff --git a/gr-qtgui/lib/qtgui.i b/gr-qtgui/lib/qtgui.i new file mode 100644 index 000000000..bb64c6ae2 --- /dev/null +++ b/gr-qtgui/lib/qtgui.i @@ -0,0 +1,131 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009 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. + */ + +%include "gnuradio.i" + +%{ +#include "qtgui_sink_c.h" +#include "qtgui_sink_f.h" +%} + +GR_SWIG_BLOCK_MAGIC(qtgui,sink_c) + + qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, + double fc=0, double bw=1.0, + const std::string &name="Display", + bool plotfreq=true, bool plotwaterfall=true, + bool plotwaterfall3d=true, bool plottime=true, + bool plotconst=true, + bool use_openGL=true, + QWidget *parent=NULL); + +class qtgui_sink_c : public gr_block +{ +private: + friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + qtgui_sink_c (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + +public: + void exec_(); + PyObject* pyqwidget(); + + void set_frequency_range(const double centerfreq, + const double bandwidth); + void set_time_domain_axis(double min, double max); + void set_constellation_axis(double xmin, double xmax, + double ymin, double ymax); + void set_frequency_axis(double min, double max); + void set_constellation_pen_size(int size); +}; + + + +/*********************************************************************/ + + +GR_SWIG_BLOCK_MAGIC(qtgui,sink_f) + +qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, + double fc=0, double bw=0.0, + const std::string &name="Display", + bool plotfreq=true, bool plotwaterfall=true, + bool plotwaterfall3d=true, bool plottime=true, + bool plotconst=true, + bool use_openGL=true, + QWidget *parent=NULL); + +class qtgui_sink_f : public gr_block +{ +private: + friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + qtgui_sink_f (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + +public: + void exec_(); + PyObject* pyqwidget(); + + void set_frequency_range(const double centerfreq, + const double bandwidth); + void set_time_domain_axis(double min, double max); + void set_constellation_axis(double xmin, double xmax, + double ymin, double ymax); + void set_frequency_axis(double min, double max); + void set_constellation_pen_size(int size); +}; + +#if SWIGGUILE +%scheme %{ +(load-extension-global "libguile-gnuradio-qtgui" "scm_init_gnuradio_qtgui_module") +%} + +%goops %{ +(use-modules (gnuradio gnuradio_core_runtime)) +%} +#endif diff --git a/gr-qtgui/lib/qtgui_sink_c.cc b/gr-qtgui/lib/qtgui_sink_c.cc new file mode 100644 index 000000000..05c7b28d5 --- /dev/null +++ b/gr-qtgui/lib/qtgui_sink_c.cc @@ -0,0 +1,326 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + +qtgui_sink_c_sptr +qtgui_make_sink_c (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent) +{ + return gnuradio::get_initial_sptr(new qtgui_sink_c (fftsize, wintype, + fc, bw, name, + plotfreq, plotwaterfall, + plotwaterfall3d, plottime, + plotconst, + use_openGL, + parent)); +} + +qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent) + : gr_block ("sink_c", + gr_make_io_signature (1, -1, sizeof(gr_complex)), + gr_make_io_signature (0, 0, 0)), + d_fftsize(fftsize), + d_wintype((gr_firdes::win_type)(wintype)), + d_center_freq(fc), d_bandwidth(bw), d_name(name), + d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall), + d_plottime(plottime), d_plotconst(plotconst), + d_parent(parent) +{ + if(plotwaterfall3d == true) { + fprintf(stderr, "Warning: plotting Waterfall3D has been removed; enabling plotwaterfall3d has no effect.\n"); + } + + d_main_gui = NULL; + lock(); + + // Perform fftshift operation; + // this is usually desired when plotting + d_shift = true; + + d_fft = new gri_fft_complex (d_fftsize, true); + + d_index = 0; + d_residbuf = new gr_complex[d_fftsize]; + + buildwindow(); + + initialize(use_openGL); +} + +qtgui_sink_c::~qtgui_sink_c() +{ + delete d_main_gui; + delete [] d_residbuf; + delete d_fft; +} + +void +qtgui_sink_c::forecast(int noutput_items, gr_vector_int &ninput_items_required) +{ + unsigned int ninputs = ninput_items_required.size(); + for (unsigned int i = 0; i < ninputs; i++) { + ninput_items_required[i] = std::min(d_fftsize, 8191); + } +} + +void qtgui_sink_c::lock() +{ + d_mutex.lock(); +} + +void qtgui_sink_c::unlock() +{ + d_mutex.unlock(); +} + + +void +qtgui_sink_c::initialize(const bool opengl) +{ + if(qApp != NULL) { + d_qApplication = qApp; + } + else { + int argc; + char **argv = NULL; + d_qApplication = new QApplication(argc, argv); + } + + if(d_center_freq < 0) { + throw std::runtime_error("qtgui_sink_c: Received bad center frequency.\n"); + } + + uint64_t maxBufferSize = 32768; + d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize, + d_center_freq, + -d_bandwidth/2.0, + d_bandwidth/2.0); + + d_main_gui->SetDisplayTitle(d_name); + d_main_gui->SetFFTSize(d_fftsize); + d_main_gui->SetWindowType((int)d_wintype); + + d_main_gui->OpenSpectrumWindow(d_parent, + d_plotfreq, d_plotwaterfall, + d_plottime, d_plotconst, + opengl); + + // initialize update time to 10 times a second + set_update_time(0.1); + + d_object = new qtgui_obj(d_qApplication); + qApp->postEvent(d_object, new qtgui_event(d_mutex)); +} + + +void +qtgui_sink_c::exec_() +{ + d_qApplication->exec(); +} + +QWidget* +qtgui_sink_c::qwidget() +{ + return d_main_gui->qwidget(); +} + +PyObject* +qtgui_sink_c::pyqwidget() +{ + PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui->qwidget()); + PyObject *retarg = Py_BuildValue("N", w); + return retarg; +} + +void +qtgui_sink_c::set_frequency_range(const double centerfreq, + const double bandwidth) +{ + d_center_freq = centerfreq; + d_bandwidth = bandwidth; + d_main_gui->SetFrequencyRange(d_center_freq, + -d_bandwidth/2.0, + d_bandwidth/2.0); +} + +void +qtgui_sink_c::set_time_domain_axis(double min, double max) +{ + d_main_gui->SetTimeDomainAxis(min, max); +} + +void +qtgui_sink_c::set_constellation_axis(double xmin, double xmax, + double ymin, double ymax) +{ + d_main_gui->SetConstellationAxis(xmin, xmax, ymin, ymax); +} + +void +qtgui_sink_c::set_constellation_pen_size(int size) +{ + d_main_gui->SetConstellationPenSize(size); +} + + +void +qtgui_sink_c::set_frequency_axis(double min, double max) +{ + d_main_gui->SetFrequencyAxis(min, max); +} + +void +qtgui_sink_c::set_update_time(double t) +{ + d_update_time = t; + d_main_gui->SetUpdateTime(d_update_time); +} + +void +qtgui_sink_c::fft(const gr_complex *data_in, int size) +{ + if (d_window.size()) { + gr_complex *dst = d_fft->get_inbuf(); + int i; + for (i = 0; i < size; i++) // apply window + dst[i] = data_in[i] * d_window[i]; + } + else { + memcpy (d_fft->get_inbuf(), data_in, sizeof(gr_complex)*size); + } + + d_fft->execute (); // compute the fft +} + +void +qtgui_sink_c::windowreset() +{ + gr_firdes::win_type newwintype = (gr_firdes::win_type)d_main_gui->GetWindowType(); + if(d_wintype != newwintype) { + d_wintype = newwintype; + buildwindow(); + } +} + +void +qtgui_sink_c::buildwindow() +{ + d_window.clear(); + if(d_wintype != 0) { + d_window = gr_firdes::window(d_wintype, d_fftsize, 6.76); + } +} + +void +qtgui_sink_c::fftresize() +{ + int newfftsize = d_main_gui->GetFFTSize(); + + if(newfftsize != d_fftsize) { + + // Resize residbuf and replace data + delete [] d_residbuf; + d_residbuf = new gr_complex[newfftsize]; + + // Set new fft size and reset buffer index + // (throws away any currently held data, but who cares?) + d_fftsize = newfftsize; + d_index = 0; + + // Reset window to reflect new size + buildwindow(); + + // Reset FFTW plan for new size + delete d_fft; + d_fft = new gri_fft_complex (d_fftsize, true); + } +} + + +int +qtgui_sink_c::general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + int j=0; + const gr_complex *in = (const gr_complex*)input_items[0]; + + gruel::scoped_lock lock(d_mutex); + + // Update the FFT size from the application + fftresize(); + windowreset(); + + for(int i=0; i < noutput_items; i+=d_fftsize) { + unsigned int datasize = noutput_items - i; + unsigned int resid = d_fftsize-d_index; + + // If we have enough input for one full FFT, do it + if(datasize >= resid) { + const timespec currentTime = get_highres_clock(); + + // Fill up residbuf with d_fftsize number of items + memcpy(d_residbuf+d_index, &in[j], sizeof(gr_complex)*resid); + d_index = 0; + + j += resid; + fft(d_residbuf, d_fftsize); + + d_main_gui->UpdateWindow(true, d_fft->get_outbuf(), d_fftsize, + NULL, 0, (float*)d_residbuf, d_fftsize, + currentTime, true); + } + // Otherwise, copy what we received into the residbuf for next time + else { + memcpy(d_residbuf+d_index, &in[j], sizeof(gr_complex)*datasize); + d_index += datasize; + j += datasize; + } + } + + consume_each(j); + return j; +} diff --git a/gr-qtgui/lib/qtgui_sink_c.h b/gr-qtgui/lib/qtgui_sink_c.h new file mode 100644 index 000000000..bbf9983b0 --- /dev/null +++ b/gr-qtgui/lib/qtgui_sink_c.h @@ -0,0 +1,127 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009,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_SINK_C_H +#define INCLUDED_QTGUI_SINK_C_H + +#include +#include +#include +#include +#include +#include +#include "SpectrumGUIClass.h" + +class qtgui_sink_c; +typedef boost::shared_ptr qtgui_sink_c_sptr; + +qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, + double fc=0, double bandwidth=1.0, + const std::string &name="Spectrum Display", + bool plotfreq=true, bool plotwaterfall=true, + bool plotwaterfall3d=true, bool plottime=true, + bool plotconst=true, + bool use_openGL=true, + QWidget *parent=NULL); + +class qtgui_sink_c : public gr_block +{ +private: + friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + qtgui_sink_c (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + + // use opengl to force OpenGL on or off + // this might be necessary for sessions over SSH + void initialize(const bool opengl=true); + + int d_fftsize; + gr_firdes::win_type d_wintype; + std::vector d_window; + double d_center_freq; + double d_bandwidth; + std::string d_name; + + gruel::mutex d_mutex; + + bool d_shift; + gri_fft_complex *d_fft; + + int d_index; + gr_complex *d_residbuf; + + bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst; + + double d_update_time; + + QWidget *d_parent; + SpectrumGUIClass *d_main_gui; + + void windowreset(); + void buildwindow(); + void fftresize(); + void fft(const gr_complex *data_in, int size); + +public: + ~qtgui_sink_c(); + void exec_(); + void lock(); + void unlock(); + QWidget* qwidget(); + PyObject* pyqwidget(); + + void set_frequency_range(const double centerfreq, + const double bandwidth); + + 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); + void set_frequency_axis(double min, double max); + + void set_update_time(double t); + + QApplication *d_qApplication; + qtgui_obj *d_object; + + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_QTGUI_SINK_C_H */ diff --git a/gr-qtgui/lib/qtgui_sink_f.cc b/gr-qtgui/lib/qtgui_sink_f.cc new file mode 100644 index 000000000..984c2803c --- /dev/null +++ b/gr-qtgui/lib/qtgui_sink_f.cc @@ -0,0 +1,321 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + +qtgui_sink_f_sptr +qtgui_make_sink_f (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent) +{ + return gnuradio::get_initial_sptr(new qtgui_sink_f (fftsize, wintype, + fc, bw, name, + plotfreq, plotwaterfall, + plotwaterfall3d, plottime, + plotconst, + use_openGL, + parent)); +} + +qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent) + : gr_block ("sink_f", + gr_make_io_signature (1, 1, sizeof(float)), + gr_make_io_signature (0, 0, 0)), + d_fftsize(fftsize), + d_wintype((gr_firdes::win_type)(wintype)), + d_center_freq(fc), d_bandwidth(bw), d_name(name), + d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall), + d_plottime(plottime), d_plotconst(plotconst), + d_parent(parent) +{ + if(plotwaterfall3d == true) { + fprintf(stderr, "Warning: plotting Waterfall3D has been removed; enabling plotwaterfall3d has no effect.\n"); + } + + d_main_gui = NULL; + lock(); + + // Perform fftshift operation; + // this is usually desired when plotting + d_shift = true; + + d_fft = new gri_fft_complex (d_fftsize, true); + + d_index = 0; + d_residbuf = new float[d_fftsize]; + + buildwindow(); + + initialize(use_openGL); +} + +qtgui_sink_f::~qtgui_sink_f() +{ + delete d_main_gui; + delete [] d_residbuf; + delete d_fft; +} + +void +qtgui_sink_f::forecast(int noutput_items, gr_vector_int &ninput_items_required) +{ + unsigned int ninputs = ninput_items_required.size(); + for (unsigned int i = 0; i < ninputs; i++) { + ninput_items_required[i] = std::min(d_fftsize, 8191); + } +} + +void qtgui_sink_f::lock() +{ + d_mutex.lock(); +} + +void qtgui_sink_f::unlock() +{ + d_mutex.unlock(); +} + +void +qtgui_sink_f::initialize(const bool opengl) +{ + if(qApp != NULL) { + d_qApplication = qApp; + } + else { + int argc; + char **argv = NULL; + d_qApplication = new QApplication(argc, argv); + } + + + uint64_t maxBufferSize = 32768; + d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize, + d_center_freq, + -d_bandwidth/2.0, + d_bandwidth/2.0); + d_main_gui->SetDisplayTitle(d_name); + d_main_gui->SetFFTSize(d_fftsize); + d_main_gui->SetWindowType((int)d_wintype); + + d_main_gui->OpenSpectrumWindow(d_parent, + d_plotfreq, d_plotwaterfall, + d_plottime, d_plotconst, + opengl); + + // initialize update time to 10 times a second + set_update_time(0.1); + + d_object = new qtgui_obj(d_qApplication); + qApp->postEvent(d_object, new qtgui_event(d_mutex)); +} + +void +qtgui_sink_f::exec_() +{ + d_qApplication->exec(); +} + +QWidget* +qtgui_sink_f::qwidget() +{ + return d_main_gui->qwidget(); +} + +PyObject* +qtgui_sink_f::pyqwidget() +{ + PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui->qwidget()); + PyObject *retarg = Py_BuildValue("N", w); + return retarg; +} + +void +qtgui_sink_f::set_frequency_range(const double centerfreq, + const double bandwidth) +{ + d_center_freq = centerfreq; + d_bandwidth = bandwidth; + d_main_gui->SetFrequencyRange(d_center_freq, + -d_bandwidth/2.0, + d_bandwidth/2.0); +} + +void +qtgui_sink_f::set_time_domain_axis(double min, double max) +{ + d_main_gui->SetTimeDomainAxis(min, max); +} + +void +qtgui_sink_f::set_constellation_axis(double xmin, double xmax, + double ymin, double ymax) +{ + d_main_gui->SetConstellationAxis(xmin, xmax, ymin, ymax); +} + +void +qtgui_sink_f::set_constellation_pen_size(int size) +{ + d_main_gui->SetConstellationPenSize(size); +} + + +void +qtgui_sink_f::set_frequency_axis(double min, double max) +{ + d_main_gui->SetFrequencyAxis(min, max); +} + +void +qtgui_sink_f::set_update_time(double t) +{ + d_update_time = t; + d_main_gui->SetUpdateTime(d_update_time); +} + +void +qtgui_sink_f::fft(const float *data_in, int size) +{ + if (d_window.size()) { + gr_complex *dst = d_fft->get_inbuf(); + for (int i = 0; i < size; i++) // apply window + dst[i] = data_in[i] * d_window[i]; + } + else { + gr_complex *dst = d_fft->get_inbuf(); + for (int i = 0; i < size; i++) // float to complex conversion + dst[i] = data_in[i]; + } + + d_fft->execute (); // compute the fft +} + +void +qtgui_sink_f::windowreset() +{ + gr_firdes::win_type newwintype = (gr_firdes::win_type)d_main_gui->GetWindowType(); + if(d_wintype != newwintype) { + d_wintype = newwintype; + buildwindow(); + } +} + +void +qtgui_sink_f::buildwindow() +{ + d_window.clear(); + if(d_wintype != 0) { + d_window = gr_firdes::window(d_wintype, d_fftsize, 6.76); + } +} + +void +qtgui_sink_f::fftresize() +{ + int newfftsize = d_main_gui->GetFFTSize(); + + if(newfftsize != d_fftsize) { + + // Resize residbuf and replace data + delete [] d_residbuf; + d_residbuf = new float[newfftsize]; + + // Set new fft size and reset buffer index + // (throws away any currently held data, but who cares?) + d_fftsize = newfftsize; + d_index = 0; + + // Reset window to reflect new size + buildwindow(); + + // Reset FFTW plan for new size + delete d_fft; + d_fft = new gri_fft_complex (d_fftsize, true); + } +} + + +int +qtgui_sink_f::general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + int j=0; + const float *in = (const float*)input_items[0]; + + gruel::scoped_lock lock(d_mutex); + + // Update the FFT size from the application + fftresize(); + windowreset(); + + for(int i=0; i < noutput_items; i+=d_fftsize) { + unsigned int datasize = noutput_items - i; + unsigned int resid = d_fftsize-d_index; + + // If we have enough input for one full FFT, do it + if(datasize >= resid) { + const timespec currentTime = get_highres_clock(); + + // Fill up residbuf with d_fftsize number of items + memcpy(d_residbuf+d_index, &in[j], sizeof(float)*resid); + d_index = 0; + + j += resid; + fft(d_residbuf, d_fftsize); + + d_main_gui->UpdateWindow(true, d_fft->get_outbuf(), d_fftsize, + (float*)d_residbuf, d_fftsize, NULL, 0, + currentTime, true); + } + // Otherwise, copy what we received into the residbuf for next time + else { + memcpy(d_residbuf+d_index, &in[j], sizeof(float)*datasize); + d_index += datasize; + j += datasize; + } + } + + consume_each(j); + return j; +} diff --git a/gr-qtgui/lib/qtgui_sink_f.h b/gr-qtgui/lib/qtgui_sink_f.h new file mode 100644 index 000000000..d80a6a198 --- /dev/null +++ b/gr-qtgui/lib/qtgui_sink_f.h @@ -0,0 +1,125 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009,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_SINK_F_H +#define INCLUDED_QTGUI_SINK_F_H + +#include +#include +#include +#include +#include +#include +#include "SpectrumGUIClass.h" + +class qtgui_sink_f; +typedef boost::shared_ptr qtgui_sink_f_sptr; + +qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, + double fc=0, double bw=1.0, + const std::string &name="Spectrum Display", + bool plotfreq=true, bool plotwaterfall=true, + bool plotwaterfall3d=true, bool plottime=true, + bool plotconst=true, + bool use_openGL=true, + QWidget *parent=NULL); + +class qtgui_sink_f : public gr_block +{ +private: + friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + qtgui_sink_f (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + + void initialize(const bool opengl=true); + + int d_fftsize; + gr_firdes::win_type d_wintype; + std::vector d_window; + double d_center_freq; + double d_bandwidth; + std::string d_name; + + gruel::mutex d_mutex; + + bool d_shift; + gri_fft_complex *d_fft; + + int d_index; + float *d_residbuf; + + bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst; + + double d_update_time; + + QWidget *d_parent; + SpectrumGUIClass *d_main_gui; + + void windowreset(); + void buildwindow(); + void fftresize(); + void fft(const float *data_in, int size); + +public: + ~qtgui_sink_f(); + void exec_(); + void lock(); + void unlock(); + QWidget* qwidget(); + PyObject* pyqwidget(); + + void set_frequency_range(const double centerfreq, + const double bandwidth); + + 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); + void set_frequency_axis(double min, double max); + + void set_update_time(double t); + + QApplication *d_qApplication; + qtgui_obj *d_object; + + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_QTGUI_SINK_F_H */ diff --git a/gr-qtgui/lib/spectrumUpdateEvents.cc b/gr-qtgui/lib/spectrumUpdateEvents.cc new file mode 100644 index 000000000..53a205fb7 --- /dev/null +++ b/gr-qtgui/lib/spectrumUpdateEvents.cc @@ -0,0 +1,180 @@ +#ifndef SPECTRUM_UPDATE_EVENTS_C +#define SPECTRUM_UPDATE_EVENTS_C + +#include + +SpectrumUpdateEvent::SpectrumUpdateEvent(const std::complex* fftPoints, + const uint64_t numFFTDataPoints, + const double* realTimeDomainPoints, + const double* imagTimeDomainPoints, + const uint64_t numTimeDomainDataPoints, + const timespec dataTimestamp, + const bool repeatDataFlag, + const bool lastOfMultipleUpdateFlag, + const timespec generatedTimestamp, + const int droppedFFTFrames) + : QEvent(QEvent::Type(10005)) +{ + if(numFFTDataPoints < 1) { + _numFFTDataPoints = 1; + } + else { + _numFFTDataPoints = numFFTDataPoints; + } + + if(numTimeDomainDataPoints < 1) { + _numTimeDomainDataPoints = 1; + } + else { + _numTimeDomainDataPoints = numTimeDomainDataPoints; + } + + _fftPoints = new std::complex[_numFFTDataPoints]; + _fftPoints[0] = std::complex(0,0); + memcpy(_fftPoints, fftPoints, numFFTDataPoints*sizeof(std::complex)); + + _realDataTimeDomainPoints = new double[_numTimeDomainDataPoints]; + memset(_realDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double)); + if(numTimeDomainDataPoints > 0) { + memcpy(_realDataTimeDomainPoints, realTimeDomainPoints, + numTimeDomainDataPoints*sizeof(double)); + } + + _imagDataTimeDomainPoints = new double[_numTimeDomainDataPoints]; + memset(_imagDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double)); + if(numTimeDomainDataPoints > 0) { + memcpy(_imagDataTimeDomainPoints, imagTimeDomainPoints, + numTimeDomainDataPoints*sizeof(double)); + } + _dataTimestamp = dataTimestamp; + _repeatDataFlag = repeatDataFlag; + _lastOfMultipleUpdateFlag = lastOfMultipleUpdateFlag; + _eventGeneratedTimestamp = generatedTimestamp; + _droppedFFTFrames = droppedFFTFrames; +} + +SpectrumUpdateEvent::~SpectrumUpdateEvent() +{ + delete[] _fftPoints; + delete[] _realDataTimeDomainPoints; + delete[] _imagDataTimeDomainPoints; +} + +const std::complex* +SpectrumUpdateEvent::getFFTPoints() const +{ + return _fftPoints; +} + +const double* +SpectrumUpdateEvent::getRealTimeDomainPoints() const +{ + return _realDataTimeDomainPoints; +} + +const double* +SpectrumUpdateEvent::getImagTimeDomainPoints() const +{ + return _imagDataTimeDomainPoints; +} + +uint64_t +SpectrumUpdateEvent::getNumFFTDataPoints() const +{ + return _numFFTDataPoints; +} + +uint64_t +SpectrumUpdateEvent::getNumTimeDomainDataPoints() const +{ + return _numTimeDomainDataPoints; +} + +timespec +SpectrumUpdateEvent::getDataTimestamp() const +{ + return _dataTimestamp; +} + +bool +SpectrumUpdateEvent::getRepeatDataFlag() const +{ + return _repeatDataFlag; +} + +bool +SpectrumUpdateEvent::getLastOfMultipleUpdateFlag() const +{ + return _lastOfMultipleUpdateFlag; +} + +timespec +SpectrumUpdateEvent::getEventGeneratedTimestamp() const +{ + return _eventGeneratedTimestamp; +} + +int +SpectrumUpdateEvent::getDroppedFFTFrames() const +{ + return _droppedFFTFrames; +} + +SpectrumWindowCaptionEvent::SpectrumWindowCaptionEvent(const QString& newLbl) + : QEvent(QEvent::Type(10008)) +{ + _labelString = newLbl; +} + +SpectrumWindowCaptionEvent::~SpectrumWindowCaptionEvent() +{ +} + +QString +SpectrumWindowCaptionEvent::getLabel() +{ + return _labelString; +} + +SpectrumWindowResetEvent::SpectrumWindowResetEvent() + : QEvent(QEvent::Type(10009)) +{ +} + +SpectrumWindowResetEvent::~SpectrumWindowResetEvent() +{ +} + +SpectrumFrequencyRangeEvent::SpectrumFrequencyRangeEvent(const double centerFreq, + const double startFreq, + const double stopFreq) + : QEvent(QEvent::Type(10010)) +{ + _centerFrequency = centerFreq; + _startFrequency = startFreq; + _stopFrequency = stopFreq; +} + +SpectrumFrequencyRangeEvent::~SpectrumFrequencyRangeEvent() +{ +} + +double +SpectrumFrequencyRangeEvent::GetCenterFrequency() const +{ + return _centerFrequency; +} + +double +SpectrumFrequencyRangeEvent::GetStartFrequency() const +{ + return _startFrequency; +} + +double +SpectrumFrequencyRangeEvent::GetStopFrequency() const +{ + return _stopFrequency; +} + +#endif /* SPECTRUM_UPDATE_EVENTS_C */ diff --git a/gr-qtgui/lib/spectrumUpdateEvents.h b/gr-qtgui/lib/spectrumUpdateEvents.h new file mode 100644 index 000000000..ccc072c3e --- /dev/null +++ b/gr-qtgui/lib/spectrumUpdateEvents.h @@ -0,0 +1,92 @@ +#ifndef SPECTRUM_UPDATE_EVENTS_H +#define SPECTRUM_UPDATE_EVENTS_H + +#include +#include +#include +#include +#include + +class SpectrumUpdateEvent:public QEvent{ + +public: + SpectrumUpdateEvent(const std::complex* fftPoints, + const uint64_t numFFTDataPoints, + const double* realTimeDomainPoints, + const double* imagTimeDomainPoints, + const uint64_t numTimeDomainDataPoints, + const timespec dataTimestamp, + const bool repeatDataFlag, + const bool lastOfMultipleUpdateFlag, + const timespec generatedTimestamp, + const int droppedFFTFrames); + + ~SpectrumUpdateEvent(); + + const std::complex* getFFTPoints() const; + const double* getRealTimeDomainPoints() const; + const double* getImagTimeDomainPoints() const; + uint64_t getNumFFTDataPoints() const; + uint64_t getNumTimeDomainDataPoints() const; + timespec getDataTimestamp() const; + bool getRepeatDataFlag() const; + bool getLastOfMultipleUpdateFlag() const; + timespec getEventGeneratedTimestamp() const; + int getDroppedFFTFrames() const; + +protected: + +private: + std::complex* _fftPoints; + double* _realDataTimeDomainPoints; + double* _imagDataTimeDomainPoints; + uint64_t _numFFTDataPoints; + uint64_t _numTimeDomainDataPoints; + timespec _dataTimestamp; + bool _repeatDataFlag; + bool _lastOfMultipleUpdateFlag; + timespec _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; +}; + + +#endif /* SPECTRUM_UPDATE_EVENTS_H */ diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc new file mode 100644 index 000000000..e0509a294 --- /dev/null +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -0,0 +1,691 @@ +#include +#include +#include +#include + +int SpectrumDisplayForm::_openGLWaterfall3DFlag = -1; + +SpectrumDisplayForm::SpectrumDisplayForm(bool useOpenGL, QWidget* parent) + : QWidget(parent) +{ + setupUi(this); + + _useOpenGL = useOpenGL; + _systemSpecifiedFlag = false; + _intValidator = new QIntValidator(this); + _intValidator->setBottom(0); + _frequencyDisplayPlot = new FrequencyDisplayPlot(FrequencyPlotDisplayFrame); + _waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame); + + _timeDomainDisplayPlot = new TimeDomainDisplayPlot(TimeDomainDisplayFrame); + _constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame); + _numRealDataPoints = 1024; + _realFFTDataPoints = new double[_numRealDataPoints]; + _averagedValues = new double[_numRealDataPoints]; + _historyVector = new std::vector; + + AvgLineEdit->setRange(0, 500); // Set range of Average box value from 0 to 500 + MinHoldCheckBox_toggled( false ); + MaxHoldCheckBox_toggled( false ); + + WaterfallMaximumIntensityWheel->setRange(-200, 0); + WaterfallMaximumIntensityWheel->setTickCnt(50); + WaterfallMinimumIntensityWheel->setRange(-200, 0); + WaterfallMinimumIntensityWheel->setTickCnt(50); + WaterfallMinimumIntensityWheel->setValue(-200); + + _peakFrequency = 0; + _peakAmplitude = -HUGE_VAL; + + _noiseFloorAmplitude = -HUGE_VAL; + + connect(_waterfallDisplayPlot, SIGNAL(UpdatedLowerIntensityLevel(const double)), + _frequencyDisplayPlot, SLOT(SetLowerIntensityLevel(const double))); + connect(_waterfallDisplayPlot, SIGNAL(UpdatedUpperIntensityLevel(const double)), + _frequencyDisplayPlot, SLOT(SetUpperIntensityLevel(const double))); + + _frequencyDisplayPlot->SetLowerIntensityLevel(-200); + _frequencyDisplayPlot->SetUpperIntensityLevel(-200); + + // Load up the acceptable FFT sizes... + FFTSizeComboBox->clear(); + for(long fftSize = SpectrumGUIClass::MIN_FFT_SIZE; fftSize <= SpectrumGUIClass::MAX_FFT_SIZE; fftSize *= 2){ + FFTSizeComboBox->insertItem(FFTSizeComboBox->count(), QString("%1").arg(fftSize)); + } + Reset(); + + ToggleTabFrequency(false); + ToggleTabWaterfall(false); + ToggleTabTime(false); + ToggleTabConstellation(false); + + // Create a timer to update plots at the specified rate + displayTimer = new QTimer(this); + connect(displayTimer, SIGNAL(timeout()), this, SLOT(UpdateGuiTimer())); +} + +SpectrumDisplayForm::~SpectrumDisplayForm() +{ + // Qt deletes children when parent is deleted + + // Don't worry about deleting Display Plots - they are deleted when parents are deleted + delete _intValidator; + + delete[] _realFFTDataPoints; + delete[] _averagedValues; + + for(unsigned int count = 0; count < _historyVector->size(); count++){ + delete[] _historyVector->operator[](count); + } + + delete _historyVector; + + displayTimer->stop(); + delete displayTimer; +} + +void +SpectrumDisplayForm::setSystem( SpectrumGUIClass * newSystem, + const uint64_t numFFTDataPoints, + const uint64_t numTimeDomainDataPoints ) +{ + ResizeBuffers(numFFTDataPoints, numTimeDomainDataPoints); + + if(newSystem != NULL){ + _system = newSystem; + _systemSpecifiedFlag = true; + } + else{ + _systemSpecifiedFlag = false; + } +} + +void +SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdateEvent) +{ + //_lastSpectrumEvent = (SpectrumUpdateEvent)(*spectrumUpdateEvent); + const std::complex* complexDataPoints = spectrumUpdateEvent->getFFTPoints(); + const uint64_t numFFTDataPoints = spectrumUpdateEvent->getNumFFTDataPoints(); + const double* realTimeDomainDataPoints = spectrumUpdateEvent->getRealTimeDomainPoints(); + const double* imagTimeDomainDataPoints = spectrumUpdateEvent->getImagTimeDomainPoints(); + const uint64_t numTimeDomainDataPoints = spectrumUpdateEvent->getNumTimeDomainDataPoints(); + const timespec dataTimestamp = spectrumUpdateEvent->getDataTimestamp(); + const bool repeatDataFlag = spectrumUpdateEvent->getRepeatDataFlag(); + const bool lastOfMultipleUpdatesFlag = spectrumUpdateEvent->getLastOfMultipleUpdateFlag(); + const timespec generatedTimestamp = spectrumUpdateEvent->getEventGeneratedTimestamp(); + + // REMEMBER: The dataTimestamp is NOT valid when the repeat data flag is true... + ResizeBuffers(numFFTDataPoints, numTimeDomainDataPoints); + + // Calculate the Magnitude of the complex point + const std::complex* complexDataPointsPtr = complexDataPoints+numFFTDataPoints/2; + double* realFFTDataPointsPtr = _realFFTDataPoints; + + double sumMean = 0.0; + double localPeakAmplitude = -HUGE_VAL; + double localPeakFrequency = 0.0; + const double fftBinSize = (_stopFrequency-_startFrequency) / + static_cast(numFFTDataPoints); + + // Run this twice to perform the fftshift operation on the data here as well + std::complex scaleFactor = std::complex((float)numFFTDataPoints); + for(uint64_t point = 0; point < numFFTDataPoints/2; point++){ + std::complex pt = (*complexDataPointsPtr) / scaleFactor; + *realFFTDataPointsPtr = 10.0*log10((pt.real() * pt.real() + pt.imag()*pt.imag()) + 1e-20); + + if(*realFFTDataPointsPtr > localPeakAmplitude) { + localPeakFrequency = static_cast(point) * fftBinSize; + localPeakAmplitude = *realFFTDataPointsPtr; + } + sumMean += *realFFTDataPointsPtr; + + complexDataPointsPtr++; + realFFTDataPointsPtr++; + } + + // This loop takes the first half of the input data and puts it in the + // second half of the plotted data + complexDataPointsPtr = complexDataPoints; + for(uint64_t point = 0; point < numFFTDataPoints/2; point++){ + std::complex pt = (*complexDataPointsPtr) / scaleFactor; + *realFFTDataPointsPtr = 10.0*log10((pt.real() * pt.real() + pt.imag()*pt.imag()) + 1e-20); + + if(*realFFTDataPointsPtr > localPeakAmplitude) { + localPeakFrequency = static_cast(point) * fftBinSize; + localPeakAmplitude = *realFFTDataPointsPtr; + } + sumMean += *realFFTDataPointsPtr; + + complexDataPointsPtr++; + realFFTDataPointsPtr++; + } + + // Don't update the averaging history if this is repeated data + if(!repeatDataFlag){ + _AverageHistory(_realFFTDataPoints); + + // Only use the local info if we are not repeating data + _peakAmplitude = localPeakAmplitude; + _peakFrequency = localPeakFrequency; + + // calculate the spectral mean + // +20 because for the comparison below we only want to throw out bins + // that are significantly higher (and would, thus, affect the mean more) + const double meanAmplitude = (sumMean / numFFTDataPoints) + 20.0; + + // now throw out any bins higher than the mean + sumMean = 0.0; + uint64_t newNumDataPoints = numFFTDataPoints; + for(uint64_t number = 0; number < numFFTDataPoints; number++){ + if (_realFFTDataPoints[number] <= meanAmplitude) + sumMean += _realFFTDataPoints[number]; + else + newNumDataPoints--; + } + + if (newNumDataPoints == 0) // in the odd case that all + _noiseFloorAmplitude = meanAmplitude; // amplitudes are equal! + else + _noiseFloorAmplitude = sumMean / newNumDataPoints; + } + + if(lastOfMultipleUpdatesFlag){ + int tabindex = SpectrumTypeTab->currentIndex(); + if(tabindex == d_plot_fft) { + _frequencyDisplayPlot->PlotNewData(_averagedValues, numFFTDataPoints, + _noiseFloorAmplitude, _peakFrequency, + _peakAmplitude, d_update_time); + } + if(tabindex == d_plot_time) { + _timeDomainDisplayPlot->PlotNewData(realTimeDomainDataPoints, + imagTimeDomainDataPoints, + numTimeDomainDataPoints, + d_update_time); + } + if(tabindex == d_plot_constellation) { + _constellationDisplayPlot->PlotNewData(realTimeDomainDataPoints, + imagTimeDomainDataPoints, + numTimeDomainDataPoints, + d_update_time); + } + + // Don't update the repeated data for the waterfall + if(!repeatDataFlag){ + if(tabindex == d_plot_waterfall) { + _waterfallDisplayPlot->PlotNewData(_realFFTDataPoints, numFFTDataPoints, + d_update_time, dataTimestamp, + spectrumUpdateEvent->getDroppedFFTFrames()); + } + } + + + // Tell the system the GUI has been updated + if(_systemSpecifiedFlag){ + _system->SetLastGUIUpdateTime(generatedTimestamp); + _system->DecrementPendingGUIUpdateEvents(); + } + } +} + +void +SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) +{ + QSize s; + s.setWidth(FrequencyPlotDisplayFrame->width()); + s.setHeight(FrequencyPlotDisplayFrame->height()); + emit _frequencyDisplayPlot->resizeSlot(&s); + + s.setWidth(TimeDomainDisplayFrame->width()); + s.setHeight(TimeDomainDisplayFrame->height()); + emit _timeDomainDisplayPlot->resizeSlot(&s); + + s.setWidth(WaterfallPlotDisplayFrame->width()); + s.setHeight(WaterfallPlotDisplayFrame->height()); + emit _waterfallDisplayPlot->resizeSlot(&s); + + s.setWidth(ConstellationDisplayFrame->width()); + s.setHeight(ConstellationDisplayFrame->height()); + emit _constellationDisplayPlot->resizeSlot(&s); +} + +void +SpectrumDisplayForm::customEvent( QEvent * e) +{ + if(e->type() == QEvent::User+3){ + if(_systemSpecifiedFlag){ + WindowComboBox->setCurrentIndex(_system->GetWindowType()); + FFTSizeComboBox->setCurrentIndex(_system->GetFFTSizeIndex()); + //FFTSizeComboBox->setCurrentIndex(1); + } + + waterfallMinimumIntensityChangedCB(WaterfallMinimumIntensityWheel->value()); + waterfallMaximumIntensityChangedCB(WaterfallMaximumIntensityWheel->value()); + + // Clear any previous display + Reset(); + } + else if(e->type() == 10005){ + SpectrumUpdateEvent* spectrumUpdateEvent = (SpectrumUpdateEvent*)e; + newFrequencyData(spectrumUpdateEvent); + } + else if(e->type() == 10008){ + setWindowTitle(((SpectrumWindowCaptionEvent*)e)->getLabel()); + } + else if(e->type() == 10009){ + Reset(); + if(_systemSpecifiedFlag){ + _system->ResetPendingGUIUpdateEvents(); + } + } + else if(e->type() == 10010){ + _startFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetStartFrequency(); + _stopFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetStopFrequency(); + _centerFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetCenterFrequency(); + + UseRFFrequenciesCB(UseRFFrequenciesCheckBox->isChecked()); + } +} + +void +SpectrumDisplayForm::UpdateGuiTimer() +{ + // This is called by the displayTimer and redraws the canvases of + // all of the plots. + _frequencyDisplayPlot->canvas()->update(); + _waterfallDisplayPlot->canvas()->update(); + _timeDomainDisplayPlot->canvas()->update(); + _constellationDisplayPlot->canvas()->update(); +} + + +void +SpectrumDisplayForm::AvgLineEdit_valueChanged( int value ) +{ + SetAverageCount(value); +} + + +void +SpectrumDisplayForm::MaxHoldCheckBox_toggled( bool newState ) +{ + MaxHoldResetBtn->setEnabled(newState); + _frequencyDisplayPlot->SetMaxFFTVisible(newState); + MaxHoldResetBtn_clicked(); +} + + +void +SpectrumDisplayForm::MinHoldCheckBox_toggled( bool newState ) +{ + MinHoldResetBtn->setEnabled(newState); + _frequencyDisplayPlot->SetMinFFTVisible(newState); + MinHoldResetBtn_clicked(); +} + + +void +SpectrumDisplayForm::MinHoldResetBtn_clicked() +{ + _frequencyDisplayPlot->ClearMinData(); + _frequencyDisplayPlot->replot(); +} + + +void +SpectrumDisplayForm::MaxHoldResetBtn_clicked() +{ + _frequencyDisplayPlot->ClearMaxData(); + _frequencyDisplayPlot->replot(); +} + + +void +SpectrumDisplayForm::TabChanged(int index) +{ + // This might be dangerous to call this with NULL + resizeEvent(NULL); +} + +void +SpectrumDisplayForm::SetFrequencyRange(const double newCenterFrequency, + const double newStartFrequency, + const double newStopFrequency) +{ + double fdiff; + if(UseRFFrequenciesCheckBox->isChecked()) { + fdiff = newCenterFrequency; + } + else { + fdiff = std::max(fabs(newStartFrequency), fabs(newStopFrequency)); + } + + if(fdiff > 0) { + std::string strunits[4] = {"Hz", "kHz", "MHz", "GHz"}; + std::string strtime[4] = {"sec", "ms", "us", "ns"}; + double units10 = floor(log10(fdiff)); + double units3 = std::max(floor(units10 / 3.0), 0.0); + double units = pow(10, (units10-fmod(units10, 3.0))); + int iunit = static_cast(units3); + + _startFrequency = newStartFrequency; + _stopFrequency = newStopFrequency; + _centerFrequency = newCenterFrequency; + + _frequencyDisplayPlot->SetFrequencyRange(_startFrequency, + _stopFrequency, + _centerFrequency, + UseRFFrequenciesCheckBox->isChecked(), + units, strunits[iunit]); + _waterfallDisplayPlot->SetFrequencyRange(_startFrequency, + _stopFrequency, + _centerFrequency, + UseRFFrequenciesCheckBox->isChecked(), + units, strunits[iunit]); + _timeDomainDisplayPlot->SetSampleRate(_stopFrequency - _startFrequency, + units, strtime[iunit]); + } +} + +int +SpectrumDisplayForm::GetAverageCount() +{ + return _historyVector->size(); +} + +void +SpectrumDisplayForm::SetAverageCount(const int newCount) +{ + if(newCount > -1){ + if(newCount != static_cast(_historyVector->size())){ + std::vector::iterator pos; + while(newCount < static_cast(_historyVector->size())){ + pos = _historyVector->begin(); + delete[] (*pos); + _historyVector->erase(pos); + } + + while(newCount > static_cast(_historyVector->size())){ + _historyVector->push_back(new double[_numRealDataPoints]); + } + AverageDataReset(); + } + } +} + +void +SpectrumDisplayForm::_AverageHistory(const double* newBuffer) +{ + if(_numRealDataPoints > 0){ + if(_historyVector->size() > 0){ + memcpy(_historyVector->operator[](_historyEntry), newBuffer, + _numRealDataPoints*sizeof(double)); + + // Increment the next location to store data + _historyEntryCount++; + if(_historyEntryCount > static_cast(_historyVector->size())){ + _historyEntryCount = _historyVector->size(); + } + _historyEntry = (++_historyEntry)%_historyVector->size(); + + // Total up and then average the values + double sum; + for(uint64_t location = 0; location < _numRealDataPoints; location++){ + sum = 0; + for(int number = 0; number < _historyEntryCount; number++){ + sum += _historyVector->operator[](number)[location]; + } + _averagedValues[location] = sum/static_cast(_historyEntryCount); + } + } + else{ + memcpy(_averagedValues, newBuffer, _numRealDataPoints*sizeof(double)); + } + } +} + +void +SpectrumDisplayForm::ResizeBuffers( const uint64_t numFFTDataPoints, + const uint64_t /*numTimeDomainDataPoints*/ ) +{ + // Convert from Complex to Real for certain Displays + if(_numRealDataPoints != numFFTDataPoints){ + _numRealDataPoints = numFFTDataPoints; + delete[] _realFFTDataPoints; + delete[] _averagedValues; + + _realFFTDataPoints = new double[_numRealDataPoints]; + _averagedValues = new double[_numRealDataPoints]; + memset(_realFFTDataPoints, 0x0, _numRealDataPoints*sizeof(double)); + + const int historySize = _historyVector->size(); + SetAverageCount(0); // Clear the existing history + SetAverageCount(historySize); + + Reset(); + } +} + +void +SpectrumDisplayForm::Reset() +{ + AverageDataReset(); + + _waterfallDisplayPlot->Reset(); +} + + +void +SpectrumDisplayForm::AverageDataReset() +{ + _historyEntry = 0; + _historyEntryCount = 0; + + memset(_averagedValues, 0x0, _numRealDataPoints*sizeof(double)); + + MaxHoldResetBtn_clicked(); + MinHoldResetBtn_clicked(); +} + + +void +SpectrumDisplayForm::closeEvent( QCloseEvent *e ) +{ + if(_systemSpecifiedFlag){ + _system->SetWindowOpenFlag(false); + } + + qApp->processEvents(); + + QWidget::closeEvent(e); +} + + +void +SpectrumDisplayForm::WindowTypeChanged( int newItem ) +{ + if(_systemSpecifiedFlag){ + _system->SetWindowType(newItem); + } +} + + +void +SpectrumDisplayForm::UseRFFrequenciesCB( bool useRFFlag ) +{ + SetFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency); +} + + +void +SpectrumDisplayForm::waterfallMaximumIntensityChangedCB( double newValue ) +{ + if(newValue > WaterfallMinimumIntensityWheel->value()){ + WaterfallMaximumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); + } + else{ + WaterfallMaximumIntensityWheel->setValue(WaterfallMinimumIntensityWheel->value()); + } + + _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(), + WaterfallMaximumIntensityWheel->value()); +} + + +void +SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue ) +{ + if(newValue < WaterfallMaximumIntensityWheel->value()){ + WaterfallMinimumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); + } + else{ + WaterfallMinimumIntensityWheel->setValue(WaterfallMaximumIntensityWheel->value()); + } + + _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(), + WaterfallMaximumIntensityWheel->value()); +} + +void +SpectrumDisplayForm::FFTComboBoxSelectedCB( const QString &fftSizeString ) +{ + if(_systemSpecifiedFlag){ + _system->SetFFTSize(fftSizeString.toLong()); + } +} + + +void +SpectrumDisplayForm::WaterfallAutoScaleBtnCB() +{ + double minimumIntensity = _noiseFloorAmplitude - 5; + if(minimumIntensity < WaterfallMinimumIntensityWheel->minValue()){ + minimumIntensity = WaterfallMinimumIntensityWheel->minValue(); + } + WaterfallMinimumIntensityWheel->setValue(minimumIntensity); + double maximumIntensity = _peakAmplitude + 10; + if(maximumIntensity > WaterfallMaximumIntensityWheel->maxValue()){ + maximumIntensity = WaterfallMaximumIntensityWheel->maxValue(); + } + WaterfallMaximumIntensityWheel->setValue(maximumIntensity); + waterfallMaximumIntensityChangedCB(maximumIntensity); +} + +void +SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType ) +{ + QColor lowIntensityColor; + QColor highIntensityColor; + if(newType == WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_USER_DEFINED){ + // Select the Low Intensity Color + lowIntensityColor = _waterfallDisplayPlot->GetUserDefinedLowIntensityColor(); + if(!lowIntensityColor.isValid()){ + lowIntensityColor = Qt::black; + } + QMessageBox::information(this, "Low Intensity Color Selection", "In the next window, select the low intensity color for the waterfall display", QMessageBox::Ok); + lowIntensityColor = QColorDialog::getColor(lowIntensityColor, this); + + // Select the High Intensity Color + highIntensityColor = _waterfallDisplayPlot->GetUserDefinedHighIntensityColor(); + if(!highIntensityColor.isValid()){ + highIntensityColor = Qt::white; + } + QMessageBox::information(this, "High Intensity Color Selection", "In the next window, select the high intensity color for the waterfall display", QMessageBox::Ok); + highIntensityColor = QColorDialog::getColor(highIntensityColor, this); + } + + _waterfallDisplayPlot->SetIntensityColorMapType(newType, lowIntensityColor, highIntensityColor); +} + +void +SpectrumDisplayForm::ToggleTabFrequency(const bool state) +{ + if(state == true) { + if(d_plot_fft == -1) { + SpectrumTypeTab->addTab(FrequencyPage, "Frequency Display"); + d_plot_fft = SpectrumTypeTab->count()-1; + } + } + else { + SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(FrequencyPage)); + d_plot_fft = -1; + } +} + +void +SpectrumDisplayForm::ToggleTabWaterfall(const bool state) +{ + if(state == true) { + if(d_plot_waterfall == -1) { + SpectrumTypeTab->addTab(WaterfallPage, "Waterfall Display"); + d_plot_waterfall = SpectrumTypeTab->count()-1; + } + } + else { + SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(WaterfallPage)); + d_plot_waterfall = -1; + } +} + +void +SpectrumDisplayForm::ToggleTabTime(const bool state) +{ + if(state == true) { + if(d_plot_time == -1) { + SpectrumTypeTab->addTab(TimeDomainPage, "Time Domain Display"); + d_plot_time = SpectrumTypeTab->count()-1; + } + } + else { + SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(TimeDomainPage)); + d_plot_time = -1; + } +} + +void +SpectrumDisplayForm::ToggleTabConstellation(const bool state) +{ + if(state == true) { + if(d_plot_constellation == -1) { + SpectrumTypeTab->addTab(ConstellationPage, "Constellation Display"); + d_plot_constellation = SpectrumTypeTab->count()-1; + } + } + else { + SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(ConstellationPage)); + d_plot_constellation = -1; + } +} + + +void +SpectrumDisplayForm::SetTimeDomainAxis(double min, double max) +{ + _timeDomainDisplayPlot->set_yaxis(min, max); +} + +void +SpectrumDisplayForm::SetConstellationAxis(double xmin, double xmax, + double ymin, double ymax) +{ + _constellationDisplayPlot->set_axis(xmin, xmax, ymin, ymax); +} + +void +SpectrumDisplayForm::SetConstellationPenSize(int size) +{ + _constellationDisplayPlot->set_pen_size( size ); +} + +void +SpectrumDisplayForm::SetFrequencyAxis(double min, double max) +{ + _frequencyDisplayPlot->set_yaxis(min, max); +} + +void +SpectrumDisplayForm::SetUpdateTime(double t) +{ + d_update_time = t; + // QTimer class takes millisecond input + displayTimer->start(d_update_time*1000); +} diff --git a/gr-qtgui/lib/spectrumdisplayform.h b/gr-qtgui/lib/spectrumdisplayform.h new file mode 100644 index 000000000..fbd08349b --- /dev/null +++ b/gr-qtgui/lib/spectrumdisplayform.h @@ -0,0 +1,114 @@ +#ifndef SPECTRUM_DISPLAY_FORM_H +#define SPECTRUM_DISPLAY_FORM_H + +#include "spectrumdisplayform.ui.h" + +class SpectrumGUIClass; +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +class SpectrumDisplayForm : public QWidget, public Ui::SpectrumDisplayForm +{ + Q_OBJECT + + public: + SpectrumDisplayForm(bool useOpenGL = true, 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(); + +protected: + +private: + void _AverageHistory( const double * newBuffer ); + + bool _useOpenGL; + int _historyEntryCount; + int _historyEntry; + std::vector* _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; + static int _openGLWaterfall3DFlag; + double _stopFrequency; + + //SpectrumUpdateEvent _lastSpectrumEvent; + + // whether or not to use a particular display + int d_plot_fft; + int d_plot_waterfall; + int d_plot_waterfall3d; + int d_plot_time; + int d_plot_constellation; + + QTimer *displayTimer; + double d_update_time; +}; + +#endif /* SPECTRUM_DISPLAY_FORM_H */ diff --git a/gr-qtgui/lib/spectrumdisplayform.ui b/gr-qtgui/lib/spectrumdisplayform.ui new file mode 100644 index 000000000..5a23bc8a9 --- /dev/null +++ b/gr-qtgui/lib/spectrumdisplayform.ui @@ -0,0 +1,788 @@ + + + SpectrumDisplayForm + + + + 0 + 0 + 712 + 543 + + + + Spectrum Display + + + + + + + 0 + 0 + + + + + 120 + 16777215 + + + + + 1024 + + + + + 2048 + + + + + 4096 + + + + + 8192 + + + + + 16384 + + + + + 32768 + + + + + + + + FFT Size: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + Display RF Frequencies + + + + + + + + + + 0 + 0 + + + + Window: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + 0 + 0 + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + + 9 + + + + + Hamming + + + + + Hann + + + + + Blackman + + + + + Rectangular + + + + + Kaiser + + + + + Blackman-harris + + + + + + + + + + 0 + + + + Frequency Display + + + + + + + + + 0 + 0 + + + + + 400 + 350 + + + + + 1 + 1 + + + + QFrame::NoFrame + + + QFrame::Plain + + + + + + + + + Max Hold + + + false + + + + + + + Min Hold + + + false + + + + + + + + 0 + 0 + + + + + 25 + 0 + + + + Reset + + + + + + + + 0 + 0 + + + + + 62 + 0 + + + + Average + + + Qt::AlignCenter + + + false + + + + + + + Reset + + + + + + + + + + Qt::Horizontal + + + + 200 + 20 + + + + + + + + + + + + + Waterfall Display + + + + + + + 100 + 16777215 + + + + Intensity Display: + + + false + + + + + + + + 200 + 0 + + + + true + + + Qt::WheelFocus + + + true + + + 200.000000000000000 + + + 20.000000000000000 + + + 0.000000000000000 + + + + + + + + 100 + 16777215 + + + + 100 dB + + + false + + + + + + + + 617 + 338 + + + + QFrame::NoFrame + + + QFrame::Plain + + + + + + + + 200 + 0 + + + + true + + + 200.000000000000000 + + + 20.000000000000000 + + + 0.000000000000000 + + + + + + + + 100 + 16777215 + + + + -100 dB + + + false + + + + + + + + 80 + 16777215 + + + + Scales the Intensity to the current data extremes. + + + Auto Scale + + + + + + + + 100 + 16777215 + + + + + Color + + + + + White Hot + + + + + Black Hot + + + + + Incandescent + + + + + User Defined + + + + + + + + + Time Domain Display + + + + + + + 617 + 404 + + + + QFrame::NoFrame + + + QFrame::Plain + + + + + + + + Constellation Display + + + + + + + 617 + 406 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + qPixmapFromMimeSource + + + QwtWheel + QWidget +
qwt_wheel.h
+
+
+ + SpectrumTypeTab + UseRFFrequenciesCheckBox + FFTSizeComboBox + WaterfallMaximumIntensityWheel + WaterfallMinimumIntensityWheel + + + SpectrumGUIClass.h + FrequencyDisplayPlot.h + WaterfallDisplayPlot.h + TimeDomainDisplayPlot.h + qvalidator.h + vector + qwt_wheel.h + + + + + MaxHoldCheckBox + toggled(bool) + SpectrumDisplayForm + MaxHoldCheckBox_toggled(bool) + + + 22 + 324 + + + 20 + 20 + + + + + MaxHoldResetBtn + clicked() + SpectrumDisplayForm + MaxHoldResetBtn_clicked() + + + 107 + 324 + + + 20 + 20 + + + + + MinHoldCheckBox + toggled(bool) + SpectrumDisplayForm + MinHoldCheckBox_toggled(bool) + + + 22 + 349 + + + 20 + 20 + + + + + MinHoldResetBtn + clicked() + SpectrumDisplayForm + MinHoldResetBtn_clicked() + + + 107 + 349 + + + 20 + 20 + + + + + WindowComboBox + activated(int) + SpectrumDisplayForm + WindowTypeChanged(int) + + + 20 + 20 + + + 20 + 20 + + + + + UseRFFrequenciesCheckBox + toggled(bool) + SpectrumDisplayForm + UseRFFrequenciesCB(bool) + + + 20 + 20 + + + 20 + 20 + + + + + WaterfallMaximumIntensityWheel + valueChanged(double) + SpectrumDisplayForm + waterfallMaximumIntensityChangedCB(double) + + + 217 + 44 + + + 20 + 20 + + + + + WaterfallMinimumIntensityWheel + valueChanged(double) + SpectrumDisplayForm + waterfallMinimumIntensityChangedCB(double) + + + 217 + 349 + + + 20 + 20 + + + + + FFTSizeComboBox + activated(QString) + SpectrumDisplayForm + FFTComboBoxSelectedCB(QString) + + + 20 + 20 + + + 20 + 20 + + + + + WaterfallAutoScaleBtn + clicked() + SpectrumDisplayForm + WaterfallAutoScaleBtnCB() + + + 22 + 349 + + + 20 + 20 + + + + + Waterfall3DAutoScaleBtn + clicked() + SpectrumDisplayForm + Waterfall3DAutoScaleBtnCB() + + + 22 + 349 + + + 20 + 20 + + + + + WaterfallIntensityComboBox + activated(int) + SpectrumDisplayForm + WaterfallIntensityColorTypeChanged(int) + + + 92 + 44 + + + 20 + 20 + + + + + Waterfall3DIntensityComboBox + activated(int) + SpectrumDisplayForm + Waterfall3DIntensityColorTypeChanged(int) + + + 92 + 44 + + + 20 + 20 + + + + + SpectrumTypeTab + currentChanged(int) + SpectrumDisplayForm + TabChanged(int) + + + 314 + 189 + + + 316 + 217 + + + + + AvgLineEdit + valueChanged(int) + SpectrumDisplayForm + AvgLineEdit_valueChanged(int) + + + 604 + 421 + + + 328 + 260 + + + + +
diff --git a/gr-qtgui/lib/waterfallGlobalData.cc b/gr-qtgui/lib/waterfallGlobalData.cc new file mode 100644 index 000000000..1ba153f0d --- /dev/null +++ b/gr-qtgui/lib/waterfallGlobalData.cc @@ -0,0 +1,164 @@ +#ifndef WATERFALL_GLOBAL_DATA_CPP +#define WATERFALL_GLOBAL_DATA_CPP + +#include + +WaterfallData::WaterfallData(const double minimumFrequency, + const double maximumFrequency, + const uint64_t fftPoints, + const unsigned int historyExtent) + : QwtRasterData(QwtDoubleRect(minimumFrequency /* X START */, 0 /* Y START */, + maximumFrequency - minimumFrequency /* WIDTH */, + static_cast(historyExtent)/* HEIGHT */)) +{ + _intensityRange = QwtDoubleInterval(-200.0, 0.0); + + _fftPoints = fftPoints; + _historyLength = historyExtent; + + _spectrumData = new double[_fftPoints * _historyLength]; + + Reset(); +} + +WaterfallData::~WaterfallData() +{ + delete[] _spectrumData; +} + +void WaterfallData::Reset() +{ + memset(_spectrumData, 0x0, _fftPoints*_historyLength*sizeof(double)); + + _numLinesToUpdate = -1; +} + +void WaterfallData::Copy(const WaterfallData* rhs) +{ + if((_fftPoints != rhs->GetNumFFTPoints()) || + (boundingRect() != rhs->boundingRect()) ){ + _fftPoints = rhs->GetNumFFTPoints(); + setBoundingRect(rhs->boundingRect()); + delete[] _spectrumData; + _spectrumData = new double[_fftPoints * _historyLength]; + } + Reset(); + SetSpectrumDataBuffer(rhs->GetSpectrumDataBuffer()); + SetNumLinesToUpdate(rhs->GetNumLinesToUpdate()); + setRange(rhs->range()); +} + +void WaterfallData::ResizeData(const double startFreq, + const double stopFreq, + const uint64_t fftPoints) +{ + if((fftPoints != GetNumFFTPoints()) || + (boundingRect().width() != (stopFreq - startFreq)) || + (boundingRect().left() != startFreq)){ + + setBoundingRect(QwtDoubleRect(startFreq, 0, stopFreq-startFreq, boundingRect().height())); + _fftPoints = fftPoints; + delete[] _spectrumData; + _spectrumData = new double[_fftPoints * _historyLength]; + } + + Reset(); +} + +QwtRasterData *WaterfallData::copy() const +{ + WaterfallData* returnData = new WaterfallData(boundingRect().left(), + boundingRect().right(), + _fftPoints, _historyLength); + returnData->Copy(this); + return returnData; +} + +QwtDoubleInterval WaterfallData::range() const +{ + return _intensityRange; +} + +void WaterfallData::setRange(const QwtDoubleInterval& newRange) +{ + _intensityRange = newRange; +} + +double WaterfallData::value(double x, double y) const +{ + double returnValue = 0.0; + + const unsigned int intY = static_cast((1.0 - (y/boundingRect().height())) * + static_cast(_historyLength - 1)); + const unsigned int intX = static_cast((((x - boundingRect().left()) / boundingRect().width()) * + static_cast(_fftPoints-1)) + 0.5); + + const int location = (intY * _fftPoints) + intX; + if((location > -1) && (location < static_cast(_fftPoints * _historyLength))){ + returnValue = _spectrumData[location]; + } + + return returnValue; +} + +uint64_t WaterfallData::GetNumFFTPoints() const +{ + return _fftPoints; +} + +void WaterfallData::addFFTData(const double* fftData, + const uint64_t fftDataSize, + const int droppedFrames){ + if(fftDataSize == _fftPoints){ + int64_t heightOffset = _historyLength - 1 - droppedFrames; + uint64_t drawingDroppedFrames = droppedFrames; + + // Any valid data rolled off the display so just fill in zeros and write new data + if(heightOffset < 0){ + heightOffset = 0; + drawingDroppedFrames = static_cast(_historyLength-1); + } + + // Copy the old data over if any available + if(heightOffset > 0){ + memmove( _spectrumData, &_spectrumData[(drawingDroppedFrames+1) * _fftPoints], + heightOffset * _fftPoints * sizeof(double)) ; + } + + if(drawingDroppedFrames > 0){ + // Fill in zeros data for dropped data + memset(&_spectrumData[heightOffset * _fftPoints], 0x00, + static_cast(drawingDroppedFrames) * _fftPoints * sizeof(double)); + } + + // add the new buffer + memcpy(&_spectrumData[(_historyLength - 1) * _fftPoints], fftData, _fftPoints*sizeof(double)); + } +} + +double* WaterfallData::GetSpectrumDataBuffer() const +{ + return _spectrumData; +} + +void WaterfallData::SetSpectrumDataBuffer(const double* newData) +{ + memcpy(_spectrumData, newData, _fftPoints * _historyLength * sizeof(double)); +} + +int WaterfallData::GetNumLinesToUpdate() const +{ + return _numLinesToUpdate; +} + +void WaterfallData::SetNumLinesToUpdate(const int newNum) +{ + _numLinesToUpdate = newNum; +} + +void WaterfallData::IncrementNumLinesToUpdate() +{ + _numLinesToUpdate++; +} + +#endif /* WATERFALL_GLOBAL_DATA_CPP */ diff --git a/gr-qtgui/lib/waterfallGlobalData.h b/gr-qtgui/lib/waterfallGlobalData.h new file mode 100644 index 000000000..51f65064c --- /dev/null +++ b/gr-qtgui/lib/waterfallGlobalData.h @@ -0,0 +1,47 @@ +#ifndef WATERFALL_GLOBAL_DATA_HPP +#define WATERFALL_GLOBAL_DATA_HPP + +#include +#include + + +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; + virtual QwtDoubleInterval range() const; + virtual void setRange(const QwtDoubleInterval&); + + 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; + QwtDoubleInterval _intensityRange; + +private: + +}; + +#endif /* WATERFALL_GLOBAL_DATA_HPP */ diff --git a/gr-qtgui/src/lib/ConstellationDisplayPlot.cc b/gr-qtgui/src/lib/ConstellationDisplayPlot.cc deleted file mode 100644 index 9ad5bdd3c..000000000 --- a/gr-qtgui/src/lib/ConstellationDisplayPlot.cc +++ /dev/null @@ -1,193 +0,0 @@ -#ifndef CONSTELLATION_DISPLAY_PLOT_C -#define CONSTELLATION_DISPLAY_PLOT_C - -#include - -#include -#include - - -class ConstellationDisplayZoomer: public QwtPlotZoomer -{ -public: - ConstellationDisplayZoomer(QwtPlotCanvas* canvas):QwtPlotZoomer(canvas) - { - setTrackerMode(QwtPicker::AlwaysOn); - } - - virtual ~ConstellationDisplayZoomer(){ - - } - - virtual void updateTrackerText(){ - updateDisplay(); - } - -protected: - using QwtPlotZoomer::trackerText; - virtual QwtText trackerText( const QwtDoublePoint& p ) const - { - QwtText t(QString("(%1, %2)").arg(p.x(), 0, 'f', 4). - arg(p.y(), 0, 'f', 4)); - return t; - } -}; - -ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent) - : QwtPlot(parent) -{ - timespec_reset(&_lastReplot); - - resize(parent->width(), parent->height()); - - _numPoints = 1024; - _penSize = 5; - _realDataPoints = new double[_numPoints]; - _imagDataPoints = new double[_numPoints]; - - // Disable polygon clipping - QwtPainter::setDeviceClipping(false); - - // We don't need the cache here - canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); - canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); - - QPalette palette; - palette.setColor(canvas()->backgroundRole(), QColor("white")); - canvas()->setPalette(palette); - - setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine); - set_xaxis(-2.0, 2.0); - setAxisTitle(QwtPlot::xBottom, "In-phase"); - - setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine); - set_yaxis(-2.0, 2.0); - setAxisTitle(QwtPlot::yLeft, "Quadrature"); - - // Automatically deleted when parent is deleted - _plot_curve = new QwtPlotCurve("Constellation Points"); - _plot_curve->attach(this); - _plot_curve->setPen(QPen(Qt::blue, _penSize, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - _plot_curve->setStyle(QwtPlotCurve::Dots); - _plot_curve->setRawData(_realDataPoints, _imagDataPoints, _numPoints); - - memset(_realDataPoints, 0x0, _numPoints*sizeof(double)); - memset(_imagDataPoints, 0x0, _numPoints*sizeof(double)); - - replot(); - - _zoomer = new ConstellationDisplayZoomer(canvas()); -#if QT_VERSION < 0x040000 - _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); -#else - _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); -#endif - _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, - Qt::RightButton); - - _panner = new QwtPlotPanner(canvas()); - _panner->setAxisEnabled(QwtPlot::yRight, false); - _panner->setMouseButton(Qt::MidButton); - - // Avoid jumping when labels with more/less digits - // appear/disappear when scrolling vertically - - const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); - QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); - sd->setMinimumExtent( fm.width("100.00") ); - - const QColor c(Qt::darkRed); - _zoomer->setRubberBandPen(c); - _zoomer->setTrackerPen(c); - - connect(this, SIGNAL( legendChecked(QwtPlotItem *, bool ) ), - this, SLOT( LegendEntryChecked(QwtPlotItem *, bool ) )); -} - -ConstellationDisplayPlot::~ConstellationDisplayPlot() -{ - delete[] _realDataPoints; - delete[] _imagDataPoints; - - // _fft_plot_curves deleted when parent deleted - // _zoomer and _panner deleted when parent deleted -} - -void -ConstellationDisplayPlot::set_pen_size(int size) -{ - if(size > 0 && size < 30){ - _penSize = size; - _plot_curve->setPen(QPen(Qt::blue, _penSize, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - } -} - - -void -ConstellationDisplayPlot::set_xaxis(double min, double max) -{ - setAxisScale(QwtPlot::xBottom, min, max); -} - -void -ConstellationDisplayPlot::set_yaxis(double min, double max) -{ - setAxisScale(QwtPlot::yLeft, min, max); -} - -void -ConstellationDisplayPlot::set_axis(double xmin, double xmax, - double ymin, double ymax) -{ - set_xaxis(xmin, xmax); - set_yaxis(ymin, ymax); -} - -void ConstellationDisplayPlot::replot() -{ - QwtPlot::replot(); -} - -void -ConstellationDisplayPlot::resizeSlot( QSize *s ) -{ - resize(s->width(), s->height()); -} - -void ConstellationDisplayPlot::PlotNewData(const double* realDataPoints, - const double* imagDataPoints, - const int64_t numDataPoints, - const double timeInterval) -{ - if((numDataPoints > 0) && - (diff_timespec(get_highres_clock(), _lastReplot) > timeInterval)) { - - if(numDataPoints != _numPoints){ - _numPoints = numDataPoints; - - delete[] _realDataPoints; - delete[] _imagDataPoints; - _realDataPoints = new double[_numPoints]; - _imagDataPoints = new double[_numPoints]; - - _plot_curve->setRawData(_realDataPoints, _imagDataPoints, _numPoints); - } - - memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double)); - memcpy(_imagDataPoints, imagDataPoints, numDataPoints*sizeof(double)); - - replot(); - - _lastReplot = get_highres_clock(); - } -} - -void -ConstellationDisplayPlot::LegendEntryChecked(QwtPlotItem* plotItem, bool on) -{ - plotItem->setVisible(!on); -} - -#endif /* CONSTELLATION_DISPLAY_PLOT_C */ diff --git a/gr-qtgui/src/lib/ConstellationDisplayPlot.h b/gr-qtgui/src/lib/ConstellationDisplayPlot.h deleted file mode 100644 index a441a8bfe..000000000 --- a/gr-qtgui/src/lib/ConstellationDisplayPlot.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef CONSTELLATION_DISPLAY_PLOT_HPP -#define CONSTELLATION_DISPLAY_PLOT_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class ConstellationDisplayPlot : public QwtPlot -{ - Q_OBJECT - -public: - ConstellationDisplayPlot(QWidget*); - virtual ~ConstellationDisplayPlot(); - - void PlotNewData(const double* realDataPoints, - const double* imagDataPoints, - const int64_t numDataPoints, - const double timeInterval); - - virtual 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 resizeSlot( QSize *s ); - -protected slots: - void LegendEntryChecked(QwtPlotItem *plotItem, bool on); - -protected: - -private: - QwtPlotCurve* _plot_curve; - - QwtPlotPanner* _panner; - QwtPlotZoomer* _zoomer; - - double* _realDataPoints; - double* _imagDataPoints; - - timespec _lastReplot; - - int64_t _numPoints; - int64_t _penSize; -}; - -#endif /* CONSTELLATION_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/src/lib/FrequencyDisplayPlot.cc b/gr-qtgui/src/lib/FrequencyDisplayPlot.cc deleted file mode 100644 index d150e2e4c..000000000 --- a/gr-qtgui/src/lib/FrequencyDisplayPlot.cc +++ /dev/null @@ -1,439 +0,0 @@ -#ifndef FREQUENCY_DISPLAY_PLOT_C -#define FREQUENCY_DISPLAY_PLOT_C - -#include - -#include - -class FreqPrecisionClass -{ -public: - FreqPrecisionClass(const int freqPrecision) - { - _frequencyPrecision = freqPrecision; - } - - virtual ~FreqPrecisionClass() - { - } - - virtual unsigned int GetFrequencyPrecision() const - { - return _frequencyPrecision; - } - - virtual void SetFrequencyPrecision(const unsigned int newPrecision) - { - _frequencyPrecision = newPrecision; - } -protected: - unsigned int _frequencyPrecision; - -private: - -}; - -class FreqDisplayScaleDraw: public QwtScaleDraw, public FreqPrecisionClass -{ -public: - FreqDisplayScaleDraw(const unsigned int precision) - : QwtScaleDraw(), FreqPrecisionClass(precision) - { - } - - virtual ~FreqDisplayScaleDraw() - { - } - - virtual QwtText label(double value) const - { - return QString("%1").arg(value, 0, 'f', GetFrequencyPrecision()); - } - -protected: - -private: - -}; - -class FreqDisplayZoomer: public QwtPlotZoomer, public FreqPrecisionClass -{ -public: - FreqDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision) - : QwtPlotZoomer(canvas),FreqPrecisionClass(freqPrecision) - { - setTrackerMode(QwtPicker::AlwaysOn); - } - - virtual ~FreqDisplayZoomer(){ - - } - - virtual void updateTrackerText(){ - updateDisplay(); - } - - void SetUnitType(const std::string &type) - { - _unitType = type; - } - -protected: - using QwtPlotZoomer::trackerText; - virtual QwtText trackerText( const QwtDoublePoint& p ) const - { - QwtText t(QString("%1 %2, %3 dB"). - arg(p.x(), 0, 'f', GetFrequencyPrecision()). - arg(_unitType.c_str()).arg(p.y(), 0, 'f', 2)); - return t; - } - -private: - std::string _unitType; -}; - -FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent) - : QwtPlot(parent) -{ - _startFrequency = 0; - _stopFrequency = 4000; - - timespec_reset(&_lastReplot); - - resize(parent->width(), parent->height()); - - _useCenterFrequencyFlag = false; - - _numPoints = 1024; - _dataPoints = new double[_numPoints]; - _minFFTPoints = new double[_numPoints]; - _maxFFTPoints = new double[_numPoints]; - _xAxisPoints = new double[_numPoints]; - - // Disable polygon clipping - QwtPainter::setDeviceClipping(false); - - // We don't need the cache here - canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); - canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); - - QPalette palette; - palette.setColor(canvas()->backgroundRole(), QColor("white")); - canvas()->setPalette(palette); - - setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)"); - setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0)); - - _minYAxis = -120; - _maxYAxis = 10; - setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine); - setAxisScale(QwtPlot::yLeft, _minYAxis, _maxYAxis); - setAxisTitle(QwtPlot::yLeft, "Power (dB)"); - - // Automatically deleted when parent is deleted - _fft_plot_curve = new QwtPlotCurve("Power Spectrum"); - _fft_plot_curve->attach(this); - _fft_plot_curve->setPen(QPen(Qt::blue)); - _fft_plot_curve->setRawData(_xAxisPoints, _dataPoints, _numPoints); - - _min_fft_plot_curve = new QwtPlotCurve("Minimum Power"); - _min_fft_plot_curve->attach(this); - _min_fft_plot_curve->setPen(QPen(Qt::magenta)); - _min_fft_plot_curve->setRawData(_xAxisPoints, _minFFTPoints, _numPoints); - _min_fft_plot_curve->setVisible(false); - - _max_fft_plot_curve = new QwtPlotCurve("Maximum Power"); - _max_fft_plot_curve->attach(this); - _max_fft_plot_curve->setPen(QPen(Qt::darkYellow)); - _max_fft_plot_curve->setRawData(_xAxisPoints, _maxFFTPoints, _numPoints); - _max_fft_plot_curve->setVisible(false); - - _lower_intensity_marker = new QwtPlotMarker(); - _lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine); - _lower_intensity_marker->setLinePen(QPen(Qt::cyan)); - _lower_intensity_marker->attach(this); - - _upper_intensity_marker = new QwtPlotMarker(); - _upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine); - _upper_intensity_marker->setLinePen(QPen(Qt::green, 0, Qt::DotLine)); - _upper_intensity_marker->attach(this); - - memset(_dataPoints, 0x0, _numPoints*sizeof(double)); - memset(_xAxisPoints, 0x0, _numPoints*sizeof(double)); - - for(int64_t number = 0; number < _numPoints; number++){ - _minFFTPoints[number] = 200.0; - _maxFFTPoints[number] = -280.0; - } - - // set up peak marker - QwtSymbol symbol; - - _markerPeakAmplitude = new QwtPlotMarker(); - _markerPeakAmplitude->setLinePen(QPen(Qt::yellow)); - symbol.setStyle(QwtSymbol::Diamond); - symbol.setSize(8); - symbol.setPen(QPen(Qt::yellow)); - symbol.setBrush(QBrush(Qt::yellow)); - _markerPeakAmplitude->setSymbol(symbol); - _markerPeakAmplitude->attach(this); - - _markerNoiseFloorAmplitude = new QwtPlotMarker(); - _markerNoiseFloorAmplitude->setLineStyle(QwtPlotMarker::HLine); - _markerNoiseFloorAmplitude->setLinePen(QPen(Qt::darkRed, 0, Qt::DotLine)); - _markerNoiseFloorAmplitude->attach(this); - - _peakFrequency = 0; - _peakAmplitude = -HUGE_VAL; - - _noiseFloorAmplitude = -HUGE_VAL; - - replot(); - - _zoomer = new FreqDisplayZoomer(canvas(), 0); -#if QT_VERSION < 0x040000 - _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); -#else - _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); -#endif - _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, - Qt::RightButton); - - _panner = new QwtPlotPanner(canvas()); - _panner->setAxisEnabled(QwtPlot::yRight, false); - _panner->setMouseButton(Qt::MidButton); - - // Avoid jumping when labels with more/less digits - // appear/disappear when scrolling vertically - - const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); - QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); - sd->setMinimumExtent( fm.width("100.00") ); - - const QColor c(Qt::darkRed); - _zoomer->setRubberBandPen(c); - _zoomer->setTrackerPen(c); - - // Do this after the zoomer has been built - _resetXAxisPoints(); -} - -FrequencyDisplayPlot::~FrequencyDisplayPlot() -{ - delete[] _dataPoints; - delete[] _maxFFTPoints; - delete[] _minFFTPoints; - delete[] _xAxisPoints; - - // _fft_plot_curves deleted when parent deleted - // _zoomer and _panner deleted when parent deleted -} - -void -FrequencyDisplayPlot::set_yaxis(double min, double max) -{ - // Get the new max/min values for the plot - _minYAxis = min; - _maxYAxis = max; - - // Set the axis max/min to the new values - setAxisScale(QwtPlot::yLeft, _minYAxis, _maxYAxis); - - // Reset the base zoom level to the new axis scale set here - _zoomer->setZoomBase(); -} - -void -FrequencyDisplayPlot::SetFrequencyRange(const double constStartFreq, - const double constStopFreq, - const double constCenterFreq, - const bool useCenterFrequencyFlag, - const double units, const std::string &strunits) -{ - double startFreq = constStartFreq / units; - double stopFreq = constStopFreq / units; - double centerFreq = constCenterFreq / units; - - _useCenterFrequencyFlag = useCenterFrequencyFlag; - - if(_useCenterFrequencyFlag){ - startFreq = (startFreq + centerFreq); - stopFreq = (stopFreq + centerFreq); - } - - bool reset = false; - if((startFreq != _startFrequency) || (stopFreq != _stopFrequency)) - reset = true; - - if(stopFreq > startFreq) { - _startFrequency = startFreq; - _stopFrequency = stopFreq; - - if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){ - double display_units = ceil(log10(units)/2.0); - setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(display_units)); - setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str())); - - if(reset) - _resetXAxisPoints(); - - ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(display_units); - ((FreqDisplayZoomer*)_zoomer)->SetUnitType(strunits); - } - } -} - - -double -FrequencyDisplayPlot::GetStartFrequency() const -{ - return _startFrequency; -} - -double -FrequencyDisplayPlot::GetStopFrequency() const -{ - return _stopFrequency; -} - -void -FrequencyDisplayPlot::replot() -{ - _markerNoiseFloorAmplitude->setYValue(_noiseFloorAmplitude); - - // Make sure to take into account the start frequency - if(_useCenterFrequencyFlag){ - _markerPeakAmplitude->setXValue((_peakFrequency/1000.0) + _startFrequency); - } - else{ - _markerPeakAmplitude->setXValue(_peakFrequency + _startFrequency); - } - _markerPeakAmplitude->setYValue(_peakAmplitude); - - QwtPlot::replot(); -} - -void -FrequencyDisplayPlot::resizeSlot( QSize *s ) -{ - resize(s->width(), s->height()); -} - -void -FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDataPoints, - const double noiseFloorAmplitude, const double peakFrequency, - const double peakAmplitude, const double timeInterval) -{ - // Only update plot if there is data and if the time interval has elapsed - if((numDataPoints > 0) && - (diff_timespec(get_highres_clock(), _lastReplot) > timeInterval)) { - - if(numDataPoints != _numPoints) { - _numPoints = numDataPoints; - - delete[] _dataPoints; - delete[] _minFFTPoints; - delete[] _maxFFTPoints; - delete[] _xAxisPoints; - _dataPoints = new double[_numPoints]; - _xAxisPoints = new double[_numPoints]; - _minFFTPoints = new double[_numPoints]; - _maxFFTPoints = new double[_numPoints]; - - _fft_plot_curve->setRawData(_xAxisPoints, _dataPoints, _numPoints); - _min_fft_plot_curve->setRawData(_xAxisPoints, _minFFTPoints, _numPoints); - _max_fft_plot_curve->setRawData(_xAxisPoints, _maxFFTPoints, _numPoints); - - _resetXAxisPoints(); - ClearMaxData(); - ClearMinData(); - } - - memcpy(_dataPoints, dataPoints, numDataPoints*sizeof(double)); - for(int64_t point = 0; point < numDataPoints; point++){ - if(dataPoints[point] < _minFFTPoints[point]){ - _minFFTPoints[point] = dataPoints[point]; - } - if(dataPoints[point] > _maxFFTPoints[point]){ - _maxFFTPoints[point] = dataPoints[point]; - } - } - - _noiseFloorAmplitude = noiseFloorAmplitude; - _peakFrequency = peakFrequency; - _peakAmplitude = peakAmplitude; - - SetUpperIntensityLevel(_peakAmplitude); - - replot(); - - _lastReplot = get_highres_clock(); - } -} - -void -FrequencyDisplayPlot::ClearMaxData() -{ - for(int64_t number = 0; number < _numPoints; number++){ - _maxFFTPoints[number] = _minYAxis; - } -} - -void -FrequencyDisplayPlot::ClearMinData() -{ - for(int64_t number = 0; number < _numPoints; number++){ - _minFFTPoints[number] = _maxYAxis; - } -} - -void -FrequencyDisplayPlot::SetMaxFFTVisible(const bool visibleFlag) -{ - _max_fft_plot_curve->setVisible(visibleFlag); -} - -void -FrequencyDisplayPlot::SetMinFFTVisible(const bool visibleFlag) -{ - _min_fft_plot_curve->setVisible(visibleFlag); -} - -void -FrequencyDisplayPlot::_resetXAxisPoints() -{ - double fft_bin_size = (_stopFrequency-_startFrequency) / static_cast(_numPoints); - double freqValue = _startFrequency; - for(int64_t loc = 0; loc < _numPoints; loc++){ - _xAxisPoints[loc] = freqValue; - freqValue += fft_bin_size; - } - - setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); - - // Set up zoomer base for maximum unzoom x-axis - // and reset to maximum unzoom level - QwtDoubleRect zbase = _zoomer->zoomBase(); - zbase.setLeft(_startFrequency); - zbase.setRight(_stopFrequency); - _zoomer->zoom(zbase); - _zoomer->setZoomBase(zbase); - _zoomer->zoom(0); -} - -void -FrequencyDisplayPlot::SetLowerIntensityLevel(const double lowerIntensityLevel) -{ - _lower_intensity_marker->setYValue( lowerIntensityLevel ); -} - -void -FrequencyDisplayPlot::SetUpperIntensityLevel(const double upperIntensityLevel) -{ - _upper_intensity_marker->setYValue( upperIntensityLevel ); -} - - -#endif /* FREQUENCY_DISPLAY_PLOT_C */ diff --git a/gr-qtgui/src/lib/FrequencyDisplayPlot.h b/gr-qtgui/src/lib/FrequencyDisplayPlot.h deleted file mode 100644 index 3c22c1397..000000000 --- a/gr-qtgui/src/lib/FrequencyDisplayPlot.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef FREQUENCY_DISPLAY_PLOT_HPP -#define FREQUENCY_DISPLAY_PLOT_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class FrequencyDisplayPlot:public QwtPlot{ - Q_OBJECT - -public: - FrequencyDisplayPlot(QWidget*); - virtual ~FrequencyDisplayPlot(); - - void SetFrequencyRange(const double, const double, - const double, const bool, - const double units=1000.0, - const std::string &strunits = "kHz"); - double GetStartFrequency()const; - double GetStopFrequency()const; - - 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 SetMaxFFTVisible(const bool); - void SetMinFFTVisible(const bool); - - virtual void replot(); - - void set_yaxis(double min, double max); - -public slots: - void resizeSlot( QSize *e ); - void SetLowerIntensityLevel(const double); - void SetUpperIntensityLevel(const double); - -protected: - -private: - - void _resetXAxisPoints(); - - double _startFrequency; - double _stopFrequency; - double _maxYAxis; - double _minYAxis; - - QwtPlotCurve* _fft_plot_curve; - QwtPlotCurve* _min_fft_plot_curve; - QwtPlotCurve* _max_fft_plot_curve; - - QwtPlotMarker* _lower_intensity_marker; - QwtPlotMarker* _upper_intensity_marker; - - QwtPlotPanner* _panner; - QwtPlotZoomer* _zoomer; - - QwtPlotMarker *_markerPeakAmplitude; - QwtPlotMarker *_markerNoiseFloorAmplitude; - - double* _dataPoints; - double* _xAxisPoints; - - double* _minFFTPoints; - double* _maxFFTPoints; - int64_t _numPoints; - - double _peakFrequency; - double _peakAmplitude; - - double _noiseFloorAmplitude; - - timespec _lastReplot; - - bool _useCenterFrequencyFlag; -}; - -#endif /* FREQUENCY_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/src/lib/Makefile.am b/gr-qtgui/src/lib/Makefile.am deleted file mode 100644 index 446a07fd0..000000000 --- a/gr-qtgui/src/lib/Makefile.am +++ /dev/null @@ -1,110 +0,0 @@ -# -# Copyright 2008,2009,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. -# - -include $(top_srcdir)/Makefile.common -include $(top_srcdir)/Makefile.swig - -EXTRA_DIST += spectrumdisplayform.ui - -AM_CPPFLAGS = -I. $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ - $(QT_INCLUDES) $(BOOST_CPPFLAGS) $(WITH_INCLUDES) - -# Only include these files in the build if qtgui passes configure checks -# This is mostly to help make distcheck pass -QMAKE_SOURCES = \ - spectrumdisplayform.moc.cc \ - FrequencyDisplayPlot.moc.cc \ - TimeDomainDisplayPlot.moc.cc \ - WaterfallDisplayPlot.moc.cc \ - ConstellationDisplayPlot.moc.cc \ - spectrumdisplayform.ui.h - -BUILT_SOURCES += $(QMAKE_SOURCES) - -# Build the normal library for C++ apps to link against -lib_LTLIBRARIES = libgnuradio-qtgui.la - -# These are the source files that go into the shared library -libgnuradio_qtgui_la_SOURCES = \ - FrequencyDisplayPlot.cc \ - TimeDomainDisplayPlot.cc \ - WaterfallDisplayPlot.cc \ - waterfallGlobalData.cc \ - ConstellationDisplayPlot.cc \ - spectrumdisplayform.cc \ - SpectrumGUIClass.cc \ - spectrumUpdateEvents.cc \ - plot_waterfall.cc \ - qtgui_sink_c.cc \ - qtgui_sink_f.cc - -nodist_libgnuradio_qtgui_la_SOURCES=$(QMAKE_SOURCES) - -# These headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ - FrequencyDisplayPlot.h \ - TimeDomainDisplayPlot.h \ - WaterfallDisplayPlot.h \ - waterfallGlobalData.h \ - ConstellationDisplayPlot.h \ - highResTimeFunctions.h \ - plot_waterfall.h \ - spectrumdisplayform.h \ - SpectrumGUIClass.h \ - spectrumUpdateEvents.h \ - qtgui.h \ - qtgui_sink_c.h \ - qtgui_sink_f.h - -QT_MOC_FLAGS=-DQT_SHARED -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -%.moc.cc : %.h - $(QT_MOC_EXEC) $(QT_MOC_FLAGS) -p $(srcdir) $< -o $@ - -%.ui.h : %.ui - $(QT_UIC_EXEC) $< -o $@ - -# magic flags -libgnuradio_qtgui_la_LDFLAGS = $(NO_UNDEFINED) $(BOOST_LDFLAGS) $(LTVERSIONFLAGS) - -libgnuradio_qtgui_la_LIBADD = \ - $(GNURADIO_CORE_LA) \ - $(BOOST_THREAD_LIB) \ - $(BOOST_DATE_TIME_LIB) \ - -lstdc++ \ - $(QT_LIBS) - - -############################## -# SWIG interfaces and libraries - -TOP_SWIG_IFILES = \ - qtgui.i - -# Install so that they end up available as: -# import gnuradio.qtgui -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio -qtgui_pythondir_category = \ - gnuradio/qtgui - -# additional libraries for linking with the SWIG-generated library -qtgui_la_swig_libadd = \ - libgnuradio-qtgui.la diff --git a/gr-qtgui/src/lib/Makefile.swig.gen b/gr-qtgui/src/lib/Makefile.swig.gen deleted file mode 100644 index 9c4c0b58c..000000000 --- a/gr-qtgui/src/lib/Makefile.swig.gen +++ /dev/null @@ -1,145 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2009 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. -# - -# Makefile.swig.gen for qtgui.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/qtgui -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/qtgui -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -qtgui_pythondir_category ?= gnuradio/qtgui -qtgui_pylibdir_category ?= $(qtgui_pythondir_category) -qtgui_pythondir = $(pythondir)/$(qtgui_pythondir_category) -qtgui_pylibdir = $(pyexecdir)/$(qtgui_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -qtgui_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/qtgui -# FIXME: determince whether these should be installed with gnuradio. -qtgui_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -qtgui_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -qtgui_swiginclude_HEADERS = \ - qtgui.i \ - $(qtgui_swiginclude_headers) - -if PYTHON -qtgui_pylib_LTLIBRARIES = \ - _qtgui.la - -_qtgui_la_SOURCES = \ - python/qtgui.cc \ - $(qtgui_la_swig_sources) - -qtgui_python_PYTHON = \ - qtgui.py \ - $(qtgui_python) - -_qtgui_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(qtgui_la_swig_libadd) - -_qtgui_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(qtgui_la_swig_ldflags) - -_qtgui_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(qtgui_la_swig_cxxflags) - -python/qtgui.cc: qtgui.py -qtgui.py: qtgui.i - -# Include the python dependencies for this file --include python/qtgui.d - -endif # end of if python - -if GUILE - -qtgui_scmlib_LTLIBRARIES = \ - libguile-gnuradio-qtgui.la -libguile_gnuradio_qtgui_la_SOURCES = \ - guile/qtgui.cc \ - $(qtgui_la_swig_sources) -nobase_qtgui_scm_DATA = \ - gnuradio/qtgui.scm \ - gnuradio/qtgui-primitive.scm -libguile_gnuradio_qtgui_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(qtgui_la_swig_libadd) -libguile_gnuradio_qtgui_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(qtgui_la_swig_ldflags) -libguile_gnuradio_qtgui_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(qtgui_la_swig_cxxflags) - -guile/qtgui.cc: gnuradio/qtgui.scm -gnuradio/qtgui.scm: qtgui.i -gnuradio/qtgui-primitive.scm: gnuradio/qtgui.scm - -# Include the guile dependencies for this file --include guile/qtgui.d - -endif # end of GUILE - - diff --git a/gr-qtgui/src/lib/SpectrumGUIClass.cc b/gr-qtgui/src/lib/SpectrumGUIClass.cc deleted file mode 100644 index 052730fc2..000000000 --- a/gr-qtgui/src/lib/SpectrumGUIClass.cc +++ /dev/null @@ -1,468 +0,0 @@ -#ifndef SPECTRUM_GUI_CLASS_CPP -#define SPECTRUM_GUI_CLASS_CPP - -#include -//Added by qt3to4: -#include -#include - -const long SpectrumGUIClass::MAX_FFT_SIZE = 32768; -const long SpectrumGUIClass::MIN_FFT_SIZE = 1024; - -SpectrumGUIClass::SpectrumGUIClass(const uint64_t maxDataSize, - const uint64_t fftSize, - const double newCenterFrequency, - const double newStartFrequency, - const double newStopFrequency) -{ - _dataPoints = maxDataSize; - if(_dataPoints < 2){ - _dataPoints = 2; - } - _lastDataPointCount = _dataPoints; - - _fftSize = fftSize; - - _pendingGUIUpdateEventsCount = 0; - _droppedEntriesCount = 0; - - _centerFrequency = newCenterFrequency; - _startFrequency = newStartFrequency; - _stopFrequency = newStopFrequency; - - _windowType = 5; - - timespec_reset(&_lastGUIUpdateTime); - - _windowOpennedFlag = false; - _fftBuffersCreatedFlag = false; - - // Create Mutex Lock - //_windowStateLock = new MutexClass("_windowStateLock"); - - _powerValue = 1; -} - -SpectrumGUIClass::~SpectrumGUIClass() -{ - if(GetWindowOpenFlag()){ - delete _spectrumDisplayForm; - } - - if(_fftBuffersCreatedFlag){ - delete[] _fftPoints; - delete[] _realTimeDomainPoints; - delete[] _imagTimeDomainPoints; - } - - //delete _windowStateLock; -} - -void -SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, - const bool frequency, const bool waterfall, - const bool time, const bool constellation, - const bool use_openGL) -{ - //_windowStateLock->Lock(); - - if(!_windowOpennedFlag){ - - if(!_fftBuffersCreatedFlag){ - _fftPoints = new std::complex[_dataPoints]; - _realTimeDomainPoints = new double[_dataPoints]; - _imagTimeDomainPoints = new double[_dataPoints]; - _fftBuffersCreatedFlag = true; - - - memset(_fftPoints, 0x0, _dataPoints*sizeof(std::complex)); - memset(_realTimeDomainPoints, 0x0, _dataPoints*sizeof(double)); - memset(_imagTimeDomainPoints, 0x0, _dataPoints*sizeof(double)); - } - - // Called from the Event Thread - _spectrumDisplayForm = new SpectrumDisplayForm(use_openGL, parent); - - // Toggle Windows on/off - _spectrumDisplayForm->ToggleTabFrequency(frequency); - _spectrumDisplayForm->ToggleTabWaterfall(waterfall); - _spectrumDisplayForm->ToggleTabTime(time); - _spectrumDisplayForm->ToggleTabConstellation(constellation); - - _windowOpennedFlag = true; - - _spectrumDisplayForm->setSystem(this, _dataPoints, _fftSize); - - qApp->processEvents(); - } - - //_windowStateLock->Unlock(); - - SetDisplayTitle(_title); - Reset(); - - qApp->postEvent(_spectrumDisplayForm, - new QEvent(QEvent::Type(QEvent::User+3))); - - qApp->processEvents(); - - timespec_reset(&_lastGUIUpdateTime); - - // Draw Blank Display - UpdateWindow(false, NULL, 0, NULL, 0, NULL, 0, get_highres_clock(), true); - - // Set up the initial frequency axis settings - SetFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency); - - // GUI Thread only - qApp->processEvents(); -} - -void -SpectrumGUIClass::Reset() -{ - if(GetWindowOpenFlag()) { - qApp->postEvent(_spectrumDisplayForm, - new SpectrumFrequencyRangeEvent(_centerFrequency, - _startFrequency, - _stopFrequency)); - qApp->postEvent(_spectrumDisplayForm, new SpectrumWindowResetEvent()); - } - _droppedEntriesCount = 0; - // Call the following function the the Spectrum Window Reset Event window - // ResetPendingGUIUpdateEvents(); -} - -void -SpectrumGUIClass::SetDisplayTitle(const std::string newString) -{ - _title.assign(newString); - - if(GetWindowOpenFlag()){ - qApp->postEvent(_spectrumDisplayForm, - new SpectrumWindowCaptionEvent(_title.c_str())); - } -} - -bool -SpectrumGUIClass::GetWindowOpenFlag() -{ - bool returnFlag = false; - //_windowStateLock->Lock(); - returnFlag = _windowOpennedFlag; - //_windowStateLock->Unlock(); - return returnFlag; -} - - -void -SpectrumGUIClass::SetWindowOpenFlag(const bool newFlag) -{ - //_windowStateLock->Lock(); - _windowOpennedFlag = newFlag; - //_windowStateLock->Unlock(); -} - -void -SpectrumGUIClass::SetFrequencyRange(const double centerFreq, - const double startFreq, - const double stopFreq) -{ - //_windowStateLock->Lock(); - _centerFrequency = centerFreq; - _startFrequency = startFreq; - _stopFrequency = stopFreq; - - _spectrumDisplayForm->SetFrequencyRange(_centerFrequency, - _startFrequency, - _stopFrequency); - //_windowStateLock->Unlock(); -} - -double -SpectrumGUIClass::GetStartFrequency() const -{ - double returnValue = 0.0; - //_windowStateLock->Lock(); - returnValue = _startFrequency; - //_windowStateLock->Unlock(); - return returnValue; -} - -double -SpectrumGUIClass::GetStopFrequency() const -{ - double returnValue = 0.0; - //_windowStateLock->Lock(); - returnValue = _stopFrequency; - //_windowStateLock->Unlock(); - return returnValue; -} - -double -SpectrumGUIClass::GetCenterFrequency() const -{ - double returnValue = 0.0; - //_windowStateLock->Lock(); - returnValue = _centerFrequency; - //_windowStateLock->Unlock(); - return returnValue; -} - - -void -SpectrumGUIClass::UpdateWindow(const bool updateDisplayFlag, - const std::complex* fftBuffer, - const uint64_t inputBufferSize, - const float* realTimeDomainData, - const uint64_t realTimeDomainDataSize, - const float* complexTimeDomainData, - const uint64_t complexTimeDomainDataSize, - const timespec timestamp, - const bool lastOfMultipleFFTUpdateFlag) -{ - int64_t bufferSize = inputBufferSize; - bool repeatDataFlag = false; - if(bufferSize > _dataPoints){ - bufferSize = _dataPoints; - } - int64_t timeDomainBufferSize = 0; - - if(updateDisplayFlag){ - if((fftBuffer != NULL) && (bufferSize > 0)){ - memcpy(_fftPoints, fftBuffer, bufferSize * sizeof(std::complex)); - } - - // Can't do a memcpy since ths is going from float to double data type - if((realTimeDomainData != NULL) && (realTimeDomainDataSize > 0)){ - const float* realTimeDomainDataPtr = realTimeDomainData; - - double* realTimeDomainPointsPtr = _realTimeDomainPoints; - timeDomainBufferSize = realTimeDomainDataSize; - - memset( _imagTimeDomainPoints, 0x0, realTimeDomainDataSize*sizeof(double)); - for( uint64_t number = 0; number < realTimeDomainDataSize; number++){ - *realTimeDomainPointsPtr++ = *realTimeDomainDataPtr++; - } - } - - // Can't do a memcpy since ths is going from float to double data type - if((complexTimeDomainData != NULL) && (complexTimeDomainDataSize > 0)){ - const float* complexTimeDomainDataPtr = complexTimeDomainData; - - double* realTimeDomainPointsPtr = _realTimeDomainPoints; - double* imagTimeDomainPointsPtr = _imagTimeDomainPoints; - - timeDomainBufferSize = complexTimeDomainDataSize; - for( uint64_t number = 0; number < complexTimeDomainDataSize; number++){ - *realTimeDomainPointsPtr++ = *complexTimeDomainDataPtr++; - *imagTimeDomainPointsPtr++ = *complexTimeDomainDataPtr++; - } - } - } - - // If bufferSize is zero, then just update the display by sending over the old data - if(bufferSize < 1){ - bufferSize = _lastDataPointCount; - repeatDataFlag = true; - } - else{ - // Since there is data this time, update the count - _lastDataPointCount = bufferSize; - } - - const timespec currentTime = get_highres_clock(); - const timespec lastUpdateGUITime = GetLastGUIUpdateTime(); - - if((diff_timespec(currentTime, lastUpdateGUITime) > (4*_updateTime)) && - (GetPendingGUIUpdateEvents() > 0) && !timespec_empty(&lastUpdateGUITime)) { - // Do not update the display if too much data is pending to be displayed - _droppedEntriesCount++; - } - else{ - // Draw the Data - IncrementPendingGUIUpdateEvents(); - qApp->postEvent(_spectrumDisplayForm, - new SpectrumUpdateEvent(_fftPoints, bufferSize, - _realTimeDomainPoints, - _imagTimeDomainPoints, - timeDomainBufferSize, - timestamp, - repeatDataFlag, - lastOfMultipleFFTUpdateFlag, - currentTime, - _droppedEntriesCount)); - - // Only reset the dropped entries counter if this is not - // repeat data since repeat data is dropped by the display systems - if(!repeatDataFlag){ - _droppedEntriesCount = 0; - } - } -} - -float -SpectrumGUIClass::GetPowerValue() const -{ - float returnValue = 0; - //_windowStateLock->Lock(); - returnValue = _powerValue; - //_windowStateLock->Unlock(); - return returnValue; -} - -void -SpectrumGUIClass::SetPowerValue(const float value) -{ - //_windowStateLock->Lock(); - _powerValue = value; - //_windowStateLock->Unlock(); -} - -int -SpectrumGUIClass::GetWindowType() const -{ - int returnValue = 0; - //_windowStateLock->Lock(); - returnValue = _windowType; - //_windowStateLock->Unlock(); - return returnValue; -} - -void -SpectrumGUIClass::SetWindowType(const int newType) -{ - //_windowStateLock->Lock(); - _windowType = newType; - //_windowStateLock->Unlock(); -} - -int -SpectrumGUIClass::GetFFTSize() const -{ - int returnValue = 0; - //_windowStateLock->Lock(); - returnValue = _fftSize; - //_windowStateLock->Unlock(); - return returnValue; -} - -int -SpectrumGUIClass::GetFFTSizeIndex() const -{ - int fftsize = GetFFTSize(); - switch(fftsize) { - case(1024): return 0; break; - case(2048): return 1; break; - case(4096): return 2; break; - case(8192): return 3; break; - case(16384): return 3; break; - case(32768): return 3; break; - default: return 0; - } -} - -void -SpectrumGUIClass::SetFFTSize(const int newSize) -{ - //_windowStateLock->Lock(); - _fftSize = newSize; - //_windowStateLock->Unlock(); -} - -timespec -SpectrumGUIClass::GetLastGUIUpdateTime() const -{ - timespec returnValue; - //_windowStateLock->Lock(); - returnValue = _lastGUIUpdateTime; - //_windowStateLock->Unlock(); - return returnValue; -} - -void -SpectrumGUIClass::SetLastGUIUpdateTime(const timespec newTime) -{ - //_windowStateLock->Lock(); - _lastGUIUpdateTime = newTime; - //_windowStateLock->Unlock(); -} - -unsigned int -SpectrumGUIClass::GetPendingGUIUpdateEvents() const -{ - unsigned int returnValue = 0; - //_windowStateLock->Lock(); - returnValue = _pendingGUIUpdateEventsCount; - //_windowStateLock->Unlock(); - return returnValue; -} - -void -SpectrumGUIClass::IncrementPendingGUIUpdateEvents() -{ - //_windowStateLock->Lock(); - _pendingGUIUpdateEventsCount++; - //_windowStateLock->Unlock(); -} - -void -SpectrumGUIClass::DecrementPendingGUIUpdateEvents() -{ - //_windowStateLock->Lock(); - if(_pendingGUIUpdateEventsCount > 0){ - _pendingGUIUpdateEventsCount--; - } - //_windowStateLock->Unlock(); -} - -void -SpectrumGUIClass::ResetPendingGUIUpdateEvents() -{ - //_windowStateLock->Lock(); - _pendingGUIUpdateEventsCount = 0; - //_windowStateLock->Unlock(); -} - - -QWidget* -SpectrumGUIClass::qwidget() -{ - return (QWidget*)_spectrumDisplayForm; -} - -void -SpectrumGUIClass::SetTimeDomainAxis(double min, double max) -{ - _spectrumDisplayForm->SetTimeDomainAxis(min, max); -} - -void -SpectrumGUIClass::SetConstellationAxis(double xmin, double xmax, - double ymin, double ymax) -{ - _spectrumDisplayForm->SetConstellationAxis(xmin, xmax, ymin, ymax); - -} - -void -SpectrumGUIClass::SetConstellationPenSize(int size){ - _spectrumDisplayForm->SetConstellationPenSize(size); -} - - -void -SpectrumGUIClass::SetFrequencyAxis(double min, double max) -{ - _spectrumDisplayForm->SetFrequencyAxis(min, max); -} - -void -SpectrumGUIClass::SetUpdateTime(double t) -{ - _updateTime = t; - _spectrumDisplayForm->SetUpdateTime(_updateTime); -} - - -#endif /* SPECTRUM_GUI_CLASS_CPP */ diff --git a/gr-qtgui/src/lib/SpectrumGUIClass.h b/gr-qtgui/src/lib/SpectrumGUIClass.h deleted file mode 100644 index 57a749a6a..000000000 --- a/gr-qtgui/src/lib/SpectrumGUIClass.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef SPECTRUM_GUI_CLASS_HPP -#define SPECTRUM_GUI_CLASS_HPP - -//#include -#include -#include -#include -#include -#include - -//#include - -class SpectrumDisplayForm; -#include - -#include - -#include -#include -#include - -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, - const bool use_openGL=true); - void SetDisplayTitle(const std::string); - - bool GetWindowOpenFlag(); - void SetWindowOpenFlag(const bool); - - void SetFrequencyRange(const double, const double, const double); - double GetStartFrequency()const; - double GetStopFrequency()const; - double GetCenterFrequency()const; - - void UpdateWindow(const bool, const std::complex*, - const uint64_t, const float*, - const uint64_t, const float*, - const uint64_t, - const timespec, const bool); - - float GetPowerValue()const; - void SetPowerValue(const float); - - int GetWindowType()const; - void SetWindowType(const int); - - int GetFFTSize()const; - int GetFFTSizeIndex()const; - void SetFFTSize(const int); - - timespec GetLastGUIUpdateTime()const; - void SetLastGUIUpdateTime(const timespec); - - unsigned int GetPendingGUIUpdateEvents()const; - 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: - - //MutexClass* _windowStateLock; - int64_t _dataPoints; - std::string _title; - double _centerFrequency; - double _startFrequency; - double _stopFrequency; - float _powerValue; - bool _windowOpennedFlag; - int _windowType; - int64_t _lastDataPointCount; - int _fftSize; - timespec _lastGUIUpdateTime; - unsigned int _pendingGUIUpdateEventsCount; - int _droppedEntriesCount; - bool _fftBuffersCreatedFlag; - double _updateTime; - - SpectrumDisplayForm* _spectrumDisplayForm; - - std::complex* _fftPoints; - double* _realTimeDomainPoints; - double* _imagTimeDomainPoints; -}; - -#endif /* SPECTRUM_GUI_CLASS_HPP */ diff --git a/gr-qtgui/src/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/src/lib/TimeDomainDisplayPlot.cc deleted file mode 100644 index 9c98cec5b..000000000 --- a/gr-qtgui/src/lib/TimeDomainDisplayPlot.cc +++ /dev/null @@ -1,276 +0,0 @@ -#ifndef TIME_DOMAIN_DISPLAY_PLOT_C -#define TIME_DOMAIN_DISPLAY_PLOT_C - -#include - -#include -#include - - -class TimePrecisionClass -{ -public: - TimePrecisionClass(const int timePrecision) - { - _timePrecision = timePrecision; - } - - virtual ~TimePrecisionClass() - { - } - - virtual unsigned int GetTimePrecision() const - { - return _timePrecision; - } - - virtual void SetTimePrecision(const unsigned int newPrecision) - { - _timePrecision = newPrecision; - } -protected: - unsigned int _timePrecision; -}; - - -class TimeDomainDisplayZoomer: public QwtPlotZoomer, public TimePrecisionClass -{ -public: - TimeDomainDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int timePrecision) - : QwtPlotZoomer(canvas),TimePrecisionClass(timePrecision) - { - setTrackerMode(QwtPicker::AlwaysOn); - } - - virtual ~TimeDomainDisplayZoomer(){ - - } - - virtual void updateTrackerText(){ - updateDisplay(); - } - - void SetUnitType(const std::string &type) - { - _unitType = type; - } - -protected: - using QwtPlotZoomer::trackerText; - virtual QwtText trackerText( const QwtDoublePoint& p ) const - { - QwtText t(QString("%1 %2, %3 V").arg(p.x(), 0, 'f', GetTimePrecision()). - arg(_unitType.c_str()). - arg(p.y(), 0, 'f', 4)); - - return t; - } - -private: - std::string _unitType; -}; - -TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent) -{ - timespec_reset(&_lastReplot); - - resize(parent->width(), parent->height()); - - _numPoints = 1024; - _realDataPoints = new double[_numPoints]; - _imagDataPoints = new double[_numPoints]; - _xAxisPoints = new double[_numPoints]; - - _zoomer = new TimeDomainDisplayZoomer(canvas(), 0); - - // Disable polygon clipping - QwtPainter::setDeviceClipping(false); - - // We don't need the cache here - canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); - canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); - - QPalette palette; - palette.setColor(canvas()->backgroundRole(), QColor("white")); - canvas()->setPalette(palette); - - setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine); - set_xaxis(0, _numPoints); - setAxisTitle(QwtPlot::xBottom, "Time (sec)"); - - setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine); - set_yaxis(-2.0, 2.0); - setAxisTitle(QwtPlot::yLeft, "Normalized Voltage"); - - // Automatically deleted when parent is deleted - _real_plot_curve = new QwtPlotCurve("Real Data"); - _real_plot_curve->attach(this); - _real_plot_curve->setPen(QPen(Qt::blue)); - _real_plot_curve->setRawData(_xAxisPoints, _realDataPoints, _numPoints); - - _imag_plot_curve = new QwtPlotCurve("Imaginary Data"); - _imag_plot_curve->attach(this); - _imag_plot_curve->setPen(QPen(Qt::magenta)); - _imag_plot_curve->setRawData(_xAxisPoints, _imagDataPoints, _numPoints); - // _imag_plot_curve->setVisible(false); - - memset(_realDataPoints, 0x0, _numPoints*sizeof(double)); - memset(_imagDataPoints, 0x0, _numPoints*sizeof(double)); - memset(_xAxisPoints, 0x0, _numPoints*sizeof(double)); - - _sampleRate = 1; - _resetXAxisPoints(); - - replot(); - -#if QT_VERSION < 0x040000 - _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); -#else - _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); -#endif - _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, - Qt::RightButton); - - _panner = new QwtPlotPanner(canvas()); - _panner->setAxisEnabled(QwtPlot::yRight, false); - _panner->setMouseButton(Qt::MidButton); - - // Avoid jumping when labels with more/less digits - // appear/disappear when scrolling vertically - - const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); - QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); - sd->setMinimumExtent( fm.width("100.00") ); - - const QColor c(Qt::darkRed); - _zoomer->setRubberBandPen(c); - _zoomer->setTrackerPen(c); - - QwtLegend* legendDisplay = new QwtLegend(this); - legendDisplay->setItemMode(QwtLegend::CheckableItem); - insertLegend(legendDisplay); - - connect(this, SIGNAL( legendChecked(QwtPlotItem *, bool ) ), - this, SLOT( LegendEntryChecked(QwtPlotItem *, bool ) )); -} - -TimeDomainDisplayPlot::~TimeDomainDisplayPlot(){ - delete[] _realDataPoints; - delete[] _imagDataPoints; - delete[] _xAxisPoints; - - // _fft_plot_curves deleted when parent deleted - // _zoomer and _panner deleted when parent deleted -} - -void -TimeDomainDisplayPlot::set_yaxis(double min, double max) -{ - setAxisScale(QwtPlot::yLeft, min, max); - _zoomer->setZoomBase(); -} - -void -TimeDomainDisplayPlot::set_xaxis(double min, double max) -{ - setAxisScale(QwtPlot::xBottom, min, max); - _zoomer->setZoomBase(); -} - - -void TimeDomainDisplayPlot::replot() -{ - QwtPlot::replot(); -} - -void -TimeDomainDisplayPlot::resizeSlot( QSize *s ) -{ - resize(s->width(), s->height()); -} - -void TimeDomainDisplayPlot::PlotNewData(const double* realDataPoints, - const double* imagDataPoints, - const int64_t numDataPoints, - const double timeInterval) -{ - if((numDataPoints > 0) && - (diff_timespec(get_highres_clock(), _lastReplot) > timeInterval)) { - - if(numDataPoints != _numPoints){ - _numPoints = numDataPoints; - - delete[] _realDataPoints; - delete[] _imagDataPoints; - delete[] _xAxisPoints; - _realDataPoints = new double[_numPoints]; - _imagDataPoints = new double[_numPoints]; - _xAxisPoints = new double[_numPoints]; - - _real_plot_curve->setRawData(_xAxisPoints, _realDataPoints, _numPoints); - _imag_plot_curve->setRawData(_xAxisPoints, _imagDataPoints, _numPoints); - - set_xaxis(0, numDataPoints); - - _resetXAxisPoints(); - } - - memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double)); - memcpy(_imagDataPoints, imagDataPoints, numDataPoints*sizeof(double)); - - replot(); - - _lastReplot = get_highres_clock(); - } -} - -void TimeDomainDisplayPlot::SetImaginaryDataVisible(const bool visibleFlag) -{ - _imag_plot_curve->setVisible(visibleFlag); -} - -void TimeDomainDisplayPlot::_resetXAxisPoints() -{ - double delt = 1.0/_sampleRate; - for(long loc = 0; loc < _numPoints; loc++){ - _xAxisPoints[loc] = loc*delt; - } - setAxisScale(QwtPlot::xBottom, 0, _numPoints*delt); - - // Set up zoomer base for maximum unzoom x-axis - // and reset to maximum unzoom level - QwtDoubleRect zbase = _zoomer->zoomBase(); - zbase.setLeft(0); - zbase.setRight(_numPoints*delt); - _zoomer->zoom(zbase); - _zoomer->setZoomBase(zbase); - _zoomer->zoom(0); -} - -void TimeDomainDisplayPlot::LegendEntryChecked(QwtPlotItem* plotItem, bool on) -{ - plotItem->setVisible(!on); -} - -void -TimeDomainDisplayPlot::SetSampleRate(double sr, double units, - const std::string &strunits) -{ - double newsr = sr/units; - if(newsr != _sampleRate) { - _sampleRate = sr/units; - _resetXAxisPoints(); - - // While we could change the displayed sigfigs based on the unit being - // displayed, I think it looks better by just setting it to 4 regardless. - //double display_units = ceil(log10(units)/2.0); - double display_units = 4; - setAxisTitle(QwtPlot::xBottom, QString("Time (%1)").arg(strunits.c_str())); - ((TimeDomainDisplayZoomer*)_zoomer)->SetTimePrecision(display_units); - ((TimeDomainDisplayZoomer*)_zoomer)->SetUnitType(strunits); - } -} - -#endif /* TIME_DOMAIN_DISPLAY_PLOT_C */ diff --git a/gr-qtgui/src/lib/TimeDomainDisplayPlot.h b/gr-qtgui/src/lib/TimeDomainDisplayPlot.h deleted file mode 100644 index 952b5c8cf..000000000 --- a/gr-qtgui/src/lib/TimeDomainDisplayPlot.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef TIME_DOMAIN_DISPLAY_PLOT_HPP -#define TIME_DOMAIN_DISPLAY_PLOT_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class TimeDomainDisplayPlot:public QwtPlot{ - Q_OBJECT - -public: - TimeDomainDisplayPlot(QWidget*); - virtual ~TimeDomainDisplayPlot(); - - void PlotNewData(const double* realDataPoints, const double* imagDataPoints, - const int64_t numDataPoints, const double timeInterval); - - void SetImaginaryDataVisible(const bool); - - virtual void replot(); - - void set_yaxis(double min, double max); - void set_xaxis(double min, double max); - -public slots: - void resizeSlot( QSize *s ); - void SetSampleRate(double sr, double units, - const std::string &strunits); - -protected slots: - void LegendEntryChecked(QwtPlotItem *plotItem, bool on); - -protected: - -private: - void _resetXAxisPoints(); - - QwtPlotCurve* _real_plot_curve; - QwtPlotCurve* _imag_plot_curve; - - QwtPlotPanner* _panner; - QwtPlotZoomer* _zoomer; - - double* _realDataPoints; - double* _imagDataPoints; - double* _xAxisPoints; - - double _sampleRate; - - timespec _lastReplot; - - int64_t _numPoints; -}; - -#endif /* TIME_DOMAIN_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc deleted file mode 100644 index a8e5361e7..000000000 --- a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc +++ /dev/null @@ -1,547 +0,0 @@ -#ifndef WATERFALL_DISPLAY_PLOT_C -#define WATERFALL_DISPLAY_PLOT_C - -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -namespace pt = boost::posix_time; - -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: - unsigned int _frequencyPrecision; - double _centerFrequency; - -private: - -}; - -class WaterfallFreqDisplayScaleDraw: public QwtScaleDraw, public FreqOffsetAndPrecisionClass{ -public: - WaterfallFreqDisplayScaleDraw(const unsigned int precision) - : QwtScaleDraw(), FreqOffsetAndPrecisionClass(precision) - { - } - - virtual ~WaterfallFreqDisplayScaleDraw() - { - } - - QwtText label(double value) const - { - return QString("%1").arg(value, 0, 'f', GetFrequencyPrecision()); - } - - virtual void initiateUpdate() - { - invalidateCache(); - } - -protected: - -private: - -}; - -class TimeScaleData -{ -public: - TimeScaleData() - { - timespec_reset(&_zeroTime); - _secondsPerLine = 1.0; - } - - virtual ~TimeScaleData() - { - } - - virtual timespec GetZeroTime() const - { - return _zeroTime; - } - - virtual void SetZeroTime(const timespec newTime) - { - _zeroTime = newTime; - } - - virtual void SetSecondsPerLine(const double newTime) - { - _secondsPerLine = newTime; - } - - virtual double GetSecondsPerLine() const - { - return _secondsPerLine; - } - - -protected: - timespec _zeroTime; - double _secondsPerLine; - -private: - -}; - -class QwtTimeScaleDraw: public QwtScaleDraw, public TimeScaleData -{ -public: - QwtTimeScaleDraw():QwtScaleDraw(),TimeScaleData() - { - } - - virtual ~QwtTimeScaleDraw() - { - } - - virtual QwtText label(double value) const - { - timespec lineTime = timespec_add(GetZeroTime(), (-value) * GetSecondsPerLine()); - std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); - - // lops off the YYYY-mmm-DD part of the string - int ind = time_str.find(" "); - if(ind != std::string::npos) - time_str = time_str.substr(ind); - return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); - } - - virtual void initiateUpdate() - { - // Do this in one call rather than when zeroTime and secondsPerLine - // updates is to prevent the display from being updated too often... - invalidateCache(); - } - -protected: - -private: - -}; - -class WaterfallZoomer: public QwtPlotZoomer, public TimeScaleData, - public FreqOffsetAndPrecisionClass -{ -public: - WaterfallZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision) - : QwtPlotZoomer(canvas), TimeScaleData(), - FreqOffsetAndPrecisionClass(freqPrecision) - { - setTrackerMode(QwtPicker::AlwaysOn); - } - - virtual ~WaterfallZoomer() - { - } - - virtual void updateTrackerText() - { - updateDisplay(); - } - - void SetUnitType(const std::string &type) - { - _unitType = type; - } - -protected: - using QwtPlotZoomer::trackerText; - virtual QwtText trackerText( const QwtDoublePoint& p ) const - { - timespec lineTime = timespec_add(GetZeroTime(), (-p.y()) * GetSecondsPerLine()); - std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); - - // lops off the YYYY-mmm-DD part of the string - int ind = time_str.find(" "); - if(ind != std::string::npos) - time_str = time_str.substr(ind); - QString yLabel(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); - - QwtText t(QString("%1 %2, %3"). - arg(p.x(), 0, 'f', GetFrequencyPrecision()). - arg(_unitType.c_str()).arg(yLabel)); - return t; - } - -private: - std::string _unitType; -}; - - -WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) - : QwtPlot(parent) -{ - _zoomer = NULL; - _startFrequency = 0; - _stopFrequency = 4000; - - resize(parent->width(), parent->height()); - _numPoints = 1024; - - _waterfallData = new WaterfallData(_startFrequency, _stopFrequency, _numPoints, 200); - - QPalette palette; - palette.setColor(canvas()->backgroundRole(), QColor("white")); - canvas()->setPalette(palette); - - setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)"); - setAxisScaleDraw(QwtPlot::xBottom, new WaterfallFreqDisplayScaleDraw(0)); - - setAxisTitle(QwtPlot::yLeft, "Time"); - setAxisScaleDraw(QwtPlot::yLeft, new QwtTimeScaleDraw()); - - timespec_reset(&_lastReplot); - - d_spectrogram = new PlotWaterfall(_waterfallData, "Waterfall Display"); - - _intensityColorMapType = INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR; - - QwtLinearColorMap colorMap(Qt::darkCyan, Qt::white); - colorMap.addColorStop(0.25, Qt::cyan); - colorMap.addColorStop(0.5, Qt::yellow); - colorMap.addColorStop(0.75, Qt::red); - - d_spectrogram->setColorMap(colorMap); - - d_spectrogram->attach(this); - - // LeftButton for the zooming - // MidButton for the panning - // RightButton: zoom out by 1 - // Ctrl+RighButton: zoom out to full size - - _zoomer = new WaterfallZoomer(canvas(), 0); -#if QT_VERSION < 0x040000 - _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); -#else - _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); -#endif - _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, - Qt::RightButton); - - _panner = new QwtPlotPanner(canvas()); - _panner->setAxisEnabled(QwtPlot::yRight, false); - _panner->setMouseButton(Qt::MidButton); - - // Avoid jumping when labels with more/less digits - // appear/disappear when scrolling vertically - - const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); - QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); - sd->setMinimumExtent( fm.width("100.00") ); - - const QColor c(Qt::white); - _zoomer->setRubberBandPen(c); - _zoomer->setTrackerPen(c); - - _UpdateIntensityRangeDisplay(); -} - -WaterfallDisplayPlot::~WaterfallDisplayPlot() -{ - delete _waterfallData; - delete d_spectrogram; -} - -void -WaterfallDisplayPlot::Reset() -{ - _waterfallData->ResizeData(_startFrequency, _stopFrequency, _numPoints); - _waterfallData->Reset(); - - setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); - - // Load up the new base zoom settings - QwtDoubleRect newSize = _zoomer->zoomBase(); - newSize.setLeft(_startFrequency); - newSize.setWidth(_stopFrequency-_startFrequency); - _zoomer->zoom(newSize); - _zoomer->setZoomBase(newSize); - _zoomer->zoom(0); -} - -void -WaterfallDisplayPlot::SetFrequencyRange(const double constStartFreq, - const double constStopFreq, - const double constCenterFreq, - const bool useCenterFrequencyFlag, - const double units, const std::string &strunits) -{ - double startFreq = constStartFreq / units; - double stopFreq = constStopFreq / units; - double centerFreq = constCenterFreq / units; - - _useCenterFrequencyFlag = useCenterFrequencyFlag; - - if(_useCenterFrequencyFlag){ - startFreq = (startFreq + centerFreq); - stopFreq = (stopFreq + centerFreq); - } - - bool reset = false; - if((startFreq != _startFrequency) || (stopFreq != _stopFrequency)) - reset = true; - - if(stopFreq > startFreq) { - _startFrequency = startFreq; - _stopFrequency = stopFreq; - - if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){ - double display_units = ceil(log10(units)/2.0); - setAxisScaleDraw(QwtPlot::xBottom, new WaterfallFreqDisplayScaleDraw(display_units)); - setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str())); - - if(reset) { - Reset(); - } - - ((WaterfallZoomer*)_zoomer)->SetFrequencyPrecision(display_units); - ((WaterfallZoomer*)_zoomer)->SetUnitType(strunits); - } - } -} - - -double -WaterfallDisplayPlot::GetStartFrequency() const -{ - return _startFrequency; -} - -double -WaterfallDisplayPlot::GetStopFrequency() const -{ - return _stopFrequency; -} - -void -WaterfallDisplayPlot::PlotNewData(const double* dataPoints, - const int64_t numDataPoints, - const double timePerFFT, - const timespec timestamp, - const int droppedFrames) -{ - if(numDataPoints > 0){ - if(numDataPoints != _numPoints){ - _numPoints = numDataPoints; - - Reset(); - - d_spectrogram->invalidateCache(); - d_spectrogram->itemChanged(); - - if(isVisible()){ - replot(); - } - - _lastReplot = get_highres_clock(); - } - - if(diff_timespec(get_highres_clock(), _lastReplot) > timePerFFT) { - //FIXME: We may want to average the data between these updates to smooth display - _waterfallData->addFFTData(dataPoints, numDataPoints, droppedFrames); - _waterfallData->IncrementNumLinesToUpdate(); - - QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); - timeScale->SetSecondsPerLine(timePerFFT); - timeScale->SetZeroTime(timestamp); - - ((WaterfallZoomer*)_zoomer)->SetSecondsPerLine(timePerFFT); - ((WaterfallZoomer*)_zoomer)->SetZeroTime(timestamp); - - d_spectrogram->invalidateCache(); - d_spectrogram->itemChanged(); - - replot(); - - _lastReplot = get_highres_clock(); - } - } -} - -void -WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, - const double maxIntensity) -{ - _waterfallData->setRange(QwtDoubleInterval(minIntensity, maxIntensity)); - - emit UpdatedLowerIntensityLevel(minIntensity); - emit UpdatedUpperIntensityLevel(maxIntensity); - - _UpdateIntensityRangeDisplay(); -} - -void -WaterfallDisplayPlot::replot() -{ - QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); - timeScale->initiateUpdate(); - - WaterfallFreqDisplayScaleDraw* freqScale = (WaterfallFreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom); - freqScale->initiateUpdate(); - - // Update the time axis display - if(axisWidget(QwtPlot::yLeft) != NULL){ - axisWidget(QwtPlot::yLeft)->update(); - } - - // Update the Frequency Offset Display - if(axisWidget(QwtPlot::xBottom) != NULL){ - axisWidget(QwtPlot::xBottom)->update(); - } - - if(_zoomer != NULL){ - ((WaterfallZoomer*)_zoomer)->updateTrackerText(); - } - - QwtPlot::replot(); -} - -void -WaterfallDisplayPlot::resizeSlot( QSize *s ) -{ - resize(s->width(), s->height()); -} - -int -WaterfallDisplayPlot::GetIntensityColorMapType() const -{ - return _intensityColorMapType; -} - -void -WaterfallDisplayPlot::SetIntensityColorMapType(const int newType, - const QColor lowColor, - const QColor highColor) -{ - if((_intensityColorMapType != newType) || - ((newType == INTENSITY_COLOR_MAP_TYPE_USER_DEFINED) && - (lowColor.isValid() && highColor.isValid()))){ - switch(newType){ - case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:{ - _intensityColorMapType = newType; - QwtLinearColorMap colorMap(Qt::darkCyan, Qt::white); - colorMap.addColorStop(0.25, Qt::cyan); - colorMap.addColorStop(0.5, Qt::yellow); - colorMap.addColorStop(0.75, Qt::red); - d_spectrogram->setColorMap(colorMap); - break; - } - case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:{ - _intensityColorMapType = newType; - QwtLinearColorMap colorMap(Qt::black, Qt::white); - d_spectrogram->setColorMap(colorMap); - break; - } - case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:{ - _intensityColorMapType = newType; - QwtLinearColorMap colorMap(Qt::white, Qt::black); - d_spectrogram->setColorMap(colorMap); - break; - } - case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:{ - _intensityColorMapType = newType; - QwtLinearColorMap colorMap(Qt::black, Qt::white); - colorMap.addColorStop(0.5, Qt::darkRed); - d_spectrogram->setColorMap(colorMap); - break; - } - case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:{ - _userDefinedLowIntensityColor = lowColor; - _userDefinedHighIntensityColor = highColor; - _intensityColorMapType = newType; - QwtLinearColorMap colorMap(_userDefinedLowIntensityColor, _userDefinedHighIntensityColor); - d_spectrogram->setColorMap(colorMap); - break; - } - default: break; - } - - _UpdateIntensityRangeDisplay(); - } -} - -const QColor -WaterfallDisplayPlot::GetUserDefinedLowIntensityColor() const -{ - return _userDefinedLowIntensityColor; -} - -const QColor -WaterfallDisplayPlot::GetUserDefinedHighIntensityColor() const -{ - return _userDefinedHighIntensityColor; -} - -void -WaterfallDisplayPlot::_UpdateIntensityRangeDisplay() -{ - QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight); - rightAxis->setTitle("Intensity (dB)"); - rightAxis->setColorBarEnabled(true); - rightAxis->setColorMap(d_spectrogram->data()->range(), - d_spectrogram->colorMap()); - - setAxisScale(QwtPlot::yRight, - d_spectrogram->data()->range().minValue(), - d_spectrogram->data()->range().maxValue() ); - enableAxis(QwtPlot::yRight); - - plotLayout()->setAlignCanvasToScales(true); - - // Tell the display to redraw everything - d_spectrogram->invalidateCache(); - d_spectrogram->itemChanged(); - - // Draw again - replot(); - - // Update the last replot timer - _lastReplot = get_highres_clock(); -} - -#endif /* WATERFALL_DISPLAY_PLOT_C */ diff --git a/gr-qtgui/src/lib/WaterfallDisplayPlot.h b/gr-qtgui/src/lib/WaterfallDisplayPlot.h deleted file mode 100644 index 6b4e978bb..000000000 --- a/gr-qtgui/src/lib/WaterfallDisplayPlot.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef WATERFALL_DISPLAY_PLOT_HPP -#define WATERFALL_DISPLAY_PLOT_HPP - -#include -#include -#include -#include -#include - -#include - -#include - -class WaterfallDisplayPlot:public QwtPlot{ - Q_OBJECT - -public: - WaterfallDisplayPlot(QWidget*); - virtual ~WaterfallDisplayPlot(); - - void Reset(); - - void SetFrequencyRange(const double, const double, - const double, const bool, - const double units=1000.0, - const std::string &strunits = "kHz"); - double GetStartFrequency()const; - double GetStopFrequency()const; - - void PlotNewData(const double* dataPoints, const int64_t numDataPoints, - const double timePerFFT, const timespec timestamp, - const int droppedFrames); - - void SetIntensityRange(const double minIntensity, const double maxIntensity); - - virtual void replot(void); - - int GetIntensityColorMapType()const; - void SetIntensityColorMapType( const int, const QColor, const QColor ); - const QColor GetUserDefinedLowIntensityColor()const; - const QColor GetUserDefinedHighIntensityColor()const; - - 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 - }; - -public slots: - void resizeSlot( QSize *s ); - -signals: - void UpdatedLowerIntensityLevel(const double); - void UpdatedUpperIntensityLevel(const double); - -protected: - -private: - void _UpdateIntensityRangeDisplay(); - - double _startFrequency; - double _stopFrequency; - - PlotWaterfall *d_spectrogram; - - QwtPlotPanner* _panner; - QwtPlotZoomer* _zoomer; - - WaterfallData* _waterfallData; - - timespec _lastReplot; - - bool _useCenterFrequencyFlag; - - int64_t _numPoints; - - int _intensityColorMapType; - QColor _userDefinedLowIntensityColor; - QColor _userDefinedHighIntensityColor; -}; - -#endif /* WATERFALL_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/src/lib/highResTimeFunctions.h b/gr-qtgui/src/lib/highResTimeFunctions.h deleted file mode 100644 index 251bbad8b..000000000 --- a/gr-qtgui/src/lib/highResTimeFunctions.h +++ /dev/null @@ -1,299 +0,0 @@ -#ifndef HIGH_RES_TIME_FUNCTIONS_H -#define HIGH_RES_TIME_FUNCTIONS_H - -#include -#include -#include -/* Requires the librt and libm libraries */ - -static const long NSEC_PER_SEC = 1000000000L; - -static inline bool -timespec_greater(const struct timespec* t1, - const struct timespec* t0) -{ - return ((t1->tv_sec > t0->tv_sec) || - ((t1->tv_sec == t0->tv_sec) && - (t1->tv_nsec > t0->tv_nsec))); -} - -static inline bool -timespec_greater(const struct timespec t1, - const struct timespec t0) -{ - return ((t1.tv_sec > t0.tv_sec) || - ((t1.tv_sec == t0.tv_sec) && - (t1.tv_nsec > t0.tv_nsec))); -} - -static inline bool -timespec_less(const struct timespec* t1, - const struct timespec* t0) -{ - return ((t1->tv_sec < t0->tv_sec) || - ((t1->tv_sec == t0->tv_sec) && - (t1->tv_nsec < t0->tv_nsec))); -} - -static inline bool -timespec_less(const struct timespec t1, - const struct timespec t0) -{ - return ((t1.tv_sec < t0.tv_sec) || - ((t1.tv_sec == t0.tv_sec) && - (t1.tv_nsec < t0.tv_nsec))); -} - -static inline bool -timespec_equal(const struct timespec* t1, - const struct timespec* t0) -{ - return ((t1->tv_sec == t0->tv_sec) && - (t1->tv_nsec == t0->tv_nsec)); -} - -static inline bool -timespec_equal(const struct timespec t1, - const struct timespec t0) -{ - return ((t1.tv_sec == t0.tv_sec) && - (t1.tv_nsec == t0.tv_nsec)); -} - -static inline void -timespec_reset(struct timespec* ret) -{ - ret->tv_sec = 0; - ret->tv_nsec = 0; -} - -static inline void -set_normalized_timespec(struct timespec *ts, - time_t sec, long nsec) -{ - while (nsec > NSEC_PER_SEC) { - nsec -= NSEC_PER_SEC; - ++sec; - } - while(nsec < 0) { - nsec += NSEC_PER_SEC; - --sec; - } - ts->tv_sec = sec; - ts->tv_nsec = nsec; -} - -static inline struct timespec -convert_to_timespec(const double timeValue) -{ - struct timespec ret; - double seconds = 0; - long nsec = static_cast(modf(timeValue, &seconds) * - static_cast(NSEC_PER_SEC)); - time_t sec = static_cast(seconds); - - set_normalized_timespec(&ret, sec, nsec); - - return ret; -} - -static inline double -convert_from_timespec(const timespec actual) -{ - return (static_cast(actual.tv_sec) + - (static_cast(actual.tv_nsec) / - static_cast(NSEC_PER_SEC))); -} - -static inline void -timespec_add(struct timespec *ret, - const struct timespec* t1, - const struct timespec* t0) -{ - time_t sec = t1->tv_sec + t0->tv_sec; - long nsec = t1->tv_nsec + t0->tv_nsec; - - set_normalized_timespec(ret, sec, nsec); -} - -static inline void -timespec_add(struct timespec *ret, - const struct timespec t1, - const struct timespec t0) -{ - return timespec_add(ret, &t1, &t0); -} - -static inline struct timespec -timespec_add(const struct timespec t1, - const struct timespec t0) -{ - struct timespec ret; - timespec_add(&ret, &t1, &t0); - return ret; -} - -static inline struct timespec -timespec_add(const struct timespec t1, - const double time0) -{ - struct timespec ret; - struct timespec t0; - t0 = convert_to_timespec(time0); - - timespec_add(&ret, &t1, &t0); - - return ret; -} - -static inline void -timespec_subtract(struct timespec *ret, - const struct timespec* t1, - const struct timespec* t0) -{ - time_t sec = t1->tv_sec - t0->tv_sec; - long nsec = t1->tv_nsec - t0->tv_nsec; - - set_normalized_timespec(ret, sec, nsec); -} - -static inline void -timespec_subtract(struct timespec *ret, - const struct timespec t1, - const struct timespec t0) -{ - return timespec_subtract(ret, &t1, &t0); -} - -static inline struct timespec -timespec_subtract(const struct timespec t1, - const struct timespec t0) -{ - struct timespec ret; - timespec_subtract(&ret, &t1, &t0); - return ret; -} - -static inline struct timespec -timespec_subtract(const struct timespec t1, - const double time0) -{ - struct timespec ret; - struct timespec t0; - t0 = convert_to_timespec(time0); - - timespec_subtract(&ret, &t1, &t0); - - return ret; -} - -static inline double -diff_timespec(struct timespec* ret, - const struct timespec *t1, - const struct timespec* t0) -{ - struct timespec actual; - time_t sec = 0; - long nsec = 0; - - if(timespec_greater(t1, t0)){ - sec = t1->tv_sec - t0->tv_sec; - nsec = t1->tv_nsec - t0->tv_nsec; - - set_normalized_timespec(&actual, sec, nsec); - - if(ret != NULL){ - ret->tv_sec = actual.tv_sec; - ret->tv_nsec = actual.tv_nsec; - } - - return convert_from_timespec(actual); - } - else{ - sec = t0->tv_sec - t1->tv_sec; - nsec = t0->tv_nsec - t1->tv_nsec; - - // Do nothing with the ret value as the ret value - // would have to store a negative, which it can't. - - set_normalized_timespec(&actual, sec, nsec); - - return (-convert_from_timespec(actual)); - } -} - -static inline double -diff_timespec(struct timespec* ret, - const struct timespec t1, - const struct timespec t0) -{ - return diff_timespec(ret, &t1, &t0); -} - -static inline double -diff_timespec(const struct timespec t1, - const struct timespec t0) -{ - return diff_timespec(NULL, &t1, &t0); -} - - -static inline double -diff_timespec(const struct timespec* t1, - const struct timespec* t0) -{ - return diff_timespec(NULL, t1, t0); -} - - -#ifdef CLOCK_REALTIME -// If we can use clock_gettime, use it; -// otherwise, use gettimeofday -static inline void -get_highres_clock(struct timespec* ret) -{ - if(clock_gettime(CLOCK_REALTIME, ret) != 0){ - // Unable to get high resolution time - - // fail over to low resolution time - timeval lowResTime; - gettimeofday(&lowResTime, NULL); - ret->tv_sec = lowResTime.tv_sec; - ret->tv_nsec = lowResTime.tv_usec*1000; - } -} - -#else - -// Trick timer functions into thinking it has an nsec timer -// but only use the low resolution (usec) timer. -static inline void -get_highres_clock(struct timespec* ret) -{ - timeval lowResTime; - gettimeofday(&lowResTime, NULL); - ret->tv_sec = lowResTime.tv_sec; - ret->tv_nsec = lowResTime.tv_usec*1000; -} -#endif - -static inline struct timespec -get_highres_clock() -{ - struct timespec ret; - get_highres_clock(&ret); - return ret; -} - -static inline bool -timespec_empty(const struct timespec* ret) -{ - return ( (ret->tv_sec == 0 ) && (ret->tv_nsec == 0) ); -} - -static inline bool -timespec_empty(const struct timespec ret) -{ - return timespec_empty(&ret); -} - -#endif /* HIGH_RES_TIME_FUNCTIONS_H */ diff --git a/gr-qtgui/src/lib/plot_waterfall.cc b/gr-qtgui/src/lib/plot_waterfall.cc deleted file mode 100644 index 2b1447e03..000000000 --- a/gr-qtgui/src/lib/plot_waterfall.cc +++ /dev/null @@ -1,325 +0,0 @@ -#include -#include -#include -#include "qwt_painter.h" -#include "qwt_double_interval.h" -#include "qwt_scale_map.h" -#include "qwt_color_map.h" -#include "plot_waterfall.h" - -#if QT_VERSION < 0x040000 -typedef Q3ValueVector QwtColorTable; -#else -typedef QVector QwtColorTable; -#endif - - -class PlotWaterfallImage: public QImage -{ - // This class hides some Qt3/Qt4 API differences -public: - PlotWaterfallImage(const QSize &size, QwtColorMap::Format format): -#if QT_VERSION < 0x040000 - QImage(size, format == QwtColorMap::RGB ? 32 : 8) -#else - QImage(size, format == QwtColorMap::RGB - ? QImage::Format_ARGB32 : QImage::Format_Indexed8 ) -#endif - { - } - - PlotWaterfallImage(const QImage &other): - QImage(other) - { - } - - void initColorTable(const QImage& other) - { -#if QT_VERSION < 0x040000 - const unsigned int numColors = other.numColors(); - - setNumColors(numColors); - for ( unsigned int i = 0; i < numColors; i++ ) - setColor(i, other.color(i)); -#else - setColorTable(other.colorTable()); -#endif - } - -#if QT_VERSION < 0x040000 - - void setColorTable(const QwtColorTable &colorTable) - { - setNumColors(colorTable.size()); - for ( unsigned int i = 0; i < colorTable.size(); i++ ) - setColor(i, colorTable[i]); - } - - QwtColorTable colorTable() const - { - QwtColorTable table(numColors()); - for ( int i = 0; i < numColors(); i++ ) - table[i] = color(i); - - return table; - } -#endif -}; - -class PlotWaterfall::PrivateData -{ -public: - PrivateData() - { - data = NULL; - colorMap = new QwtLinearColorMap(); - } - ~PrivateData() - { - delete colorMap; - } - - WaterfallData *data; - QwtColorMap *colorMap; -}; - -/*! - Sets the following item attributes: - - QwtPlotItem::AutoScale: true - - QwtPlotItem::Legend: false - - The z value is initialized by 8.0. - - \param title Title - - \sa QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ() -*/ -PlotWaterfall::PlotWaterfall(WaterfallData* data, const QString &title): - QwtPlotRasterItem(title) -{ - d_data = new PrivateData(); - d_data->data = data; - -// setCachePolicy(QwtPlotRasterItem::PaintCache); - - setItemAttribute(QwtPlotItem::AutoScale, true); - setItemAttribute(QwtPlotItem::Legend, false); - - setZ(8.0); -} - -//! Destructor -PlotWaterfall::~PlotWaterfall() -{ - delete d_data; -} - -const WaterfallData* PlotWaterfall::data()const{ - return d_data->data; -} - -//! \return QwtPlotItem::Rtti_PlotSpectrogram -int PlotWaterfall::rtti() const -{ - return QwtPlotItem::Rtti_PlotSpectrogram; -} - -/*! - Change the color map - - Often it is useful to display the mapping between intensities and - colors as an additional plot axis, showing a color bar. - - \param colorMap Color Map - - \sa colorMap(), QwtScaleWidget::setColorBarEnabled(), - QwtScaleWidget::setColorMap() -*/ -void PlotWaterfall::setColorMap(const QwtColorMap &colorMap) -{ - delete d_data->colorMap; - d_data->colorMap = colorMap.copy(); - - invalidateCache(); - itemChanged(); -} - -/*! - \return Color Map used for mapping the intensity values to colors - \sa setColorMap() -*/ -const QwtColorMap &PlotWaterfall::colorMap() const -{ - return *d_data->colorMap; -} -/*! - \return Bounding rect of the data - \sa QwtRasterData::boundingRect -*/ -QwtDoubleRect PlotWaterfall::boundingRect() const -{ - return d_data->data->boundingRect(); -} - -/*! - \brief Returns the recommended raster for a given rect. - - F.e the raster hint is used to limit the resolution of - the image that is rendered. - - \param rect Rect for the raster hint - \return data().rasterHint(rect) -*/ -QSize PlotWaterfall::rasterHint(const QwtDoubleRect &rect) const -{ - return d_data->data->rasterHint(rect); -} - -/*! - \brief Render an image from the data and color map. - - The area is translated into a rect of the paint device. - For each pixel of this rect the intensity is mapped - into a color. - - \param xMap X-Scale Map - \param yMap Y-Scale Map - \param area Area that should be rendered in scale coordinates. - - \return A QImage::Format_Indexed8 or QImage::Format_ARGB32 depending - on the color map. - - \sa QwtRasterData::intensity(), QwtColorMap::rgb(), - QwtColorMap::colorIndex() -*/ -QImage PlotWaterfall::renderImage( - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QwtDoubleRect &area) const -{ - if ( area.isEmpty() ) - return QImage(); - - QRect rect = transform(xMap, yMap, area); - - QwtScaleMap xxMap = xMap; - QwtScaleMap yyMap = yMap; - - const QSize res = d_data->data->rasterHint(area); - if ( res.isValid() ) - { - /* - It is useless to render an image with a higher resolution - than the data offers. Of course someone will have to - scale this image later into the size of the given rect, but f.e. - in case of postscript this will done on the printer. - */ - rect.setSize(rect.size().boundedTo(res)); - - int px1 = rect.x(); - int px2 = rect.x() + rect.width(); - if ( xMap.p1() > xMap.p2() ) - qSwap(px1, px2); - - double sx1 = area.x(); - double sx2 = area.x() + area.width(); - if ( xMap.s1() > xMap.s2() ) - qSwap(sx1, sx2); - - int py1 = rect.y(); - int py2 = rect.y() + rect.height(); - if ( yMap.p1() > yMap.p2() ) - qSwap(py1, py2); - - double sy1 = area.y(); - double sy2 = area.y() + area.height(); - if ( yMap.s1() > yMap.s2() ) - qSwap(sy1, sy2); - - xxMap.setPaintInterval(px1, px2); - xxMap.setScaleInterval(sx1, sx2); - yyMap.setPaintInterval(py1, py2); - yyMap.setScaleInterval(sy1, sy2); - } - - PlotWaterfallImage image(rect.size(), d_data->colorMap->format()); - - const QwtDoubleInterval intensityRange = d_data->data->range(); - if ( !intensityRange.isValid() ) - return image; - - d_data->data->initRaster(area, rect.size()); - - if ( d_data->colorMap->format() == QwtColorMap::RGB ) - { - for ( int y = rect.top(); y <= rect.bottom(); y++ ) - { - const double ty = yyMap.invTransform(y); - - QRgb *line = (QRgb *)image.scanLine(y - rect.top()); - for ( int x = rect.left(); x <= rect.right(); x++ ) - { - const double tx = xxMap.invTransform(x); - - *line++ = d_data->colorMap->rgb(intensityRange, - d_data->data->value(tx, ty)); - } - } - } - else if ( d_data->colorMap->format() == QwtColorMap::Indexed ) - { - image.setColorTable(d_data->colorMap->colorTable(intensityRange)); - - for ( int y = rect.top(); y <= rect.bottom(); y++ ) - { - const double ty = yyMap.invTransform(y); - - unsigned char *line = image.scanLine(y - rect.top()); - for ( int x = rect.left(); x <= rect.right(); x++ ) - { - const double tx = xxMap.invTransform(x); - - *line++ = d_data->colorMap->colorIndex(intensityRange, - d_data->data->value(tx, ty)); - } - } - } - - d_data->data->discardRaster(); - - // Mirror the image in case of inverted maps - - const bool hInvert = xxMap.p1() > xxMap.p2(); - const bool vInvert = yyMap.p1() < yyMap.p2(); - if ( hInvert || vInvert ) - { -#ifdef __GNUC__ -#endif -#if QT_VERSION < 0x040000 - image = image.mirror(hInvert, vInvert); -#else - image = image.mirrored(hInvert, vInvert); -#endif - } - - return image; -} - -/*! - \brief Draw the spectrogram - - \param painter Painter - \param xMap Maps x-values into pixel coordinates. - \param yMap Maps y-values into pixel coordinates. - \param canvasRect Contents rect of the canvas in painter coordinates - - \sa setDisplayMode, renderImage, - QwtPlotRasterItem::draw, drawContourLines -*/ - -void PlotWaterfall::draw(QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRect &canvasRect) const -{ - QwtPlotRasterItem::draw(painter, xMap, yMap, canvasRect); -} - diff --git a/gr-qtgui/src/lib/plot_waterfall.h b/gr-qtgui/src/lib/plot_waterfall.h deleted file mode 100644 index a11461611..000000000 --- a/gr-qtgui/src/lib/plot_waterfall.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef PLOT_WATERFALL_H -#define PLOT_WATERFALL_H - -#include -#include - -#include "qwt_valuelist.h" -#include "qwt_plot_rasteritem.h" - -class QwtColorMap; - -/*! - \brief A plot item, which displays a waterfall spectrogram - - 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; - - virtual QwtDoubleRect boundingRect() const; - virtual QSize rasterHint(const QwtDoubleRect &) const; - - virtual int rtti() const; - - virtual void draw(QPainter *p, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRect &rect) const; - -protected: - virtual QImage renderImage( - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QwtDoubleRect &rect) const; - -private: - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/gr-qtgui/src/lib/qtgui.h b/gr-qtgui/src/lib/qtgui.h deleted file mode 100644 index 9831697ac..000000000 --- a/gr-qtgui/src/lib/qtgui.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- 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 INCLUDED_QTGUI_H -#define INCLUDED_QTGUI_H - -#include -#include -#include "SpectrumGUIClass.h" - -class qtgui_event : public QEvent -{ -private: - gruel::mutex &d_mutex; - -public: - qtgui_event(gruel::mutex &mutex) - : QEvent((QEvent::Type)(QEvent::User+101)), - d_mutex(mutex) - { - //nop - } - - void lock() - { - d_mutex.lock(); - } - - void unlock() - { - d_mutex.unlock(); - } -}; - -class qtgui_obj : public QObject -{ -public: - qtgui_obj(QObject *p) - : QObject(p) - { - } - - void customEvent(QEvent *e) - { - if(e->type() == (QEvent::Type)(QEvent::User+101)) { - qtgui_event *qt = (qtgui_event*)e; - qt->unlock(); - } - } -}; - -#endif /* INCLUDED_QTGUI_H */ diff --git a/gr-qtgui/src/lib/qtgui.i b/gr-qtgui/src/lib/qtgui.i deleted file mode 100644 index bb64c6ae2..000000000 --- a/gr-qtgui/src/lib/qtgui.i +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 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. - */ - -%include "gnuradio.i" - -%{ -#include "qtgui_sink_c.h" -#include "qtgui_sink_f.h" -%} - -GR_SWIG_BLOCK_MAGIC(qtgui,sink_c) - - qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, - double fc=0, double bw=1.0, - const std::string &name="Display", - bool plotfreq=true, bool plotwaterfall=true, - bool plotwaterfall3d=true, bool plottime=true, - bool plotconst=true, - bool use_openGL=true, - QWidget *parent=NULL); - -class qtgui_sink_c : public gr_block -{ -private: - friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - qtgui_sink_c (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - -public: - void exec_(); - PyObject* pyqwidget(); - - void set_frequency_range(const double centerfreq, - const double bandwidth); - void set_time_domain_axis(double min, double max); - void set_constellation_axis(double xmin, double xmax, - double ymin, double ymax); - void set_frequency_axis(double min, double max); - void set_constellation_pen_size(int size); -}; - - - -/*********************************************************************/ - - -GR_SWIG_BLOCK_MAGIC(qtgui,sink_f) - -qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, - double fc=0, double bw=0.0, - const std::string &name="Display", - bool plotfreq=true, bool plotwaterfall=true, - bool plotwaterfall3d=true, bool plottime=true, - bool plotconst=true, - bool use_openGL=true, - QWidget *parent=NULL); - -class qtgui_sink_f : public gr_block -{ -private: - friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - qtgui_sink_f (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - -public: - void exec_(); - PyObject* pyqwidget(); - - void set_frequency_range(const double centerfreq, - const double bandwidth); - void set_time_domain_axis(double min, double max); - void set_constellation_axis(double xmin, double xmax, - double ymin, double ymax); - void set_frequency_axis(double min, double max); - void set_constellation_pen_size(int size); -}; - -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-qtgui" "scm_init_gnuradio_qtgui_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif diff --git a/gr-qtgui/src/lib/qtgui_sink_c.cc b/gr-qtgui/src/lib/qtgui_sink_c.cc deleted file mode 100644 index 05c7b28d5..000000000 --- a/gr-qtgui/src/lib/qtgui_sink_c.cc +++ /dev/null @@ -1,326 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009,2010,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. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include - -qtgui_sink_c_sptr -qtgui_make_sink_c (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent) -{ - return gnuradio::get_initial_sptr(new qtgui_sink_c (fftsize, wintype, - fc, bw, name, - plotfreq, plotwaterfall, - plotwaterfall3d, plottime, - plotconst, - use_openGL, - parent)); -} - -qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent) - : gr_block ("sink_c", - gr_make_io_signature (1, -1, sizeof(gr_complex)), - gr_make_io_signature (0, 0, 0)), - d_fftsize(fftsize), - d_wintype((gr_firdes::win_type)(wintype)), - d_center_freq(fc), d_bandwidth(bw), d_name(name), - d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall), - d_plottime(plottime), d_plotconst(plotconst), - d_parent(parent) -{ - if(plotwaterfall3d == true) { - fprintf(stderr, "Warning: plotting Waterfall3D has been removed; enabling plotwaterfall3d has no effect.\n"); - } - - d_main_gui = NULL; - lock(); - - // Perform fftshift operation; - // this is usually desired when plotting - d_shift = true; - - d_fft = new gri_fft_complex (d_fftsize, true); - - d_index = 0; - d_residbuf = new gr_complex[d_fftsize]; - - buildwindow(); - - initialize(use_openGL); -} - -qtgui_sink_c::~qtgui_sink_c() -{ - delete d_main_gui; - delete [] d_residbuf; - delete d_fft; -} - -void -qtgui_sink_c::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned int ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) { - ninput_items_required[i] = std::min(d_fftsize, 8191); - } -} - -void qtgui_sink_c::lock() -{ - d_mutex.lock(); -} - -void qtgui_sink_c::unlock() -{ - d_mutex.unlock(); -} - - -void -qtgui_sink_c::initialize(const bool opengl) -{ - if(qApp != NULL) { - d_qApplication = qApp; - } - else { - int argc; - char **argv = NULL; - d_qApplication = new QApplication(argc, argv); - } - - if(d_center_freq < 0) { - throw std::runtime_error("qtgui_sink_c: Received bad center frequency.\n"); - } - - uint64_t maxBufferSize = 32768; - d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize, - d_center_freq, - -d_bandwidth/2.0, - d_bandwidth/2.0); - - d_main_gui->SetDisplayTitle(d_name); - d_main_gui->SetFFTSize(d_fftsize); - d_main_gui->SetWindowType((int)d_wintype); - - d_main_gui->OpenSpectrumWindow(d_parent, - d_plotfreq, d_plotwaterfall, - d_plottime, d_plotconst, - opengl); - - // initialize update time to 10 times a second - set_update_time(0.1); - - d_object = new qtgui_obj(d_qApplication); - qApp->postEvent(d_object, new qtgui_event(d_mutex)); -} - - -void -qtgui_sink_c::exec_() -{ - d_qApplication->exec(); -} - -QWidget* -qtgui_sink_c::qwidget() -{ - return d_main_gui->qwidget(); -} - -PyObject* -qtgui_sink_c::pyqwidget() -{ - PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui->qwidget()); - PyObject *retarg = Py_BuildValue("N", w); - return retarg; -} - -void -qtgui_sink_c::set_frequency_range(const double centerfreq, - const double bandwidth) -{ - d_center_freq = centerfreq; - d_bandwidth = bandwidth; - d_main_gui->SetFrequencyRange(d_center_freq, - -d_bandwidth/2.0, - d_bandwidth/2.0); -} - -void -qtgui_sink_c::set_time_domain_axis(double min, double max) -{ - d_main_gui->SetTimeDomainAxis(min, max); -} - -void -qtgui_sink_c::set_constellation_axis(double xmin, double xmax, - double ymin, double ymax) -{ - d_main_gui->SetConstellationAxis(xmin, xmax, ymin, ymax); -} - -void -qtgui_sink_c::set_constellation_pen_size(int size) -{ - d_main_gui->SetConstellationPenSize(size); -} - - -void -qtgui_sink_c::set_frequency_axis(double min, double max) -{ - d_main_gui->SetFrequencyAxis(min, max); -} - -void -qtgui_sink_c::set_update_time(double t) -{ - d_update_time = t; - d_main_gui->SetUpdateTime(d_update_time); -} - -void -qtgui_sink_c::fft(const gr_complex *data_in, int size) -{ - if (d_window.size()) { - gr_complex *dst = d_fft->get_inbuf(); - int i; - for (i = 0; i < size; i++) // apply window - dst[i] = data_in[i] * d_window[i]; - } - else { - memcpy (d_fft->get_inbuf(), data_in, sizeof(gr_complex)*size); - } - - d_fft->execute (); // compute the fft -} - -void -qtgui_sink_c::windowreset() -{ - gr_firdes::win_type newwintype = (gr_firdes::win_type)d_main_gui->GetWindowType(); - if(d_wintype != newwintype) { - d_wintype = newwintype; - buildwindow(); - } -} - -void -qtgui_sink_c::buildwindow() -{ - d_window.clear(); - if(d_wintype != 0) { - d_window = gr_firdes::window(d_wintype, d_fftsize, 6.76); - } -} - -void -qtgui_sink_c::fftresize() -{ - int newfftsize = d_main_gui->GetFFTSize(); - - if(newfftsize != d_fftsize) { - - // Resize residbuf and replace data - delete [] d_residbuf; - d_residbuf = new gr_complex[newfftsize]; - - // Set new fft size and reset buffer index - // (throws away any currently held data, but who cares?) - d_fftsize = newfftsize; - d_index = 0; - - // Reset window to reflect new size - buildwindow(); - - // Reset FFTW plan for new size - delete d_fft; - d_fft = new gri_fft_complex (d_fftsize, true); - } -} - - -int -qtgui_sink_c::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - int j=0; - const gr_complex *in = (const gr_complex*)input_items[0]; - - gruel::scoped_lock lock(d_mutex); - - // Update the FFT size from the application - fftresize(); - windowreset(); - - for(int i=0; i < noutput_items; i+=d_fftsize) { - unsigned int datasize = noutput_items - i; - unsigned int resid = d_fftsize-d_index; - - // If we have enough input for one full FFT, do it - if(datasize >= resid) { - const timespec currentTime = get_highres_clock(); - - // Fill up residbuf with d_fftsize number of items - memcpy(d_residbuf+d_index, &in[j], sizeof(gr_complex)*resid); - d_index = 0; - - j += resid; - fft(d_residbuf, d_fftsize); - - d_main_gui->UpdateWindow(true, d_fft->get_outbuf(), d_fftsize, - NULL, 0, (float*)d_residbuf, d_fftsize, - currentTime, true); - } - // Otherwise, copy what we received into the residbuf for next time - else { - memcpy(d_residbuf+d_index, &in[j], sizeof(gr_complex)*datasize); - d_index += datasize; - j += datasize; - } - } - - consume_each(j); - return j; -} diff --git a/gr-qtgui/src/lib/qtgui_sink_c.h b/gr-qtgui/src/lib/qtgui_sink_c.h deleted file mode 100644 index bbf9983b0..000000000 --- a/gr-qtgui/src/lib/qtgui_sink_c.h +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009,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_SINK_C_H -#define INCLUDED_QTGUI_SINK_C_H - -#include -#include -#include -#include -#include -#include -#include "SpectrumGUIClass.h" - -class qtgui_sink_c; -typedef boost::shared_ptr qtgui_sink_c_sptr; - -qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, - double fc=0, double bandwidth=1.0, - const std::string &name="Spectrum Display", - bool plotfreq=true, bool plotwaterfall=true, - bool plotwaterfall3d=true, bool plottime=true, - bool plotconst=true, - bool use_openGL=true, - QWidget *parent=NULL); - -class qtgui_sink_c : public gr_block -{ -private: - friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - qtgui_sink_c (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - - // use opengl to force OpenGL on or off - // this might be necessary for sessions over SSH - void initialize(const bool opengl=true); - - int d_fftsize; - gr_firdes::win_type d_wintype; - std::vector d_window; - double d_center_freq; - double d_bandwidth; - std::string d_name; - - gruel::mutex d_mutex; - - bool d_shift; - gri_fft_complex *d_fft; - - int d_index; - gr_complex *d_residbuf; - - bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst; - - double d_update_time; - - QWidget *d_parent; - SpectrumGUIClass *d_main_gui; - - void windowreset(); - void buildwindow(); - void fftresize(); - void fft(const gr_complex *data_in, int size); - -public: - ~qtgui_sink_c(); - void exec_(); - void lock(); - void unlock(); - QWidget* qwidget(); - PyObject* pyqwidget(); - - void set_frequency_range(const double centerfreq, - const double bandwidth); - - 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); - void set_frequency_axis(double min, double max); - - void set_update_time(double t); - - QApplication *d_qApplication; - qtgui_obj *d_object; - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_QTGUI_SINK_C_H */ diff --git a/gr-qtgui/src/lib/qtgui_sink_f.cc b/gr-qtgui/src/lib/qtgui_sink_f.cc deleted file mode 100644 index 984c2803c..000000000 --- a/gr-qtgui/src/lib/qtgui_sink_f.cc +++ /dev/null @@ -1,321 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009,2010,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. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include - -qtgui_sink_f_sptr -qtgui_make_sink_f (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent) -{ - return gnuradio::get_initial_sptr(new qtgui_sink_f (fftsize, wintype, - fc, bw, name, - plotfreq, plotwaterfall, - plotwaterfall3d, plottime, - plotconst, - use_openGL, - parent)); -} - -qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent) - : gr_block ("sink_f", - gr_make_io_signature (1, 1, sizeof(float)), - gr_make_io_signature (0, 0, 0)), - d_fftsize(fftsize), - d_wintype((gr_firdes::win_type)(wintype)), - d_center_freq(fc), d_bandwidth(bw), d_name(name), - d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall), - d_plottime(plottime), d_plotconst(plotconst), - d_parent(parent) -{ - if(plotwaterfall3d == true) { - fprintf(stderr, "Warning: plotting Waterfall3D has been removed; enabling plotwaterfall3d has no effect.\n"); - } - - d_main_gui = NULL; - lock(); - - // Perform fftshift operation; - // this is usually desired when plotting - d_shift = true; - - d_fft = new gri_fft_complex (d_fftsize, true); - - d_index = 0; - d_residbuf = new float[d_fftsize]; - - buildwindow(); - - initialize(use_openGL); -} - -qtgui_sink_f::~qtgui_sink_f() -{ - delete d_main_gui; - delete [] d_residbuf; - delete d_fft; -} - -void -qtgui_sink_f::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned int ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) { - ninput_items_required[i] = std::min(d_fftsize, 8191); - } -} - -void qtgui_sink_f::lock() -{ - d_mutex.lock(); -} - -void qtgui_sink_f::unlock() -{ - d_mutex.unlock(); -} - -void -qtgui_sink_f::initialize(const bool opengl) -{ - if(qApp != NULL) { - d_qApplication = qApp; - } - else { - int argc; - char **argv = NULL; - d_qApplication = new QApplication(argc, argv); - } - - - uint64_t maxBufferSize = 32768; - d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize, - d_center_freq, - -d_bandwidth/2.0, - d_bandwidth/2.0); - d_main_gui->SetDisplayTitle(d_name); - d_main_gui->SetFFTSize(d_fftsize); - d_main_gui->SetWindowType((int)d_wintype); - - d_main_gui->OpenSpectrumWindow(d_parent, - d_plotfreq, d_plotwaterfall, - d_plottime, d_plotconst, - opengl); - - // initialize update time to 10 times a second - set_update_time(0.1); - - d_object = new qtgui_obj(d_qApplication); - qApp->postEvent(d_object, new qtgui_event(d_mutex)); -} - -void -qtgui_sink_f::exec_() -{ - d_qApplication->exec(); -} - -QWidget* -qtgui_sink_f::qwidget() -{ - return d_main_gui->qwidget(); -} - -PyObject* -qtgui_sink_f::pyqwidget() -{ - PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui->qwidget()); - PyObject *retarg = Py_BuildValue("N", w); - return retarg; -} - -void -qtgui_sink_f::set_frequency_range(const double centerfreq, - const double bandwidth) -{ - d_center_freq = centerfreq; - d_bandwidth = bandwidth; - d_main_gui->SetFrequencyRange(d_center_freq, - -d_bandwidth/2.0, - d_bandwidth/2.0); -} - -void -qtgui_sink_f::set_time_domain_axis(double min, double max) -{ - d_main_gui->SetTimeDomainAxis(min, max); -} - -void -qtgui_sink_f::set_constellation_axis(double xmin, double xmax, - double ymin, double ymax) -{ - d_main_gui->SetConstellationAxis(xmin, xmax, ymin, ymax); -} - -void -qtgui_sink_f::set_constellation_pen_size(int size) -{ - d_main_gui->SetConstellationPenSize(size); -} - - -void -qtgui_sink_f::set_frequency_axis(double min, double max) -{ - d_main_gui->SetFrequencyAxis(min, max); -} - -void -qtgui_sink_f::set_update_time(double t) -{ - d_update_time = t; - d_main_gui->SetUpdateTime(d_update_time); -} - -void -qtgui_sink_f::fft(const float *data_in, int size) -{ - if (d_window.size()) { - gr_complex *dst = d_fft->get_inbuf(); - for (int i = 0; i < size; i++) // apply window - dst[i] = data_in[i] * d_window[i]; - } - else { - gr_complex *dst = d_fft->get_inbuf(); - for (int i = 0; i < size; i++) // float to complex conversion - dst[i] = data_in[i]; - } - - d_fft->execute (); // compute the fft -} - -void -qtgui_sink_f::windowreset() -{ - gr_firdes::win_type newwintype = (gr_firdes::win_type)d_main_gui->GetWindowType(); - if(d_wintype != newwintype) { - d_wintype = newwintype; - buildwindow(); - } -} - -void -qtgui_sink_f::buildwindow() -{ - d_window.clear(); - if(d_wintype != 0) { - d_window = gr_firdes::window(d_wintype, d_fftsize, 6.76); - } -} - -void -qtgui_sink_f::fftresize() -{ - int newfftsize = d_main_gui->GetFFTSize(); - - if(newfftsize != d_fftsize) { - - // Resize residbuf and replace data - delete [] d_residbuf; - d_residbuf = new float[newfftsize]; - - // Set new fft size and reset buffer index - // (throws away any currently held data, but who cares?) - d_fftsize = newfftsize; - d_index = 0; - - // Reset window to reflect new size - buildwindow(); - - // Reset FFTW plan for new size - delete d_fft; - d_fft = new gri_fft_complex (d_fftsize, true); - } -} - - -int -qtgui_sink_f::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - int j=0; - const float *in = (const float*)input_items[0]; - - gruel::scoped_lock lock(d_mutex); - - // Update the FFT size from the application - fftresize(); - windowreset(); - - for(int i=0; i < noutput_items; i+=d_fftsize) { - unsigned int datasize = noutput_items - i; - unsigned int resid = d_fftsize-d_index; - - // If we have enough input for one full FFT, do it - if(datasize >= resid) { - const timespec currentTime = get_highres_clock(); - - // Fill up residbuf with d_fftsize number of items - memcpy(d_residbuf+d_index, &in[j], sizeof(float)*resid); - d_index = 0; - - j += resid; - fft(d_residbuf, d_fftsize); - - d_main_gui->UpdateWindow(true, d_fft->get_outbuf(), d_fftsize, - (float*)d_residbuf, d_fftsize, NULL, 0, - currentTime, true); - } - // Otherwise, copy what we received into the residbuf for next time - else { - memcpy(d_residbuf+d_index, &in[j], sizeof(float)*datasize); - d_index += datasize; - j += datasize; - } - } - - consume_each(j); - return j; -} diff --git a/gr-qtgui/src/lib/qtgui_sink_f.h b/gr-qtgui/src/lib/qtgui_sink_f.h deleted file mode 100644 index d80a6a198..000000000 --- a/gr-qtgui/src/lib/qtgui_sink_f.h +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009,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_SINK_F_H -#define INCLUDED_QTGUI_SINK_F_H - -#include -#include -#include -#include -#include -#include -#include "SpectrumGUIClass.h" - -class qtgui_sink_f; -typedef boost::shared_ptr qtgui_sink_f_sptr; - -qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, - double fc=0, double bw=1.0, - const std::string &name="Spectrum Display", - bool plotfreq=true, bool plotwaterfall=true, - bool plotwaterfall3d=true, bool plottime=true, - bool plotconst=true, - bool use_openGL=true, - QWidget *parent=NULL); - -class qtgui_sink_f : public gr_block -{ -private: - friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - qtgui_sink_f (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - - void initialize(const bool opengl=true); - - int d_fftsize; - gr_firdes::win_type d_wintype; - std::vector d_window; - double d_center_freq; - double d_bandwidth; - std::string d_name; - - gruel::mutex d_mutex; - - bool d_shift; - gri_fft_complex *d_fft; - - int d_index; - float *d_residbuf; - - bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst; - - double d_update_time; - - QWidget *d_parent; - SpectrumGUIClass *d_main_gui; - - void windowreset(); - void buildwindow(); - void fftresize(); - void fft(const float *data_in, int size); - -public: - ~qtgui_sink_f(); - void exec_(); - void lock(); - void unlock(); - QWidget* qwidget(); - PyObject* pyqwidget(); - - void set_frequency_range(const double centerfreq, - const double bandwidth); - - 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); - void set_frequency_axis(double min, double max); - - void set_update_time(double t); - - QApplication *d_qApplication; - qtgui_obj *d_object; - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_QTGUI_SINK_F_H */ diff --git a/gr-qtgui/src/lib/spectrumUpdateEvents.cc b/gr-qtgui/src/lib/spectrumUpdateEvents.cc deleted file mode 100644 index 53a205fb7..000000000 --- a/gr-qtgui/src/lib/spectrumUpdateEvents.cc +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef SPECTRUM_UPDATE_EVENTS_C -#define SPECTRUM_UPDATE_EVENTS_C - -#include - -SpectrumUpdateEvent::SpectrumUpdateEvent(const std::complex* fftPoints, - const uint64_t numFFTDataPoints, - const double* realTimeDomainPoints, - const double* imagTimeDomainPoints, - const uint64_t numTimeDomainDataPoints, - const timespec dataTimestamp, - const bool repeatDataFlag, - const bool lastOfMultipleUpdateFlag, - const timespec generatedTimestamp, - const int droppedFFTFrames) - : QEvent(QEvent::Type(10005)) -{ - if(numFFTDataPoints < 1) { - _numFFTDataPoints = 1; - } - else { - _numFFTDataPoints = numFFTDataPoints; - } - - if(numTimeDomainDataPoints < 1) { - _numTimeDomainDataPoints = 1; - } - else { - _numTimeDomainDataPoints = numTimeDomainDataPoints; - } - - _fftPoints = new std::complex[_numFFTDataPoints]; - _fftPoints[0] = std::complex(0,0); - memcpy(_fftPoints, fftPoints, numFFTDataPoints*sizeof(std::complex)); - - _realDataTimeDomainPoints = new double[_numTimeDomainDataPoints]; - memset(_realDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double)); - if(numTimeDomainDataPoints > 0) { - memcpy(_realDataTimeDomainPoints, realTimeDomainPoints, - numTimeDomainDataPoints*sizeof(double)); - } - - _imagDataTimeDomainPoints = new double[_numTimeDomainDataPoints]; - memset(_imagDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double)); - if(numTimeDomainDataPoints > 0) { - memcpy(_imagDataTimeDomainPoints, imagTimeDomainPoints, - numTimeDomainDataPoints*sizeof(double)); - } - _dataTimestamp = dataTimestamp; - _repeatDataFlag = repeatDataFlag; - _lastOfMultipleUpdateFlag = lastOfMultipleUpdateFlag; - _eventGeneratedTimestamp = generatedTimestamp; - _droppedFFTFrames = droppedFFTFrames; -} - -SpectrumUpdateEvent::~SpectrumUpdateEvent() -{ - delete[] _fftPoints; - delete[] _realDataTimeDomainPoints; - delete[] _imagDataTimeDomainPoints; -} - -const std::complex* -SpectrumUpdateEvent::getFFTPoints() const -{ - return _fftPoints; -} - -const double* -SpectrumUpdateEvent::getRealTimeDomainPoints() const -{ - return _realDataTimeDomainPoints; -} - -const double* -SpectrumUpdateEvent::getImagTimeDomainPoints() const -{ - return _imagDataTimeDomainPoints; -} - -uint64_t -SpectrumUpdateEvent::getNumFFTDataPoints() const -{ - return _numFFTDataPoints; -} - -uint64_t -SpectrumUpdateEvent::getNumTimeDomainDataPoints() const -{ - return _numTimeDomainDataPoints; -} - -timespec -SpectrumUpdateEvent::getDataTimestamp() const -{ - return _dataTimestamp; -} - -bool -SpectrumUpdateEvent::getRepeatDataFlag() const -{ - return _repeatDataFlag; -} - -bool -SpectrumUpdateEvent::getLastOfMultipleUpdateFlag() const -{ - return _lastOfMultipleUpdateFlag; -} - -timespec -SpectrumUpdateEvent::getEventGeneratedTimestamp() const -{ - return _eventGeneratedTimestamp; -} - -int -SpectrumUpdateEvent::getDroppedFFTFrames() const -{ - return _droppedFFTFrames; -} - -SpectrumWindowCaptionEvent::SpectrumWindowCaptionEvent(const QString& newLbl) - : QEvent(QEvent::Type(10008)) -{ - _labelString = newLbl; -} - -SpectrumWindowCaptionEvent::~SpectrumWindowCaptionEvent() -{ -} - -QString -SpectrumWindowCaptionEvent::getLabel() -{ - return _labelString; -} - -SpectrumWindowResetEvent::SpectrumWindowResetEvent() - : QEvent(QEvent::Type(10009)) -{ -} - -SpectrumWindowResetEvent::~SpectrumWindowResetEvent() -{ -} - -SpectrumFrequencyRangeEvent::SpectrumFrequencyRangeEvent(const double centerFreq, - const double startFreq, - const double stopFreq) - : QEvent(QEvent::Type(10010)) -{ - _centerFrequency = centerFreq; - _startFrequency = startFreq; - _stopFrequency = stopFreq; -} - -SpectrumFrequencyRangeEvent::~SpectrumFrequencyRangeEvent() -{ -} - -double -SpectrumFrequencyRangeEvent::GetCenterFrequency() const -{ - return _centerFrequency; -} - -double -SpectrumFrequencyRangeEvent::GetStartFrequency() const -{ - return _startFrequency; -} - -double -SpectrumFrequencyRangeEvent::GetStopFrequency() const -{ - return _stopFrequency; -} - -#endif /* SPECTRUM_UPDATE_EVENTS_C */ diff --git a/gr-qtgui/src/lib/spectrumUpdateEvents.h b/gr-qtgui/src/lib/spectrumUpdateEvents.h deleted file mode 100644 index ccc072c3e..000000000 --- a/gr-qtgui/src/lib/spectrumUpdateEvents.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef SPECTRUM_UPDATE_EVENTS_H -#define SPECTRUM_UPDATE_EVENTS_H - -#include -#include -#include -#include -#include - -class SpectrumUpdateEvent:public QEvent{ - -public: - SpectrumUpdateEvent(const std::complex* fftPoints, - const uint64_t numFFTDataPoints, - const double* realTimeDomainPoints, - const double* imagTimeDomainPoints, - const uint64_t numTimeDomainDataPoints, - const timespec dataTimestamp, - const bool repeatDataFlag, - const bool lastOfMultipleUpdateFlag, - const timespec generatedTimestamp, - const int droppedFFTFrames); - - ~SpectrumUpdateEvent(); - - const std::complex* getFFTPoints() const; - const double* getRealTimeDomainPoints() const; - const double* getImagTimeDomainPoints() const; - uint64_t getNumFFTDataPoints() const; - uint64_t getNumTimeDomainDataPoints() const; - timespec getDataTimestamp() const; - bool getRepeatDataFlag() const; - bool getLastOfMultipleUpdateFlag() const; - timespec getEventGeneratedTimestamp() const; - int getDroppedFFTFrames() const; - -protected: - -private: - std::complex* _fftPoints; - double* _realDataTimeDomainPoints; - double* _imagDataTimeDomainPoints; - uint64_t _numFFTDataPoints; - uint64_t _numTimeDomainDataPoints; - timespec _dataTimestamp; - bool _repeatDataFlag; - bool _lastOfMultipleUpdateFlag; - timespec _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; -}; - - -#endif /* SPECTRUM_UPDATE_EVENTS_H */ diff --git a/gr-qtgui/src/lib/spectrumdisplayform.cc b/gr-qtgui/src/lib/spectrumdisplayform.cc deleted file mode 100644 index e0509a294..000000000 --- a/gr-qtgui/src/lib/spectrumdisplayform.cc +++ /dev/null @@ -1,691 +0,0 @@ -#include -#include -#include -#include - -int SpectrumDisplayForm::_openGLWaterfall3DFlag = -1; - -SpectrumDisplayForm::SpectrumDisplayForm(bool useOpenGL, QWidget* parent) - : QWidget(parent) -{ - setupUi(this); - - _useOpenGL = useOpenGL; - _systemSpecifiedFlag = false; - _intValidator = new QIntValidator(this); - _intValidator->setBottom(0); - _frequencyDisplayPlot = new FrequencyDisplayPlot(FrequencyPlotDisplayFrame); - _waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame); - - _timeDomainDisplayPlot = new TimeDomainDisplayPlot(TimeDomainDisplayFrame); - _constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame); - _numRealDataPoints = 1024; - _realFFTDataPoints = new double[_numRealDataPoints]; - _averagedValues = new double[_numRealDataPoints]; - _historyVector = new std::vector; - - AvgLineEdit->setRange(0, 500); // Set range of Average box value from 0 to 500 - MinHoldCheckBox_toggled( false ); - MaxHoldCheckBox_toggled( false ); - - WaterfallMaximumIntensityWheel->setRange(-200, 0); - WaterfallMaximumIntensityWheel->setTickCnt(50); - WaterfallMinimumIntensityWheel->setRange(-200, 0); - WaterfallMinimumIntensityWheel->setTickCnt(50); - WaterfallMinimumIntensityWheel->setValue(-200); - - _peakFrequency = 0; - _peakAmplitude = -HUGE_VAL; - - _noiseFloorAmplitude = -HUGE_VAL; - - connect(_waterfallDisplayPlot, SIGNAL(UpdatedLowerIntensityLevel(const double)), - _frequencyDisplayPlot, SLOT(SetLowerIntensityLevel(const double))); - connect(_waterfallDisplayPlot, SIGNAL(UpdatedUpperIntensityLevel(const double)), - _frequencyDisplayPlot, SLOT(SetUpperIntensityLevel(const double))); - - _frequencyDisplayPlot->SetLowerIntensityLevel(-200); - _frequencyDisplayPlot->SetUpperIntensityLevel(-200); - - // Load up the acceptable FFT sizes... - FFTSizeComboBox->clear(); - for(long fftSize = SpectrumGUIClass::MIN_FFT_SIZE; fftSize <= SpectrumGUIClass::MAX_FFT_SIZE; fftSize *= 2){ - FFTSizeComboBox->insertItem(FFTSizeComboBox->count(), QString("%1").arg(fftSize)); - } - Reset(); - - ToggleTabFrequency(false); - ToggleTabWaterfall(false); - ToggleTabTime(false); - ToggleTabConstellation(false); - - // Create a timer to update plots at the specified rate - displayTimer = new QTimer(this); - connect(displayTimer, SIGNAL(timeout()), this, SLOT(UpdateGuiTimer())); -} - -SpectrumDisplayForm::~SpectrumDisplayForm() -{ - // Qt deletes children when parent is deleted - - // Don't worry about deleting Display Plots - they are deleted when parents are deleted - delete _intValidator; - - delete[] _realFFTDataPoints; - delete[] _averagedValues; - - for(unsigned int count = 0; count < _historyVector->size(); count++){ - delete[] _historyVector->operator[](count); - } - - delete _historyVector; - - displayTimer->stop(); - delete displayTimer; -} - -void -SpectrumDisplayForm::setSystem( SpectrumGUIClass * newSystem, - const uint64_t numFFTDataPoints, - const uint64_t numTimeDomainDataPoints ) -{ - ResizeBuffers(numFFTDataPoints, numTimeDomainDataPoints); - - if(newSystem != NULL){ - _system = newSystem; - _systemSpecifiedFlag = true; - } - else{ - _systemSpecifiedFlag = false; - } -} - -void -SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdateEvent) -{ - //_lastSpectrumEvent = (SpectrumUpdateEvent)(*spectrumUpdateEvent); - const std::complex* complexDataPoints = spectrumUpdateEvent->getFFTPoints(); - const uint64_t numFFTDataPoints = spectrumUpdateEvent->getNumFFTDataPoints(); - const double* realTimeDomainDataPoints = spectrumUpdateEvent->getRealTimeDomainPoints(); - const double* imagTimeDomainDataPoints = spectrumUpdateEvent->getImagTimeDomainPoints(); - const uint64_t numTimeDomainDataPoints = spectrumUpdateEvent->getNumTimeDomainDataPoints(); - const timespec dataTimestamp = spectrumUpdateEvent->getDataTimestamp(); - const bool repeatDataFlag = spectrumUpdateEvent->getRepeatDataFlag(); - const bool lastOfMultipleUpdatesFlag = spectrumUpdateEvent->getLastOfMultipleUpdateFlag(); - const timespec generatedTimestamp = spectrumUpdateEvent->getEventGeneratedTimestamp(); - - // REMEMBER: The dataTimestamp is NOT valid when the repeat data flag is true... - ResizeBuffers(numFFTDataPoints, numTimeDomainDataPoints); - - // Calculate the Magnitude of the complex point - const std::complex* complexDataPointsPtr = complexDataPoints+numFFTDataPoints/2; - double* realFFTDataPointsPtr = _realFFTDataPoints; - - double sumMean = 0.0; - double localPeakAmplitude = -HUGE_VAL; - double localPeakFrequency = 0.0; - const double fftBinSize = (_stopFrequency-_startFrequency) / - static_cast(numFFTDataPoints); - - // Run this twice to perform the fftshift operation on the data here as well - std::complex scaleFactor = std::complex((float)numFFTDataPoints); - for(uint64_t point = 0; point < numFFTDataPoints/2; point++){ - std::complex pt = (*complexDataPointsPtr) / scaleFactor; - *realFFTDataPointsPtr = 10.0*log10((pt.real() * pt.real() + pt.imag()*pt.imag()) + 1e-20); - - if(*realFFTDataPointsPtr > localPeakAmplitude) { - localPeakFrequency = static_cast(point) * fftBinSize; - localPeakAmplitude = *realFFTDataPointsPtr; - } - sumMean += *realFFTDataPointsPtr; - - complexDataPointsPtr++; - realFFTDataPointsPtr++; - } - - // This loop takes the first half of the input data and puts it in the - // second half of the plotted data - complexDataPointsPtr = complexDataPoints; - for(uint64_t point = 0; point < numFFTDataPoints/2; point++){ - std::complex pt = (*complexDataPointsPtr) / scaleFactor; - *realFFTDataPointsPtr = 10.0*log10((pt.real() * pt.real() + pt.imag()*pt.imag()) + 1e-20); - - if(*realFFTDataPointsPtr > localPeakAmplitude) { - localPeakFrequency = static_cast(point) * fftBinSize; - localPeakAmplitude = *realFFTDataPointsPtr; - } - sumMean += *realFFTDataPointsPtr; - - complexDataPointsPtr++; - realFFTDataPointsPtr++; - } - - // Don't update the averaging history if this is repeated data - if(!repeatDataFlag){ - _AverageHistory(_realFFTDataPoints); - - // Only use the local info if we are not repeating data - _peakAmplitude = localPeakAmplitude; - _peakFrequency = localPeakFrequency; - - // calculate the spectral mean - // +20 because for the comparison below we only want to throw out bins - // that are significantly higher (and would, thus, affect the mean more) - const double meanAmplitude = (sumMean / numFFTDataPoints) + 20.0; - - // now throw out any bins higher than the mean - sumMean = 0.0; - uint64_t newNumDataPoints = numFFTDataPoints; - for(uint64_t number = 0; number < numFFTDataPoints; number++){ - if (_realFFTDataPoints[number] <= meanAmplitude) - sumMean += _realFFTDataPoints[number]; - else - newNumDataPoints--; - } - - if (newNumDataPoints == 0) // in the odd case that all - _noiseFloorAmplitude = meanAmplitude; // amplitudes are equal! - else - _noiseFloorAmplitude = sumMean / newNumDataPoints; - } - - if(lastOfMultipleUpdatesFlag){ - int tabindex = SpectrumTypeTab->currentIndex(); - if(tabindex == d_plot_fft) { - _frequencyDisplayPlot->PlotNewData(_averagedValues, numFFTDataPoints, - _noiseFloorAmplitude, _peakFrequency, - _peakAmplitude, d_update_time); - } - if(tabindex == d_plot_time) { - _timeDomainDisplayPlot->PlotNewData(realTimeDomainDataPoints, - imagTimeDomainDataPoints, - numTimeDomainDataPoints, - d_update_time); - } - if(tabindex == d_plot_constellation) { - _constellationDisplayPlot->PlotNewData(realTimeDomainDataPoints, - imagTimeDomainDataPoints, - numTimeDomainDataPoints, - d_update_time); - } - - // Don't update the repeated data for the waterfall - if(!repeatDataFlag){ - if(tabindex == d_plot_waterfall) { - _waterfallDisplayPlot->PlotNewData(_realFFTDataPoints, numFFTDataPoints, - d_update_time, dataTimestamp, - spectrumUpdateEvent->getDroppedFFTFrames()); - } - } - - - // Tell the system the GUI has been updated - if(_systemSpecifiedFlag){ - _system->SetLastGUIUpdateTime(generatedTimestamp); - _system->DecrementPendingGUIUpdateEvents(); - } - } -} - -void -SpectrumDisplayForm::resizeEvent( QResizeEvent *e ) -{ - QSize s; - s.setWidth(FrequencyPlotDisplayFrame->width()); - s.setHeight(FrequencyPlotDisplayFrame->height()); - emit _frequencyDisplayPlot->resizeSlot(&s); - - s.setWidth(TimeDomainDisplayFrame->width()); - s.setHeight(TimeDomainDisplayFrame->height()); - emit _timeDomainDisplayPlot->resizeSlot(&s); - - s.setWidth(WaterfallPlotDisplayFrame->width()); - s.setHeight(WaterfallPlotDisplayFrame->height()); - emit _waterfallDisplayPlot->resizeSlot(&s); - - s.setWidth(ConstellationDisplayFrame->width()); - s.setHeight(ConstellationDisplayFrame->height()); - emit _constellationDisplayPlot->resizeSlot(&s); -} - -void -SpectrumDisplayForm::customEvent( QEvent * e) -{ - if(e->type() == QEvent::User+3){ - if(_systemSpecifiedFlag){ - WindowComboBox->setCurrentIndex(_system->GetWindowType()); - FFTSizeComboBox->setCurrentIndex(_system->GetFFTSizeIndex()); - //FFTSizeComboBox->setCurrentIndex(1); - } - - waterfallMinimumIntensityChangedCB(WaterfallMinimumIntensityWheel->value()); - waterfallMaximumIntensityChangedCB(WaterfallMaximumIntensityWheel->value()); - - // Clear any previous display - Reset(); - } - else if(e->type() == 10005){ - SpectrumUpdateEvent* spectrumUpdateEvent = (SpectrumUpdateEvent*)e; - newFrequencyData(spectrumUpdateEvent); - } - else if(e->type() == 10008){ - setWindowTitle(((SpectrumWindowCaptionEvent*)e)->getLabel()); - } - else if(e->type() == 10009){ - Reset(); - if(_systemSpecifiedFlag){ - _system->ResetPendingGUIUpdateEvents(); - } - } - else if(e->type() == 10010){ - _startFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetStartFrequency(); - _stopFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetStopFrequency(); - _centerFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetCenterFrequency(); - - UseRFFrequenciesCB(UseRFFrequenciesCheckBox->isChecked()); - } -} - -void -SpectrumDisplayForm::UpdateGuiTimer() -{ - // This is called by the displayTimer and redraws the canvases of - // all of the plots. - _frequencyDisplayPlot->canvas()->update(); - _waterfallDisplayPlot->canvas()->update(); - _timeDomainDisplayPlot->canvas()->update(); - _constellationDisplayPlot->canvas()->update(); -} - - -void -SpectrumDisplayForm::AvgLineEdit_valueChanged( int value ) -{ - SetAverageCount(value); -} - - -void -SpectrumDisplayForm::MaxHoldCheckBox_toggled( bool newState ) -{ - MaxHoldResetBtn->setEnabled(newState); - _frequencyDisplayPlot->SetMaxFFTVisible(newState); - MaxHoldResetBtn_clicked(); -} - - -void -SpectrumDisplayForm::MinHoldCheckBox_toggled( bool newState ) -{ - MinHoldResetBtn->setEnabled(newState); - _frequencyDisplayPlot->SetMinFFTVisible(newState); - MinHoldResetBtn_clicked(); -} - - -void -SpectrumDisplayForm::MinHoldResetBtn_clicked() -{ - _frequencyDisplayPlot->ClearMinData(); - _frequencyDisplayPlot->replot(); -} - - -void -SpectrumDisplayForm::MaxHoldResetBtn_clicked() -{ - _frequencyDisplayPlot->ClearMaxData(); - _frequencyDisplayPlot->replot(); -} - - -void -SpectrumDisplayForm::TabChanged(int index) -{ - // This might be dangerous to call this with NULL - resizeEvent(NULL); -} - -void -SpectrumDisplayForm::SetFrequencyRange(const double newCenterFrequency, - const double newStartFrequency, - const double newStopFrequency) -{ - double fdiff; - if(UseRFFrequenciesCheckBox->isChecked()) { - fdiff = newCenterFrequency; - } - else { - fdiff = std::max(fabs(newStartFrequency), fabs(newStopFrequency)); - } - - if(fdiff > 0) { - std::string strunits[4] = {"Hz", "kHz", "MHz", "GHz"}; - std::string strtime[4] = {"sec", "ms", "us", "ns"}; - double units10 = floor(log10(fdiff)); - double units3 = std::max(floor(units10 / 3.0), 0.0); - double units = pow(10, (units10-fmod(units10, 3.0))); - int iunit = static_cast(units3); - - _startFrequency = newStartFrequency; - _stopFrequency = newStopFrequency; - _centerFrequency = newCenterFrequency; - - _frequencyDisplayPlot->SetFrequencyRange(_startFrequency, - _stopFrequency, - _centerFrequency, - UseRFFrequenciesCheckBox->isChecked(), - units, strunits[iunit]); - _waterfallDisplayPlot->SetFrequencyRange(_startFrequency, - _stopFrequency, - _centerFrequency, - UseRFFrequenciesCheckBox->isChecked(), - units, strunits[iunit]); - _timeDomainDisplayPlot->SetSampleRate(_stopFrequency - _startFrequency, - units, strtime[iunit]); - } -} - -int -SpectrumDisplayForm::GetAverageCount() -{ - return _historyVector->size(); -} - -void -SpectrumDisplayForm::SetAverageCount(const int newCount) -{ - if(newCount > -1){ - if(newCount != static_cast(_historyVector->size())){ - std::vector::iterator pos; - while(newCount < static_cast(_historyVector->size())){ - pos = _historyVector->begin(); - delete[] (*pos); - _historyVector->erase(pos); - } - - while(newCount > static_cast(_historyVector->size())){ - _historyVector->push_back(new double[_numRealDataPoints]); - } - AverageDataReset(); - } - } -} - -void -SpectrumDisplayForm::_AverageHistory(const double* newBuffer) -{ - if(_numRealDataPoints > 0){ - if(_historyVector->size() > 0){ - memcpy(_historyVector->operator[](_historyEntry), newBuffer, - _numRealDataPoints*sizeof(double)); - - // Increment the next location to store data - _historyEntryCount++; - if(_historyEntryCount > static_cast(_historyVector->size())){ - _historyEntryCount = _historyVector->size(); - } - _historyEntry = (++_historyEntry)%_historyVector->size(); - - // Total up and then average the values - double sum; - for(uint64_t location = 0; location < _numRealDataPoints; location++){ - sum = 0; - for(int number = 0; number < _historyEntryCount; number++){ - sum += _historyVector->operator[](number)[location]; - } - _averagedValues[location] = sum/static_cast(_historyEntryCount); - } - } - else{ - memcpy(_averagedValues, newBuffer, _numRealDataPoints*sizeof(double)); - } - } -} - -void -SpectrumDisplayForm::ResizeBuffers( const uint64_t numFFTDataPoints, - const uint64_t /*numTimeDomainDataPoints*/ ) -{ - // Convert from Complex to Real for certain Displays - if(_numRealDataPoints != numFFTDataPoints){ - _numRealDataPoints = numFFTDataPoints; - delete[] _realFFTDataPoints; - delete[] _averagedValues; - - _realFFTDataPoints = new double[_numRealDataPoints]; - _averagedValues = new double[_numRealDataPoints]; - memset(_realFFTDataPoints, 0x0, _numRealDataPoints*sizeof(double)); - - const int historySize = _historyVector->size(); - SetAverageCount(0); // Clear the existing history - SetAverageCount(historySize); - - Reset(); - } -} - -void -SpectrumDisplayForm::Reset() -{ - AverageDataReset(); - - _waterfallDisplayPlot->Reset(); -} - - -void -SpectrumDisplayForm::AverageDataReset() -{ - _historyEntry = 0; - _historyEntryCount = 0; - - memset(_averagedValues, 0x0, _numRealDataPoints*sizeof(double)); - - MaxHoldResetBtn_clicked(); - MinHoldResetBtn_clicked(); -} - - -void -SpectrumDisplayForm::closeEvent( QCloseEvent *e ) -{ - if(_systemSpecifiedFlag){ - _system->SetWindowOpenFlag(false); - } - - qApp->processEvents(); - - QWidget::closeEvent(e); -} - - -void -SpectrumDisplayForm::WindowTypeChanged( int newItem ) -{ - if(_systemSpecifiedFlag){ - _system->SetWindowType(newItem); - } -} - - -void -SpectrumDisplayForm::UseRFFrequenciesCB( bool useRFFlag ) -{ - SetFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency); -} - - -void -SpectrumDisplayForm::waterfallMaximumIntensityChangedCB( double newValue ) -{ - if(newValue > WaterfallMinimumIntensityWheel->value()){ - WaterfallMaximumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); - } - else{ - WaterfallMaximumIntensityWheel->setValue(WaterfallMinimumIntensityWheel->value()); - } - - _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(), - WaterfallMaximumIntensityWheel->value()); -} - - -void -SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue ) -{ - if(newValue < WaterfallMaximumIntensityWheel->value()){ - WaterfallMinimumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0)); - } - else{ - WaterfallMinimumIntensityWheel->setValue(WaterfallMaximumIntensityWheel->value()); - } - - _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(), - WaterfallMaximumIntensityWheel->value()); -} - -void -SpectrumDisplayForm::FFTComboBoxSelectedCB( const QString &fftSizeString ) -{ - if(_systemSpecifiedFlag){ - _system->SetFFTSize(fftSizeString.toLong()); - } -} - - -void -SpectrumDisplayForm::WaterfallAutoScaleBtnCB() -{ - double minimumIntensity = _noiseFloorAmplitude - 5; - if(minimumIntensity < WaterfallMinimumIntensityWheel->minValue()){ - minimumIntensity = WaterfallMinimumIntensityWheel->minValue(); - } - WaterfallMinimumIntensityWheel->setValue(minimumIntensity); - double maximumIntensity = _peakAmplitude + 10; - if(maximumIntensity > WaterfallMaximumIntensityWheel->maxValue()){ - maximumIntensity = WaterfallMaximumIntensityWheel->maxValue(); - } - WaterfallMaximumIntensityWheel->setValue(maximumIntensity); - waterfallMaximumIntensityChangedCB(maximumIntensity); -} - -void -SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType ) -{ - QColor lowIntensityColor; - QColor highIntensityColor; - if(newType == WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_USER_DEFINED){ - // Select the Low Intensity Color - lowIntensityColor = _waterfallDisplayPlot->GetUserDefinedLowIntensityColor(); - if(!lowIntensityColor.isValid()){ - lowIntensityColor = Qt::black; - } - QMessageBox::information(this, "Low Intensity Color Selection", "In the next window, select the low intensity color for the waterfall display", QMessageBox::Ok); - lowIntensityColor = QColorDialog::getColor(lowIntensityColor, this); - - // Select the High Intensity Color - highIntensityColor = _waterfallDisplayPlot->GetUserDefinedHighIntensityColor(); - if(!highIntensityColor.isValid()){ - highIntensityColor = Qt::white; - } - QMessageBox::information(this, "High Intensity Color Selection", "In the next window, select the high intensity color for the waterfall display", QMessageBox::Ok); - highIntensityColor = QColorDialog::getColor(highIntensityColor, this); - } - - _waterfallDisplayPlot->SetIntensityColorMapType(newType, lowIntensityColor, highIntensityColor); -} - -void -SpectrumDisplayForm::ToggleTabFrequency(const bool state) -{ - if(state == true) { - if(d_plot_fft == -1) { - SpectrumTypeTab->addTab(FrequencyPage, "Frequency Display"); - d_plot_fft = SpectrumTypeTab->count()-1; - } - } - else { - SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(FrequencyPage)); - d_plot_fft = -1; - } -} - -void -SpectrumDisplayForm::ToggleTabWaterfall(const bool state) -{ - if(state == true) { - if(d_plot_waterfall == -1) { - SpectrumTypeTab->addTab(WaterfallPage, "Waterfall Display"); - d_plot_waterfall = SpectrumTypeTab->count()-1; - } - } - else { - SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(WaterfallPage)); - d_plot_waterfall = -1; - } -} - -void -SpectrumDisplayForm::ToggleTabTime(const bool state) -{ - if(state == true) { - if(d_plot_time == -1) { - SpectrumTypeTab->addTab(TimeDomainPage, "Time Domain Display"); - d_plot_time = SpectrumTypeTab->count()-1; - } - } - else { - SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(TimeDomainPage)); - d_plot_time = -1; - } -} - -void -SpectrumDisplayForm::ToggleTabConstellation(const bool state) -{ - if(state == true) { - if(d_plot_constellation == -1) { - SpectrumTypeTab->addTab(ConstellationPage, "Constellation Display"); - d_plot_constellation = SpectrumTypeTab->count()-1; - } - } - else { - SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(ConstellationPage)); - d_plot_constellation = -1; - } -} - - -void -SpectrumDisplayForm::SetTimeDomainAxis(double min, double max) -{ - _timeDomainDisplayPlot->set_yaxis(min, max); -} - -void -SpectrumDisplayForm::SetConstellationAxis(double xmin, double xmax, - double ymin, double ymax) -{ - _constellationDisplayPlot->set_axis(xmin, xmax, ymin, ymax); -} - -void -SpectrumDisplayForm::SetConstellationPenSize(int size) -{ - _constellationDisplayPlot->set_pen_size( size ); -} - -void -SpectrumDisplayForm::SetFrequencyAxis(double min, double max) -{ - _frequencyDisplayPlot->set_yaxis(min, max); -} - -void -SpectrumDisplayForm::SetUpdateTime(double t) -{ - d_update_time = t; - // QTimer class takes millisecond input - displayTimer->start(d_update_time*1000); -} diff --git a/gr-qtgui/src/lib/spectrumdisplayform.h b/gr-qtgui/src/lib/spectrumdisplayform.h deleted file mode 100644 index fbd08349b..000000000 --- a/gr-qtgui/src/lib/spectrumdisplayform.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef SPECTRUM_DISPLAY_FORM_H -#define SPECTRUM_DISPLAY_FORM_H - -#include "spectrumdisplayform.ui.h" - -class SpectrumGUIClass; -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -class SpectrumDisplayForm : public QWidget, public Ui::SpectrumDisplayForm -{ - Q_OBJECT - - public: - SpectrumDisplayForm(bool useOpenGL = true, 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(); - -protected: - -private: - void _AverageHistory( const double * newBuffer ); - - bool _useOpenGL; - int _historyEntryCount; - int _historyEntry; - std::vector* _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; - static int _openGLWaterfall3DFlag; - double _stopFrequency; - - //SpectrumUpdateEvent _lastSpectrumEvent; - - // whether or not to use a particular display - int d_plot_fft; - int d_plot_waterfall; - int d_plot_waterfall3d; - int d_plot_time; - int d_plot_constellation; - - QTimer *displayTimer; - double d_update_time; -}; - -#endif /* SPECTRUM_DISPLAY_FORM_H */ diff --git a/gr-qtgui/src/lib/spectrumdisplayform.ui b/gr-qtgui/src/lib/spectrumdisplayform.ui deleted file mode 100644 index 5a23bc8a9..000000000 --- a/gr-qtgui/src/lib/spectrumdisplayform.ui +++ /dev/null @@ -1,788 +0,0 @@ - - - SpectrumDisplayForm - - - - 0 - 0 - 712 - 543 - - - - Spectrum Display - - - - - - - 0 - 0 - - - - - 120 - 16777215 - - - - - 1024 - - - - - 2048 - - - - - 4096 - - - - - 8192 - - - - - 16384 - - - - - 32768 - - - - - - - - FFT Size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - Display RF Frequencies - - - - - - - - - - 0 - 0 - - - - Window: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - 120 - 16777215 - - - - - 9 - - - - - Hamming - - - - - Hann - - - - - Blackman - - - - - Rectangular - - - - - Kaiser - - - - - Blackman-harris - - - - - - - - - - 0 - - - - Frequency Display - - - - - - - - - 0 - 0 - - - - - 400 - 350 - - - - - 1 - 1 - - - - QFrame::NoFrame - - - QFrame::Plain - - - - - - - - - Max Hold - - - false - - - - - - - Min Hold - - - false - - - - - - - - 0 - 0 - - - - - 25 - 0 - - - - Reset - - - - - - - - 0 - 0 - - - - - 62 - 0 - - - - Average - - - Qt::AlignCenter - - - false - - - - - - - Reset - - - - - - - - - - Qt::Horizontal - - - - 200 - 20 - - - - - - - - - - - - - Waterfall Display - - - - - - - 100 - 16777215 - - - - Intensity Display: - - - false - - - - - - - - 200 - 0 - - - - true - - - Qt::WheelFocus - - - true - - - 200.000000000000000 - - - 20.000000000000000 - - - 0.000000000000000 - - - - - - - - 100 - 16777215 - - - - 100 dB - - - false - - - - - - - - 617 - 338 - - - - QFrame::NoFrame - - - QFrame::Plain - - - - - - - - 200 - 0 - - - - true - - - 200.000000000000000 - - - 20.000000000000000 - - - 0.000000000000000 - - - - - - - - 100 - 16777215 - - - - -100 dB - - - false - - - - - - - - 80 - 16777215 - - - - Scales the Intensity to the current data extremes. - - - Auto Scale - - - - - - - - 100 - 16777215 - - - - - Color - - - - - White Hot - - - - - Black Hot - - - - - Incandescent - - - - - User Defined - - - - - - - - - Time Domain Display - - - - - - - 617 - 404 - - - - QFrame::NoFrame - - - QFrame::Plain - - - - - - - - Constellation Display - - - - - - - 617 - 406 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - - qPixmapFromMimeSource - - - QwtWheel - QWidget -
qwt_wheel.h
-
-
- - SpectrumTypeTab - UseRFFrequenciesCheckBox - FFTSizeComboBox - WaterfallMaximumIntensityWheel - WaterfallMinimumIntensityWheel - - - SpectrumGUIClass.h - FrequencyDisplayPlot.h - WaterfallDisplayPlot.h - TimeDomainDisplayPlot.h - qvalidator.h - vector - qwt_wheel.h - - - - - MaxHoldCheckBox - toggled(bool) - SpectrumDisplayForm - MaxHoldCheckBox_toggled(bool) - - - 22 - 324 - - - 20 - 20 - - - - - MaxHoldResetBtn - clicked() - SpectrumDisplayForm - MaxHoldResetBtn_clicked() - - - 107 - 324 - - - 20 - 20 - - - - - MinHoldCheckBox - toggled(bool) - SpectrumDisplayForm - MinHoldCheckBox_toggled(bool) - - - 22 - 349 - - - 20 - 20 - - - - - MinHoldResetBtn - clicked() - SpectrumDisplayForm - MinHoldResetBtn_clicked() - - - 107 - 349 - - - 20 - 20 - - - - - WindowComboBox - activated(int) - SpectrumDisplayForm - WindowTypeChanged(int) - - - 20 - 20 - - - 20 - 20 - - - - - UseRFFrequenciesCheckBox - toggled(bool) - SpectrumDisplayForm - UseRFFrequenciesCB(bool) - - - 20 - 20 - - - 20 - 20 - - - - - WaterfallMaximumIntensityWheel - valueChanged(double) - SpectrumDisplayForm - waterfallMaximumIntensityChangedCB(double) - - - 217 - 44 - - - 20 - 20 - - - - - WaterfallMinimumIntensityWheel - valueChanged(double) - SpectrumDisplayForm - waterfallMinimumIntensityChangedCB(double) - - - 217 - 349 - - - 20 - 20 - - - - - FFTSizeComboBox - activated(QString) - SpectrumDisplayForm - FFTComboBoxSelectedCB(QString) - - - 20 - 20 - - - 20 - 20 - - - - - WaterfallAutoScaleBtn - clicked() - SpectrumDisplayForm - WaterfallAutoScaleBtnCB() - - - 22 - 349 - - - 20 - 20 - - - - - Waterfall3DAutoScaleBtn - clicked() - SpectrumDisplayForm - Waterfall3DAutoScaleBtnCB() - - - 22 - 349 - - - 20 - 20 - - - - - WaterfallIntensityComboBox - activated(int) - SpectrumDisplayForm - WaterfallIntensityColorTypeChanged(int) - - - 92 - 44 - - - 20 - 20 - - - - - Waterfall3DIntensityComboBox - activated(int) - SpectrumDisplayForm - Waterfall3DIntensityColorTypeChanged(int) - - - 92 - 44 - - - 20 - 20 - - - - - SpectrumTypeTab - currentChanged(int) - SpectrumDisplayForm - TabChanged(int) - - - 314 - 189 - - - 316 - 217 - - - - - AvgLineEdit - valueChanged(int) - SpectrumDisplayForm - AvgLineEdit_valueChanged(int) - - - 604 - 421 - - - 328 - 260 - - - - -
diff --git a/gr-qtgui/src/lib/waterfallGlobalData.cc b/gr-qtgui/src/lib/waterfallGlobalData.cc deleted file mode 100644 index 1ba153f0d..000000000 --- a/gr-qtgui/src/lib/waterfallGlobalData.cc +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef WATERFALL_GLOBAL_DATA_CPP -#define WATERFALL_GLOBAL_DATA_CPP - -#include - -WaterfallData::WaterfallData(const double minimumFrequency, - const double maximumFrequency, - const uint64_t fftPoints, - const unsigned int historyExtent) - : QwtRasterData(QwtDoubleRect(minimumFrequency /* X START */, 0 /* Y START */, - maximumFrequency - minimumFrequency /* WIDTH */, - static_cast(historyExtent)/* HEIGHT */)) -{ - _intensityRange = QwtDoubleInterval(-200.0, 0.0); - - _fftPoints = fftPoints; - _historyLength = historyExtent; - - _spectrumData = new double[_fftPoints * _historyLength]; - - Reset(); -} - -WaterfallData::~WaterfallData() -{ - delete[] _spectrumData; -} - -void WaterfallData::Reset() -{ - memset(_spectrumData, 0x0, _fftPoints*_historyLength*sizeof(double)); - - _numLinesToUpdate = -1; -} - -void WaterfallData::Copy(const WaterfallData* rhs) -{ - if((_fftPoints != rhs->GetNumFFTPoints()) || - (boundingRect() != rhs->boundingRect()) ){ - _fftPoints = rhs->GetNumFFTPoints(); - setBoundingRect(rhs->boundingRect()); - delete[] _spectrumData; - _spectrumData = new double[_fftPoints * _historyLength]; - } - Reset(); - SetSpectrumDataBuffer(rhs->GetSpectrumDataBuffer()); - SetNumLinesToUpdate(rhs->GetNumLinesToUpdate()); - setRange(rhs->range()); -} - -void WaterfallData::ResizeData(const double startFreq, - const double stopFreq, - const uint64_t fftPoints) -{ - if((fftPoints != GetNumFFTPoints()) || - (boundingRect().width() != (stopFreq - startFreq)) || - (boundingRect().left() != startFreq)){ - - setBoundingRect(QwtDoubleRect(startFreq, 0, stopFreq-startFreq, boundingRect().height())); - _fftPoints = fftPoints; - delete[] _spectrumData; - _spectrumData = new double[_fftPoints * _historyLength]; - } - - Reset(); -} - -QwtRasterData *WaterfallData::copy() const -{ - WaterfallData* returnData = new WaterfallData(boundingRect().left(), - boundingRect().right(), - _fftPoints, _historyLength); - returnData->Copy(this); - return returnData; -} - -QwtDoubleInterval WaterfallData::range() const -{ - return _intensityRange; -} - -void WaterfallData::setRange(const QwtDoubleInterval& newRange) -{ - _intensityRange = newRange; -} - -double WaterfallData::value(double x, double y) const -{ - double returnValue = 0.0; - - const unsigned int intY = static_cast((1.0 - (y/boundingRect().height())) * - static_cast(_historyLength - 1)); - const unsigned int intX = static_cast((((x - boundingRect().left()) / boundingRect().width()) * - static_cast(_fftPoints-1)) + 0.5); - - const int location = (intY * _fftPoints) + intX; - if((location > -1) && (location < static_cast(_fftPoints * _historyLength))){ - returnValue = _spectrumData[location]; - } - - return returnValue; -} - -uint64_t WaterfallData::GetNumFFTPoints() const -{ - return _fftPoints; -} - -void WaterfallData::addFFTData(const double* fftData, - const uint64_t fftDataSize, - const int droppedFrames){ - if(fftDataSize == _fftPoints){ - int64_t heightOffset = _historyLength - 1 - droppedFrames; - uint64_t drawingDroppedFrames = droppedFrames; - - // Any valid data rolled off the display so just fill in zeros and write new data - if(heightOffset < 0){ - heightOffset = 0; - drawingDroppedFrames = static_cast(_historyLength-1); - } - - // Copy the old data over if any available - if(heightOffset > 0){ - memmove( _spectrumData, &_spectrumData[(drawingDroppedFrames+1) * _fftPoints], - heightOffset * _fftPoints * sizeof(double)) ; - } - - if(drawingDroppedFrames > 0){ - // Fill in zeros data for dropped data - memset(&_spectrumData[heightOffset * _fftPoints], 0x00, - static_cast(drawingDroppedFrames) * _fftPoints * sizeof(double)); - } - - // add the new buffer - memcpy(&_spectrumData[(_historyLength - 1) * _fftPoints], fftData, _fftPoints*sizeof(double)); - } -} - -double* WaterfallData::GetSpectrumDataBuffer() const -{ - return _spectrumData; -} - -void WaterfallData::SetSpectrumDataBuffer(const double* newData) -{ - memcpy(_spectrumData, newData, _fftPoints * _historyLength * sizeof(double)); -} - -int WaterfallData::GetNumLinesToUpdate() const -{ - return _numLinesToUpdate; -} - -void WaterfallData::SetNumLinesToUpdate(const int newNum) -{ - _numLinesToUpdate = newNum; -} - -void WaterfallData::IncrementNumLinesToUpdate() -{ - _numLinesToUpdate++; -} - -#endif /* WATERFALL_GLOBAL_DATA_CPP */ diff --git a/gr-qtgui/src/lib/waterfallGlobalData.h b/gr-qtgui/src/lib/waterfallGlobalData.h deleted file mode 100644 index 51f65064c..000000000 --- a/gr-qtgui/src/lib/waterfallGlobalData.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef WATERFALL_GLOBAL_DATA_HPP -#define WATERFALL_GLOBAL_DATA_HPP - -#include -#include - - -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; - virtual QwtDoubleInterval range() const; - virtual void setRange(const QwtDoubleInterval&); - - 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; - QwtDoubleInterval _intensityRange; - -private: - -}; - -#endif /* WATERFALL_GLOBAL_DATA_HPP */ -- cgit From c102d4f510339f78184d292c8126e5d3721bb0b9 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 12:56:22 -0400 Subject: gr-qtgui: moving gitignore to new location. --- gr-qtgui/lib/.gitignore | 16 ++++++++++++++++ gr-qtgui/src/lib/.gitignore | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 gr-qtgui/lib/.gitignore delete mode 100644 gr-qtgui/src/lib/.gitignore diff --git a/gr-qtgui/lib/.gitignore b/gr-qtgui/lib/.gitignore new file mode 100644 index 000000000..61b9ca8c1 --- /dev/null +++ b/gr-qtgui/lib/.gitignore @@ -0,0 +1,16 @@ +/Makefile +/Makefile.in +/.libs +/.deps +/qtgui.cc +/qtgui.py +/WaterfallDisplayPlot.moc.cc +/Waterfall3DDisplayPlot.moc.cc +/TimeDomainDisplayPlot.moc.cc +/spectrumdisplayform.moc.cc +/spectrumdisplayform.ui.h +/FrequencyDisplayPlot.moc.cc +/ConstellationDisplayPlot.moc.cc +/gnuradio +/guile +/python diff --git a/gr-qtgui/src/lib/.gitignore b/gr-qtgui/src/lib/.gitignore deleted file mode 100644 index 61b9ca8c1..000000000 --- a/gr-qtgui/src/lib/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -/Makefile -/Makefile.in -/.libs -/.deps -/qtgui.cc -/qtgui.py -/WaterfallDisplayPlot.moc.cc -/Waterfall3DDisplayPlot.moc.cc -/TimeDomainDisplayPlot.moc.cc -/spectrumdisplayform.moc.cc -/spectrumdisplayform.ui.h -/FrequencyDisplayPlot.moc.cc -/ConstellationDisplayPlot.moc.cc -/gnuradio -/guile -/python -- cgit From 43b9359fabe5c153a02081ae56047b9e121dce02 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 12:59:52 -0400 Subject: gr-qtgui: moving Python files to new structure; get rid of src directory. --- gr-qtgui/lib/Makefile.swig.gen | 145 ------------ gr-qtgui/lib/qtgui.i | 131 ----------- gr-qtgui/python/.gitignore | 3 + gr-qtgui/python/Makefile.am | 45 ++++ gr-qtgui/python/__init__.py | 0 gr-qtgui/python/pyqt_example.py | 144 ++++++++++++ gr-qtgui/python/pyqt_example_f.py | 143 ++++++++++++ gr-qtgui/python/qa_qtgui.py | 46 ++++ gr-qtgui/python/qt_digital.py | 276 ++++++++++++++++++++++ gr-qtgui/python/qt_digital_window.py | 161 +++++++++++++ gr-qtgui/python/qt_digital_window.ui | 342 +++++++++++++++++++++++++++ gr-qtgui/python/run_tests.in | 10 + gr-qtgui/python/usrp2_display.py | 313 +++++++++++++++++++++++++ gr-qtgui/python/usrp_display.py | 299 ++++++++++++++++++++++++ gr-qtgui/python/usrp_display_qtgui.py | 191 +++++++++++++++ gr-qtgui/python/usrp_display_qtgui.ui | 375 ++++++++++++++++++++++++++++++ gr-qtgui/src/.gitignore | 2 - gr-qtgui/src/Makefile.am | 25 -- gr-qtgui/src/python/.gitignore | 3 - gr-qtgui/src/python/Makefile.am | 45 ---- gr-qtgui/src/python/__init__.py | 0 gr-qtgui/src/python/pyqt_example.py | 144 ------------ gr-qtgui/src/python/pyqt_example_f.py | 143 ------------ gr-qtgui/src/python/qa_qtgui.py | 46 ---- gr-qtgui/src/python/qt_digital.py | 276 ---------------------- gr-qtgui/src/python/qt_digital_window.py | 161 ------------- gr-qtgui/src/python/qt_digital_window.ui | 342 --------------------------- gr-qtgui/src/python/run_tests.in | 10 - gr-qtgui/src/python/usrp2_display.py | 313 ------------------------- gr-qtgui/src/python/usrp_display.py | 299 ------------------------ gr-qtgui/src/python/usrp_display_qtgui.py | 191 --------------- gr-qtgui/src/python/usrp_display_qtgui.ui | 375 ------------------------------ gr-qtgui/swig/qtgui.i | 131 +++++++++++ 33 files changed, 2479 insertions(+), 2651 deletions(-) delete mode 100644 gr-qtgui/lib/Makefile.swig.gen delete mode 100644 gr-qtgui/lib/qtgui.i create mode 100644 gr-qtgui/python/.gitignore create mode 100644 gr-qtgui/python/Makefile.am create mode 100644 gr-qtgui/python/__init__.py create mode 100755 gr-qtgui/python/pyqt_example.py create mode 100755 gr-qtgui/python/pyqt_example_f.py create mode 100755 gr-qtgui/python/qa_qtgui.py create mode 100755 gr-qtgui/python/qt_digital.py create mode 100644 gr-qtgui/python/qt_digital_window.py create mode 100644 gr-qtgui/python/qt_digital_window.ui create mode 100644 gr-qtgui/python/run_tests.in create mode 100755 gr-qtgui/python/usrp2_display.py create mode 100755 gr-qtgui/python/usrp_display.py create mode 100644 gr-qtgui/python/usrp_display_qtgui.py create mode 100644 gr-qtgui/python/usrp_display_qtgui.ui delete mode 100644 gr-qtgui/src/.gitignore delete mode 100644 gr-qtgui/src/Makefile.am delete mode 100644 gr-qtgui/src/python/.gitignore delete mode 100644 gr-qtgui/src/python/Makefile.am delete mode 100644 gr-qtgui/src/python/__init__.py delete mode 100755 gr-qtgui/src/python/pyqt_example.py delete mode 100755 gr-qtgui/src/python/pyqt_example_f.py delete mode 100755 gr-qtgui/src/python/qa_qtgui.py delete mode 100755 gr-qtgui/src/python/qt_digital.py delete mode 100644 gr-qtgui/src/python/qt_digital_window.py delete mode 100644 gr-qtgui/src/python/qt_digital_window.ui delete mode 100644 gr-qtgui/src/python/run_tests.in delete mode 100755 gr-qtgui/src/python/usrp2_display.py delete mode 100755 gr-qtgui/src/python/usrp_display.py delete mode 100644 gr-qtgui/src/python/usrp_display_qtgui.py delete mode 100644 gr-qtgui/src/python/usrp_display_qtgui.ui create mode 100644 gr-qtgui/swig/qtgui.i diff --git a/gr-qtgui/lib/Makefile.swig.gen b/gr-qtgui/lib/Makefile.swig.gen deleted file mode 100644 index 9c4c0b58c..000000000 --- a/gr-qtgui/lib/Makefile.swig.gen +++ /dev/null @@ -1,145 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2009 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. -# - -# Makefile.swig.gen for qtgui.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/qtgui -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/qtgui -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -qtgui_pythondir_category ?= gnuradio/qtgui -qtgui_pylibdir_category ?= $(qtgui_pythondir_category) -qtgui_pythondir = $(pythondir)/$(qtgui_pythondir_category) -qtgui_pylibdir = $(pyexecdir)/$(qtgui_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -qtgui_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/qtgui -# FIXME: determince whether these should be installed with gnuradio. -qtgui_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -qtgui_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -qtgui_swiginclude_HEADERS = \ - qtgui.i \ - $(qtgui_swiginclude_headers) - -if PYTHON -qtgui_pylib_LTLIBRARIES = \ - _qtgui.la - -_qtgui_la_SOURCES = \ - python/qtgui.cc \ - $(qtgui_la_swig_sources) - -qtgui_python_PYTHON = \ - qtgui.py \ - $(qtgui_python) - -_qtgui_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(qtgui_la_swig_libadd) - -_qtgui_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(qtgui_la_swig_ldflags) - -_qtgui_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(qtgui_la_swig_cxxflags) - -python/qtgui.cc: qtgui.py -qtgui.py: qtgui.i - -# Include the python dependencies for this file --include python/qtgui.d - -endif # end of if python - -if GUILE - -qtgui_scmlib_LTLIBRARIES = \ - libguile-gnuradio-qtgui.la -libguile_gnuradio_qtgui_la_SOURCES = \ - guile/qtgui.cc \ - $(qtgui_la_swig_sources) -nobase_qtgui_scm_DATA = \ - gnuradio/qtgui.scm \ - gnuradio/qtgui-primitive.scm -libguile_gnuradio_qtgui_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(qtgui_la_swig_libadd) -libguile_gnuradio_qtgui_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(qtgui_la_swig_ldflags) -libguile_gnuradio_qtgui_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(qtgui_la_swig_cxxflags) - -guile/qtgui.cc: gnuradio/qtgui.scm -gnuradio/qtgui.scm: qtgui.i -gnuradio/qtgui-primitive.scm: gnuradio/qtgui.scm - -# Include the guile dependencies for this file --include guile/qtgui.d - -endif # end of GUILE - - diff --git a/gr-qtgui/lib/qtgui.i b/gr-qtgui/lib/qtgui.i deleted file mode 100644 index bb64c6ae2..000000000 --- a/gr-qtgui/lib/qtgui.i +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 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. - */ - -%include "gnuradio.i" - -%{ -#include "qtgui_sink_c.h" -#include "qtgui_sink_f.h" -%} - -GR_SWIG_BLOCK_MAGIC(qtgui,sink_c) - - qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, - double fc=0, double bw=1.0, - const std::string &name="Display", - bool plotfreq=true, bool plotwaterfall=true, - bool plotwaterfall3d=true, bool plottime=true, - bool plotconst=true, - bool use_openGL=true, - QWidget *parent=NULL); - -class qtgui_sink_c : public gr_block -{ -private: - friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - qtgui_sink_c (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - -public: - void exec_(); - PyObject* pyqwidget(); - - void set_frequency_range(const double centerfreq, - const double bandwidth); - void set_time_domain_axis(double min, double max); - void set_constellation_axis(double xmin, double xmax, - double ymin, double ymax); - void set_frequency_axis(double min, double max); - void set_constellation_pen_size(int size); -}; - - - -/*********************************************************************/ - - -GR_SWIG_BLOCK_MAGIC(qtgui,sink_f) - -qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, - double fc=0, double bw=0.0, - const std::string &name="Display", - bool plotfreq=true, bool plotwaterfall=true, - bool plotwaterfall3d=true, bool plottime=true, - bool plotconst=true, - bool use_openGL=true, - QWidget *parent=NULL); - -class qtgui_sink_f : public gr_block -{ -private: - friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - qtgui_sink_f (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - -public: - void exec_(); - PyObject* pyqwidget(); - - void set_frequency_range(const double centerfreq, - const double bandwidth); - void set_time_domain_axis(double min, double max); - void set_constellation_axis(double xmin, double xmax, - double ymin, double ymax); - void set_frequency_axis(double min, double max); - void set_constellation_pen_size(int size); -}; - -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-qtgui" "scm_init_gnuradio_qtgui_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif diff --git a/gr-qtgui/python/.gitignore b/gr-qtgui/python/.gitignore new file mode 100644 index 000000000..604b402c5 --- /dev/null +++ b/gr-qtgui/python/.gitignore @@ -0,0 +1,3 @@ +/Makefile +/Makefile.in +/run_tests diff --git a/gr-qtgui/python/Makefile.am b/gr-qtgui/python/Makefile.am new file mode 100644 index 000000000..0953a71e5 --- /dev/null +++ b/gr-qtgui/python/Makefile.am @@ -0,0 +1,45 @@ +# +# Copyright 2008,2009 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. +# + +include $(top_srcdir)/Makefile.common + +TESTS = +EXTRA_DIST += run_tests.in \ + qt_digital_window.ui + +if PYTHON +TESTS += run_tests +DISTCLEANFILES += run_tests + +qtguipythondir = $(grpythondir)/qtgui + +noinst_PYTHON = \ + pyqt_example_f.py \ + pyqt_example.py \ + qt_digital.py \ + qt_digital_window.py \ + usrp2_display.py \ + usrp_display.py \ + qa_qtgui.py + +qtguipython_PYTHON = \ + __init__.py +endif diff --git a/gr-qtgui/python/__init__.py b/gr-qtgui/python/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/gr-qtgui/python/pyqt_example.py b/gr-qtgui/python/pyqt_example.py new file mode 100755 index 000000000..7c0cfc698 --- /dev/null +++ b/gr-qtgui/python/pyqt_example.py @@ -0,0 +1,144 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio.qtgui import qtgui +from PyQt4 import QtGui, QtCore +import sys, sip + +class dialog_box(QtGui.QWidget): + def __init__(self, display, control): + QtGui.QWidget.__init__(self, None) + self.setWindowTitle('PyQt Test GUI') + + self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) + self.boxlayout.addWidget(display, 1) + self.boxlayout.addWidget(control) + + self.resize(800, 500) + +class control_box(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + self.setWindowTitle('Control Panel') + + self.setToolTip('Control the signals') + QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) + + self.layout = QtGui.QFormLayout(self) + + # Control the first signal + self.freq1Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) + self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), + self.freq1EditText) + + self.amp1Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) + self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), + self.amp1EditText) + + + # Control the second signal + self.freq2Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) + self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), + self.freq2EditText) + + + self.amp2Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) + self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), + self.amp2EditText) + + self.quit = QtGui.QPushButton('Close', self) + self.layout.addWidget(self.quit) + + self.connect(self.quit, QtCore.SIGNAL('clicked()'), + QtGui.qApp, QtCore.SLOT('quit()')) + + def attach_signal1(self, signal): + self.signal1 = signal + self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) + self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) + + def attach_signal2(self, signal): + self.signal2 = signal + self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) + self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) + + def freq1EditText(self): + try: + newfreq = float(self.freq1Edit.text()) + self.signal1.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp1EditText(self): + try: + newamp = float(self.amp1Edit.text()) + self.signal1.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + + def freq2EditText(self): + try: + newfreq = float(self.freq2Edit.text()) + self.signal2.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp2EditText(self): + try: + newamp = float(self.amp2Edit.text()) + self.signal2.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + Rs = 8000 + f1 = 1000 + f2 = 2000 + + fftsize = 2048 + + self.qapp = QtGui.QApplication(sys.argv) + + src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) + src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) + src = gr.add_cc() + channel = gr.channel_model(0.001) + thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize) + self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, Rs, + "Complex Signal Example", + True, True, False, True, False) + + self.connect(src1, (src,0)) + self.connect(src2, (src,1)) + self.connect(src, channel, thr, self.snk1) + + self.ctrl_win = control_box() + self.ctrl_win.attach_signal1(src1) + self.ctrl_win.attach_signal2(src2) + + # Get the reference pointer to the SpectrumDisplayForm QWidget + pyQt = self.snk1.pyqwidget() + + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + + self.main_box = dialog_box(self.pyWin, self.ctrl_win) + + self.main_box.show() + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() + diff --git a/gr-qtgui/python/pyqt_example_f.py b/gr-qtgui/python/pyqt_example_f.py new file mode 100755 index 000000000..4e36ccca5 --- /dev/null +++ b/gr-qtgui/python/pyqt_example_f.py @@ -0,0 +1,143 @@ +#!/usr/bin/env python + +from gnuradio import gr, blks2 +from gnuradio.qtgui import qtgui +from PyQt4 import QtGui, QtCore +import sys, sip + +class dialog_box(QtGui.QWidget): + def __init__(self, display, control): + QtGui.QWidget.__init__(self, None) + self.setWindowTitle('PyQt Test GUI') + + self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) + self.boxlayout.addWidget(display, 1) + self.boxlayout.addWidget(control) + + self.resize(800, 500) + +class control_box(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + self.setWindowTitle('Control Panel') + + self.setToolTip('Control the signals') + QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) + + self.layout = QtGui.QFormLayout(self) + + # Control the first signal + self.freq1Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) + self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), + self.freq1EditText) + + self.amp1Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) + self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), + self.amp1EditText) + + + # Control the second signal + self.freq2Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) + self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), + self.freq2EditText) + + + self.amp2Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) + self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), + self.amp2EditText) + + self.quit = QtGui.QPushButton('Close', self) + self.layout.addWidget(self.quit) + + self.connect(self.quit, QtCore.SIGNAL('clicked()'), + QtGui.qApp, QtCore.SLOT('quit()')) + + def attach_signal1(self, signal): + self.signal1 = signal + self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) + self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) + + def attach_signal2(self, signal): + self.signal2 = signal + self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) + self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) + + def freq1EditText(self): + try: + newfreq = float(self.freq1Edit.text()) + self.signal1.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp1EditText(self): + try: + newamp = float(self.amp1Edit.text()) + self.signal1.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + + def freq2EditText(self): + try: + newfreq = float(self.freq2Edit.text()) + self.signal2.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp2EditText(self): + try: + newamp = float(self.amp2Edit.text()) + self.signal2.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + Rs = 8000 + f1 = 1000 + f2 = 2000 + + fftsize = 2048 + + self.qapp = QtGui.QApplication(sys.argv) + + src1 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) + src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) + src = gr.add_ff() + thr = gr.throttle(gr.sizeof_float, 100*fftsize) + self.snk1 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, Rs, + "Float Signal Example", + True, True, False, True, False) + + self.connect(src1, (src,0)) + self.connect(src2, (src,1)) + self.connect(src, thr, self.snk1) + + self.ctrl_win = control_box() + self.ctrl_win.attach_signal1(src1) + self.ctrl_win.attach_signal2(src2) + + # Get the reference pointer to the SpectrumDisplayForm QWidget + pyQt = self.snk1.pyqwidget() + + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + + self.main_box = dialog_box(self.pyWin, self.ctrl_win) + + self.main_box.show() + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() + diff --git a/gr-qtgui/python/qa_qtgui.py b/gr-qtgui/python/qa_qtgui.py new file mode 100755 index 000000000..fbf0de46e --- /dev/null +++ b/gr-qtgui/python/qa_qtgui.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, gr_unittest +import qtgui +from PyQt4 import QtGui, QtCore +import sys, sip + +class test_qtgui(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test01 (self): + pass + # Test to make sure we can instantiate these + #self.qapp = QtGui.QApplication(sys.argv) + #self.qtsnk = qtgui.sink_c(1024, gr.firdes.WIN_BLACKMAN_hARRIS, + # 0, 1, "Test", + # True, True, False, True, True) + + +if __name__ == '__main__': + gr_unittest.run(test_qtgui, "test_qtgui.xml") diff --git a/gr-qtgui/python/qt_digital.py b/gr-qtgui/python/qt_digital.py new file mode 100755 index 000000000..679f144ef --- /dev/null +++ b/gr-qtgui/python/qt_digital.py @@ -0,0 +1,276 @@ +#!/usr/bin/env python + +from gnuradio import gr, blks2 +from gnuradio.qtgui import qtgui +from gnuradio import eng_notation +from PyQt4 import QtGui, QtCore +import sys, sip +import scipy + +try: + from qt_digital_window import Ui_DigitalWindow +except ImportError: + print "Error: could not find qt_digital_window.py:" + print "\t\"Please run: pyuic4 qt_digital_window.ui -o qt_digital_window.py\"" + sys.exit(1) + +class dialog_box(QtGui.QMainWindow): + def __init__(self, snkTx, snkRx, fg, parent=None): + QtGui.QWidget.__init__(self, parent) + self.gui = Ui_DigitalWindow() + self.gui.setupUi(self) + + self.fg = fg + + self.set_sample_rate(self.fg.sample_rate()) + + self.set_snr(self.fg.snr()) + self.set_frequency(self.fg.frequency_offset()) + self.set_time_offset(self.fg.timing_offset()) + + self.set_gain_mu(self.fg.rx_gain_mu()) + self.set_alpha(self.fg.rx_alpha()) + + # Add the qtsnk widgets to the hlayout box + self.gui.sinkLayout.addWidget(snkTx) + self.gui.sinkLayout.addWidget(snkRx) + + + # Connect up some signals + self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), + self.pauseFg) + + self.connect(self.gui.sampleRateEdit, QtCore.SIGNAL("editingFinished()"), + self.sampleRateEditText) + + self.connect(self.gui.snrEdit, QtCore.SIGNAL("editingFinished()"), + self.snrEditText) + self.connect(self.gui.freqEdit, QtCore.SIGNAL("editingFinished()"), + self.freqEditText) + self.connect(self.gui.timeEdit, QtCore.SIGNAL("editingFinished()"), + self.timeEditText) + + self.connect(self.gui.gainMuEdit, QtCore.SIGNAL("editingFinished()"), + self.gainMuEditText) + self.connect(self.gui.alphaEdit, QtCore.SIGNAL("editingFinished()"), + self.alphaEditText) + + + def pauseFg(self): + if(self.gui.pauseButton.text() == "Pause"): + self.fg.stop() + self.fg.wait() + self.gui.pauseButton.setText("Unpause") + else: + self.fg.start() + self.gui.pauseButton.setText("Pause") + + # Accessor functions for Gui to manipulate system parameters + def set_sample_rate(self, sr): + ssr = eng_notation.num_to_str(sr) + self.gui.sampleRateEdit.setText(QtCore.QString("%1").arg(ssr)) + + def sampleRateEditText(self): + try: + rate = self.gui.sampleRateEdit.text().toAscii() + srate = eng_notation.str_to_num(rate) + self.fg.set_sample_rate(srate) + except RuntimeError: + pass + + + # Accessor functions for Gui to manipulate channel model + def set_snr(self, snr): + self.gui.snrEdit.setText(QtCore.QString("%1").arg(snr)) + + def set_frequency(self, fo): + self.gui.freqEdit.setText(QtCore.QString("%1").arg(fo)) + + def set_time_offset(self, to): + self.gui.timeEdit.setText(QtCore.QString("%1").arg(to)) + + def snrEditText(self): + try: + snr = self.gui.snrEdit.text().toDouble()[0] + self.fg.set_snr(snr) + except RuntimeError: + pass + + def freqEditText(self): + try: + freq = self.gui.freqEdit.text().toDouble()[0] + self.fg.set_frequency_offset(freq) + except RuntimeError: + pass + + def timeEditText(self): + try: + to = self.gui.timeEdit.text().toDouble()[0] + self.fg.set_timing_offset(to) + except RuntimeError: + pass + + + # Accessor functions for Gui to manipulate receiver parameters + def set_gain_mu(self, gain): + self.gui.gainMuEdit.setText(QtCore.QString("%1").arg(gain)) + + def set_alpha(self, alpha): + self.gui.alphaEdit.setText(QtCore.QString("%1").arg(alpha)) + + def alphaEditText(self): + try: + alpha = self.gui.alphaEdit.text().toDouble()[0] + self.fg.set_rx_alpha(alpha) + except RuntimeError: + pass + + def gainMuEditText(self): + try: + gain = self.gui.gainMuEdit.text().toDouble()[0] + self.fg.set_rx_gain_mu(gain) + except RuntimeError: + pass + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + self.qapp = QtGui.QApplication(sys.argv) + + self._sample_rate = 2000e3 + + self.sps = 2 + self.excess_bw = 0.35 + self.gray_code = True + + fftsize = 2048 + + self.data = scipy.random.randint(0, 255, 1000) + self.src = gr.vector_source_b(self.data.tolist(), True) + self.mod = blks2.dqpsk_mod(self.sps, self.excess_bw, self.gray_code, False, False) + + self.rrctaps = gr.firdes.root_raised_cosine(1, self.sps, 1, self.excess_bw, 21) + self.rx_rrc = gr.fir_filter_ccf(1, self.rrctaps) + + + # Set up the carrier & clock recovery parameters + self.arity = 4 + self.mu = 0.5 + self.gain_mu = 0.05 + self.omega = self.sps + self.gain_omega = .25 * self.gain_mu * self.gain_mu + self.omega_rel_lim = 0.05 + + self.alpha = 0.15 + self.beta = 0.25 * self.alpha * self.alpha + self.fmin = -1000/self.sample_rate() + self.fmax = 1000/self.sample_rate() + + self.receiver = gr.mpsk_receiver_cc(self.arity, 0, + self.alpha, self.beta, + self.fmin, self.fmax, + self.mu, self.gain_mu, + self.omega, self.gain_omega, + self.omega_rel_lim) + + + self.snr_dB = 15 + noise = self.get_noise_voltage(self.snr_dB) + self.fo = 100/self.sample_rate() + self.to = 1.0 + self.channel = gr.channel_model(noise, self.fo, self.to) + + self.thr = gr.throttle(gr.sizeof_char, self._sample_rate) + self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, self._sample_rate*self.sps, + "Tx", True, True, False, True, True) + + self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, self._sample_rate, + "Rx", True, True, False, True, True) + + self.connect(self.src, self.thr, self.mod, self.channel, self.snk_tx) + self.connect(self.channel, self.rx_rrc, self.receiver, self.snk_rx) + + pyTxQt = self.snk_tx.pyqwidget() + pyTx = sip.wrapinstance(pyTxQt, QtGui.QWidget) + + pyRxQt = self.snk_rx.pyqwidget() + pyRx = sip.wrapinstance(pyRxQt, QtGui.QWidget) + + self.main_box = dialog_box(pyTx, pyRx, self); + self.main_box.show() + + + def get_noise_voltage(self, SNR): + S = 0 # dBm, assuming signal power normalized + N = S - SNR # dBm + npwr = pow(10.0, N/10.0) # ratio + nv = scipy.sqrt(npwr * self.sps) # convert the noise voltage + return nv + + + # System Parameters + def sample_rate(self): + return self._sample_rate + + def set_sample_rate(self, sr): + self._sample_rate = sr + + + # Channel Model Parameters + def snr(self): + return self.snr_dB + + def set_snr(self, snr): + self.snr_dB = snr + noise = self.get_noise_voltage(self.snr_dB) + self.channel.set_noise_voltage(noise) + + def frequency_offset(self): + return self.fo * self.sample_rate() + + def set_frequency_offset(self, fo): + self.fo = fo / self.sample_rate() + self.channel.set_frequency_offset(self.fo) + + def timing_offset(self): + return self.to + + def set_timing_offset(self, to): + self.to = to + self.channel.set_timing_offset(self.to) + + + # Receiver Parameters + def rx_gain_mu(self): + return self.gain_mu + + def rx_gain_omega(self): + return self.gain_omega + + def set_rx_gain_mu(self, gain): + self.gain_mu = gain + self.gain_omega = .25 * self.gain_mu * self.gain_mu + self.receiver.set_gain_mu(self.gain_mu) + self.receiver.set_gain_omega(self.gain_omega) + + def rx_alpha(self): + return self.alpha + + def rx_beta(self): + return self.beta + + def set_rx_alpha(self, alpha): + self.alpha = alpha + self.beta = .25 * self.alpha * self.alpha + self.receiver.set_alpha(self.alpha) + self.receiver.set_beta(self.beta) + + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() diff --git a/gr-qtgui/python/qt_digital_window.py b/gr-qtgui/python/qt_digital_window.py new file mode 100644 index 000000000..50dd53a92 --- /dev/null +++ b/gr-qtgui/python/qt_digital_window.py @@ -0,0 +1,161 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'qt_digital_window.ui' +# +# Created: Sat May 1 20:14:02 2010 +# by: PyQt4 UI code generator 4.6.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_DigitalWindow(object): + def setupUi(self, DigitalWindow): + DigitalWindow.setObjectName("DigitalWindow") + DigitalWindow.resize(1236, 741) + self.centralwidget = QtGui.QWidget(DigitalWindow) + self.centralwidget.setObjectName("centralwidget") + self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) + self.verticalLayout.setObjectName("verticalLayout") + self.sinkFrame = QtGui.QFrame(self.centralwidget) + self.sinkFrame.setMinimumSize(QtCore.QSize(0, 550)) + self.sinkFrame.setFrameShape(QtGui.QFrame.StyledPanel) + self.sinkFrame.setFrameShadow(QtGui.QFrame.Raised) + self.sinkFrame.setObjectName("sinkFrame") + self.horizontalLayout_2 = QtGui.QHBoxLayout(self.sinkFrame) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.sinkLayout = QtGui.QHBoxLayout() + self.sinkLayout.setObjectName("sinkLayout") + self.horizontalLayout_2.addLayout(self.sinkLayout) + self.verticalLayout.addWidget(self.sinkFrame) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.sysBox = QtGui.QGroupBox(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.sysBox.sizePolicy().hasHeightForWidth()) + self.sysBox.setSizePolicy(sizePolicy) + self.sysBox.setMinimumSize(QtCore.QSize(0, 0)) + self.sysBox.setMaximumSize(QtCore.QSize(16777215, 120)) + self.sysBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.sysBox.setObjectName("sysBox") + self.gridLayout_2 = QtGui.QGridLayout(self.sysBox) + self.gridLayout_2.setObjectName("gridLayout_2") + self.sampleRateEdit = QtGui.QLineEdit(self.sysBox) + self.sampleRateEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.sampleRateEdit.setObjectName("sampleRateEdit") + self.gridLayout_2.addWidget(self.sampleRateEdit, 0, 3, 1, 1) + self.sampleRateLabel = QtGui.QLabel(self.sysBox) + self.sampleRateLabel.setObjectName("sampleRateLabel") + self.gridLayout_2.addWidget(self.sampleRateLabel, 0, 2, 1, 1) + self.horizontalLayout.addWidget(self.sysBox) + self.rxBox = QtGui.QGroupBox(self.centralwidget) + self.rxBox.setMaximumSize(QtCore.QSize(16777215, 120)) + self.rxBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.rxBox.setObjectName("rxBox") + self.gridLayout_3 = QtGui.QGridLayout(self.rxBox) + self.gridLayout_3.setObjectName("gridLayout_3") + self.alphaLabel = QtGui.QLabel(self.rxBox) + self.alphaLabel.setObjectName("alphaLabel") + self.gridLayout_3.addWidget(self.alphaLabel, 1, 0, 1, 1) + self.alphaEdit = QtGui.QLineEdit(self.rxBox) + self.alphaEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.alphaEdit.setObjectName("alphaEdit") + self.gridLayout_3.addWidget(self.alphaEdit, 1, 1, 1, 1) + self.gainMuLabel = QtGui.QLabel(self.rxBox) + self.gainMuLabel.setObjectName("gainMuLabel") + self.gridLayout_3.addWidget(self.gainMuLabel, 0, 0, 1, 1) + self.gainMuEdit = QtGui.QLineEdit(self.rxBox) + self.gainMuEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.gainMuEdit.setObjectName("gainMuEdit") + self.gridLayout_3.addWidget(self.gainMuEdit, 0, 1, 1, 1) + self.horizontalLayout.addWidget(self.rxBox) + self.channelModeBox = QtGui.QGroupBox(self.centralwidget) + self.channelModeBox.setMaximumSize(QtCore.QSize(16777215, 120)) + self.channelModeBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.channelModeBox.setObjectName("channelModeBox") + self.gridLayout = QtGui.QGridLayout(self.channelModeBox) + self.gridLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize) + self.gridLayout.setObjectName("gridLayout") + self.snrLabel = QtGui.QLabel(self.channelModeBox) + self.snrLabel.setObjectName("snrLabel") + self.gridLayout.addWidget(self.snrLabel, 0, 1, 1, 1) + self.snrEdit = QtGui.QLineEdit(self.channelModeBox) + self.snrEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.snrEdit.setObjectName("snrEdit") + self.gridLayout.addWidget(self.snrEdit, 0, 2, 1, 1) + self.freqLabel = QtGui.QLabel(self.channelModeBox) + self.freqLabel.setObjectName("freqLabel") + self.gridLayout.addWidget(self.freqLabel, 1, 1, 1, 1) + self.freqEdit = QtGui.QLineEdit(self.channelModeBox) + self.freqEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.freqEdit.setObjectName("freqEdit") + self.gridLayout.addWidget(self.freqEdit, 1, 2, 1, 1) + self.timeLabel = QtGui.QLabel(self.channelModeBox) + self.timeLabel.setObjectName("timeLabel") + self.gridLayout.addWidget(self.timeLabel, 2, 1, 1, 1) + self.timeEdit = QtGui.QLineEdit(self.channelModeBox) + self.timeEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.timeEdit.setObjectName("timeEdit") + self.gridLayout.addWidget(self.timeEdit, 2, 2, 1, 1) + self.horizontalLayout.addWidget(self.channelModeBox) + spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem) + self.verticalLayout_2 = QtGui.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout_2.addItem(spacerItem1) + self.pauseButton = QtGui.QPushButton(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.pauseButton.sizePolicy().hasHeightForWidth()) + self.pauseButton.setSizePolicy(sizePolicy) + self.pauseButton.setMaximumSize(QtCore.QSize(80, 16777215)) + self.pauseButton.setObjectName("pauseButton") + self.verticalLayout_2.addWidget(self.pauseButton) + self.closeButton = QtGui.QPushButton(self.centralwidget) + self.closeButton.setMaximumSize(QtCore.QSize(80, 16777215)) + self.closeButton.setObjectName("closeButton") + self.verticalLayout_2.addWidget(self.closeButton) + self.horizontalLayout.addLayout(self.verticalLayout_2) + self.verticalLayout.addLayout(self.horizontalLayout) + DigitalWindow.setCentralWidget(self.centralwidget) + self.menubar = QtGui.QMenuBar(DigitalWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1236, 23)) + self.menubar.setObjectName("menubar") + self.menuFile = QtGui.QMenu(self.menubar) + self.menuFile.setObjectName("menuFile") + DigitalWindow.setMenuBar(self.menubar) + self.statusbar = QtGui.QStatusBar(DigitalWindow) + self.statusbar.setObjectName("statusbar") + DigitalWindow.setStatusBar(self.statusbar) + self.actionExit = QtGui.QAction(DigitalWindow) + self.actionExit.setObjectName("actionExit") + self.menuFile.addAction(self.actionExit) + self.menubar.addAction(self.menuFile.menuAction()) + + self.retranslateUi(DigitalWindow) + QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), DigitalWindow.close) + QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), DigitalWindow.close) + QtCore.QMetaObject.connectSlotsByName(DigitalWindow) + DigitalWindow.setTabOrder(self.snrEdit, self.freqEdit) + DigitalWindow.setTabOrder(self.freqEdit, self.timeEdit) + + def retranslateUi(self, DigitalWindow): + DigitalWindow.setWindowTitle(QtGui.QApplication.translate("DigitalWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) + self.sysBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.sampleRateLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Sample Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) + self.rxBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.alphaLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Alpha", None, QtGui.QApplication.UnicodeUTF8)) + self.gainMuLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Gain mu", None, QtGui.QApplication.UnicodeUTF8)) + self.channelModeBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Channel Model Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.snrLabel.setText(QtGui.QApplication.translate("DigitalWindow", "SNR (dB)", None, QtGui.QApplication.UnicodeUTF8)) + self.freqLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Frequency Offset (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.timeLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Timing Offset", None, QtGui.QApplication.UnicodeUTF8)) + self.pauseButton.setText(QtGui.QApplication.translate("DigitalWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) + self.closeButton.setText(QtGui.QApplication.translate("DigitalWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) + self.menuFile.setTitle(QtGui.QApplication.translate("DigitalWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) + self.actionExit.setText(QtGui.QApplication.translate("DigitalWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) + diff --git a/gr-qtgui/python/qt_digital_window.ui b/gr-qtgui/python/qt_digital_window.ui new file mode 100644 index 000000000..967252181 --- /dev/null +++ b/gr-qtgui/python/qt_digital_window.ui @@ -0,0 +1,342 @@ + + + DigitalWindow + + + + 0 + 0 + 1236 + 741 + + + + MainWindow + + + + + + + + 0 + 550 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 120 + + + + System Parameters + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + 100 + 16777215 + + + + + + + + Sample Rate (sps) + + + + + + + + + + + 16777215 + 120 + + + + Receiver Parameters + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + Alpha + + + + + + + + 100 + 16777215 + + + + + + + + Gain mu + + + + + + + + 100 + 16777215 + + + + + + + + + + + + 16777215 + 120 + + + + Channel Model Parameters + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + QLayout::SetMinimumSize + + + + + SNR (dB) + + + + + + + + 100 + 16777215 + + + + + + + + Frequency Offset (Hz) + + + + + + + + 100 + 16777215 + + + + + + + + Timing Offset + + + + + + + + 100 + 16777215 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + 80 + 16777215 + + + + Pause + + + + + + + + 80 + 16777215 + + + + Close + + + + + + + + + + + + + 0 + 0 + 1236 + 23 + + + + + &File + + + + + + + + + E&xit + + + + + snrEdit + freqEdit + timeEdit + + + + + closeButton + clicked() + DigitalWindow + close() + + + 322 + 623 + + + 66 + 561 + + + + + actionExit + triggered() + DigitalWindow + close() + + + -1 + -1 + + + 617 + 327 + + + + + diff --git a/gr-qtgui/python/run_tests.in b/gr-qtgui/python/run_tests.in new file mode 100644 index 000000000..909194752 --- /dev/null +++ b/gr-qtgui/python/run_tests.in @@ -0,0 +1,10 @@ +#!/bin/sh + +# 1st parameter is absolute path to component source directory +# 2nd parameter is absolute path to component build directory +# 3rd parameter is path to Python QA directory + +@top_builddir@/run_tests.sh \ + @abs_top_srcdir@/gr-qtgui \ + @abs_top_builddir@/gr-qtgui \ + @srcdir@ diff --git a/gr-qtgui/python/usrp2_display.py b/gr-qtgui/python/usrp2_display.py new file mode 100755 index 000000000..75d374c2b --- /dev/null +++ b/gr-qtgui/python/usrp2_display.py @@ -0,0 +1,313 @@ +#!/usr/bin/env python +# +# Copyright 2009 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. +# + +from gnuradio import gr +from gnuradio import usrp2 +from gnuradio import eng_notation +from gnuradio.eng_option import eng_option +from gnuradio.qtgui import qtgui +from optparse import OptionParser +import sys + +try: + from gnuradio.qtgui import qtgui + from PyQt4 import QtGui, QtCore + import sip +except ImportError: + print "Please install gr-qtgui." + sys.exit(1) + +try: + from usrp_display_qtgui import Ui_MainWindow +except ImportError: + print "Error: could not find usrp_display_qtgui.py:" + print "\t\"pyuic4 usrp_display_qtgui.ui -o usrp_display_qtgui.py\"" + sys.exit(1) + + +# //////////////////////////////////////////////////////////////////// +# Define the QT Interface and Control Dialog +# //////////////////////////////////////////////////////////////////// + + +class main_window(QtGui.QMainWindow): + def __init__(self, snk, fg, parent=None): + + QtGui.QWidget.__init__(self, parent) + self.gui = Ui_MainWindow() + self.gui.setupUi(self) + + self.fg = fg + + # Add the qtsnk widgets to the layout box + self.gui.sinkLayout.addWidget(snk) + + self.gui.dcGainEdit.setText(QtCore.QString("%1").arg(0.001)) + + # Connect up some signals + self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), + self.pauseFg) + self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"), + self.frequencyEditText) + self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"), + self.gainEditText) + self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"), + self.bandwidthEditText) + self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"), + self.amplifierEditText) + + self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"), + self.saveData) + self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save) + + self.connect(self.gui.dcGainEdit, QtCore.SIGNAL("editingFinished()"), + self.dcGainEditText) + self.connect(self.gui.dcCancelCheckBox, QtCore.SIGNAL("clicked(bool)"), + self.dcCancelClicked) + + def pauseFg(self): + if(self.gui.pauseButton.text() == "Pause"): + self.fg.stop() + self.fg.wait() + self.gui.pauseButton.setText("Unpause") + else: + self.fg.start() + self.gui.pauseButton.setText("Pause") + + + # Functions to set the values in the GUI + def set_frequency(self, freq): + self.freq = freq + sfreq = eng_notation.num_to_str(self.freq) + self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq)) + + def set_gain(self, gain): + self.gain = gain + self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain)) + + def set_bandwidth(self, bw): + self.bw = bw + sbw = eng_notation.num_to_str(self.bw) + self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw)) + + def set_amplifier(self, amp): + self.amp = amp + self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp)) + + + # Functions called when signals are triggered in the GUI + def frequencyEditText(self): + try: + freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii()) + self.fg.set_frequency(freq) + self.freq = freq + except RuntimeError: + pass + + def gainEditText(self): + try: + gain = float(self.gui.gainEdit.text()) + self.fg.set_gain(gain) + self.gain = gain + except ValueError: + pass + + def bandwidthEditText(self): + try: + bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii()) + self.fg.set_bandwidth(bw) + self.bw = bw + except ValueError: + pass + + def amplifierEditText(self): + try: + amp = float(self.gui.amplifierEdit.text()) + self.fg.set_amplifier_gain(amp) + self.amp = amp + except ValueError: + pass + + def saveData(self): + fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", "."); + if(len(fileName)): + self.fg.save_to_file(str(fileName)) + + def dcGainEditText(self): + gain = float(self.gui.dcGainEdit.text()) + self.fg.set_dc_gain(gain) + + def dcCancelClicked(self, state): + self.dcGainEditText() + self.fg.cancel_dc(state) + + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + parser = OptionParser(option_class=eng_option) + parser.add_option("-e", "--interface", type="string", default="eth0", + help="select Ethernet interface, default is eth0") + parser.add_option("-m", "--mac-addr", type="string", default="", + help="select USRP by MAC address, default is auto-select") + parser.add_option("-W", "--bw", type="eng_float", default=1e6, + help="set bandwidth of receiver [default=%default]") + parser.add_option("-f", "--freq", type="eng_float", default=2412e6, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is midpoint)") + parser.add_option("--fft-size", type="int", default=2048, + help="Set number of FFT bins [default=%default]") + (options, args) = parser.parse_args() + + if len(args) != 0: + parser.print_help() + sys.exit(1) + self.options = options + self.show_debug_info = True + + self.qapp = QtGui.QApplication(sys.argv) + + self.u = usrp2.source_32fc(options.interface, options.mac_addr) + self._adc_rate = self.u.adc_rate() + self.set_bandwidth(options.bw) + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.gain_range() + options.gain = float(g[0]+g[1])/2 + self.set_gain(options.gain) + + if options.freq is None: + # if no frequency was specified, use the mid-point of the subdev + f = self.u.freq_range() + options.freq = float(f[0]+f[1])/2 + self.set_frequency(options.freq) + + self._fftsize = options.fft_size + + self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS, + self._freq, self._bandwidth, + "USRP2 Display", + True, True, False, True, False) + + # Set up internal amplifier + self.amp = gr.multiply_const_cc(0.0) + self.set_amplifier_gain(100) + + # Create a single-pole IIR filter to remove DC + # but don't connect it yet + self.dc_gain = 0.001 + self.dc = gr.single_pole_iir_filter_cc(self.dc_gain) + self.dc_sub = gr.sub_cc() + + self.connect(self.u, self.amp, self.snk) + + if self.show_debug_info: + print "Decimation rate: ", self._decim + print "Bandwidth: ", self._bandwidth + print "D'board: ", self.u.daughterboard_id() + + # Get the reference pointer to the SpectrumDisplayForm QWidget + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + + self.main_win = main_window(self.pysink, self) + + self.main_win.set_frequency(self._freq) + self.main_win.set_gain(self._gain) + self.main_win.set_bandwidth(self._bandwidth) + self.main_win.set_amplifier(self._amp_value) + + self.main_win.show() + + + def save_to_file(self, name): + self.lock() + + # Add file sink to save data + self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name) + self.connect(self.amp, self.file_sink) + + self.unlock() + + def set_gain(self, gain): + self._gain = gain + self.u.set_gain(self._gain) + + def set_frequency(self, freq): + self._freq = freq + r = self.u.set_center_freq(freq) + + try: + self.snk.set_frequency_range(self._freq, self._bandwidth) + except: + pass + + def set_bandwidth(self, bw): + self._bandwidth = bw + self._decim = int(self._adc_rate / self._bandwidth) + self.u.set_decim(self._decim) + + try: + self.snk.set_frequency_range(self._freq, self._bandwidth) + except: + pass + + def set_amplifier_gain(self, amp): + self._amp_value = amp + self.amp.set_k(self._amp_value) + + def set_dc_gain(self, gain): + self.dc.set_taps(gain) + + def cancel_dc(self, state): + self.lock() + + if(state): + self.disconnect(self.u, self.amp) + self.connect(self.u, (self.dc_sub,0)) + self.connect(self.u, self.dc, (self.dc_sub,1)) + self.connect(self.dc_sub, self.amp) + else: + self.disconnect(self.dc_sub, self.amp) + self.disconnect(self.dc, (self.dc_sub,1)) + self.disconnect(self.u, self.dc) + self.disconnect(self.u, (self.dc_sub,0)) + self.connect(self.u, self.amp) + + self.unlock() + +def main (): + tb = my_top_block() + tb.start() + tb.snk.exec_(); + +if __name__ == '__main__': + try: + main () + except KeyboardInterrupt: + pass + diff --git a/gr-qtgui/python/usrp_display.py b/gr-qtgui/python/usrp_display.py new file mode 100755 index 000000000..432e74d9a --- /dev/null +++ b/gr-qtgui/python/usrp_display.py @@ -0,0 +1,299 @@ +#!/usr/bin/env python +# +# Copyright 2009 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. +# + +from gnuradio import gr +from gnuradio import usrp +from gnuradio import eng_notation +from gnuradio.eng_option import eng_option +from gnuradio.qtgui import qtgui +from optparse import OptionParser +import sys + +try: + from gnuradio.qtgui import qtgui + from PyQt4 import QtGui, QtCore + import sip +except ImportError: + print "Please install gr-qtgui." + sys.exit(1) + +try: + from usrp_display_qtgui import Ui_MainWindow +except ImportError: + print "Error: could not find usrp_display_qtgui.py:" + print "\t\"pyuic4 usrp_display_qtgui.ui -o usrp_display_qtgui.py\"" + sys.exit(1) + + + +# //////////////////////////////////////////////////////////////////// +# Define the QT Interface and Control Dialog +# //////////////////////////////////////////////////////////////////// + + +class main_window(QtGui.QMainWindow): + def __init__(self, snk, fg, parent=None): + + QtGui.QWidget.__init__(self, parent) + self.gui = Ui_MainWindow() + self.gui.setupUi(self) + + self.fg = fg + + # Add the qtsnk widgets to the layout box + self.gui.sinkLayout.addWidget(snk) + + # Connect up some signals + self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), + self.pauseFg) + self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"), + self.frequencyEditText) + self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"), + self.gainEditText) + self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"), + self.bandwidthEditText) + self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"), + self.amplifierEditText) + + self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"), + self.saveData) + self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save) + + def pauseFg(self): + if(self.gui.pauseButton.text() == "Pause"): + self.fg.stop() + self.fg.wait() + self.gui.pauseButton.setText("Unpause") + else: + self.fg.start() + self.gui.pauseButton.setText("Pause") + + + # Functions to set the values in the GUI + def set_frequency(self, freq): + self.freq = freq + sfreq = eng_notation.num_to_str(self.freq) + self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq)) + + def set_gain(self, gain): + self.gain = gain + self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain)) + + def set_bandwidth(self, bw): + self.bw = bw + sbw = eng_notation.num_to_str(self.bw) + self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw)) + + def set_amplifier(self, amp): + self.amp = amp + self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp)) + + + # Functions called when signals are triggered in the GUI + def frequencyEditText(self): + try: + freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii()) + self.fg.set_frequency(freq) + self.freq = freq + except RuntimeError: + pass + + def gainEditText(self): + try: + gain = float(self.gui.gainEdit.text()) + self.fg.set_gain(gain) + self.gain = gain + except ValueError: + pass + + def bandwidthEditText(self): + try: + bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii()) + self.fg.set_bandwidth(bw) + self.bw = bw + except ValueError: + pass + + def amplifierEditText(self): + try: + amp = float(self.gui.amplifierEdit.text()) + self.fg.set_amplifier_gain(amp) + self.amp = amp + except ValueError: + pass + + def saveData(self): + fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", "."); + if(len(fileName)): + self.fg.save_to_file(str(fileName)) + + +def pick_subdevice(u): + """ + The user didn't specify a subdevice on the command line. + If there's a daughterboard on A, select A. + If there's a daughterboard on B, select B. + Otherwise, select A. + """ + if u.db(0, 0).dbid() >= 0: # dbid is < 0 if there's no d'board or a problem + return (0, 0) + if u.db(0, 0).dbid() >= 0: + return (1, 0) + return (0, 0) + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + parser = OptionParser(option_class=eng_option) + parser.add_option("-w", "--which", type="int", default=0, + help="select which USRP (0, 1, ...) default is %default", + metavar="NUM") + parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, + help="select USRP Rx side A or B (default=first one with a daughterboard)") + parser.add_option("-A", "--antenna", default=None, + help="select Rx Antenna (only on RFX-series boards)") + parser.add_option("-W", "--bw", type="float", default=1e6, + help="set bandwidth of receiver [default=%default]") + parser.add_option("-f", "--freq", type="eng_float", default=None, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB [default is midpoint]") + parser.add_option("-8", "--width-8", action="store_true", default=False, + help="Enable 8-bit samples across USB") + parser.add_option( "--no-hb", action="store_true", default=False, + help="don't use halfband filter in usrp") + parser.add_option("-S", "--oscilloscope", action="store_true", default=False, + help="Enable oscilloscope display") + parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1, + help="Set fftsink averaging factor, [default=%default]") + parser.add_option("", "--ref-scale", type="eng_float", default=13490.0, + help="Set dBFS=0dB input value, [default=%default]") + parser.add_option("", "--fft-size", type="int", default=2048, + help="Set FFT frame size, [default=%default]"); + + (options, args) = parser.parse_args() + if len(args) != 0: + parser.print_help() + sys.exit(1) + self.options = options + self.show_debug_info = True + + # Call this before creating the Qt sink + self.qapp = QtGui.QApplication(sys.argv) + + self._fftsize = options.fft_size + + self.u = usrp.source_c(which=options.which) + self._adc_rate = self.u.converter_rate() + self.set_bandwidth(options.bw) + + if options.rx_subdev_spec is None: + options.rx_subdev_spec = pick_subdevice(self.u) + self._rx_subdev_spec = options.rx_subdev_spec + self.u.set_mux(usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec)) + self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec) + + self._gain_range = self.subdev.gain_range() + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self._gain_range + options.gain = float(g[0]+g[1])/2 + self.set_gain(options.gain) + + if options.freq is None: + # if no frequency was specified, use the mid-point of the subdev + f = self.subdev.freq_range() + options.freq = float(f[0]+f[1])/2 + self.set_frequency(options.freq) + + self.snk = qtgui.sink_c(self._fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + self._freq, self._bandwidth, + "USRP Display", + True, True, False, True, False) + + # Set up internal amplifier + self.amp = gr.multiply_const_cc(0.0) + self.set_amplifier_gain(0.001) + + # Connect the flow graph + self.connect(self.u, self.amp, self.snk) + + + # Get the reference pointer to the SpectrumDisplayForm QWidget + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + + self.main_win = main_window(self.pysink, self) + + self.main_win.set_frequency(self._freq) + self.main_win.set_gain(self._gain) + self.main_win.set_bandwidth(self._bandwidth) + self.main_win.set_amplifier(self._amp_value) + + self.main_win.show() + + def save_to_file(self, name): + # Pause the flow graph + self.stop() + self.wait() + + # Add file sink to save data + self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name) + self.connect(self.amp, self.file_sink) + + # Restart flow graph + self.start() + + def set_gain(self, gain): + self._gain = gain + self.subdev.set_gain(self._gain) + + def set_frequency(self, freq): + self._freq = freq + self.u.tune(0, self.subdev, self._freq) + + try: + self.snk.set_frequency_range(self._freq, self._bandwidth) + except: + pass + + def set_bandwidth(self, bw): + self._bandwidth = bw + self._decim = int(self._adc_rate / self._bandwidth) + self.u.set_decim_rate(self._decim) + + try: + self.snk.set_frequency_range(self._freq, self._bandwidth) + except: + pass + + def set_amplifier_gain(self, amp): + self._amp_value = amp + self.amp.set_k(self._amp_value) + + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() diff --git a/gr-qtgui/python/usrp_display_qtgui.py b/gr-qtgui/python/usrp_display_qtgui.py new file mode 100644 index 000000000..4c9de3a53 --- /dev/null +++ b/gr-qtgui/python/usrp_display_qtgui.py @@ -0,0 +1,191 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'usrp_display_qtgui.ui' +# +# Created: Thu Jul 16 22:06:24 2009 +# by: PyQt4 UI code generator 4.4.3 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(820, 774) + self.centralwidget = QtGui.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.gridLayout_2 = QtGui.QGridLayout(self.centralwidget) + self.gridLayout_2.setObjectName("gridLayout_2") + self.horizontalLayout_2 = QtGui.QHBoxLayout() + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.groupBox = QtGui.QGroupBox(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth()) + self.groupBox.setSizePolicy(sizePolicy) + self.groupBox.setMinimumSize(QtCore.QSize(240, 150)) + self.groupBox.setMaximumSize(QtCore.QSize(240, 16777215)) + self.groupBox.setObjectName("groupBox") + self.formLayoutWidget = QtGui.QWidget(self.groupBox) + self.formLayoutWidget.setGeometry(QtCore.QRect(10, 20, 221, 124)) + self.formLayoutWidget.setObjectName("formLayoutWidget") + self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) + self.formLayout.setObjectName("formLayout") + self.frequencyLabel = QtGui.QLabel(self.formLayoutWidget) + self.frequencyLabel.setObjectName("frequencyLabel") + self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.frequencyLabel) + self.gainLabel = QtGui.QLabel(self.formLayoutWidget) + self.gainLabel.setObjectName("gainLabel") + self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.gainLabel) + self.bandwidthLabel = QtGui.QLabel(self.formLayoutWidget) + self.bandwidthLabel.setObjectName("bandwidthLabel") + self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.bandwidthLabel) + self.frequencyEdit = QtGui.QLineEdit(self.formLayoutWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.frequencyEdit.sizePolicy().hasHeightForWidth()) + self.frequencyEdit.setSizePolicy(sizePolicy) + self.frequencyEdit.setMinimumSize(QtCore.QSize(120, 26)) + self.frequencyEdit.setObjectName("frequencyEdit") + self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.frequencyEdit) + self.gainEdit = QtGui.QLineEdit(self.formLayoutWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.gainEdit.sizePolicy().hasHeightForWidth()) + self.gainEdit.setSizePolicy(sizePolicy) + self.gainEdit.setMinimumSize(QtCore.QSize(120, 26)) + self.gainEdit.setObjectName("gainEdit") + self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.gainEdit) + self.bandwidthEdit = QtGui.QLineEdit(self.formLayoutWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.bandwidthEdit.sizePolicy().hasHeightForWidth()) + self.bandwidthEdit.setSizePolicy(sizePolicy) + self.bandwidthEdit.setMinimumSize(QtCore.QSize(120, 26)) + self.bandwidthEdit.setObjectName("bandwidthEdit") + self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.bandwidthEdit) + self.amplifierLabel = QtGui.QLabel(self.formLayoutWidget) + self.amplifierLabel.setObjectName("amplifierLabel") + self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.amplifierLabel) + self.amplifierEdit = QtGui.QLineEdit(self.formLayoutWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.amplifierEdit.sizePolicy().hasHeightForWidth()) + self.amplifierEdit.setSizePolicy(sizePolicy) + self.amplifierEdit.setMinimumSize(QtCore.QSize(120, 26)) + self.amplifierEdit.setObjectName("amplifierEdit") + self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.amplifierEdit) + self.horizontalLayout_2.addWidget(self.groupBox) + self.frame_2 = QtGui.QFrame(self.centralwidget) + self.frame_2.setMinimumSize(QtCore.QSize(200, 0)) + self.frame_2.setFrameShape(QtGui.QFrame.StyledPanel) + self.frame_2.setFrameShadow(QtGui.QFrame.Raised) + self.frame_2.setObjectName("frame_2") + self.verticalLayoutWidget = QtGui.QWidget(self.frame_2) + self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, -1, 191, 151)) + self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") + self.verticalLayout_3 = QtGui.QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.dcCancelCheckBox = QtGui.QCheckBox(self.verticalLayoutWidget) + self.dcCancelCheckBox.setObjectName("dcCancelCheckBox") + self.verticalLayout_3.addWidget(self.dcCancelCheckBox) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.dcGainLabel = QtGui.QLabel(self.verticalLayoutWidget) + self.dcGainLabel.setObjectName("dcGainLabel") + self.horizontalLayout.addWidget(self.dcGainLabel) + self.dcGainEdit = QtGui.QLineEdit(self.verticalLayoutWidget) + self.dcGainEdit.setObjectName("dcGainEdit") + self.horizontalLayout.addWidget(self.dcGainEdit) + self.verticalLayout_3.addLayout(self.horizontalLayout) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout_3.addItem(spacerItem) + self.horizontalLayout_2.addWidget(self.frame_2) + spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout_2.addItem(spacerItem1) + self.verticalLayout = QtGui.QVBoxLayout() + self.verticalLayout.setObjectName("verticalLayout") + spacerItem2 = QtGui.QSpacerItem(20, 80, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) + self.verticalLayout.addItem(spacerItem2) + self.pauseButton = QtGui.QPushButton(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.pauseButton.sizePolicy().hasHeightForWidth()) + self.pauseButton.setSizePolicy(sizePolicy) + self.pauseButton.setObjectName("pauseButton") + self.verticalLayout.addWidget(self.pauseButton) + self.closeButton = QtGui.QPushButton(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.closeButton.sizePolicy().hasHeightForWidth()) + self.closeButton.setSizePolicy(sizePolicy) + self.closeButton.setMinimumSize(QtCore.QSize(75, 0)) + self.closeButton.setObjectName("closeButton") + self.verticalLayout.addWidget(self.closeButton) + self.horizontalLayout_2.addLayout(self.verticalLayout) + self.gridLayout_2.addLayout(self.horizontalLayout_2, 1, 0, 1, 1) + self.verticalLayout_2 = QtGui.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.frame = QtGui.QFrame(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(1) + sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth()) + self.frame.setSizePolicy(sizePolicy) + self.frame.setMinimumSize(QtCore.QSize(800, 550)) + self.frame.setFrameShape(QtGui.QFrame.StyledPanel) + self.frame.setFrameShadow(QtGui.QFrame.Raised) + self.frame.setObjectName("frame") + self.gridLayout = QtGui.QGridLayout(self.frame) + self.gridLayout.setObjectName("gridLayout") + self.sinkLayout = QtGui.QHBoxLayout() + self.sinkLayout.setObjectName("sinkLayout") + self.gridLayout.addLayout(self.sinkLayout, 0, 0, 1, 1) + self.verticalLayout_2.addWidget(self.frame) + self.gridLayout_2.addLayout(self.verticalLayout_2, 0, 0, 1, 1) + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtGui.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 820, 24)) + self.menubar.setObjectName("menubar") + self.menuFile = QtGui.QMenu(self.menubar) + self.menuFile.setObjectName("menuFile") + MainWindow.setMenuBar(self.menubar) + self.statusbar = QtGui.QStatusBar(MainWindow) + self.statusbar.setObjectName("statusbar") + MainWindow.setStatusBar(self.statusbar) + self.actionExit = QtGui.QAction(MainWindow) + self.actionExit.setObjectName("actionExit") + self.actionSaveData = QtGui.QAction(MainWindow) + self.actionSaveData.setObjectName("actionSaveData") + self.menuFile.addAction(self.actionSaveData) + self.menuFile.addAction(self.actionExit) + self.menubar.addAction(self.menuFile.menuAction()) + + self.retranslateUi(MainWindow) + QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), MainWindow.close) + QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), MainWindow.close) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "USRP Display", None, QtGui.QApplication.UnicodeUTF8)) + self.groupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.frequencyLabel.setText(QtGui.QApplication.translate("MainWindow", "Frequency (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.gainLabel.setText(QtGui.QApplication.translate("MainWindow", "RF Gain", None, QtGui.QApplication.UnicodeUTF8)) + self.bandwidthLabel.setText(QtGui.QApplication.translate("MainWindow", "Bandwidth", None, QtGui.QApplication.UnicodeUTF8)) + self.amplifierLabel.setText(QtGui.QApplication.translate("MainWindow", "Amplifier", None, QtGui.QApplication.UnicodeUTF8)) + self.dcCancelCheckBox.setText(QtGui.QApplication.translate("MainWindow", "Cancel DC", None, QtGui.QApplication.UnicodeUTF8)) + self.dcGainLabel.setText(QtGui.QApplication.translate("MainWindow", "DC Canceller Gain", None, QtGui.QApplication.UnicodeUTF8)) + self.pauseButton.setText(QtGui.QApplication.translate("MainWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) + self.closeButton.setText(QtGui.QApplication.translate("MainWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) + self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) + self.actionExit.setText(QtGui.QApplication.translate("MainWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) + self.actionSaveData.setText(QtGui.QApplication.translate("MainWindow", "&Save Data", None, QtGui.QApplication.UnicodeUTF8)) + diff --git a/gr-qtgui/python/usrp_display_qtgui.ui b/gr-qtgui/python/usrp_display_qtgui.ui new file mode 100644 index 000000000..e88ca9dce --- /dev/null +++ b/gr-qtgui/python/usrp_display_qtgui.ui @@ -0,0 +1,375 @@ + + MainWindow + + + + 0 + 0 + 820 + 774 + + + + USRP Display + + + + + + + + + + 0 + 0 + + + + + 240 + 150 + + + + + 240 + 16777215 + + + + Receiver Parameters + + + + + 10 + 20 + 221 + 124 + + + + + + + Frequency (Hz) + + + + + + + RF Gain + + + + + + + Bandwidth + + + + + + + + 0 + 0 + + + + + 120 + 26 + + + + + + + + + 0 + 0 + + + + + 120 + 26 + + + + + + + + + 0 + 0 + + + + + 120 + 26 + + + + + + + + Amplifier + + + + + + + + 0 + 0 + + + + + 120 + 26 + + + + + + + + + + + + + 200 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + -1 + 191 + 151 + + + + + + + Cancel DC + + + + + + + + + DC Canceller Gain + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 80 + + + + + + + + + 0 + 0 + + + + Pause + + + + + + + + 0 + 0 + + + + + 75 + 0 + + + + Close + + + + + + + + + + + + + + 0 + 1 + + + + + 800 + 550 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + + + + + 0 + 0 + 820 + 24 + + + + + &File + + + + + + + + + + E&xit + + + + + &Save Data + + + + + + + closeButton + clicked() + MainWindow + close() + + + 808 + 739 + + + 66 + 561 + + + + + actionExit + triggered() + MainWindow + close() + + + -1 + -1 + + + 617 + 327 + + + + + diff --git a/gr-qtgui/src/.gitignore b/gr-qtgui/src/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/gr-qtgui/src/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/gr-qtgui/src/Makefile.am b/gr-qtgui/src/Makefile.am deleted file mode 100644 index 52b06fbc4..000000000 --- a/gr-qtgui/src/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -# -# Copyright 2008 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. -# - -SUBDIRS = lib -if PYTHON -SUBDIRS += python -endif diff --git a/gr-qtgui/src/python/.gitignore b/gr-qtgui/src/python/.gitignore deleted file mode 100644 index 604b402c5..000000000 --- a/gr-qtgui/src/python/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/Makefile -/Makefile.in -/run_tests diff --git a/gr-qtgui/src/python/Makefile.am b/gr-qtgui/src/python/Makefile.am deleted file mode 100644 index 0953a71e5..000000000 --- a/gr-qtgui/src/python/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright 2008,2009 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. -# - -include $(top_srcdir)/Makefile.common - -TESTS = -EXTRA_DIST += run_tests.in \ - qt_digital_window.ui - -if PYTHON -TESTS += run_tests -DISTCLEANFILES += run_tests - -qtguipythondir = $(grpythondir)/qtgui - -noinst_PYTHON = \ - pyqt_example_f.py \ - pyqt_example.py \ - qt_digital.py \ - qt_digital_window.py \ - usrp2_display.py \ - usrp_display.py \ - qa_qtgui.py - -qtguipython_PYTHON = \ - __init__.py -endif diff --git a/gr-qtgui/src/python/__init__.py b/gr-qtgui/src/python/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/gr-qtgui/src/python/pyqt_example.py b/gr-qtgui/src/python/pyqt_example.py deleted file mode 100755 index 7c0cfc698..000000000 --- a/gr-qtgui/src/python/pyqt_example.py +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio.qtgui import qtgui -from PyQt4 import QtGui, QtCore -import sys, sip - -class dialog_box(QtGui.QWidget): - def __init__(self, display, control): - QtGui.QWidget.__init__(self, None) - self.setWindowTitle('PyQt Test GUI') - - self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) - self.boxlayout.addWidget(display, 1) - self.boxlayout.addWidget(control) - - self.resize(800, 500) - -class control_box(QtGui.QWidget): - def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) - self.setWindowTitle('Control Panel') - - self.setToolTip('Control the signals') - QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) - - self.layout = QtGui.QFormLayout(self) - - # Control the first signal - self.freq1Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) - self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), - self.freq1EditText) - - self.amp1Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) - self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), - self.amp1EditText) - - - # Control the second signal - self.freq2Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) - self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), - self.freq2EditText) - - - self.amp2Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) - self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), - self.amp2EditText) - - self.quit = QtGui.QPushButton('Close', self) - self.layout.addWidget(self.quit) - - self.connect(self.quit, QtCore.SIGNAL('clicked()'), - QtGui.qApp, QtCore.SLOT('quit()')) - - def attach_signal1(self, signal): - self.signal1 = signal - self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) - self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) - - def attach_signal2(self, signal): - self.signal2 = signal - self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) - self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) - - def freq1EditText(self): - try: - newfreq = float(self.freq1Edit.text()) - self.signal1.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp1EditText(self): - try: - newamp = float(self.amp1Edit.text()) - self.signal1.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - - def freq2EditText(self): - try: - newfreq = float(self.freq2Edit.text()) - self.signal2.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp2EditText(self): - try: - newamp = float(self.amp2Edit.text()) - self.signal2.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - Rs = 8000 - f1 = 1000 - f2 = 2000 - - fftsize = 2048 - - self.qapp = QtGui.QApplication(sys.argv) - - src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) - src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_cc() - channel = gr.channel_model(0.001) - thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize) - self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, Rs, - "Complex Signal Example", - True, True, False, True, False) - - self.connect(src1, (src,0)) - self.connect(src2, (src,1)) - self.connect(src, channel, thr, self.snk1) - - self.ctrl_win = control_box() - self.ctrl_win.attach_signal1(src1) - self.ctrl_win.attach_signal2(src2) - - # Get the reference pointer to the SpectrumDisplayForm QWidget - pyQt = self.snk1.pyqwidget() - - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - - self.main_box = dialog_box(self.pyWin, self.ctrl_win) - - self.main_box.show() - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() - diff --git a/gr-qtgui/src/python/pyqt_example_f.py b/gr-qtgui/src/python/pyqt_example_f.py deleted file mode 100755 index 4e36ccca5..000000000 --- a/gr-qtgui/src/python/pyqt_example_f.py +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr, blks2 -from gnuradio.qtgui import qtgui -from PyQt4 import QtGui, QtCore -import sys, sip - -class dialog_box(QtGui.QWidget): - def __init__(self, display, control): - QtGui.QWidget.__init__(self, None) - self.setWindowTitle('PyQt Test GUI') - - self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) - self.boxlayout.addWidget(display, 1) - self.boxlayout.addWidget(control) - - self.resize(800, 500) - -class control_box(QtGui.QWidget): - def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) - self.setWindowTitle('Control Panel') - - self.setToolTip('Control the signals') - QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) - - self.layout = QtGui.QFormLayout(self) - - # Control the first signal - self.freq1Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) - self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), - self.freq1EditText) - - self.amp1Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) - self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), - self.amp1EditText) - - - # Control the second signal - self.freq2Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) - self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), - self.freq2EditText) - - - self.amp2Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) - self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), - self.amp2EditText) - - self.quit = QtGui.QPushButton('Close', self) - self.layout.addWidget(self.quit) - - self.connect(self.quit, QtCore.SIGNAL('clicked()'), - QtGui.qApp, QtCore.SLOT('quit()')) - - def attach_signal1(self, signal): - self.signal1 = signal - self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) - self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) - - def attach_signal2(self, signal): - self.signal2 = signal - self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) - self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) - - def freq1EditText(self): - try: - newfreq = float(self.freq1Edit.text()) - self.signal1.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp1EditText(self): - try: - newamp = float(self.amp1Edit.text()) - self.signal1.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - - def freq2EditText(self): - try: - newfreq = float(self.freq2Edit.text()) - self.signal2.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp2EditText(self): - try: - newamp = float(self.amp2Edit.text()) - self.signal2.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - Rs = 8000 - f1 = 1000 - f2 = 2000 - - fftsize = 2048 - - self.qapp = QtGui.QApplication(sys.argv) - - src1 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) - src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_ff() - thr = gr.throttle(gr.sizeof_float, 100*fftsize) - self.snk1 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, Rs, - "Float Signal Example", - True, True, False, True, False) - - self.connect(src1, (src,0)) - self.connect(src2, (src,1)) - self.connect(src, thr, self.snk1) - - self.ctrl_win = control_box() - self.ctrl_win.attach_signal1(src1) - self.ctrl_win.attach_signal2(src2) - - # Get the reference pointer to the SpectrumDisplayForm QWidget - pyQt = self.snk1.pyqwidget() - - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - - self.main_box = dialog_box(self.pyWin, self.ctrl_win) - - self.main_box.show() - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() - diff --git a/gr-qtgui/src/python/qa_qtgui.py b/gr-qtgui/src/python/qa_qtgui.py deleted file mode 100755 index fbf0de46e..000000000 --- a/gr-qtgui/src/python/qa_qtgui.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python -# -# 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. -# - -from gnuradio import gr, gr_unittest -import qtgui -from PyQt4 import QtGui, QtCore -import sys, sip - -class test_qtgui(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test01 (self): - pass - # Test to make sure we can instantiate these - #self.qapp = QtGui.QApplication(sys.argv) - #self.qtsnk = qtgui.sink_c(1024, gr.firdes.WIN_BLACKMAN_hARRIS, - # 0, 1, "Test", - # True, True, False, True, True) - - -if __name__ == '__main__': - gr_unittest.run(test_qtgui, "test_qtgui.xml") diff --git a/gr-qtgui/src/python/qt_digital.py b/gr-qtgui/src/python/qt_digital.py deleted file mode 100755 index 679f144ef..000000000 --- a/gr-qtgui/src/python/qt_digital.py +++ /dev/null @@ -1,276 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr, blks2 -from gnuradio.qtgui import qtgui -from gnuradio import eng_notation -from PyQt4 import QtGui, QtCore -import sys, sip -import scipy - -try: - from qt_digital_window import Ui_DigitalWindow -except ImportError: - print "Error: could not find qt_digital_window.py:" - print "\t\"Please run: pyuic4 qt_digital_window.ui -o qt_digital_window.py\"" - sys.exit(1) - -class dialog_box(QtGui.QMainWindow): - def __init__(self, snkTx, snkRx, fg, parent=None): - QtGui.QWidget.__init__(self, parent) - self.gui = Ui_DigitalWindow() - self.gui.setupUi(self) - - self.fg = fg - - self.set_sample_rate(self.fg.sample_rate()) - - self.set_snr(self.fg.snr()) - self.set_frequency(self.fg.frequency_offset()) - self.set_time_offset(self.fg.timing_offset()) - - self.set_gain_mu(self.fg.rx_gain_mu()) - self.set_alpha(self.fg.rx_alpha()) - - # Add the qtsnk widgets to the hlayout box - self.gui.sinkLayout.addWidget(snkTx) - self.gui.sinkLayout.addWidget(snkRx) - - - # Connect up some signals - self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), - self.pauseFg) - - self.connect(self.gui.sampleRateEdit, QtCore.SIGNAL("editingFinished()"), - self.sampleRateEditText) - - self.connect(self.gui.snrEdit, QtCore.SIGNAL("editingFinished()"), - self.snrEditText) - self.connect(self.gui.freqEdit, QtCore.SIGNAL("editingFinished()"), - self.freqEditText) - self.connect(self.gui.timeEdit, QtCore.SIGNAL("editingFinished()"), - self.timeEditText) - - self.connect(self.gui.gainMuEdit, QtCore.SIGNAL("editingFinished()"), - self.gainMuEditText) - self.connect(self.gui.alphaEdit, QtCore.SIGNAL("editingFinished()"), - self.alphaEditText) - - - def pauseFg(self): - if(self.gui.pauseButton.text() == "Pause"): - self.fg.stop() - self.fg.wait() - self.gui.pauseButton.setText("Unpause") - else: - self.fg.start() - self.gui.pauseButton.setText("Pause") - - # Accessor functions for Gui to manipulate system parameters - def set_sample_rate(self, sr): - ssr = eng_notation.num_to_str(sr) - self.gui.sampleRateEdit.setText(QtCore.QString("%1").arg(ssr)) - - def sampleRateEditText(self): - try: - rate = self.gui.sampleRateEdit.text().toAscii() - srate = eng_notation.str_to_num(rate) - self.fg.set_sample_rate(srate) - except RuntimeError: - pass - - - # Accessor functions for Gui to manipulate channel model - def set_snr(self, snr): - self.gui.snrEdit.setText(QtCore.QString("%1").arg(snr)) - - def set_frequency(self, fo): - self.gui.freqEdit.setText(QtCore.QString("%1").arg(fo)) - - def set_time_offset(self, to): - self.gui.timeEdit.setText(QtCore.QString("%1").arg(to)) - - def snrEditText(self): - try: - snr = self.gui.snrEdit.text().toDouble()[0] - self.fg.set_snr(snr) - except RuntimeError: - pass - - def freqEditText(self): - try: - freq = self.gui.freqEdit.text().toDouble()[0] - self.fg.set_frequency_offset(freq) - except RuntimeError: - pass - - def timeEditText(self): - try: - to = self.gui.timeEdit.text().toDouble()[0] - self.fg.set_timing_offset(to) - except RuntimeError: - pass - - - # Accessor functions for Gui to manipulate receiver parameters - def set_gain_mu(self, gain): - self.gui.gainMuEdit.setText(QtCore.QString("%1").arg(gain)) - - def set_alpha(self, alpha): - self.gui.alphaEdit.setText(QtCore.QString("%1").arg(alpha)) - - def alphaEditText(self): - try: - alpha = self.gui.alphaEdit.text().toDouble()[0] - self.fg.set_rx_alpha(alpha) - except RuntimeError: - pass - - def gainMuEditText(self): - try: - gain = self.gui.gainMuEdit.text().toDouble()[0] - self.fg.set_rx_gain_mu(gain) - except RuntimeError: - pass - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - self.qapp = QtGui.QApplication(sys.argv) - - self._sample_rate = 2000e3 - - self.sps = 2 - self.excess_bw = 0.35 - self.gray_code = True - - fftsize = 2048 - - self.data = scipy.random.randint(0, 255, 1000) - self.src = gr.vector_source_b(self.data.tolist(), True) - self.mod = blks2.dqpsk_mod(self.sps, self.excess_bw, self.gray_code, False, False) - - self.rrctaps = gr.firdes.root_raised_cosine(1, self.sps, 1, self.excess_bw, 21) - self.rx_rrc = gr.fir_filter_ccf(1, self.rrctaps) - - - # Set up the carrier & clock recovery parameters - self.arity = 4 - self.mu = 0.5 - self.gain_mu = 0.05 - self.omega = self.sps - self.gain_omega = .25 * self.gain_mu * self.gain_mu - self.omega_rel_lim = 0.05 - - self.alpha = 0.15 - self.beta = 0.25 * self.alpha * self.alpha - self.fmin = -1000/self.sample_rate() - self.fmax = 1000/self.sample_rate() - - self.receiver = gr.mpsk_receiver_cc(self.arity, 0, - self.alpha, self.beta, - self.fmin, self.fmax, - self.mu, self.gain_mu, - self.omega, self.gain_omega, - self.omega_rel_lim) - - - self.snr_dB = 15 - noise = self.get_noise_voltage(self.snr_dB) - self.fo = 100/self.sample_rate() - self.to = 1.0 - self.channel = gr.channel_model(noise, self.fo, self.to) - - self.thr = gr.throttle(gr.sizeof_char, self._sample_rate) - self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, self._sample_rate*self.sps, - "Tx", True, True, False, True, True) - - self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, self._sample_rate, - "Rx", True, True, False, True, True) - - self.connect(self.src, self.thr, self.mod, self.channel, self.snk_tx) - self.connect(self.channel, self.rx_rrc, self.receiver, self.snk_rx) - - pyTxQt = self.snk_tx.pyqwidget() - pyTx = sip.wrapinstance(pyTxQt, QtGui.QWidget) - - pyRxQt = self.snk_rx.pyqwidget() - pyRx = sip.wrapinstance(pyRxQt, QtGui.QWidget) - - self.main_box = dialog_box(pyTx, pyRx, self); - self.main_box.show() - - - def get_noise_voltage(self, SNR): - S = 0 # dBm, assuming signal power normalized - N = S - SNR # dBm - npwr = pow(10.0, N/10.0) # ratio - nv = scipy.sqrt(npwr * self.sps) # convert the noise voltage - return nv - - - # System Parameters - def sample_rate(self): - return self._sample_rate - - def set_sample_rate(self, sr): - self._sample_rate = sr - - - # Channel Model Parameters - def snr(self): - return self.snr_dB - - def set_snr(self, snr): - self.snr_dB = snr - noise = self.get_noise_voltage(self.snr_dB) - self.channel.set_noise_voltage(noise) - - def frequency_offset(self): - return self.fo * self.sample_rate() - - def set_frequency_offset(self, fo): - self.fo = fo / self.sample_rate() - self.channel.set_frequency_offset(self.fo) - - def timing_offset(self): - return self.to - - def set_timing_offset(self, to): - self.to = to - self.channel.set_timing_offset(self.to) - - - # Receiver Parameters - def rx_gain_mu(self): - return self.gain_mu - - def rx_gain_omega(self): - return self.gain_omega - - def set_rx_gain_mu(self, gain): - self.gain_mu = gain - self.gain_omega = .25 * self.gain_mu * self.gain_mu - self.receiver.set_gain_mu(self.gain_mu) - self.receiver.set_gain_omega(self.gain_omega) - - def rx_alpha(self): - return self.alpha - - def rx_beta(self): - return self.beta - - def set_rx_alpha(self, alpha): - self.alpha = alpha - self.beta = .25 * self.alpha * self.alpha - self.receiver.set_alpha(self.alpha) - self.receiver.set_beta(self.beta) - - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() diff --git a/gr-qtgui/src/python/qt_digital_window.py b/gr-qtgui/src/python/qt_digital_window.py deleted file mode 100644 index 50dd53a92..000000000 --- a/gr-qtgui/src/python/qt_digital_window.py +++ /dev/null @@ -1,161 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'qt_digital_window.ui' -# -# Created: Sat May 1 20:14:02 2010 -# by: PyQt4 UI code generator 4.6.1 -# -# WARNING! All changes made in this file will be lost! - -from PyQt4 import QtCore, QtGui - -class Ui_DigitalWindow(object): - def setupUi(self, DigitalWindow): - DigitalWindow.setObjectName("DigitalWindow") - DigitalWindow.resize(1236, 741) - self.centralwidget = QtGui.QWidget(DigitalWindow) - self.centralwidget.setObjectName("centralwidget") - self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) - self.verticalLayout.setObjectName("verticalLayout") - self.sinkFrame = QtGui.QFrame(self.centralwidget) - self.sinkFrame.setMinimumSize(QtCore.QSize(0, 550)) - self.sinkFrame.setFrameShape(QtGui.QFrame.StyledPanel) - self.sinkFrame.setFrameShadow(QtGui.QFrame.Raised) - self.sinkFrame.setObjectName("sinkFrame") - self.horizontalLayout_2 = QtGui.QHBoxLayout(self.sinkFrame) - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.sinkLayout = QtGui.QHBoxLayout() - self.sinkLayout.setObjectName("sinkLayout") - self.horizontalLayout_2.addLayout(self.sinkLayout) - self.verticalLayout.addWidget(self.sinkFrame) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.sysBox = QtGui.QGroupBox(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.sysBox.sizePolicy().hasHeightForWidth()) - self.sysBox.setSizePolicy(sizePolicy) - self.sysBox.setMinimumSize(QtCore.QSize(0, 0)) - self.sysBox.setMaximumSize(QtCore.QSize(16777215, 120)) - self.sysBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) - self.sysBox.setObjectName("sysBox") - self.gridLayout_2 = QtGui.QGridLayout(self.sysBox) - self.gridLayout_2.setObjectName("gridLayout_2") - self.sampleRateEdit = QtGui.QLineEdit(self.sysBox) - self.sampleRateEdit.setMaximumSize(QtCore.QSize(100, 16777215)) - self.sampleRateEdit.setObjectName("sampleRateEdit") - self.gridLayout_2.addWidget(self.sampleRateEdit, 0, 3, 1, 1) - self.sampleRateLabel = QtGui.QLabel(self.sysBox) - self.sampleRateLabel.setObjectName("sampleRateLabel") - self.gridLayout_2.addWidget(self.sampleRateLabel, 0, 2, 1, 1) - self.horizontalLayout.addWidget(self.sysBox) - self.rxBox = QtGui.QGroupBox(self.centralwidget) - self.rxBox.setMaximumSize(QtCore.QSize(16777215, 120)) - self.rxBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) - self.rxBox.setObjectName("rxBox") - self.gridLayout_3 = QtGui.QGridLayout(self.rxBox) - self.gridLayout_3.setObjectName("gridLayout_3") - self.alphaLabel = QtGui.QLabel(self.rxBox) - self.alphaLabel.setObjectName("alphaLabel") - self.gridLayout_3.addWidget(self.alphaLabel, 1, 0, 1, 1) - self.alphaEdit = QtGui.QLineEdit(self.rxBox) - self.alphaEdit.setMaximumSize(QtCore.QSize(100, 16777215)) - self.alphaEdit.setObjectName("alphaEdit") - self.gridLayout_3.addWidget(self.alphaEdit, 1, 1, 1, 1) - self.gainMuLabel = QtGui.QLabel(self.rxBox) - self.gainMuLabel.setObjectName("gainMuLabel") - self.gridLayout_3.addWidget(self.gainMuLabel, 0, 0, 1, 1) - self.gainMuEdit = QtGui.QLineEdit(self.rxBox) - self.gainMuEdit.setMaximumSize(QtCore.QSize(100, 16777215)) - self.gainMuEdit.setObjectName("gainMuEdit") - self.gridLayout_3.addWidget(self.gainMuEdit, 0, 1, 1, 1) - self.horizontalLayout.addWidget(self.rxBox) - self.channelModeBox = QtGui.QGroupBox(self.centralwidget) - self.channelModeBox.setMaximumSize(QtCore.QSize(16777215, 120)) - self.channelModeBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) - self.channelModeBox.setObjectName("channelModeBox") - self.gridLayout = QtGui.QGridLayout(self.channelModeBox) - self.gridLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize) - self.gridLayout.setObjectName("gridLayout") - self.snrLabel = QtGui.QLabel(self.channelModeBox) - self.snrLabel.setObjectName("snrLabel") - self.gridLayout.addWidget(self.snrLabel, 0, 1, 1, 1) - self.snrEdit = QtGui.QLineEdit(self.channelModeBox) - self.snrEdit.setMaximumSize(QtCore.QSize(100, 16777215)) - self.snrEdit.setObjectName("snrEdit") - self.gridLayout.addWidget(self.snrEdit, 0, 2, 1, 1) - self.freqLabel = QtGui.QLabel(self.channelModeBox) - self.freqLabel.setObjectName("freqLabel") - self.gridLayout.addWidget(self.freqLabel, 1, 1, 1, 1) - self.freqEdit = QtGui.QLineEdit(self.channelModeBox) - self.freqEdit.setMaximumSize(QtCore.QSize(100, 16777215)) - self.freqEdit.setObjectName("freqEdit") - self.gridLayout.addWidget(self.freqEdit, 1, 2, 1, 1) - self.timeLabel = QtGui.QLabel(self.channelModeBox) - self.timeLabel.setObjectName("timeLabel") - self.gridLayout.addWidget(self.timeLabel, 2, 1, 1, 1) - self.timeEdit = QtGui.QLineEdit(self.channelModeBox) - self.timeEdit.setMaximumSize(QtCore.QSize(100, 16777215)) - self.timeEdit.setObjectName("timeEdit") - self.gridLayout.addWidget(self.timeEdit, 2, 2, 1, 1) - self.horizontalLayout.addWidget(self.channelModeBox) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem) - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName("verticalLayout_2") - spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout_2.addItem(spacerItem1) - self.pauseButton = QtGui.QPushButton(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pauseButton.sizePolicy().hasHeightForWidth()) - self.pauseButton.setSizePolicy(sizePolicy) - self.pauseButton.setMaximumSize(QtCore.QSize(80, 16777215)) - self.pauseButton.setObjectName("pauseButton") - self.verticalLayout_2.addWidget(self.pauseButton) - self.closeButton = QtGui.QPushButton(self.centralwidget) - self.closeButton.setMaximumSize(QtCore.QSize(80, 16777215)) - self.closeButton.setObjectName("closeButton") - self.verticalLayout_2.addWidget(self.closeButton) - self.horizontalLayout.addLayout(self.verticalLayout_2) - self.verticalLayout.addLayout(self.horizontalLayout) - DigitalWindow.setCentralWidget(self.centralwidget) - self.menubar = QtGui.QMenuBar(DigitalWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 1236, 23)) - self.menubar.setObjectName("menubar") - self.menuFile = QtGui.QMenu(self.menubar) - self.menuFile.setObjectName("menuFile") - DigitalWindow.setMenuBar(self.menubar) - self.statusbar = QtGui.QStatusBar(DigitalWindow) - self.statusbar.setObjectName("statusbar") - DigitalWindow.setStatusBar(self.statusbar) - self.actionExit = QtGui.QAction(DigitalWindow) - self.actionExit.setObjectName("actionExit") - self.menuFile.addAction(self.actionExit) - self.menubar.addAction(self.menuFile.menuAction()) - - self.retranslateUi(DigitalWindow) - QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), DigitalWindow.close) - QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), DigitalWindow.close) - QtCore.QMetaObject.connectSlotsByName(DigitalWindow) - DigitalWindow.setTabOrder(self.snrEdit, self.freqEdit) - DigitalWindow.setTabOrder(self.freqEdit, self.timeEdit) - - def retranslateUi(self, DigitalWindow): - DigitalWindow.setWindowTitle(QtGui.QApplication.translate("DigitalWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) - self.sysBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.sampleRateLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Sample Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) - self.rxBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.alphaLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Alpha", None, QtGui.QApplication.UnicodeUTF8)) - self.gainMuLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Gain mu", None, QtGui.QApplication.UnicodeUTF8)) - self.channelModeBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Channel Model Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.snrLabel.setText(QtGui.QApplication.translate("DigitalWindow", "SNR (dB)", None, QtGui.QApplication.UnicodeUTF8)) - self.freqLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Frequency Offset (Hz)", None, QtGui.QApplication.UnicodeUTF8)) - self.timeLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Timing Offset", None, QtGui.QApplication.UnicodeUTF8)) - self.pauseButton.setText(QtGui.QApplication.translate("DigitalWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) - self.closeButton.setText(QtGui.QApplication.translate("DigitalWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) - self.menuFile.setTitle(QtGui.QApplication.translate("DigitalWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) - self.actionExit.setText(QtGui.QApplication.translate("DigitalWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/gr-qtgui/src/python/qt_digital_window.ui b/gr-qtgui/src/python/qt_digital_window.ui deleted file mode 100644 index 967252181..000000000 --- a/gr-qtgui/src/python/qt_digital_window.ui +++ /dev/null @@ -1,342 +0,0 @@ - - - DigitalWindow - - - - 0 - 0 - 1236 - 741 - - - - MainWindow - - - - - - - - 0 - 550 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 120 - - - - System Parameters - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - 100 - 16777215 - - - - - - - - Sample Rate (sps) - - - - - - - - - - - 16777215 - 120 - - - - Receiver Parameters - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - Alpha - - - - - - - - 100 - 16777215 - - - - - - - - Gain mu - - - - - - - - 100 - 16777215 - - - - - - - - - - - - 16777215 - 120 - - - - Channel Model Parameters - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - QLayout::SetMinimumSize - - - - - SNR (dB) - - - - - - - - 100 - 16777215 - - - - - - - - Frequency Offset (Hz) - - - - - - - - 100 - 16777215 - - - - - - - - Timing Offset - - - - - - - - 100 - 16777215 - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - - 80 - 16777215 - - - - Pause - - - - - - - - 80 - 16777215 - - - - Close - - - - - - - - - - - - - 0 - 0 - 1236 - 23 - - - - - &File - - - - - - - - - E&xit - - - - - snrEdit - freqEdit - timeEdit - - - - - closeButton - clicked() - DigitalWindow - close() - - - 322 - 623 - - - 66 - 561 - - - - - actionExit - triggered() - DigitalWindow - close() - - - -1 - -1 - - - 617 - 327 - - - - - diff --git a/gr-qtgui/src/python/run_tests.in b/gr-qtgui/src/python/run_tests.in deleted file mode 100644 index 909194752..000000000 --- a/gr-qtgui/src/python/run_tests.in +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# 1st parameter is absolute path to component source directory -# 2nd parameter is absolute path to component build directory -# 3rd parameter is path to Python QA directory - -@top_builddir@/run_tests.sh \ - @abs_top_srcdir@/gr-qtgui \ - @abs_top_builddir@/gr-qtgui \ - @srcdir@ diff --git a/gr-qtgui/src/python/usrp2_display.py b/gr-qtgui/src/python/usrp2_display.py deleted file mode 100755 index 75d374c2b..000000000 --- a/gr-qtgui/src/python/usrp2_display.py +++ /dev/null @@ -1,313 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr -from gnuradio import usrp2 -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from gnuradio.qtgui import qtgui -from optparse import OptionParser -import sys - -try: - from gnuradio.qtgui import qtgui - from PyQt4 import QtGui, QtCore - import sip -except ImportError: - print "Please install gr-qtgui." - sys.exit(1) - -try: - from usrp_display_qtgui import Ui_MainWindow -except ImportError: - print "Error: could not find usrp_display_qtgui.py:" - print "\t\"pyuic4 usrp_display_qtgui.ui -o usrp_display_qtgui.py\"" - sys.exit(1) - - -# //////////////////////////////////////////////////////////////////// -# Define the QT Interface and Control Dialog -# //////////////////////////////////////////////////////////////////// - - -class main_window(QtGui.QMainWindow): - def __init__(self, snk, fg, parent=None): - - QtGui.QWidget.__init__(self, parent) - self.gui = Ui_MainWindow() - self.gui.setupUi(self) - - self.fg = fg - - # Add the qtsnk widgets to the layout box - self.gui.sinkLayout.addWidget(snk) - - self.gui.dcGainEdit.setText(QtCore.QString("%1").arg(0.001)) - - # Connect up some signals - self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), - self.pauseFg) - self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"), - self.frequencyEditText) - self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"), - self.gainEditText) - self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"), - self.bandwidthEditText) - self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"), - self.amplifierEditText) - - self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"), - self.saveData) - self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save) - - self.connect(self.gui.dcGainEdit, QtCore.SIGNAL("editingFinished()"), - self.dcGainEditText) - self.connect(self.gui.dcCancelCheckBox, QtCore.SIGNAL("clicked(bool)"), - self.dcCancelClicked) - - def pauseFg(self): - if(self.gui.pauseButton.text() == "Pause"): - self.fg.stop() - self.fg.wait() - self.gui.pauseButton.setText("Unpause") - else: - self.fg.start() - self.gui.pauseButton.setText("Pause") - - - # Functions to set the values in the GUI - def set_frequency(self, freq): - self.freq = freq - sfreq = eng_notation.num_to_str(self.freq) - self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq)) - - def set_gain(self, gain): - self.gain = gain - self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain)) - - def set_bandwidth(self, bw): - self.bw = bw - sbw = eng_notation.num_to_str(self.bw) - self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw)) - - def set_amplifier(self, amp): - self.amp = amp - self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp)) - - - # Functions called when signals are triggered in the GUI - def frequencyEditText(self): - try: - freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii()) - self.fg.set_frequency(freq) - self.freq = freq - except RuntimeError: - pass - - def gainEditText(self): - try: - gain = float(self.gui.gainEdit.text()) - self.fg.set_gain(gain) - self.gain = gain - except ValueError: - pass - - def bandwidthEditText(self): - try: - bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii()) - self.fg.set_bandwidth(bw) - self.bw = bw - except ValueError: - pass - - def amplifierEditText(self): - try: - amp = float(self.gui.amplifierEdit.text()) - self.fg.set_amplifier_gain(amp) - self.amp = amp - except ValueError: - pass - - def saveData(self): - fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", "."); - if(len(fileName)): - self.fg.save_to_file(str(fileName)) - - def dcGainEditText(self): - gain = float(self.gui.dcGainEdit.text()) - self.fg.set_dc_gain(gain) - - def dcCancelClicked(self, state): - self.dcGainEditText() - self.fg.cancel_dc(state) - - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - parser = OptionParser(option_class=eng_option) - parser.add_option("-e", "--interface", type="string", default="eth0", - help="select Ethernet interface, default is eth0") - parser.add_option("-m", "--mac-addr", type="string", default="", - help="select USRP by MAC address, default is auto-select") - parser.add_option("-W", "--bw", type="eng_float", default=1e6, - help="set bandwidth of receiver [default=%default]") - parser.add_option("-f", "--freq", type="eng_float", default=2412e6, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("--fft-size", type="int", default=2048, - help="Set number of FFT bins [default=%default]") - (options, args) = parser.parse_args() - - if len(args) != 0: - parser.print_help() - sys.exit(1) - self.options = options - self.show_debug_info = True - - self.qapp = QtGui.QApplication(sys.argv) - - self.u = usrp2.source_32fc(options.interface, options.mac_addr) - self._adc_rate = self.u.adc_rate() - self.set_bandwidth(options.bw) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.gain_range() - options.gain = float(g[0]+g[1])/2 - self.set_gain(options.gain) - - if options.freq is None: - # if no frequency was specified, use the mid-point of the subdev - f = self.u.freq_range() - options.freq = float(f[0]+f[1])/2 - self.set_frequency(options.freq) - - self._fftsize = options.fft_size - - self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS, - self._freq, self._bandwidth, - "USRP2 Display", - True, True, False, True, False) - - # Set up internal amplifier - self.amp = gr.multiply_const_cc(0.0) - self.set_amplifier_gain(100) - - # Create a single-pole IIR filter to remove DC - # but don't connect it yet - self.dc_gain = 0.001 - self.dc = gr.single_pole_iir_filter_cc(self.dc_gain) - self.dc_sub = gr.sub_cc() - - self.connect(self.u, self.amp, self.snk) - - if self.show_debug_info: - print "Decimation rate: ", self._decim - print "Bandwidth: ", self._bandwidth - print "D'board: ", self.u.daughterboard_id() - - # Get the reference pointer to the SpectrumDisplayForm QWidget - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) - - self.main_win = main_window(self.pysink, self) - - self.main_win.set_frequency(self._freq) - self.main_win.set_gain(self._gain) - self.main_win.set_bandwidth(self._bandwidth) - self.main_win.set_amplifier(self._amp_value) - - self.main_win.show() - - - def save_to_file(self, name): - self.lock() - - # Add file sink to save data - self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name) - self.connect(self.amp, self.file_sink) - - self.unlock() - - def set_gain(self, gain): - self._gain = gain - self.u.set_gain(self._gain) - - def set_frequency(self, freq): - self._freq = freq - r = self.u.set_center_freq(freq) - - try: - self.snk.set_frequency_range(self._freq, self._bandwidth) - except: - pass - - def set_bandwidth(self, bw): - self._bandwidth = bw - self._decim = int(self._adc_rate / self._bandwidth) - self.u.set_decim(self._decim) - - try: - self.snk.set_frequency_range(self._freq, self._bandwidth) - except: - pass - - def set_amplifier_gain(self, amp): - self._amp_value = amp - self.amp.set_k(self._amp_value) - - def set_dc_gain(self, gain): - self.dc.set_taps(gain) - - def cancel_dc(self, state): - self.lock() - - if(state): - self.disconnect(self.u, self.amp) - self.connect(self.u, (self.dc_sub,0)) - self.connect(self.u, self.dc, (self.dc_sub,1)) - self.connect(self.dc_sub, self.amp) - else: - self.disconnect(self.dc_sub, self.amp) - self.disconnect(self.dc, (self.dc_sub,1)) - self.disconnect(self.u, self.dc) - self.disconnect(self.u, (self.dc_sub,0)) - self.connect(self.u, self.amp) - - self.unlock() - -def main (): - tb = my_top_block() - tb.start() - tb.snk.exec_(); - -if __name__ == '__main__': - try: - main () - except KeyboardInterrupt: - pass - diff --git a/gr-qtgui/src/python/usrp_display.py b/gr-qtgui/src/python/usrp_display.py deleted file mode 100755 index 432e74d9a..000000000 --- a/gr-qtgui/src/python/usrp_display.py +++ /dev/null @@ -1,299 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr -from gnuradio import usrp -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from gnuradio.qtgui import qtgui -from optparse import OptionParser -import sys - -try: - from gnuradio.qtgui import qtgui - from PyQt4 import QtGui, QtCore - import sip -except ImportError: - print "Please install gr-qtgui." - sys.exit(1) - -try: - from usrp_display_qtgui import Ui_MainWindow -except ImportError: - print "Error: could not find usrp_display_qtgui.py:" - print "\t\"pyuic4 usrp_display_qtgui.ui -o usrp_display_qtgui.py\"" - sys.exit(1) - - - -# //////////////////////////////////////////////////////////////////// -# Define the QT Interface and Control Dialog -# //////////////////////////////////////////////////////////////////// - - -class main_window(QtGui.QMainWindow): - def __init__(self, snk, fg, parent=None): - - QtGui.QWidget.__init__(self, parent) - self.gui = Ui_MainWindow() - self.gui.setupUi(self) - - self.fg = fg - - # Add the qtsnk widgets to the layout box - self.gui.sinkLayout.addWidget(snk) - - # Connect up some signals - self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), - self.pauseFg) - self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"), - self.frequencyEditText) - self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"), - self.gainEditText) - self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"), - self.bandwidthEditText) - self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"), - self.amplifierEditText) - - self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"), - self.saveData) - self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save) - - def pauseFg(self): - if(self.gui.pauseButton.text() == "Pause"): - self.fg.stop() - self.fg.wait() - self.gui.pauseButton.setText("Unpause") - else: - self.fg.start() - self.gui.pauseButton.setText("Pause") - - - # Functions to set the values in the GUI - def set_frequency(self, freq): - self.freq = freq - sfreq = eng_notation.num_to_str(self.freq) - self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq)) - - def set_gain(self, gain): - self.gain = gain - self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain)) - - def set_bandwidth(self, bw): - self.bw = bw - sbw = eng_notation.num_to_str(self.bw) - self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw)) - - def set_amplifier(self, amp): - self.amp = amp - self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp)) - - - # Functions called when signals are triggered in the GUI - def frequencyEditText(self): - try: - freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii()) - self.fg.set_frequency(freq) - self.freq = freq - except RuntimeError: - pass - - def gainEditText(self): - try: - gain = float(self.gui.gainEdit.text()) - self.fg.set_gain(gain) - self.gain = gain - except ValueError: - pass - - def bandwidthEditText(self): - try: - bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii()) - self.fg.set_bandwidth(bw) - self.bw = bw - except ValueError: - pass - - def amplifierEditText(self): - try: - amp = float(self.gui.amplifierEdit.text()) - self.fg.set_amplifier_gain(amp) - self.amp = amp - except ValueError: - pass - - def saveData(self): - fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", "."); - if(len(fileName)): - self.fg.save_to_file(str(fileName)) - - -def pick_subdevice(u): - """ - The user didn't specify a subdevice on the command line. - If there's a daughterboard on A, select A. - If there's a daughterboard on B, select B. - Otherwise, select A. - """ - if u.db(0, 0).dbid() >= 0: # dbid is < 0 if there's no d'board or a problem - return (0, 0) - if u.db(0, 0).dbid() >= 0: - return (1, 0) - return (0, 0) - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - parser = OptionParser(option_class=eng_option) - parser.add_option("-w", "--which", type="int", default=0, - help="select which USRP (0, 1, ...) default is %default", - metavar="NUM") - parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, - help="select USRP Rx side A or B (default=first one with a daughterboard)") - parser.add_option("-A", "--antenna", default=None, - help="select Rx Antenna (only on RFX-series boards)") - parser.add_option("-W", "--bw", type="float", default=1e6, - help="set bandwidth of receiver [default=%default]") - parser.add_option("-f", "--freq", type="eng_float", default=None, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB [default is midpoint]") - parser.add_option("-8", "--width-8", action="store_true", default=False, - help="Enable 8-bit samples across USB") - parser.add_option( "--no-hb", action="store_true", default=False, - help="don't use halfband filter in usrp") - parser.add_option("-S", "--oscilloscope", action="store_true", default=False, - help="Enable oscilloscope display") - parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1, - help="Set fftsink averaging factor, [default=%default]") - parser.add_option("", "--ref-scale", type="eng_float", default=13490.0, - help="Set dBFS=0dB input value, [default=%default]") - parser.add_option("", "--fft-size", type="int", default=2048, - help="Set FFT frame size, [default=%default]"); - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - self.options = options - self.show_debug_info = True - - # Call this before creating the Qt sink - self.qapp = QtGui.QApplication(sys.argv) - - self._fftsize = options.fft_size - - self.u = usrp.source_c(which=options.which) - self._adc_rate = self.u.converter_rate() - self.set_bandwidth(options.bw) - - if options.rx_subdev_spec is None: - options.rx_subdev_spec = pick_subdevice(self.u) - self._rx_subdev_spec = options.rx_subdev_spec - self.u.set_mux(usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec)) - self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec) - - self._gain_range = self.subdev.gain_range() - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self._gain_range - options.gain = float(g[0]+g[1])/2 - self.set_gain(options.gain) - - if options.freq is None: - # if no frequency was specified, use the mid-point of the subdev - f = self.subdev.freq_range() - options.freq = float(f[0]+f[1])/2 - self.set_frequency(options.freq) - - self.snk = qtgui.sink_c(self._fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - self._freq, self._bandwidth, - "USRP Display", - True, True, False, True, False) - - # Set up internal amplifier - self.amp = gr.multiply_const_cc(0.0) - self.set_amplifier_gain(0.001) - - # Connect the flow graph - self.connect(self.u, self.amp, self.snk) - - - # Get the reference pointer to the SpectrumDisplayForm QWidget - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) - - self.main_win = main_window(self.pysink, self) - - self.main_win.set_frequency(self._freq) - self.main_win.set_gain(self._gain) - self.main_win.set_bandwidth(self._bandwidth) - self.main_win.set_amplifier(self._amp_value) - - self.main_win.show() - - def save_to_file(self, name): - # Pause the flow graph - self.stop() - self.wait() - - # Add file sink to save data - self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name) - self.connect(self.amp, self.file_sink) - - # Restart flow graph - self.start() - - def set_gain(self, gain): - self._gain = gain - self.subdev.set_gain(self._gain) - - def set_frequency(self, freq): - self._freq = freq - self.u.tune(0, self.subdev, self._freq) - - try: - self.snk.set_frequency_range(self._freq, self._bandwidth) - except: - pass - - def set_bandwidth(self, bw): - self._bandwidth = bw - self._decim = int(self._adc_rate / self._bandwidth) - self.u.set_decim_rate(self._decim) - - try: - self.snk.set_frequency_range(self._freq, self._bandwidth) - except: - pass - - def set_amplifier_gain(self, amp): - self._amp_value = amp - self.amp.set_k(self._amp_value) - - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() diff --git a/gr-qtgui/src/python/usrp_display_qtgui.py b/gr-qtgui/src/python/usrp_display_qtgui.py deleted file mode 100644 index 4c9de3a53..000000000 --- a/gr-qtgui/src/python/usrp_display_qtgui.py +++ /dev/null @@ -1,191 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'usrp_display_qtgui.ui' -# -# Created: Thu Jul 16 22:06:24 2009 -# by: PyQt4 UI code generator 4.4.3 -# -# WARNING! All changes made in this file will be lost! - -from PyQt4 import QtCore, QtGui - -class Ui_MainWindow(object): - def setupUi(self, MainWindow): - MainWindow.setObjectName("MainWindow") - MainWindow.resize(820, 774) - self.centralwidget = QtGui.QWidget(MainWindow) - self.centralwidget.setObjectName("centralwidget") - self.gridLayout_2 = QtGui.QGridLayout(self.centralwidget) - self.gridLayout_2.setObjectName("gridLayout_2") - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.groupBox = QtGui.QGroupBox(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth()) - self.groupBox.setSizePolicy(sizePolicy) - self.groupBox.setMinimumSize(QtCore.QSize(240, 150)) - self.groupBox.setMaximumSize(QtCore.QSize(240, 16777215)) - self.groupBox.setObjectName("groupBox") - self.formLayoutWidget = QtGui.QWidget(self.groupBox) - self.formLayoutWidget.setGeometry(QtCore.QRect(10, 20, 221, 124)) - self.formLayoutWidget.setObjectName("formLayoutWidget") - self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) - self.formLayout.setObjectName("formLayout") - self.frequencyLabel = QtGui.QLabel(self.formLayoutWidget) - self.frequencyLabel.setObjectName("frequencyLabel") - self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.frequencyLabel) - self.gainLabel = QtGui.QLabel(self.formLayoutWidget) - self.gainLabel.setObjectName("gainLabel") - self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.gainLabel) - self.bandwidthLabel = QtGui.QLabel(self.formLayoutWidget) - self.bandwidthLabel.setObjectName("bandwidthLabel") - self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.bandwidthLabel) - self.frequencyEdit = QtGui.QLineEdit(self.formLayoutWidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.frequencyEdit.sizePolicy().hasHeightForWidth()) - self.frequencyEdit.setSizePolicy(sizePolicy) - self.frequencyEdit.setMinimumSize(QtCore.QSize(120, 26)) - self.frequencyEdit.setObjectName("frequencyEdit") - self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.frequencyEdit) - self.gainEdit = QtGui.QLineEdit(self.formLayoutWidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.gainEdit.sizePolicy().hasHeightForWidth()) - self.gainEdit.setSizePolicy(sizePolicy) - self.gainEdit.setMinimumSize(QtCore.QSize(120, 26)) - self.gainEdit.setObjectName("gainEdit") - self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.gainEdit) - self.bandwidthEdit = QtGui.QLineEdit(self.formLayoutWidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.bandwidthEdit.sizePolicy().hasHeightForWidth()) - self.bandwidthEdit.setSizePolicy(sizePolicy) - self.bandwidthEdit.setMinimumSize(QtCore.QSize(120, 26)) - self.bandwidthEdit.setObjectName("bandwidthEdit") - self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.bandwidthEdit) - self.amplifierLabel = QtGui.QLabel(self.formLayoutWidget) - self.amplifierLabel.setObjectName("amplifierLabel") - self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.amplifierLabel) - self.amplifierEdit = QtGui.QLineEdit(self.formLayoutWidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.amplifierEdit.sizePolicy().hasHeightForWidth()) - self.amplifierEdit.setSizePolicy(sizePolicy) - self.amplifierEdit.setMinimumSize(QtCore.QSize(120, 26)) - self.amplifierEdit.setObjectName("amplifierEdit") - self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.amplifierEdit) - self.horizontalLayout_2.addWidget(self.groupBox) - self.frame_2 = QtGui.QFrame(self.centralwidget) - self.frame_2.setMinimumSize(QtCore.QSize(200, 0)) - self.frame_2.setFrameShape(QtGui.QFrame.StyledPanel) - self.frame_2.setFrameShadow(QtGui.QFrame.Raised) - self.frame_2.setObjectName("frame_2") - self.verticalLayoutWidget = QtGui.QWidget(self.frame_2) - self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, -1, 191, 151)) - self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") - self.verticalLayout_3 = QtGui.QVBoxLayout(self.verticalLayoutWidget) - self.verticalLayout_3.setObjectName("verticalLayout_3") - self.dcCancelCheckBox = QtGui.QCheckBox(self.verticalLayoutWidget) - self.dcCancelCheckBox.setObjectName("dcCancelCheckBox") - self.verticalLayout_3.addWidget(self.dcCancelCheckBox) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.dcGainLabel = QtGui.QLabel(self.verticalLayoutWidget) - self.dcGainLabel.setObjectName("dcGainLabel") - self.horizontalLayout.addWidget(self.dcGainLabel) - self.dcGainEdit = QtGui.QLineEdit(self.verticalLayoutWidget) - self.dcGainEdit.setObjectName("dcGainEdit") - self.horizontalLayout.addWidget(self.dcGainEdit) - self.verticalLayout_3.addLayout(self.horizontalLayout) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout_3.addItem(spacerItem) - self.horizontalLayout_2.addWidget(self.frame_2) - spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_2.addItem(spacerItem1) - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") - spacerItem2 = QtGui.QSpacerItem(20, 80, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - self.verticalLayout.addItem(spacerItem2) - self.pauseButton = QtGui.QPushButton(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pauseButton.sizePolicy().hasHeightForWidth()) - self.pauseButton.setSizePolicy(sizePolicy) - self.pauseButton.setObjectName("pauseButton") - self.verticalLayout.addWidget(self.pauseButton) - self.closeButton = QtGui.QPushButton(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.closeButton.sizePolicy().hasHeightForWidth()) - self.closeButton.setSizePolicy(sizePolicy) - self.closeButton.setMinimumSize(QtCore.QSize(75, 0)) - self.closeButton.setObjectName("closeButton") - self.verticalLayout.addWidget(self.closeButton) - self.horizontalLayout_2.addLayout(self.verticalLayout) - self.gridLayout_2.addLayout(self.horizontalLayout_2, 1, 0, 1, 1) - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.frame = QtGui.QFrame(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(1) - sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth()) - self.frame.setSizePolicy(sizePolicy) - self.frame.setMinimumSize(QtCore.QSize(800, 550)) - self.frame.setFrameShape(QtGui.QFrame.StyledPanel) - self.frame.setFrameShadow(QtGui.QFrame.Raised) - self.frame.setObjectName("frame") - self.gridLayout = QtGui.QGridLayout(self.frame) - self.gridLayout.setObjectName("gridLayout") - self.sinkLayout = QtGui.QHBoxLayout() - self.sinkLayout.setObjectName("sinkLayout") - self.gridLayout.addLayout(self.sinkLayout, 0, 0, 1, 1) - self.verticalLayout_2.addWidget(self.frame) - self.gridLayout_2.addLayout(self.verticalLayout_2, 0, 0, 1, 1) - MainWindow.setCentralWidget(self.centralwidget) - self.menubar = QtGui.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 820, 24)) - self.menubar.setObjectName("menubar") - self.menuFile = QtGui.QMenu(self.menubar) - self.menuFile.setObjectName("menuFile") - MainWindow.setMenuBar(self.menubar) - self.statusbar = QtGui.QStatusBar(MainWindow) - self.statusbar.setObjectName("statusbar") - MainWindow.setStatusBar(self.statusbar) - self.actionExit = QtGui.QAction(MainWindow) - self.actionExit.setObjectName("actionExit") - self.actionSaveData = QtGui.QAction(MainWindow) - self.actionSaveData.setObjectName("actionSaveData") - self.menuFile.addAction(self.actionSaveData) - self.menuFile.addAction(self.actionExit) - self.menubar.addAction(self.menuFile.menuAction()) - - self.retranslateUi(MainWindow) - QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), MainWindow.close) - QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), MainWindow.close) - QtCore.QMetaObject.connectSlotsByName(MainWindow) - - def retranslateUi(self, MainWindow): - MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "USRP Display", None, QtGui.QApplication.UnicodeUTF8)) - self.groupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.frequencyLabel.setText(QtGui.QApplication.translate("MainWindow", "Frequency (Hz)", None, QtGui.QApplication.UnicodeUTF8)) - self.gainLabel.setText(QtGui.QApplication.translate("MainWindow", "RF Gain", None, QtGui.QApplication.UnicodeUTF8)) - self.bandwidthLabel.setText(QtGui.QApplication.translate("MainWindow", "Bandwidth", None, QtGui.QApplication.UnicodeUTF8)) - self.amplifierLabel.setText(QtGui.QApplication.translate("MainWindow", "Amplifier", None, QtGui.QApplication.UnicodeUTF8)) - self.dcCancelCheckBox.setText(QtGui.QApplication.translate("MainWindow", "Cancel DC", None, QtGui.QApplication.UnicodeUTF8)) - self.dcGainLabel.setText(QtGui.QApplication.translate("MainWindow", "DC Canceller Gain", None, QtGui.QApplication.UnicodeUTF8)) - self.pauseButton.setText(QtGui.QApplication.translate("MainWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) - self.closeButton.setText(QtGui.QApplication.translate("MainWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) - self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) - self.actionExit.setText(QtGui.QApplication.translate("MainWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) - self.actionSaveData.setText(QtGui.QApplication.translate("MainWindow", "&Save Data", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/gr-qtgui/src/python/usrp_display_qtgui.ui b/gr-qtgui/src/python/usrp_display_qtgui.ui deleted file mode 100644 index e88ca9dce..000000000 --- a/gr-qtgui/src/python/usrp_display_qtgui.ui +++ /dev/null @@ -1,375 +0,0 @@ - - MainWindow - - - - 0 - 0 - 820 - 774 - - - - USRP Display - - - - - - - - - - 0 - 0 - - - - - 240 - 150 - - - - - 240 - 16777215 - - - - Receiver Parameters - - - - - 10 - 20 - 221 - 124 - - - - - - - Frequency (Hz) - - - - - - - RF Gain - - - - - - - Bandwidth - - - - - - - - 0 - 0 - - - - - 120 - 26 - - - - - - - - - 0 - 0 - - - - - 120 - 26 - - - - - - - - - 0 - 0 - - - - - 120 - 26 - - - - - - - - Amplifier - - - - - - - - 0 - 0 - - - - - 120 - 26 - - - - - - - - - - - - - 200 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - 10 - -1 - 191 - 151 - - - - - - - Cancel DC - - - - - - - - - DC Canceller Gain - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 80 - - - - - - - - - 0 - 0 - - - - Pause - - - - - - - - 0 - 0 - - - - - 75 - 0 - - - - Close - - - - - - - - - - - - - - 0 - 1 - - - - - 800 - 550 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - - - - - - - 0 - 0 - 820 - 24 - - - - - &File - - - - - - - - - - E&xit - - - - - &Save Data - - - - - - - closeButton - clicked() - MainWindow - close() - - - 808 - 739 - - - 66 - 561 - - - - - actionExit - triggered() - MainWindow - close() - - - -1 - -1 - - - 617 - 327 - - - - - diff --git a/gr-qtgui/swig/qtgui.i b/gr-qtgui/swig/qtgui.i new file mode 100644 index 000000000..bb64c6ae2 --- /dev/null +++ b/gr-qtgui/swig/qtgui.i @@ -0,0 +1,131 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009 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. + */ + +%include "gnuradio.i" + +%{ +#include "qtgui_sink_c.h" +#include "qtgui_sink_f.h" +%} + +GR_SWIG_BLOCK_MAGIC(qtgui,sink_c) + + qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, + double fc=0, double bw=1.0, + const std::string &name="Display", + bool plotfreq=true, bool plotwaterfall=true, + bool plotwaterfall3d=true, bool plottime=true, + bool plotconst=true, + bool use_openGL=true, + QWidget *parent=NULL); + +class qtgui_sink_c : public gr_block +{ +private: + friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + qtgui_sink_c (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + +public: + void exec_(); + PyObject* pyqwidget(); + + void set_frequency_range(const double centerfreq, + const double bandwidth); + void set_time_domain_axis(double min, double max); + void set_constellation_axis(double xmin, double xmax, + double ymin, double ymax); + void set_frequency_axis(double min, double max); + void set_constellation_pen_size(int size); +}; + + + +/*********************************************************************/ + + +GR_SWIG_BLOCK_MAGIC(qtgui,sink_f) + +qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, + double fc=0, double bw=0.0, + const std::string &name="Display", + bool plotfreq=true, bool plotwaterfall=true, + bool plotwaterfall3d=true, bool plottime=true, + bool plotconst=true, + bool use_openGL=true, + QWidget *parent=NULL); + +class qtgui_sink_f : public gr_block +{ +private: + friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + qtgui_sink_f (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + +public: + void exec_(); + PyObject* pyqwidget(); + + void set_frequency_range(const double centerfreq, + const double bandwidth); + void set_time_domain_axis(double min, double max); + void set_constellation_axis(double xmin, double xmax, + double ymin, double ymax); + void set_frequency_axis(double min, double max); + void set_constellation_pen_size(int size); +}; + +#if SWIGGUILE +%scheme %{ +(load-extension-global "libguile-gnuradio-qtgui" "scm_init_gnuradio_qtgui_module") +%} + +%goops %{ +(use-modules (gnuradio gnuradio_core_runtime)) +%} +#endif -- cgit From 4a1dfe6b13a6ea839e1e6f4792d5f8992c495594 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 13:10:40 -0400 Subject: gr-qtgui: wip: moving and renaming files for new structure. --- gr-qtgui/Makefile.am | 11 +-- gr-qtgui/gnuradio-qtgui.pc.in | 11 +++ gr-qtgui/lib/Makefile.am | 4 +- gr-qtgui/swig/Makefile.am | 63 +++++++++++++++++ gr-qtgui/swig/Makefile.swig.gen | 145 +++++++++++++++++++++++++++++++++++++++ gr-qtgui/swig/__init__.py | 24 +++++++ gr-qtgui/swig/qtgui.i | 131 ----------------------------------- gr-qtgui/swig/qtgui.test | 36 ++++++++++ gr-qtgui/swig/qtgui_swig.i | 131 +++++++++++++++++++++++++++++++++++ gr-qtgui/swig/run_guile_tests.in | 14 ++++ 10 files changed, 431 insertions(+), 139 deletions(-) create mode 100644 gr-qtgui/gnuradio-qtgui.pc.in create mode 100644 gr-qtgui/swig/Makefile.am create mode 100644 gr-qtgui/swig/Makefile.swig.gen create mode 100644 gr-qtgui/swig/__init__.py delete mode 100644 gr-qtgui/swig/qtgui.i create mode 100644 gr-qtgui/swig/qtgui.test create mode 100644 gr-qtgui/swig/qtgui_swig.i create mode 100644 gr-qtgui/swig/run_guile_tests.in diff --git a/gr-qtgui/Makefile.am b/gr-qtgui/Makefile.am index e794266cb..cc194e4c0 100644 --- a/gr-qtgui/Makefile.am +++ b/gr-qtgui/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2008-2010 Free Software Foundation, Inc. +# Copyright 2008-2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,10 +21,11 @@ include $(top_srcdir)/Makefile.common -SUBDIRS = src -DIST_SUBDIRS = src +SUBDIRS = lib if PYTHON -SUBDIRS += grc -DIST_SUBDIRS += grc +SUBDIRS += swig python apps grc endif + +pkgconfigdir = $(libdir)/pkgconfig +dist_pkgconfig_DATA = gnuradio-qtgui.pc diff --git a/gr-qtgui/gnuradio-qtgui.pc.in b/gr-qtgui/gnuradio-qtgui.pc.in new file mode 100644 index 000000000..27b6a21bf --- /dev/null +++ b/gr-qtgui/gnuradio-qtgui.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: gnuradio-qtgui +Description: GNU Radio blocks for QT GUI +Requires: gnuradio-core +Version: @LIBVER@ +Libs: -L${libdir} -lgnuradio-qtgui +Cflags: -I${includedir} diff --git a/gr-qtgui/lib/Makefile.am b/gr-qtgui/lib/Makefile.am index 446a07fd0..687a4f966 100644 --- a/gr-qtgui/lib/Makefile.am +++ b/gr-qtgui/lib/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2008,2009,2010 Free Software Foundation, Inc. +# Copyright 2008-2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,7 +20,6 @@ # include $(top_srcdir)/Makefile.common -include $(top_srcdir)/Makefile.swig EXTRA_DIST += spectrumdisplayform.ui @@ -91,7 +90,6 @@ libgnuradio_qtgui_la_LIBADD = \ -lstdc++ \ $(QT_LIBS) - ############################## # SWIG interfaces and libraries diff --git a/gr-qtgui/swig/Makefile.am b/gr-qtgui/swig/Makefile.am new file mode 100644 index 000000000..812d1caca --- /dev/null +++ b/gr-qtgui/swig/Makefile.am @@ -0,0 +1,63 @@ +# +# Copyright 2004,2005,2006,2008,2009,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. +# + +include $(top_srcdir)/Makefile.common +include $(top_srcdir)/Makefile.swig + +TESTS = +EXTRA_DIST += $(nobase_guile_DATA) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/gr-qtgui/lib \ + $(STD_DEFINES_AND_INCLUDES) \ + $(PYTHON_CPPFLAGS) \ + $(WITH_INCLUDES) + +if GUILE +nobase_guile_DATA = \ + gnuradio/qtgui.scm +endif + +noinst_GUILE = qtgui.test + + +############################## +# SWIG interface and library +TOP_SWIG_IFILES = \ + qtgui_swig.i + +# Install so that they end up available as: +# import gnuradio.qtgui +# This ends up at: +# ${prefix}/lib/python${python_version}/site-packages/gnuradio/qtgui +qtgui_swig_pythondir_category = \ + gnuradio/qtgui + +# additional libraries for linking with the SWIG-generated library +qtgui_swig_la_swig_libadd = \ + $(abs_top_builddir)/gr-qtgui/lib/libgnuradio-qtgui.la + +# additional SWIG files to be installed +qtgui_swig_swiginclude_headers = + +if GUILE +TESTS += run_guile_tests +endif \ No newline at end of file diff --git a/gr-qtgui/swig/Makefile.swig.gen b/gr-qtgui/swig/Makefile.swig.gen new file mode 100644 index 000000000..3659601c3 --- /dev/null +++ b/gr-qtgui/swig/Makefile.swig.gen @@ -0,0 +1,145 @@ +# -*- Makefile -*- +# +# Copyright 2009 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. +# + +# Makefile.swig.gen for qtgui_swig.i + +## Default install locations for these files: +## +## Default location for the Python directory is: +## ${prefix}/lib/python${python_version}/site-packages/[category]/qtgui_swig +## Default location for the Python exec directory is: +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/qtgui_swig +## +## The following can be overloaded to change the install location, but +## this has to be done in the including Makefile.am -before- +## Makefile.swig is included. + +qtgui_swig_pythondir_category ?= gnuradio/qtgui_swig +qtgui_swig_pylibdir_category ?= $(qtgui_swig_pythondir_category) +qtgui_swig_pythondir = $(pythondir)/$(qtgui_swig_pythondir_category) +qtgui_swig_pylibdir = $(pyexecdir)/$(qtgui_swig_pylibdir_category) + +# The .so libraries for the guile modules get installed whereever guile +# is installed, usually /usr/lib/guile/gnuradio/ +# FIXME: determince whether these should be installed with gnuradio. +qtgui_swig_scmlibdir = $(libdir) + +# The scm files for the guile modules get installed where ever guile +# is installed, usually /usr/share/guile/site/qtgui_swig +# FIXME: determince whether these should be installed with gnuradio. +qtgui_swig_scmdir = $(guiledir) + +## SWIG headers are always installed into the same directory. + +qtgui_swig_swigincludedir = $(swigincludedir) + +## This is a template file for a "generated" Makefile addition (in +## this case, "Makefile.swig.gen"). By including the top-level +## Makefile.swig, this file will be used to generate the SWIG +## dependencies. Assign the variable TOP_SWIG_FILES to be the list of +## SWIG .i files to generated wrappings for; there can be more than 1 +## so long as the names are unique (no sorting is done on the +## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i +## file will generate .cc, .py, and possibly .h files -- meaning that +## all of these files will have the same base name (that provided for +## the SWIG .i file). +## +## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the +## right thing. For more info, see < +## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > + +## Other cleaned files: dependency files generated by SWIG or this Makefile + +MOSTLYCLEANFILES += $(DEPDIR)/*.S* + +## Various SWIG variables. These can be overloaded in the including +## Makefile.am by setting the variable value there, then including +## Makefile.swig . + +qtgui_swig_swiginclude_HEADERS = \ + qtgui_swig.i \ + $(qtgui_swig_swiginclude_headers) + +if PYTHON +qtgui_swig_pylib_LTLIBRARIES = \ + _qtgui_swig.la + +_qtgui_swig_la_SOURCES = \ + python/qtgui_swig.cc \ + $(qtgui_swig_la_swig_sources) + +qtgui_swig_python_PYTHON = \ + qtgui_swig.py \ + $(qtgui_swig_python) + +_qtgui_swig_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(qtgui_swig_la_swig_libadd) + +_qtgui_swig_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(qtgui_swig_la_swig_ldflags) + +_qtgui_swig_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(qtgui_swig_la_swig_cxxflags) + +python/qtgui_swig.cc: qtgui_swig.py +qtgui_swig.py: qtgui_swig.i + +# Include the python dependencies for this file +-include python/qtgui_swig.d + +endif # end of if python + +if GUILE + +qtgui_swig_scmlib_LTLIBRARIES = \ + libguile-gnuradio-qtgui_swig.la +libguile_gnuradio_qtgui_swig_la_SOURCES = \ + guile/qtgui_swig.cc \ + $(qtgui_swig_la_swig_sources) +nobase_qtgui_swig_scm_DATA = \ + gnuradio/qtgui_swig.scm \ + gnuradio/qtgui_swig-primitive.scm +libguile_gnuradio_qtgui_swig_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(qtgui_swig_la_swig_libadd) +libguile_gnuradio_qtgui_swig_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(qtgui_swig_la_swig_ldflags) +libguile_gnuradio_qtgui_swig_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(qtgui_swig_la_swig_cxxflags) + +guile/qtgui_swig.cc: gnuradio/qtgui_swig.scm +gnuradio/qtgui_swig.scm: qtgui_swig.i +gnuradio/qtgui_swig-primitive.scm: gnuradio/qtgui_swig.scm + +# Include the guile dependencies for this file +-include guile/qtgui_swig.d + +endif # end of GUILE + + diff --git a/gr-qtgui/swig/__init__.py b/gr-qtgui/swig/__init__.py new file mode 100644 index 000000000..3986f2513 --- /dev/null +++ b/gr-qtgui/swig/__init__.py @@ -0,0 +1,24 @@ +# +# 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. +# + +# The presence of this file turns this directory into a Python package + +from qtgui_swig import * diff --git a/gr-qtgui/swig/qtgui.i b/gr-qtgui/swig/qtgui.i deleted file mode 100644 index bb64c6ae2..000000000 --- a/gr-qtgui/swig/qtgui.i +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 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. - */ - -%include "gnuradio.i" - -%{ -#include "qtgui_sink_c.h" -#include "qtgui_sink_f.h" -%} - -GR_SWIG_BLOCK_MAGIC(qtgui,sink_c) - - qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, - double fc=0, double bw=1.0, - const std::string &name="Display", - bool plotfreq=true, bool plotwaterfall=true, - bool plotwaterfall3d=true, bool plottime=true, - bool plotconst=true, - bool use_openGL=true, - QWidget *parent=NULL); - -class qtgui_sink_c : public gr_block -{ -private: - friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - qtgui_sink_c (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - -public: - void exec_(); - PyObject* pyqwidget(); - - void set_frequency_range(const double centerfreq, - const double bandwidth); - void set_time_domain_axis(double min, double max); - void set_constellation_axis(double xmin, double xmax, - double ymin, double ymax); - void set_frequency_axis(double min, double max); - void set_constellation_pen_size(int size); -}; - - - -/*********************************************************************/ - - -GR_SWIG_BLOCK_MAGIC(qtgui,sink_f) - -qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, - double fc=0, double bw=0.0, - const std::string &name="Display", - bool plotfreq=true, bool plotwaterfall=true, - bool plotwaterfall3d=true, bool plottime=true, - bool plotconst=true, - bool use_openGL=true, - QWidget *parent=NULL); - -class qtgui_sink_f : public gr_block -{ -private: - friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - qtgui_sink_f (int fftsize, int wintype, - double fc, double bw, - const std::string &name, - bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, - bool use_openGL, - QWidget *parent); - -public: - void exec_(); - PyObject* pyqwidget(); - - void set_frequency_range(const double centerfreq, - const double bandwidth); - void set_time_domain_axis(double min, double max); - void set_constellation_axis(double xmin, double xmax, - double ymin, double ymax); - void set_frequency_axis(double min, double max); - void set_constellation_pen_size(int size); -}; - -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-qtgui" "scm_init_gnuradio_qtgui_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif diff --git a/gr-qtgui/swig/qtgui.test b/gr-qtgui/swig/qtgui.test new file mode 100644 index 000000000..956a97df9 --- /dev/null +++ b/gr-qtgui/swig/qtgui.test @@ -0,0 +1,36 @@ +;;; -*- Scheme -*- +;;; +;;; 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 this program. If not, see . +;;; + +;;; If you're using Emacs's Scheme mode: +;;; (put 'with-test-prefix 'scheme-indent-function 1) + +;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. +;;; See also the very end of the file, where the test-equal, test-eqv +;;; and test-eq macros are defined. + +(define-module (test-module) + #:use-module (oop goops) + #:use-module (gnuradio core) + #:use-module (gnuradio test-suite lib) + #:duplicates (merge-generics replace check)) + +;;; Confirm we can import the module... +(use-modules (gnuradio qtgui)) + diff --git a/gr-qtgui/swig/qtgui_swig.i b/gr-qtgui/swig/qtgui_swig.i new file mode 100644 index 000000000..bb64c6ae2 --- /dev/null +++ b/gr-qtgui/swig/qtgui_swig.i @@ -0,0 +1,131 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009 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. + */ + +%include "gnuradio.i" + +%{ +#include "qtgui_sink_c.h" +#include "qtgui_sink_f.h" +%} + +GR_SWIG_BLOCK_MAGIC(qtgui,sink_c) + + qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, + double fc=0, double bw=1.0, + const std::string &name="Display", + bool plotfreq=true, bool plotwaterfall=true, + bool plotwaterfall3d=true, bool plottime=true, + bool plotconst=true, + bool use_openGL=true, + QWidget *parent=NULL); + +class qtgui_sink_c : public gr_block +{ +private: + friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + qtgui_sink_c (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + +public: + void exec_(); + PyObject* pyqwidget(); + + void set_frequency_range(const double centerfreq, + const double bandwidth); + void set_time_domain_axis(double min, double max); + void set_constellation_axis(double xmin, double xmax, + double ymin, double ymax); + void set_frequency_axis(double min, double max); + void set_constellation_pen_size(int size); +}; + + + +/*********************************************************************/ + + +GR_SWIG_BLOCK_MAGIC(qtgui,sink_f) + +qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, + double fc=0, double bw=0.0, + const std::string &name="Display", + bool plotfreq=true, bool plotwaterfall=true, + bool plotwaterfall3d=true, bool plottime=true, + bool plotconst=true, + bool use_openGL=true, + QWidget *parent=NULL); + +class qtgui_sink_f : public gr_block +{ +private: + friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + qtgui_sink_f (int fftsize, int wintype, + double fc, double bw, + const std::string &name, + bool plotfreq, bool plotwaterfall, + bool plotwaterfall3d, bool plottime, + bool plotconst, + bool use_openGL, + QWidget *parent); + +public: + void exec_(); + PyObject* pyqwidget(); + + void set_frequency_range(const double centerfreq, + const double bandwidth); + void set_time_domain_axis(double min, double max); + void set_constellation_axis(double xmin, double xmax, + double ymin, double ymax); + void set_frequency_axis(double min, double max); + void set_constellation_pen_size(int size); +}; + +#if SWIGGUILE +%scheme %{ +(load-extension-global "libguile-gnuradio-qtgui" "scm_init_gnuradio_qtgui_module") +%} + +%goops %{ +(use-modules (gnuradio gnuradio_core_runtime)) +%} +#endif diff --git a/gr-qtgui/swig/run_guile_tests.in b/gr-qtgui/swig/run_guile_tests.in new file mode 100644 index 000000000..5d08b0dd5 --- /dev/null +++ b/gr-qtgui/swig/run_guile_tests.in @@ -0,0 +1,14 @@ +#!/bin/sh + +. @top_builddir@/setup_guile_test_env + +# 1st argument is absolute path to hand coded guile source directory +# 2nd argument is absolute path to component C++ shared library build directory +# 3nd argument is absolute path to component SWIG build directory + +add_local_paths \ + @srcdir@ \ + @abs_builddir@ \ + @abs_builddir@ + +@GUILE@ -e main -c '(use-modules (gnuradio test-suite guile-test))' -t @srcdir@ -- cgit From 2f8c2f9211bdfe5b599f2aa75ad7ce045688bed8 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 13:12:51 -0400 Subject: gr-qtgui: updating M4 file for new directory structure. --- config/grc_gr_qtgui.m4 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/config/grc_gr_qtgui.m4 b/config/grc_gr_qtgui.m4 index aa9646b3c..fb63e1972 100644 --- a/config/grc_gr_qtgui.m4 +++ b/config/grc_gr_qtgui.m4 @@ -81,16 +81,20 @@ AC_DEFUN([GRC_GR_QTGUI],[ AC_CONFIG_FILES([ \ gr-qtgui/Makefile \ + gr-qtgui/gnuradio-qtgui.pc \ + gr-qtgui/apps/Makefile \ gr-qtgui/grc/Makefile \ - gr-qtgui/src/Makefile \ - gr-qtgui/src/lib/Makefile \ - gr-qtgui/src/python/Makefile \ - gr-qtgui/src/python/run_tests \ + gr-qtgui/lib/Makefile \ + gr-qtgui/python/Makefile \ + gr-qtgui/python/run_tests \ + gr-qtgui/swig/Makefile \ + gr-qtgui/dswig/run_guile_tests \ ]) GRC_BUILD_CONDITIONAL(gr-qtgui,[ dnl run_tests is created from run_tests.in. Make it executable. AC_CONFIG_COMMANDS([run_tests_qtgui], - [chmod +x gr-qtgui/src/python/run_tests]) + [chmod +x gr-qtgui/python/run_tests + chmod +x gr-qtgui/swig/run_guile_tests]) ]) ]) -- cgit From 59fc7194d5e7f486605d2df2d3e83e30d1b5a653 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 13:26:48 -0400 Subject: gr-qtgui: moving qtgui apps to the apps directory. --- gr-qtgui/apps/Makefile.am | 42 ++++ gr-qtgui/apps/pyqt_example.py | 144 +++++++++++++ gr-qtgui/apps/pyqt_example_f.py | 143 +++++++++++++ gr-qtgui/apps/qt_digital.py | 276 +++++++++++++++++++++++++ gr-qtgui/apps/qt_digital_window.py | 161 +++++++++++++++ gr-qtgui/apps/qt_digital_window.ui | 342 +++++++++++++++++++++++++++++++ gr-qtgui/apps/usrp2_display.py | 313 ++++++++++++++++++++++++++++ gr-qtgui/apps/usrp_display.py | 299 +++++++++++++++++++++++++++ gr-qtgui/apps/usrp_display_qtgui.py | 191 +++++++++++++++++ gr-qtgui/apps/usrp_display_qtgui.ui | 375 ++++++++++++++++++++++++++++++++++ gr-qtgui/python/pyqt_example.py | 144 ------------- gr-qtgui/python/pyqt_example_f.py | 143 ------------- gr-qtgui/python/qt_digital.py | 276 ------------------------- gr-qtgui/python/qt_digital_window.py | 161 --------------- gr-qtgui/python/qt_digital_window.ui | 342 ------------------------------- gr-qtgui/python/usrp2_display.py | 313 ---------------------------- gr-qtgui/python/usrp_display.py | 299 --------------------------- gr-qtgui/python/usrp_display_qtgui.py | 191 ----------------- gr-qtgui/python/usrp_display_qtgui.ui | 375 ---------------------------------- 19 files changed, 2286 insertions(+), 2244 deletions(-) create mode 100644 gr-qtgui/apps/Makefile.am create mode 100755 gr-qtgui/apps/pyqt_example.py create mode 100755 gr-qtgui/apps/pyqt_example_f.py create mode 100755 gr-qtgui/apps/qt_digital.py create mode 100644 gr-qtgui/apps/qt_digital_window.py create mode 100644 gr-qtgui/apps/qt_digital_window.ui create mode 100755 gr-qtgui/apps/usrp2_display.py create mode 100755 gr-qtgui/apps/usrp_display.py create mode 100644 gr-qtgui/apps/usrp_display_qtgui.py create mode 100644 gr-qtgui/apps/usrp_display_qtgui.ui delete mode 100755 gr-qtgui/python/pyqt_example.py delete mode 100755 gr-qtgui/python/pyqt_example_f.py delete mode 100755 gr-qtgui/python/qt_digital.py delete mode 100644 gr-qtgui/python/qt_digital_window.py delete mode 100644 gr-qtgui/python/qt_digital_window.ui delete mode 100755 gr-qtgui/python/usrp2_display.py delete mode 100755 gr-qtgui/python/usrp_display.py delete mode 100644 gr-qtgui/python/usrp_display_qtgui.py delete mode 100644 gr-qtgui/python/usrp_display_qtgui.ui diff --git a/gr-qtgui/apps/Makefile.am b/gr-qtgui/apps/Makefile.am new file mode 100644 index 000000000..4076570d3 --- /dev/null +++ b/gr-qtgui/apps/Makefile.am @@ -0,0 +1,42 @@ +# +# 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. +# + +include $(top_srcdir)/Makefile.common + +if PYTHON + +dist_bin_SCRIPTS = + +noinst_PYTHON = \ + pyqt_example_f.py \ + pyqt_example.py \ + qt_digital.py \ + qt_digital_window.py \ + usrp2_display.py \ + usrp_display.py \ + qa_qtgui.py + +EXTRA_DIST += \ + qt_digital_window.ui \ + usrp_display_qtgui.ui +endif + +EXTRA_DIST += diff --git a/gr-qtgui/apps/pyqt_example.py b/gr-qtgui/apps/pyqt_example.py new file mode 100755 index 000000000..7c0cfc698 --- /dev/null +++ b/gr-qtgui/apps/pyqt_example.py @@ -0,0 +1,144 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio.qtgui import qtgui +from PyQt4 import QtGui, QtCore +import sys, sip + +class dialog_box(QtGui.QWidget): + def __init__(self, display, control): + QtGui.QWidget.__init__(self, None) + self.setWindowTitle('PyQt Test GUI') + + self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) + self.boxlayout.addWidget(display, 1) + self.boxlayout.addWidget(control) + + self.resize(800, 500) + +class control_box(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + self.setWindowTitle('Control Panel') + + self.setToolTip('Control the signals') + QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) + + self.layout = QtGui.QFormLayout(self) + + # Control the first signal + self.freq1Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) + self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), + self.freq1EditText) + + self.amp1Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) + self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), + self.amp1EditText) + + + # Control the second signal + self.freq2Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) + self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), + self.freq2EditText) + + + self.amp2Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) + self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), + self.amp2EditText) + + self.quit = QtGui.QPushButton('Close', self) + self.layout.addWidget(self.quit) + + self.connect(self.quit, QtCore.SIGNAL('clicked()'), + QtGui.qApp, QtCore.SLOT('quit()')) + + def attach_signal1(self, signal): + self.signal1 = signal + self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) + self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) + + def attach_signal2(self, signal): + self.signal2 = signal + self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) + self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) + + def freq1EditText(self): + try: + newfreq = float(self.freq1Edit.text()) + self.signal1.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp1EditText(self): + try: + newamp = float(self.amp1Edit.text()) + self.signal1.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + + def freq2EditText(self): + try: + newfreq = float(self.freq2Edit.text()) + self.signal2.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp2EditText(self): + try: + newamp = float(self.amp2Edit.text()) + self.signal2.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + Rs = 8000 + f1 = 1000 + f2 = 2000 + + fftsize = 2048 + + self.qapp = QtGui.QApplication(sys.argv) + + src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) + src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) + src = gr.add_cc() + channel = gr.channel_model(0.001) + thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize) + self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, Rs, + "Complex Signal Example", + True, True, False, True, False) + + self.connect(src1, (src,0)) + self.connect(src2, (src,1)) + self.connect(src, channel, thr, self.snk1) + + self.ctrl_win = control_box() + self.ctrl_win.attach_signal1(src1) + self.ctrl_win.attach_signal2(src2) + + # Get the reference pointer to the SpectrumDisplayForm QWidget + pyQt = self.snk1.pyqwidget() + + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + + self.main_box = dialog_box(self.pyWin, self.ctrl_win) + + self.main_box.show() + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() + diff --git a/gr-qtgui/apps/pyqt_example_f.py b/gr-qtgui/apps/pyqt_example_f.py new file mode 100755 index 000000000..4e36ccca5 --- /dev/null +++ b/gr-qtgui/apps/pyqt_example_f.py @@ -0,0 +1,143 @@ +#!/usr/bin/env python + +from gnuradio import gr, blks2 +from gnuradio.qtgui import qtgui +from PyQt4 import QtGui, QtCore +import sys, sip + +class dialog_box(QtGui.QWidget): + def __init__(self, display, control): + QtGui.QWidget.__init__(self, None) + self.setWindowTitle('PyQt Test GUI') + + self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) + self.boxlayout.addWidget(display, 1) + self.boxlayout.addWidget(control) + + self.resize(800, 500) + +class control_box(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + self.setWindowTitle('Control Panel') + + self.setToolTip('Control the signals') + QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) + + self.layout = QtGui.QFormLayout(self) + + # Control the first signal + self.freq1Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) + self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), + self.freq1EditText) + + self.amp1Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) + self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), + self.amp1EditText) + + + # Control the second signal + self.freq2Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) + self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), + self.freq2EditText) + + + self.amp2Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) + self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), + self.amp2EditText) + + self.quit = QtGui.QPushButton('Close', self) + self.layout.addWidget(self.quit) + + self.connect(self.quit, QtCore.SIGNAL('clicked()'), + QtGui.qApp, QtCore.SLOT('quit()')) + + def attach_signal1(self, signal): + self.signal1 = signal + self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) + self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) + + def attach_signal2(self, signal): + self.signal2 = signal + self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) + self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) + + def freq1EditText(self): + try: + newfreq = float(self.freq1Edit.text()) + self.signal1.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp1EditText(self): + try: + newamp = float(self.amp1Edit.text()) + self.signal1.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + + def freq2EditText(self): + try: + newfreq = float(self.freq2Edit.text()) + self.signal2.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp2EditText(self): + try: + newamp = float(self.amp2Edit.text()) + self.signal2.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + Rs = 8000 + f1 = 1000 + f2 = 2000 + + fftsize = 2048 + + self.qapp = QtGui.QApplication(sys.argv) + + src1 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) + src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) + src = gr.add_ff() + thr = gr.throttle(gr.sizeof_float, 100*fftsize) + self.snk1 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, Rs, + "Float Signal Example", + True, True, False, True, False) + + self.connect(src1, (src,0)) + self.connect(src2, (src,1)) + self.connect(src, thr, self.snk1) + + self.ctrl_win = control_box() + self.ctrl_win.attach_signal1(src1) + self.ctrl_win.attach_signal2(src2) + + # Get the reference pointer to the SpectrumDisplayForm QWidget + pyQt = self.snk1.pyqwidget() + + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + + self.main_box = dialog_box(self.pyWin, self.ctrl_win) + + self.main_box.show() + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() + diff --git a/gr-qtgui/apps/qt_digital.py b/gr-qtgui/apps/qt_digital.py new file mode 100755 index 000000000..679f144ef --- /dev/null +++ b/gr-qtgui/apps/qt_digital.py @@ -0,0 +1,276 @@ +#!/usr/bin/env python + +from gnuradio import gr, blks2 +from gnuradio.qtgui import qtgui +from gnuradio import eng_notation +from PyQt4 import QtGui, QtCore +import sys, sip +import scipy + +try: + from qt_digital_window import Ui_DigitalWindow +except ImportError: + print "Error: could not find qt_digital_window.py:" + print "\t\"Please run: pyuic4 qt_digital_window.ui -o qt_digital_window.py\"" + sys.exit(1) + +class dialog_box(QtGui.QMainWindow): + def __init__(self, snkTx, snkRx, fg, parent=None): + QtGui.QWidget.__init__(self, parent) + self.gui = Ui_DigitalWindow() + self.gui.setupUi(self) + + self.fg = fg + + self.set_sample_rate(self.fg.sample_rate()) + + self.set_snr(self.fg.snr()) + self.set_frequency(self.fg.frequency_offset()) + self.set_time_offset(self.fg.timing_offset()) + + self.set_gain_mu(self.fg.rx_gain_mu()) + self.set_alpha(self.fg.rx_alpha()) + + # Add the qtsnk widgets to the hlayout box + self.gui.sinkLayout.addWidget(snkTx) + self.gui.sinkLayout.addWidget(snkRx) + + + # Connect up some signals + self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), + self.pauseFg) + + self.connect(self.gui.sampleRateEdit, QtCore.SIGNAL("editingFinished()"), + self.sampleRateEditText) + + self.connect(self.gui.snrEdit, QtCore.SIGNAL("editingFinished()"), + self.snrEditText) + self.connect(self.gui.freqEdit, QtCore.SIGNAL("editingFinished()"), + self.freqEditText) + self.connect(self.gui.timeEdit, QtCore.SIGNAL("editingFinished()"), + self.timeEditText) + + self.connect(self.gui.gainMuEdit, QtCore.SIGNAL("editingFinished()"), + self.gainMuEditText) + self.connect(self.gui.alphaEdit, QtCore.SIGNAL("editingFinished()"), + self.alphaEditText) + + + def pauseFg(self): + if(self.gui.pauseButton.text() == "Pause"): + self.fg.stop() + self.fg.wait() + self.gui.pauseButton.setText("Unpause") + else: + self.fg.start() + self.gui.pauseButton.setText("Pause") + + # Accessor functions for Gui to manipulate system parameters + def set_sample_rate(self, sr): + ssr = eng_notation.num_to_str(sr) + self.gui.sampleRateEdit.setText(QtCore.QString("%1").arg(ssr)) + + def sampleRateEditText(self): + try: + rate = self.gui.sampleRateEdit.text().toAscii() + srate = eng_notation.str_to_num(rate) + self.fg.set_sample_rate(srate) + except RuntimeError: + pass + + + # Accessor functions for Gui to manipulate channel model + def set_snr(self, snr): + self.gui.snrEdit.setText(QtCore.QString("%1").arg(snr)) + + def set_frequency(self, fo): + self.gui.freqEdit.setText(QtCore.QString("%1").arg(fo)) + + def set_time_offset(self, to): + self.gui.timeEdit.setText(QtCore.QString("%1").arg(to)) + + def snrEditText(self): + try: + snr = self.gui.snrEdit.text().toDouble()[0] + self.fg.set_snr(snr) + except RuntimeError: + pass + + def freqEditText(self): + try: + freq = self.gui.freqEdit.text().toDouble()[0] + self.fg.set_frequency_offset(freq) + except RuntimeError: + pass + + def timeEditText(self): + try: + to = self.gui.timeEdit.text().toDouble()[0] + self.fg.set_timing_offset(to) + except RuntimeError: + pass + + + # Accessor functions for Gui to manipulate receiver parameters + def set_gain_mu(self, gain): + self.gui.gainMuEdit.setText(QtCore.QString("%1").arg(gain)) + + def set_alpha(self, alpha): + self.gui.alphaEdit.setText(QtCore.QString("%1").arg(alpha)) + + def alphaEditText(self): + try: + alpha = self.gui.alphaEdit.text().toDouble()[0] + self.fg.set_rx_alpha(alpha) + except RuntimeError: + pass + + def gainMuEditText(self): + try: + gain = self.gui.gainMuEdit.text().toDouble()[0] + self.fg.set_rx_gain_mu(gain) + except RuntimeError: + pass + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + self.qapp = QtGui.QApplication(sys.argv) + + self._sample_rate = 2000e3 + + self.sps = 2 + self.excess_bw = 0.35 + self.gray_code = True + + fftsize = 2048 + + self.data = scipy.random.randint(0, 255, 1000) + self.src = gr.vector_source_b(self.data.tolist(), True) + self.mod = blks2.dqpsk_mod(self.sps, self.excess_bw, self.gray_code, False, False) + + self.rrctaps = gr.firdes.root_raised_cosine(1, self.sps, 1, self.excess_bw, 21) + self.rx_rrc = gr.fir_filter_ccf(1, self.rrctaps) + + + # Set up the carrier & clock recovery parameters + self.arity = 4 + self.mu = 0.5 + self.gain_mu = 0.05 + self.omega = self.sps + self.gain_omega = .25 * self.gain_mu * self.gain_mu + self.omega_rel_lim = 0.05 + + self.alpha = 0.15 + self.beta = 0.25 * self.alpha * self.alpha + self.fmin = -1000/self.sample_rate() + self.fmax = 1000/self.sample_rate() + + self.receiver = gr.mpsk_receiver_cc(self.arity, 0, + self.alpha, self.beta, + self.fmin, self.fmax, + self.mu, self.gain_mu, + self.omega, self.gain_omega, + self.omega_rel_lim) + + + self.snr_dB = 15 + noise = self.get_noise_voltage(self.snr_dB) + self.fo = 100/self.sample_rate() + self.to = 1.0 + self.channel = gr.channel_model(noise, self.fo, self.to) + + self.thr = gr.throttle(gr.sizeof_char, self._sample_rate) + self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, self._sample_rate*self.sps, + "Tx", True, True, False, True, True) + + self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, self._sample_rate, + "Rx", True, True, False, True, True) + + self.connect(self.src, self.thr, self.mod, self.channel, self.snk_tx) + self.connect(self.channel, self.rx_rrc, self.receiver, self.snk_rx) + + pyTxQt = self.snk_tx.pyqwidget() + pyTx = sip.wrapinstance(pyTxQt, QtGui.QWidget) + + pyRxQt = self.snk_rx.pyqwidget() + pyRx = sip.wrapinstance(pyRxQt, QtGui.QWidget) + + self.main_box = dialog_box(pyTx, pyRx, self); + self.main_box.show() + + + def get_noise_voltage(self, SNR): + S = 0 # dBm, assuming signal power normalized + N = S - SNR # dBm + npwr = pow(10.0, N/10.0) # ratio + nv = scipy.sqrt(npwr * self.sps) # convert the noise voltage + return nv + + + # System Parameters + def sample_rate(self): + return self._sample_rate + + def set_sample_rate(self, sr): + self._sample_rate = sr + + + # Channel Model Parameters + def snr(self): + return self.snr_dB + + def set_snr(self, snr): + self.snr_dB = snr + noise = self.get_noise_voltage(self.snr_dB) + self.channel.set_noise_voltage(noise) + + def frequency_offset(self): + return self.fo * self.sample_rate() + + def set_frequency_offset(self, fo): + self.fo = fo / self.sample_rate() + self.channel.set_frequency_offset(self.fo) + + def timing_offset(self): + return self.to + + def set_timing_offset(self, to): + self.to = to + self.channel.set_timing_offset(self.to) + + + # Receiver Parameters + def rx_gain_mu(self): + return self.gain_mu + + def rx_gain_omega(self): + return self.gain_omega + + def set_rx_gain_mu(self, gain): + self.gain_mu = gain + self.gain_omega = .25 * self.gain_mu * self.gain_mu + self.receiver.set_gain_mu(self.gain_mu) + self.receiver.set_gain_omega(self.gain_omega) + + def rx_alpha(self): + return self.alpha + + def rx_beta(self): + return self.beta + + def set_rx_alpha(self, alpha): + self.alpha = alpha + self.beta = .25 * self.alpha * self.alpha + self.receiver.set_alpha(self.alpha) + self.receiver.set_beta(self.beta) + + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() diff --git a/gr-qtgui/apps/qt_digital_window.py b/gr-qtgui/apps/qt_digital_window.py new file mode 100644 index 000000000..50dd53a92 --- /dev/null +++ b/gr-qtgui/apps/qt_digital_window.py @@ -0,0 +1,161 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'qt_digital_window.ui' +# +# Created: Sat May 1 20:14:02 2010 +# by: PyQt4 UI code generator 4.6.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_DigitalWindow(object): + def setupUi(self, DigitalWindow): + DigitalWindow.setObjectName("DigitalWindow") + DigitalWindow.resize(1236, 741) + self.centralwidget = QtGui.QWidget(DigitalWindow) + self.centralwidget.setObjectName("centralwidget") + self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) + self.verticalLayout.setObjectName("verticalLayout") + self.sinkFrame = QtGui.QFrame(self.centralwidget) + self.sinkFrame.setMinimumSize(QtCore.QSize(0, 550)) + self.sinkFrame.setFrameShape(QtGui.QFrame.StyledPanel) + self.sinkFrame.setFrameShadow(QtGui.QFrame.Raised) + self.sinkFrame.setObjectName("sinkFrame") + self.horizontalLayout_2 = QtGui.QHBoxLayout(self.sinkFrame) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.sinkLayout = QtGui.QHBoxLayout() + self.sinkLayout.setObjectName("sinkLayout") + self.horizontalLayout_2.addLayout(self.sinkLayout) + self.verticalLayout.addWidget(self.sinkFrame) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.sysBox = QtGui.QGroupBox(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.sysBox.sizePolicy().hasHeightForWidth()) + self.sysBox.setSizePolicy(sizePolicy) + self.sysBox.setMinimumSize(QtCore.QSize(0, 0)) + self.sysBox.setMaximumSize(QtCore.QSize(16777215, 120)) + self.sysBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.sysBox.setObjectName("sysBox") + self.gridLayout_2 = QtGui.QGridLayout(self.sysBox) + self.gridLayout_2.setObjectName("gridLayout_2") + self.sampleRateEdit = QtGui.QLineEdit(self.sysBox) + self.sampleRateEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.sampleRateEdit.setObjectName("sampleRateEdit") + self.gridLayout_2.addWidget(self.sampleRateEdit, 0, 3, 1, 1) + self.sampleRateLabel = QtGui.QLabel(self.sysBox) + self.sampleRateLabel.setObjectName("sampleRateLabel") + self.gridLayout_2.addWidget(self.sampleRateLabel, 0, 2, 1, 1) + self.horizontalLayout.addWidget(self.sysBox) + self.rxBox = QtGui.QGroupBox(self.centralwidget) + self.rxBox.setMaximumSize(QtCore.QSize(16777215, 120)) + self.rxBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.rxBox.setObjectName("rxBox") + self.gridLayout_3 = QtGui.QGridLayout(self.rxBox) + self.gridLayout_3.setObjectName("gridLayout_3") + self.alphaLabel = QtGui.QLabel(self.rxBox) + self.alphaLabel.setObjectName("alphaLabel") + self.gridLayout_3.addWidget(self.alphaLabel, 1, 0, 1, 1) + self.alphaEdit = QtGui.QLineEdit(self.rxBox) + self.alphaEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.alphaEdit.setObjectName("alphaEdit") + self.gridLayout_3.addWidget(self.alphaEdit, 1, 1, 1, 1) + self.gainMuLabel = QtGui.QLabel(self.rxBox) + self.gainMuLabel.setObjectName("gainMuLabel") + self.gridLayout_3.addWidget(self.gainMuLabel, 0, 0, 1, 1) + self.gainMuEdit = QtGui.QLineEdit(self.rxBox) + self.gainMuEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.gainMuEdit.setObjectName("gainMuEdit") + self.gridLayout_3.addWidget(self.gainMuEdit, 0, 1, 1, 1) + self.horizontalLayout.addWidget(self.rxBox) + self.channelModeBox = QtGui.QGroupBox(self.centralwidget) + self.channelModeBox.setMaximumSize(QtCore.QSize(16777215, 120)) + self.channelModeBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.channelModeBox.setObjectName("channelModeBox") + self.gridLayout = QtGui.QGridLayout(self.channelModeBox) + self.gridLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize) + self.gridLayout.setObjectName("gridLayout") + self.snrLabel = QtGui.QLabel(self.channelModeBox) + self.snrLabel.setObjectName("snrLabel") + self.gridLayout.addWidget(self.snrLabel, 0, 1, 1, 1) + self.snrEdit = QtGui.QLineEdit(self.channelModeBox) + self.snrEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.snrEdit.setObjectName("snrEdit") + self.gridLayout.addWidget(self.snrEdit, 0, 2, 1, 1) + self.freqLabel = QtGui.QLabel(self.channelModeBox) + self.freqLabel.setObjectName("freqLabel") + self.gridLayout.addWidget(self.freqLabel, 1, 1, 1, 1) + self.freqEdit = QtGui.QLineEdit(self.channelModeBox) + self.freqEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.freqEdit.setObjectName("freqEdit") + self.gridLayout.addWidget(self.freqEdit, 1, 2, 1, 1) + self.timeLabel = QtGui.QLabel(self.channelModeBox) + self.timeLabel.setObjectName("timeLabel") + self.gridLayout.addWidget(self.timeLabel, 2, 1, 1, 1) + self.timeEdit = QtGui.QLineEdit(self.channelModeBox) + self.timeEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.timeEdit.setObjectName("timeEdit") + self.gridLayout.addWidget(self.timeEdit, 2, 2, 1, 1) + self.horizontalLayout.addWidget(self.channelModeBox) + spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem) + self.verticalLayout_2 = QtGui.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout_2.addItem(spacerItem1) + self.pauseButton = QtGui.QPushButton(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.pauseButton.sizePolicy().hasHeightForWidth()) + self.pauseButton.setSizePolicy(sizePolicy) + self.pauseButton.setMaximumSize(QtCore.QSize(80, 16777215)) + self.pauseButton.setObjectName("pauseButton") + self.verticalLayout_2.addWidget(self.pauseButton) + self.closeButton = QtGui.QPushButton(self.centralwidget) + self.closeButton.setMaximumSize(QtCore.QSize(80, 16777215)) + self.closeButton.setObjectName("closeButton") + self.verticalLayout_2.addWidget(self.closeButton) + self.horizontalLayout.addLayout(self.verticalLayout_2) + self.verticalLayout.addLayout(self.horizontalLayout) + DigitalWindow.setCentralWidget(self.centralwidget) + self.menubar = QtGui.QMenuBar(DigitalWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1236, 23)) + self.menubar.setObjectName("menubar") + self.menuFile = QtGui.QMenu(self.menubar) + self.menuFile.setObjectName("menuFile") + DigitalWindow.setMenuBar(self.menubar) + self.statusbar = QtGui.QStatusBar(DigitalWindow) + self.statusbar.setObjectName("statusbar") + DigitalWindow.setStatusBar(self.statusbar) + self.actionExit = QtGui.QAction(DigitalWindow) + self.actionExit.setObjectName("actionExit") + self.menuFile.addAction(self.actionExit) + self.menubar.addAction(self.menuFile.menuAction()) + + self.retranslateUi(DigitalWindow) + QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), DigitalWindow.close) + QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), DigitalWindow.close) + QtCore.QMetaObject.connectSlotsByName(DigitalWindow) + DigitalWindow.setTabOrder(self.snrEdit, self.freqEdit) + DigitalWindow.setTabOrder(self.freqEdit, self.timeEdit) + + def retranslateUi(self, DigitalWindow): + DigitalWindow.setWindowTitle(QtGui.QApplication.translate("DigitalWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) + self.sysBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.sampleRateLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Sample Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) + self.rxBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.alphaLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Alpha", None, QtGui.QApplication.UnicodeUTF8)) + self.gainMuLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Gain mu", None, QtGui.QApplication.UnicodeUTF8)) + self.channelModeBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Channel Model Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.snrLabel.setText(QtGui.QApplication.translate("DigitalWindow", "SNR (dB)", None, QtGui.QApplication.UnicodeUTF8)) + self.freqLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Frequency Offset (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.timeLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Timing Offset", None, QtGui.QApplication.UnicodeUTF8)) + self.pauseButton.setText(QtGui.QApplication.translate("DigitalWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) + self.closeButton.setText(QtGui.QApplication.translate("DigitalWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) + self.menuFile.setTitle(QtGui.QApplication.translate("DigitalWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) + self.actionExit.setText(QtGui.QApplication.translate("DigitalWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) + diff --git a/gr-qtgui/apps/qt_digital_window.ui b/gr-qtgui/apps/qt_digital_window.ui new file mode 100644 index 000000000..967252181 --- /dev/null +++ b/gr-qtgui/apps/qt_digital_window.ui @@ -0,0 +1,342 @@ + + + DigitalWindow + + + + 0 + 0 + 1236 + 741 + + + + MainWindow + + + + + + + + 0 + 550 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 120 + + + + System Parameters + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + 100 + 16777215 + + + + + + + + Sample Rate (sps) + + + + + + + + + + + 16777215 + 120 + + + + Receiver Parameters + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + Alpha + + + + + + + + 100 + 16777215 + + + + + + + + Gain mu + + + + + + + + 100 + 16777215 + + + + + + + + + + + + 16777215 + 120 + + + + Channel Model Parameters + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + QLayout::SetMinimumSize + + + + + SNR (dB) + + + + + + + + 100 + 16777215 + + + + + + + + Frequency Offset (Hz) + + + + + + + + 100 + 16777215 + + + + + + + + Timing Offset + + + + + + + + 100 + 16777215 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + 80 + 16777215 + + + + Pause + + + + + + + + 80 + 16777215 + + + + Close + + + + + + + + + + + + + 0 + 0 + 1236 + 23 + + + + + &File + + + + + + + + + E&xit + + + + + snrEdit + freqEdit + timeEdit + + + + + closeButton + clicked() + DigitalWindow + close() + + + 322 + 623 + + + 66 + 561 + + + + + actionExit + triggered() + DigitalWindow + close() + + + -1 + -1 + + + 617 + 327 + + + + + diff --git a/gr-qtgui/apps/usrp2_display.py b/gr-qtgui/apps/usrp2_display.py new file mode 100755 index 000000000..75d374c2b --- /dev/null +++ b/gr-qtgui/apps/usrp2_display.py @@ -0,0 +1,313 @@ +#!/usr/bin/env python +# +# Copyright 2009 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. +# + +from gnuradio import gr +from gnuradio import usrp2 +from gnuradio import eng_notation +from gnuradio.eng_option import eng_option +from gnuradio.qtgui import qtgui +from optparse import OptionParser +import sys + +try: + from gnuradio.qtgui import qtgui + from PyQt4 import QtGui, QtCore + import sip +except ImportError: + print "Please install gr-qtgui." + sys.exit(1) + +try: + from usrp_display_qtgui import Ui_MainWindow +except ImportError: + print "Error: could not find usrp_display_qtgui.py:" + print "\t\"pyuic4 usrp_display_qtgui.ui -o usrp_display_qtgui.py\"" + sys.exit(1) + + +# //////////////////////////////////////////////////////////////////// +# Define the QT Interface and Control Dialog +# //////////////////////////////////////////////////////////////////// + + +class main_window(QtGui.QMainWindow): + def __init__(self, snk, fg, parent=None): + + QtGui.QWidget.__init__(self, parent) + self.gui = Ui_MainWindow() + self.gui.setupUi(self) + + self.fg = fg + + # Add the qtsnk widgets to the layout box + self.gui.sinkLayout.addWidget(snk) + + self.gui.dcGainEdit.setText(QtCore.QString("%1").arg(0.001)) + + # Connect up some signals + self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), + self.pauseFg) + self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"), + self.frequencyEditText) + self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"), + self.gainEditText) + self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"), + self.bandwidthEditText) + self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"), + self.amplifierEditText) + + self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"), + self.saveData) + self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save) + + self.connect(self.gui.dcGainEdit, QtCore.SIGNAL("editingFinished()"), + self.dcGainEditText) + self.connect(self.gui.dcCancelCheckBox, QtCore.SIGNAL("clicked(bool)"), + self.dcCancelClicked) + + def pauseFg(self): + if(self.gui.pauseButton.text() == "Pause"): + self.fg.stop() + self.fg.wait() + self.gui.pauseButton.setText("Unpause") + else: + self.fg.start() + self.gui.pauseButton.setText("Pause") + + + # Functions to set the values in the GUI + def set_frequency(self, freq): + self.freq = freq + sfreq = eng_notation.num_to_str(self.freq) + self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq)) + + def set_gain(self, gain): + self.gain = gain + self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain)) + + def set_bandwidth(self, bw): + self.bw = bw + sbw = eng_notation.num_to_str(self.bw) + self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw)) + + def set_amplifier(self, amp): + self.amp = amp + self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp)) + + + # Functions called when signals are triggered in the GUI + def frequencyEditText(self): + try: + freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii()) + self.fg.set_frequency(freq) + self.freq = freq + except RuntimeError: + pass + + def gainEditText(self): + try: + gain = float(self.gui.gainEdit.text()) + self.fg.set_gain(gain) + self.gain = gain + except ValueError: + pass + + def bandwidthEditText(self): + try: + bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii()) + self.fg.set_bandwidth(bw) + self.bw = bw + except ValueError: + pass + + def amplifierEditText(self): + try: + amp = float(self.gui.amplifierEdit.text()) + self.fg.set_amplifier_gain(amp) + self.amp = amp + except ValueError: + pass + + def saveData(self): + fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", "."); + if(len(fileName)): + self.fg.save_to_file(str(fileName)) + + def dcGainEditText(self): + gain = float(self.gui.dcGainEdit.text()) + self.fg.set_dc_gain(gain) + + def dcCancelClicked(self, state): + self.dcGainEditText() + self.fg.cancel_dc(state) + + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + parser = OptionParser(option_class=eng_option) + parser.add_option("-e", "--interface", type="string", default="eth0", + help="select Ethernet interface, default is eth0") + parser.add_option("-m", "--mac-addr", type="string", default="", + help="select USRP by MAC address, default is auto-select") + parser.add_option("-W", "--bw", type="eng_float", default=1e6, + help="set bandwidth of receiver [default=%default]") + parser.add_option("-f", "--freq", type="eng_float", default=2412e6, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is midpoint)") + parser.add_option("--fft-size", type="int", default=2048, + help="Set number of FFT bins [default=%default]") + (options, args) = parser.parse_args() + + if len(args) != 0: + parser.print_help() + sys.exit(1) + self.options = options + self.show_debug_info = True + + self.qapp = QtGui.QApplication(sys.argv) + + self.u = usrp2.source_32fc(options.interface, options.mac_addr) + self._adc_rate = self.u.adc_rate() + self.set_bandwidth(options.bw) + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.gain_range() + options.gain = float(g[0]+g[1])/2 + self.set_gain(options.gain) + + if options.freq is None: + # if no frequency was specified, use the mid-point of the subdev + f = self.u.freq_range() + options.freq = float(f[0]+f[1])/2 + self.set_frequency(options.freq) + + self._fftsize = options.fft_size + + self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS, + self._freq, self._bandwidth, + "USRP2 Display", + True, True, False, True, False) + + # Set up internal amplifier + self.amp = gr.multiply_const_cc(0.0) + self.set_amplifier_gain(100) + + # Create a single-pole IIR filter to remove DC + # but don't connect it yet + self.dc_gain = 0.001 + self.dc = gr.single_pole_iir_filter_cc(self.dc_gain) + self.dc_sub = gr.sub_cc() + + self.connect(self.u, self.amp, self.snk) + + if self.show_debug_info: + print "Decimation rate: ", self._decim + print "Bandwidth: ", self._bandwidth + print "D'board: ", self.u.daughterboard_id() + + # Get the reference pointer to the SpectrumDisplayForm QWidget + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + + self.main_win = main_window(self.pysink, self) + + self.main_win.set_frequency(self._freq) + self.main_win.set_gain(self._gain) + self.main_win.set_bandwidth(self._bandwidth) + self.main_win.set_amplifier(self._amp_value) + + self.main_win.show() + + + def save_to_file(self, name): + self.lock() + + # Add file sink to save data + self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name) + self.connect(self.amp, self.file_sink) + + self.unlock() + + def set_gain(self, gain): + self._gain = gain + self.u.set_gain(self._gain) + + def set_frequency(self, freq): + self._freq = freq + r = self.u.set_center_freq(freq) + + try: + self.snk.set_frequency_range(self._freq, self._bandwidth) + except: + pass + + def set_bandwidth(self, bw): + self._bandwidth = bw + self._decim = int(self._adc_rate / self._bandwidth) + self.u.set_decim(self._decim) + + try: + self.snk.set_frequency_range(self._freq, self._bandwidth) + except: + pass + + def set_amplifier_gain(self, amp): + self._amp_value = amp + self.amp.set_k(self._amp_value) + + def set_dc_gain(self, gain): + self.dc.set_taps(gain) + + def cancel_dc(self, state): + self.lock() + + if(state): + self.disconnect(self.u, self.amp) + self.connect(self.u, (self.dc_sub,0)) + self.connect(self.u, self.dc, (self.dc_sub,1)) + self.connect(self.dc_sub, self.amp) + else: + self.disconnect(self.dc_sub, self.amp) + self.disconnect(self.dc, (self.dc_sub,1)) + self.disconnect(self.u, self.dc) + self.disconnect(self.u, (self.dc_sub,0)) + self.connect(self.u, self.amp) + + self.unlock() + +def main (): + tb = my_top_block() + tb.start() + tb.snk.exec_(); + +if __name__ == '__main__': + try: + main () + except KeyboardInterrupt: + pass + diff --git a/gr-qtgui/apps/usrp_display.py b/gr-qtgui/apps/usrp_display.py new file mode 100755 index 000000000..432e74d9a --- /dev/null +++ b/gr-qtgui/apps/usrp_display.py @@ -0,0 +1,299 @@ +#!/usr/bin/env python +# +# Copyright 2009 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. +# + +from gnuradio import gr +from gnuradio import usrp +from gnuradio import eng_notation +from gnuradio.eng_option import eng_option +from gnuradio.qtgui import qtgui +from optparse import OptionParser +import sys + +try: + from gnuradio.qtgui import qtgui + from PyQt4 import QtGui, QtCore + import sip +except ImportError: + print "Please install gr-qtgui." + sys.exit(1) + +try: + from usrp_display_qtgui import Ui_MainWindow +except ImportError: + print "Error: could not find usrp_display_qtgui.py:" + print "\t\"pyuic4 usrp_display_qtgui.ui -o usrp_display_qtgui.py\"" + sys.exit(1) + + + +# //////////////////////////////////////////////////////////////////// +# Define the QT Interface and Control Dialog +# //////////////////////////////////////////////////////////////////// + + +class main_window(QtGui.QMainWindow): + def __init__(self, snk, fg, parent=None): + + QtGui.QWidget.__init__(self, parent) + self.gui = Ui_MainWindow() + self.gui.setupUi(self) + + self.fg = fg + + # Add the qtsnk widgets to the layout box + self.gui.sinkLayout.addWidget(snk) + + # Connect up some signals + self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), + self.pauseFg) + self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"), + self.frequencyEditText) + self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"), + self.gainEditText) + self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"), + self.bandwidthEditText) + self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"), + self.amplifierEditText) + + self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"), + self.saveData) + self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save) + + def pauseFg(self): + if(self.gui.pauseButton.text() == "Pause"): + self.fg.stop() + self.fg.wait() + self.gui.pauseButton.setText("Unpause") + else: + self.fg.start() + self.gui.pauseButton.setText("Pause") + + + # Functions to set the values in the GUI + def set_frequency(self, freq): + self.freq = freq + sfreq = eng_notation.num_to_str(self.freq) + self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq)) + + def set_gain(self, gain): + self.gain = gain + self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain)) + + def set_bandwidth(self, bw): + self.bw = bw + sbw = eng_notation.num_to_str(self.bw) + self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw)) + + def set_amplifier(self, amp): + self.amp = amp + self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp)) + + + # Functions called when signals are triggered in the GUI + def frequencyEditText(self): + try: + freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii()) + self.fg.set_frequency(freq) + self.freq = freq + except RuntimeError: + pass + + def gainEditText(self): + try: + gain = float(self.gui.gainEdit.text()) + self.fg.set_gain(gain) + self.gain = gain + except ValueError: + pass + + def bandwidthEditText(self): + try: + bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii()) + self.fg.set_bandwidth(bw) + self.bw = bw + except ValueError: + pass + + def amplifierEditText(self): + try: + amp = float(self.gui.amplifierEdit.text()) + self.fg.set_amplifier_gain(amp) + self.amp = amp + except ValueError: + pass + + def saveData(self): + fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", "."); + if(len(fileName)): + self.fg.save_to_file(str(fileName)) + + +def pick_subdevice(u): + """ + The user didn't specify a subdevice on the command line. + If there's a daughterboard on A, select A. + If there's a daughterboard on B, select B. + Otherwise, select A. + """ + if u.db(0, 0).dbid() >= 0: # dbid is < 0 if there's no d'board or a problem + return (0, 0) + if u.db(0, 0).dbid() >= 0: + return (1, 0) + return (0, 0) + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + parser = OptionParser(option_class=eng_option) + parser.add_option("-w", "--which", type="int", default=0, + help="select which USRP (0, 1, ...) default is %default", + metavar="NUM") + parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, + help="select USRP Rx side A or B (default=first one with a daughterboard)") + parser.add_option("-A", "--antenna", default=None, + help="select Rx Antenna (only on RFX-series boards)") + parser.add_option("-W", "--bw", type="float", default=1e6, + help="set bandwidth of receiver [default=%default]") + parser.add_option("-f", "--freq", type="eng_float", default=None, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB [default is midpoint]") + parser.add_option("-8", "--width-8", action="store_true", default=False, + help="Enable 8-bit samples across USB") + parser.add_option( "--no-hb", action="store_true", default=False, + help="don't use halfband filter in usrp") + parser.add_option("-S", "--oscilloscope", action="store_true", default=False, + help="Enable oscilloscope display") + parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1, + help="Set fftsink averaging factor, [default=%default]") + parser.add_option("", "--ref-scale", type="eng_float", default=13490.0, + help="Set dBFS=0dB input value, [default=%default]") + parser.add_option("", "--fft-size", type="int", default=2048, + help="Set FFT frame size, [default=%default]"); + + (options, args) = parser.parse_args() + if len(args) != 0: + parser.print_help() + sys.exit(1) + self.options = options + self.show_debug_info = True + + # Call this before creating the Qt sink + self.qapp = QtGui.QApplication(sys.argv) + + self._fftsize = options.fft_size + + self.u = usrp.source_c(which=options.which) + self._adc_rate = self.u.converter_rate() + self.set_bandwidth(options.bw) + + if options.rx_subdev_spec is None: + options.rx_subdev_spec = pick_subdevice(self.u) + self._rx_subdev_spec = options.rx_subdev_spec + self.u.set_mux(usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec)) + self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec) + + self._gain_range = self.subdev.gain_range() + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self._gain_range + options.gain = float(g[0]+g[1])/2 + self.set_gain(options.gain) + + if options.freq is None: + # if no frequency was specified, use the mid-point of the subdev + f = self.subdev.freq_range() + options.freq = float(f[0]+f[1])/2 + self.set_frequency(options.freq) + + self.snk = qtgui.sink_c(self._fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + self._freq, self._bandwidth, + "USRP Display", + True, True, False, True, False) + + # Set up internal amplifier + self.amp = gr.multiply_const_cc(0.0) + self.set_amplifier_gain(0.001) + + # Connect the flow graph + self.connect(self.u, self.amp, self.snk) + + + # Get the reference pointer to the SpectrumDisplayForm QWidget + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + + self.main_win = main_window(self.pysink, self) + + self.main_win.set_frequency(self._freq) + self.main_win.set_gain(self._gain) + self.main_win.set_bandwidth(self._bandwidth) + self.main_win.set_amplifier(self._amp_value) + + self.main_win.show() + + def save_to_file(self, name): + # Pause the flow graph + self.stop() + self.wait() + + # Add file sink to save data + self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name) + self.connect(self.amp, self.file_sink) + + # Restart flow graph + self.start() + + def set_gain(self, gain): + self._gain = gain + self.subdev.set_gain(self._gain) + + def set_frequency(self, freq): + self._freq = freq + self.u.tune(0, self.subdev, self._freq) + + try: + self.snk.set_frequency_range(self._freq, self._bandwidth) + except: + pass + + def set_bandwidth(self, bw): + self._bandwidth = bw + self._decim = int(self._adc_rate / self._bandwidth) + self.u.set_decim_rate(self._decim) + + try: + self.snk.set_frequency_range(self._freq, self._bandwidth) + except: + pass + + def set_amplifier_gain(self, amp): + self._amp_value = amp + self.amp.set_k(self._amp_value) + + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() diff --git a/gr-qtgui/apps/usrp_display_qtgui.py b/gr-qtgui/apps/usrp_display_qtgui.py new file mode 100644 index 000000000..4c9de3a53 --- /dev/null +++ b/gr-qtgui/apps/usrp_display_qtgui.py @@ -0,0 +1,191 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'usrp_display_qtgui.ui' +# +# Created: Thu Jul 16 22:06:24 2009 +# by: PyQt4 UI code generator 4.4.3 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(820, 774) + self.centralwidget = QtGui.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.gridLayout_2 = QtGui.QGridLayout(self.centralwidget) + self.gridLayout_2.setObjectName("gridLayout_2") + self.horizontalLayout_2 = QtGui.QHBoxLayout() + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.groupBox = QtGui.QGroupBox(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth()) + self.groupBox.setSizePolicy(sizePolicy) + self.groupBox.setMinimumSize(QtCore.QSize(240, 150)) + self.groupBox.setMaximumSize(QtCore.QSize(240, 16777215)) + self.groupBox.setObjectName("groupBox") + self.formLayoutWidget = QtGui.QWidget(self.groupBox) + self.formLayoutWidget.setGeometry(QtCore.QRect(10, 20, 221, 124)) + self.formLayoutWidget.setObjectName("formLayoutWidget") + self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) + self.formLayout.setObjectName("formLayout") + self.frequencyLabel = QtGui.QLabel(self.formLayoutWidget) + self.frequencyLabel.setObjectName("frequencyLabel") + self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.frequencyLabel) + self.gainLabel = QtGui.QLabel(self.formLayoutWidget) + self.gainLabel.setObjectName("gainLabel") + self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.gainLabel) + self.bandwidthLabel = QtGui.QLabel(self.formLayoutWidget) + self.bandwidthLabel.setObjectName("bandwidthLabel") + self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.bandwidthLabel) + self.frequencyEdit = QtGui.QLineEdit(self.formLayoutWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.frequencyEdit.sizePolicy().hasHeightForWidth()) + self.frequencyEdit.setSizePolicy(sizePolicy) + self.frequencyEdit.setMinimumSize(QtCore.QSize(120, 26)) + self.frequencyEdit.setObjectName("frequencyEdit") + self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.frequencyEdit) + self.gainEdit = QtGui.QLineEdit(self.formLayoutWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.gainEdit.sizePolicy().hasHeightForWidth()) + self.gainEdit.setSizePolicy(sizePolicy) + self.gainEdit.setMinimumSize(QtCore.QSize(120, 26)) + self.gainEdit.setObjectName("gainEdit") + self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.gainEdit) + self.bandwidthEdit = QtGui.QLineEdit(self.formLayoutWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.bandwidthEdit.sizePolicy().hasHeightForWidth()) + self.bandwidthEdit.setSizePolicy(sizePolicy) + self.bandwidthEdit.setMinimumSize(QtCore.QSize(120, 26)) + self.bandwidthEdit.setObjectName("bandwidthEdit") + self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.bandwidthEdit) + self.amplifierLabel = QtGui.QLabel(self.formLayoutWidget) + self.amplifierLabel.setObjectName("amplifierLabel") + self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.amplifierLabel) + self.amplifierEdit = QtGui.QLineEdit(self.formLayoutWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.amplifierEdit.sizePolicy().hasHeightForWidth()) + self.amplifierEdit.setSizePolicy(sizePolicy) + self.amplifierEdit.setMinimumSize(QtCore.QSize(120, 26)) + self.amplifierEdit.setObjectName("amplifierEdit") + self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.amplifierEdit) + self.horizontalLayout_2.addWidget(self.groupBox) + self.frame_2 = QtGui.QFrame(self.centralwidget) + self.frame_2.setMinimumSize(QtCore.QSize(200, 0)) + self.frame_2.setFrameShape(QtGui.QFrame.StyledPanel) + self.frame_2.setFrameShadow(QtGui.QFrame.Raised) + self.frame_2.setObjectName("frame_2") + self.verticalLayoutWidget = QtGui.QWidget(self.frame_2) + self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, -1, 191, 151)) + self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") + self.verticalLayout_3 = QtGui.QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.dcCancelCheckBox = QtGui.QCheckBox(self.verticalLayoutWidget) + self.dcCancelCheckBox.setObjectName("dcCancelCheckBox") + self.verticalLayout_3.addWidget(self.dcCancelCheckBox) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.dcGainLabel = QtGui.QLabel(self.verticalLayoutWidget) + self.dcGainLabel.setObjectName("dcGainLabel") + self.horizontalLayout.addWidget(self.dcGainLabel) + self.dcGainEdit = QtGui.QLineEdit(self.verticalLayoutWidget) + self.dcGainEdit.setObjectName("dcGainEdit") + self.horizontalLayout.addWidget(self.dcGainEdit) + self.verticalLayout_3.addLayout(self.horizontalLayout) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout_3.addItem(spacerItem) + self.horizontalLayout_2.addWidget(self.frame_2) + spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout_2.addItem(spacerItem1) + self.verticalLayout = QtGui.QVBoxLayout() + self.verticalLayout.setObjectName("verticalLayout") + spacerItem2 = QtGui.QSpacerItem(20, 80, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) + self.verticalLayout.addItem(spacerItem2) + self.pauseButton = QtGui.QPushButton(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.pauseButton.sizePolicy().hasHeightForWidth()) + self.pauseButton.setSizePolicy(sizePolicy) + self.pauseButton.setObjectName("pauseButton") + self.verticalLayout.addWidget(self.pauseButton) + self.closeButton = QtGui.QPushButton(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.closeButton.sizePolicy().hasHeightForWidth()) + self.closeButton.setSizePolicy(sizePolicy) + self.closeButton.setMinimumSize(QtCore.QSize(75, 0)) + self.closeButton.setObjectName("closeButton") + self.verticalLayout.addWidget(self.closeButton) + self.horizontalLayout_2.addLayout(self.verticalLayout) + self.gridLayout_2.addLayout(self.horizontalLayout_2, 1, 0, 1, 1) + self.verticalLayout_2 = QtGui.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.frame = QtGui.QFrame(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(1) + sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth()) + self.frame.setSizePolicy(sizePolicy) + self.frame.setMinimumSize(QtCore.QSize(800, 550)) + self.frame.setFrameShape(QtGui.QFrame.StyledPanel) + self.frame.setFrameShadow(QtGui.QFrame.Raised) + self.frame.setObjectName("frame") + self.gridLayout = QtGui.QGridLayout(self.frame) + self.gridLayout.setObjectName("gridLayout") + self.sinkLayout = QtGui.QHBoxLayout() + self.sinkLayout.setObjectName("sinkLayout") + self.gridLayout.addLayout(self.sinkLayout, 0, 0, 1, 1) + self.verticalLayout_2.addWidget(self.frame) + self.gridLayout_2.addLayout(self.verticalLayout_2, 0, 0, 1, 1) + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtGui.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 820, 24)) + self.menubar.setObjectName("menubar") + self.menuFile = QtGui.QMenu(self.menubar) + self.menuFile.setObjectName("menuFile") + MainWindow.setMenuBar(self.menubar) + self.statusbar = QtGui.QStatusBar(MainWindow) + self.statusbar.setObjectName("statusbar") + MainWindow.setStatusBar(self.statusbar) + self.actionExit = QtGui.QAction(MainWindow) + self.actionExit.setObjectName("actionExit") + self.actionSaveData = QtGui.QAction(MainWindow) + self.actionSaveData.setObjectName("actionSaveData") + self.menuFile.addAction(self.actionSaveData) + self.menuFile.addAction(self.actionExit) + self.menubar.addAction(self.menuFile.menuAction()) + + self.retranslateUi(MainWindow) + QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), MainWindow.close) + QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), MainWindow.close) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "USRP Display", None, QtGui.QApplication.UnicodeUTF8)) + self.groupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.frequencyLabel.setText(QtGui.QApplication.translate("MainWindow", "Frequency (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.gainLabel.setText(QtGui.QApplication.translate("MainWindow", "RF Gain", None, QtGui.QApplication.UnicodeUTF8)) + self.bandwidthLabel.setText(QtGui.QApplication.translate("MainWindow", "Bandwidth", None, QtGui.QApplication.UnicodeUTF8)) + self.amplifierLabel.setText(QtGui.QApplication.translate("MainWindow", "Amplifier", None, QtGui.QApplication.UnicodeUTF8)) + self.dcCancelCheckBox.setText(QtGui.QApplication.translate("MainWindow", "Cancel DC", None, QtGui.QApplication.UnicodeUTF8)) + self.dcGainLabel.setText(QtGui.QApplication.translate("MainWindow", "DC Canceller Gain", None, QtGui.QApplication.UnicodeUTF8)) + self.pauseButton.setText(QtGui.QApplication.translate("MainWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) + self.closeButton.setText(QtGui.QApplication.translate("MainWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) + self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) + self.actionExit.setText(QtGui.QApplication.translate("MainWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) + self.actionSaveData.setText(QtGui.QApplication.translate("MainWindow", "&Save Data", None, QtGui.QApplication.UnicodeUTF8)) + diff --git a/gr-qtgui/apps/usrp_display_qtgui.ui b/gr-qtgui/apps/usrp_display_qtgui.ui new file mode 100644 index 000000000..e88ca9dce --- /dev/null +++ b/gr-qtgui/apps/usrp_display_qtgui.ui @@ -0,0 +1,375 @@ + + MainWindow + + + + 0 + 0 + 820 + 774 + + + + USRP Display + + + + + + + + + + 0 + 0 + + + + + 240 + 150 + + + + + 240 + 16777215 + + + + Receiver Parameters + + + + + 10 + 20 + 221 + 124 + + + + + + + Frequency (Hz) + + + + + + + RF Gain + + + + + + + Bandwidth + + + + + + + + 0 + 0 + + + + + 120 + 26 + + + + + + + + + 0 + 0 + + + + + 120 + 26 + + + + + + + + + 0 + 0 + + + + + 120 + 26 + + + + + + + + Amplifier + + + + + + + + 0 + 0 + + + + + 120 + 26 + + + + + + + + + + + + + 200 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + -1 + 191 + 151 + + + + + + + Cancel DC + + + + + + + + + DC Canceller Gain + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 80 + + + + + + + + + 0 + 0 + + + + Pause + + + + + + + + 0 + 0 + + + + + 75 + 0 + + + + Close + + + + + + + + + + + + + + 0 + 1 + + + + + 800 + 550 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + + + + + 0 + 0 + 820 + 24 + + + + + &File + + + + + + + + + + E&xit + + + + + &Save Data + + + + + + + closeButton + clicked() + MainWindow + close() + + + 808 + 739 + + + 66 + 561 + + + + + actionExit + triggered() + MainWindow + close() + + + -1 + -1 + + + 617 + 327 + + + + + diff --git a/gr-qtgui/python/pyqt_example.py b/gr-qtgui/python/pyqt_example.py deleted file mode 100755 index 7c0cfc698..000000000 --- a/gr-qtgui/python/pyqt_example.py +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio.qtgui import qtgui -from PyQt4 import QtGui, QtCore -import sys, sip - -class dialog_box(QtGui.QWidget): - def __init__(self, display, control): - QtGui.QWidget.__init__(self, None) - self.setWindowTitle('PyQt Test GUI') - - self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) - self.boxlayout.addWidget(display, 1) - self.boxlayout.addWidget(control) - - self.resize(800, 500) - -class control_box(QtGui.QWidget): - def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) - self.setWindowTitle('Control Panel') - - self.setToolTip('Control the signals') - QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) - - self.layout = QtGui.QFormLayout(self) - - # Control the first signal - self.freq1Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) - self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), - self.freq1EditText) - - self.amp1Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) - self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), - self.amp1EditText) - - - # Control the second signal - self.freq2Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) - self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), - self.freq2EditText) - - - self.amp2Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) - self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), - self.amp2EditText) - - self.quit = QtGui.QPushButton('Close', self) - self.layout.addWidget(self.quit) - - self.connect(self.quit, QtCore.SIGNAL('clicked()'), - QtGui.qApp, QtCore.SLOT('quit()')) - - def attach_signal1(self, signal): - self.signal1 = signal - self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) - self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) - - def attach_signal2(self, signal): - self.signal2 = signal - self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) - self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) - - def freq1EditText(self): - try: - newfreq = float(self.freq1Edit.text()) - self.signal1.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp1EditText(self): - try: - newamp = float(self.amp1Edit.text()) - self.signal1.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - - def freq2EditText(self): - try: - newfreq = float(self.freq2Edit.text()) - self.signal2.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp2EditText(self): - try: - newamp = float(self.amp2Edit.text()) - self.signal2.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - Rs = 8000 - f1 = 1000 - f2 = 2000 - - fftsize = 2048 - - self.qapp = QtGui.QApplication(sys.argv) - - src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) - src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_cc() - channel = gr.channel_model(0.001) - thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize) - self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, Rs, - "Complex Signal Example", - True, True, False, True, False) - - self.connect(src1, (src,0)) - self.connect(src2, (src,1)) - self.connect(src, channel, thr, self.snk1) - - self.ctrl_win = control_box() - self.ctrl_win.attach_signal1(src1) - self.ctrl_win.attach_signal2(src2) - - # Get the reference pointer to the SpectrumDisplayForm QWidget - pyQt = self.snk1.pyqwidget() - - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - - self.main_box = dialog_box(self.pyWin, self.ctrl_win) - - self.main_box.show() - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() - diff --git a/gr-qtgui/python/pyqt_example_f.py b/gr-qtgui/python/pyqt_example_f.py deleted file mode 100755 index 4e36ccca5..000000000 --- a/gr-qtgui/python/pyqt_example_f.py +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr, blks2 -from gnuradio.qtgui import qtgui -from PyQt4 import QtGui, QtCore -import sys, sip - -class dialog_box(QtGui.QWidget): - def __init__(self, display, control): - QtGui.QWidget.__init__(self, None) - self.setWindowTitle('PyQt Test GUI') - - self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) - self.boxlayout.addWidget(display, 1) - self.boxlayout.addWidget(control) - - self.resize(800, 500) - -class control_box(QtGui.QWidget): - def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) - self.setWindowTitle('Control Panel') - - self.setToolTip('Control the signals') - QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) - - self.layout = QtGui.QFormLayout(self) - - # Control the first signal - self.freq1Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) - self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), - self.freq1EditText) - - self.amp1Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) - self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), - self.amp1EditText) - - - # Control the second signal - self.freq2Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) - self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), - self.freq2EditText) - - - self.amp2Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) - self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), - self.amp2EditText) - - self.quit = QtGui.QPushButton('Close', self) - self.layout.addWidget(self.quit) - - self.connect(self.quit, QtCore.SIGNAL('clicked()'), - QtGui.qApp, QtCore.SLOT('quit()')) - - def attach_signal1(self, signal): - self.signal1 = signal - self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) - self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) - - def attach_signal2(self, signal): - self.signal2 = signal - self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) - self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) - - def freq1EditText(self): - try: - newfreq = float(self.freq1Edit.text()) - self.signal1.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp1EditText(self): - try: - newamp = float(self.amp1Edit.text()) - self.signal1.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - - def freq2EditText(self): - try: - newfreq = float(self.freq2Edit.text()) - self.signal2.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp2EditText(self): - try: - newamp = float(self.amp2Edit.text()) - self.signal2.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - Rs = 8000 - f1 = 1000 - f2 = 2000 - - fftsize = 2048 - - self.qapp = QtGui.QApplication(sys.argv) - - src1 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) - src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_ff() - thr = gr.throttle(gr.sizeof_float, 100*fftsize) - self.snk1 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, Rs, - "Float Signal Example", - True, True, False, True, False) - - self.connect(src1, (src,0)) - self.connect(src2, (src,1)) - self.connect(src, thr, self.snk1) - - self.ctrl_win = control_box() - self.ctrl_win.attach_signal1(src1) - self.ctrl_win.attach_signal2(src2) - - # Get the reference pointer to the SpectrumDisplayForm QWidget - pyQt = self.snk1.pyqwidget() - - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - - self.main_box = dialog_box(self.pyWin, self.ctrl_win) - - self.main_box.show() - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() - diff --git a/gr-qtgui/python/qt_digital.py b/gr-qtgui/python/qt_digital.py deleted file mode 100755 index 679f144ef..000000000 --- a/gr-qtgui/python/qt_digital.py +++ /dev/null @@ -1,276 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr, blks2 -from gnuradio.qtgui import qtgui -from gnuradio import eng_notation -from PyQt4 import QtGui, QtCore -import sys, sip -import scipy - -try: - from qt_digital_window import Ui_DigitalWindow -except ImportError: - print "Error: could not find qt_digital_window.py:" - print "\t\"Please run: pyuic4 qt_digital_window.ui -o qt_digital_window.py\"" - sys.exit(1) - -class dialog_box(QtGui.QMainWindow): - def __init__(self, snkTx, snkRx, fg, parent=None): - QtGui.QWidget.__init__(self, parent) - self.gui = Ui_DigitalWindow() - self.gui.setupUi(self) - - self.fg = fg - - self.set_sample_rate(self.fg.sample_rate()) - - self.set_snr(self.fg.snr()) - self.set_frequency(self.fg.frequency_offset()) - self.set_time_offset(self.fg.timing_offset()) - - self.set_gain_mu(self.fg.rx_gain_mu()) - self.set_alpha(self.fg.rx_alpha()) - - # Add the qtsnk widgets to the hlayout box - self.gui.sinkLayout.addWidget(snkTx) - self.gui.sinkLayout.addWidget(snkRx) - - - # Connect up some signals - self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), - self.pauseFg) - - self.connect(self.gui.sampleRateEdit, QtCore.SIGNAL("editingFinished()"), - self.sampleRateEditText) - - self.connect(self.gui.snrEdit, QtCore.SIGNAL("editingFinished()"), - self.snrEditText) - self.connect(self.gui.freqEdit, QtCore.SIGNAL("editingFinished()"), - self.freqEditText) - self.connect(self.gui.timeEdit, QtCore.SIGNAL("editingFinished()"), - self.timeEditText) - - self.connect(self.gui.gainMuEdit, QtCore.SIGNAL("editingFinished()"), - self.gainMuEditText) - self.connect(self.gui.alphaEdit, QtCore.SIGNAL("editingFinished()"), - self.alphaEditText) - - - def pauseFg(self): - if(self.gui.pauseButton.text() == "Pause"): - self.fg.stop() - self.fg.wait() - self.gui.pauseButton.setText("Unpause") - else: - self.fg.start() - self.gui.pauseButton.setText("Pause") - - # Accessor functions for Gui to manipulate system parameters - def set_sample_rate(self, sr): - ssr = eng_notation.num_to_str(sr) - self.gui.sampleRateEdit.setText(QtCore.QString("%1").arg(ssr)) - - def sampleRateEditText(self): - try: - rate = self.gui.sampleRateEdit.text().toAscii() - srate = eng_notation.str_to_num(rate) - self.fg.set_sample_rate(srate) - except RuntimeError: - pass - - - # Accessor functions for Gui to manipulate channel model - def set_snr(self, snr): - self.gui.snrEdit.setText(QtCore.QString("%1").arg(snr)) - - def set_frequency(self, fo): - self.gui.freqEdit.setText(QtCore.QString("%1").arg(fo)) - - def set_time_offset(self, to): - self.gui.timeEdit.setText(QtCore.QString("%1").arg(to)) - - def snrEditText(self): - try: - snr = self.gui.snrEdit.text().toDouble()[0] - self.fg.set_snr(snr) - except RuntimeError: - pass - - def freqEditText(self): - try: - freq = self.gui.freqEdit.text().toDouble()[0] - self.fg.set_frequency_offset(freq) - except RuntimeError: - pass - - def timeEditText(self): - try: - to = self.gui.timeEdit.text().toDouble()[0] - self.fg.set_timing_offset(to) - except RuntimeError: - pass - - - # Accessor functions for Gui to manipulate receiver parameters - def set_gain_mu(self, gain): - self.gui.gainMuEdit.setText(QtCore.QString("%1").arg(gain)) - - def set_alpha(self, alpha): - self.gui.alphaEdit.setText(QtCore.QString("%1").arg(alpha)) - - def alphaEditText(self): - try: - alpha = self.gui.alphaEdit.text().toDouble()[0] - self.fg.set_rx_alpha(alpha) - except RuntimeError: - pass - - def gainMuEditText(self): - try: - gain = self.gui.gainMuEdit.text().toDouble()[0] - self.fg.set_rx_gain_mu(gain) - except RuntimeError: - pass - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - self.qapp = QtGui.QApplication(sys.argv) - - self._sample_rate = 2000e3 - - self.sps = 2 - self.excess_bw = 0.35 - self.gray_code = True - - fftsize = 2048 - - self.data = scipy.random.randint(0, 255, 1000) - self.src = gr.vector_source_b(self.data.tolist(), True) - self.mod = blks2.dqpsk_mod(self.sps, self.excess_bw, self.gray_code, False, False) - - self.rrctaps = gr.firdes.root_raised_cosine(1, self.sps, 1, self.excess_bw, 21) - self.rx_rrc = gr.fir_filter_ccf(1, self.rrctaps) - - - # Set up the carrier & clock recovery parameters - self.arity = 4 - self.mu = 0.5 - self.gain_mu = 0.05 - self.omega = self.sps - self.gain_omega = .25 * self.gain_mu * self.gain_mu - self.omega_rel_lim = 0.05 - - self.alpha = 0.15 - self.beta = 0.25 * self.alpha * self.alpha - self.fmin = -1000/self.sample_rate() - self.fmax = 1000/self.sample_rate() - - self.receiver = gr.mpsk_receiver_cc(self.arity, 0, - self.alpha, self.beta, - self.fmin, self.fmax, - self.mu, self.gain_mu, - self.omega, self.gain_omega, - self.omega_rel_lim) - - - self.snr_dB = 15 - noise = self.get_noise_voltage(self.snr_dB) - self.fo = 100/self.sample_rate() - self.to = 1.0 - self.channel = gr.channel_model(noise, self.fo, self.to) - - self.thr = gr.throttle(gr.sizeof_char, self._sample_rate) - self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, self._sample_rate*self.sps, - "Tx", True, True, False, True, True) - - self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, self._sample_rate, - "Rx", True, True, False, True, True) - - self.connect(self.src, self.thr, self.mod, self.channel, self.snk_tx) - self.connect(self.channel, self.rx_rrc, self.receiver, self.snk_rx) - - pyTxQt = self.snk_tx.pyqwidget() - pyTx = sip.wrapinstance(pyTxQt, QtGui.QWidget) - - pyRxQt = self.snk_rx.pyqwidget() - pyRx = sip.wrapinstance(pyRxQt, QtGui.QWidget) - - self.main_box = dialog_box(pyTx, pyRx, self); - self.main_box.show() - - - def get_noise_voltage(self, SNR): - S = 0 # dBm, assuming signal power normalized - N = S - SNR # dBm - npwr = pow(10.0, N/10.0) # ratio - nv = scipy.sqrt(npwr * self.sps) # convert the noise voltage - return nv - - - # System Parameters - def sample_rate(self): - return self._sample_rate - - def set_sample_rate(self, sr): - self._sample_rate = sr - - - # Channel Model Parameters - def snr(self): - return self.snr_dB - - def set_snr(self, snr): - self.snr_dB = snr - noise = self.get_noise_voltage(self.snr_dB) - self.channel.set_noise_voltage(noise) - - def frequency_offset(self): - return self.fo * self.sample_rate() - - def set_frequency_offset(self, fo): - self.fo = fo / self.sample_rate() - self.channel.set_frequency_offset(self.fo) - - def timing_offset(self): - return self.to - - def set_timing_offset(self, to): - self.to = to - self.channel.set_timing_offset(self.to) - - - # Receiver Parameters - def rx_gain_mu(self): - return self.gain_mu - - def rx_gain_omega(self): - return self.gain_omega - - def set_rx_gain_mu(self, gain): - self.gain_mu = gain - self.gain_omega = .25 * self.gain_mu * self.gain_mu - self.receiver.set_gain_mu(self.gain_mu) - self.receiver.set_gain_omega(self.gain_omega) - - def rx_alpha(self): - return self.alpha - - def rx_beta(self): - return self.beta - - def set_rx_alpha(self, alpha): - self.alpha = alpha - self.beta = .25 * self.alpha * self.alpha - self.receiver.set_alpha(self.alpha) - self.receiver.set_beta(self.beta) - - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() diff --git a/gr-qtgui/python/qt_digital_window.py b/gr-qtgui/python/qt_digital_window.py deleted file mode 100644 index 50dd53a92..000000000 --- a/gr-qtgui/python/qt_digital_window.py +++ /dev/null @@ -1,161 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'qt_digital_window.ui' -# -# Created: Sat May 1 20:14:02 2010 -# by: PyQt4 UI code generator 4.6.1 -# -# WARNING! All changes made in this file will be lost! - -from PyQt4 import QtCore, QtGui - -class Ui_DigitalWindow(object): - def setupUi(self, DigitalWindow): - DigitalWindow.setObjectName("DigitalWindow") - DigitalWindow.resize(1236, 741) - self.centralwidget = QtGui.QWidget(DigitalWindow) - self.centralwidget.setObjectName("centralwidget") - self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) - self.verticalLayout.setObjectName("verticalLayout") - self.sinkFrame = QtGui.QFrame(self.centralwidget) - self.sinkFrame.setMinimumSize(QtCore.QSize(0, 550)) - self.sinkFrame.setFrameShape(QtGui.QFrame.StyledPanel) - self.sinkFrame.setFrameShadow(QtGui.QFrame.Raised) - self.sinkFrame.setObjectName("sinkFrame") - self.horizontalLayout_2 = QtGui.QHBoxLayout(self.sinkFrame) - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.sinkLayout = QtGui.QHBoxLayout() - self.sinkLayout.setObjectName("sinkLayout") - self.horizontalLayout_2.addLayout(self.sinkLayout) - self.verticalLayout.addWidget(self.sinkFrame) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.sysBox = QtGui.QGroupBox(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.sysBox.sizePolicy().hasHeightForWidth()) - self.sysBox.setSizePolicy(sizePolicy) - self.sysBox.setMinimumSize(QtCore.QSize(0, 0)) - self.sysBox.setMaximumSize(QtCore.QSize(16777215, 120)) - self.sysBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) - self.sysBox.setObjectName("sysBox") - self.gridLayout_2 = QtGui.QGridLayout(self.sysBox) - self.gridLayout_2.setObjectName("gridLayout_2") - self.sampleRateEdit = QtGui.QLineEdit(self.sysBox) - self.sampleRateEdit.setMaximumSize(QtCore.QSize(100, 16777215)) - self.sampleRateEdit.setObjectName("sampleRateEdit") - self.gridLayout_2.addWidget(self.sampleRateEdit, 0, 3, 1, 1) - self.sampleRateLabel = QtGui.QLabel(self.sysBox) - self.sampleRateLabel.setObjectName("sampleRateLabel") - self.gridLayout_2.addWidget(self.sampleRateLabel, 0, 2, 1, 1) - self.horizontalLayout.addWidget(self.sysBox) - self.rxBox = QtGui.QGroupBox(self.centralwidget) - self.rxBox.setMaximumSize(QtCore.QSize(16777215, 120)) - self.rxBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) - self.rxBox.setObjectName("rxBox") - self.gridLayout_3 = QtGui.QGridLayout(self.rxBox) - self.gridLayout_3.setObjectName("gridLayout_3") - self.alphaLabel = QtGui.QLabel(self.rxBox) - self.alphaLabel.setObjectName("alphaLabel") - self.gridLayout_3.addWidget(self.alphaLabel, 1, 0, 1, 1) - self.alphaEdit = QtGui.QLineEdit(self.rxBox) - self.alphaEdit.setMaximumSize(QtCore.QSize(100, 16777215)) - self.alphaEdit.setObjectName("alphaEdit") - self.gridLayout_3.addWidget(self.alphaEdit, 1, 1, 1, 1) - self.gainMuLabel = QtGui.QLabel(self.rxBox) - self.gainMuLabel.setObjectName("gainMuLabel") - self.gridLayout_3.addWidget(self.gainMuLabel, 0, 0, 1, 1) - self.gainMuEdit = QtGui.QLineEdit(self.rxBox) - self.gainMuEdit.setMaximumSize(QtCore.QSize(100, 16777215)) - self.gainMuEdit.setObjectName("gainMuEdit") - self.gridLayout_3.addWidget(self.gainMuEdit, 0, 1, 1, 1) - self.horizontalLayout.addWidget(self.rxBox) - self.channelModeBox = QtGui.QGroupBox(self.centralwidget) - self.channelModeBox.setMaximumSize(QtCore.QSize(16777215, 120)) - self.channelModeBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) - self.channelModeBox.setObjectName("channelModeBox") - self.gridLayout = QtGui.QGridLayout(self.channelModeBox) - self.gridLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize) - self.gridLayout.setObjectName("gridLayout") - self.snrLabel = QtGui.QLabel(self.channelModeBox) - self.snrLabel.setObjectName("snrLabel") - self.gridLayout.addWidget(self.snrLabel, 0, 1, 1, 1) - self.snrEdit = QtGui.QLineEdit(self.channelModeBox) - self.snrEdit.setMaximumSize(QtCore.QSize(100, 16777215)) - self.snrEdit.setObjectName("snrEdit") - self.gridLayout.addWidget(self.snrEdit, 0, 2, 1, 1) - self.freqLabel = QtGui.QLabel(self.channelModeBox) - self.freqLabel.setObjectName("freqLabel") - self.gridLayout.addWidget(self.freqLabel, 1, 1, 1, 1) - self.freqEdit = QtGui.QLineEdit(self.channelModeBox) - self.freqEdit.setMaximumSize(QtCore.QSize(100, 16777215)) - self.freqEdit.setObjectName("freqEdit") - self.gridLayout.addWidget(self.freqEdit, 1, 2, 1, 1) - self.timeLabel = QtGui.QLabel(self.channelModeBox) - self.timeLabel.setObjectName("timeLabel") - self.gridLayout.addWidget(self.timeLabel, 2, 1, 1, 1) - self.timeEdit = QtGui.QLineEdit(self.channelModeBox) - self.timeEdit.setMaximumSize(QtCore.QSize(100, 16777215)) - self.timeEdit.setObjectName("timeEdit") - self.gridLayout.addWidget(self.timeEdit, 2, 2, 1, 1) - self.horizontalLayout.addWidget(self.channelModeBox) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem) - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName("verticalLayout_2") - spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout_2.addItem(spacerItem1) - self.pauseButton = QtGui.QPushButton(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pauseButton.sizePolicy().hasHeightForWidth()) - self.pauseButton.setSizePolicy(sizePolicy) - self.pauseButton.setMaximumSize(QtCore.QSize(80, 16777215)) - self.pauseButton.setObjectName("pauseButton") - self.verticalLayout_2.addWidget(self.pauseButton) - self.closeButton = QtGui.QPushButton(self.centralwidget) - self.closeButton.setMaximumSize(QtCore.QSize(80, 16777215)) - self.closeButton.setObjectName("closeButton") - self.verticalLayout_2.addWidget(self.closeButton) - self.horizontalLayout.addLayout(self.verticalLayout_2) - self.verticalLayout.addLayout(self.horizontalLayout) - DigitalWindow.setCentralWidget(self.centralwidget) - self.menubar = QtGui.QMenuBar(DigitalWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 1236, 23)) - self.menubar.setObjectName("menubar") - self.menuFile = QtGui.QMenu(self.menubar) - self.menuFile.setObjectName("menuFile") - DigitalWindow.setMenuBar(self.menubar) - self.statusbar = QtGui.QStatusBar(DigitalWindow) - self.statusbar.setObjectName("statusbar") - DigitalWindow.setStatusBar(self.statusbar) - self.actionExit = QtGui.QAction(DigitalWindow) - self.actionExit.setObjectName("actionExit") - self.menuFile.addAction(self.actionExit) - self.menubar.addAction(self.menuFile.menuAction()) - - self.retranslateUi(DigitalWindow) - QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), DigitalWindow.close) - QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), DigitalWindow.close) - QtCore.QMetaObject.connectSlotsByName(DigitalWindow) - DigitalWindow.setTabOrder(self.snrEdit, self.freqEdit) - DigitalWindow.setTabOrder(self.freqEdit, self.timeEdit) - - def retranslateUi(self, DigitalWindow): - DigitalWindow.setWindowTitle(QtGui.QApplication.translate("DigitalWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) - self.sysBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.sampleRateLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Sample Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) - self.rxBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.alphaLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Alpha", None, QtGui.QApplication.UnicodeUTF8)) - self.gainMuLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Gain mu", None, QtGui.QApplication.UnicodeUTF8)) - self.channelModeBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Channel Model Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.snrLabel.setText(QtGui.QApplication.translate("DigitalWindow", "SNR (dB)", None, QtGui.QApplication.UnicodeUTF8)) - self.freqLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Frequency Offset (Hz)", None, QtGui.QApplication.UnicodeUTF8)) - self.timeLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Timing Offset", None, QtGui.QApplication.UnicodeUTF8)) - self.pauseButton.setText(QtGui.QApplication.translate("DigitalWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) - self.closeButton.setText(QtGui.QApplication.translate("DigitalWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) - self.menuFile.setTitle(QtGui.QApplication.translate("DigitalWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) - self.actionExit.setText(QtGui.QApplication.translate("DigitalWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/gr-qtgui/python/qt_digital_window.ui b/gr-qtgui/python/qt_digital_window.ui deleted file mode 100644 index 967252181..000000000 --- a/gr-qtgui/python/qt_digital_window.ui +++ /dev/null @@ -1,342 +0,0 @@ - - - DigitalWindow - - - - 0 - 0 - 1236 - 741 - - - - MainWindow - - - - - - - - 0 - 550 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 120 - - - - System Parameters - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - 100 - 16777215 - - - - - - - - Sample Rate (sps) - - - - - - - - - - - 16777215 - 120 - - - - Receiver Parameters - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - Alpha - - - - - - - - 100 - 16777215 - - - - - - - - Gain mu - - - - - - - - 100 - 16777215 - - - - - - - - - - - - 16777215 - 120 - - - - Channel Model Parameters - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - QLayout::SetMinimumSize - - - - - SNR (dB) - - - - - - - - 100 - 16777215 - - - - - - - - Frequency Offset (Hz) - - - - - - - - 100 - 16777215 - - - - - - - - Timing Offset - - - - - - - - 100 - 16777215 - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - - 80 - 16777215 - - - - Pause - - - - - - - - 80 - 16777215 - - - - Close - - - - - - - - - - - - - 0 - 0 - 1236 - 23 - - - - - &File - - - - - - - - - E&xit - - - - - snrEdit - freqEdit - timeEdit - - - - - closeButton - clicked() - DigitalWindow - close() - - - 322 - 623 - - - 66 - 561 - - - - - actionExit - triggered() - DigitalWindow - close() - - - -1 - -1 - - - 617 - 327 - - - - - diff --git a/gr-qtgui/python/usrp2_display.py b/gr-qtgui/python/usrp2_display.py deleted file mode 100755 index 75d374c2b..000000000 --- a/gr-qtgui/python/usrp2_display.py +++ /dev/null @@ -1,313 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr -from gnuradio import usrp2 -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from gnuradio.qtgui import qtgui -from optparse import OptionParser -import sys - -try: - from gnuradio.qtgui import qtgui - from PyQt4 import QtGui, QtCore - import sip -except ImportError: - print "Please install gr-qtgui." - sys.exit(1) - -try: - from usrp_display_qtgui import Ui_MainWindow -except ImportError: - print "Error: could not find usrp_display_qtgui.py:" - print "\t\"pyuic4 usrp_display_qtgui.ui -o usrp_display_qtgui.py\"" - sys.exit(1) - - -# //////////////////////////////////////////////////////////////////// -# Define the QT Interface and Control Dialog -# //////////////////////////////////////////////////////////////////// - - -class main_window(QtGui.QMainWindow): - def __init__(self, snk, fg, parent=None): - - QtGui.QWidget.__init__(self, parent) - self.gui = Ui_MainWindow() - self.gui.setupUi(self) - - self.fg = fg - - # Add the qtsnk widgets to the layout box - self.gui.sinkLayout.addWidget(snk) - - self.gui.dcGainEdit.setText(QtCore.QString("%1").arg(0.001)) - - # Connect up some signals - self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), - self.pauseFg) - self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"), - self.frequencyEditText) - self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"), - self.gainEditText) - self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"), - self.bandwidthEditText) - self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"), - self.amplifierEditText) - - self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"), - self.saveData) - self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save) - - self.connect(self.gui.dcGainEdit, QtCore.SIGNAL("editingFinished()"), - self.dcGainEditText) - self.connect(self.gui.dcCancelCheckBox, QtCore.SIGNAL("clicked(bool)"), - self.dcCancelClicked) - - def pauseFg(self): - if(self.gui.pauseButton.text() == "Pause"): - self.fg.stop() - self.fg.wait() - self.gui.pauseButton.setText("Unpause") - else: - self.fg.start() - self.gui.pauseButton.setText("Pause") - - - # Functions to set the values in the GUI - def set_frequency(self, freq): - self.freq = freq - sfreq = eng_notation.num_to_str(self.freq) - self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq)) - - def set_gain(self, gain): - self.gain = gain - self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain)) - - def set_bandwidth(self, bw): - self.bw = bw - sbw = eng_notation.num_to_str(self.bw) - self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw)) - - def set_amplifier(self, amp): - self.amp = amp - self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp)) - - - # Functions called when signals are triggered in the GUI - def frequencyEditText(self): - try: - freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii()) - self.fg.set_frequency(freq) - self.freq = freq - except RuntimeError: - pass - - def gainEditText(self): - try: - gain = float(self.gui.gainEdit.text()) - self.fg.set_gain(gain) - self.gain = gain - except ValueError: - pass - - def bandwidthEditText(self): - try: - bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii()) - self.fg.set_bandwidth(bw) - self.bw = bw - except ValueError: - pass - - def amplifierEditText(self): - try: - amp = float(self.gui.amplifierEdit.text()) - self.fg.set_amplifier_gain(amp) - self.amp = amp - except ValueError: - pass - - def saveData(self): - fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", "."); - if(len(fileName)): - self.fg.save_to_file(str(fileName)) - - def dcGainEditText(self): - gain = float(self.gui.dcGainEdit.text()) - self.fg.set_dc_gain(gain) - - def dcCancelClicked(self, state): - self.dcGainEditText() - self.fg.cancel_dc(state) - - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - parser = OptionParser(option_class=eng_option) - parser.add_option("-e", "--interface", type="string", default="eth0", - help="select Ethernet interface, default is eth0") - parser.add_option("-m", "--mac-addr", type="string", default="", - help="select USRP by MAC address, default is auto-select") - parser.add_option("-W", "--bw", type="eng_float", default=1e6, - help="set bandwidth of receiver [default=%default]") - parser.add_option("-f", "--freq", type="eng_float", default=2412e6, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("--fft-size", type="int", default=2048, - help="Set number of FFT bins [default=%default]") - (options, args) = parser.parse_args() - - if len(args) != 0: - parser.print_help() - sys.exit(1) - self.options = options - self.show_debug_info = True - - self.qapp = QtGui.QApplication(sys.argv) - - self.u = usrp2.source_32fc(options.interface, options.mac_addr) - self._adc_rate = self.u.adc_rate() - self.set_bandwidth(options.bw) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.gain_range() - options.gain = float(g[0]+g[1])/2 - self.set_gain(options.gain) - - if options.freq is None: - # if no frequency was specified, use the mid-point of the subdev - f = self.u.freq_range() - options.freq = float(f[0]+f[1])/2 - self.set_frequency(options.freq) - - self._fftsize = options.fft_size - - self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS, - self._freq, self._bandwidth, - "USRP2 Display", - True, True, False, True, False) - - # Set up internal amplifier - self.amp = gr.multiply_const_cc(0.0) - self.set_amplifier_gain(100) - - # Create a single-pole IIR filter to remove DC - # but don't connect it yet - self.dc_gain = 0.001 - self.dc = gr.single_pole_iir_filter_cc(self.dc_gain) - self.dc_sub = gr.sub_cc() - - self.connect(self.u, self.amp, self.snk) - - if self.show_debug_info: - print "Decimation rate: ", self._decim - print "Bandwidth: ", self._bandwidth - print "D'board: ", self.u.daughterboard_id() - - # Get the reference pointer to the SpectrumDisplayForm QWidget - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) - - self.main_win = main_window(self.pysink, self) - - self.main_win.set_frequency(self._freq) - self.main_win.set_gain(self._gain) - self.main_win.set_bandwidth(self._bandwidth) - self.main_win.set_amplifier(self._amp_value) - - self.main_win.show() - - - def save_to_file(self, name): - self.lock() - - # Add file sink to save data - self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name) - self.connect(self.amp, self.file_sink) - - self.unlock() - - def set_gain(self, gain): - self._gain = gain - self.u.set_gain(self._gain) - - def set_frequency(self, freq): - self._freq = freq - r = self.u.set_center_freq(freq) - - try: - self.snk.set_frequency_range(self._freq, self._bandwidth) - except: - pass - - def set_bandwidth(self, bw): - self._bandwidth = bw - self._decim = int(self._adc_rate / self._bandwidth) - self.u.set_decim(self._decim) - - try: - self.snk.set_frequency_range(self._freq, self._bandwidth) - except: - pass - - def set_amplifier_gain(self, amp): - self._amp_value = amp - self.amp.set_k(self._amp_value) - - def set_dc_gain(self, gain): - self.dc.set_taps(gain) - - def cancel_dc(self, state): - self.lock() - - if(state): - self.disconnect(self.u, self.amp) - self.connect(self.u, (self.dc_sub,0)) - self.connect(self.u, self.dc, (self.dc_sub,1)) - self.connect(self.dc_sub, self.amp) - else: - self.disconnect(self.dc_sub, self.amp) - self.disconnect(self.dc, (self.dc_sub,1)) - self.disconnect(self.u, self.dc) - self.disconnect(self.u, (self.dc_sub,0)) - self.connect(self.u, self.amp) - - self.unlock() - -def main (): - tb = my_top_block() - tb.start() - tb.snk.exec_(); - -if __name__ == '__main__': - try: - main () - except KeyboardInterrupt: - pass - diff --git a/gr-qtgui/python/usrp_display.py b/gr-qtgui/python/usrp_display.py deleted file mode 100755 index 432e74d9a..000000000 --- a/gr-qtgui/python/usrp_display.py +++ /dev/null @@ -1,299 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr -from gnuradio import usrp -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from gnuradio.qtgui import qtgui -from optparse import OptionParser -import sys - -try: - from gnuradio.qtgui import qtgui - from PyQt4 import QtGui, QtCore - import sip -except ImportError: - print "Please install gr-qtgui." - sys.exit(1) - -try: - from usrp_display_qtgui import Ui_MainWindow -except ImportError: - print "Error: could not find usrp_display_qtgui.py:" - print "\t\"pyuic4 usrp_display_qtgui.ui -o usrp_display_qtgui.py\"" - sys.exit(1) - - - -# //////////////////////////////////////////////////////////////////// -# Define the QT Interface and Control Dialog -# //////////////////////////////////////////////////////////////////// - - -class main_window(QtGui.QMainWindow): - def __init__(self, snk, fg, parent=None): - - QtGui.QWidget.__init__(self, parent) - self.gui = Ui_MainWindow() - self.gui.setupUi(self) - - self.fg = fg - - # Add the qtsnk widgets to the layout box - self.gui.sinkLayout.addWidget(snk) - - # Connect up some signals - self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), - self.pauseFg) - self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"), - self.frequencyEditText) - self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"), - self.gainEditText) - self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"), - self.bandwidthEditText) - self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"), - self.amplifierEditText) - - self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"), - self.saveData) - self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save) - - def pauseFg(self): - if(self.gui.pauseButton.text() == "Pause"): - self.fg.stop() - self.fg.wait() - self.gui.pauseButton.setText("Unpause") - else: - self.fg.start() - self.gui.pauseButton.setText("Pause") - - - # Functions to set the values in the GUI - def set_frequency(self, freq): - self.freq = freq - sfreq = eng_notation.num_to_str(self.freq) - self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq)) - - def set_gain(self, gain): - self.gain = gain - self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain)) - - def set_bandwidth(self, bw): - self.bw = bw - sbw = eng_notation.num_to_str(self.bw) - self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw)) - - def set_amplifier(self, amp): - self.amp = amp - self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp)) - - - # Functions called when signals are triggered in the GUI - def frequencyEditText(self): - try: - freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii()) - self.fg.set_frequency(freq) - self.freq = freq - except RuntimeError: - pass - - def gainEditText(self): - try: - gain = float(self.gui.gainEdit.text()) - self.fg.set_gain(gain) - self.gain = gain - except ValueError: - pass - - def bandwidthEditText(self): - try: - bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii()) - self.fg.set_bandwidth(bw) - self.bw = bw - except ValueError: - pass - - def amplifierEditText(self): - try: - amp = float(self.gui.amplifierEdit.text()) - self.fg.set_amplifier_gain(amp) - self.amp = amp - except ValueError: - pass - - def saveData(self): - fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", "."); - if(len(fileName)): - self.fg.save_to_file(str(fileName)) - - -def pick_subdevice(u): - """ - The user didn't specify a subdevice on the command line. - If there's a daughterboard on A, select A. - If there's a daughterboard on B, select B. - Otherwise, select A. - """ - if u.db(0, 0).dbid() >= 0: # dbid is < 0 if there's no d'board or a problem - return (0, 0) - if u.db(0, 0).dbid() >= 0: - return (1, 0) - return (0, 0) - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - parser = OptionParser(option_class=eng_option) - parser.add_option("-w", "--which", type="int", default=0, - help="select which USRP (0, 1, ...) default is %default", - metavar="NUM") - parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, - help="select USRP Rx side A or B (default=first one with a daughterboard)") - parser.add_option("-A", "--antenna", default=None, - help="select Rx Antenna (only on RFX-series boards)") - parser.add_option("-W", "--bw", type="float", default=1e6, - help="set bandwidth of receiver [default=%default]") - parser.add_option("-f", "--freq", type="eng_float", default=None, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB [default is midpoint]") - parser.add_option("-8", "--width-8", action="store_true", default=False, - help="Enable 8-bit samples across USB") - parser.add_option( "--no-hb", action="store_true", default=False, - help="don't use halfband filter in usrp") - parser.add_option("-S", "--oscilloscope", action="store_true", default=False, - help="Enable oscilloscope display") - parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1, - help="Set fftsink averaging factor, [default=%default]") - parser.add_option("", "--ref-scale", type="eng_float", default=13490.0, - help="Set dBFS=0dB input value, [default=%default]") - parser.add_option("", "--fft-size", type="int", default=2048, - help="Set FFT frame size, [default=%default]"); - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - self.options = options - self.show_debug_info = True - - # Call this before creating the Qt sink - self.qapp = QtGui.QApplication(sys.argv) - - self._fftsize = options.fft_size - - self.u = usrp.source_c(which=options.which) - self._adc_rate = self.u.converter_rate() - self.set_bandwidth(options.bw) - - if options.rx_subdev_spec is None: - options.rx_subdev_spec = pick_subdevice(self.u) - self._rx_subdev_spec = options.rx_subdev_spec - self.u.set_mux(usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec)) - self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec) - - self._gain_range = self.subdev.gain_range() - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self._gain_range - options.gain = float(g[0]+g[1])/2 - self.set_gain(options.gain) - - if options.freq is None: - # if no frequency was specified, use the mid-point of the subdev - f = self.subdev.freq_range() - options.freq = float(f[0]+f[1])/2 - self.set_frequency(options.freq) - - self.snk = qtgui.sink_c(self._fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - self._freq, self._bandwidth, - "USRP Display", - True, True, False, True, False) - - # Set up internal amplifier - self.amp = gr.multiply_const_cc(0.0) - self.set_amplifier_gain(0.001) - - # Connect the flow graph - self.connect(self.u, self.amp, self.snk) - - - # Get the reference pointer to the SpectrumDisplayForm QWidget - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) - - self.main_win = main_window(self.pysink, self) - - self.main_win.set_frequency(self._freq) - self.main_win.set_gain(self._gain) - self.main_win.set_bandwidth(self._bandwidth) - self.main_win.set_amplifier(self._amp_value) - - self.main_win.show() - - def save_to_file(self, name): - # Pause the flow graph - self.stop() - self.wait() - - # Add file sink to save data - self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name) - self.connect(self.amp, self.file_sink) - - # Restart flow graph - self.start() - - def set_gain(self, gain): - self._gain = gain - self.subdev.set_gain(self._gain) - - def set_frequency(self, freq): - self._freq = freq - self.u.tune(0, self.subdev, self._freq) - - try: - self.snk.set_frequency_range(self._freq, self._bandwidth) - except: - pass - - def set_bandwidth(self, bw): - self._bandwidth = bw - self._decim = int(self._adc_rate / self._bandwidth) - self.u.set_decim_rate(self._decim) - - try: - self.snk.set_frequency_range(self._freq, self._bandwidth) - except: - pass - - def set_amplifier_gain(self, amp): - self._amp_value = amp - self.amp.set_k(self._amp_value) - - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() diff --git a/gr-qtgui/python/usrp_display_qtgui.py b/gr-qtgui/python/usrp_display_qtgui.py deleted file mode 100644 index 4c9de3a53..000000000 --- a/gr-qtgui/python/usrp_display_qtgui.py +++ /dev/null @@ -1,191 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'usrp_display_qtgui.ui' -# -# Created: Thu Jul 16 22:06:24 2009 -# by: PyQt4 UI code generator 4.4.3 -# -# WARNING! All changes made in this file will be lost! - -from PyQt4 import QtCore, QtGui - -class Ui_MainWindow(object): - def setupUi(self, MainWindow): - MainWindow.setObjectName("MainWindow") - MainWindow.resize(820, 774) - self.centralwidget = QtGui.QWidget(MainWindow) - self.centralwidget.setObjectName("centralwidget") - self.gridLayout_2 = QtGui.QGridLayout(self.centralwidget) - self.gridLayout_2.setObjectName("gridLayout_2") - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.groupBox = QtGui.QGroupBox(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth()) - self.groupBox.setSizePolicy(sizePolicy) - self.groupBox.setMinimumSize(QtCore.QSize(240, 150)) - self.groupBox.setMaximumSize(QtCore.QSize(240, 16777215)) - self.groupBox.setObjectName("groupBox") - self.formLayoutWidget = QtGui.QWidget(self.groupBox) - self.formLayoutWidget.setGeometry(QtCore.QRect(10, 20, 221, 124)) - self.formLayoutWidget.setObjectName("formLayoutWidget") - self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) - self.formLayout.setObjectName("formLayout") - self.frequencyLabel = QtGui.QLabel(self.formLayoutWidget) - self.frequencyLabel.setObjectName("frequencyLabel") - self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.frequencyLabel) - self.gainLabel = QtGui.QLabel(self.formLayoutWidget) - self.gainLabel.setObjectName("gainLabel") - self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.gainLabel) - self.bandwidthLabel = QtGui.QLabel(self.formLayoutWidget) - self.bandwidthLabel.setObjectName("bandwidthLabel") - self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.bandwidthLabel) - self.frequencyEdit = QtGui.QLineEdit(self.formLayoutWidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.frequencyEdit.sizePolicy().hasHeightForWidth()) - self.frequencyEdit.setSizePolicy(sizePolicy) - self.frequencyEdit.setMinimumSize(QtCore.QSize(120, 26)) - self.frequencyEdit.setObjectName("frequencyEdit") - self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.frequencyEdit) - self.gainEdit = QtGui.QLineEdit(self.formLayoutWidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.gainEdit.sizePolicy().hasHeightForWidth()) - self.gainEdit.setSizePolicy(sizePolicy) - self.gainEdit.setMinimumSize(QtCore.QSize(120, 26)) - self.gainEdit.setObjectName("gainEdit") - self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.gainEdit) - self.bandwidthEdit = QtGui.QLineEdit(self.formLayoutWidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.bandwidthEdit.sizePolicy().hasHeightForWidth()) - self.bandwidthEdit.setSizePolicy(sizePolicy) - self.bandwidthEdit.setMinimumSize(QtCore.QSize(120, 26)) - self.bandwidthEdit.setObjectName("bandwidthEdit") - self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.bandwidthEdit) - self.amplifierLabel = QtGui.QLabel(self.formLayoutWidget) - self.amplifierLabel.setObjectName("amplifierLabel") - self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.amplifierLabel) - self.amplifierEdit = QtGui.QLineEdit(self.formLayoutWidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.amplifierEdit.sizePolicy().hasHeightForWidth()) - self.amplifierEdit.setSizePolicy(sizePolicy) - self.amplifierEdit.setMinimumSize(QtCore.QSize(120, 26)) - self.amplifierEdit.setObjectName("amplifierEdit") - self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.amplifierEdit) - self.horizontalLayout_2.addWidget(self.groupBox) - self.frame_2 = QtGui.QFrame(self.centralwidget) - self.frame_2.setMinimumSize(QtCore.QSize(200, 0)) - self.frame_2.setFrameShape(QtGui.QFrame.StyledPanel) - self.frame_2.setFrameShadow(QtGui.QFrame.Raised) - self.frame_2.setObjectName("frame_2") - self.verticalLayoutWidget = QtGui.QWidget(self.frame_2) - self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, -1, 191, 151)) - self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") - self.verticalLayout_3 = QtGui.QVBoxLayout(self.verticalLayoutWidget) - self.verticalLayout_3.setObjectName("verticalLayout_3") - self.dcCancelCheckBox = QtGui.QCheckBox(self.verticalLayoutWidget) - self.dcCancelCheckBox.setObjectName("dcCancelCheckBox") - self.verticalLayout_3.addWidget(self.dcCancelCheckBox) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.dcGainLabel = QtGui.QLabel(self.verticalLayoutWidget) - self.dcGainLabel.setObjectName("dcGainLabel") - self.horizontalLayout.addWidget(self.dcGainLabel) - self.dcGainEdit = QtGui.QLineEdit(self.verticalLayoutWidget) - self.dcGainEdit.setObjectName("dcGainEdit") - self.horizontalLayout.addWidget(self.dcGainEdit) - self.verticalLayout_3.addLayout(self.horizontalLayout) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout_3.addItem(spacerItem) - self.horizontalLayout_2.addWidget(self.frame_2) - spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_2.addItem(spacerItem1) - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") - spacerItem2 = QtGui.QSpacerItem(20, 80, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - self.verticalLayout.addItem(spacerItem2) - self.pauseButton = QtGui.QPushButton(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pauseButton.sizePolicy().hasHeightForWidth()) - self.pauseButton.setSizePolicy(sizePolicy) - self.pauseButton.setObjectName("pauseButton") - self.verticalLayout.addWidget(self.pauseButton) - self.closeButton = QtGui.QPushButton(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.closeButton.sizePolicy().hasHeightForWidth()) - self.closeButton.setSizePolicy(sizePolicy) - self.closeButton.setMinimumSize(QtCore.QSize(75, 0)) - self.closeButton.setObjectName("closeButton") - self.verticalLayout.addWidget(self.closeButton) - self.horizontalLayout_2.addLayout(self.verticalLayout) - self.gridLayout_2.addLayout(self.horizontalLayout_2, 1, 0, 1, 1) - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.frame = QtGui.QFrame(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(1) - sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth()) - self.frame.setSizePolicy(sizePolicy) - self.frame.setMinimumSize(QtCore.QSize(800, 550)) - self.frame.setFrameShape(QtGui.QFrame.StyledPanel) - self.frame.setFrameShadow(QtGui.QFrame.Raised) - self.frame.setObjectName("frame") - self.gridLayout = QtGui.QGridLayout(self.frame) - self.gridLayout.setObjectName("gridLayout") - self.sinkLayout = QtGui.QHBoxLayout() - self.sinkLayout.setObjectName("sinkLayout") - self.gridLayout.addLayout(self.sinkLayout, 0, 0, 1, 1) - self.verticalLayout_2.addWidget(self.frame) - self.gridLayout_2.addLayout(self.verticalLayout_2, 0, 0, 1, 1) - MainWindow.setCentralWidget(self.centralwidget) - self.menubar = QtGui.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 820, 24)) - self.menubar.setObjectName("menubar") - self.menuFile = QtGui.QMenu(self.menubar) - self.menuFile.setObjectName("menuFile") - MainWindow.setMenuBar(self.menubar) - self.statusbar = QtGui.QStatusBar(MainWindow) - self.statusbar.setObjectName("statusbar") - MainWindow.setStatusBar(self.statusbar) - self.actionExit = QtGui.QAction(MainWindow) - self.actionExit.setObjectName("actionExit") - self.actionSaveData = QtGui.QAction(MainWindow) - self.actionSaveData.setObjectName("actionSaveData") - self.menuFile.addAction(self.actionSaveData) - self.menuFile.addAction(self.actionExit) - self.menubar.addAction(self.menuFile.menuAction()) - - self.retranslateUi(MainWindow) - QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), MainWindow.close) - QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), MainWindow.close) - QtCore.QMetaObject.connectSlotsByName(MainWindow) - - def retranslateUi(self, MainWindow): - MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "USRP Display", None, QtGui.QApplication.UnicodeUTF8)) - self.groupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.frequencyLabel.setText(QtGui.QApplication.translate("MainWindow", "Frequency (Hz)", None, QtGui.QApplication.UnicodeUTF8)) - self.gainLabel.setText(QtGui.QApplication.translate("MainWindow", "RF Gain", None, QtGui.QApplication.UnicodeUTF8)) - self.bandwidthLabel.setText(QtGui.QApplication.translate("MainWindow", "Bandwidth", None, QtGui.QApplication.UnicodeUTF8)) - self.amplifierLabel.setText(QtGui.QApplication.translate("MainWindow", "Amplifier", None, QtGui.QApplication.UnicodeUTF8)) - self.dcCancelCheckBox.setText(QtGui.QApplication.translate("MainWindow", "Cancel DC", None, QtGui.QApplication.UnicodeUTF8)) - self.dcGainLabel.setText(QtGui.QApplication.translate("MainWindow", "DC Canceller Gain", None, QtGui.QApplication.UnicodeUTF8)) - self.pauseButton.setText(QtGui.QApplication.translate("MainWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) - self.closeButton.setText(QtGui.QApplication.translate("MainWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) - self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) - self.actionExit.setText(QtGui.QApplication.translate("MainWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) - self.actionSaveData.setText(QtGui.QApplication.translate("MainWindow", "&Save Data", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/gr-qtgui/python/usrp_display_qtgui.ui b/gr-qtgui/python/usrp_display_qtgui.ui deleted file mode 100644 index e88ca9dce..000000000 --- a/gr-qtgui/python/usrp_display_qtgui.ui +++ /dev/null @@ -1,375 +0,0 @@ - - MainWindow - - - - 0 - 0 - 820 - 774 - - - - USRP Display - - - - - - - - - - 0 - 0 - - - - - 240 - 150 - - - - - 240 - 16777215 - - - - Receiver Parameters - - - - - 10 - 20 - 221 - 124 - - - - - - - Frequency (Hz) - - - - - - - RF Gain - - - - - - - Bandwidth - - - - - - - - 0 - 0 - - - - - 120 - 26 - - - - - - - - - 0 - 0 - - - - - 120 - 26 - - - - - - - - - 0 - 0 - - - - - 120 - 26 - - - - - - - - Amplifier - - - - - - - - 0 - 0 - - - - - 120 - 26 - - - - - - - - - - - - - 200 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - 10 - -1 - 191 - 151 - - - - - - - Cancel DC - - - - - - - - - DC Canceller Gain - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 80 - - - - - - - - - 0 - 0 - - - - Pause - - - - - - - - 0 - 0 - - - - - 75 - 0 - - - - Close - - - - - - - - - - - - - - 0 - 1 - - - - - 800 - 550 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - - - - - - - 0 - 0 - 820 - 24 - - - - - &File - - - - - - - - - - E&xit - - - - - &Save Data - - - - - - - closeButton - clicked() - MainWindow - close() - - - 808 - 739 - - - 66 - 561 - - - - - actionExit - triggered() - MainWindow - close() - - - -1 - -1 - - - 617 - 327 - - - - - -- cgit From b7f96d543b35b8d5a401ced3afbc0aff2d7043db Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 13:41:32 -0400 Subject: gr-qtgui: fixed some signed/unsigned comparison warnings. --- gr-qtgui/lib/WaterfallDisplayPlot.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index a8e5361e7..08a71c023 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -142,7 +142,7 @@ public: std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); // lops off the YYYY-mmm-DD part of the string - int ind = time_str.find(" "); + size_t ind = time_str.find(" "); if(ind != std::string::npos) time_str = time_str.substr(ind); return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); @@ -194,7 +194,7 @@ protected: std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); // lops off the YYYY-mmm-DD part of the string - int ind = time_str.find(" "); + size_t ind = time_str.find(" "); if(ind != std::string::npos) time_str = time_str.substr(ind); QString yLabel(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); -- cgit From 147143f58f50210c5ad2dc66d00d12237183d428 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 14:11:26 -0400 Subject: gr-qtgui: qtgui builds and passes make check under new structure. --- gr-qtgui/apps/.gitignore | 2 ++ gr-qtgui/swig/.gitignore | 2 ++ gr-qtgui/swig/Makefile.am | 2 ++ gr-qtgui/swig/gnuradio/qtgui.scm | 28 ++++++++++++++++++++++++++++ gr-qtgui/swig/qtgui_swig.i | 2 +- 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 gr-qtgui/apps/.gitignore create mode 100644 gr-qtgui/swig/.gitignore create mode 100644 gr-qtgui/swig/gnuradio/qtgui.scm diff --git a/gr-qtgui/apps/.gitignore b/gr-qtgui/apps/.gitignore new file mode 100644 index 000000000..282522db0 --- /dev/null +++ b/gr-qtgui/apps/.gitignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/gr-qtgui/swig/.gitignore b/gr-qtgui/swig/.gitignore new file mode 100644 index 000000000..282522db0 --- /dev/null +++ b/gr-qtgui/swig/.gitignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/gr-qtgui/swig/Makefile.am b/gr-qtgui/swig/Makefile.am index 812d1caca..ab1acce71 100644 --- a/gr-qtgui/swig/Makefile.am +++ b/gr-qtgui/swig/Makefile.am @@ -27,8 +27,10 @@ EXTRA_DIST += $(nobase_guile_DATA) AM_CPPFLAGS = \ -I$(top_srcdir)/gr-qtgui/lib \ + -I$(top_builddir)/gr-qtgui/lib \ $(STD_DEFINES_AND_INCLUDES) \ $(PYTHON_CPPFLAGS) \ + $(QT_INCLUDES) \ $(WITH_INCLUDES) if GUILE diff --git a/gr-qtgui/swig/gnuradio/qtgui.scm b/gr-qtgui/swig/gnuradio/qtgui.scm new file mode 100644 index 000000000..fc650d022 --- /dev/null +++ b/gr-qtgui/swig/gnuradio/qtgui.scm @@ -0,0 +1,28 @@ +;;; +;;; 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 this program. If not, see . +;;; + +;;; Module that just re-exports the qtgui_swig module + +(define-module (gnuradio qtgui) + #:use-module (gnuradio export-safely) + #:use-module (gnuradio qtgui_swig) + #:duplicates (merge-generics replace check)) + +(re-export-all '(gnuradio qtgui_swig)) + diff --git a/gr-qtgui/swig/qtgui_swig.i b/gr-qtgui/swig/qtgui_swig.i index bb64c6ae2..ba97b4e9a 100644 --- a/gr-qtgui/swig/qtgui_swig.i +++ b/gr-qtgui/swig/qtgui_swig.i @@ -122,7 +122,7 @@ public: #if SWIGGUILE %scheme %{ -(load-extension-global "libguile-gnuradio-qtgui" "scm_init_gnuradio_qtgui_module") +(load-extension-global "libguile-gnuradio-qtgui_swig" "scm_init_gnuradio_qtgui_swig_module") %} %goops %{ -- cgit From 3ddd1f9c2e30cb7f3b9848210b84e263d2af9938 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 14:12:32 -0400 Subject: gr-qtgui: typo correct in M4 file. --- config/grc_gr_qtgui.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/grc_gr_qtgui.m4 b/config/grc_gr_qtgui.m4 index fb63e1972..a5eac6293 100644 --- a/config/grc_gr_qtgui.m4 +++ b/config/grc_gr_qtgui.m4 @@ -88,7 +88,7 @@ AC_DEFUN([GRC_GR_QTGUI],[ gr-qtgui/python/Makefile \ gr-qtgui/python/run_tests \ gr-qtgui/swig/Makefile \ - gr-qtgui/dswig/run_guile_tests \ + gr-qtgui/swig/run_guile_tests \ ]) GRC_BUILD_CONDITIONAL(gr-qtgui,[ -- cgit From 9ebfa393e94a5614fccac987a7044bc66814af78 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 14:15:41 -0400 Subject: gr-qtgui: small correction in Python QA code with new structure. --- gr-qtgui/python/qa_qtgui.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gr-qtgui/python/qa_qtgui.py b/gr-qtgui/python/qa_qtgui.py index fbf0de46e..7d3cf8098 100755 --- a/gr-qtgui/python/qa_qtgui.py +++ b/gr-qtgui/python/qa_qtgui.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import qtgui +import qtgui_swig from PyQt4 import QtGui, QtCore import sys, sip @@ -37,9 +37,9 @@ class test_qtgui(gr_unittest.TestCase): pass # Test to make sure we can instantiate these #self.qapp = QtGui.QApplication(sys.argv) - #self.qtsnk = qtgui.sink_c(1024, gr.firdes.WIN_BLACKMAN_hARRIS, - # 0, 1, "Test", - # True, True, False, True, True) + #self.qtsnk = qtgui_swig.sink_c(1024, gr.firdes.WIN_BLACKMAN_hARRIS, + # 0, 1, "Test", + # True, True, False, True, True) if __name__ == '__main__': -- cgit From 0726044c8c608826253d732512b56f0c88e0c55c Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 14:25:15 -0400 Subject: gr-qtgui: making necessary changes to build a python package and export qtgui; also preserves old convention of 'from gnuradio.qtgui import qtgui'. Some of the examples have been updated to use the new (cleaner) convention. --- gr-qtgui/apps/pyqt_example.py | 144 ---------------------------------------- gr-qtgui/apps/pyqt_example_c.py | 144 ++++++++++++++++++++++++++++++++++++++++ gr-qtgui/apps/pyqt_example_f.py | 2 +- gr-qtgui/apps/qt_digital.py | 2 +- gr-qtgui/python/__init__.py | 25 +++++++ 5 files changed, 171 insertions(+), 146 deletions(-) delete mode 100755 gr-qtgui/apps/pyqt_example.py create mode 100755 gr-qtgui/apps/pyqt_example_c.py diff --git a/gr-qtgui/apps/pyqt_example.py b/gr-qtgui/apps/pyqt_example.py deleted file mode 100755 index 7c0cfc698..000000000 --- a/gr-qtgui/apps/pyqt_example.py +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio.qtgui import qtgui -from PyQt4 import QtGui, QtCore -import sys, sip - -class dialog_box(QtGui.QWidget): - def __init__(self, display, control): - QtGui.QWidget.__init__(self, None) - self.setWindowTitle('PyQt Test GUI') - - self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) - self.boxlayout.addWidget(display, 1) - self.boxlayout.addWidget(control) - - self.resize(800, 500) - -class control_box(QtGui.QWidget): - def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) - self.setWindowTitle('Control Panel') - - self.setToolTip('Control the signals') - QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) - - self.layout = QtGui.QFormLayout(self) - - # Control the first signal - self.freq1Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) - self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), - self.freq1EditText) - - self.amp1Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) - self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), - self.amp1EditText) - - - # Control the second signal - self.freq2Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) - self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), - self.freq2EditText) - - - self.amp2Edit = QtGui.QLineEdit(self) - self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) - self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), - self.amp2EditText) - - self.quit = QtGui.QPushButton('Close', self) - self.layout.addWidget(self.quit) - - self.connect(self.quit, QtCore.SIGNAL('clicked()'), - QtGui.qApp, QtCore.SLOT('quit()')) - - def attach_signal1(self, signal): - self.signal1 = signal - self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) - self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) - - def attach_signal2(self, signal): - self.signal2 = signal - self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) - self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) - - def freq1EditText(self): - try: - newfreq = float(self.freq1Edit.text()) - self.signal1.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp1EditText(self): - try: - newamp = float(self.amp1Edit.text()) - self.signal1.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - - def freq2EditText(self): - try: - newfreq = float(self.freq2Edit.text()) - self.signal2.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp2EditText(self): - try: - newamp = float(self.amp2Edit.text()) - self.signal2.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - Rs = 8000 - f1 = 1000 - f2 = 2000 - - fftsize = 2048 - - self.qapp = QtGui.QApplication(sys.argv) - - src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) - src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_cc() - channel = gr.channel_model(0.001) - thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize) - self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, Rs, - "Complex Signal Example", - True, True, False, True, False) - - self.connect(src1, (src,0)) - self.connect(src2, (src,1)) - self.connect(src, channel, thr, self.snk1) - - self.ctrl_win = control_box() - self.ctrl_win.attach_signal1(src1) - self.ctrl_win.attach_signal2(src2) - - # Get the reference pointer to the SpectrumDisplayForm QWidget - pyQt = self.snk1.pyqwidget() - - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - - self.main_box = dialog_box(self.pyWin, self.ctrl_win) - - self.main_box.show() - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() - diff --git a/gr-qtgui/apps/pyqt_example_c.py b/gr-qtgui/apps/pyqt_example_c.py new file mode 100755 index 000000000..e8f377846 --- /dev/null +++ b/gr-qtgui/apps/pyqt_example_c.py @@ -0,0 +1,144 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import qtgui +from PyQt4 import QtGui, QtCore +import sys, sip + +class dialog_box(QtGui.QWidget): + def __init__(self, display, control): + QtGui.QWidget.__init__(self, None) + self.setWindowTitle('PyQt Test GUI') + + self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) + self.boxlayout.addWidget(display, 1) + self.boxlayout.addWidget(control) + + self.resize(800, 500) + +class control_box(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + self.setWindowTitle('Control Panel') + + self.setToolTip('Control the signals') + QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) + + self.layout = QtGui.QFormLayout(self) + + # Control the first signal + self.freq1Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) + self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), + self.freq1EditText) + + self.amp1Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) + self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), + self.amp1EditText) + + + # Control the second signal + self.freq2Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) + self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), + self.freq2EditText) + + + self.amp2Edit = QtGui.QLineEdit(self) + self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) + self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), + self.amp2EditText) + + self.quit = QtGui.QPushButton('Close', self) + self.layout.addWidget(self.quit) + + self.connect(self.quit, QtCore.SIGNAL('clicked()'), + QtGui.qApp, QtCore.SLOT('quit()')) + + def attach_signal1(self, signal): + self.signal1 = signal + self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) + self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) + + def attach_signal2(self, signal): + self.signal2 = signal + self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) + self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) + + def freq1EditText(self): + try: + newfreq = float(self.freq1Edit.text()) + self.signal1.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp1EditText(self): + try: + newamp = float(self.amp1Edit.text()) + self.signal1.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + + def freq2EditText(self): + try: + newfreq = float(self.freq2Edit.text()) + self.signal2.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp2EditText(self): + try: + newamp = float(self.amp2Edit.text()) + self.signal2.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + Rs = 8000 + f1 = 1000 + f2 = 2000 + + fftsize = 2048 + + self.qapp = QtGui.QApplication(sys.argv) + + src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) + src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) + src = gr.add_cc() + channel = gr.channel_model(0.001) + thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize) + self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, Rs, + "Complex Signal Example", + True, True, False, True, False) + + self.connect(src1, (src,0)) + self.connect(src2, (src,1)) + self.connect(src, channel, thr, self.snk1) + + self.ctrl_win = control_box() + self.ctrl_win.attach_signal1(src1) + self.ctrl_win.attach_signal2(src2) + + # Get the reference pointer to the SpectrumDisplayForm QWidget + pyQt = self.snk1.pyqwidget() + + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + + self.main_box = dialog_box(self.pyWin, self.ctrl_win) + + self.main_box.show() + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() + diff --git a/gr-qtgui/apps/pyqt_example_f.py b/gr-qtgui/apps/pyqt_example_f.py index 4e36ccca5..ed525ae63 100755 --- a/gr-qtgui/apps/pyqt_example_f.py +++ b/gr-qtgui/apps/pyqt_example_f.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr, blks2 -from gnuradio.qtgui import qtgui +from gnuradio import qtgui from PyQt4 import QtGui, QtCore import sys, sip diff --git a/gr-qtgui/apps/qt_digital.py b/gr-qtgui/apps/qt_digital.py index 679f144ef..7b9e9b773 100755 --- a/gr-qtgui/apps/qt_digital.py +++ b/gr-qtgui/apps/qt_digital.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr, blks2 -from gnuradio.qtgui import qtgui +from gnuradio import qtgui from gnuradio import eng_notation from PyQt4 import QtGui, QtCore import sys, sip diff --git a/gr-qtgui/python/__init__.py b/gr-qtgui/python/__init__.py index e69de29bb..db113bbd3 100644 --- a/gr-qtgui/python/__init__.py +++ b/gr-qtgui/python/__init__.py @@ -0,0 +1,25 @@ +# +# 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. +# + +# The presence of this file turns this directory into a Python package + +from qtgui_swig import * +import qtgui_swig as qtgui # to preserve the old interface -- cgit From 4c4fab942ddb6b685947bf089b127dfa756de7c4 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 15:03:14 -0400 Subject: gr-qtgui: fixing up the Makefile for proper dist. Passes make distcheck. --- gr-qtgui/apps/Makefile.am | 9 ++++++--- gr-qtgui/python/Makefile.am | 9 +-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/gr-qtgui/apps/Makefile.am b/gr-qtgui/apps/Makefile.am index 4076570d3..c8d967334 100644 --- a/gr-qtgui/apps/Makefile.am +++ b/gr-qtgui/apps/Makefile.am @@ -23,16 +23,19 @@ include $(top_srcdir)/Makefile.common if PYTHON -dist_bin_SCRIPTS = +nodist_bin_SCRIPTS = \ + qt_digital_window.ui \ + usrp_display_qtgui.ui noinst_PYTHON = \ pyqt_example_f.py \ - pyqt_example.py \ + pyqt_example_c.py \ qt_digital.py \ qt_digital_window.py \ usrp2_display.py \ usrp_display.py \ - qa_qtgui.py + qt_digital_window.py \ + usrp_display_qtgui.py EXTRA_DIST += \ qt_digital_window.ui \ diff --git a/gr-qtgui/python/Makefile.am b/gr-qtgui/python/Makefile.am index 0953a71e5..f1bdf359b 100644 --- a/gr-qtgui/python/Makefile.am +++ b/gr-qtgui/python/Makefile.am @@ -22,8 +22,7 @@ include $(top_srcdir)/Makefile.common TESTS = -EXTRA_DIST += run_tests.in \ - qt_digital_window.ui +EXTRA_DIST += run_tests.in if PYTHON TESTS += run_tests @@ -32,12 +31,6 @@ DISTCLEANFILES += run_tests qtguipythondir = $(grpythondir)/qtgui noinst_PYTHON = \ - pyqt_example_f.py \ - pyqt_example.py \ - qt_digital.py \ - qt_digital_window.py \ - usrp2_display.py \ - usrp_display.py \ qa_qtgui.py qtguipython_PYTHON = \ -- cgit From 79fa80423ab962e550b57c1bde49673394d8e0db Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 18:17:17 -0400 Subject: gr-qtgui: cleaning up handling of mutex --- gr-qtgui/lib/qtgui_sink_c.cc | 13 +------------ gr-qtgui/lib/qtgui_sink_c.h | 2 -- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/gr-qtgui/lib/qtgui_sink_c.cc b/gr-qtgui/lib/qtgui_sink_c.cc index 05c7b28d5..dee7c2f43 100644 --- a/gr-qtgui/lib/qtgui_sink_c.cc +++ b/gr-qtgui/lib/qtgui_sink_c.cc @@ -71,8 +71,8 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, fprintf(stderr, "Warning: plotting Waterfall3D has been removed; enabling plotwaterfall3d has no effect.\n"); } + gruel::scoped_lock lock(d_mutex); d_main_gui = NULL; - lock(); // Perform fftshift operation; // this is usually desired when plotting @@ -104,17 +104,6 @@ qtgui_sink_c::forecast(int noutput_items, gr_vector_int &ninput_items_required) } } -void qtgui_sink_c::lock() -{ - d_mutex.lock(); -} - -void qtgui_sink_c::unlock() -{ - d_mutex.unlock(); -} - - void qtgui_sink_c::initialize(const bool opengl) { diff --git a/gr-qtgui/lib/qtgui_sink_c.h b/gr-qtgui/lib/qtgui_sink_c.h index bbf9983b0..bcdcf65ae 100644 --- a/gr-qtgui/lib/qtgui_sink_c.h +++ b/gr-qtgui/lib/qtgui_sink_c.h @@ -99,8 +99,6 @@ private: public: ~qtgui_sink_c(); void exec_(); - void lock(); - void unlock(); QWidget* qwidget(); PyObject* pyqwidget(); -- cgit From efc646ac1231f2381d860df92b2399cbd84f0ec9 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 19:07:05 -0400 Subject: gr-qtgui: improvements to python test apps. --- gr-qtgui/apps/pyqt_example_c.py | 7 ++++++- gr-qtgui/apps/pyqt_example_f.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gr-qtgui/apps/pyqt_example_c.py b/gr-qtgui/apps/pyqt_example_c.py index e8f377846..e1fb8a6be 100755 --- a/gr-qtgui/apps/pyqt_example_c.py +++ b/gr-qtgui/apps/pyqt_example_c.py @@ -28,11 +28,13 @@ class control_box(QtGui.QWidget): # Control the first signal self.freq1Edit = QtGui.QLineEdit(self) + self.freq1Edit.setMinimumWidth(100) self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), self.freq1EditText) self.amp1Edit = QtGui.QLineEdit(self) + self.amp1Edit.setMinimumWidth(100) self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), self.amp1EditText) @@ -40,17 +42,20 @@ class control_box(QtGui.QWidget): # Control the second signal self.freq2Edit = QtGui.QLineEdit(self) + self.freq2Edit.setMinimumWidth(100) self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), self.freq2EditText) self.amp2Edit = QtGui.QLineEdit(self) + self.amp2Edit.setMinimumWidth(100) self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), self.amp2EditText) self.quit = QtGui.QPushButton('Close', self) + self.quit.setMinimumWidth(100) self.layout.addWidget(self.quit) self.connect(self.quit, QtCore.SIGNAL('clicked()'), @@ -140,5 +145,5 @@ class my_top_block(gr.top_block): if __name__ == "__main__": tb = my_top_block(); tb.start() - tb.qapp.exec_() + sys.exit(tb.qapp.exec_()) diff --git a/gr-qtgui/apps/pyqt_example_f.py b/gr-qtgui/apps/pyqt_example_f.py index ed525ae63..55d987329 100755 --- a/gr-qtgui/apps/pyqt_example_f.py +++ b/gr-qtgui/apps/pyqt_example_f.py @@ -28,11 +28,13 @@ class control_box(QtGui.QWidget): # Control the first signal self.freq1Edit = QtGui.QLineEdit(self) + self.freq1Edit.setMinimumWidth(100) self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), self.freq1EditText) self.amp1Edit = QtGui.QLineEdit(self) + self.amp1Edit.setMinimumWidth(100) self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), self.amp1EditText) @@ -40,17 +42,20 @@ class control_box(QtGui.QWidget): # Control the second signal self.freq2Edit = QtGui.QLineEdit(self) + self.freq2Edit.setMinimumWidth(100) self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), self.freq2EditText) self.amp2Edit = QtGui.QLineEdit(self) + self.amp2Edit.setMinimumWidth(100) self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), self.amp2EditText) self.quit = QtGui.QPushButton('Close', self) + self.quit.setMinimumWidth(100) self.layout.addWidget(self.quit) self.connect(self.quit, QtCore.SIGNAL('clicked()'), @@ -139,5 +144,5 @@ class my_top_block(gr.top_block): if __name__ == "__main__": tb = my_top_block(); tb.start() - tb.qapp.exec_() + sys.exit(tb.qapp.exec_()) -- cgit From 7563ab82b34600219daf45555a00de79dd254fdb Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 27 Mar 2011 19:21:58 -0400 Subject: gr-qtgui: tightening up and cleaning up some memory leaks. --- gr-qtgui/lib/qtgui.h | 6 +++++- gr-qtgui/lib/qtgui_sink_c.cc | 3 ++- gr-qtgui/lib/spectrumdisplayform.cc | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gr-qtgui/lib/qtgui.h b/gr-qtgui/lib/qtgui.h index 9831697ac..27279e5cd 100644 --- a/gr-qtgui/lib/qtgui.h +++ b/gr-qtgui/lib/qtgui.h @@ -40,6 +40,8 @@ public: //nop } + ~qtgui_event() {} + void lock() { d_mutex.lock(); @@ -58,7 +60,9 @@ public: : QObject(p) { } - + + ~qtgui_obj() {} + void customEvent(QEvent *e) { if(e->type() == (QEvent::Type)(QEvent::User+101)) { diff --git a/gr-qtgui/lib/qtgui_sink_c.cc b/gr-qtgui/lib/qtgui_sink_c.cc index dee7c2f43..405971aa0 100644 --- a/gr-qtgui/lib/qtgui_sink_c.cc +++ b/gr-qtgui/lib/qtgui_sink_c.cc @@ -93,6 +93,7 @@ qtgui_sink_c::~qtgui_sink_c() delete d_main_gui; delete [] d_residbuf; delete d_fft; + delete d_object; } void @@ -111,7 +112,7 @@ qtgui_sink_c::initialize(const bool opengl) d_qApplication = qApp; } else { - int argc; + int argc=0; char **argv = NULL; d_qApplication = new QApplication(argc, argv); } diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index e0509a294..b5d4bf4d7 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -74,6 +74,11 @@ SpectrumDisplayForm::~SpectrumDisplayForm() delete[] _realFFTDataPoints; delete[] _averagedValues; + delete _frequencyDisplayPlot; + delete _waterfallDisplayPlot; + delete _timeDomainDisplayPlot; + delete _constellationDisplayPlot; + for(unsigned int count = 0; count < _historyVector->size(); count++){ delete[] _historyVector->operator[](count); } -- cgit From 2653d20527b9c8b431b9bfcd396bc2a03a8a950b Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 1 Apr 2011 10:59:33 -0400 Subject: gr-qtgui: wip trying to figure out segfaults. --- gr-qtgui/apps/pyqt_example_c.py | 5 ++ gr-qtgui/lib/SpectrumGUIClass.cc | 96 ++++++++++++++++--------------------- gr-qtgui/lib/SpectrumGUIClass.h | 24 +++++----- gr-qtgui/lib/spectrumdisplayform.cc | 8 ++-- 4 files changed, 61 insertions(+), 72 deletions(-) diff --git a/gr-qtgui/apps/pyqt_example_c.py b/gr-qtgui/apps/pyqt_example_c.py index e1fb8a6be..6625857a5 100755 --- a/gr-qtgui/apps/pyqt_example_c.py +++ b/gr-qtgui/apps/pyqt_example_c.py @@ -5,6 +5,11 @@ from gnuradio import qtgui from PyQt4 import QtGui, QtCore import sys, sip +import os +print os.getpid() +raw_input() + + class dialog_box(QtGui.QWidget): def __init__(self, display, control): QtGui.QWidget.__init__(self, None) diff --git a/gr-qtgui/lib/SpectrumGUIClass.cc b/gr-qtgui/lib/SpectrumGUIClass.cc index 052730fc2..c62f34290 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.cc +++ b/gr-qtgui/lib/SpectrumGUIClass.cc @@ -37,15 +37,13 @@ SpectrumGUIClass::SpectrumGUIClass(const uint64_t maxDataSize, _windowOpennedFlag = false; _fftBuffersCreatedFlag = false; - // Create Mutex Lock - //_windowStateLock = new MutexClass("_windowStateLock"); - _powerValue = 1; } SpectrumGUIClass::~SpectrumGUIClass() { if(GetWindowOpenFlag()){ + printf("spectrumDisplayForm: %p\n", _spectrumDisplayForm); delete _spectrumDisplayForm; } @@ -54,8 +52,6 @@ SpectrumGUIClass::~SpectrumGUIClass() delete[] _realTimeDomainPoints; delete[] _imagTimeDomainPoints; } - - //delete _windowStateLock; } void @@ -64,7 +60,7 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, const bool time, const bool constellation, const bool use_openGL) { - //_windowStateLock->Lock(); + d_mutex.lock(); if(!_windowOpennedFlag){ @@ -82,6 +78,7 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, // Called from the Event Thread _spectrumDisplayForm = new SpectrumDisplayForm(use_openGL, parent); + printf("spectrumDisplayForm: %p\n", _spectrumDisplayForm); // Toggle Windows on/off _spectrumDisplayForm->ToggleTabFrequency(frequency); @@ -95,8 +92,8 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, qApp->processEvents(); } + d_mutex.unlock(); - //_windowStateLock->Unlock(); SetDisplayTitle(_title); Reset(); @@ -104,7 +101,7 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, qApp->postEvent(_spectrumDisplayForm, new QEvent(QEvent::Type(QEvent::User+3))); - qApp->processEvents(); + //qApp->processEvents(); timespec_reset(&_lastGUIUpdateTime); @@ -147,10 +144,9 @@ SpectrumGUIClass::SetDisplayTitle(const std::string newString) bool SpectrumGUIClass::GetWindowOpenFlag() { + gruel::scoped_lock lock(d_mutex); bool returnFlag = false; - //_windowStateLock->Lock(); returnFlag = _windowOpennedFlag; - //_windowStateLock->Unlock(); return returnFlag; } @@ -158,9 +154,8 @@ SpectrumGUIClass::GetWindowOpenFlag() void SpectrumGUIClass::SetWindowOpenFlag(const bool newFlag) { - //_windowStateLock->Lock(); + gruel::scoped_lock lock(d_mutex); _windowOpennedFlag = newFlag; - //_windowStateLock->Unlock(); } void @@ -168,7 +163,7 @@ SpectrumGUIClass::SetFrequencyRange(const double centerFreq, const double startFreq, const double stopFreq) { - //_windowStateLock->Lock(); + gruel::scoped_lock lock(d_mutex); _centerFrequency = centerFreq; _startFrequency = startFreq; _stopFrequency = stopFreq; @@ -176,36 +171,32 @@ SpectrumGUIClass::SetFrequencyRange(const double centerFreq, _spectrumDisplayForm->SetFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency); - //_windowStateLock->Unlock(); } double -SpectrumGUIClass::GetStartFrequency() const +SpectrumGUIClass::GetStartFrequency() { + gruel::scoped_lock lock(d_mutex); double returnValue = 0.0; - //_windowStateLock->Lock(); returnValue = _startFrequency; - //_windowStateLock->Unlock(); return returnValue; } double -SpectrumGUIClass::GetStopFrequency() const +SpectrumGUIClass::GetStopFrequency() { + gruel::scoped_lock lock(d_mutex); double returnValue = 0.0; - //_windowStateLock->Lock(); returnValue = _stopFrequency; - //_windowStateLock->Unlock(); return returnValue; } double -SpectrumGUIClass::GetCenterFrequency() const +SpectrumGUIClass::GetCenterFrequency() { + gruel::scoped_lock lock(d_mutex); double returnValue = 0.0; - //_windowStateLock->Lock(); returnValue = _centerFrequency; - //_windowStateLock->Unlock(); return returnValue; } @@ -221,6 +212,7 @@ SpectrumGUIClass::UpdateWindow(const bool updateDisplayFlag, const timespec timestamp, const bool lastOfMultipleFFTUpdateFlag) { + //gruel::scoped_lock lock(d_mutex); int64_t bufferSize = inputBufferSize; bool repeatDataFlag = false; if(bufferSize > _dataPoints){ @@ -302,54 +294,49 @@ SpectrumGUIClass::UpdateWindow(const bool updateDisplayFlag, } float -SpectrumGUIClass::GetPowerValue() const +SpectrumGUIClass::GetPowerValue() { + gruel::scoped_lock lock(d_mutex); float returnValue = 0; - //_windowStateLock->Lock(); returnValue = _powerValue; - //_windowStateLock->Unlock(); return returnValue; } void SpectrumGUIClass::SetPowerValue(const float value) { - //_windowStateLock->Lock(); + gruel::scoped_lock lock(d_mutex); _powerValue = value; - //_windowStateLock->Unlock(); } int -SpectrumGUIClass::GetWindowType() const +SpectrumGUIClass::GetWindowType() { + gruel::scoped_lock lock(d_mutex); int returnValue = 0; - //_windowStateLock->Lock(); returnValue = _windowType; - //_windowStateLock->Unlock(); return returnValue; } void SpectrumGUIClass::SetWindowType(const int newType) { - //_windowStateLock->Lock(); + gruel::scoped_lock lock(d_mutex); _windowType = newType; - //_windowStateLock->Unlock(); } int -SpectrumGUIClass::GetFFTSize() const +SpectrumGUIClass::GetFFTSize() { int returnValue = 0; - //_windowStateLock->Lock(); returnValue = _fftSize; - //_windowStateLock->Unlock(); return returnValue; } int -SpectrumGUIClass::GetFFTSizeIndex() const +SpectrumGUIClass::GetFFTSizeIndex() { + gruel::scoped_lock lock(d_mutex); int fftsize = GetFFTSize(); switch(fftsize) { case(1024): return 0; break; @@ -365,75 +352,70 @@ SpectrumGUIClass::GetFFTSizeIndex() const void SpectrumGUIClass::SetFFTSize(const int newSize) { - //_windowStateLock->Lock(); + gruel::scoped_lock lock(d_mutex); _fftSize = newSize; - //_windowStateLock->Unlock(); } timespec -SpectrumGUIClass::GetLastGUIUpdateTime() const +SpectrumGUIClass::GetLastGUIUpdateTime() { + gruel::scoped_lock lock(d_mutex); timespec returnValue; - //_windowStateLock->Lock(); returnValue = _lastGUIUpdateTime; - //_windowStateLock->Unlock(); return returnValue; } void SpectrumGUIClass::SetLastGUIUpdateTime(const timespec newTime) { - //_windowStateLock->Lock(); + gruel::scoped_lock lock(d_mutex); _lastGUIUpdateTime = newTime; - //_windowStateLock->Unlock(); } unsigned int -SpectrumGUIClass::GetPendingGUIUpdateEvents() const +SpectrumGUIClass::GetPendingGUIUpdateEvents() { + gruel::scoped_lock lock(d_mutex); unsigned int returnValue = 0; - //_windowStateLock->Lock(); returnValue = _pendingGUIUpdateEventsCount; - //_windowStateLock->Unlock(); return returnValue; } void SpectrumGUIClass::IncrementPendingGUIUpdateEvents() { - //_windowStateLock->Lock(); + gruel::scoped_lock lock(d_mutex); _pendingGUIUpdateEventsCount++; - //_windowStateLock->Unlock(); } void SpectrumGUIClass::DecrementPendingGUIUpdateEvents() { - //_windowStateLock->Lock(); + gruel::scoped_lock lock(d_mutex); if(_pendingGUIUpdateEventsCount > 0){ _pendingGUIUpdateEventsCount--; } - //_windowStateLock->Unlock(); } void SpectrumGUIClass::ResetPendingGUIUpdateEvents() { - //_windowStateLock->Lock(); + gruel::scoped_lock lock(d_mutex); _pendingGUIUpdateEventsCount = 0; - //_windowStateLock->Unlock(); } QWidget* SpectrumGUIClass::qwidget() { + gruel::scoped_lock lock(d_mutex); return (QWidget*)_spectrumDisplayForm; } void SpectrumGUIClass::SetTimeDomainAxis(double min, double max) { + gruel::scoped_lock lock(d_mutex); _spectrumDisplayForm->SetTimeDomainAxis(min, max); } @@ -441,12 +423,14 @@ void SpectrumGUIClass::SetConstellationAxis(double xmin, double xmax, double ymin, double ymax) { + gruel::scoped_lock lock(d_mutex); _spectrumDisplayForm->SetConstellationAxis(xmin, xmax, ymin, ymax); - } void -SpectrumGUIClass::SetConstellationPenSize(int size){ +SpectrumGUIClass::SetConstellationPenSize(int size) +{ + gruel::scoped_lock lock(d_mutex); _spectrumDisplayForm->SetConstellationPenSize(size); } @@ -454,12 +438,14 @@ SpectrumGUIClass::SetConstellationPenSize(int size){ void SpectrumGUIClass::SetFrequencyAxis(double min, double max) { + gruel::scoped_lock lock(d_mutex); _spectrumDisplayForm->SetFrequencyAxis(min, max); } void SpectrumGUIClass::SetUpdateTime(double t) { + gruel::scoped_lock lock(d_mutex); _updateTime = t; _spectrumDisplayForm->SetUpdateTime(_updateTime); } diff --git a/gr-qtgui/lib/SpectrumGUIClass.h b/gr-qtgui/lib/SpectrumGUIClass.h index 57a749a6a..8ffb411b8 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.h +++ b/gr-qtgui/lib/SpectrumGUIClass.h @@ -1,15 +1,13 @@ #ifndef SPECTRUM_GUI_CLASS_HPP #define SPECTRUM_GUI_CLASS_HPP -//#include +#include #include #include #include #include #include -//#include - class SpectrumDisplayForm; #include @@ -39,9 +37,9 @@ public: void SetWindowOpenFlag(const bool); void SetFrequencyRange(const double, const double, const double); - double GetStartFrequency()const; - double GetStopFrequency()const; - double GetCenterFrequency()const; + double GetStartFrequency(); + double GetStopFrequency(); + double GetCenterFrequency(); void UpdateWindow(const bool, const std::complex*, const uint64_t, const float*, @@ -49,20 +47,20 @@ public: const uint64_t, const timespec, const bool); - float GetPowerValue()const; + float GetPowerValue(); void SetPowerValue(const float); - int GetWindowType()const; + int GetWindowType(); void SetWindowType(const int); - int GetFFTSize()const; - int GetFFTSizeIndex()const; + int GetFFTSize(); + int GetFFTSizeIndex(); void SetFFTSize(const int); - timespec GetLastGUIUpdateTime()const; + timespec GetLastGUIUpdateTime(); void SetLastGUIUpdateTime(const timespec); - unsigned int GetPendingGUIUpdateEvents()const; + unsigned int GetPendingGUIUpdateEvents(); void IncrementPendingGUIUpdateEvents(); void DecrementPendingGUIUpdateEvents(); void ResetPendingGUIUpdateEvents(); @@ -84,7 +82,7 @@ protected: private: - //MutexClass* _windowStateLock; + gruel::mutex d_mutex; int64_t _dataPoints; std::string _title; double _centerFrequency; diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index b5d4bf4d7..d85637a67 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -74,10 +74,10 @@ SpectrumDisplayForm::~SpectrumDisplayForm() delete[] _realFFTDataPoints; delete[] _averagedValues; - delete _frequencyDisplayPlot; - delete _waterfallDisplayPlot; - delete _timeDomainDisplayPlot; - delete _constellationDisplayPlot; + //delete _frequencyDisplayPlot; + //delete _waterfallDisplayPlot; + //delete _timeDomainDisplayPlot; + //delete _constellationDisplayPlot; for(unsigned int count = 0; count < _historyVector->size(); count++){ delete[] _historyVector->operator[](count); -- cgit From 414ff0e69704f8c75edfc2ad3284a9c1bba5e50c Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 4 Apr 2011 23:37:58 -0400 Subject: gr-qtgui: removing unnecessary mutex and qtevent objects. --- gr-qtgui/lib/qtgui_sink_c.cc | 7 ------- gr-qtgui/lib/qtgui_sink_c.h | 6 +++--- gr-qtgui/lib/qtgui_sink_f.cc | 15 --------------- gr-qtgui/lib/qtgui_sink_f.h | 7 +------ 4 files changed, 4 insertions(+), 31 deletions(-) diff --git a/gr-qtgui/lib/qtgui_sink_c.cc b/gr-qtgui/lib/qtgui_sink_c.cc index 405971aa0..bdd941fe1 100644 --- a/gr-qtgui/lib/qtgui_sink_c.cc +++ b/gr-qtgui/lib/qtgui_sink_c.cc @@ -71,7 +71,6 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, fprintf(stderr, "Warning: plotting Waterfall3D has been removed; enabling plotwaterfall3d has no effect.\n"); } - gruel::scoped_lock lock(d_mutex); d_main_gui = NULL; // Perform fftshift operation; @@ -93,7 +92,6 @@ qtgui_sink_c::~qtgui_sink_c() delete d_main_gui; delete [] d_residbuf; delete d_fft; - delete d_object; } void @@ -138,9 +136,6 @@ qtgui_sink_c::initialize(const bool opengl) // initialize update time to 10 times a second set_update_time(0.1); - - d_object = new qtgui_obj(d_qApplication); - qApp->postEvent(d_object, new qtgui_event(d_mutex)); } @@ -278,8 +273,6 @@ qtgui_sink_c::general_work (int noutput_items, int j=0; const gr_complex *in = (const gr_complex*)input_items[0]; - gruel::scoped_lock lock(d_mutex); - // Update the FFT size from the application fftresize(); windowreset(); diff --git a/gr-qtgui/lib/qtgui_sink_c.h b/gr-qtgui/lib/qtgui_sink_c.h index bcdcf65ae..59b5acfe5 100644 --- a/gr-qtgui/lib/qtgui_sink_c.h +++ b/gr-qtgui/lib/qtgui_sink_c.h @@ -28,7 +28,7 @@ #include #include #include -#include +//#include #include "SpectrumGUIClass.h" class qtgui_sink_c; @@ -76,7 +76,7 @@ private: double d_bandwidth; std::string d_name; - gruel::mutex d_mutex; + //gruel::mutex d_mutex; bool d_shift; gri_fft_complex *d_fft; @@ -114,7 +114,7 @@ public: void set_update_time(double t); QApplication *d_qApplication; - qtgui_obj *d_object; + //qtgui_obj *d_object; int general_work (int noutput_items, gr_vector_int &ninput_items, diff --git a/gr-qtgui/lib/qtgui_sink_f.cc b/gr-qtgui/lib/qtgui_sink_f.cc index 984c2803c..3b3140b5e 100644 --- a/gr-qtgui/lib/qtgui_sink_f.cc +++ b/gr-qtgui/lib/qtgui_sink_f.cc @@ -104,16 +104,6 @@ qtgui_sink_f::forecast(int noutput_items, gr_vector_int &ninput_items_required) } } -void qtgui_sink_f::lock() -{ - d_mutex.lock(); -} - -void qtgui_sink_f::unlock() -{ - d_mutex.unlock(); -} - void qtgui_sink_f::initialize(const bool opengl) { @@ -143,9 +133,6 @@ qtgui_sink_f::initialize(const bool opengl) // initialize update time to 10 times a second set_update_time(0.1); - - d_object = new qtgui_obj(d_qApplication); - qApp->postEvent(d_object, new qtgui_event(d_mutex)); } void @@ -283,8 +270,6 @@ qtgui_sink_f::general_work (int noutput_items, int j=0; const float *in = (const float*)input_items[0]; - gruel::scoped_lock lock(d_mutex); - // Update the FFT size from the application fftresize(); windowreset(); diff --git a/gr-qtgui/lib/qtgui_sink_f.h b/gr-qtgui/lib/qtgui_sink_f.h index d80a6a198..a798a41bb 100644 --- a/gr-qtgui/lib/qtgui_sink_f.h +++ b/gr-qtgui/lib/qtgui_sink_f.h @@ -28,7 +28,7 @@ #include #include #include -#include +//#include #include "SpectrumGUIClass.h" class qtgui_sink_f; @@ -74,8 +74,6 @@ private: double d_bandwidth; std::string d_name; - gruel::mutex d_mutex; - bool d_shift; gri_fft_complex *d_fft; @@ -97,8 +95,6 @@ private: public: ~qtgui_sink_f(); void exec_(); - void lock(); - void unlock(); QWidget* qwidget(); PyObject* pyqwidget(); @@ -114,7 +110,6 @@ public: void set_update_time(double t); QApplication *d_qApplication; - qtgui_obj *d_object; int general_work (int noutput_items, gr_vector_int &ninput_items, -- cgit From fb89b81971ecb6859936ee484d31f5bd3e665f62 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 4 Apr 2011 23:38:37 -0400 Subject: gr-qtgui: removing uncessary file of qtevents and objects. --- gr-qtgui/lib/Makefile.am | 1 - gr-qtgui/lib/qtgui.h | 75 ------------------------------------------------ 2 files changed, 76 deletions(-) delete mode 100644 gr-qtgui/lib/qtgui.h diff --git a/gr-qtgui/lib/Makefile.am b/gr-qtgui/lib/Makefile.am index 687a4f966..7c21bfc14 100644 --- a/gr-qtgui/lib/Makefile.am +++ b/gr-qtgui/lib/Makefile.am @@ -69,7 +69,6 @@ grinclude_HEADERS = \ spectrumdisplayform.h \ SpectrumGUIClass.h \ spectrumUpdateEvents.h \ - qtgui.h \ qtgui_sink_c.h \ qtgui_sink_f.h diff --git a/gr-qtgui/lib/qtgui.h b/gr-qtgui/lib/qtgui.h deleted file mode 100644 index 27279e5cd..000000000 --- a/gr-qtgui/lib/qtgui.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- 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 INCLUDED_QTGUI_H -#define INCLUDED_QTGUI_H - -#include -#include -#include "SpectrumGUIClass.h" - -class qtgui_event : public QEvent -{ -private: - gruel::mutex &d_mutex; - -public: - qtgui_event(gruel::mutex &mutex) - : QEvent((QEvent::Type)(QEvent::User+101)), - d_mutex(mutex) - { - //nop - } - - ~qtgui_event() {} - - void lock() - { - d_mutex.lock(); - } - - void unlock() - { - d_mutex.unlock(); - } -}; - -class qtgui_obj : public QObject -{ -public: - qtgui_obj(QObject *p) - : QObject(p) - { - } - - ~qtgui_obj() {} - - void customEvent(QEvent *e) - { - if(e->type() == (QEvent::Type)(QEvent::User+101)) { - qtgui_event *qt = (qtgui_event*)e; - qt->unlock(); - } - } -}; - -#endif /* INCLUDED_QTGUI_H */ -- cgit From c5fd71cf8e03617a902291e85c589f3ff37e3fd8 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 4 Apr 2011 23:41:09 -0400 Subject: gr-qtgui: missed lock call that was just deleted. --- gr-qtgui/lib/qtgui_sink_f.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/gr-qtgui/lib/qtgui_sink_f.cc b/gr-qtgui/lib/qtgui_sink_f.cc index 3b3140b5e..e27ff3ac1 100644 --- a/gr-qtgui/lib/qtgui_sink_f.cc +++ b/gr-qtgui/lib/qtgui_sink_f.cc @@ -72,7 +72,6 @@ qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype, } d_main_gui = NULL; - lock(); // Perform fftshift operation; // this is usually desired when plotting -- cgit From 484b6a0715f2ed6e4f460ee05887e1e5c98c1e2f Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 6 Apr 2011 00:05:05 -0400 Subject: gr-qtgui: don't delete the SpectrumDisplayWindow; as a QWidget, it takes care of itself when the parent is deleted. --- gr-qtgui/lib/SpectrumGUIClass.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gr-qtgui/lib/SpectrumGUIClass.cc b/gr-qtgui/lib/SpectrumGUIClass.cc index c62f34290..3342c0cb3 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.cc +++ b/gr-qtgui/lib/SpectrumGUIClass.cc @@ -42,10 +42,12 @@ SpectrumGUIClass::SpectrumGUIClass(const uint64_t maxDataSize, SpectrumGUIClass::~SpectrumGUIClass() { - if(GetWindowOpenFlag()){ - printf("spectrumDisplayForm: %p\n", _spectrumDisplayForm); - delete _spectrumDisplayForm; - } + // We don't need to delete this since as a QWidget, it is supposed to be destroyed + // with it's parent. Deleting it causes a segmentation fault, and not deleting it + // does not leave any extra memory. + //if(GetWindowOpenFlag()){ + //delete _spectrumDisplayForm; + //} if(_fftBuffersCreatedFlag){ delete[] _fftPoints; @@ -78,7 +80,6 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, // Called from the Event Thread _spectrumDisplayForm = new SpectrumDisplayForm(use_openGL, parent); - printf("spectrumDisplayForm: %p\n", _spectrumDisplayForm); // Toggle Windows on/off _spectrumDisplayForm->ToggleTabFrequency(frequency); @@ -101,8 +102,6 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, qApp->postEvent(_spectrumDisplayForm, new QEvent(QEvent::Type(QEvent::User+3))); - //qApp->processEvents(); - timespec_reset(&_lastGUIUpdateTime); // Draw Blank Display -- cgit From b0f876b55549db96920c2b3bfee32de6748096af Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 6 Apr 2011 00:07:00 -0400 Subject: gr-qtgui: cleaning up unnecessary plotting calls. --- gr-qtgui/apps/pyqt_example_c.py | 5 ----- gr-qtgui/lib/ConstellationDisplayPlot.cc | 4 ---- gr-qtgui/lib/FrequencyDisplayPlot.cc | 2 -- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 4 ---- gr-qtgui/lib/spectrumdisplayform.cc | 8 +++----- 5 files changed, 3 insertions(+), 20 deletions(-) diff --git a/gr-qtgui/apps/pyqt_example_c.py b/gr-qtgui/apps/pyqt_example_c.py index 6625857a5..e1fb8a6be 100755 --- a/gr-qtgui/apps/pyqt_example_c.py +++ b/gr-qtgui/apps/pyqt_example_c.py @@ -5,11 +5,6 @@ from gnuradio import qtgui from PyQt4 import QtGui, QtCore import sys, sip -import os -print os.getpid() -raw_input() - - class dialog_box(QtGui.QWidget): def __init__(self, display, control): QtGui.QWidget.__init__(self, None) diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.cc b/gr-qtgui/lib/ConstellationDisplayPlot.cc index 9ad5bdd3c..71933cece 100644 --- a/gr-qtgui/lib/ConstellationDisplayPlot.cc +++ b/gr-qtgui/lib/ConstellationDisplayPlot.cc @@ -74,8 +74,6 @@ ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent) memset(_realDataPoints, 0x0, _numPoints*sizeof(double)); memset(_imagDataPoints, 0x0, _numPoints*sizeof(double)); - replot(); - _zoomer = new ConstellationDisplayZoomer(canvas()); #if QT_VERSION < 0x040000 _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, @@ -178,8 +176,6 @@ void ConstellationDisplayPlot::PlotNewData(const double* realDataPoints, memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double)); memcpy(_imagDataPoints, imagDataPoints, numDataPoints*sizeof(double)); - replot(); - _lastReplot = get_highres_clock(); } } diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.cc b/gr-qtgui/lib/FrequencyDisplayPlot.cc index d150e2e4c..45e2e6c16 100644 --- a/gr-qtgui/lib/FrequencyDisplayPlot.cc +++ b/gr-qtgui/lib/FrequencyDisplayPlot.cc @@ -367,8 +367,6 @@ FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDat SetUpperIntensityLevel(_peakAmplitude); - replot(); - _lastReplot = get_highres_clock(); } } diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index 9c98cec5b..da28d0304 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -121,8 +121,6 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent) _sampleRate = 1; _resetXAxisPoints(); - replot(); - #if QT_VERSION < 0x040000 _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); @@ -220,8 +218,6 @@ void TimeDomainDisplayPlot::PlotNewData(const double* realDataPoints, memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double)); memcpy(_imagDataPoints, imagDataPoints, numDataPoints*sizeof(double)); - replot(); - _lastReplot = get_highres_clock(); } } diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index d85637a67..d4fc03781 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -59,6 +59,9 @@ SpectrumDisplayForm::SpectrumDisplayForm(bool useOpenGL, QWidget* parent) ToggleTabTime(false); ToggleTabConstellation(false); + _historyEntry = 0; + _historyEntryCount = 0; + // Create a timer to update plots at the specified rate displayTimer = new QTimer(this); connect(displayTimer, SIGNAL(timeout()), this, SLOT(UpdateGuiTimer())); @@ -74,11 +77,6 @@ SpectrumDisplayForm::~SpectrumDisplayForm() delete[] _realFFTDataPoints; delete[] _averagedValues; - //delete _frequencyDisplayPlot; - //delete _waterfallDisplayPlot; - //delete _timeDomainDisplayPlot; - //delete _constellationDisplayPlot; - for(unsigned int count = 0; count < _historyVector->size(); count++){ delete[] _historyVector->operator[](count); } -- cgit From 8f53f5a782a6500d191ba557b37e7e3785cf6e02 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 6 Apr 2011 00:22:29 -0400 Subject: gr-qtgui: removing references to 3D waterfall plot and changning QtGui API to remove bool that turns it on/off. --- gr-qtgui/apps/pyqt_example_c.py | 2 +- gr-qtgui/apps/pyqt_example_f.py | 2 +- gr-qtgui/apps/qt_digital.py | 4 ++-- gr-qtgui/apps/usrp2_display.py | 2 +- gr-qtgui/apps/usrp_display.py | 2 +- gr-qtgui/grc/qtgui_sink_x.xml | 10 ---------- gr-qtgui/lib/.gitignore | 1 - gr-qtgui/lib/qtgui_sink_c.cc | 13 +++---------- gr-qtgui/lib/qtgui_sink_c.h | 10 +++------- gr-qtgui/lib/qtgui_sink_f.cc | 13 +++---------- gr-qtgui/lib/qtgui_sink_f.h | 9 +++------ gr-qtgui/lib/spectrumdisplayform.cc | 2 -- gr-qtgui/lib/spectrumdisplayform.h | 2 -- gr-qtgui/python/qa_qtgui.py | 10 +++++----- gr-qtgui/swig/qtgui_swig.i | 18 ++++++------------ 15 files changed, 29 insertions(+), 71 deletions(-) diff --git a/gr-qtgui/apps/pyqt_example_c.py b/gr-qtgui/apps/pyqt_example_c.py index e1fb8a6be..90eec3694 100755 --- a/gr-qtgui/apps/pyqt_example_c.py +++ b/gr-qtgui/apps/pyqt_example_c.py @@ -121,7 +121,7 @@ class my_top_block(gr.top_block): self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, Rs, "Complex Signal Example", - True, True, False, True, False) + True, True, True, False) self.connect(src1, (src,0)) self.connect(src2, (src,1)) diff --git a/gr-qtgui/apps/pyqt_example_f.py b/gr-qtgui/apps/pyqt_example_f.py index 55d987329..29905b8d9 100755 --- a/gr-qtgui/apps/pyqt_example_f.py +++ b/gr-qtgui/apps/pyqt_example_f.py @@ -120,7 +120,7 @@ class my_top_block(gr.top_block): self.snk1 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, Rs, "Float Signal Example", - True, True, False, True, False) + True, True, True, False) self.connect(src1, (src,0)) self.connect(src2, (src,1)) diff --git a/gr-qtgui/apps/qt_digital.py b/gr-qtgui/apps/qt_digital.py index 7b9e9b773..c6920a05d 100755 --- a/gr-qtgui/apps/qt_digital.py +++ b/gr-qtgui/apps/qt_digital.py @@ -185,11 +185,11 @@ class my_top_block(gr.top_block): self.thr = gr.throttle(gr.sizeof_char, self._sample_rate) self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, self._sample_rate*self.sps, - "Tx", True, True, False, True, True) + "Tx", True, True, True, True) self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, self._sample_rate, - "Rx", True, True, False, True, True) + "Rx", True, True, True, True) self.connect(self.src, self.thr, self.mod, self.channel, self.snk_tx) self.connect(self.channel, self.rx_rrc, self.receiver, self.snk_rx) diff --git a/gr-qtgui/apps/usrp2_display.py b/gr-qtgui/apps/usrp2_display.py index 75d374c2b..ab1a6f742 100755 --- a/gr-qtgui/apps/usrp2_display.py +++ b/gr-qtgui/apps/usrp2_display.py @@ -210,7 +210,7 @@ class my_top_block(gr.top_block): self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS, self._freq, self._bandwidth, "USRP2 Display", - True, True, False, True, False) + True, True, True, False) # Set up internal amplifier self.amp = gr.multiply_const_cc(0.0) diff --git a/gr-qtgui/apps/usrp_display.py b/gr-qtgui/apps/usrp_display.py index 432e74d9a..131bc4a7e 100755 --- a/gr-qtgui/apps/usrp_display.py +++ b/gr-qtgui/apps/usrp_display.py @@ -229,7 +229,7 @@ class my_top_block(gr.top_block): self.snk = qtgui.sink_c(self._fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, self._freq, self._bandwidth, "USRP Display", - True, True, False, True, False) + True, True, True, False) # Set up internal amplifier self.amp = gr.multiply_const_cc(0.0) diff --git a/gr-qtgui/grc/qtgui_sink_x.xml b/gr-qtgui/grc/qtgui_sink_x.xml index 7a5f5ec13..8c470a1a5 100644 --- a/gr-qtgui/grc/qtgui_sink_x.xml +++ b/gr-qtgui/grc/qtgui_sink_x.xml @@ -21,7 +21,6 @@ qtgui.$(type.fcn)( $name, \#name $plotfreq, \#plotfreq $plotwaterfall, \#plotwaterfall - $plotwaterfall3d, \#plotwaterfall3d $plottime, \#plottime $plotconst, \#plotconst ) @@ -89,15 +88,6 @@ $(gui_hint()($win)) - - Plot Waterfall 3D - plotwaterfall3d - True - bool - part - - - Plot Time plottime diff --git a/gr-qtgui/lib/.gitignore b/gr-qtgui/lib/.gitignore index 61b9ca8c1..fc4f8cdfe 100644 --- a/gr-qtgui/lib/.gitignore +++ b/gr-qtgui/lib/.gitignore @@ -5,7 +5,6 @@ /qtgui.cc /qtgui.py /WaterfallDisplayPlot.moc.cc -/Waterfall3DDisplayPlot.moc.cc /TimeDomainDisplayPlot.moc.cc /spectrumdisplayform.moc.cc /spectrumdisplayform.ui.h diff --git a/gr-qtgui/lib/qtgui_sink_c.cc b/gr-qtgui/lib/qtgui_sink_c.cc index bdd941fe1..4cbd47c55 100644 --- a/gr-qtgui/lib/qtgui_sink_c.cc +++ b/gr-qtgui/lib/qtgui_sink_c.cc @@ -35,16 +35,14 @@ qtgui_make_sink_c (int fftsize, int wintype, double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, + bool plottime, bool plotconst, bool use_openGL, QWidget *parent) { return gnuradio::get_initial_sptr(new qtgui_sink_c (fftsize, wintype, fc, bw, name, plotfreq, plotwaterfall, - plotwaterfall3d, plottime, - plotconst, + plottime, plotconst, use_openGL, parent)); } @@ -53,8 +51,7 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, + bool plottime, bool plotconst, bool use_openGL, QWidget *parent) : gr_block ("sink_c", @@ -67,10 +64,6 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, d_plottime(plottime), d_plotconst(plotconst), d_parent(parent) { - if(plotwaterfall3d == true) { - fprintf(stderr, "Warning: plotting Waterfall3D has been removed; enabling plotwaterfall3d has no effect.\n"); - } - d_main_gui = NULL; // Perform fftshift operation; diff --git a/gr-qtgui/lib/qtgui_sink_c.h b/gr-qtgui/lib/qtgui_sink_c.h index 59b5acfe5..22ca07f77 100644 --- a/gr-qtgui/lib/qtgui_sink_c.h +++ b/gr-qtgui/lib/qtgui_sink_c.h @@ -28,7 +28,6 @@ #include #include #include -//#include #include "SpectrumGUIClass.h" class qtgui_sink_c; @@ -38,8 +37,7 @@ qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, double fc=0, double bandwidth=1.0, const std::string &name="Spectrum Display", bool plotfreq=true, bool plotwaterfall=true, - bool plotwaterfall3d=true, bool plottime=true, - bool plotconst=true, + bool plottime=true, bool plotconst=true, bool use_openGL=true, QWidget *parent=NULL); @@ -50,16 +48,14 @@ private: double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, + bool plottime, bool plotconst, bool use_openGL, QWidget *parent); qtgui_sink_c (int fftsize, int wintype, double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, + bool plottime, bool plotconst, bool use_openGL, QWidget *parent); diff --git a/gr-qtgui/lib/qtgui_sink_f.cc b/gr-qtgui/lib/qtgui_sink_f.cc index e27ff3ac1..90d4d7a70 100644 --- a/gr-qtgui/lib/qtgui_sink_f.cc +++ b/gr-qtgui/lib/qtgui_sink_f.cc @@ -35,16 +35,14 @@ qtgui_make_sink_f (int fftsize, int wintype, double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, + bool plottime, bool plotconst, bool use_openGL, QWidget *parent) { return gnuradio::get_initial_sptr(new qtgui_sink_f (fftsize, wintype, fc, bw, name, plotfreq, plotwaterfall, - plotwaterfall3d, plottime, - plotconst, + plottime, plotconst, use_openGL, parent)); } @@ -53,8 +51,7 @@ qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype, double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, + bool plottime, bool plotconst, bool use_openGL, QWidget *parent) : gr_block ("sink_f", @@ -67,10 +64,6 @@ qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype, d_plottime(plottime), d_plotconst(plotconst), d_parent(parent) { - if(plotwaterfall3d == true) { - fprintf(stderr, "Warning: plotting Waterfall3D has been removed; enabling plotwaterfall3d has no effect.\n"); - } - d_main_gui = NULL; // Perform fftshift operation; diff --git a/gr-qtgui/lib/qtgui_sink_f.h b/gr-qtgui/lib/qtgui_sink_f.h index a798a41bb..8f27d120a 100644 --- a/gr-qtgui/lib/qtgui_sink_f.h +++ b/gr-qtgui/lib/qtgui_sink_f.h @@ -38,8 +38,7 @@ qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, double fc=0, double bw=1.0, const std::string &name="Spectrum Display", bool plotfreq=true, bool plotwaterfall=true, - bool plotwaterfall3d=true, bool plottime=true, - bool plotconst=true, + bool plottime=true, bool plotconst=true, bool use_openGL=true, QWidget *parent=NULL); @@ -50,16 +49,14 @@ private: double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, + bool plottime, bool plotconst, bool use_openGL, QWidget *parent); qtgui_sink_f (int fftsize, int wintype, double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, + bool plottime, bool plotconst, bool use_openGL, QWidget *parent); diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index d4fc03781..101bbc52b 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -3,8 +3,6 @@ #include #include -int SpectrumDisplayForm::_openGLWaterfall3DFlag = -1; - SpectrumDisplayForm::SpectrumDisplayForm(bool useOpenGL, QWidget* parent) : QWidget(parent) { diff --git a/gr-qtgui/lib/spectrumdisplayform.h b/gr-qtgui/lib/spectrumdisplayform.h index fbd08349b..e760ccc13 100644 --- a/gr-qtgui/lib/spectrumdisplayform.h +++ b/gr-qtgui/lib/spectrumdisplayform.h @@ -95,7 +95,6 @@ private: double _noiseFloorAmplitude; double _peakFrequency; double _peakAmplitude; - static int _openGLWaterfall3DFlag; double _stopFrequency; //SpectrumUpdateEvent _lastSpectrumEvent; @@ -103,7 +102,6 @@ private: // whether or not to use a particular display int d_plot_fft; int d_plot_waterfall; - int d_plot_waterfall3d; int d_plot_time; int d_plot_constellation; diff --git a/gr-qtgui/python/qa_qtgui.py b/gr-qtgui/python/qa_qtgui.py index 7d3cf8098..dd6529ce0 100755 --- a/gr-qtgui/python/qa_qtgui.py +++ b/gr-qtgui/python/qa_qtgui.py @@ -34,12 +34,12 @@ class test_qtgui(gr_unittest.TestCase): self.tb = None def test01 (self): - pass + #pass # Test to make sure we can instantiate these - #self.qapp = QtGui.QApplication(sys.argv) - #self.qtsnk = qtgui_swig.sink_c(1024, gr.firdes.WIN_BLACKMAN_hARRIS, - # 0, 1, "Test", - # True, True, False, True, True) + self.qapp = QtGui.QApplication(sys.argv) + self.qtsnk = qtgui_swig.sink_c(1024, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, 1, "Test", + True, True, True, True) if __name__ == '__main__': diff --git a/gr-qtgui/swig/qtgui_swig.i b/gr-qtgui/swig/qtgui_swig.i index ba97b4e9a..8069ed6c2 100644 --- a/gr-qtgui/swig/qtgui_swig.i +++ b/gr-qtgui/swig/qtgui_swig.i @@ -33,8 +33,7 @@ GR_SWIG_BLOCK_MAGIC(qtgui,sink_c) double fc=0, double bw=1.0, const std::string &name="Display", bool plotfreq=true, bool plotwaterfall=true, - bool plotwaterfall3d=true, bool plottime=true, - bool plotconst=true, + bool plottime=true, bool plotconst=true, bool use_openGL=true, QWidget *parent=NULL); @@ -45,16 +44,14 @@ private: double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, + bool plottime, bool plotconst, bool use_openGL, QWidget *parent); qtgui_sink_c (int fftsize, int wintype, double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, + bool plottime, bool plotconst, bool use_openGL, QWidget *parent); @@ -82,8 +79,7 @@ qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, double fc=0, double bw=0.0, const std::string &name="Display", bool plotfreq=true, bool plotwaterfall=true, - bool plotwaterfall3d=true, bool plottime=true, - bool plotconst=true, + bool plottime=true, bool plotconst=true, bool use_openGL=true, QWidget *parent=NULL); @@ -94,16 +90,14 @@ private: double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, + bool plottime, bool plotconst, bool use_openGL, QWidget *parent); qtgui_sink_f (int fftsize, int wintype, double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, - bool plotwaterfall3d, bool plottime, - bool plotconst, + bool plottime, bool plotconst, bool use_openGL, QWidget *parent); -- cgit From 997e8dd482eb88bcf34a0014aab7da5986548d8e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 6 Apr 2011 00:27:52 -0400 Subject: gr-qtgui: finishing off removing references to 3D plotting in UI file. --- gr-qtgui/lib/spectrumdisplayform.ui | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/gr-qtgui/lib/spectrumdisplayform.ui b/gr-qtgui/lib/spectrumdisplayform.ui index 5a23bc8a9..856f59153 100644 --- a/gr-qtgui/lib/spectrumdisplayform.ui +++ b/gr-qtgui/lib/spectrumdisplayform.ui @@ -704,22 +704,6 @@ - - Waterfall3DAutoScaleBtn - clicked() - SpectrumDisplayForm - Waterfall3DAutoScaleBtnCB() - - - 22 - 349 - - - 20 - 20 - - - WaterfallIntensityComboBox activated(int) @@ -736,22 +720,6 @@ - - Waterfall3DIntensityComboBox - activated(int) - SpectrumDisplayForm - Waterfall3DIntensityColorTypeChanged(int) - - - 92 - 44 - - - 20 - 20 - - - SpectrumTypeTab currentChanged(int) -- cgit From 42caa092c83be06df3c2f38a39285096bf8a4cfe Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 9 Apr 2011 23:16:02 -0400 Subject: gr-qtgui: removing Guile-specific stuff since there is no way QtGui will work with Guile yet. Changed Python QA to complete properly. --- config/grc_gr_qtgui.m4 | 4 +--- gr-qtgui/python/qa_qtgui.py | 12 +++++++----- gr-qtgui/swig/Makefile.am | 12 ------------ gr-qtgui/swig/gnuradio/qtgui.scm | 28 ---------------------------- gr-qtgui/swig/qtgui.test | 36 ------------------------------------ gr-qtgui/swig/run_guile_tests.in | 14 -------------- 6 files changed, 8 insertions(+), 98 deletions(-) delete mode 100644 gr-qtgui/swig/gnuradio/qtgui.scm delete mode 100644 gr-qtgui/swig/qtgui.test delete mode 100644 gr-qtgui/swig/run_guile_tests.in diff --git a/config/grc_gr_qtgui.m4 b/config/grc_gr_qtgui.m4 index a5eac6293..a4592fa41 100644 --- a/config/grc_gr_qtgui.m4 +++ b/config/grc_gr_qtgui.m4 @@ -88,13 +88,11 @@ AC_DEFUN([GRC_GR_QTGUI],[ gr-qtgui/python/Makefile \ gr-qtgui/python/run_tests \ gr-qtgui/swig/Makefile \ - gr-qtgui/swig/run_guile_tests \ ]) GRC_BUILD_CONDITIONAL(gr-qtgui,[ dnl run_tests is created from run_tests.in. Make it executable. AC_CONFIG_COMMANDS([run_tests_qtgui], - [chmod +x gr-qtgui/python/run_tests - chmod +x gr-qtgui/swig/run_guile_tests]) + [chmod +x gr-qtgui/python/run_tests]) ]) ]) diff --git a/gr-qtgui/python/qa_qtgui.py b/gr-qtgui/python/qa_qtgui.py index dd6529ce0..9cafd4550 100755 --- a/gr-qtgui/python/qa_qtgui.py +++ b/gr-qtgui/python/qa_qtgui.py @@ -22,8 +22,6 @@ from gnuradio import gr, gr_unittest import qtgui_swig -from PyQt4 import QtGui, QtCore -import sys, sip class test_qtgui(gr_unittest.TestCase): @@ -34,12 +32,16 @@ class test_qtgui(gr_unittest.TestCase): self.tb = None def test01 (self): - #pass - # Test to make sure we can instantiate these - self.qapp = QtGui.QApplication(sys.argv) + # Test to make sure we can instantiate the sink self.qtsnk = qtgui_swig.sink_c(1024, gr.firdes.WIN_BLACKMAN_hARRIS, 0, 1, "Test", True, True, True, True) + + def test02 (self): + # Test to make sure we can instantiate the sink + self.qtsnk = qtgui_swig.sink_f(1024, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, 1, "Test", + True, True, True, True) if __name__ == '__main__': diff --git a/gr-qtgui/swig/Makefile.am b/gr-qtgui/swig/Makefile.am index ab1acce71..460868701 100644 --- a/gr-qtgui/swig/Makefile.am +++ b/gr-qtgui/swig/Makefile.am @@ -33,14 +33,6 @@ AM_CPPFLAGS = \ $(QT_INCLUDES) \ $(WITH_INCLUDES) -if GUILE -nobase_guile_DATA = \ - gnuradio/qtgui.scm -endif - -noinst_GUILE = qtgui.test - - ############################## # SWIG interface and library TOP_SWIG_IFILES = \ @@ -59,7 +51,3 @@ qtgui_swig_la_swig_libadd = \ # additional SWIG files to be installed qtgui_swig_swiginclude_headers = - -if GUILE -TESTS += run_guile_tests -endif \ No newline at end of file diff --git a/gr-qtgui/swig/gnuradio/qtgui.scm b/gr-qtgui/swig/gnuradio/qtgui.scm deleted file mode 100644 index fc650d022..000000000 --- a/gr-qtgui/swig/gnuradio/qtgui.scm +++ /dev/null @@ -1,28 +0,0 @@ -;;; -;;; 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 this program. If not, see . -;;; - -;;; Module that just re-exports the qtgui_swig module - -(define-module (gnuradio qtgui) - #:use-module (gnuradio export-safely) - #:use-module (gnuradio qtgui_swig) - #:duplicates (merge-generics replace check)) - -(re-export-all '(gnuradio qtgui_swig)) - diff --git a/gr-qtgui/swig/qtgui.test b/gr-qtgui/swig/qtgui.test deleted file mode 100644 index 956a97df9..000000000 --- a/gr-qtgui/swig/qtgui.test +++ /dev/null @@ -1,36 +0,0 @@ -;;; -*- Scheme -*- -;;; -;;; 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 this program. If not, see . -;;; - -;;; If you're using Emacs's Scheme mode: -;;; (put 'with-test-prefix 'scheme-indent-function 1) - -;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. -;;; See also the very end of the file, where the test-equal, test-eqv -;;; and test-eq macros are defined. - -(define-module (test-module) - #:use-module (oop goops) - #:use-module (gnuradio core) - #:use-module (gnuradio test-suite lib) - #:duplicates (merge-generics replace check)) - -;;; Confirm we can import the module... -(use-modules (gnuradio qtgui)) - diff --git a/gr-qtgui/swig/run_guile_tests.in b/gr-qtgui/swig/run_guile_tests.in deleted file mode 100644 index 5d08b0dd5..000000000 --- a/gr-qtgui/swig/run_guile_tests.in +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -. @top_builddir@/setup_guile_test_env - -# 1st argument is absolute path to hand coded guile source directory -# 2nd argument is absolute path to component C++ shared library build directory -# 3nd argument is absolute path to component SWIG build directory - -add_local_paths \ - @srcdir@ \ - @abs_builddir@ \ - @abs_builddir@ - -@GUILE@ -e main -c '(use-modules (gnuradio test-suite guile-test))' -t @srcdir@ -- cgit From 4ffbb545436f60acd80e1b28714e76bf502b0a2e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 10 Apr 2011 16:33:21 -0400 Subject: gr-qtgui: updating example apps so the wrapped instance of the qtgui is not a class member; this ensures proper cleanup on exit. --- gr-qtgui/apps/pyqt_example_c.py | 4 ++-- gr-qtgui/apps/pyqt_example_f.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gr-qtgui/apps/pyqt_example_c.py b/gr-qtgui/apps/pyqt_example_c.py index 90eec3694..e1b58442f 100755 --- a/gr-qtgui/apps/pyqt_example_c.py +++ b/gr-qtgui/apps/pyqt_example_c.py @@ -136,9 +136,9 @@ class my_top_block(gr.top_block): # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - self.main_box = dialog_box(self.pyWin, self.ctrl_win) + self.main_box = dialog_box(pyWin, self.ctrl_win) self.main_box.show() diff --git a/gr-qtgui/apps/pyqt_example_f.py b/gr-qtgui/apps/pyqt_example_f.py index 29905b8d9..6b2131019 100755 --- a/gr-qtgui/apps/pyqt_example_f.py +++ b/gr-qtgui/apps/pyqt_example_f.py @@ -135,9 +135,9 @@ class my_top_block(gr.top_block): # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - self.main_box = dialog_box(self.pyWin, self.ctrl_win) + self.main_box = dialog_box(pyWin, self.ctrl_win) self.main_box.show() -- cgit From 6a4bef7a8076864ab574fef6b3fd4e93824988cc Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 10 Apr 2011 16:50:02 -0400 Subject: gr-qtgui: adding a GRC example for QtGui graphs. --- gr-qtgui/apps/grc_qt_example.grc | 441 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 441 insertions(+) create mode 100644 gr-qtgui/apps/grc_qt_example.grc diff --git a/gr-qtgui/apps/grc_qt_example.grc b/gr-qtgui/apps/grc_qt_example.grc new file mode 100644 index 000000000..170cd546a --- /dev/null +++ b/gr-qtgui/apps/grc_qt_example.grc @@ -0,0 +1,441 @@ + + + Sun Apr 10 16:49:13 2011 + + options + + id + grc_qt_example + + + _enabled + True + + + title + + + + author + + + + description + + + + window_size + 1280, 1024 + + + generate_options + qt_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + samp_rate + + + _enabled + True + + + value + 32000 + + + _coordinate + (10, 170) + + + _rotation + 0 + + + + gr_throttle + + id + gr_throttle_0 + + + _enabled + True + + + type + complex + + + samples_per_second + samp_rate + + + vlen + 1 + + + _coordinate + (511, 96) + + + _rotation + 0 + + + + variable_qtgui_range + + id + freq + + + _enabled + True + + + label + Signal Frequency + + + value + 1000 + + + start + 0 + + + stop + samp_rate/2.0 + + + step + samp_rate/100.0 + + + widget + counter_slider + + + orient + Qt.Horizontal + + + min_len + 200 + + + gui_hint + + + + _coordinate + (169, 187) + + + _rotation + 0 + + + + gr_sig_source_x + + id + gr_sig_source_x_0 + + + _enabled + True + + + type + complex + + + samp_rate + samp_rate + + + waveform + gr.GR_COS_WAVE + + + freq + freq + + + amp + amp + + + offset + 0 + + + _coordinate + (295, 64) + + + _rotation + 0 + + + + variable_qtgui_range + + id + amp + + + _enabled + True + + + label + Signal Amplitude + + + value + 1 + + + start + 0 + + + stop + 1.0 + + + step + 0.01 + + + widget + counter_slider + + + orient + Qt.Horizontal + + + min_len + 200 + + + gui_hint + + + + _coordinate + (311, 187) + + + _rotation + 0 + + + + variable_qtgui_range + + id + noise + + + _enabled + True + + + label + Noise Amplitude + + + value + 0.01 + + + start + 0 + + + stop + 1.0 + + + step + 0.01 + + + widget + counter_slider + + + orient + Qt.Horizontal + + + min_len + 200 + + + gui_hint + + + + _coordinate + (723, 191) + + + _rotation + 0 + + + + gr_channel_model + + id + gr_channel_model_0 + + + _enabled + True + + + noise_voltage + noise + + + freq_offset + 0.0 + + + epsilon + 1.0 + + + taps + 1.0 + 0.0j + + + seed + 42 + + + _coordinate + (727, 64) + + + _rotation + 0 + + + + qtgui_sink_x + + id + qtgui_sink_x_0 + + + _enabled + True + + + type + complex + + + name + QT GUI Plot + + + fftsize + 1024 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + + fc + 0 + + + bw + samp_rate + + + plotfreq + True + + + plotwaterfall + True + + + plottime + True + + + plotconst + False + + + gui_hint + + + + _coordinate + (958, 72) + + + _rotation + 0 + + + + gr_sig_source_x_0 + gr_throttle_0 + 0 + 0 + + + gr_throttle_0 + gr_channel_model_0 + 0 + 0 + + + gr_channel_model_0 + qtgui_sink_x_0 + 0 + 0 + + -- cgit From c4050c5bdb55ce14565d0ade84bd518cc8c27ec5 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 10 Apr 2011 17:13:15 -0400 Subject: gr-qtgui: removed OpenGL calls; we still link against the QTOPENGL_LIBS because of some dependencies in Qwt. --- gr-qtgui/lib/Makefile.am | 3 ++- gr-qtgui/lib/SpectrumGUIClass.cc | 5 ++--- gr-qtgui/lib/SpectrumGUIClass.h | 3 +-- gr-qtgui/lib/qtgui_sink_c.cc | 10 +++------- gr-qtgui/lib/qtgui_sink_c.h | 7 +------ gr-qtgui/lib/qtgui_sink_f.cc | 10 +++------- gr-qtgui/lib/qtgui_sink_f.h | 5 +---- gr-qtgui/lib/spectrumdisplayform.cc | 3 +-- gr-qtgui/lib/spectrumdisplayform.h | 3 +-- gr-qtgui/swig/qtgui_swig.i | 6 ------ 10 files changed, 15 insertions(+), 40 deletions(-) diff --git a/gr-qtgui/lib/Makefile.am b/gr-qtgui/lib/Makefile.am index 7c21bfc14..f9b5dd03e 100644 --- a/gr-qtgui/lib/Makefile.am +++ b/gr-qtgui/lib/Makefile.am @@ -72,7 +72,8 @@ grinclude_HEADERS = \ qtgui_sink_c.h \ qtgui_sink_f.h -QT_MOC_FLAGS=-DQT_SHARED -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB +#QT_MOC_FLAGS=-DQT_SHARED -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB +QT_MOC_FLAGS=-DQT_SHARED -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB %.moc.cc : %.h $(QT_MOC_EXEC) $(QT_MOC_FLAGS) -p $(srcdir) $< -o $@ diff --git a/gr-qtgui/lib/SpectrumGUIClass.cc b/gr-qtgui/lib/SpectrumGUIClass.cc index 3342c0cb3..1a519591d 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.cc +++ b/gr-qtgui/lib/SpectrumGUIClass.cc @@ -59,8 +59,7 @@ SpectrumGUIClass::~SpectrumGUIClass() void SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, const bool frequency, const bool waterfall, - const bool time, const bool constellation, - const bool use_openGL) + const bool time, const bool constellation) { d_mutex.lock(); @@ -79,7 +78,7 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, } // Called from the Event Thread - _spectrumDisplayForm = new SpectrumDisplayForm(use_openGL, parent); + _spectrumDisplayForm = new SpectrumDisplayForm(parent); // Toggle Windows on/off _spectrumDisplayForm->ToggleTabFrequency(frequency); diff --git a/gr-qtgui/lib/SpectrumGUIClass.h b/gr-qtgui/lib/SpectrumGUIClass.h index 8ffb411b8..48f45a0f5 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.h +++ b/gr-qtgui/lib/SpectrumGUIClass.h @@ -29,8 +29,7 @@ public: void OpenSpectrumWindow(QWidget*, const bool frequency=true, const bool waterfall=true, - const bool time=true, const bool constellation=true, - const bool use_openGL=true); + const bool time=true, const bool constellation=true); void SetDisplayTitle(const std::string); bool GetWindowOpenFlag(); diff --git a/gr-qtgui/lib/qtgui_sink_c.cc b/gr-qtgui/lib/qtgui_sink_c.cc index 4cbd47c55..2cfa67d75 100644 --- a/gr-qtgui/lib/qtgui_sink_c.cc +++ b/gr-qtgui/lib/qtgui_sink_c.cc @@ -36,14 +36,12 @@ qtgui_make_sink_c (int fftsize, int wintype, const std::string &name, bool plotfreq, bool plotwaterfall, bool plottime, bool plotconst, - bool use_openGL, QWidget *parent) { return gnuradio::get_initial_sptr(new qtgui_sink_c (fftsize, wintype, fc, bw, name, plotfreq, plotwaterfall, plottime, plotconst, - use_openGL, parent)); } @@ -52,7 +50,6 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, const std::string &name, bool plotfreq, bool plotwaterfall, bool plottime, bool plotconst, - bool use_openGL, QWidget *parent) : gr_block ("sink_c", gr_make_io_signature (1, -1, sizeof(gr_complex)), @@ -77,7 +74,7 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, buildwindow(); - initialize(use_openGL); + initialize(); } qtgui_sink_c::~qtgui_sink_c() @@ -97,7 +94,7 @@ qtgui_sink_c::forecast(int noutput_items, gr_vector_int &ninput_items_required) } void -qtgui_sink_c::initialize(const bool opengl) +qtgui_sink_c::initialize() { if(qApp != NULL) { d_qApplication = qApp; @@ -124,8 +121,7 @@ qtgui_sink_c::initialize(const bool opengl) d_main_gui->OpenSpectrumWindow(d_parent, d_plotfreq, d_plotwaterfall, - d_plottime, d_plotconst, - opengl); + d_plottime, d_plotconst); // initialize update time to 10 times a second set_update_time(0.1); diff --git a/gr-qtgui/lib/qtgui_sink_c.h b/gr-qtgui/lib/qtgui_sink_c.h index 22ca07f77..1c9561704 100644 --- a/gr-qtgui/lib/qtgui_sink_c.h +++ b/gr-qtgui/lib/qtgui_sink_c.h @@ -38,7 +38,6 @@ qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, const std::string &name="Spectrum Display", bool plotfreq=true, bool plotwaterfall=true, bool plottime=true, bool plotconst=true, - bool use_openGL=true, QWidget *parent=NULL); class qtgui_sink_c : public gr_block @@ -49,21 +48,17 @@ private: const std::string &name, bool plotfreq, bool plotwaterfall, bool plottime, bool plotconst, - bool use_openGL, QWidget *parent); qtgui_sink_c (int fftsize, int wintype, double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, bool plottime, bool plotconst, - bool use_openGL, QWidget *parent); void forecast(int noutput_items, gr_vector_int &ninput_items_required); - // use opengl to force OpenGL on or off - // this might be necessary for sessions over SSH - void initialize(const bool opengl=true); + void initialize(); int d_fftsize; gr_firdes::win_type d_wintype; diff --git a/gr-qtgui/lib/qtgui_sink_f.cc b/gr-qtgui/lib/qtgui_sink_f.cc index 90d4d7a70..3312b9006 100644 --- a/gr-qtgui/lib/qtgui_sink_f.cc +++ b/gr-qtgui/lib/qtgui_sink_f.cc @@ -36,14 +36,12 @@ qtgui_make_sink_f (int fftsize, int wintype, const std::string &name, bool plotfreq, bool plotwaterfall, bool plottime, bool plotconst, - bool use_openGL, QWidget *parent) { return gnuradio::get_initial_sptr(new qtgui_sink_f (fftsize, wintype, fc, bw, name, plotfreq, plotwaterfall, plottime, plotconst, - use_openGL, parent)); } @@ -52,7 +50,6 @@ qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype, const std::string &name, bool plotfreq, bool plotwaterfall, bool plottime, bool plotconst, - bool use_openGL, QWidget *parent) : gr_block ("sink_f", gr_make_io_signature (1, 1, sizeof(float)), @@ -77,7 +74,7 @@ qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype, buildwindow(); - initialize(use_openGL); + initialize(); } qtgui_sink_f::~qtgui_sink_f() @@ -97,7 +94,7 @@ qtgui_sink_f::forecast(int noutput_items, gr_vector_int &ninput_items_required) } void -qtgui_sink_f::initialize(const bool opengl) +qtgui_sink_f::initialize() { if(qApp != NULL) { d_qApplication = qApp; @@ -120,8 +117,7 @@ qtgui_sink_f::initialize(const bool opengl) d_main_gui->OpenSpectrumWindow(d_parent, d_plotfreq, d_plotwaterfall, - d_plottime, d_plotconst, - opengl); + d_plottime, d_plotconst); // initialize update time to 10 times a second set_update_time(0.1); diff --git a/gr-qtgui/lib/qtgui_sink_f.h b/gr-qtgui/lib/qtgui_sink_f.h index 8f27d120a..518aa3846 100644 --- a/gr-qtgui/lib/qtgui_sink_f.h +++ b/gr-qtgui/lib/qtgui_sink_f.h @@ -39,7 +39,6 @@ qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, const std::string &name="Spectrum Display", bool plotfreq=true, bool plotwaterfall=true, bool plottime=true, bool plotconst=true, - bool use_openGL=true, QWidget *parent=NULL); class qtgui_sink_f : public gr_block @@ -50,19 +49,17 @@ private: const std::string &name, bool plotfreq, bool plotwaterfall, bool plottime, bool plotconst, - bool use_openGL, QWidget *parent); qtgui_sink_f (int fftsize, int wintype, double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, bool plottime, bool plotconst, - bool use_openGL, QWidget *parent); void forecast(int noutput_items, gr_vector_int &ninput_items_required); - void initialize(const bool opengl=true); + void initialize(); int d_fftsize; gr_firdes::win_type d_wintype; diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index 101bbc52b..804dbdd62 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -3,12 +3,11 @@ #include #include -SpectrumDisplayForm::SpectrumDisplayForm(bool useOpenGL, QWidget* parent) +SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) : QWidget(parent) { setupUi(this); - _useOpenGL = useOpenGL; _systemSpecifiedFlag = false; _intValidator = new QIntValidator(this); _intValidator->setBottom(0); diff --git a/gr-qtgui/lib/spectrumdisplayform.h b/gr-qtgui/lib/spectrumdisplayform.h index e760ccc13..794a8c58e 100644 --- a/gr-qtgui/lib/spectrumdisplayform.h +++ b/gr-qtgui/lib/spectrumdisplayform.h @@ -20,7 +20,7 @@ class SpectrumDisplayForm : public QWidget, public Ui::SpectrumDisplayForm Q_OBJECT public: - SpectrumDisplayForm(bool useOpenGL = true, QWidget* parent = 0); + SpectrumDisplayForm(QWidget* parent = 0); ~SpectrumDisplayForm(); void setSystem( SpectrumGUIClass * newSystem, const uint64_t numFFTDataPoints, @@ -76,7 +76,6 @@ protected: private: void _AverageHistory( const double * newBuffer ); - bool _useOpenGL; int _historyEntryCount; int _historyEntry; std::vector* _historyVector; diff --git a/gr-qtgui/swig/qtgui_swig.i b/gr-qtgui/swig/qtgui_swig.i index 8069ed6c2..734709f09 100644 --- a/gr-qtgui/swig/qtgui_swig.i +++ b/gr-qtgui/swig/qtgui_swig.i @@ -34,7 +34,6 @@ GR_SWIG_BLOCK_MAGIC(qtgui,sink_c) const std::string &name="Display", bool plotfreq=true, bool plotwaterfall=true, bool plottime=true, bool plotconst=true, - bool use_openGL=true, QWidget *parent=NULL); class qtgui_sink_c : public gr_block @@ -45,14 +44,12 @@ private: const std::string &name, bool plotfreq, bool plotwaterfall, bool plottime, bool plotconst, - bool use_openGL, QWidget *parent); qtgui_sink_c (int fftsize, int wintype, double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, bool plottime, bool plotconst, - bool use_openGL, QWidget *parent); public: @@ -80,7 +77,6 @@ qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, const std::string &name="Display", bool plotfreq=true, bool plotwaterfall=true, bool plottime=true, bool plotconst=true, - bool use_openGL=true, QWidget *parent=NULL); class qtgui_sink_f : public gr_block @@ -91,14 +87,12 @@ private: const std::string &name, bool plotfreq, bool plotwaterfall, bool plottime, bool plotconst, - bool use_openGL, QWidget *parent); qtgui_sink_f (int fftsize, int wintype, double fc, double bw, const std::string &name, bool plotfreq, bool plotwaterfall, bool plottime, bool plotconst, - bool use_openGL, QWidget *parent); public: -- cgit From 16ec5a3bf5a22cc72423d975666878eeadd2cf3c Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 10 Apr 2011 17:21:38 -0400 Subject: gr-qtgui: exposing set_update_time to Python. --- gr-qtgui/lib/qtgui_sink_c.cc | 8 ++++---- gr-qtgui/swig/qtgui_swig.i | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gr-qtgui/lib/qtgui_sink_c.cc b/gr-qtgui/lib/qtgui_sink_c.cc index 2cfa67d75..7b40dd01d 100644 --- a/gr-qtgui/lib/qtgui_sink_c.cc +++ b/gr-qtgui/lib/qtgui_sink_c.cc @@ -39,10 +39,10 @@ qtgui_make_sink_c (int fftsize, int wintype, QWidget *parent) { return gnuradio::get_initial_sptr(new qtgui_sink_c (fftsize, wintype, - fc, bw, name, - plotfreq, plotwaterfall, - plottime, plotconst, - parent)); + fc, bw, name, + plotfreq, plotwaterfall, + plottime, plotconst, + parent)); } qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, diff --git a/gr-qtgui/swig/qtgui_swig.i b/gr-qtgui/swig/qtgui_swig.i index 734709f09..c471bb09c 100644 --- a/gr-qtgui/swig/qtgui_swig.i +++ b/gr-qtgui/swig/qtgui_swig.i @@ -63,6 +63,7 @@ public: double ymin, double ymax); void set_frequency_axis(double min, double max); void set_constellation_pen_size(int size); + void set_update_time(double t); }; @@ -106,6 +107,7 @@ public: double ymin, double ymax); void set_frequency_axis(double min, double max); void set_constellation_pen_size(int size); + void set_update_time(double t); }; #if SWIGGUILE -- cgit From 65dd7abbe7310d6e064712ac2507312c50304345 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 10 Apr 2011 17:53:08 -0400 Subject: gr-qtgui: fixes problem with initial axes not showing up properly. --- gr-qtgui/lib/spectrumdisplayform.ui | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gr-qtgui/lib/spectrumdisplayform.ui b/gr-qtgui/lib/spectrumdisplayform.ui index 856f59153..049d4ffeb 100644 --- a/gr-qtgui/lib/spectrumdisplayform.ui +++ b/gr-qtgui/lib/spectrumdisplayform.ui @@ -7,7 +7,7 @@ 0 0 712 - 543 + 560 @@ -182,8 +182,8 @@ - 400 - 350 + 617 + 400 -- cgit From 11e91cdd442f9232382986f9d974b230554fabe2 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 10 Apr 2011 17:54:07 -0400 Subject: gr-qtgui: ignore GRC-built py file of grc_qt_example.grc. --- gr-qtgui/apps/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/gr-qtgui/apps/.gitignore b/gr-qtgui/apps/.gitignore index 282522db0..943275d5c 100644 --- a/gr-qtgui/apps/.gitignore +++ b/gr-qtgui/apps/.gitignore @@ -1,2 +1,3 @@ Makefile Makefile.in +grc_qt_example.py -- cgit