bunch-o compiler bitch'n
[goodguy/history.git] / cinelerra-5.1 / plugins / perspective / perspective.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 #include <math.h>
23 #include <stdint.h>
24 #include <string.h>
25
26 #include "affine.inc"
27 #include "clip.h"
28 #include "bchash.h"
29 #include "filexml.h"
30 #include "keyframe.h"
31 #include "loadbalance.h"
32 #include "pluginvclient.h"
33 #include "vframe.h"
34
35
36 class PerspectiveConfig;
37 class PerspectiveCanvas;
38 class PerspectiveCoord;
39 class PerspectiveReset;
40 class PerspectiveMode;
41 class PerspectiveDirection;
42 class PerspectiveAffine;
43 class PerspectiveAffineItem;
44 class PerspectiveWindow;
45 class PerspectiveMain;
46
47 class PerspectiveConfig
48 {
49 public:
50         PerspectiveConfig();
51
52         int equivalent(PerspectiveConfig &that);
53         void copy_from(PerspectiveConfig &that);
54         void interpolate(PerspectiveConfig &prev, PerspectiveConfig &next,
55                 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
56
57         float x1, y1, x2, y2, x3, y3, x4, y4;
58         int mode, smoothing;
59         int window_w, window_h;
60         int current_point;
61         int forward;
62 };
63
64
65
66 class PerspectiveCanvas : public BC_SubWindow
67 {
68 public:
69         PerspectiveCanvas(PerspectiveMain *plugin,
70                 int x, int y, int w, int h);
71         int button_press_event();
72         int button_release_event();
73         int cursor_motion_event();
74
75         int state;
76         enum { NONE, DRAG, DRAG_FULL, ZOOM };
77
78         int start_cursor_x, start_cursor_y;
79         float start_x1, start_y1;
80         float start_x2, start_y2;
81         float start_x3, start_y3;
82         float start_x4, start_y4;
83         PerspectiveMain *plugin;
84 };
85
86 class PerspectiveCoord : public BC_TumbleTextBox
87 {
88 public:
89         PerspectiveCoord(PerspectiveWindow *gui,
90                 PerspectiveMain *plugin,
91                 int x, int y, float value, int is_x);
92         int handle_event();
93         PerspectiveMain *plugin;
94         int is_x;
95 };
96
97 class PerspectiveReset : public BC_GenericButton
98 {
99 public:
100         PerspectiveReset(PerspectiveMain *plugin,
101                 int x, int y);
102         int handle_event();
103         PerspectiveMain *plugin;
104 };
105
106 class PerspectiveMode : public BC_Radial
107 {
108 public:
109         PerspectiveMode(PerspectiveMain *plugin,
110                 int x, int y, int value, char *text);
111         int handle_event();
112         PerspectiveMain *plugin;
113         int value;
114 };
115
116 class PerspectiveDirection : public BC_Radial
117 {
118 public:
119         PerspectiveDirection(PerspectiveMain *plugin,
120                 int x, int y, int value, char *text);
121         int handle_event();
122         PerspectiveMain *plugin;
123         int value;
124 };
125
126 class PerspectiveAffine : public BC_PopupMenu
127 {
128         static const int n_modes = AffineEngine::AF_MODES;
129         const char *affine_modes[n_modes];
130         PerspectiveAffineItem *affine_items[n_modes];
131 public:
132         PerspectiveAffine(PerspectiveWindow *gui, int x, int y);
133         ~PerspectiveAffine();
134
135         void create_objects();
136         void update(int mode, int send=1);
137         void affine_item(int id);
138
139         PerspectiveWindow *gui;
140         int mode;
141 };
142
143 class PerspectiveAffineItem : public BC_MenuItem
144 {
145 public:
146         PerspectiveAffineItem(const char *txt, int id)
147         : BC_MenuItem(txt) { this->id = id; }
148
149         int handle_event();
150         PerspectiveWindow *gui;
151         int id;
152 };
153
154
155
156 class PerspectiveWindow : public PluginClientWindow
157 {
158 public:
159         PerspectiveWindow(PerspectiveMain *plugin);
160         ~PerspectiveWindow();
161
162         void create_objects();
163         int resize_event(int x, int y);
164         void update_canvas();
165         void update_mode();
166         void update_coord();
167         void calculate_canvas_coords(
168                 int &x1, int &y1, int &x2, int &y2,
169                 int &x3, int &y3, int &x4, int &y4);
170
171         PerspectiveCanvas *canvas;
172         PerspectiveCoord *x, *y;
173         PerspectiveReset *reset;
174         PerspectiveMode *mode_perspective, *mode_sheer, *mode_stretch;
175         PerspectiveAffine *affine;
176         PerspectiveMain *plugin;
177         PerspectiveDirection *forward, *reverse;
178 };
179
180
181 class PerspectiveMain : public PluginVClient
182 {
183 public:
184         PerspectiveMain(PluginServer *server);
185         ~PerspectiveMain();
186
187         int process_buffer(VFrame *frame,
188                 int64_t start_position,
189                 double frame_rate);
190         int is_realtime();
191         void save_data(KeyFrame *keyframe);
192         void read_data(KeyFrame *keyframe);
193         void update_gui();
194         int handle_opengl();
195
196         PLUGIN_CLASS_MEMBERS(PerspectiveConfig)
197
198         float get_current_x();
199         float get_current_y();
200         void set_current_x(float value);
201         void set_current_y(float value);
202         VFrame *input, *output;
203         VFrame *temp;
204         AffineEngine *engine;
205 };
206
207