GNU Radio's TEST Package
base_sink_c_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2013-2021 Sylvain Munaut <tnt@246tNt.com>
4 *
5 * This file is part of gr-fosphor
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 */
9
10#pragma once
11
12#include <stdint.h>
13
14#include <gnuradio/thread/thread.h>
15
17
18struct fosphor;
19struct fosphor_render;
20
21namespace gr {
22 namespace fosphor {
23
24 class fifo;
25
26 /*!
27 * \brief Base class for fosphor sink implementation
28 * \ingroup fosphor
29 */
30 class base_sink_c_impl : virtual public base_sink_c
31 {
32 private:
33 /* Worker thread */
34 gr::thread::thread d_worker;
35 bool d_visible;
36 bool d_active;
37 bool d_frozen;
38
39 void worker();
40 static void _worker(base_sink_c_impl *obj);
41
42 gr::thread::mutex d_render_mutex;
43
44 /* fosphor core */
45 fifo *d_fifo;
46
47 struct fosphor *d_fosphor;
48 struct fosphor_render *d_render_main;
49 struct fosphor_render *d_render_zoom;
50
51 void render();
52
53 static gr::thread::mutex s_boot_mutex;
54
55 /* settings refresh logic */
56 enum {
57 SETTING_DIMENSIONS = (1 << 0),
58 SETTING_POWER_RANGE = (1 << 1),
59 SETTING_FREQUENCY_RANGE = (1 << 2),
60 SETTING_FFT_WINDOW = (1 << 3),
61 SETTING_RENDER_OPTIONS = (1 << 4),
62 };
63
64 uint32_t d_settings_changed;
65 gr::thread::mutex d_settings_mutex;
66
67 void settings_mark_changed(uint32_t setting);
68 uint32_t settings_get_and_reset_changed(void);
69 void settings_apply(uint32_t settings);
70
71 /* settings values */
72 int d_width;
73 int d_height;
74
75 static const int k_db_per_div[];
76 int d_db_ref;
77 int d_db_per_div_idx;
78
79 bool d_zoom_enabled;
80 double d_zoom_center;
81 double d_zoom_width;
82
83 float d_ratio;
84
85 struct {
86 double center;
87 double span;
88 } d_frequency;
89
90 gr::fft::window::win_type d_fft_window;
91
92 protected:
94
95 /* Delegated implementation of GL context management */
96 virtual void glctx_init() = 0;
97 virtual void glctx_poll() = 0;
98 virtual void glctx_swap() = 0;
99 virtual void glctx_fini() = 0;
100 virtual void glctx_update() = 0;
101
102 /* Callbacks from GL window */
103 void cb_reshape(int width, int height);
104 void cb_visibility(bool visible);
105
106 public:
108
109 /* gr::fosphor::base_sink_c implementation */
111 void execute_mouse_action(enum mouse_action_t action, int x, int y);
112
113 void set_frequency_range(const double center,
114 const double span);
115 void set_frequency_center(const double center);
116 void set_frequency_span(const double span);
117
118 void set_fft_window(const gr::fft::window::win_type win);
119
120 /* gr::sync_block implementation */
121 int work (int noutput_items,
122 gr_vector_const_void_star &input_items,
123 gr_vector_void_star &output_items);
124
125 bool start();
126 bool stop();
127 };
128
129 } // namespace fosphor
130} // namespace gr
Base class for fosphor sink implementation.
Definition base_sink_c_impl.h:31
double span
Definition base_sink_c_impl.h:87
void set_frequency_center(const double center)
double center
Definition base_sink_c_impl.h:86
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:25
ui_action_t
Definition base_sink_c.h:31
mouse_action_t
Definition base_sink_c.h:46
Definition fifo.h:21
Definition base_sink_c.h:17
fosphor render options
Definition fosphor.h:63
Definition private.h:31