r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / vautomation.C
blobe7f8296f719b0960832b6e9163a1d26f45c508e9
1 #include "bezierautos.h"
2 #include "clip.h"
3 #include "colors.h"
4 #include "edl.h"
5 #include "edlsession.h"
6 #include "floatauto.h"
7 #include "floatautos.h"
8 #include "intauto.h"
9 #include "intautos.h"
10 #include "maskautos.h"
11 #include "overlayframe.inc"
12 #include "transportque.inc"
13 #include "vautomation.h"
16 VAutomation::VAutomation(EDL *edl, Track *track)
17  : Automation(edl, track)
23 VAutomation::~VAutomation()
28 int VAutomation::create_objects()
30         Automation::create_objects();
31         fade_autos = new FloatAutos(edl, track, LTGREY, 0, 100, 100);
32         fade_autos->create_objects();
33         ((FloatAuto*)fade_autos->default_auto)->value = 100;
34         mode_autos = new IntAutos(edl, track);
35         mode_autos->create_objects();
36         mask_autos = new MaskAutos(edl, track);
37         mask_autos->create_objects();
38         ((IntAuto*)mode_autos->default_auto)->value = TRANSFER_NORMAL;
39         camera_autos = new BezierAutos(edl, 
40                                                                         track, 
41                                                                         WHITE, 
42                                                                         0, 
43                                                                         0, 
44                                                                         1, 
45                                                                         edl->session->output_w,
46                                                                         edl->session->output_h);
47         camera_autos->create_objects();
49         projector_autos = new BezierAutos(edl, 
50                                                                         track,
51                                                                         WHITE,
52                                                                         0,
53                                                                         0,
54                                                                         1,
55                                                                         edl->session->output_w,
56                                                                         edl->session->output_h);
57         projector_autos->create_objects();
58         czoom_autos = new FloatAutos(edl, track, LTGREY, 0, 10, 1.0);
59         czoom_autos->create_objects();
60         ((FloatAuto*)czoom_autos->default_auto)->value = 1;
61         pzoom_autos = new FloatAutos(edl, track, LTGREY, 0, 10, 1.0);
62         pzoom_autos->create_objects();
63         ((FloatAuto*)pzoom_autos->default_auto)->value = 1;
65         
66         return 0;
69 int VAutomation::direct_copy_possible(int64_t start, int direction)
71         BezierAuto *before = 0, *after = 0;
72         FloatAuto *previous = 0, *next = 0;
73         float x, y, z;
74         int64_t end = (direction == PLAY_FORWARD) ? (start + 1) : (start - 1);
76         if(!Automation::direct_copy_possible(start, direction))
77                 return 0;
79 //printf("VAutomation::direct_copy_possible 1\n");
80 // Automation is constant
81         double constant;
82         if(fade_autos->automation_is_constant(start, end, direction, constant))
83         {
84 //printf("VAutomation::direct_copy_possible 2 %f\n", fade_autos->get_automation_constant(start, end));
85                 if(!EQUIV(constant, 100))
86                         return 0;
87         }
88         else
89 // Automation varies
90                 return 0;
92 //printf("VAutomation::direct_copy_possible 3\n");
93 // Track must not be muted
94         if(mute_autos->automation_is_constant(start, end))
95         {
96 //printf("VAutomation::direct_copy_possible 4 %d\n", mute_autos->get_automation_constant(start, end));
97                 if(mute_autos->get_automation_constant(start, end) > 0)
98                         return 0;
99         }
100         else
101                 return 0;
103 //printf("VAutomation::direct_copy_possible 5\n");
104 // Projector must be centered in an output channel
105         z = pzoom_autos->get_value(start, direction, previous, next);
106         if(!EQUIV(z, 1)) return 0;
108         projector_autos->get_center(x, 
109                                 y, 
110                                 z, 
111                                 start,
112                                 direction,
113                                 &before, 
114                                 &after);
115 // FIXME develop channel search using track->get_projection
116         if(!EQUIV(x, 0) || 
117                 !EQUIV(y, 0)) return 0;
119 //printf("VAutomation::direct_copy_possible 6 %f %f %f\n", x, y, z);
123 // Camera must be centered
124         previous = next = 0;
125         z = czoom_autos->get_value(start, direction, previous, next);
126         if(!EQUIV(z, 1)) return 0;
130         before = 0;
131         after = 0;
132         camera_autos->get_center(x, 
133                                 y, 
134                                 z, 
135                                 start,
136                                 direction,
137                                 &before, 
138                                 &after);
140 //printf("VAutomation::direct_copy_possible 8 %f %f\n", x, y);
141 // Translation no longer used
142         if(!EQUIV(x, 0) || 
143                 !EQUIV(y, 0)) return 0;
144 //printf("VAutomation::direct_copy_possible 9\n");
146 // No mask must exist
147 //printf("VAutomation::direct_copy_possible 1\n");
148         if(mask_autos->mask_exists(start, direction))
149                 return 0;
150 //printf("VAutomation::direct_copy_possible 7\n");
152         return 1;