Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

floatauto.C

Go to the documentation of this file.
00001 #include "autos.h"
00002 #include "clip.h"
00003 #include "edl.h"
00004 #include "filexml.h"
00005 #include "floatauto.h"
00006 #include "localsession.h"
00007 
00008 FloatAuto::FloatAuto(EDL *edl, FloatAutos *autos)
00009  : Auto(edl, (Autos*)autos)
00010 {
00011         value = 0;
00012         control_in_value = 0;
00013         control_out_value = 0;
00014         control_in_position = 0;
00015         control_out_position = 0;
00016 }
00017 
00018 FloatAuto::~FloatAuto()
00019 {
00020 }
00021 
00022 int FloatAuto::operator==(Auto &that)
00023 {
00024         return identical((FloatAuto*)&that);
00025 }
00026 
00027 
00028 int FloatAuto::operator==(FloatAuto &that)
00029 {
00030         return identical((FloatAuto*)&that);
00031 }
00032 
00033 
00034 int FloatAuto::identical(FloatAuto *src)
00035 {
00036         return EQUIV(value, src->value) &&
00037                 EQUIV(control_in_value, src->control_in_value) &&
00038                 EQUIV(control_out_value, src->control_out_value) &&
00039                 control_in_position == src->control_in_position &&
00040                 control_out_position == src->control_out_position;
00041 }
00042 
00043 float FloatAuto::value_to_percentage()
00044 {
00045         if(!edl) return 0;
00046         float automation_min = edl->local_session->automation_min;
00047         float automation_max = edl->local_session->automation_max;
00048         float automation_range = automation_max - automation_min;
00049         return (value - automation_min) / automation_range;
00050 }
00051 
00052 float FloatAuto::invalue_to_percentage()
00053 {
00054         if(!edl) return 0;
00055         float automation_min = edl->local_session->automation_min;
00056         float automation_max = edl->local_session->automation_max;
00057         float automation_range = automation_max - automation_min;
00058         return (value + control_in_value - automation_min) / 
00059                 automation_range;
00060 }
00061 
00062 float FloatAuto::outvalue_to_percentage()
00063 {
00064         if(!edl) return 0;
00065         float automation_min = edl->local_session->automation_min;
00066         float automation_max = edl->local_session->automation_max;
00067         float automation_range = automation_max - automation_min;
00068         return (value + control_out_value - automation_min) / 
00069                 automation_range;
00070 }
00071 
00072 // float FloatAuto::percentage_to_value(float percentage)
00073 // {
00074 //      return percentage * (autos->max - autos->min) + autos->min;
00075 // }
00076 // 
00077 // float FloatAuto::percentage_to_invalue(float percentage)
00078 // {
00079 //      return percentage * (autos->max - autos->min) + autos->min - value;
00080 // }
00081 // 
00082 // float FloatAuto::percentage_to_outvalue(float percentage)
00083 // {
00084 //      return percentage * (autos->max - autos->min) + autos->min - value;
00085 // }
00086 
00087 void FloatAuto::copy_from(Auto *that)
00088 {
00089         copy_from((FloatAuto*)that);
00090 }
00091 
00092 void FloatAuto::copy_from(FloatAuto *that)
00093 {
00094         Auto::copy_from(that);
00095         this->value = that->value;
00096         this->control_in_value = that->control_in_value;
00097         this->control_out_value = that->control_out_value;
00098         this->control_in_position = that->control_in_position;
00099         this->control_out_position = that->control_out_position;
00100 }
00101 
00102 int FloatAuto::value_to_str(char *string, float value)
00103 {
00104         int j = 0, i = 0;
00105         if(value > 0) 
00106                 sprintf(string, "+%.2f", value);
00107         else
00108                 sprintf(string, "%.2f", value);
00109 
00110 // fix number
00111         if(value == 0)
00112         {
00113                 j = 0;
00114                 string[1] = 0;
00115         }
00116         else
00117         if(value < 1 && value > -1) 
00118         {
00119                 j = 1;
00120                 string[j] = string[0];
00121         }
00122         else 
00123         {
00124                 j = 0;
00125                 string[3] = 0;
00126         }
00127         
00128         while(string[j] != 0) string[i++] = string[j++];
00129         string[i] = 0;
00130 
00131         return 0;
00132 }
00133 
00134 void FloatAuto::copy(int64_t start, int64_t end, FileXML *file, int default_auto)
00135 {
00136         file->tag.set_title("AUTO");
00137         if(default_auto)
00138                 file->tag.set_property("POSITION", 0);
00139         else
00140                 file->tag.set_property("POSITION", position - start);
00141         file->tag.set_property("VALUE", value);
00142         file->tag.set_property("CONTROL_IN_VALUE", control_in_value);
00143         file->tag.set_property("CONTROL_OUT_VALUE", control_out_value);
00144         file->tag.set_property("CONTROL_IN_POSITION", control_in_position);
00145         file->tag.set_property("CONTROL_OUT_POSITION", control_out_position);
00146         file->append_tag();
00147         file->tag.set_title("/AUTO");
00148         file->append_tag();
00149         file->append_newline();
00150 }
00151 
00152 void FloatAuto::load(FileXML *file)
00153 {
00154         value = file->tag.get_property("VALUE", value);
00155         control_in_value = file->tag.get_property("CONTROL_IN_VALUE", control_in_value);
00156         control_out_value = file->tag.get_property("CONTROL_OUT_VALUE", control_out_value);
00157         control_in_position = file->tag.get_property("CONTROL_IN_POSITION", control_in_position);
00158         control_out_position = file->tag.get_property("CONTROL_OUT_POSITION", control_out_position);
00159 }

Generated on Sun Jan 8 13:38:55 2006 for Cinelerra-svn by  doxygen 1.4.4