GNU Radio 3.7.0 C++ API
WaterfallDisplayPlot.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2008-2012 Free Software Foundation, Inc.
00004  *
00005  * This file is part of GNU Radio
00006  *
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  *
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef WATERFALL_DISPLAY_PLOT_H
00024 #define WATERFALL_DISPLAY_PLOT_H
00025 
00026 #include <stdint.h>
00027 #include <cstdio>
00028 #include <vector>
00029 #include <qwt_plot_spectrogram.h>
00030 #include <gnuradio/qtgui/DisplayPlot.h>
00031 #include <gnuradio/qtgui/waterfallGlobalData.h>
00032 #include <gnuradio/high_res_timer.h>
00033 
00034 #if QWT_VERSION < 0x060000
00035 #include <gnuradio/qtgui/plot_waterfall.h>
00036 #else
00037 #include <qwt_compat.h>
00038 #endif
00039 
00040 /*!
00041  * \brief QWidget for displaying waterfall (spectrogram) plots.
00042  * \ingroup qtgui_blk
00043  */
00044 class WaterfallDisplayPlot: public DisplayPlot
00045 {
00046   Q_OBJECT
00047 
00048   Q_PROPERTY ( int intensity_color_map_type1 READ getIntensityColorMapType1 WRITE setIntensityColorMapType1 )
00049   Q_PROPERTY ( QColor low_intensity_color READ getUserDefinedLowIntensityColor WRITE setUserDefinedLowIntensityColor )
00050   Q_PROPERTY ( QColor high_intensity_color READ getUserDefinedHighIntensityColor WRITE setUserDefinedHighIntensityColor )
00051   
00052 
00053 public:
00054   WaterfallDisplayPlot(int nplots, QWidget*);
00055   virtual ~WaterfallDisplayPlot();
00056 
00057   void resetAxis();
00058 
00059   void setFrequencyRange(const double, const double,
00060                          const double units=1000.0,
00061                          const std::string &strunits = "kHz");
00062   double getStartFrequency() const;
00063   double getStopFrequency() const;
00064 
00065   void plotNewData(const std::vector<double*> dataPoints,
00066                    const int64_t numDataPoints,
00067                    const double timePerFFT,
00068                    const gr::high_res_timer_type timestamp,
00069                    const int droppedFrames);
00070 
00071   // to be removed
00072   void plotNewData(const double* dataPoints,
00073                    const int64_t numDataPoints,
00074                    const double timePerFFT,
00075                    const gr::high_res_timer_type timestamp,
00076                    const int droppedFrames);
00077 
00078   void setIntensityRange(const double minIntensity, const double maxIntensity);
00079   double getMinIntensity(int which) const;
00080   double getMaxIntensity(int which) const;
00081 
00082   void replot(void);
00083   void clearData();
00084 
00085   int getIntensityColorMapType(int) const;
00086   int getIntensityColorMapType1() const;
00087   const QColor getUserDefinedLowIntensityColor() const;
00088   const QColor getUserDefinedHighIntensityColor() const;
00089 
00090   int  getAlpha(int which);
00091   void setAlpha(int which, int alpha);
00092 
00093 public slots:
00094   void setIntensityColorMapType(const int, const int, const QColor, const QColor);
00095   void setIntensityColorMapType1(int);
00096   void setUserDefinedLowIntensityColor(QColor);
00097   void setUserDefinedHighIntensityColor(QColor);
00098 
00099 signals:
00100   void updatedLowerIntensityLevel(const double);
00101   void updatedUpperIntensityLevel(const double);
00102 
00103 private:
00104   void _updateIntensityRangeDisplay();
00105 
00106   double _startFrequency;
00107   double _stopFrequency;
00108   int    _xAxisMultiplier;
00109 
00110   std::vector<WaterfallData*> d_data;
00111 
00112 #if QWT_VERSION < 0x060000
00113   std::vector<PlotWaterfall*> d_spectrogram;
00114 #else
00115   std::vector<QwtPlotSpectrogram*> d_spectrogram;
00116 #endif
00117 
00118   gr::high_res_timer_type _lastReplot;
00119 
00120   std::vector<int> _intensityColorMapType;
00121   QColor _userDefinedLowIntensityColor;
00122   QColor _userDefinedHighIntensityColor;
00123 };
00124 
00125 #endif /* WATERFALL_DISPLAY_PLOT_H */