44b2f8fd80503b803480384d3cc7ceb014a15638
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / scopewindow.h
1 /*
2  * CINELERRA
3  * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
4  *
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.
9  *
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.
14  *
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
18  *
19  */
20
21 #ifndef SCOPEWINDOW_H
22 #define SCOPEWINDOW_H
23
24
25 #include "boxblur.inc"
26 #include "guicast.h"
27 #include "loadbalance.h"
28 #include "mwindow.h"
29 #include "pluginclient.h"
30 #include "recordmonitor.inc"
31 #include "scopewindow.inc"
32 #include "theme.inc"
33
34 enum {
35         SCOPE_HISTOGRAM, SCOPE_HISTOGRAM_RGB,
36         SCOPE_WAVEFORM, SCOPE_WAVEFORM_RGB, SCOPE_WAVEFORM_PLY,
37         SCOPE_VECTORSCOPE, SCOPE_VECTORWHEEL,
38 };
39
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
50 #define FLOAT_MAX 1.1
51
52 #define MIN_SCOPE_W xS(640)
53 #define MIN_SCOPE_H yS(320)
54
55
56 #define WAVEFORM_DIVISIONS 12
57 #define VECTORSCOPE_DIVISIONS 11
58
59 class ScopePackage : public LoadPackage
60 {
61 public:
62         ScopePackage();
63         int row1, row2;
64 };
65
66
67 class ScopeUnit : public LoadClient
68 {
69 public:
70         ScopeUnit(ScopeGUI *gui, ScopeEngine *server);
71         void process_package(LoadPackage *package);
72         int bins[HIST_SECTIONS][TOTAL_BINS];
73         ScopeGUI *gui;
74 };
75
76 class ScopeEngine : public LoadServer
77 {
78 public:
79         ScopeEngine(ScopeGUI *gui, int cpus);
80         virtual ~ScopeEngine();
81         void init_packages();
82         LoadClient* new_client();
83         LoadPackage* new_package();
84         void process();
85         ScopeGUI *gui;
86 };
87
88 class ScopePanel : public BC_SubWindow
89 {
90 public:
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();
99         int is_dragging;
100         ScopeGUI *gui;
101 };
102
103 class ScopeWaveform : public ScopePanel
104 {
105 public:
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();
110         int drag_x;
111         int drag_y;
112 };
113
114
115 class ScopeVectorscope : public ScopePanel
116 {
117 public:
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);
124
125         int drag_radius;
126         float drag_angle;
127 };
128
129 class ScopeHistogram : public ScopePanel
130 {
131 public:
132         ScopeHistogram(ScopeGUI *gui, int x, int y, int w, int h);
133         void clear_point();
134         void update_point(int x, int y);
135         void draw_point();
136         void draw(int flash, int flush);
137         void draw_mode(int mode, int color, int y, int h);
138         int drag_x;
139 };
140
141
142 class ScopeScopesOn : public BC_MenuItem
143 {
144 public:
145         ScopeScopesOn(ScopeMenu *scope_menu, const char *text, int id);
146         int handle_event();
147
148         ScopeMenu *scope_menu;
149         int id;
150 };
151
152 class ScopeMenu : public BC_PopupMenu
153 {
154 public:
155         ScopeMenu(ScopeGUI *gui, int x, int y);
156         void create_objects();
157         void update_toggles();
158
159         ScopeGUI *gui;
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;
167 };
168
169
170 class ScopeGradPaths : public ArrayList<const char *>
171 {
172 public:
173         ScopeGradPaths() { set_array_delete(); }
174         ~ScopeGradPaths() { remove_all_objects(); }
175 };
176
177 class ScopeGradItem : public BC_MenuItem
178 {
179 public:
180         ScopeGradItem(ScopeVectGrads *vect_grads, const char *text, int idx);
181         int handle_event();
182
183         ScopeVectGrads *vect_grads;
184         int idx;
185 };
186
187 class ScopeVectGrads : public BC_PopupMenu
188 {
189 public:
190         ScopeVectGrads(ScopeGUI *gui, int x, int y);
191         void create_objects();
192
193         ScopeGUI *gui;
194 };
195
196
197 class ScopeGainReset : public BC_Button
198 {
199 public:
200         ScopeGainReset(ScopeGain *gain, int x, int y);
201         static int calculate_w(BC_Theme *theme);
202         int handle_event();
203
204         ScopeGain *gain;
205 };
206
207 class ScopeGainSlider : public BC_ISlider
208 {
209 public:
210         ScopeGainSlider(ScopeGain *gain, int x, int y, int w);
211
212         int handle_event();
213         ScopeGain *gain;
214 };
215
216 class ScopeGain
217 {
218 public:
219         ScopeGain(ScopeGUI *gui, int x, int y, int w, int *value);
220         ~ScopeGain();
221         static int calculate_h();
222         void create_objects();
223         void reposition_window(int x, int y);
224         int handle_event();
225
226         ScopeGUI *gui;
227         int x, y, w, *value;
228         int reset_w;
229         ScopeGainReset *reset;
230         ScopeGainSlider *slider;
231
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(); }
236 };
237
238 class ScopeWaveSlider : public ScopeGain
239 {
240 public:
241         ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w);
242 };
243
244 class ScopeVectSlider : public ScopeGain
245 {
246 public:
247         ScopeVectSlider(ScopeGUI *gui, int x, int y, int w);
248 };
249
250
251 class ScopeSmooth : public BC_CheckBox
252 {
253 public:
254         ScopeSmooth(ScopeGUI *gui, int x, int y);
255         int handle_event();
256         ScopeGUI *gui;
257 };
258
259
260 class ScopeGUI : public PluginClientWindow
261 {
262 public:
263         ScopeGUI(Theme *theme, int x, int y, int w, int h, int cpus);
264         ScopeGUI(PluginClient *plugin, int w, int h);
265         virtual ~ScopeGUI();
266
267         void reset();
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() {}
273
274 // Called for user storage when toggles change
275         virtual void toggle_event();
276
277 // update toggles
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_gradical(int idx);
283         void draw_colorwheel(VFrame *dst, int bg_color);
284         void draw_gradical();
285         void process(VFrame *output_frame);
286         void draw(int flash, int flush);
287         void clear_points(int flash);
288
289         Theme *theme;
290         VFrame *output_frame;
291         VFrame *data_frame, *temp_frame;
292         ScopeEngine *engine;
293         BoxBlur *box_blur;
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;
304         ScopeSmooth *smooth;
305         BC_Title *value_text;
306         VFrame *grad_image;
307         BC_Pixmap *grad_pixmap;
308
309         int x, y, w, h;
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;
315
316         ScopeGradPaths grad_paths;
317         int grad_idx, vector_gradical;
318
319         int cpus;
320         int use_hist, use_wave, use_vector;
321         int use_hist_parade, use_wave_parade;
322
323         int bins[HIST_SECTIONS][TOTAL_BINS];
324         int frame_w, use_smooth;
325         int use_wave_gain, use_vect_gain;
326 };
327
328 #endif