Radio Control  Control Software and GUI for the Panoradio SDR, by DC9ST 2016
waterfallplot.h
1 #ifndef WATERFALLPLOT_H
2 #define WATERFALLPLOT_H
3 
4 #include <QWheelEvent>
5 
6 #include <qwt_plot.h>
7 #include <qwt_plot_spectrogram.h>
8 #include <qwt_color_map.h>
9 
10 #include "waterfall/rasterdata.h"
11 #include "waterfall/waterfalldata.h"
12 
16 class WaterfallPlot : public QwtPlot
17 {
18  Q_OBJECT
19 public:
21  explicit WaterfallPlot(QWidget *parent = 0);
22 
25 
38  void init(int spectrogram_data_width, int spectrogram_data_depth, \
39  double max_frequency, double data_min, double data_max, \
40  int zoom_init, double span_init, double center_frequency_init);
41 
43  void set_max_zoom(int max_zoom) {max_zoom_ = max_zoom;}
44 
46  void set_min_zoom(int min_zoom) {min_zoom_ = min_zoom;}
47 
49  void set_color_map(QwtLinearColorMap color_map) {spectrogram_plot_->setColorMap(color_map); this->replot();}
50 
53  void set_next_data_line(double *array);
54 
56  void correct_size();
57 
59  void set_center_frequency(double center_frequency);
60 
63  void set_wheel_action(int wheel_action) { wheel_action_ = wheel_action; }
64 
66  bool receiver_update_required() {return receiver_update_required_;}
67 
69  void reset_receiver_update() {receiver_update_required_ = false;}
70 
71  // getter functions
72  int get_zoom_level() {return zoom_level_;}
73  double get_center_frequency() {return center_frequency_;}
74  double get_start_frequency() {return start_frequency_;}
75  double get_stop_frequency() {return stop_frequency_;}
76  double get_frequency_span() {return frequency_span_;}
77  double get_max_frequency() {return max_frequency_;}
78  double get_data_min() {return data_min_;}
79  double get_data_max() {return data_max_;}
80 
81 signals:
84  void audio_frequency_clicked(double frequency);
85 
86 private:
87 
89  void wheelEvent(QWheelEvent *event);
90 
94  void zoom_update_axis(int x, bool zoom_in);
95 
97  void shift_frequency(double frequency_shift);
98 
100  void mouseMoveEvent(QMouseEvent *event);
101 
103  void mousePressEvent(QMouseEvent *event);
104 
105  QwtPlotSpectrogram *spectrogram_plot_; // spectromgram plot (waterfall) integrated in the QwtPlot
106  RasterData *raster_data_; // data for spectrogram plot
107  WaterfallData *waterfall_data_; // holds a 2D array
108 
109  int zoom_level_;
110  int max_zoom_;
111  int min_zoom_;
112  double data_min_;
113  double data_max_;
114  double max_frequency_;
115  double start_frequency_; // start frequency of waterfall display in kHz
116  double stop_frequency_; // stop frequency of waterfall display in kHz
117  double center_frequency_; // center frequency of waterfall display in kHz
118  double frequency_span_; // frequency span in waterfall display in kHz
119 
120  int spectrogram_data_width_; // spectrogram width in pixels/data points
121  int spectrogram_data_depth_; // spectrogram height/depth in pixels/data points
122 
123  double scroll_start_frequency_; // stores the start frequency at the beginning of a shift
124  int left_border_; // marks left border of waterfall painting area
125  int right_border_; // marks right border of waterfall painting area
126 
127  bool receiver_update_required_; // signals, that a scroll or zoom activity has occured and the receiver has to be updated
128 
129  int wheel_action_; // specifies, what happend if the wheel is turned (see set_wheel_action())
130 };
131 
132 #endif // WATERFALLPLOT_H
void set_min_zoom(int min_zoom)
sets the minimum possible zoom level
Definition: waterfallplot.h:46
void set_color_map(QwtLinearColorMap color_map)
changes the color map of the waterfall plot (a default is assinged in the constructor) ...
Definition: waterfallplot.h:49
void set_max_zoom(int max_zoom)
sets the maximum possible zoom level
Definition: waterfallplot.h:43
void init(int spectrogram_data_width, int spectrogram_data_depth, double max_frequency, double data_min, double data_max, int zoom_init, double span_init, double center_frequency_init)
initializing function, creates data structures for spectrogram and its display important: the user ne...
Definition: waterfallplot.cpp:21
holds a 2 dimensional array for display in a Waterfall Plot (instanciated by class WaterfallPlot) ...
Definition: waterfalldata.h:10
void reset_receiver_update()
confirms, that a receiver update has been recognized and resets the internal memeber, which signals "update required"
Definition: waterfallplot.h:69
bool receiver_update_required()
Definition: waterfallplot.h:66
void wheelEvent(QWheelEvent *event)
handels wheel events (for zoom) and decides if zoom in or out or nothing (max or min zoom exeeded) is...
Definition: waterfallplot.cpp:161
void shift_frequency(double frequency_shift)
shifts the waterfall ny the specified shift
Definition: waterfallplot.cpp:288
void set_wheel_action(int wheel_action)
sets, what happens if the user turn the mouse wheel in the plot area
Definition: waterfallplot.h:63
Implementation of the abstract QwtRasterData Class,.
Definition: rasterdata.h:16
void set_next_data_line(double *array)
sets one line in the 2 dim data array for spectrogram
Definition: waterfallplot.cpp:127
void zoom_update_axis(int x, bool zoom_in)
calls zoom functions of waterfalldata, calculates new frequencies (start/stop/span etc...
Definition: waterfallplot.cpp:203
void audio_frequency_clicked(double frequency)
sends the frequency for tuning the audio receiver (when right clicking in the waterfall) ...
void mouseMoveEvent(QMouseEvent *event)
event handler for mouse moves for shift functionality
Definition: waterfallplot.cpp:277
void correct_size()
corrects the size of the plot area, so that the data width always matches the display width in pixels...
Definition: waterfallplot.cpp:88
~WaterfallPlot()
destructor
Definition: waterfallplot.cpp:14
void set_center_frequency(double center_frequency)
sets center frequency in kHz (in this case the waterfall display is emptied completely) ...
Definition: waterfallplot.cpp:134
WaterfallPlot(QWidget *parent=0)
constructor
Definition: waterfallplot.cpp:3
Top class for Waterfall Plots ,.
Definition: waterfallplot.h:16
void mousePressEvent(QMouseEvent *event)
event handler for mouse clicks for shift functionality and audio tuning
Definition: waterfallplot.cpp:268