1、在属性面板下添加Save按钮,并连接保存json函数(目前有bug,需要点击两下才能保存json;第一次点击能够检测,但是没能触发保存

feature/struct-menu-20241023
mzh 1 week ago
parent abb80ac863
commit ca6d4eb85e

@ -1,97 +1,89 @@
#include "CFDStructDataManager.h" #include "CFDStructDataManager.h"
#include "CFDStructDataSolverTimeModeManager.h"
#include "CFDStructDataSolverBasicModelManager.h" #include "CFDStructDataSolverBasicModelManager.h"
#include "CFDStructDataSolverKvislManager.h" #include "CFDStructDataSolverKvislManager.h"
#include "CFDStructDataSolverNumericalMethodManager.h" #include "CFDStructDataSolverNumericalMethodManager.h"
#include "CFDStructDataSolverTimeModeManager.h"
#include "CFDStructDataSolverSportsAttributesManager.h"
#include "CFDStructDataSolverBoundaryConditionManager.h" #include "CFDStructDataSolverBoundaryConditionManager.h"
#include "CFDStructDataSolverInitializationManager.h"
#include "CFDStructDataSolverReferenceQuantityManager.h"
#include "CFDStructDataSolverComputingControlManager.h" #include "CFDStructDataSolverComputingControlManager.h"
#include "CFDStructDataSolverMonitorResidualManager.h" #include "CFDStructDataSolverInitializationManager.h"
#include "CFDStructDataSolverMonitorAerodynamicManager.h" #include "CFDStructDataSolverMonitorAerodynamicManager.h"
#include "CFDStructDataSolverMonitorImpellerManager.h" #include "CFDStructDataSolverMonitorImpellerManager.h"
#include "CFDStructDataSolverMonitorResidualManager.h"
#include "CFDStructDataSolverReferenceQuantityManager.h"
#include "CFDStructDataSolverSportsAttributesManager.h"
#include "CUIProperty/CUIConfig.h" #include "CUIProperty/CUIConfig.h"
#include <rapidjson/writer.h>
#include <rapidjson/stringbuffer.h> #include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
CFDStructDataManager *CFDStructDataManager::m_instance = NULL; CFDStructDataManager *CFDStructDataManager::m_instance = NULL;
CFDStructDataManager::CFDStructDataManager() CFDStructDataManager::CFDStructDataManager() {
{
this->initDataManagers(); this->initDataManagers();
this->initJson(); this->initJson();
} }
CFDStructDataManager *CFDStructDataManager::getInstance() CFDStructDataManager *CFDStructDataManager::getInstance() {
{ if (m_instance == nullptr) {
if (m_instance == nullptr)
{
m_instance = new CFDStructDataManager; m_instance = new CFDStructDataManager;
} }
return m_instance; return m_instance;
} }
CUIConfig *CFDStructDataManager::getActionParamUIConfig(SolutionAnalysisModuleProperty sig, QVariant idx) CUIConfig *CFDStructDataManager::getActionParamUIConfig(SolutionAnalysisModuleProperty sig, QVariant idx) {
{ if (m_solverBoundaryConditionManager == nullptr) {
if (m_solverBoundaryConditionManager == nullptr)
{
qDebug() << "manager is null"; qDebug() << "manager is null";
} }
CUIConfig *res = nullptr; CUIConfig *res = nullptr;
switch (sig) {
switch (sig)
{
case SolutionAnalysisModuleProperty::Time_Mode: case SolutionAnalysisModuleProperty::Time_Mode:
res = m_solverTimeModeManager->getParamUIConfig(); res = m_solverTimeModeManager->getParamUIConfig();
break; break;
case SolutionAnalysisModuleProperty::Basic_Model: case SolutionAnalysisModuleProperty::Basic_Model:
res = m_solverBasicModeManager->getParamUIConfig(); res = m_solverBasicModeManager->getParamUIConfig();
break; break;
case SolutionAnalysisModuleProperty::Viscosity_Model: case SolutionAnalysisModuleProperty::Viscosity_Model:
res = m_solverKvislManager->getParamUIConfig(); res = m_solverKvislManager->getParamUIConfig();
break; break;
case SolutionAnalysisModuleProperty::NUumerical_Methods: case SolutionAnalysisModuleProperty::NUumerical_Methods:
res = m_solverNumericalMethodManager->getParamUIConfig(); res = m_solverNumericalMethodManager->getParamUIConfig();
break; break;
case SolutionAnalysisModuleProperty::Motion_Properties: case SolutionAnalysisModuleProperty::Motion_Properties:
res = m_solverSportsAttributesManager->getParamUIConfig(); res = m_solverSportsAttributesManager->getParamUIConfig();
break; break;
case SolutionAnalysisModuleProperty::Boundary_Conditions: case SolutionAnalysisModuleProperty::Boundary_Conditions:
res = m_solverBoundaryConditionManager->getParamUIConfig(); res = m_solverBoundaryConditionManager->getParamUIConfig();
break; break;
case SolutionAnalysisModuleProperty::Initialization: case SolutionAnalysisModuleProperty::Initialization:
res = m_solverInitializationManager->getParamUIConfig(); res = m_solverInitializationManager->getParamUIConfig();
break; break;
case SolutionAnalysisModuleProperty::Computational_Control_Reference_Quantity: case SolutionAnalysisModuleProperty::Computational_Control_Reference_Quantity:
res = m_solverReferenceQuantityManager->getParamUIConfig(); res = m_solverReferenceQuantityManager->getParamUIConfig();
break; break;
case SolutionAnalysisModuleProperty::Computational_Control: case SolutionAnalysisModuleProperty::Computational_Control:
res = m_solverComputingControlManager->getParamUIConfig(); res = m_solverComputingControlManager->getParamUIConfig();
break; break;
case SolutionAnalysisModuleProperty::Monitors_Residual: case SolutionAnalysisModuleProperty::Monitors_Residual:
res = m_solverMonitorResidualManager->getParamUIConfig(); res = m_solverMonitorResidualManager->getParamUIConfig();
break; break;
case SolutionAnalysisModuleProperty::Monitors_AerodynamicForce: case SolutionAnalysisModuleProperty::Monitors_AerodynamicForce:
res = m_solverMonitorAerodynamicForceManager->getParamUIConfig(); res = m_solverMonitorAerodynamicForceManager->getParamUIConfig();
break; break;
case SolutionAnalysisModuleProperty::Monitors_Tubomachinery_Performance: case SolutionAnalysisModuleProperty::Monitors_Tubomachinery_Performance:
res = m_solverMonitorTubomachineryPerformanceManager->getParamUIConfig(); res = m_solverMonitorTubomachineryPerformanceManager->getParamUIConfig();
break; break;
default: default:
break; break;
} }
if(res == nullptr) if (res == nullptr)
qDebug() << "DataManager return null CUIConfig"; qDebug() << "DataManager return null CUIConfig";
return res; return res;
} }
void CFDStructDataManager::initDataManagers() void CFDStructDataManager::initDataManagers() {
{
m_solverTimeModeManager = new CFDStructDataSolverTimeModeManager; m_solverTimeModeManager = new CFDStructDataSolverTimeModeManager;
m_solverBasicModeManager = new CFDStructDataSolverBasicModelManager; m_solverBasicModeManager = new CFDStructDataSolverBasicModelManager;
m_solverKvislManager = new CFDStructDataSolverKvislManager; m_solverKvislManager = new CFDStructDataSolverKvislManager;
@ -106,13 +98,11 @@ void CFDStructDataManager::initDataManagers()
m_solverMonitorTubomachineryPerformanceManager = new CFDStructDataSolverMonitorImpellerManager; m_solverMonitorTubomachineryPerformanceManager = new CFDStructDataSolverMonitorImpellerManager;
} }
void CFDStructDataManager::initJson() void CFDStructDataManager::initJson() {
{
m_dom.SetObject(); m_dom.SetObject();
} }
void CFDStructDataManager::updateJson() void CFDStructDataManager::updateJson() {
{
m_dom.SetObject(); m_dom.SetObject();
m_solverTimeModeManager->saveDataToDom(m_dom); m_solverTimeModeManager->saveDataToDom(m_dom);
@ -129,10 +119,8 @@ void CFDStructDataManager::updateJson()
m_solverMonitorTubomachineryPerformanceManager->saveDataToDom(m_dom); m_solverMonitorTubomachineryPerformanceManager->saveDataToDom(m_dom);
} }
#include <iostream> #include <iostream>
void CFDStructDataManager::printJson() void CFDStructDataManager::printJson() {
{
using namespace rapidjson; using namespace rapidjson;
StringBuffer buffer; StringBuffer buffer;

@ -1,58 +1,71 @@
#include "CFDStructOperatorsModelSolverProperty.h" #include "CFDStructOperatorsModelSolverProperty.h"
#include "CFDStructOperatorsModelSolverProperty.h"
#include "GUIFrame/MainWindow.h" #include "GUIFrame/MainWindow.h"
#include "GUIFrame/PropertyWidget.h" #include "GUIFrame/PropertyWidget.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "CFDStruct/CUIProperty/CUIPropertyWidget.h" #include "CFDStruct/CUIProperty/CUIPropertyWidget.h"
#include "CUIProperty/CUIConfig.h"
#include "CFDStructDataManager/CFDStructDataManager.h" #include "CFDStructDataManager/CFDStructDataManager.h"
#include "CFDStructDataManager/CFDStructSigsCenter.h" #include "CFDStructDataManager/CFDStructSigsCenter.h"
#include "CUIProperty/CUIConfig.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include <QLabel>
#include <QDebug> #include <QDebug>
#include <QLabel>
#include <QLayout>
#include <QPushButton>
CFDStructOperatorsModelSolverProperty* CFDStructOperatorsModelSolverProperty::m_instance = nullptr; CFDStructOperatorsModelSolverProperty *CFDStructOperatorsModelSolverProperty::m_instance = nullptr;
CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModelSolverProperty(QObject *parent) : QObject(parent) CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModelSolverProperty(QObject *parent) : QObject(parent) {
{ CFDStructSigsCenter *sigsCenter = CFDStructSigsCenter::getInstance();
CFDStructSigsCenter* sigsCenter = CFDStructSigsCenter::getInstance();
connect(sigsCenter, &CFDStructSigsCenter::sig_solverModuleProperty, this, [ = ](SolutionAnalysisModuleProperty sig, QVariant idx) { // 定义保存按钮
QPushButton *btn = new QPushButton("Save");
// 连接保存的信号
connect(btn, &QPushButton::clicked, this, [=]() {
qDebug() << "Save button has clicked";
emit CFDStructSigsCenter::getInstance() -> sig_solverSaveData();
});
// 保存数据
connect(sigsCenter, &CFDStructSigsCenter::sig_solverSaveData, this, [=]() {
this->CFDStructOperatorsModeSolverSaveData();
});
connect(sigsCenter, &CFDStructSigsCenter::sig_solverModuleProperty, this, [=](SolutionAnalysisModuleProperty sig, QVariant idx) {
if (sig == SolutionAnalysisModuleProperty::UNKNOW) { if (sig == SolutionAnalysisModuleProperty::UNKNOW) {
return; return;
} }
m_module = sig; m_module = sig;
GUI::MainWindow* mainWindow = dynamic_cast<GUI::MainWindow*>(FITKAPP->getGlobalData()->getMainWindow()); GUI::MainWindow *mainWindow = dynamic_cast<GUI::MainWindow *>(FITKAPP->getGlobalData()->getMainWindow());
if (mainWindow == nullptr) { if (mainWindow == nullptr) {
return; return;
} }
GUI::PropertyWidget* propertyWidget = mainWindow->getPropertyWidget(); GUI::PropertyWidget *propertyWidget = mainWindow->getPropertyWidget();
if (propertyWidget == nullptr) { if (propertyWidget == nullptr) {
return; return;
} }
CUIConfig* uiConfig = CFDStructDataManager::getInstance()->getActionParamUIConfig(sig, idx); CUIConfig *uiConfig = CFDStructDataManager::getInstance()->getActionParamUIConfig(sig, idx);
QWidget* widget = new CUIPropertyWidget(nullptr, uiConfig); QWidget *widget = new CUIPropertyWidget(nullptr, uiConfig);
if(widget != nullptr)
// 添加保存按钮
widget->layout()->addWidget(btn);
if (widget != nullptr)
propertyWidget->setWidget(widget); propertyWidget->setWidget(widget);
return; return;
}); });
} }
CFDStructOperatorsModelSolverProperty *CFDStructOperatorsModelSolverProperty::getInstance() {
CFDStructOperatorsModelSolverProperty *CFDStructOperatorsModelSolverProperty::getInstance()
{
if (m_instance == nullptr) { if (m_instance == nullptr) {
m_instance = new CFDStructOperatorsModelSolverProperty; m_instance = new CFDStructOperatorsModelSolverProperty;
} }
return m_instance; return m_instance;
} }
void CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModeSolverSaveData() void CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModeSolverSaveData() {
{ CFDStructSigsCenter *sigsCenter = CFDStructSigsCenter::getInstance();
CFDStructSigsCenter* sigsCenter = CFDStructSigsCenter::getInstance(); connect(sigsCenter, &CFDStructSigsCenter::sig_solverSaveData, this, [=]() {
connect(sigsCenter, &CFDStructSigsCenter::sig_solverSaveData, this, [ = ]() {
CFDStructDataManager::getInstance()->updateJson(); CFDStructDataManager::getInstance()->updateJson();
CFDStructDataManager::getInstance()->printJson(); CFDStructDataManager::getInstance()->printJson();
}); });

@ -19,7 +19,12 @@
"chimeraMesh": 0, "chimeraMesh": 0,
"refValue": { "refValue": {
"rgas_mean": 0.0, "rgas_mean": 0.0,
"gamma": 0.0 "gamma": 0.0,
"pressure": -6.2774385622041928e66,
"temperature": -6.2774385622041928e66,
"refLength": -6.2774385622041928e66,
"refArea": -6.2774385622041928e66,
"jx": ""
}, },
"numericMethod": { "numericMethod": {
"numMethodParm": { "numMethodParm": {
@ -47,10 +52,17 @@
"stepType": 1.0, "stepType": 1.0,
"timeStep": 1.0, "timeStep": 1.0,
"timeStepsNumber": 10, "timeStepsNumber": 10,
"Timeverage": 0 "Timeverage": 0,
"savedSteps": -842150451
}, },
"steady": { "steady": {
"iters": 1000 "iters": 1000,
"savedIters": -842150451
},
"mpi": {
"core": 0,
"on": 0,
"type": 0
} }
} }
} }
Loading…
Cancel
Save