保存当前模型,打开时加载

feature/nm-para-property-20260615
lvjunjie 3 weeks ago
parent c157bbf794
commit dc22f56c9c

@ -3144,6 +3144,11 @@ bool nmDataAnalyzeManager::ReadProjectData(const QString & filePath)
m_pTimeStep->FromJsonValue(doc["TimeStep"]); m_pTimeStep->FromJsonValue(doc["TimeStep"]);
} }
// 恢复当前求解器模型类型
if(doc.HasMember("SolverModelType") && doc["SolverModelType"].IsInt()) {
m_eSolverModelType = static_cast<NM_SOLVER_MODEL_TYPE>(doc["SolverModelType"].GetInt());
}
return true; return true;
} }
@ -3318,6 +3323,9 @@ bool nmDataAnalyzeManager::WriteProjectData(const QString & filePath)
doc.AddMember("TimeStep", timeStepJson, allocator); doc.AddMember("TimeStep", timeStepJson, allocator);
} }
// 保存当前求解器模型类型
doc.AddMember("SolverModelType", static_cast<int>(m_eSolverModelType), allocator);
// 将最终构建好的 Document 写入文件 // 将最终构建好的 Document 写入文件
if(!nmDataJsonTools::WriteDomToFile(doc, filePath)) { if(!nmDataJsonTools::WriteDomToFile(doc, filePath)) {
qDebug() << "Error: Failed to write DOM to file:" << filePath; qDebug() << "Error: Failed to write DOM to file:" << filePath;

@ -131,6 +131,9 @@ rapidjson::Value nmDataReservoir::ToJsonValue(rapidjson::Document::AllocatorType
reservoirObject.AddMember("Sgi", m_Sgi.ToJsonValue(allocator), allocator); reservoirObject.AddMember("Sgi", m_Sgi.ToJsonValue(allocator), allocator);
reservoirObject.AddMember("Swi", m_Swi.ToJsonValue(allocator), allocator); reservoirObject.AddMember("Swi", m_Swi.ToJsonValue(allocator), allocator);
// 多相流类型
reservoirObject.AddMember("PhaseType", static_cast<int>(m_ePhaseType), allocator);
return reservoirObject; // 返回序列化后的 RapidJSON Value return reservoirObject; // 返回序列化后的 RapidJSON Value
} }
@ -204,6 +207,11 @@ void nmDataReservoir::FromJsonValue(const rapidjson::Value& jsonValue)
if (jsonValue.HasMember("Swi") && jsonValue["Swi"].IsObject()) { if (jsonValue.HasMember("Swi") && jsonValue["Swi"].IsObject()) {
m_Swi.FromJsonValue(jsonValue["Swi"]); m_Swi.FromJsonValue(jsonValue["Swi"]);
} }
// 多相流类型
if (jsonValue.HasMember("PhaseType") && jsonValue["PhaseType"].IsInt()) {
m_ePhaseType = static_cast<NM_PHASE_TYPE>(jsonValue["PhaseType"].GetInt());
}
} }

@ -824,10 +824,10 @@ bool nmSubWndUtils::loadRsts(iSubWnd* pSubWnd, \
// 设置当前操作的是哪一个分析 // 设置当前操作的是哪一个分析
nmDataAnalyzeManager::setCurrentFitting(pSubWndF); nmDataAnalyzeManager::setCurrentFitting(pSubWndF);
// 加载本地文件的数据到数据中心里的数据体里
pDataManager->loadNmResult(sDir);
// 加载当前分析中的PVT数据 // 加载当前分析中的PVT数据
pDataManager->initPvtParaFromSubFit(); pDataManager->initPvtParaFromSubFit();
// 加载本地文件的数据到数据中心里的数据体里含用户选择的模型类型覆盖PVT推导结果
pDataManager->loadNmResult(sDir);
// 切换左侧参数视图 // 切换左侧参数视图
pSubWndF->swapAnaNmDocks(true); pSubWndF->swapAnaNmDocks(true);

Loading…
Cancel
Save