remove whitespace at eol
[goodguy/history.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 *client,
45                 LensGUI *gui,
46                 LensText *text,
47                 float *output,
48                 int x,
49                 int y,
50                 float min,
51                 float max);
52         int handle_event();
53
54         LensGUI *gui;
55         LensMain *client;
56         LensText *text;
57         float *output;
58 };
59
60 class LensText : public BC_TextBox
61 {
62 public:
63         LensText(LensMain *client,
64                 LensGUI *gui,
65                 LensSlider *slider,
66                 float *output,
67                 int x,
68                 int y);
69         int handle_event();
70
71         LensGUI *gui;
72         LensMain *client;
73         LensSlider *slider;
74         float *output;
75 };
76
77
78 class LensToggle : public BC_CheckBox
79 {
80 public:
81         LensToggle(LensMain *client,
82                 int *output,
83                 int x,
84                 int y,
85                 const char *text);
86         int handle_event();
87
88         LensMain *client;
89         int *output;
90 };
91
92
93 class LensMode : public BC_PopupMenu
94 {
95 public:
96         LensMode(LensMain *plugin,
97                 LensGUI *gui,
98                 int x,
99                 int y);
100         int handle_event();
101         void create_objects();
102         static int calculate_w(LensGUI *gui);
103         static int from_text(char *text);
104         static const char* to_text(int mode);
105         void update(int mode);
106         LensMain *plugin;
107         LensGUI *gui;
108 };
109
110
111 class LensPresets : public BC_PopupMenu
112 {
113 public:
114         LensPresets(LensMain *plugin,
115                 LensGUI *gui,
116                 int x,
117                 int y,
118                 int w);
119         int handle_event();
120         void create_objects();
121         int from_text(LensMain *plugin, char *text);
122         const char* to_text(LensMain *plugin, int preset);
123         void update(int preset);
124         LensMain *plugin;
125         LensGUI *gui;
126 };
127
128 class LensSavePreset : public BC_GenericButton
129 {
130 public:
131         LensSavePreset(LensMain *plugin,
132                 LensGUI *gui,
133                 int x,
134                 int y);
135         int handle_event();
136         LensMain *plugin;
137         LensGUI *gui;
138 };
139
140 class LensDeletePreset : public BC_GenericButton
141 {
142 public:
143         LensDeletePreset(LensMain *plugin,
144                 LensGUI *gui,
145                 int x,
146                 int y);
147         int handle_event();
148         LensMain *plugin;
149         LensGUI *gui;
150 };
151
152 class LensPresetText : public BC_TextBox
153 {
154 public:
155         LensPresetText(LensMain *plugin,
156                 LensGUI *gui,
157                 int x,
158                 int y,
159                 int w);
160         int handle_event();
161         LensMain *plugin;
162         LensGUI *gui;
163 };
164
165 class LensGUI : public PluginClientWindow
166 {
167 public:
168         LensGUI(LensMain *client);
169         ~LensGUI();
170
171         void create_objects();
172
173         LensMain *client;
174         LensSlider *fov_slider[FOV_CHANNELS];
175         LensText *fov_text[FOV_CHANNELS];
176         LensSlider *aspect_slider;
177         LensText *aspect_text;
178         LensSlider *radius_slider;
179         LensText *radius_text;
180         LensSlider *centerx_slider;
181         LensText *centerx_text;
182         LensSlider *centery_slider;
183         LensText *centery_text;
184         LensMode *mode;
185 //      LensPresets *presets;
186 //      LensSavePreset *save_preset;
187 //      LensDeletePreset *delete_preset;
188 //      LensPresetText *preset_text;
189         LensToggle *reverse;
190         LensToggle *draw_guides;
191 };
192
193 class LensConfig
194 {
195 public:
196         LensConfig();
197         int equivalent(LensConfig &that);
198         void copy_from(LensConfig &that);
199         void interpolate(LensConfig &prev,
200                 LensConfig &next,
201                 int64_t prev_frame,
202                 int64_t next_frame,
203                 int64_t current_frame);
204         void boundaries();
205         float fov[FOV_CHANNELS];
206         int lock;
207         float aspect;
208         float radius;
209         float center_x;
210         float center_y;
211         int draw_guides;
212         int mode;
213         enum
214         {
215                 SHRINK,
216                 STRETCH,
217                 RECTILINEAR_SHRINK,
218                 RECTILINEAR_STRETCH
219         };
220 };
221
222 class LensPreset
223 {
224 public:
225         char title[BCTEXTLEN];
226         float fov[FOV_CHANNELS];
227         float aspect;
228         float radius;
229         int mode;
230 };
231
232
233
234
235
236 class LensPackage : public LoadPackage
237 {
238 public:
239         LensPackage();
240         int row1, row2;
241 };
242
243
244 class LensUnit : public LoadClient
245 {
246 public:
247         LensUnit(LensEngine *engine, LensMain *plugin);
248         ~LensUnit();
249         void process_package(LoadPackage *package);
250         void process_stretch(LensPackage *pkg);
251         void process_shrink(LensPackage *pkg);
252         void process_rectilinear_stretch(LensPackage *pkg);
253         void process_rectilinear_shrink(LensPackage *pkg);
254         LensEngine *engine;
255         LensMain *plugin;
256 };
257
258 class LensEngine : public LoadServer
259 {
260 public:
261         LensEngine(LensMain *plugin);
262         ~LensEngine();
263
264         void init_packages();
265         LoadClient* new_client();
266         LoadPackage* new_package();
267
268         LensMain *plugin;
269 };
270
271 class LensMain : public PluginVClient
272 {
273 public:
274         LensMain(PluginServer *server);
275         ~LensMain();
276
277         PLUGIN_CLASS_MEMBERS(LensConfig)
278         int process_buffer(VFrame *frame,
279                 int64_t start_position,
280                 double frame_rate);
281         int is_realtime();
282         void update_gui();
283         void save_data(KeyFrame *keyframe);
284         void read_data(KeyFrame *keyframe);
285 //      void load_presets();
286 //      void save_presets();
287         int handle_opengl();
288
289         LensEngine *engine;
290         int lock;
291         int current_preset;
292         ArrayList<LensPreset*> presets;
293 };
294
295
296
297 #endif