00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TIL_SEQUENCE_H
00020 #define TIL_SEQUENCE_H
00021
00022 #include "TIL_API.h"
00023 #include <iostream.h>
00024 #include <UT/UT_SmallObject.h>
00025 #include <UT/UT_PtrArray.h>
00026 #include <UT/UT_String.h>
00027
00028 #include "TIL_Defines.h"
00029
00030
00031 #define SEQUENCE_NEAREST 0
00032 #define SEQUENCE_PREVIOUS 1
00033 #define SEQUENCE_NEXT 2
00034
00035 class UT_WorkBuffer;
00036 class TIL_Plane;
00037 class IMG_Stat;
00038
00039 class TIL_API TIL_Sequence :
00040 public UT_SmallObject<TIL_Sequence,
00041 UT_SMALLOBJECT_CLEANPAGES_OFF, 196,
00042 UT_SMALLOBJECT_THREADSAFE_ON>
00043
00044 {
00045 public:
00046 TIL_Sequence();
00047 TIL_Sequence(const TIL_Sequence &);
00048
00049 virtual ~TIL_Sequence();
00050
00051 void reset();
00052 bool isValid() const { return myValidFlag; }
00053 void setValid(bool valid) { myValidFlag = valid; }
00054
00055
00056 TIL_Sequence & operator=(const TIL_Sequence &);
00057
00058 bool operator==(const TIL_Sequence &) const;
00059
00060 void copyFrom(const IMG_Stat &stat);
00061 void copyTo(IMG_Stat &stat) const;
00062
00063
00064 void copyAttributes(const TIL_Sequence &);
00065
00066 void getInfoText(UT_WorkBuffer &info,
00067 bool timedep =true,
00068 bool mark_unscoped = false) const;
00069
00070
00071
00072 bool isSingleImage() const { return mySingleImage;}
00073 void setSingleImage(bool on) { mySingleImage = on; }
00074
00075 float getFrameRate() const { return myRate; }
00076 void setFrameRate(float rate) { myRate = rate; }
00077
00078 int getLength() const { return myLength; }
00079 void setLength(int n) { myLength = n; }
00080
00081 float getStart() const { return myStart; }
00082 void setStart(float start) { myStart = start; }
00083
00084 float getEnd() const { return myStart+myLength-1; }
00085
00086 float getStartTime() const { return (myStart-1) / myRate; }
00087 float getEndTime() const
00088 { return (myStart + myLength -2) / myRate; }
00089
00090
00091
00092 void getRes(int &x,int &y) const
00093 { x = myXRes; y = myYRes; }
00094
00095 void setRes(int x, int y);
00096
00097 void setAspectRatio(float aspect)
00098 { myAspect = (aspect > 0.0f) ? aspect : 1.0f; }
00099 float getAspectRatio() const { return myAspect; }
00100 float getVAspectRatio() const
00101 { return (getInterlace()==INTERLACE_HALF) ? 2.0f:1.0f; }
00102
00103 void getTemporalExtend(TIL_Extend &b, TIL_Extend &a) const
00104 { b = myPreExtend; a = myPostExtend; }
00105
00106 void getTemporalHold(int &before, int &after) const
00107 { before = myPreHold; after = myPostHold; }
00108
00109 void setTemporalExtend(TIL_Extend before, TIL_Extend after)
00110 { myPreExtend = before; myPostExtend = after; }
00111 void setTemporalHold(int before, int after)
00112 { myPreHold = before; myPostHold = after; }
00113
00114
00115
00116
00117 int getImageIndex(float t, int clamp_range = 1,
00118 int round_off = SEQUENCE_NEAREST) const;
00119 float getImageTime(float t, int clamp_range =1,
00120 int round_off = SEQUENCE_NEAREST) const;
00121
00122
00123 int getFrameIndex(float t, int clamp_range = 1,
00124 int round_off = SEQUENCE_NEAREST) const;
00125 float getFrameTime(float t,int clamp_range =1,
00126 int round_off = SEQUENCE_NEAREST) const;
00127
00128
00129 float getIndexTime(int image_index) const;
00130
00131 int checkIndexBounds(int image_index) const;
00132
00133
00134 int getNumPlanes() const { return myPlanes.entries(); }
00135
00136
00137
00138 TIL_Plane * addPlane(const char *name, TIL_DataFormat format,
00139 const char *vn1 = 0,
00140 const char *vn2 = 0,
00141 const char *vn3 = 0,
00142 const char *vn4 = 0,
00143 bool reorder=false);
00144 TIL_Plane * addPlane(const TIL_Plane *plane,
00145 bool reorder=false);
00146
00147
00148 void removePlane(int index);
00149 void removePlane(const char *name);
00150
00151 void clearAllPlanes();
00152
00153
00154 TIL_Plane * getPlane(int index);
00155 const TIL_Plane * getPlane(int index) const;
00156
00157 TIL_Plane * getPlane(const char *name);
00158 const TIL_Plane * getPlane(const char *name) const;
00159
00160 TIL_Plane * getPlaneWithElement(const char *elem_name);
00161 const TIL_Plane * getPlaneWithElement(const char *elem_name) const;
00162
00163 int getPlaneByName(const char *name) const;
00164
00165
00166 void setInterlace(TIL_Interlace i, TIL_Dominance d);
00167 TIL_Interlace getInterlace() const { return myInterlace; }
00168 TIL_Dominance getFieldDominance() const { return myDominance; }
00169
00170 void print(ostream &os);
00171
00172 void bumpColorAlphaToFront();
00173
00174 private:
00175 void makeUnique(UT_String &name);
00176
00177 unsigned myValidFlag :1,
00178 mySingleImage : 1;
00179
00180
00181 int myLength;
00182 float myStart;
00183 float myRate;
00184
00185
00186 int myXRes;
00187 int myYRes;
00188 float myAspect;
00189
00190
00191 TIL_Extend myPreExtend;
00192 TIL_Extend myPostExtend;
00193
00194 int myPreHold;
00195 int myPostHold;
00196
00197
00198 UT_PtrArray<TIL_Plane *> myPlanes;
00199
00200 TIL_Interlace myInterlace;
00201 TIL_Dominance myDominance;
00202 };
00203
00204 #endif