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