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

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

@ -1,51 +1,44 @@
#include "CFDStructDataManager.h"
#include "CFDStructDataSolverTimeModeManager.h"
#include "CFDStructDataSolverBasicModelManager.h"
#include "CFDStructDataSolverKvislManager.h"
#include "CFDStructDataSolverNumericalMethodManager.h"
#include "CFDStructDataSolverTimeModeManager.h"
#include "CFDStructDataSolverSportsAttributesManager.h"
#include "CFDStructDataSolverBoundaryConditionManager.h"
#include "CFDStructDataSolverInitializationManager.h"
#include "CFDStructDataSolverReferenceQuantityManager.h"
#include "CFDStructDataSolverComputingControlManager.h"
#include "CFDStructDataSolverMonitorResidualManager.h"
#include "CFDStructDataSolverInitializationManager.h"
#include "CFDStructDataSolverMonitorAerodynamicManager.h"
#include "CFDStructDataSolverMonitorImpellerManager.h"
#include "CFDStructDataSolverMonitorResidualManager.h"
#include "CFDStructDataSolverReferenceQuantityManager.h"
#include "CFDStructDataSolverSportsAttributesManager.h"
#include "CUIProperty/CUIConfig.h"
#include <rapidjson/writer.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
CFDStructDataManager *CFDStructDataManager::m_instance = NULL;
CFDStructDataManager::CFDStructDataManager()
{
CFDStructDataManager::CFDStructDataManager() {
this->initDataManagers();
this->initJson();
}
CFDStructDataManager *CFDStructDataManager::getInstance()
{
if (m_instance == nullptr)
{
CFDStructDataManager *CFDStructDataManager::getInstance() {
if (m_instance == nullptr) {
m_instance = new CFDStructDataManager;
}
return m_instance;
}
CUIConfig *CFDStructDataManager::getActionParamUIConfig(SolutionAnalysisModuleProperty sig, QVariant idx)
{
if (m_solverBoundaryConditionManager == nullptr)
{
CUIConfig *CFDStructDataManager::getActionParamUIConfig(SolutionAnalysisModuleProperty sig, QVariant idx) {
if (m_solverBoundaryConditionManager == nullptr) {
qDebug() << "manager is null";
}
CUIConfig *res = nullptr;
switch (sig)
{
switch (sig) {
case SolutionAnalysisModuleProperty::Time_Mode:
res = m_solverTimeModeManager->getParamUIConfig();
break;
@ -85,13 +78,12 @@ CUIConfig *CFDStructDataManager::getActionParamUIConfig(SolutionAnalysisModulePr
default:
break;
}
if(res == nullptr)
if (res == nullptr)
qDebug() << "DataManager return null CUIConfig";
return res;
}
void CFDStructDataManager::initDataManagers()
{
void CFDStructDataManager::initDataManagers() {
m_solverTimeModeManager = new CFDStructDataSolverTimeModeManager;
m_solverBasicModeManager = new CFDStructDataSolverBasicModelManager;
m_solverKvislManager = new CFDStructDataSolverKvislManager;
@ -106,13 +98,11 @@ void CFDStructDataManager::initDataManagers()
m_solverMonitorTubomachineryPerformanceManager = new CFDStructDataSolverMonitorImpellerManager;
}
void CFDStructDataManager::initJson()
{
void CFDStructDataManager::initJson() {
m_dom.SetObject();
}
void CFDStructDataManager::updateJson()
{
void CFDStructDataManager::updateJson() {
m_dom.SetObject();
m_solverTimeModeManager->saveDataToDom(m_dom);
@ -129,10 +119,8 @@ void CFDStructDataManager::updateJson()
m_solverMonitorTubomachineryPerformanceManager->saveDataToDom(m_dom);
}
#include <iostream>
void CFDStructDataManager::printJson()
{
void CFDStructDataManager::printJson() {
using namespace rapidjson;
StringBuffer buffer;

@ -1,58 +1,71 @@
#include "CFDStructOperatorsModelSolverProperty.h"
#include "CFDStructOperatorsModelSolverProperty.h"
#include "GUIFrame/MainWindow.h"
#include "GUIFrame/PropertyWidget.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "CFDStruct/CUIProperty/CUIPropertyWidget.h"
#include "CUIProperty/CUIConfig.h"
#include "CFDStructDataManager/CFDStructDataManager.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 <QLabel>
#include <QLayout>
#include <QPushButton>
CFDStructOperatorsModelSolverProperty* CFDStructOperatorsModelSolverProperty::m_instance = nullptr;
CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModelSolverProperty(QObject *parent) : QObject(parent)
{
CFDStructSigsCenter* sigsCenter = CFDStructSigsCenter::getInstance();
connect(sigsCenter, &CFDStructSigsCenter::sig_solverModuleProperty, this, [ = ](SolutionAnalysisModuleProperty sig, QVariant idx) {
CFDStructOperatorsModelSolverProperty *CFDStructOperatorsModelSolverProperty::m_instance = nullptr;
CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModelSolverProperty(QObject *parent) : QObject(parent) {
CFDStructSigsCenter *sigsCenter = CFDStructSigsCenter::getInstance();
// 定义保存按钮
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) {
return;
}
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) {
return;
}
GUI::PropertyWidget* propertyWidget = mainWindow->getPropertyWidget();
GUI::PropertyWidget *propertyWidget = mainWindow->getPropertyWidget();
if (propertyWidget == nullptr) {
return;
}
CUIConfig* uiConfig = CFDStructDataManager::getInstance()->getActionParamUIConfig(sig, idx);
QWidget* widget = new CUIPropertyWidget(nullptr, uiConfig);
if(widget != nullptr)
CUIConfig *uiConfig = CFDStructDataManager::getInstance()->getActionParamUIConfig(sig, idx);
QWidget *widget = new CUIPropertyWidget(nullptr, uiConfig);
// 添加保存按钮
widget->layout()->addWidget(btn);
if (widget != nullptr)
propertyWidget->setWidget(widget);
return;
});
}
CFDStructOperatorsModelSolverProperty *CFDStructOperatorsModelSolverProperty::getInstance()
{
CFDStructOperatorsModelSolverProperty *CFDStructOperatorsModelSolverProperty::getInstance() {
if (m_instance == nullptr) {
m_instance = new CFDStructOperatorsModelSolverProperty;
}
return m_instance;
}
void CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModeSolverSaveData()
{
CFDStructSigsCenter* sigsCenter = CFDStructSigsCenter::getInstance();
connect(sigsCenter, &CFDStructSigsCenter::sig_solverSaveData, this, [ = ]() {
void CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModeSolverSaveData() {
CFDStructSigsCenter *sigsCenter = CFDStructSigsCenter::getInstance();
connect(sigsCenter, &CFDStructSigsCenter::sig_solverSaveData, this, [=]() {
CFDStructDataManager::getInstance()->updateJson();
CFDStructDataManager::getInstance()->printJson();
});

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