GNU Radio's FOSPHOR 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 
31 struct fosphor;
32 struct fosphor_render;
33 
34 namespace 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  bool d_frozen;
47 
48  /* fosphor core */
49  fifo *d_fifo;
50 
51  struct fosphor *d_fosphor;
52  struct fosphor_render *d_render_main;
53  struct fosphor_render *d_render_zoom;
54 
55  void render();
56 
57  static gr::thread::mutex s_boot_mutex;
58 
59  /* settings refresh logic */
60  enum {
61  SETTING_DIMENSIONS = (1 << 0),
62  SETTING_POWER_RANGE = (1 << 1),
63  SETTING_FREQUENCY_RANGE = (1 << 2),
64  SETTING_FFT_WINDOW = (1 << 3),
65  SETTING_RENDER_OPTIONS = (1 << 4),
66  };
67 
68  uint32_t d_settings_changed;
69  thread::mutex d_settings_mutex;
70 
71  void settings_mark_changed(uint32_t setting);
72  uint32_t settings_get_and_reset_changed(void);
73  void settings_apply(uint32_t settings);
74 
75  /* settings values */
76  int d_width;
77  int d_height;
78 
79  static const int k_db_per_div[];
80  int d_db_ref;
81  int d_db_per_div_idx;
82 
83  bool d_zoom_enabled;
84  double d_zoom_center;
85  double d_zoom_width;
86 
87  float d_ratio;
88 
89  struct {
90  double center;
91  double span;
92  } d_frequency;
93 
94  gr::fft::window::win_type d_fft_window;
95 
96  protected:
98 
99  /* Delegated implementation of GL context management */
100  virtual void glctx_init() = 0;
101  virtual void glctx_poll() = 0;
102  virtual void glctx_swap() = 0;
103  virtual void glctx_fini() = 0;
104  virtual void glctx_update() = 0;
105 
106  /* Callbacks from GL window */
107  void cb_reshape(int width, int height);
108 
109  bool d_active;
110 
111  public:
112  void worker();
113  virtual ~base_sink_c_impl();
114 
115  /* gr::fosphor::base_sink_c implementation */
116  void execute_ui_action(enum ui_action_t action);
117 
118  void set_frequency_range(const double center,
119  const double span);
120  void set_frequency_center(const double center);
121  void set_frequency_span(const double span);
122 
123  void set_fft_window(const gr::fft::window::win_type win);
124 
125  /* gr::sync_block implementation */
126  int work (int noutput_items,
127  gr_vector_const_void_star &input_items,
128  gr_vector_void_star &output_items);
129 
130  };
131 
132  } // namespace fosphor
133 } // namespace gr
134 
135 #endif /* INCLUDED_GR_FOSPHOR_BASE_SINK_C_IMPL_H */
136 
Base fosphor sink API interface.
Definition: base_sink_c.h:37
double center
Definition: base_sink_c_impl.h:90
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
void set_frequency_range(const double center, const double span)
virtual void glctx_update()=0
void set_fft_window(const gr::fft::window::win_type win)
Definition: private.h:43
Base class for fosphor sink implementation.
Definition: base_sink_c_impl.h:43
ui_action_t
Definition: base_sink_c.h:44
Definition: base_sink_c.h:30
bool d_active
Definition: base_sink_c_impl.h:109
void execute_ui_action(enum ui_action_t action)
void set_frequency_center(const double center)
fosphor render options
Definition: fosphor.h:75
void set_frequency_span(const double span)
double span
Definition: base_sink_c_impl.h:91
Definition: fifo.h:32
void cb_reshape(int width, int height)