You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWTAI-Platform/Src/nmNum/nmData/nmDataTimeStepSetting.cpp

71 lines
2.4 KiB
C++

#include "nmDataTimeStepSetting.h"
nmDataTimeStepSetting::nmDataTimeStepSetting()
{
m_TimeGrowthExponent = nmDataAttribute("Time Growth Exponent", 1.05, "");
m_MinDeltaT = nmDataAttribute("Min Delta T", 0.0008, "hr", UNIT_TYPE_TIME, QStringList(), QStringList() << "hr" << "day" << "min" << "sec" << "ms" << "Week" << "Month" << "Year");
m_MaxDeltaT = nmDataAttribute("Max Delta T", 12.5, "hr", UNIT_TYPE_TIME, QStringList(), QStringList() << "hr" << "day" << "min" << "sec" << "ms" << "Week" << "Month" << "Year");
}
nmDataTimeStepSetting::~nmDataTimeStepSetting()
{
}
rapidjson::Value nmDataTimeStepSetting::ToJsonValue(rapidjson::Document::AllocatorType& allocator) const
{
rapidjson::Value timeStepObj(rapidjson::kObjectType);
// 序列化 nmDataAttribute 类型的成员,通过调用其自身的 ToJsonValue 方法
timeStepObj.AddMember("timeGrowthExponent", m_TimeGrowthExponent.ToJsonValue(allocator), allocator);
timeStepObj.AddMember("minDeltaT", m_MinDeltaT.ToJsonValue(allocator), allocator);
timeStepObj.AddMember("maxDeltaT", m_MaxDeltaT.ToJsonValue(allocator), allocator);
return timeStepObj;
}
void nmDataTimeStepSetting::FromJsonValue(const rapidjson::Value& jsonValue)
{
if(jsonValue.IsObject()) {
// 反序列化 nmDataAttribute 类型的成员,通过调用其自身的 FromJsonValue 方法
if(jsonValue.HasMember("timeGrowthExponent") && jsonValue["timeGrowthExponent"].IsObject()) {
m_TimeGrowthExponent.FromJsonValue(jsonValue["timeGrowthExponent"]);
}
if(jsonValue.HasMember("minDeltaT") && jsonValue["minDeltaT"].IsObject()) {
m_MinDeltaT.FromJsonValue(jsonValue["minDeltaT"]);
}
if(jsonValue.HasMember("maxDeltaT") && jsonValue["maxDeltaT"].IsObject()) {
m_MaxDeltaT.FromJsonValue(jsonValue["maxDeltaT"]);
}
}
}
nmDataAttribute& nmDataTimeStepSetting::getTimeGrowthExponent()
{
return m_TimeGrowthExponent;
}
nmDataAttribute& nmDataTimeStepSetting::getMinDeltaTAttribute()
{
return m_MinDeltaT;
}
nmDataAttribute& nmDataTimeStepSetting::getMaxDeltaTAttribute()
{
return m_MaxDeltaT;
}
void nmDataTimeStepSetting::setTimeGrowthExponent(const nmDataAttribute& attr)
{
m_TimeGrowthExponent = attr;
}
void nmDataTimeStepSetting::setMinDeltaTAttribute(const nmDataAttribute& attr)
{
m_MinDeltaT = attr;
}
void nmDataTimeStepSetting::setMaxDeltaTAttribute(const nmDataAttribute& attr)
{
m_MaxDeltaT = attr;
}