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;
@ -90,8 +83,7 @@ CUIConfig *CFDStructDataManager::getActionParamUIConfig(SolutionAnalysisModulePr
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,23 +1,36 @@
#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)
{
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;
@ -33,24 +46,24 @@ CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModelSolverProperty(QOb
}
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()
{
void CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModeSolverSaveData() {
CFDStructSigsCenter *sigsCenter = CFDStructSigsCenter::getInstance();
connect(sigsCenter, &CFDStructSigsCenter::sig_solverSaveData, this, [=]() {
CFDStructDataManager::getInstance()->updateJson();

@ -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