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 "pluginclient.h"
30 #include "recordmonitor.inc"
31 #include "scopewindow.inc"
35 SCOPE_HISTOGRAM, SCOPE_HISTOGRAM_RGB,
36 SCOPE_WAVEFORM, SCOPE_WAVEFORM_RGB, SCOPE_WAVEFORM_PLY,
40 // Number of divisions in histogram.
41 // 65536 + min and max range to speed up the tabulation
42 #define TOTAL_BINS 0x13333
43 #define HIST_SECTIONS 4
44 #define FLOAT_RANGE 1.2
45 // Minimum value in percentage
46 #define HISTOGRAM_MIN -10
47 #define FLOAT_MIN -0.1
48 // Maximum value in percentage
49 #define HISTOGRAM_MAX 110
52 #define MIN_SCOPE_W xS(640)
53 #define MIN_SCOPE_H yS(320)
56 #define WAVEFORM_DIVISIONS 12
57 #define VECTORSCOPE_DIVISIONS 11
59 class ScopePackage : public LoadPackage
67 class ScopeUnit : public LoadClient
70 ScopeUnit(ScopeGUI *gui, ScopeEngine *server);
71 void process_package(LoadPackage *package);
72 int bins[HIST_SECTIONS][TOTAL_BINS];
76 class ScopeEngine : public LoadServer
79 ScopeEngine(ScopeGUI *gui, int cpus);
80 virtual ~ScopeEngine();
82 LoadClient* new_client();
83 LoadPackage* new_package();
88 class ScopePanel : public BC_SubWindow
91 ScopePanel(ScopeGUI *gui, int x, int y, int w, int h);
92 void create_objects();
93 virtual void update_point(int x, int y);
94 virtual void draw_point();
95 virtual void clear_point();
96 int button_press_event();
97 int cursor_motion_event();
98 int button_release_event();
103 class ScopeWaveform : public ScopePanel
106 ScopeWaveform(ScopeGUI *gui, int x, int y, int w, int h);
107 virtual void update_point(int x, int y);
108 virtual void draw_point();
109 virtual void clear_point();
115 class ScopeVectorscope : public ScopePanel
118 ScopeVectorscope(ScopeGUI *gui, int x, int y, int w, int h);
119 virtual void update_point(int x, int y);
120 virtual void draw_point();
121 virtual void clear_point();
126 class ScopeHistogram : public ScopePanel
129 ScopeHistogram(ScopeGUI *gui, int x, int y, int w, int h);
131 void update_point(int x, int y);
133 void draw(int flash, int flush);
134 void draw_mode(int mode, int color, int y, int h);
139 class ScopeScopesOn : public BC_MenuItem
142 ScopeScopesOn(ScopeMenu *scope_menu, const char *text, int id);
145 ScopeMenu *scope_menu;
149 class ScopeMenu : public BC_PopupMenu
152 ScopeMenu(ScopeGUI *gui, int x, int y);
153 void create_objects();
154 void update_toggles();
157 ScopeScopesOn *hist_on;
158 ScopeScopesOn *hist_rgb_on;
159 ScopeScopesOn *wave_on;
160 ScopeScopesOn *wave_rgb_on;
161 ScopeScopesOn *wave_ply_on;
162 ScopeScopesOn *vect_on;
166 class ScopeGainReset : public BC_Button
169 ScopeGainReset(ScopeGain *gain, int x, int y);
170 static int calculate_w(BC_Theme *theme);
176 class ScopeGainSlider : public BC_ISlider
179 ScopeGainSlider(ScopeGain *gain, int x, int y, int w);
188 ScopeGain(ScopeGUI *gui, int x, int y, int w, int *value);
190 static int calculate_h();
191 void create_objects();
192 void reposition_window(int x, int y);
198 ScopeGainReset *reset;
199 ScopeGainSlider *slider;
201 int get_x() { return x; }
202 int get_y() { return y; }
203 int get_w() { return w; }
204 int get_h() { return calculate_h(); }
207 class ScopeWaveSlider : public ScopeGain
210 ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w);
213 class ScopeVectSlider : public ScopeGain
216 ScopeVectSlider(ScopeGUI *gui, int x, int y, int w);
220 class ScopeSmooth : public BC_CheckBox
223 ScopeSmooth(ScopeGUI *gui, int x, int y);
229 class ScopeGUI : public PluginClientWindow
232 ScopeGUI(Theme *theme, int x, int y, int w, int h, int cpus);
233 ScopeGUI(PluginClient *plugin, int w, int h);
237 virtual void create_objects();
238 void create_panels();
239 virtual int resize_event(int w, int h);
240 virtual int translation_event();
241 virtual void update_scope() {}
243 // Called for user storage when toggles change
244 virtual void toggle_event();
247 void update_toggles();
248 void calculate_sizes(int w, int h);
249 void allocate_vframes();
250 void draw_overlays(int overlays, int borders, int flush);
251 void process(VFrame *output_frame);
252 void draw(int flash, int flush);
253 void clear_points(int flash);
256 VFrame *output_frame;
257 VFrame *data_frame, *temp_frame;
260 VFrame *waveform_vframe;
261 VFrame *vector_vframe;
262 ScopeHistogram *histogram;
263 ScopeWaveform *waveform;
264 ScopeVectorscope *vectorscope;
265 ScopeMenu *scope_menu;
266 ScopeWaveSlider *wave_slider;
267 ScopeVectSlider *vect_slider;
269 BC_Title *value_text;
272 int vector_x, vector_y, vector_w, vector_h;
273 int wave_x, wave_y, wave_w, wave_h;
274 int hist_x, hist_y, hist_w, hist_h;
277 int use_hist, use_wave, use_vector;
278 int use_hist_parade, use_wave_parade;
280 int bins[HIST_SECTIONS][TOTAL_BINS];
281 int frame_w, use_smooth;
282 int use_wave_gain, use_vect_gain;