add auto zoombar/status color, fix 3 batchrender boobies, rotate plugin tweaks, add...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / lens / lens.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef LENS_H
23 #define LENS_H
24
25
26 #include "bchash.inc"
27 #include "guicast.h"
28 #include "loadbalance.h"
29 #include "pluginvclient.h"
30 #include "thread.h"
31
32
33 class LensEngine;
34 class LensGUI;
35 class LensMain;
36 class LensText;
37
38 #define FOV_CHANNELS 4
39
40
41 class LensSlider : public BC_FSlider
42 {
43 public:
44         LensSlider(LensMain *plugin, LensGUI *gui,
45                 LensText *text, float *output, int x, int y,
46                 float min, float max);
47         int handle_event();
48
49         LensGUI *gui;
50         LensMain *plugin;
51         LensText *text;
52         float *output;
53 };
54
55 class LensText : public BC_TextBox
56 {
57 public:
58         LensText(LensMain *plugin, LensGUI *gui,
59                 LensSlider *slider, float *output, int x, int y);
60         int handle_event();
61
62         LensGUI *gui;
63         LensMain *plugin;
64         LensSlider *slider;
65         float *output;
66 };
67
68
69 class LensToggle : public BC_CheckBox
70 {
71 public:
72         LensToggle(LensMain *plugin, int *output, int x, int y,
73                 const char *text);
74         int handle_event();
75
76         LensMain *plugin;
77         int *output;
78 };
79
80
81 class LensInterpItem : public BC_MenuItem
82 {
83 public:
84         LensInterpItem(const char *text, int id);
85
86         int handle_event();
87         int id;
88 };
89
90 class LensInterp : public BC_PopupMenu
91 {
92 public:
93         LensInterp(LensMain *plugin, int x, int y);
94         void create_objects();
95         void set_value(int id);
96         int get_value();
97
98         LensMain *plugin;
99         int value;
100 };
101
102
103 class LensReset : public BC_GenericButton
104 {
105 public:
106         LensReset(LensMain *plugin, LensGUI *gui, int x, int y);
107         int handle_event();
108
109         LensMain *plugin;
110         LensGUI *gui;
111 };
112
113
114 class LensMode : public BC_PopupMenu
115 {
116 public:
117         LensMode(LensMain *plugin, LensGUI *gui, int x, int y);
118         int handle_event();
119         void create_objects();
120         static int calculate_w(LensGUI *gui);
121         static int from_text(char *text);
122         static const char* to_text(int mode);
123         void update(int mode);
124         LensMain *plugin;
125         LensGUI *gui;
126 };
127
128
129 class LensPresets : public BC_PopupMenu
130 {
131 public:
132         LensPresets(LensMain *plugin, LensGUI *gui, int x, int y, int w);
133         int handle_event();
134         void create_objects();
135         int from_text(LensMain *plugin, char *text);
136         const char* to_text(LensMain *plugin, int preset);
137         void update(int preset);
138         LensMain *plugin;
139         LensGUI *gui;
140 };
141
142 class LensSavePreset : public BC_GenericButton
143 {
144 public:
145         LensSavePreset(LensMain *plugin, LensGUI *gui, int x, int y);
146         int handle_event();
147         LensMain *plugin;
148         LensGUI *gui;
149 };
150
151 class LensDeletePreset : public BC_GenericButton
152 {
153 public:
154         LensDeletePreset(LensMain *plugin, LensGUI *gui, int x, int y);
155         int handle_event();
156         LensMain *plugin;
157         LensGUI *gui;
158 };
159
160 class LensPresetText : public BC_TextBox
161 {
162 public:
163         LensPresetText(LensMain *plugin, LensGUI *gui, int x, int y, int w);
164         int handle_event();
165         LensMain *plugin;
166         LensGUI *gui;
167 };
168
169 class LensGUI : public PluginClientWindow
170 {
171 public:
172         LensGUI(LensMain *plugin);
173         ~LensGUI();
174
175         void create_objects();
176         void update_gui();
177
178         LensMain *plugin;
179         LensSlider *fov_slider[FOV_CHANNELS];
180         LensText *fov_text[FOV_CHANNELS];
181         LensSlider *aspect_slider;
182         LensText *aspect_text;
183         LensSlider *radius_slider;
184         LensText *radius_text;
185         LensSlider *centerx_slider;
186         LensText *centerx_text;
187         LensSlider *centery_slider;
188         LensText *centery_text;
189         LensMode *mode;
190         LensInterp *interp;
191         LensReset *reset;
192 //      LensPresets *presets;
193 //      LensSavePreset *save_preset;
194 //      LensDeletePreset *delete_preset;
195 //      LensPresetText *preset_text;
196         LensToggle *reverse;
197         LensToggle *draw_guides;
198 };
199
200 class LensConfig
201 {
202 public:
203         LensConfig();
204         void reset();
205         int equivalent(LensConfig &that);
206         void copy_from(LensConfig &that);
207         void interpolate(LensConfig &prev, LensConfig &next,
208                 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
209         void boundaries();
210         float fov[FOV_CHANNELS];
211         int lock;
212         float aspect;
213         float radius;
214         float center_x;
215         float center_y;
216         int draw_guides;
217         int mode, interp;
218         enum {
219                 SPHERICAL_SHRINK,
220                 SPHERICAL_STRETCH,
221                 RECTILINEAR_SHRINK,
222                 RECTILINEAR_STRETCH
223         };
224         enum {
225                 INTERP_DEFAULT,
226                 INTERP_NEAREST,
227                 INTERP_BILINEAR,
228                 INTERP_BICUBIC,
229         };
230 };
231
232 class LensPreset
233 {
234 public:
235         char title[BCTEXTLEN];
236         float fov[FOV_CHANNELS];
237         float aspect;
238         float radius;
239         int mode;
240 };
241
242
243
244
245
246 class LensPackage : public LoadPackage
247 {
248 public:
249         LensPackage();
250         int row1, row2;
251 };
252
253
254 class LensUnit : public LoadClient
255 {
256 public:
257         LensUnit(LensEngine *engine, LensMain *plugin);
258         ~LensUnit();
259         void process_package(LoadPackage *package);
260         void process_spherical_stretch(LensPackage *pkg);
261         void process_spherical_shrink(LensPackage *pkg);
262         void process_rectilinear_stretch(LensPackage *pkg);
263         void process_rectilinear_shrink(LensPackage *pkg);
264         LensEngine *engine;
265         LensMain *plugin;
266 };
267
268 class LensEngine : public LoadServer
269 {
270 public:
271         LensEngine(LensMain *plugin);
272         ~LensEngine();
273
274         void init_packages();
275         LoadClient* new_client();
276         LoadPackage* new_package();
277
278         LensMain *plugin;
279 };
280
281
282 class LensMain : public PluginVClient
283 {
284 public:
285         LensMain(PluginServer *server);
286         ~LensMain();
287
288         PLUGIN_CLASS_MEMBERS(LensConfig)
289         int process_buffer(VFrame *frame,
290                 int64_t start_position,
291                 double frame_rate);
292         int is_realtime();
293         void update_gui();
294         void save_data(KeyFrame *keyframe);
295         void read_data(KeyFrame *keyframe);
296 //      void load_presets();
297 //      void save_presets();
298         int handle_opengl();
299
300         LensEngine *engine;
301         int lock;
302         int current_preset;
303         ArrayList<LensPreset*> presets;
304 };
305
306
307
308 #endif