1 #pragma once
2 
3 #ifndef TDOUBLEKEYFRAME_INCLUDED
4 #define TDOUBLEKEYFRAME_INCLUDED
5 
6 #include "tgeometry.h"
7 #include "tfilepath.h"
8 
9 #undef DVAPI
10 #undef DVVAR
11 #ifdef TPARAM_EXPORTS
12 #define DVAPI DV_EXPORT_API
13 #define DVVAR DV_EXPORT_VAR
14 #else
15 #define DVAPI DV_IMPORT_API
16 #define DVVAR DV_IMPORT_VAR
17 #endif
18 
19 class TOStream;
20 class TIStream;
21 class TUnit;
22 
23 class DVAPI TDoubleKeyframe {
24 public:
25   enum Type {
26     None = 0,
27     Constant,
28     Linear,
29     SpeedInOut,
30     EaseInOut,
31     EaseInOutPercentage,
32     Exponential,
33     Expression,
34     File,
35     SimilarShape
36   };
37 
38   class DVAPI FileParams {
39   public:
40     TFilePath m_path;
41     int m_fieldIndex;
FileParams()42     FileParams() : m_path(), m_fieldIndex(0) {}
43   };
44 
isKeyframeBased(int type)45   static inline bool isKeyframeBased(int type) {
46     return type < TDoubleKeyframe::Expression &&
47            type != TDoubleKeyframe::SimilarShape;
48   }
49 
50   // private:
51   Type m_type;
52   Type m_prevType;
53   double m_frame;
54   double m_value;
55   bool m_isKeyframe;
56   int m_step;
57   TPointD m_speedIn, m_speedOut;
58 
59   bool m_linkedHandles;
60   std::string m_expressionText;
61   FileParams m_fileParams;
62   std::string m_unitName;  // file/expression only
63   double m_similarShapeOffset;
64 
65   void saveData(TOStream &os) const;
66   void loadData(TIStream &is);
67 
68 public:
69   TDoubleKeyframe(double frame = 0, double value = 0);
70   ~TDoubleKeyframe();
71 
72   bool operator<(const TDoubleKeyframe &k) const { return m_frame < k.m_frame; }
73 };
74 
75 #endif
76