GNU Radio 3.7.2 C++ API
qtgui_types.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef QTGUI_TYPES_H
24 #define QTGUI_TYPES_H
25 
26 #include <qwt_color_map.h>
27 #include <qwt_scale_draw.h>
29 
31 {
32 public:
33  FreqOffsetAndPrecisionClass(const int freqPrecision)
34  {
35  _frequencyPrecision = freqPrecision;
36  _centerFrequency = 0;
37  }
38 
40  {
41  }
42 
43  virtual unsigned int getFrequencyPrecision() const
44  {
45  return _frequencyPrecision;
46  }
47 
48  virtual void setFrequencyPrecision(const unsigned int newPrecision)
49  {
50  _frequencyPrecision = newPrecision;
51  }
52 
53  virtual double getCenterFrequency() const
54  {
55  return _centerFrequency;
56  }
57 
58  virtual void setCenterFrequency(const double newFreq)
59  {
60  _centerFrequency = newFreq;
61  }
62 
63 protected:
64 
65 private:
66  unsigned int _frequencyPrecision;
67  double _centerFrequency;
68 };
69 
71 {
72 public:
74  {
75  _zeroTime = 0;
76  _secondsPerLine = 1.0;
77  }
78 
79  virtual ~TimeScaleData()
80  {
81  }
82 
84  {
85  return _zeroTime;
86  }
87 
88  virtual void setZeroTime(const gr::high_res_timer_type newTime)
89  {
90  _zeroTime = newTime - gr::high_res_timer_epoch();
91  }
92 
93  virtual void setSecondsPerLine(const double newTime)
94  {
95  _secondsPerLine = newTime;
96  }
97 
98  virtual double getSecondsPerLine() const
99  {
100  return _secondsPerLine;
101  }
102 
103 
104 protected:
105 
106 private:
107  gr::high_res_timer_type _zeroTime;
108  double _secondsPerLine;
109 
110 };
111 
112 /***********************************************************************
113  * Text scale widget to provide X (freq) axis text
114  **********************************************************************/
116 {
117 public:
118  FreqDisplayScaleDraw(const unsigned int precision)
119  : QwtScaleDraw(), FreqOffsetAndPrecisionClass(precision)
120  {
121  }
122 
123  virtual QwtText label(double value) const
124  {
125  return QString("%1").arg(value, 0, 'f', getFrequencyPrecision());
126  }
127 
128  virtual void initiateUpdate(void)
129  {
130  invalidateCache();
131  }
132 
133 protected:
134 
135 private:
136 
137 };
138 
139 enum{
145 };
146 
147 class ColorMap_MultiColor: public QwtLinearColorMap
148 {
149 public:
151  QwtLinearColorMap(Qt::darkCyan, Qt::white)
152  {
153  addColorStop(0.25, Qt::cyan);
154  addColorStop(0.5, Qt::yellow);
155  addColorStop(0.75, Qt::red);
156  }
157 };
158 
159 class ColorMap_WhiteHot: public QwtLinearColorMap
160 {
161 public:
163  QwtLinearColorMap(Qt::black, Qt::white)
164  {
165  }
166 };
167 
168 class ColorMap_BlackHot: public QwtLinearColorMap
169 {
170 public:
172  QwtLinearColorMap(Qt::white, Qt::black)
173  {
174  }
175 };
176 
177 class ColorMap_Incandescent: public QwtLinearColorMap
178 {
179 public:
181  QwtLinearColorMap(Qt::black, Qt::white)
182  {
183  addColorStop(0.5, Qt::darkRed);
184  }
185 };
186 
187 class ColorMap_UserDefined: public QwtLinearColorMap
188 {
189 public:
190  ColorMap_UserDefined(QColor low, QColor high):
191  QwtLinearColorMap(low, high)
192  {
193  }
194 };
195 
196 #endif //QTGUI_TYPES_H
TimeScaleData()
Definition: qtgui_types.h:73
virtual gr::high_res_timer_type getZeroTime() const
Definition: qtgui_types.h:83
ColorMap_Incandescent()
Definition: qtgui_types.h:180
virtual double getCenterFrequency() const
Definition: qtgui_types.h:53
high_res_timer_type high_res_timer_epoch(void)
Get the tick count at the epoch.
Definition: high_res_timer.h:150
Definition: qtgui_types.h:70
Definition: qtgui_types.h:115
ColorMap_MultiColor()
Definition: qtgui_types.h:150
Definition: qtgui_types.h:142
virtual void setCenterFrequency(const double newFreq)
Definition: qtgui_types.h:58
virtual ~TimeScaleData()
Definition: qtgui_types.h:79
virtual ~FreqOffsetAndPrecisionClass()
Definition: qtgui_types.h:39
Definition: qtgui_types.h:144
virtual unsigned int getFrequencyPrecision() const
Definition: qtgui_types.h:43
Definition: qtgui_types.h:30
Definition: qtgui_types.h:141
Definition: qtgui_types.h:143
virtual void setZeroTime(const gr::high_res_timer_type newTime)
Definition: qtgui_types.h:88
signed long long high_res_timer_type
Typedef for the timer tick count.
Definition: high_res_timer.h:49
ColorMap_BlackHot()
Definition: qtgui_types.h:171
virtual void initiateUpdate(void)
Definition: qtgui_types.h:128
Definition: qtgui_types.h:147
virtual QwtText label(double value) const
Definition: qtgui_types.h:123
ColorMap_WhiteHot()
Definition: qtgui_types.h:162
Definition: qtgui_types.h:159
virtual void setSecondsPerLine(const double newTime)
Definition: qtgui_types.h:93
FreqDisplayScaleDraw(const unsigned int precision)
Definition: qtgui_types.h:118
Definition: qtgui_types.h:140
virtual double getSecondsPerLine() const
Definition: qtgui_types.h:98
Definition: qtgui_types.h:187
Definition: qtgui_types.h:177
FreqOffsetAndPrecisionClass(const int freqPrecision)
Definition: qtgui_types.h:33
virtual void setFrequencyPrecision(const unsigned int newPrecision)
Definition: qtgui_types.h:48
Definition: qtgui_types.h:168
ColorMap_UserDefined(QColor low, QColor high)
Definition: qtgui_types.h:190