diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.cpp b/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.cpp index e57b374..b846ad3 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.cpp +++ b/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.cpp @@ -14,8 +14,6 @@ CFDStructDataManagerBase::~CFDStructDataManagerBase() { CUIConfig *CFDStructDataManagerBase::getParamUIConfig() { return nullptr; } -void CFDStructDataManagerBase::saveDataToDom(rapidjson::Document &dom) {} - // 写入json void CFDStructDataManagerBase::jsonAdd(rapidjson::Document &document, QVariant value, QVector path) { diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.h b/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.h index 20fda88..f713c41 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.h +++ b/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.h @@ -17,7 +17,10 @@ class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataManagerBase : public QObject { ~CFDStructDataManagerBase(); // 获取参数界面的配置 virtual CUIConfig *getParamUIConfig(); - virtual void saveDataToDom(rapidjson::Document &dom); + // 将数据存入dom + virtual void saveDataToDom(rapidjson::Document &dom) = 0; + // 将数据从dom中读出 + virtual void readDataFromDom(rapidjson::Document &dom) = 0; signals: protected: diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataSolverBasicModelManager.cpp b/CFDStruct/CFDStructDataManager/CFDStructDataSolverBasicModelManager.cpp index f15e1f9..187c5da 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataSolverBasicModelManager.cpp +++ b/CFDStruct/CFDStructDataManager/CFDStructDataSolverBasicModelManager.cpp @@ -1,43 +1,54 @@ #include "CFDStructDataSolverBasicModelManager.h" -#include "CUIProperty/CUIConfig.h" #include "CFDStructMain/CFDStructDefine.h" #include "CFDStructSigsCenter.h" +#include "CUIProperty/CUIConfig.h" -CFDStructDataSolverBasicModelManager::CFDStructDataSolverBasicModelManager(QObject *parent) : CFDStructDataManagerBase(parent) -{ +CFDStructDataSolverBasicModelManager::CFDStructDataSolverBasicModelManager(QObject *parent) : CFDStructDataManagerBase(parent) { m_uiConfig = nullptr; } -CFDStructDataSolverBasicModelManager::~CFDStructDataSolverBasicModelManager() -{ - if (m_uiConfig != nullptr) - { +CFDStructDataSolverBasicModelManager::~CFDStructDataSolverBasicModelManager() { + if (m_uiConfig != nullptr) { delete m_uiConfig; m_uiConfig = nullptr; } - connect(m_cuiSigsCenter, &CUISigsCenter::sig_cuiPropertyChanged, this, [=](int semaphore){ - emit CFDStructSigsCenter::getInstance()->sig_solverTimeModeDataChanged(); + connect(m_cuiSigsCenter, &CUISigsCenter::sig_cuiPropertyChanged, this, [=](int semaphore) { + emit CFDStructSigsCenter::getInstance() -> sig_solverTimeModeDataChanged(); }); } -CUIConfig *CFDStructDataSolverBasicModelManager::getParamUIConfig() -{ - if(m_FluidProperties == 0) +CUIConfig *CFDStructDataSolverBasicModelManager::getParamUIConfig() { + if (m_FluidProperties == 0) return this->genFluidPropertiesOffUIConfig(); - if(m_FluidProperties == 1) + if (m_FluidProperties == 1) return this->genFluidPropertiesOnUIConfig(); return this->genFluidPropertiesOnUIConfig(); } -void CFDStructDataSolverBasicModelManager::saveDataToDom(rapidjson::Document &dom) -{ - jsonAdd(dom,m_FlowModel,{"region",0, "flowType",}); - jsonAdd(dom,m_OverlayNetwork,{"region",0, "chimeraMesh",}); - jsonAdd(dom,m_Rgasmean,{"region",0, "refValue", "rgas_mean",}); - jsonAdd(dom,m_Gmean,{"region",0, "refValue", "gamma",}); - jsonAdd(dom,m_Prlmean,{"region",0, "solver", "turbModel", "RANS", "params", "Prl",}); - jsonAdd(dom,m_Prtmean,{"region",0, "solver", "turbModel", "RANS", "params", "Prt",}); +void CFDStructDataSolverBasicModelManager::saveDataToDom(rapidjson::Document &dom) { + jsonAdd(dom, m_FlowModel, {"region", 0, "flowType"}); + jsonAdd(dom, m_OverlayNetwork, {"region", 0, "chimeraMesh"}); + jsonAdd(dom, m_Rgasmean, {"region", 0, "refValue", "rgas_mean"}); + jsonAdd(dom, m_Gmean, {"region", 0, "refValue", "gamma"}); + jsonAdd(dom, m_Prlmean, {"region", 0, "solver", "turbModel", "RANS", "params", "Prl"}); + jsonAdd(dom, m_Prtmean, {"region", 0, "solver", "turbModel", "RANS", "params", "Prt"}); +} + +void CFDStructDataSolverBasicModelManager::readDataFromDom(rapidjson::Document &dom) { + QVariant temp; + jsonRead(dom, temp, {"region", 0, "flowType"}); + m_FlowModel = temp.toInt(); + jsonRead(dom, temp, {"region", 0, "chimeraMesh"}); + m_OverlayNetwork = temp.toInt(); + jsonRead(dom, temp, {"region", 0, "refValue", "rgas_mean"}); + m_Rgasmean = temp.toDouble(); + jsonRead(dom, temp, {"region", 0, "refValue", "gamma"}); + m_Gmean = temp.toDouble(); + jsonRead(dom, temp, {"region", 0, "solver", "turbModel", "RANS", "params", "Prl"}); + m_Prlmean = temp.toDouble(); + jsonRead(dom, temp, {"region", 0, "solver", "turbModel", "RANS", "params", "Prt"}); + m_Prtmean = temp.toDouble(); } /** @@ -45,8 +56,7 @@ void CFDStructDataSolverBasicModelManager::saveDataToDom(rapidjson::Document &do * * @return 属性设置 */ -CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOffUIConfig() -{ +CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOffUIConfig() { return new CUIConfig({ {"type", "Widget"}, }, @@ -58,13 +68,14 @@ CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOffUIConfig() {new CUIConfig({ {"type", "Item"}, {"name", tr("Compressible Flow")} // 选项:可压缩流动 })}), - new CUIConfig({// 下拉框:流动模型 - {"type", "ComboBox"}, - {"name", tr("Flow Model")}, - {"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, - {"value_origin",QVA_GLOBAL(&m_FlowModel)}, - {"semaphore",1}, - }, + new CUIConfig({ + // 下拉框:流动模型 + {"type", "ComboBox"}, + {"name", tr("Flow Model")}, + {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, + {"value_origin", QVA_GLOBAL(&m_FlowModel)}, + {"semaphore", 1}, + }, {new CUIConfig({// 选项:外流 {"type", "Item"}, {"name", tr("Internal Flow")}}), @@ -74,23 +85,24 @@ CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOffUIConfig() new CUIConfig({// 选项:多级叶轮机械 {"type", "Item"}, {"name", tr("Multistage Turbomachinery")}})}), - new CUIConfig({// 方形勾选:重叠网络 - {"type", "CheckBox"}, - {"name", tr("Overlay Network")}, - {"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, - {"value_origin",QVA_GLOBAL(&m_OverlayNetwork)}, + new CUIConfig({ + // 方形勾选:重叠网络 + {"type", "CheckBox"}, + {"name", tr("Overlay Network")}, + {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, + {"value_origin", QVA_GLOBAL(&m_OverlayNetwork)}, }), - new CUIConfig({// 方形选择按钮:流体属性 - {"type", "CheckBox"}, - {"name", tr("Fluid Properties")}, - {"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, - {"value_origin",QVA_GLOBAL(&m_FluidProperties)}, - {"semaphore",1}, + new CUIConfig({ + // 方形选择按钮:流体属性 + {"type", "CheckBox"}, + {"name", tr("Fluid Properties")}, + {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, + {"value_origin", QVA_GLOBAL(&m_FluidProperties)}, + {"semaphore", 1}, })}); } -CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOnUIConfig() -{ +CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOnUIConfig() { return new CUIConfig({ {"type", "Widget"}, }, @@ -102,12 +114,13 @@ CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOnUIConfig() {new CUIConfig({ {"type", "Item"}, {"name", tr("Compressible Flow")} // 选项:可压缩流动 })}), - new CUIConfig({// 下拉框:流动模型 - {"type", "ComboBox"}, - {"name", tr("Flow Model")}, - {"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, - {"value_origin",QVA_GLOBAL(&m_FlowModel)}, - }, + new CUIConfig({ + // 下拉框:流动模型 + {"type", "ComboBox"}, + {"name", tr("Flow Model")}, + {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, + {"value_origin", QVA_GLOBAL(&m_FlowModel)}, + }, {new CUIConfig({// 选项:外流 {"type", "Item"}, {"name", tr("Internal Flow")}}), @@ -117,52 +130,59 @@ CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOnUIConfig() new CUIConfig({// 选项:多级叶轮机械 {"type", "Item"}, {"name", tr("Multistage Turbomachinery")}})}), - new CUIConfig({// 方形勾选:重叠网络 - {"type", "CheckBox"}, - {"name", tr("Overlay Network")}, - {"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, - {"value_origin",QVA_GLOBAL(&m_OverlayNetwork)}, + new CUIConfig({ + // 方形勾选:重叠网络 + {"type", "CheckBox"}, + {"name", tr("Overlay Network")}, + {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, + {"value_origin", QVA_GLOBAL(&m_OverlayNetwork)}, }), - new CUIConfig({// 圆形选择按钮:流体属性 - {"type", "CheckBox"}, - {"name", tr("Fluid Properties")}, - {"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, - {"value_origin",QVA_GLOBAL(&m_FluidProperties)}, - {"semaphore",1}, + new CUIConfig({ + // 圆形选择按钮:流体属性 + {"type", "CheckBox"}, + {"name", tr("Fluid Properties")}, + {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, + {"value_origin", QVA_GLOBAL(&m_FluidProperties)}, + {"semaphore", 1}, }), new CUIConfig({// 组,流体属性下的内容 {"type", "GroupBox"}, {"name", tr("Fluid Properties")}}, { - new CUIConfig({// 气体成分 - {"type", "LineEdit"}, - {"name", tr("Gas Composition")}, - {"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_STRING}, - {"value_origin",QVA_GLOBAL(&m_GasComposition)}, - }), - new CUIConfig({// 气体常数 - {"type", "LineEdit"}, - {"name", tr("rgasmean")}, - {"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE}, - {"value_origin",QVA_GLOBAL(&m_Rgasmean)}, - }), - new CUIConfig({// 比热比 - {"type", "LineEdit"}, - {"name", tr("gmean")}, - {"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE}, - {"value_origin",QVA_GLOBAL(&m_Gmean)}, - }), - new CUIConfig({// 层流普朗特数 - {"type", "LineEdit"}, - {"name", tr("prlmean")}, - {"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE}, - {"value_origin",QVA_GLOBAL(&m_Prlmean)}, - }), - new CUIConfig({// 湍流普朗特数 - {"type", "LineEdit"}, - {"name", tr("prtmean")}, - {"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE}, - {"value_origin",QVA_GLOBAL(&m_Prtmean)}, - }), + new CUIConfig({ + // 气体成分 + {"type", "LineEdit"}, + {"name", tr("Gas Composition")}, + {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_STRING}, + {"value_origin", QVA_GLOBAL(&m_GasComposition)}, + }), + new CUIConfig({ + // 气体常数 + {"type", "LineEdit"}, + {"name", tr("rgasmean")}, + {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE}, + {"value_origin", QVA_GLOBAL(&m_Rgasmean)}, + }), + new CUIConfig({ + // 比热比 + {"type", "LineEdit"}, + {"name", tr("gmean")}, + {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE}, + {"value_origin", QVA_GLOBAL(&m_Gmean)}, + }), + new CUIConfig({ + // 层流普朗特数 + {"type", "LineEdit"}, + {"name", tr("prlmean")}, + {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE}, + {"value_origin", QVA_GLOBAL(&m_Prlmean)}, + }), + new CUIConfig({ + // 湍流普朗特数 + {"type", "LineEdit"}, + {"name", tr("prtmean")}, + {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE}, + {"value_origin", QVA_GLOBAL(&m_Prtmean)}, + }), })}); } diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataSolverBasicModelManager.h b/CFDStruct/CFDStructDataManager/CFDStructDataSolverBasicModelManager.h index 1ed743a..4fba921 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataSolverBasicModelManager.h +++ b/CFDStruct/CFDStructDataManager/CFDStructDataSolverBasicModelManager.h @@ -19,7 +19,9 @@ public: CUIConfig* getParamUIConfig(); void saveDataToDom(rapidjson::Document &dom); -private: + void readDataFromDom(rapidjson::Document &dom); + + private: // 生成流体属性关闭界面配置 CUIConfig* genFluidPropertiesOffUIConfig(); // 生成流体属性开启界面配置