|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tdoublekeyframe.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tunit.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDoubleKeyframe::TDoubleKeyframe(double frame, double value)
|
|
Toshihiro Shimizu |
890ddd |
: m_type(Linear), m_frame(frame), m_value(value), m_step(1), m_isKeyframe(false), m_speedIn(), m_speedOut(), m_linkedHandles(true), m_expressionText(""), m_fileParams(), m_similarShapeOffset(0), m_unitName("")
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDoubleKeyframe::~TDoubleKeyframe()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TDoubleKeyframe::saveData(TOStream &os) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
static std::map<tdoublekeyframe::type, string=""> typeCodes;</tdoublekeyframe::type,>
|
|
Toshihiro Shimizu |
890ddd |
if (typeCodes.empty()) {
|
|
Toshihiro Shimizu |
890ddd |
typeCodes[None] = "n";
|
|
Toshihiro Shimizu |
890ddd |
typeCodes[Constant] = "C";
|
|
Toshihiro Shimizu |
890ddd |
typeCodes[Linear] = "L";
|
|
Toshihiro Shimizu |
890ddd |
typeCodes[Exponential] = "Exp";
|
|
Toshihiro Shimizu |
890ddd |
typeCodes[SpeedInOut] = "S";
|
|
Toshihiro Shimizu |
890ddd |
typeCodes[EaseInOut] = "E";
|
|
Toshihiro Shimizu |
890ddd |
typeCodes[EaseInOutPercentage] = "Ep";
|
|
Toshihiro Shimizu |
890ddd |
typeCodes[Expression] = "Ex";
|
|
Toshihiro Shimizu |
890ddd |
typeCodes[File] = "F";
|
|
Toshihiro Shimizu |
890ddd |
typeCodes[SimilarShape] = "SimShape";
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
map<string, string=""> attr;</string,>
|
|
Toshihiro Shimizu |
890ddd |
if (!m_linkedHandles)
|
|
Toshihiro Shimizu |
890ddd |
attr["lnk"] = "no";
|
|
Toshihiro Shimizu |
890ddd |
if (m_step > 1)
|
|
Toshihiro Shimizu |
890ddd |
attr["step"] = toString(m_step);
|
|
Toshihiro Shimizu |
890ddd |
os.openChild(typeCodes[m_type], attr);
|
|
Toshihiro Shimizu |
890ddd |
switch (m_prevType) {
|
|
Toshihiro Shimizu |
890ddd |
case Linear:
|
|
Toshihiro Shimizu |
890ddd |
os.child("prev") << m_value;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case SpeedInOut:
|
|
Toshihiro Shimizu |
890ddd |
os.child("prev") << m_value << m_speedIn.x << m_speedIn.y;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case EaseInOut:
|
|
Toshihiro Shimizu |
890ddd |
case EaseInOutPercentage:
|
|
Toshihiro Shimizu |
890ddd |
os.child("prev") << m_value << m_speedIn.x;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
string unitName = m_unitName != "" ? m_unitName : "default";
|
|
Toshihiro Shimizu |
890ddd |
switch (m_type) {
|
|
Toshihiro Shimizu |
890ddd |
case Constant:
|
|
Toshihiro Shimizu |
890ddd |
case Exponential:
|
|
Toshihiro Shimizu |
890ddd |
case Linear:
|
|
Toshihiro Shimizu |
890ddd |
os << m_frame << m_value;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case SpeedInOut:
|
|
Toshihiro Shimizu |
890ddd |
os << m_frame << m_value
|
|
Toshihiro Shimizu |
890ddd |
<< m_speedOut.x << m_speedOut.y;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case EaseInOut:
|
|
Toshihiro Shimizu |
890ddd |
case EaseInOutPercentage:
|
|
Toshihiro Shimizu |
890ddd |
os << m_frame << m_value
|
|
Toshihiro Shimizu |
890ddd |
<< m_speedOut.x;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case Expression:
|
|
Toshihiro Shimizu |
890ddd |
os << m_frame << m_expressionText << unitName;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case SimilarShape:
|
|
Toshihiro Shimizu |
890ddd |
os << m_frame << m_value << m_expressionText << m_similarShapeOffset;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case File:
|
|
Toshihiro Shimizu |
890ddd |
os << m_frame << m_fileParams.m_path << m_fileParams.m_fieldIndex << unitName;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TDoubleKeyframe::loadData(TIStream &is)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
static std::map<string, tdoublekeyframe::type=""> typeCodes;</string,>
|
|
Toshihiro Shimizu |
890ddd |
if (typeCodes.empty()) {
|
|
Toshihiro Shimizu |
890ddd |
typeCodes["n"] = None;
|
|
Toshihiro Shimizu |
890ddd |
typeCodes["C"] = Constant;
|
|
Toshihiro Shimizu |
890ddd |
typeCodes["L"] = Linear;
|
|
Toshihiro Shimizu |
890ddd |
typeCodes["Exp"] = Exponential;
|
|
Toshihiro Shimizu |
890ddd |
typeCodes["S"] = SpeedInOut;
|
|
Toshihiro Shimizu |
890ddd |
typeCodes["E"] = EaseInOut;
|
|
Toshihiro Shimizu |
890ddd |
typeCodes["Ep"] = EaseInOutPercentage;
|
|
Toshihiro Shimizu |
890ddd |
typeCodes["Ex"] = Expression;
|
|
Toshihiro Shimizu |
890ddd |
typeCodes["F"] = File;
|
|
Toshihiro Shimizu |
890ddd |
typeCodes["SimShape"] = SimilarShape;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
string tagName;
|
|
Toshihiro Shimizu |
890ddd |
if (!is.matchTag(tagName))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
std::map<string, tdoublekeyframe::type="">::iterator it =</string,>
|
|
Toshihiro Shimizu |
890ddd |
typeCodes.find(tagName);
|
|
Toshihiro Shimizu |
890ddd |
if (it == typeCodes.end()) {
|
|
Toshihiro Shimizu |
890ddd |
throw TException(tagName + " : unexpected tag");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_type = it->second;
|
|
Toshihiro Shimizu |
890ddd |
is.getTagParam("step", m_step);
|
|
Toshihiro Shimizu |
890ddd |
string lnkValue;
|
|
Toshihiro Shimizu |
890ddd |
if (is.getTagParam("lnk", lnkValue) && lnkValue == "no")
|
|
Toshihiro Shimizu |
890ddd |
m_linkedHandles = false;
|
|
Toshihiro Shimizu |
890ddd |
if (is.matchTag(tagName)) {
|
|
Toshihiro Shimizu |
890ddd |
if (tagName != "prev")
|
|
Toshihiro Shimizu |
890ddd |
throw TException(tagName + " : unexpected tag");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
is >> m_value;
|
|
Toshihiro Shimizu |
890ddd |
if (!is.eos()) {
|
|
Toshihiro Shimizu |
890ddd |
is >> m_speedIn.x;
|
|
Toshihiro Shimizu |
890ddd |
if (!is.eos())
|
|
Toshihiro Shimizu |
890ddd |
is >> m_speedIn.y;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (!is.matchEndTag())
|
|
Toshihiro Shimizu |
890ddd |
throw TException(tagName + " : missing endtag");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
double dummy0, dummy1;
|
|
Toshihiro Shimizu |
890ddd |
switch (m_type) {
|
|
Toshihiro Shimizu |
890ddd |
case Constant:
|
|
Toshihiro Shimizu |
890ddd |
case Linear:
|
|
Toshihiro Shimizu |
890ddd |
case Exponential:
|
|
Toshihiro Shimizu |
890ddd |
is >> m_frame >> m_value;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case SpeedInOut:
|
|
Toshihiro Shimizu |
890ddd |
is >> m_frame >> m_value >> m_speedOut.x >> m_speedOut.y;
|
|
Toshihiro Shimizu |
890ddd |
if (!is.eos())
|
|
Toshihiro Shimizu |
890ddd |
is >> dummy0 >> dummy1; // old and wrong format. used only during the 6.0 release
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case EaseInOut:
|
|
Toshihiro Shimizu |
890ddd |
case EaseInOutPercentage:
|
|
Toshihiro Shimizu |
890ddd |
is >> m_frame >> m_value >> m_speedOut.x;
|
|
Toshihiro Shimizu |
890ddd |
if (!is.eos())
|
|
Toshihiro Shimizu |
890ddd |
is >> dummy0; // old and wrong format. used only during the 6.0 release
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case Expression:
|
|
Toshihiro Shimizu |
890ddd |
is >> m_frame >> m_expressionText >> m_unitName;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case SimilarShape:
|
|
Toshihiro Shimizu |
890ddd |
is >> m_frame >> m_value >> m_expressionText >> m_similarShapeOffset;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case File:
|
|
Toshihiro Shimizu |
890ddd |
is >> m_frame >> m_fileParams.m_path >> m_fileParams.m_fieldIndex >> m_unitName;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (!is.matchEndTag())
|
|
Toshihiro Shimizu |
890ddd |
throw TException(tagName + " : missing endtag");
|
|
Toshihiro Shimizu |
890ddd |
if (m_unitName == "default")
|
|
Toshihiro Shimizu |
890ddd |
m_unitName = "";
|
|
Toshihiro Shimizu |
890ddd |
m_isKeyframe = true;
|
|
Toshihiro Shimizu |
890ddd |
}
|