GNU Radio 3.7.1 C++ API
qtgui_types.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 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 QTGUI_TYPES_H
00024 #define QTGUI_TYPES_H
00025 
00026 #include <qwt_color_map.h>
00027 #include <qwt_scale_draw.h>
00028 #include <gnuradio/high_res_timer.h>
00029 
00030 class FreqOffsetAndPrecisionClass
00031 {
00032 public:
00033   FreqOffsetAndPrecisionClass(const int freqPrecision)
00034   {
00035     _frequencyPrecision = freqPrecision;
00036     _centerFrequency = 0;
00037   }
00038 
00039   virtual ~FreqOffsetAndPrecisionClass()
00040   {
00041   }
00042 
00043   virtual unsigned int getFrequencyPrecision() const
00044   {
00045     return _frequencyPrecision;
00046   }
00047 
00048   virtual void setFrequencyPrecision(const unsigned int newPrecision)
00049   {
00050     _frequencyPrecision = newPrecision;
00051   }
00052 
00053   virtual double getCenterFrequency() const
00054   {
00055     return _centerFrequency;
00056   }
00057 
00058   virtual void setCenterFrequency(const double newFreq)
00059   {
00060     _centerFrequency = newFreq;
00061   }
00062 
00063 protected:
00064 
00065 private:
00066   unsigned int _frequencyPrecision;
00067   double _centerFrequency;
00068 };
00069 
00070 class TimeScaleData
00071 {
00072 public:
00073   TimeScaleData()
00074   {
00075     _zeroTime = 0;
00076     _secondsPerLine = 1.0;
00077   }
00078   
00079   virtual ~TimeScaleData()
00080   {    
00081   }
00082 
00083   virtual gr::high_res_timer_type getZeroTime() const
00084   {
00085     return _zeroTime;
00086   }
00087   
00088   virtual void setZeroTime(const gr::high_res_timer_type newTime)
00089   {
00090     _zeroTime = newTime - gr::high_res_timer_epoch();
00091   }
00092 
00093   virtual void setSecondsPerLine(const double newTime)
00094   {
00095     _secondsPerLine = newTime;
00096   }
00097 
00098   virtual double getSecondsPerLine() const
00099   {
00100     return _secondsPerLine;
00101   }
00102 
00103   
00104 protected:
00105   
00106 private:
00107   gr::high_res_timer_type _zeroTime;
00108   double _secondsPerLine;
00109   
00110 };
00111 
00112 /***********************************************************************
00113  * Text scale widget to provide X (freq) axis text
00114  **********************************************************************/
00115 class FreqDisplayScaleDraw: public QwtScaleDraw, FreqOffsetAndPrecisionClass
00116 {
00117 public:
00118   FreqDisplayScaleDraw(const unsigned int precision)
00119     : QwtScaleDraw(), FreqOffsetAndPrecisionClass(precision)
00120   {
00121   }
00122 
00123   virtual QwtText label(double value) const
00124   {
00125     return QString("%1").arg(value, 0, 'f', getFrequencyPrecision());
00126   }
00127 
00128   virtual void initiateUpdate(void)
00129   {
00130       invalidateCache();
00131   }
00132 
00133 protected:
00134 
00135 private:
00136 
00137 };
00138 
00139 enum{
00140   INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR = 0,
00141   INTENSITY_COLOR_MAP_TYPE_WHITE_HOT = 1,
00142   INTENSITY_COLOR_MAP_TYPE_BLACK_HOT = 2,
00143   INTENSITY_COLOR_MAP_TYPE_INCANDESCENT = 3,
00144   INTENSITY_COLOR_MAP_TYPE_USER_DEFINED = 4
00145 };
00146 
00147 class ColorMap_MultiColor: public QwtLinearColorMap
00148 {
00149 public:
00150   ColorMap_MultiColor():
00151     QwtLinearColorMap(Qt::darkCyan, Qt::white)
00152   {
00153     addColorStop(0.25, Qt::cyan);
00154     addColorStop(0.5, Qt::yellow);
00155     addColorStop(0.75, Qt::red);
00156   }
00157 };
00158 
00159 class ColorMap_WhiteHot: public QwtLinearColorMap
00160 {
00161 public:
00162   ColorMap_WhiteHot():
00163     QwtLinearColorMap(Qt::black, Qt::white)
00164   {
00165   }
00166 };
00167 
00168 class ColorMap_BlackHot: public QwtLinearColorMap
00169 {
00170 public:
00171   ColorMap_BlackHot():
00172     QwtLinearColorMap(Qt::white, Qt::black)
00173   {
00174   }
00175 };
00176 
00177 class ColorMap_Incandescent: public QwtLinearColorMap
00178 {
00179 public:
00180   ColorMap_Incandescent():
00181     QwtLinearColorMap(Qt::black, Qt::white)
00182   {
00183     addColorStop(0.5, Qt::darkRed);
00184   }
00185 };
00186 
00187 class ColorMap_UserDefined: public QwtLinearColorMap
00188 {
00189 public:
00190   ColorMap_UserDefined(QColor low, QColor high):
00191     QwtLinearColorMap(low, high)
00192   {
00193   }
00194 };
00195 
00196 #endif //QTGUI_TYPES_H