00001 #include "automation.inc"
00002 #include "panauto.h"
00003 #include "panautos.h"
00004 #include "transportque.inc"
00005
00006 PanAutos::PanAutos(EDL *edl, Track *track)
00007 : Autos(edl, track)
00008 {
00009 type = AUTOMATION_TYPE_PAN;
00010 }
00011
00012 PanAutos::~PanAutos()
00013 {
00014 }
00015
00016
00017 Auto* PanAutos::new_auto()
00018 {
00019 return new PanAuto(edl, this);
00020 }
00021
00022 void PanAutos::get_handle(int &handle_x,
00023 int &handle_y,
00024 int64_t position,
00025 int direction,
00026 PanAuto* &previous,
00027 PanAuto* &next)
00028 {
00029 previous = (PanAuto*)get_prev_auto(position, direction, (Auto* &)previous);
00030 next = (PanAuto*)get_next_auto(position, direction, (Auto* &)next);
00031
00032
00033 if(previous->handle_x == next->handle_x &&
00034 previous->handle_y == next->handle_y)
00035 {
00036 handle_x = previous->handle_x;
00037 handle_y = previous->handle_y;
00038 return;
00039 }
00040
00041
00042 int64_t total = labs(next->position - previous->position);
00043 double fraction;
00044 if(direction == PLAY_FORWARD)
00045 {
00046 fraction = (double)(position - previous->position) / total;
00047 }
00048 else
00049 {
00050 fraction = (double)(previous->position - position) / total;
00051 }
00052
00053 handle_x = (int)(previous->handle_x + (next->handle_x - previous->handle_x) * fraction);
00054 handle_y = (int)(previous->handle_y + (next->handle_y - previous->handle_y) * fraction);
00055 }
00056
00057 void PanAutos::dump()
00058 {
00059 printf(" PanAutos::dump %p\n", this);
00060 printf(" Default: position %ld\n", default_auto->position);
00061 ((PanAuto*)default_auto)->dump();
00062 for(Auto* current = first; current; current = NEXT)
00063 {
00064 printf(" position %ld\n", current->position);
00065 ((PanAuto*)current)->dump();
00066 }
00067 }