#include "CFDStructOperatorsModelSolverProperty.h" #include "GUIFrame/MainWindow.h" #include "GUIFrame/PropertyWidget.h" #include "CFDStruct/CUIProperty/CUIPropertyWidget.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 #include #include #include 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(FITKAPP->getGlobalData()->getMainWindow()); if (mainWindow == nullptr) { return; } GUI::PropertyWidget *propertyWidget = mainWindow->getPropertyWidget(); if (propertyWidget == nullptr) { return; } 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() { if (m_instance == nullptr) { m_instance = new CFDStructOperatorsModelSolverProperty; } return m_instance; } void CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModeSolverSaveData() { CFDStructSigsCenter *sigsCenter = CFDStructSigsCenter::getInstance(); connect(sigsCenter, &CFDStructSigsCenter::sig_solverSaveData, this, [=]() { CFDStructDataManager::getInstance()->updateJson(); CFDStructDataManager::getInstance()->printJson(); }); }