SoDaRadio-5.0.3-master:8901fb5
soda_wfall.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2017 Matthew H. Reilly (kb1vc)
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8 
9  Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef SODAWFALL_H
30 #define SODAWFALL_H
31 
32 #include <QWidget>
33 #include <qwt/qwt_plot.h>
34 #include <qwt/qwt_plot_spectrogram.h>
35 #include <qwt/qwt_raster_data.h>
36 #include <qwt/qwt_plot_picker.h>
37 #include <qwt/qwt_plot_grid.h>
38 #include <qwt/qwt_plot_panner.h>
39 #include <qwt/qwt_scale_draw.h>
40 #include <qwt/qwt_plot_marker.h>
41 #include <qwt/qwt_plot_shapeitem.h>
42 
43 
44 #include <QMouseEvent>
45 #include <QPointF>
46 
47 #include <iostream>
48 #include <boost/format.hpp>
49 
50 #include "soda_wfall_picker.hpp"
51 #include "soda_freq_scale_draw.hpp"
52 #include "soda_wfall_data.hpp"
53 
54 #include <cmath>
55 
56 namespace GUISoDa {
57  class PlotSpectrogram ;
58  class WFColorMap;
59 
60  class WFall : public QwtPlot
61  {
62  Q_OBJECT
63 
64  public:
65  explicit WFall(QWidget *parent = 0);
66  ~WFall();
67 
68  double freqCenter() { return center_freq; }
69  public slots:
70  void updateData(double cf, float * y);
71  void pickPoint(const QPointF & pos);
72 
73  void setFreqMarker(double freq);
74 
75  void setDynamicRange(double drange);
76  void setRefLevel(int rlvl);
77  void setFreqCenter(double cf, bool check_boundary = false);
78  void setFreqSpan(double fs, bool check_boundary = false);
79  void setFreqSpanKHz(double fs) { setFreqSpan(1e3 * fs, true); }
80  void scrollRight(bool v) {
81  (void) v;
82  setFreqCenter(center_freq + freq_span * 0.25, true);
83  }
84  void scrollLeft(bool v) {
85  (void) v;
86  setFreqCenter(center_freq - freq_span * 0.25, true); }
87  void configureSpectrum(double cfreq, double span, long buckets) {
88  setFreqCenter(cfreq);
89  // setFreqSpan(span);
90  spectrum_input_span = span;
91  wfall_data->setSpectrumDimensions(cfreq, span, buckets);
92  }
93  void setMarkerOffset(double lo, double hi);
94 
95  private:
96  void setZAxis();
97  void setMarkers(double lo, double hi) {
98  wfall_data->setMarkers(lo, hi);
99  }
102 
103  public:
104 
105  signals:
106  void xClick(double x);
107 
108  protected:
109 
110  double correctCenterFreq(double cfreq);
111 
112  double center_freq;
113  double freq_span;
116  double marker_freq;
117 
118 
121 
123 
125 
126  QwtScaleWidget * right_axis;
127  private:
128  void initPlot();
129 
130  };
131 }
132 #endif
void setFreqCenter(double cf, bool check_boundary=false)
Definition: soda_wfall.cpp:200
double marker_hi_offset
Definition: soda_wfall.hpp:101
void setFreqSpan(double fs, bool check_boundary=false)
Definition: soda_wfall.cpp:212
double last_input_cfreq
Definition: soda_wfall.hpp:115
void setMarkerOffset(double lo, double hi)
Definition: soda_wfall.cpp:238
void setDynamicRange(double drange)
Definition: soda_wfall.cpp:257
PlotSpectrogram * sgram
Definition: soda_wfall.hpp:120
double correctCenterFreq(double cfreq)
Definition: soda_wfall.cpp:189
void scrollLeft(bool v)
Definition: soda_wfall.hpp:84
FreqScaleDraw * freq_scale_p
Definition: soda_wfall.hpp:124
void updateData(double cf, float *y)
Definition: soda_wfall.cpp:231
void configureSpectrum(double cfreq, double span, long buckets)
Definition: soda_wfall.hpp:87
double marker_freq
Definition: soda_wfall.hpp:116
void setMarkers(double lo, double hi)
Definition: soda_wfall.hpp:97
WFall(QWidget *parent=0)
Definition: soda_wfall.cpp:139
void xClick(double x)
void scrollRight(bool v)
Definition: soda_wfall.hpp:80
WFallPicker * picker_p
Definition: soda_wfall.hpp:122
void setRefLevel(int rlvl)
Definition: soda_wfall.cpp:263
void setFreqSpanKHz(double fs)
Definition: soda_wfall.hpp:79
void pickPoint(const QPointF &pos)
Definition: soda_wfall.cpp:250
QwtScaleWidget * right_axis
Definition: soda_wfall.hpp:126
void setMarkers(double lo, double hi)
double center_freq
Definition: soda_wfall.hpp:112
double marker_lo_offset
Definition: soda_wfall.hpp:100
double freqCenter()
Definition: soda_wfall.hpp:68
void setSpectrumDimensions(double cfreq, double span, long buckets)
void setFreqMarker(double freq)
Definition: soda_wfall.cpp:244
double spectrum_input_span
Definition: soda_wfall.hpp:114
WFallData * wfall_data
Definition: soda_wfall.hpp:119