r870: Merge 2.1:
[cinelerra_cv.git] / cinelerra / vautomation.C
blob3cd953b3e845a318d5c7b402d5d025e301ffd6e5
1 #include "clip.h"
2 #include "colors.h"
3 #include "edl.h"
4 #include "edlsession.h"
5 #include "floatauto.h"
6 #include "floatautos.h"
7 #include "intauto.h"
8 #include "intautos.h"
9 #include "maskautos.h"
10 #include "overlayframe.inc"
11 #include "transportque.inc"
12 #include "vautomation.h"
15 VAutomation::VAutomation(EDL *edl, Track *track)
16  : Automation(edl, track)
22 VAutomation::~VAutomation()
27 int VAutomation::create_objects()
29         Automation::create_objects();
31         autos[AUTOMATION_FADE] = new FloatAutos(edl, track, 100);
32         autos[AUTOMATION_FADE]->create_objects();
34         autos[AUTOMATION_MODE] = new IntAutos(edl, track, TRANSFER_NORMAL);
35         autos[AUTOMATION_MODE]->create_objects();
37         autos[AUTOMATION_MASK] = new MaskAutos(edl, track);
38         autos[AUTOMATION_MASK]->create_objects();
40         autos[AUTOMATION_CAMERA_X] = new FloatAutos(edl, track, 0.0);
41         autos[AUTOMATION_CAMERA_X]->create_objects();
43         autos[AUTOMATION_CAMERA_Y] = new FloatAutos(edl, track, 0.0);
44         autos[AUTOMATION_CAMERA_Y]->create_objects();
46         autos[AUTOMATION_PROJECTOR_X] = new FloatAutos(edl, track, 0.0);
47         autos[AUTOMATION_PROJECTOR_X]->create_objects();
49         autos[AUTOMATION_PROJECTOR_Y] = new FloatAutos(edl, track, 0.0);
50         autos[AUTOMATION_PROJECTOR_Y]->create_objects();
52         autos[AUTOMATION_CAMERA_Z] = new FloatAutos(edl, track, 1.0);
53         autos[AUTOMATION_CAMERA_Z]->create_objects();
55         autos[AUTOMATION_PROJECTOR_Z] = new FloatAutos(edl, track, 1.0);
56         autos[AUTOMATION_PROJECTOR_Z]->create_objects();
58 //      autos[AUTOMATION_NUDGE] = new FloatAutos(edl, track, 0.0);
59 //      autos[AUTOMATION_NUDGE]->create_objects();
61         return 0;
64 int VAutomation::direct_copy_possible(int64_t start, int direction)
66         int64_t end = (direction == PLAY_FORWARD) ? (start + 1) : (start - 1);
68         if(!Automation::direct_copy_possible(start, direction))
69                 return 0;
71 // Automation is constant
72         double constant;
73         if(((FloatAutos*)autos[AUTOMATION_FADE])->automation_is_constant(
74                 start, 1, direction, constant))
75         {
76                 if(!EQUIV(constant, 100))
77                         return 0;
78         }
79         else
80 // Automation varies
81                 return 0;
83 // Track must not be muted
84         if(autos[AUTOMATION_MUTE]->automation_is_constant(start, end))
85         {
86                 if(autos[AUTOMATION_MUTE]->get_automation_constant(start, end) > 0)
87                         return 0;
88         }
89         else
90                 return 0;
92 // Projector must be centered.
93         FloatAuto *previous = 0, *next = 0;
94         float z = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_Z])->get_value(
95                 start, direction, previous, next);
96         if(!EQUIV(z, 1)) return 0;
98         previous = 0;
99         next = 0;
100         float x = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_X])->get_value(start,
101                                 direction,
102                                 previous, 
103                                 next);
104         if(!EQUIV(x, 0)) return 0;
105         previous = 0;
106         next = 0;
107         float y = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_Y])->get_value(start,
108                                 direction,
109                                 previous, 
110                                 next);
111         if(!EQUIV(y, 0)) return 0;
116 // Camera must be centered
117         previous = 0;
118         next = 0;
119         z = ((FloatAutos*)autos[AUTOMATION_CAMERA_Z])->get_value(
120                 start, 
121                 direction, 
122                 previous, 
123                 next);
124         if(!EQUIV(z, 1)) return 0;
128         previous = 0;
129         next = 0;
130         x = ((FloatAutos*)autos[AUTOMATION_CAMERA_X])->get_value(start,
131                                 direction,
132                                 previous, 
133                                 next);
134         if(!EQUIV(x, 0)) return 0;
136         previous = 0;
137         next = 0;
138         y = ((FloatAutos*)autos[AUTOMATION_CAMERA_Y])->get_value(start,
139                                 direction,
140                                 previous, 
141                                 next);
143         if(!EQUIV(y, 0)) return 0;
145 // No mask must exist
146         if(((MaskAutos*)autos[AUTOMATION_MASK])->mask_exists(start, direction))
147                 return 0;
149         return 1;
152 void VAutomation::get_projector(float *x, 
153         float *y, 
154         float *z, 
155         int64_t position,
156         int direction)
158         FloatAuto *before, *after;
159         before = 0;
160         after = 0;
161         *x = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_X])->get_value(position,
162                 direction,
163                 before,
164                 after);
165         before = 0;
166         after = 0;
167         *y = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_Y])->get_value(position,
168                 direction,
169                 before,
170                 after);
171         before = 0;
172         after = 0;
173         *z = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_Z])->get_value(position,
174                 direction,
175                 before,
176                 after);
180 void VAutomation::get_camera(float *x, 
181         float *y, 
182         float *z, 
183         int64_t position,
184         int direction)
186         FloatAuto *before, *after;
187         before = 0;
188         after = 0;
189         *x = ((FloatAutos*)autos[AUTOMATION_CAMERA_X])->get_value(position,
190                 direction,
191                 before,
192                 after);
193         before = 0;
194         after = 0;
195         *y = ((FloatAutos*)autos[AUTOMATION_CAMERA_Y])->get_value(position,
196                 direction,
197                 before,
198                 after);
199         before = 0;
200         after = 0;
201         *z = ((FloatAutos*)autos[AUTOMATION_CAMERA_Z])->get_value(position,
202                 direction,
203                 before,
204                 after);