From ebc8e4e79be12c6c0dc69a6d8a9ca69a57b62882 Mon Sep 17 00:00:00 2001 From: simonyan <315082291@qq.com> Date: Wed, 30 Oct 2024 10:15:55 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=AE=8C=E6=88=90=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E7=9A=84=E5=88=87=E6=8D=A2=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CFDStructDataSolverTimeModeManager.cpp | 12 ++++++++++-- .../CFDStructSigsCenter.cpp | 14 ++++++++++++++ .../CFDStructSigsCenter.h | 19 +++++++++++++++++++ CFDStruct/CUIProperty/CUIConfig.cpp | 19 +++++++++++++------ CFDStruct/CUIProperty/CUIConfig.h | 4 ++++ CFDStruct/CUIProperty/CUIProperty.pri | 18 +++++++----------- CFDStruct/CUIProperty/CUISigsCenter.cpp | 14 ++++++++++++++ CFDStruct/CUIProperty/CUISigsCenter.h | 19 +++++++++++++++++++ 8 files changed, 100 insertions(+), 19 deletions(-) create mode 100644 CFDStruct/CFDStructDataManager/CFDStructSigsCenter.cpp create mode 100644 CFDStruct/CFDStructDataManager/CFDStructSigsCenter.h create mode 100644 CFDStruct/CUIProperty/CUISigsCenter.cpp create mode 100644 CFDStruct/CUIProperty/CUISigsCenter.h diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.cpp b/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.cpp index 30be010..d4bfe25 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.cpp +++ b/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.cpp @@ -1,11 +1,17 @@ #include "CFDStructDataSolverTimeModeManager.h" #include "CUIProperty/CUIConfig.h" #include "CFDStructDataDefine.h" +#include "CFDStructSigsCenter.h" +#include "CUIProperty/CUISigsCenter.h" #include CFDStructDataSolverTimeModeManager::CFDStructDataSolverTimeModeManager(QObject *parent) : QObject(parent) { m_uiConfig = nullptr; + connect(CUISigsCenter::getInstance(), &CUISigsCenter::sig_cuiPropertyChanged, this, [ = ](int semaphore) { + qDebug() << semaphore << " ========================"; + emit CFDStructSigsCenter::getInstance()->sig_solverTimeModeDataChanged(); + }); } CFDStructDataSolverTimeModeManager::~CFDStructDataSolverTimeModeManager() @@ -43,7 +49,8 @@ CUIConfig *CFDStructDataSolverTimeModeManager::genSteadyModeUIConfig() {"type", "ComboBox"}, {"name", "Time Mode"}, {"valueType", "Int"}, - {"valueOrigin", QVA_GLOBAL(&m_runtype)} + {"valueOrigin", QVA_GLOBAL(&m_runtype)}, + {"semaphore", 1}, }, { new CUIConfig({ {"type", "Item"}, @@ -71,7 +78,8 @@ CUIConfig *CFDStructDataSolverTimeModeManager::genUnsteadyModeUIConfig() {"type", "ComboBox"}, {"name", "Time Mode"}, {"valueType", "Int"}, - {"valueOrigin", QVA_GLOBAL(&m_runtype)} + {"valueOrigin", QVA_GLOBAL(&m_runtype)}, + {"semaphore", 1}, }, { new CUIConfig({ {"type", "Item"}, diff --git a/CFDStruct/CFDStructDataManager/CFDStructSigsCenter.cpp b/CFDStruct/CFDStructDataManager/CFDStructSigsCenter.cpp new file mode 100644 index 0000000..ad0ec67 --- /dev/null +++ b/CFDStruct/CFDStructDataManager/CFDStructSigsCenter.cpp @@ -0,0 +1,14 @@ +#include "CFDStructSigsCenter.h" + +CFDStructSigsCenter* CFDStructSigsCenter::m_instance = nullptr; +CFDStructSigsCenter::CFDStructSigsCenter(QObject *parent) : QObject(parent) +{ +} + +CFDStructSigsCenter *CFDStructSigsCenter::getInstance() +{ + if (m_instance == nullptr) { + m_instance = new CFDStructSigsCenter; + } + return m_instance; +} diff --git a/CFDStruct/CFDStructDataManager/CFDStructSigsCenter.h b/CFDStruct/CFDStructDataManager/CFDStructSigsCenter.h new file mode 100644 index 0000000..5bcd82a --- /dev/null +++ b/CFDStruct/CFDStructDataManager/CFDStructSigsCenter.h @@ -0,0 +1,19 @@ +#ifndef CFDSTRUCTSIGSCENTER_H +#define CFDSTRUCTSIGSCENTER_H + +#include +#include "CFDStructDataManager_global.h" + +class CFDSTRUCTDATAMANAGER_EXPORT CFDStructSigsCenter : public QObject +{ + Q_OBJECT +public: + explicit CFDStructSigsCenter(QObject *parent = nullptr); + static CFDStructSigsCenter* getInstance(); +signals: + void sig_solverTimeModeDataChanged(); +private: + static CFDStructSigsCenter* m_instance; +}; + +#endif // CFDSTRUCTSIGSCENTER_H diff --git a/CFDStruct/CUIProperty/CUIConfig.cpp b/CFDStruct/CUIProperty/CUIConfig.cpp index dc0d2e8..cd13d91 100644 --- a/CFDStruct/CUIProperty/CUIConfig.cpp +++ b/CFDStruct/CUIProperty/CUIConfig.cpp @@ -1,4 +1,5 @@ #include "CUIConfig.h" +#include "CUISigsCenter.h" #include #include "CFDStructDataManager/CFDStructDataDefine.h" #include "CFDStructDataManager/CFDStructSigsCenter.h" @@ -12,6 +13,7 @@ CUIConfig::CUIConfig(QMap property) { setDefault(); this->property = property; + this->m_sigsCenter = CUISigsCenter::getInstance(); } /** @@ -76,6 +78,7 @@ CUIConfig::CUIConfig(QMap property, QVector sub) setDefault(); this->property = property; this->sub = sub; + this->m_sigsCenter = CUISigsCenter::getInstance(); } /** @@ -95,15 +98,19 @@ void CUIConfig::printConfig() void CUIConfig::setValue(QVariant value) { - // TODO QVariant pValue = property["valueOrigin"]; if (property["valueType"] == "Int") { int* ptr = qvariant_cast(pValue); -// if (*ptr != value.toInt()) { - *ptr = value.toInt(); - // TODO,通知参数值发生修改 - QTimer::singleShot(200, CFDStructSigsCenter::getInstance(), &CFDStructSigsCenter::sig_solverTimeModeDataChanged); -// } + if (*ptr != value.toInt()) { + *ptr = value.toInt(); + // 如果需要通知,则通知参数值发生修改 + if (this->getPropertyOriginValue("semaphore") != QVariant::Invalid) { + QTimer::singleShot(50, m_sigsCenter, [ = ]() { + int semaphore = this->getPropertyOriginValue("semaphore").toInt(); + emit m_sigsCenter->sig_cuiPropertyChanged(semaphore); + }); + } + } } } diff --git a/CFDStruct/CUIProperty/CUIConfig.h b/CFDStruct/CUIProperty/CUIConfig.h index 3d535e1..5b551c7 100644 --- a/CFDStruct/CUIProperty/CUIConfig.h +++ b/CFDStruct/CUIProperty/CUIConfig.h @@ -6,6 +6,8 @@ #include #include "CUIPropertyAPI.h" +class CUISigsCenter; + class CUIPropertyAPI CUIConfig { public: @@ -25,6 +27,8 @@ private: QMap property; QVector sub; static int labelMinWidth; + + CUISigsCenter* m_sigsCenter = nullptr; }; #endif // CUICONFIG_H diff --git a/CFDStruct/CUIProperty/CUIProperty.pri b/CFDStruct/CUIProperty/CUIProperty.pri index 065b63f..3463af4 100644 --- a/CFDStruct/CUIProperty/CUIProperty.pri +++ b/CFDStruct/CUIProperty/CUIProperty.pri @@ -1,12 +1,3 @@ -HEADERS += \ - $$PWD/CUIPropertyAPI.h \ - $$PWD/CUIConfig.h \ - -SOURCES += \ - $$PWD/CUIConfig.cpp \ - - - HEADERS += \ CUI.h \ CUIButtonBox.h \ @@ -18,7 +9,10 @@ HEADERS += \ CUIPushButton.h \ CUIRadioButton.h \ CUITabWidget.h \ - CUIWidget.h + CUIWidget.h \ + CUISigsCenter.h \ + CUIPropertyAPI.h \ + CUIConfig.h SOURCES += \ CUI.cpp \ @@ -31,4 +25,6 @@ SOURCES += \ CUIPushButton.cpp \ CUIRadioButton.cpp \ CUITabWidget.cpp \ - CUIWidget.cpp + CUIWidget.cpp \ + CUIConfig.cpp \ + CUISigsCenter.cpp diff --git a/CFDStruct/CUIProperty/CUISigsCenter.cpp b/CFDStruct/CUIProperty/CUISigsCenter.cpp new file mode 100644 index 0000000..6e076cd --- /dev/null +++ b/CFDStruct/CUIProperty/CUISigsCenter.cpp @@ -0,0 +1,14 @@ +#include "CUISigsCenter.h" + +CUISigsCenter* CUISigsCenter::m_instance = nullptr; +CUISigsCenter::CUISigsCenter(QObject *parent) : QObject(parent) +{ +} + +CUISigsCenter *CUISigsCenter::getInstance() +{ + if (m_instance == nullptr) { + m_instance = new CUISigsCenter; + } + return m_instance; +} diff --git a/CFDStruct/CUIProperty/CUISigsCenter.h b/CFDStruct/CUIProperty/CUISigsCenter.h new file mode 100644 index 0000000..c8c080d --- /dev/null +++ b/CFDStruct/CUIProperty/CUISigsCenter.h @@ -0,0 +1,19 @@ +#ifndef CUISIGSCENTER_H +#define CUISIGSCENTER_H + +#include +#include "CUIPropertyAPI.h" + +class CUIPropertyAPI CUISigsCenter : public QObject +{ + Q_OBJECT +public: + explicit CUISigsCenter(QObject *parent = nullptr); + static CUISigsCenter* getInstance(); +signals: + void sig_cuiPropertyChanged(int); +private: + static CUISigsCenter* m_instance; +}; + +#endif // CUISIGSCENTER_H