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,
39 SCOPE_SMOOTH, SCOPE_REFRESH, SCOPE_RELEASE,
42 // Number of divisions in histogram.
43 // 65536 + min and max range to speed up the tabulation
44 #define TOTAL_BINS 0x13333
45 #define HIST_SECTIONS 4
46 #define FLOAT_RANGE 1.2
47 // Minimum value in percentage
48 #define HISTOGRAM_MIN -10
49 #define FLOAT_MIN -0.1
50 // Maximum value in percentage
51 #define HISTOGRAM_MAX 110
54 #define MIN_SCOPE_W xS(320)
55 #define MIN_SCOPE_H yS(320)
58 #define WAVEFORM_DIVISIONS 12
59 #define VECTORSCOPE_DIVISIONS 11
61 class ScopePackage : public LoadPackage
69 class ScopeUnit : public LoadClient
72 ScopeUnit(ScopeGUI *gui, ScopeEngine *server);
73 void process_package(LoadPackage *package);
74 int bins[HIST_SECTIONS][TOTAL_BINS];
78 class ScopeEngine : public LoadServer
81 ScopeEngine(ScopeGUI *gui, int cpus);
82 virtual ~ScopeEngine();
84 LoadClient* new_client();
85 LoadPackage* new_package();
90 class ScopePanel : public BC_SubWindow
93 ScopePanel(ScopeGUI *gui, int x, int y, int w, int h);
94 void create_objects();
95 virtual void update_point(int x, int y);
96 virtual void draw_point();
97 virtual void clear_point();
98 int button_press_event();
99 int cursor_motion_event();
100 int button_release_event();
105 class ScopeWaveform : public ScopePanel
108 ScopeWaveform(ScopeGUI *gui, int x, int y, int w, int h);
109 virtual void update_point(int x, int y);
110 virtual void draw_point();
111 virtual void clear_point();
117 class ScopeVectorscope : public ScopePanel
120 ScopeVectorscope(ScopeGUI *gui, int x, int y, int w, int h);
121 virtual void update_point(int x, int y);
122 virtual void draw_point();
123 virtual void clear_point();
124 void draw_point(float th, float r, int color);
125 void draw_radient(float th, float r1, float r2, int color);
131 class ScopeHistogram : public ScopePanel
134 ScopeHistogram(ScopeGUI *gui, int x, int y, int w, int h);
136 void update_point(int x, int y);
138 void draw(int flash, int flush);
139 void draw_mode(int mode, int color, int y, int h);
144 class ScopeScopesOn : public BC_MenuItem
147 ScopeScopesOn(ScopeMenu *scope_menu, const char *text, int id);
150 ScopeMenu *scope_menu;
154 class ScopeMenu : public BC_PopupMenu
157 ScopeMenu(ScopeGUI *gui, int x, int y);
158 void create_objects();
159 void update_toggles();
162 ScopeScopesOn *hist_on;
163 ScopeScopesOn *hist_rgb_on;
164 ScopeScopesOn *wave_on;
165 ScopeScopesOn *wave_rgb_on;
166 ScopeScopesOn *wave_ply_on;
167 ScopeScopesOn *vect_on;
168 ScopeScopesOn *vect_wheel;
171 class ScopeSettingOn : public BC_MenuItem
174 ScopeSettingOn(ScopeSettings *settings, const char *text, int id);
177 ScopeSettings *settings;
181 class ScopeGratPaths : public ArrayList<const char *>
184 ScopeGratPaths() { set_array_delete(); }
185 ~ScopeGratPaths() { remove_all_objects(); }
188 class ScopeGratItem : public BC_MenuItem
191 ScopeGratItem(ScopeSettings *settings, const char *text, int idx);
194 ScopeSettings *settings;
198 class ScopeSettings : public BC_PopupMenu
201 ScopeSettings(ScopeGUI *gui, int x, int y);
202 void create_objects();
203 void update_toggles();
206 ScopeSettingOn *smooth_on;
207 ScopeSettingOn *refresh_on;
208 ScopeSettingOn *release_on;
212 class ScopeGainReset : public BC_Button
215 ScopeGainReset(ScopeGain *gain, int x, int y);
216 static int calculate_w(BC_Theme *theme);
222 class ScopeGainSlider : public BC_ISlider
225 ScopeGainSlider(ScopeGain *gain, int x, int y, int w);
234 ScopeGain(ScopeGUI *gui, int x, int y, int w, int *value);
236 static int calculate_h();
237 void create_objects();
238 void reposition_window(int x, int y);
244 ScopeGainReset *reset;
245 ScopeGainSlider *slider;
247 int get_x() { return x; }
248 int get_y() { return y; }
249 int get_w() { return w; }
250 int get_h() { return calculate_h(); }
253 class ScopeWaveSlider : public ScopeGain
256 ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w);
259 class ScopeVectSlider : public ScopeGain
262 ScopeVectSlider(ScopeGUI *gui, int x, int y, int w);
266 class ScopeGUI : public PluginClientWindow
269 ScopeGUI(Theme *theme, int x, int y, int w, int h, int cpus);
270 ScopeGUI(PluginClient *plugin, int w, int h);
274 virtual void create_objects();
275 void create_panels();
276 virtual int resize_event(int w, int h);
277 virtual int translation_event();
278 virtual void update_scope() {}
280 // Called for user storage when toggles change
281 virtual void toggle_event();
284 void update_toggles();
285 void calculate_sizes(int w, int h);
286 void allocate_vframes();
287 void draw_overlays(int overlays, int borders, int flush);
288 void update_graticule(int idx);
289 void draw_colorwheel(VFrame *dst, int bg_color);
291 void process(VFrame *output_frame);
292 void draw(int flash, int flush);
293 void clear_points(int flash);
296 VFrame *output_frame;
297 VFrame *data_frame, *temp_frame;
300 VFrame *waveform_vframe;
301 VFrame *vector_vframe;
302 VFrame *wheel_vframe;
303 ScopeHistogram *histogram;
304 ScopeWaveform *waveform;
305 ScopeVectorscope *vectorscope;
306 ScopeMenu *scope_menu;
307 ScopeWaveSlider *wave_slider;
308 ScopeVectSlider *vect_slider;
309 ScopeSettings *settings;
311 OverlayFrame *overlay;
314 int vector_x, vector_y, vector_w, vector_h;
315 int vector_cx, vector_cy, radius;
316 int wave_x, wave_y, wave_w, wave_h;
317 int hist_x, hist_y, hist_w, hist_h;
318 int text_color, dark_color;
320 ScopeGratPaths grat_paths;
321 int grat_idx, use_graticule;
324 int use_hist, use_wave, use_vector;
325 int use_hist_parade, use_wave_parade;
327 int bins[HIST_SECTIONS][TOTAL_BINS];
328 int frame_w, use_smooth;
329 int use_refresh, use_release;
330 int use_wave_gain, use_vect_gain;