r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / plugins / perspective / perspective.h
blob737c3cd043f2294d6149a2e4f8da9a016b026d4a
1 #include <math.h>
2 #include <stdint.h>
3 #include <string.h>
5 #include "bcdisplayinfo.h"
6 #include "clip.h"
7 #include "defaults.h"
8 #include "filexml.h"
9 #include "keyframe.h"
10 #include "loadbalance.h"
11 #include "picon_png.h"
12 #include "pluginvclient.h"
13 #include "vframe.h"
15 class PerspectiveMain;
16 class PerspectiveWindow;
17 class PerspectiveEngine;
21 #define OVERSAMPLE 2
23 class PerspectiveConfig
25 public:
26 PerspectiveConfig();
28 int equivalent(PerspectiveConfig &that);
29 void copy_from(PerspectiveConfig &that);
30 void interpolate(PerspectiveConfig &prev,
31 PerspectiveConfig &next,
32 int64_t prev_frame,
33 int64_t next_frame,
34 int64_t current_frame);
36 float x1, y1, x2, y2, x3, y3, x4, y4;
37 int mode;
38 int window_w, window_h;
39 int current_point;
40 enum
42 PERSPECTIVE,
43 SHEER,
44 STRETCH
46 int forward;
51 class PerspectiveCanvas : public BC_SubWindow
53 public:
54 PerspectiveCanvas(PerspectiveMain *plugin,
55 int x,
56 int y,
57 int w,
58 int w);
59 int button_press_event();
60 int button_release_event();
61 int cursor_motion_event();
62 int state;
64 enum
66 NONE,
67 DRAG,
68 DRAG_FULL,
69 ZOOM
72 int start_cursor_x, start_cursor_y;
73 float start_x1, start_y1;
74 float start_x2, start_y2;
75 float start_x3, start_y3;
76 float start_x4, start_y4;
77 PerspectiveMain *plugin;
80 class PerspectiveCoord : public BC_TumbleTextBox
82 public:
83 PerspectiveCoord(PerspectiveWindow *gui,
84 PerspectiveMain *plugin,
85 int x,
86 int y,
87 float value,
88 int is_x);
89 int handle_event();
90 PerspectiveMain *plugin;
91 int is_x;
94 class PerspectiveReset : public BC_GenericButton
96 public:
97 PerspectiveReset(PerspectiveMain *plugin,
98 int x,
99 int y);
100 int handle_event();
101 PerspectiveMain *plugin;
104 class PerspectiveMode : public BC_Radial
106 public:
107 PerspectiveMode(PerspectiveMain *plugin,
108 int x,
109 int y,
110 int value,
111 char *text);
112 int handle_event();
113 PerspectiveMain *plugin;
114 int value;
117 class PerspectiveDirection : public BC_Radial
119 public:
120 PerspectiveDirection(PerspectiveMain *plugin,
121 int x,
122 int y,
123 int value,
124 char *text);
125 int handle_event();
126 PerspectiveMain *plugin;
127 int value;
130 class PerspectiveWindow : public BC_Window
132 public:
133 PerspectiveWindow(PerspectiveMain *plugin, int x, int y);
134 ~PerspectiveWindow();
136 int create_objects();
137 int close_event();
138 int resize_event(int x, int y);
139 void update_canvas();
140 void update_mode();
141 void update_coord();
142 void calculate_canvas_coords(int &x1,
143 int &y1,
144 int &x2,
145 int &y2,
146 int &x3,
147 int &y3,
148 int &x4,
149 int &y4);
151 PerspectiveCanvas *canvas;
152 PerspectiveCoord *x, *y;
153 PerspectiveReset *reset;
154 PerspectiveMode *mode_perspective, *mode_sheer, *mode_stretch;
155 PerspectiveMain *plugin;
156 PerspectiveDirection *forward, *reverse;
161 PLUGIN_THREAD_HEADER(PerspectiveMain, PerspectiveThread, PerspectiveWindow)
164 class PerspectiveMain : public PluginVClient
166 public:
167 PerspectiveMain(PluginServer *server);
168 ~PerspectiveMain();
170 int process_realtime(VFrame *input_ptr, VFrame *output_ptr);
171 int is_realtime();
172 int load_defaults();
173 int save_defaults();
174 void save_data(KeyFrame *keyframe);
175 void read_data(KeyFrame *keyframe);
176 void update_gui();
178 PLUGIN_CLASS_MEMBERS(PerspectiveConfig, PerspectiveThread)
180 float get_current_x();
181 float get_current_y();
182 void set_current_x(float value);
183 void set_current_y(float value);
184 VFrame *input, *output;
185 VFrame *temp;
186 PerspectiveEngine *engine;
190 class PerspectiveMatrix
192 public:
193 PerspectiveMatrix();
194 void identity();
195 void translate(double x, double y);
196 void scale(double x, double y);
197 // Result is put in dst
198 void multiply(PerspectiveMatrix *dst);
199 void copy_from(PerspectiveMatrix *src);
200 void invert(PerspectiveMatrix *dst);
201 void transform_point(float x, float y, float *newx, float *newy);
202 double determinant();
203 void dump();
204 double values[3][3];
207 class PerspectivePackage : public LoadPackage
209 public:
210 PerspectivePackage();
211 int y1, y2;
214 class PerspectiveUnit : public LoadClient
216 public:
217 PerspectiveUnit(PerspectiveEngine *server, PerspectiveMain *plugin);
218 void process_package(LoadPackage *package);
219 void calculate_matrix(
220 double in_x1,
221 double in_y1,
222 double in_x2,
223 double in_y2,
224 double out_x1,
225 double out_y1,
226 double out_x2,
227 double out_y2,
228 double out_x3,
229 double out_y3,
230 double out_x4,
231 double out_y4,
232 PerspectiveMatrix *result);
233 float PerspectiveUnit::transform_cubic(float dx,
234 float jm1,
235 float j,
236 float jp1,
237 float jp2);
238 PerspectiveEngine *server;
239 PerspectiveMain *plugin;
242 class PerspectiveEngine : public LoadServer
244 public:
245 PerspectiveEngine(PerspectiveMain *plugin,
246 int total_clients,
247 int total_packages);
248 void init_packages();
249 LoadClient* new_client();
250 LoadPackage* new_package();
251 PerspectiveMain *plugin;