Add float overload to VariableData and use it in visual_tool.cpp rather than pretending that float* and double* are the same thing.

Originally committed to SVN as r4623.
This commit is contained in:
Thomas Goyne 2010-06-27 07:53:31 +00:00
parent 75d9ecd14a
commit cd0378519d
2 changed files with 18 additions and 7 deletions

View File

@ -76,6 +76,9 @@ template<class T> static inline VariableDataType get_type();
template<> inline VariableDataType get_type<int>() {
return VARDATA_INT;
}
template<> inline VariableDataType get_type<float>() {
return VARDATA_FLOAT;
}
template<> inline VariableDataType get_type<double>() {
return VARDATA_FLOAT;
}
@ -99,6 +102,7 @@ void VariableData::Set(T param) {
value = new T(param);
}
template void VariableData::Set<int>(int param);
template void VariableData::Set<float>(float param);
template void VariableData::Set<double>(double param);
template void VariableData::Set<bool>(bool param);
template void VariableData::Set(wxString param);
@ -151,12 +155,19 @@ template<> int VariableData::Get<int>() const {
}
/// @brief Reads as a float
/// @return
/// @return
template<> float VariableData::Get<float>() const {
if (!value) throw _T("Null parameter");
if (type == VARDATA_FLOAT) return (float)*value_float;
if (type == VARDATA_INT) return (float)(*value_int);
if (type == VARDATA_TEXT) return 0.0f;
throw _T("Wrong parameter type, should be float");
}
template<> double VariableData::Get<double>() const {
if (!value) throw _T("Null parameter");
if (type == VARDATA_FLOAT) return *value_float;
if (type == VARDATA_INT) return (float)(*value_int);
if (type == VARDATA_TEXT) return 0.0f;
if (type == VARDATA_TEXT) return 0.0;
throw _T("Wrong parameter type, should be float");
}

View File

@ -550,9 +550,9 @@ void VisualTool<FeatureType>::GetLineRotation(AssDialogue *diag,float &rx,float
diag->ParseASSTags();
get_value<double>(diag, L"\\frx", 1, &rx);
get_value<double>(diag, L"\\fry", 1, &ry);
get_value<double>(diag, L"\\frz", 1, &rz);
get_value<float>(diag, L"\\frx", 1, &rx);
get_value<float>(diag, L"\\fry", 1, &ry);
get_value<float>(diag, L"\\frz", 1, &rz);
diag->ClearBlocks();
}
@ -569,8 +569,8 @@ void VisualTool<FeatureType>::GetLineScale(AssDialogue *diag,float &scalX,float
diag->ParseASSTags();
get_value<double>(diag, L"\\fscx", 1, &scalX);
get_value<double>(diag, L"\\fscy", 1, &scalY);
get_value<float>(diag, L"\\fscx", 1, &scalX);
get_value<float>(diag, L"\\fscy", 1, &scalY);
diag->ClearBlocks();
}