add auto zoombar/status color, fix 3 batchrender boobies, rotate plugin tweaks, add...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / spherecam / spherecam.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2017 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 FUSE360_H
23 #define FUSE360_H
24
25
26 #include "affine.inc"
27 #include "bchash.inc"
28 #include "guicast.h"
29 #include "loadbalance.h"
30 #include "pluginvclient.h"
31 #include "thread.h"
32
33
34 class SphereCamEngine;
35 class SphereCamGUI;
36 class SphereCamMain;
37 class SphereCamText;
38
39 #define EYES 2
40
41 class SphereCamSlider : public BC_FSlider
42 {
43 public:
44         SphereCamSlider(SphereCamMain *client, 
45                 SphereCamGUI *gui,
46                 SphereCamText *text,
47                 float *output, 
48                 int x, 
49                 int y, 
50                 float min,
51                 float max);
52         int handle_event();
53
54         SphereCamGUI *gui;
55         SphereCamMain *client;
56         SphereCamText *text;
57         float *output;
58 };
59
60 class SphereCamText : public BC_TextBox
61 {
62 public:
63         SphereCamText(SphereCamMain *client, 
64                 SphereCamGUI *gui,
65                 SphereCamSlider *slider,
66                 float *output, 
67                 int x, 
68                 int y);
69         int handle_event();
70
71         SphereCamGUI *gui;
72         SphereCamMain *client;
73         SphereCamSlider *slider;
74         float *output;
75 };
76
77
78 class SphereCamToggle : public BC_CheckBox
79 {
80 public:
81         SphereCamToggle(SphereCamMain *client, 
82                 int *output, 
83                 int x, 
84                 int y,
85                 const char *text);
86         int handle_event();
87
88         SphereCamMain *client;
89         int *output;
90 };
91
92
93 class SphereCamMode : public BC_PopupMenu
94 {
95 public:
96         SphereCamMode(SphereCamMain *plugin,  
97                 SphereCamGUI *gui,
98                 int x,
99                 int y);
100         int handle_event();
101         void create_objects();
102         static int calculate_w(SphereCamGUI *gui);
103         static int from_text(char *text);
104         static const char* to_text(int mode);
105         void update(int mode);
106         SphereCamMain *plugin;
107         SphereCamGUI *gui;
108 };
109
110
111 class SphereCamGUI : public PluginClientWindow
112 {
113 public:
114         SphereCamGUI(SphereCamMain *client);
115         ~SphereCamGUI();
116         
117         void create_objects();
118
119         SphereCamMain *client;
120         SphereCamToggle *enabled[EYES];
121         SphereCamSlider *fov_slider[EYES];
122         SphereCamText *fov_text[EYES];
123         SphereCamSlider *radius_slider[EYES];
124         SphereCamText *radius_text[EYES];
125         SphereCamSlider *centerx_slider[EYES];
126         SphereCamText *centerx_text[EYES];
127         SphereCamSlider *centery_slider[EYES];
128         SphereCamText *centery_text[EYES];
129         SphereCamSlider *rotatex_slider[EYES];
130         SphereCamText *rotatex_text[EYES];
131         SphereCamSlider *rotatey_slider[EYES];
132         SphereCamText *rotatey_text[EYES];
133         SphereCamSlider *rotatez_slider[EYES];
134         SphereCamText *rotatez_text[EYES];
135         SphereCamSlider *feather_slider;
136         SphereCamText *feather_text;
137         
138         SphereCamMode *mode;
139         SphereCamToggle *draw_guides;
140 };
141
142 class SphereCamConfig
143 {
144 public:
145         SphereCamConfig();
146         int equivalent(SphereCamConfig &that);
147         void copy_from(SphereCamConfig &that);
148         void interpolate(SphereCamConfig &prev, 
149                 SphereCamConfig &next, 
150                 int64_t prev_frame, 
151                 int64_t next_frame, 
152                 int64_t current_frame);
153         void boundaries();
154
155
156         int enabled[EYES];
157 // degrees 1-359
158         float fov[EYES];
159 // radius of each eye 1-150
160         float radius[EYES];
161 // center of 2 eyes  0-100
162         float center_x[EYES];
163         float center_y[EYES];
164 // rotation  0-359
165         float rotate_x[EYES];
166         float rotate_y[EYES];
167         float rotate_z[EYES];
168 // amount to feather eye edges 0-50
169         float feather;
170         int draw_guides;
171         int mode;
172         enum
173         {
174 // draw guides only
175                 DO_NOTHING,
176 // the standard algorithm
177                 EQUIRECT,
178 // alignment only
179                 ALIGN,
180         };
181 };
182
183
184
185
186
187 class SphereCamPackage : public LoadPackage
188 {
189 public:
190         SphereCamPackage();
191         int row1, row2;
192 };
193
194
195 class SphereCamUnit : public LoadClient
196 {
197 public:
198         SphereCamUnit(SphereCamEngine *engine, SphereCamMain *plugin);
199         ~SphereCamUnit();
200         
201         
202         void process_package(LoadPackage *package);
203         void process_equirect(SphereCamPackage *pkg);
204         void process_align(SphereCamPackage *pkg);
205         double calculate_max_z(double a, double r);
206
207         
208         SphereCamEngine *engine;
209         SphereCamMain *plugin;
210 };
211
212 class SphereCamEngine : public LoadServer
213 {
214 public:
215         SphereCamEngine(SphereCamMain *plugin);
216         ~SphereCamEngine();
217         
218         void init_packages();
219         LoadClient* new_client();
220         LoadPackage* new_package();
221         
222         SphereCamMain *plugin;
223 };
224
225 class SphereCamMain : public PluginVClient
226 {
227 public:
228         SphereCamMain(PluginServer *server);
229         ~SphereCamMain();
230
231         PLUGIN_CLASS_MEMBERS2(SphereCamConfig)
232         int process_buffer(VFrame *frame,
233                 int64_t start_position,
234                 double frame_rate);
235         void draw_feather(int left, int right, int eye, int y);
236         int is_realtime();
237         void update_gui();
238         void save_data(KeyFrame *keyframe);
239         void read_data(KeyFrame *keyframe);
240         void calculate_extents();
241         double calculate_max_z(double a, int r);
242
243 // config values converted to pixels
244         int w;
245         int h;
246
247 // the center of the output regions, shifted by the rotations
248         int output_x[EYES];
249         int output_y[EYES];
250 // The output of each eye is split into 2 halves so it can wrap around
251         int out_x1[EYES];
252         int out_y1[EYES];
253         int out_x2[EYES];
254         int out_y2[EYES];
255         int out_x3[EYES];
256         int out_y3[EYES];
257         int out_x4[EYES];
258         int out_y4[EYES];
259 // the center of the input regions
260         int input_x[EYES];
261         int input_y[EYES];
262 // radius of the input regions for drawing the guide only
263         int radius[EYES];
264 // pixels to add to the output regions
265         int feather;
266
267         SphereCamEngine *engine;
268         AffineEngine *affine;
269 };
270
271
272
273 #endif