GNU Radio's TEST Package
base_sink_c_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2013-2014 Sylvain Munaut <tnt@246tNt.com>
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
8 * any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street,
18 * Boston, MA 02110-1301, USA.
19 */
20
21
22#ifndef INCLUDED_GR_FOSPHOR_BASE_SINK_C_IMPL_H
23#define INCLUDED_GR_FOSPHOR_BASE_SINK_C_IMPL_H
24
25#include <stdint.h>
26
27#include <gnuradio/thread/thread.h>
28
30
31struct fosphor;
32struct fosphor_render;
33
34namespace gr {
35 namespace fosphor {
36
37 class fifo;
38
39 /*!
40 * \brief Base class for fosphor sink implementation
41 * \ingroup fosphor
42 */
43 class base_sink_c_impl : virtual public base_sink_c
44 {
45 private:
46 /* Worker thread */
47 gr::thread::thread d_worker;
48 bool d_visible;
49 bool d_active;
50 bool d_frozen;
51
52 void worker();
53 static void _worker(base_sink_c_impl *obj);
54
55 gr::thread::mutex d_render_mutex;
56
57 /* fosphor core */
58 fifo *d_fifo;
59
60 struct fosphor *d_fosphor;
61 struct fosphor_render *d_render_main;
62 struct fosphor_render *d_render_zoom;
63
64 void render();
65
66 static gr::thread::mutex s_boot_mutex;
67
68 /* settings refresh logic */
69 enum {
70 SETTING_DIMENSIONS = (1 << 0),
71 SETTING_POWER_RANGE = (1 << 1),
72 SETTING_FREQUENCY_RANGE = (1 << 2),
73 SETTING_FFT_WINDOW = (1 << 3),
74 SETTING_RENDER_OPTIONS = (1 << 4),
75 };
76
77 uint32_t d_settings_changed;
78 gr::thread::mutex d_settings_mutex;
79
80 void settings_mark_changed(uint32_t setting);
81 uint32_t settings_get_and_reset_changed(void);
82 void settings_apply(uint32_t settings);
83
84 /* settings values */
85 int d_width;
86 int d_height;
87
88 static const int k_db_per_div[];
89 int d_db_ref;
90 int d_db_per_div_idx;
91
92 bool d_zoom_enabled;
93 double d_zoom_center;
94 double d_zoom_width;
95
96 float d_ratio;
97
98 struct {
99 double center;
100 double span;
101 } d_frequency;
102
103 gr::fft::window::win_type d_fft_window;
104
105 protected:
107
108 /* Delegated implementation of GL context management */
109 virtual void glctx_init() = 0;
110 virtual void glctx_poll() = 0;
111 virtual void glctx_swap() = 0;
112 virtual void glctx_fini() = 0;
113 virtual void glctx_update() = 0;
114
115 /* Callbacks from GL window */
116 void cb_reshape(int width, int height);
117 void cb_visibility(bool visible);
118
119 public:
121
122 /* gr::fosphor::base_sink_c implementation */
124 void execute_mouse_action(enum mouse_action_t action, int x, int y);
125
126 void set_frequency_range(const double center,
127 const double span);
128 void set_frequency_center(const double center);
129 void set_frequency_span(const double span);
130
131 void set_fft_window(const gr::fft::window::win_type win);
132
133 /* gr::sync_block implementation */
134 int work (int noutput_items,
135 gr_vector_const_void_star &input_items,
136 gr_vector_void_star &output_items);
137
138 bool start();
139 bool stop();
140 };
141
142 } // namespace fosphor
143} // namespace gr
144
145#endif /* INCLUDED_GR_FOSPHOR_BASE_SINK_C_IMPL_H */
146
Base class for fosphor sink implementation.
Definition: base_sink_c_impl.h:44
double span
Definition: base_sink_c_impl.h:100
void set_frequency_center(const double center)
double center
Definition: base_sink_c_impl.h:99
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
void set_frequency_span(const double span)
void execute_ui_action(enum ui_action_t action)
virtual void glctx_update()=0
void set_frequency_range(const double center, const double span)
void execute_mouse_action(enum mouse_action_t action, int x, int y)
void set_fft_window(const gr::fft::window::win_type win)
void cb_visibility(bool visible)
void cb_reshape(int width, int height)
Base fosphor sink API interface.
Definition: base_sink_c.h:38
ui_action_t
Definition: base_sink_c.h:44
mouse_action_t
Definition: base_sink_c.h:59
Definition: fifo.h:33
Definition: base_sink_c.h:30
fosphor render options
Definition: fosphor.h:76
Definition: private.h:44