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,
37 SCOPE_VECTORSCOPE, SCOPE_VECTORWHEEL,
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();
122 void draw_point(float th, float r, int color);
123 void draw_radient(float th, float r1, float r2, int color);
129 class ScopeHistogram : public ScopePanel
132 ScopeHistogram(ScopeGUI *gui, int x, int y, int w, int h);
134 void update_point(int x, int y);
136 void draw(int flash, int flush);
137 void draw_mode(int mode, int color, int y, int h);
142 class ScopeScopesOn : public BC_MenuItem
145 ScopeScopesOn(ScopeMenu *scope_menu, const char *text, int id);
148 ScopeMenu *scope_menu;
152 class ScopeMenu : public BC_PopupMenu
155 ScopeMenu(ScopeGUI *gui, int x, int y);
156 void create_objects();
157 void update_toggles();
160 ScopeScopesOn *hist_on;
161 ScopeScopesOn *hist_rgb_on;
162 ScopeScopesOn *wave_on;
163 ScopeScopesOn *wave_rgb_on;
164 ScopeScopesOn *wave_ply_on;
165 ScopeScopesOn *vect_on;
166 ScopeScopesOn *vect_wheel;
170 class ScopeGradPaths : public ArrayList<const char *>
173 ScopeGradPaths() { set_array_delete(); }
174 ~ScopeGradPaths() { remove_all_objects(); }
177 class ScopeGradItem : public BC_MenuItem
180 ScopeGradItem(ScopeVectGrads *vect_grads, const char *text, int idx);
183 ScopeVectGrads *vect_grads;
187 class ScopeVectGrads : public BC_PopupMenu
190 ScopeVectGrads(ScopeGUI *gui, int x, int y);
191 void create_objects();
197 class ScopeGainReset : public BC_Button
200 ScopeGainReset(ScopeGain *gain, int x, int y);
201 static int calculate_w(BC_Theme *theme);
207 class ScopeGainSlider : public BC_ISlider
210 ScopeGainSlider(ScopeGain *gain, int x, int y, int w);
219 ScopeGain(ScopeGUI *gui, int x, int y, int w, int *value);
221 static int calculate_h();
222 void create_objects();
223 void reposition_window(int x, int y);
229 ScopeGainReset *reset;
230 ScopeGainSlider *slider;
232 int get_x() { return x; }
233 int get_y() { return y; }
234 int get_w() { return w; }
235 int get_h() { return calculate_h(); }
238 class ScopeWaveSlider : public ScopeGain
241 ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w);
244 class ScopeVectSlider : public ScopeGain
247 ScopeVectSlider(ScopeGUI *gui, int x, int y, int w);
251 class ScopeSmooth : public BC_CheckBox
254 ScopeSmooth(ScopeGUI *gui, int x, int y);
260 class ScopeGUI : public PluginClientWindow
263 ScopeGUI(Theme *theme, int x, int y, int w, int h, int cpus);
264 ScopeGUI(PluginClient *plugin, int w, int h);
268 virtual void create_objects();
269 void create_panels();
270 virtual int resize_event(int w, int h);
271 virtual int translation_event();
272 virtual void update_scope() {}
274 // Called for user storage when toggles change
275 virtual void toggle_event();
278 void update_toggles();
279 void calculate_sizes(int w, int h);
280 void allocate_vframes();
281 void draw_overlays(int overlays, int borders, int flush);
282 void update_graticule(int idx);
283 void draw_colorwheel(VFrame *dst, int bg_color);
284 void draw_graticule();
285 void process(VFrame *output_frame);
286 void draw(int flash, int flush);
287 void clear_points(int flash);
290 VFrame *output_frame;
291 VFrame *data_frame, *temp_frame;
294 VFrame *waveform_vframe;
295 VFrame *vector_vframe;
296 VFrame *wheel_vframe;
297 ScopeHistogram *histogram;
298 ScopeWaveform *waveform;
299 ScopeVectorscope *vectorscope;
300 ScopeMenu *scope_menu;
301 ScopeWaveSlider *wave_slider;
302 ScopeVectSlider *vect_slider;
303 ScopeVectGrads *vect_grads;
305 BC_Title *value_text;
307 BC_Pixmap *grad_pixmap;
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 ScopeGradPaths grad_paths;
317 int grad_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;