From 011318054a95322522560bcc43b29531658e3288 Mon Sep 17 00:00:00 2001 From: mzh Date: Fri, 8 Nov 2024 11:16:29 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=88=9B=E5=BB=BACFDStructMainUtils?= =?UTF-8?q?=202=E3=80=81=E5=AE=9E=E7=8E=B0Utils=E4=B8=ADwrite=E5=87=BD?= =?UTF-8?q?=E6=95=B0=203=E3=80=81=E4=BF=AE=E6=94=B9json=E5=86=99=E5=85=A5?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E8=B0=83=E7=94=A8Utils=E4=B8=AD?= =?UTF-8?q?=E7=9A=84wirte=E5=87=BD=E6=95=B0=EF=BC=8C=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CFDStructDataManager.cpp | 12 +++++--- .../CFDStructDataManager.pro | 2 ++ .../CFDStructDataSolverBasicModelManager.h | 29 +++++++++---------- CFDStruct/CFDStructMain/CFDStructMain.pri | 4 ++- .../CFDStructMain/CFDStructMainUtils.cpp | 20 +++++++++++++ CFDStruct/CFDStructMain/CFDStructMainUtils.h | 15 ++++++++++ 6 files changed, 61 insertions(+), 21 deletions(-) create mode 100644 CFDStruct/CFDStructMain/CFDStructMainUtils.cpp create mode 100644 CFDStruct/CFDStructMain/CFDStructMainUtils.h diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp b/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp index cdb03df..df54fb8 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp +++ b/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp @@ -103,7 +103,9 @@ void CFDStructDataManager::initJson() { } void CFDStructDataManager::updateJson() { + qDebug() << "-----------"; m_dom.SetObject(); + qDebug() << "++++++++++"; m_solverTimeModeManager->saveDataToDom(m_dom); m_solverBasicModeManager->saveDataToDom(m_dom); @@ -119,7 +121,9 @@ void CFDStructDataManager::updateJson() { m_solverMonitorTubomachineryPerformanceManager->saveDataToDom(m_dom); } +#include "CFDStructMain/CFDStructMainUtils.h" #include + void CFDStructDataManager::printJson() { using namespace rapidjson; @@ -127,9 +131,9 @@ void CFDStructDataManager::printJson() { Writer writer(buffer); m_dom.Accept(writer); - freopen(caseJSONPath.c_str(), "w", stdout); - - std::cout << buffer.GetString() << std::endl; + // freopen(caseJSONPath.c_str(), "w", stdout); + // std::cout << buffer.GetString() << std::endl; + // fclose(stdout); - fclose(stdout); + CFDStructMainUtils::write(caseJSONPath, buffer.GetString()); } diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataManager.pro b/CFDStruct/CFDStructDataManager/CFDStructDataManager.pro index c715c31..b1bea29 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataManager.pro +++ b/CFDStruct/CFDStructDataManager/CFDStructDataManager.pro @@ -62,6 +62,7 @@ win32{ -lOperatorsModel \ -lCUIProperty \ -lCFDStructOperatorsModel \ + -lCFDStructMain \ # -lCFDStructDataManager \ @@ -96,6 +97,7 @@ win32{ -lOperatorsModel \ -lCUIProperty \ -lCFDStructOperatorsModel \ + -lCFDStructMain \ # -lCFDStructDataManager \ diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataSolverBasicModelManager.h b/CFDStruct/CFDStructDataManager/CFDStructDataSolverBasicModelManager.h index 4fba921..36b71d6 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataSolverBasicModelManager.h +++ b/CFDStruct/CFDStructDataManager/CFDStructDataSolverBasicModelManager.h @@ -4,42 +4,40 @@ #ifndef CFDSTRUCTDATASOLVERBASICMODELMANAGER_H #define CFDSTRUCTDATASOLVERBASICMODELMANAGER_H -#include #include "CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.h" #include "CFDStructDataManager_global.h" +#include class CUIConfig; -class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataSolverBasicModelManager : public CFDStructDataManagerBase -{ +class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataSolverBasicModelManager : public CFDStructDataManagerBase { Q_OBJECT -public: + public: explicit CFDStructDataSolverBasicModelManager(QObject *parent = nullptr); ~CFDStructDataSolverBasicModelManager(); - CUIConfig* getParamUIConfig(); + CUIConfig *getParamUIConfig(); void saveDataToDom(rapidjson::Document &dom); void readDataFromDom(rapidjson::Document &dom); private: // 生成流体属性关闭界面配置 - CUIConfig* genFluidPropertiesOffUIConfig(); + CUIConfig *genFluidPropertiesOffUIConfig(); // 生成流体属性开启界面配置 - CUIConfig* genFluidPropertiesOnUIConfig(); -signals: - -private: + CUIConfig *genFluidPropertiesOnUIConfig(); + signals: - //流动模型:外流0;内流1;多级叶轮机械2 + private: + // 流动模型:外流0;内流1;多级叶轮机械2 int m_FlowModel = 0; - //重叠网格:不勾选0;勾选1 + // 重叠网格:不勾选0;勾选1 int m_OverlayNetwork = 0; - //流体属性:关闭0;开启1 + // 流体属性:关闭0;开启1 int m_FluidProperties = 0; - //气体成分 + // 气体成分 QString m_GasComposition = ""; // 气体常数 @@ -54,8 +52,7 @@ private: // 湍流普朗特数 double m_Prtmean = 0; - - CUIConfig* m_uiConfig = nullptr; + CUIConfig *m_uiConfig = nullptr; }; #endif // CFDSTRUCTDATASOLVERBASICMODELMANAGER_H diff --git a/CFDStruct/CFDStructMain/CFDStructMain.pri b/CFDStruct/CFDStructMain/CFDStructMain.pri index 8e1b254..1effc24 100644 --- a/CFDStruct/CFDStructMain/CFDStructMain.pri +++ b/CFDStruct/CFDStructMain/CFDStructMain.pri @@ -5,9 +5,11 @@ HEADERS += \ $$PWD/CFDMainTreeWidget.h \ $$PWD/CFDTreeWidget.h \ $$PWD/CFDPropertyWidget.h \ + $$PWD/CFDStructMainUtils.h \ SOURCES += \ $$PWD/CFDStructMainWindow.cpp \ $$PWD/CFDMainTreeWidget.cpp \ $$PWD/CFDTreeWidget.cpp \ - $$PWD/CFDPropertyWidget.cpp + $$PWD/CFDPropertyWidget.cpp \ + $$PWD/CFDStructMainUtils.cpp \ diff --git a/CFDStruct/CFDStructMain/CFDStructMainUtils.cpp b/CFDStruct/CFDStructMain/CFDStructMainUtils.cpp new file mode 100644 index 0000000..da23fe4 --- /dev/null +++ b/CFDStruct/CFDStructMain/CFDStructMainUtils.cpp @@ -0,0 +1,20 @@ +#include "CFDStructMainUtils.h" + +#include +#include +#include +#include + +void CFDStructMainUtils::write(std::string path, std::string text) { + using namespace std; + + char drive[_MAX_PATH], dir[_MAX_PATH], filename[_MAX_PATH], ext[_MAX_PATH]; + _splitpath(path.c_str(), drive, dir, filename, ext); + _mkdir(dir); + freopen(path.c_str(), "w", stdout); + cout << text << endl; + fclose(stdout); +} + +void CFDStructMainUtils::read(std::string path, std::string &text) { +} diff --git a/CFDStruct/CFDStructMain/CFDStructMainUtils.h b/CFDStruct/CFDStructMain/CFDStructMainUtils.h new file mode 100644 index 0000000..74aab35 --- /dev/null +++ b/CFDStruct/CFDStructMain/CFDStructMainUtils.h @@ -0,0 +1,15 @@ +#ifndef CFDStructMainUtils_h +#define CFDStructMainUtils_h + +#include "CFDStructMainAPI.h" +#include + +class CFDStructMAINAPI CFDStructMainUtils { + + public: + static void write(std::string path, std::string text); + + static void read(std::string path, std::string &text); +}; + +#endif