3 * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
5 * This program 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 2 of the License, or
8 * (at your option) any later version.
10 * This program 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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "boxblur.inc"
27 #include "loadbalance.h"
29 #include "overlayframe.inc"
30 #include "pluginclient.h"
31 #include "recordmonitor.inc"
32 #include "scopewindow.inc"
36 SCOPE_HISTOGRAM, SCOPE_HISTOGRAM_RGB,
37 SCOPE_WAVEFORM, SCOPE_WAVEFORM_RGB, SCOPE_WAVEFORM_PLY,
38 SCOPE_VECTORSCOPE, SCOPE_VECTORWHEEL,
41 // Number of divisions in histogram.
42 // 65536 + min and max range to speed up the tabulation
43 #define TOTAL_BINS 0x13333
44 #define HIST_SECTIONS 4
45 #define FLOAT_RANGE 1.2
46 // Minimum value in percentage
47 #define HISTOGRAM_MIN -10
48 #define FLOAT_MIN -0.1
49 // Maximum value in percentage
50 #define HISTOGRAM_MAX 110
53 #define MIN_SCOPE_W xS(320)
54 #define MIN_SCOPE_H yS(320)
57 #define WAVEFORM_DIVISIONS 12
58 #define VECTORSCOPE_DIVISIONS 11
60 class ScopePackage : public LoadPackage
68 class ScopeUnit : public LoadClient
71 ScopeUnit(ScopeGUI *gui, ScopeEngine *server);
72 void process_package(LoadPackage *package);
73 int bins[HIST_SECTIONS][TOTAL_BINS];
77 class ScopeEngine : public LoadServer
80 ScopeEngine(ScopeGUI *gui, int cpus);
81 virtual ~ScopeEngine();
83 LoadClient* new_client();
84 LoadPackage* new_package();
89 class ScopePanel : public BC_SubWindow
92 ScopePanel(ScopeGUI *gui, int x, int y, int w, int h);
93 void create_objects();
94 virtual void update_point(int x, int y);
95 virtual void draw_point();
96 virtual void clear_point();
97 int button_press_event();
98 int cursor_motion_event();
99 int button_release_event();
104 class ScopeWaveform : public ScopePanel
107 ScopeWaveform(ScopeGUI *gui, int x, int y, int w, int h);
108 virtual void update_point(int x, int y);
109 virtual void draw_point();
110 virtual void clear_point();
116 class ScopeVectorscope : public ScopePanel
119 ScopeVectorscope(ScopeGUI *gui, int x, int y, int w, int h);
120 virtual void update_point(int x, int y);
121 virtual void draw_point();
122 virtual void clear_point();
123 void draw_point(float th, float r, int color);
124 void draw_radient(float th, float r1, float r2, int color);
130 class ScopeHistogram : public ScopePanel
133 ScopeHistogram(ScopeGUI *gui, int x, int y, int w, int h);
135 void update_point(int x, int y);
137 void draw(int flash, int flush);
138 void draw_mode(int mode, int color, int y, int h);
143 class ScopeScopesOn : public BC_MenuItem
146 ScopeScopesOn(ScopeMenu *scope_menu, const char *text, int id);
149 ScopeMenu *scope_menu;
153 class ScopeMenu : public BC_PopupMenu
156 ScopeMenu(ScopeGUI *gui, int x, int y);
157 void create_objects();
158 void update_toggles();
161 ScopeScopesOn *hist_on;
162 ScopeScopesOn *hist_rgb_on;
163 ScopeScopesOn *wave_on;
164 ScopeScopesOn *wave_rgb_on;
165 ScopeScopesOn *wave_ply_on;
166 ScopeScopesOn *vect_on;
167 ScopeScopesOn *vect_wheel;
171 class ScopeGratPaths : public ArrayList<const char *>
174 ScopeGratPaths() { set_array_delete(); }
175 ~ScopeGratPaths() { remove_all_objects(); }
178 class ScopeGratItem : public BC_MenuItem
181 ScopeGratItem(ScopeVectGrats *vect_grats, const char *text, int idx);
184 ScopeVectGrats *vect_grats;
188 class ScopeVectGrats : public BC_PopupMenu
191 ScopeVectGrats(ScopeGUI *gui, int x, int y);
192 void create_objects();
198 class ScopeGainReset : public BC_Button
201 ScopeGainReset(ScopeGain *gain, int x, int y);
202 static int calculate_w(BC_Theme *theme);
208 class ScopeGainSlider : public BC_ISlider
211 ScopeGainSlider(ScopeGain *gain, int x, int y, int w);
220 ScopeGain(ScopeGUI *gui, int x, int y, int w, int *value);
222 static int calculate_h();
223 void create_objects();
224 void reposition_window(int x, int y);
230 ScopeGainReset *reset;
231 ScopeGainSlider *slider;
233 int get_x() { return x; }
234 int get_y() { return y; }
235 int get_w() { return w; }
236 int get_h() { return calculate_h(); }
239 class ScopeWaveSlider : public ScopeGain
242 ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w);
245 class ScopeVectSlider : public ScopeGain
248 ScopeVectSlider(ScopeGUI *gui, int x, int y, int w);
252 class ScopeSmooth : public BC_CheckBox
255 ScopeSmooth(ScopeGUI *gui, int x, int y);
261 class ScopeGUI : public PluginClientWindow
264 ScopeGUI(Theme *theme, int x, int y, int w, int h, int cpus);
265 ScopeGUI(PluginClient *plugin, int w, int h);
269 virtual void create_objects();
270 void create_panels();
271 virtual int resize_event(int w, int h);
272 virtual int translation_event();
273 virtual void update_scope() {}
275 // Called for user storage when toggles change
276 virtual void toggle_event();
279 void update_toggles();
280 void calculate_sizes(int w, int h);
281 void allocate_vframes();
282 void draw_overlays(int overlays, int borders, int flush);
283 void update_graticule(int idx);
284 void draw_colorwheel(VFrame *dst, int bg_color);
286 void process(VFrame *output_frame);
287 void draw(int flash, int flush);
288 void clear_points(int flash);
291 VFrame *output_frame;
292 VFrame *data_frame, *temp_frame;
295 VFrame *waveform_vframe;
296 VFrame *vector_vframe;
297 VFrame *wheel_vframe;
298 ScopeHistogram *histogram;
299 ScopeWaveform *waveform;
300 ScopeVectorscope *vectorscope;
301 ScopeMenu *scope_menu;
302 ScopeWaveSlider *wave_slider;
303 ScopeVectSlider *vect_slider;
304 ScopeVectGrats *vect_grats;
307 OverlayFrame *overlay;
310 int vector_x, vector_y, vector_w, vector_h;
311 int vector_cx, vector_cy, radius;
312 int wave_x, wave_y, wave_w, wave_h;
313 int hist_x, hist_y, hist_w, hist_h;
314 int text_color, dark_color;
316 ScopeGratPaths grat_paths;
317 int grat_idx, use_graticule;
320 int use_hist, use_wave, use_vector;
321 int use_hist_parade, use_wave_parade;
323 int bins[HIST_SECTIONS][TOTAL_BINS];
324 int frame_w, use_smooth;
325 int use_wave_gain, use_vect_gain;