1、完成时间模式的切换;

feature/struct-menu-20241023
simonyan 2 weeks ago
parent 102aa1de3c
commit ebc8e4e79b

@ -1,11 +1,17 @@
#include "CFDStructDataSolverTimeModeManager.h"
#include "CUIProperty/CUIConfig.h"
#include "CFDStructDataDefine.h"
#include "CFDStructSigsCenter.h"
#include "CUIProperty/CUISigsCenter.h"
#include <QVariant>
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"},

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

@ -0,0 +1,19 @@
#ifndef CFDSTRUCTSIGSCENTER_H
#define CFDSTRUCTSIGSCENTER_H
#include <QObject>
#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

@ -1,4 +1,5 @@
#include "CUIConfig.h"
#include "CUISigsCenter.h"
#include <QDebug>
#include "CFDStructDataManager/CFDStructDataDefine.h"
#include "CFDStructDataManager/CFDStructSigsCenter.h"
@ -12,6 +13,7 @@ CUIConfig::CUIConfig(QMap<QString, QVariant> property)
{
setDefault();
this->property = property;
this->m_sigsCenter = CUISigsCenter::getInstance();
}
/**
@ -76,6 +78,7 @@ CUIConfig::CUIConfig(QMap<QString, QVariant> property, QVector<CUIConfig *> 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<int*>(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);
});
}
}
}
}

@ -6,6 +6,8 @@
#include <QVariant>
#include "CUIPropertyAPI.h"
class CUISigsCenter;
class CUIPropertyAPI CUIConfig
{
public:
@ -25,6 +27,8 @@ private:
QMap<QString, QVariant> property;
QVector<CUIConfig*> sub;
static int labelMinWidth;
CUISigsCenter* m_sigsCenter = nullptr;
};
#endif // CUICONFIG_H

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

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

@ -0,0 +1,19 @@
#ifndef CUISIGSCENTER_H
#define CUISIGSCENTER_H
#include <QObject>
#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
Loading…
Cancel
Save