From 102aa1de3ca89565694f5c6c411ce7ae0a8b3d8d Mon Sep 17 00:00:00 2001 From: simonyan <315082291@qq.com> Date: Tue, 29 Oct 2024 19:36:18 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=AE=9E=E7=8E=B0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E7=9A=84=E8=AE=BE=E7=BD=AE=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=92=8C=E4=B8=80=E4=B8=AA=E5=8F=82=E6=95=B0=E5=88=B0=E5=86=85?= =?UTF-8?q?=E5=AD=98=E7=9A=84=E5=85=B3=E8=81=94=EF=BC=8C=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=B9=8B=E9=97=B4=E7=9A=84=E5=85=B3=E8=81=94?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CFDOperatorsBasicModelManager.cpp | 107 ++++++------ .../CFDOperatorsTimeModeManager.cpp | 45 ++--- .../CFDOperatorsTimeModeManager.h | 8 +- .../CFDStructDataDefine.h | 1 + .../CFDStructDataManager.cpp | 6 +- .../CFDStructDataManager.pri | 2 + .../CFDStructDataManager.pro | 2 + .../CFDStructDataSolverTimeModeManager.cpp | 23 ++- .../CFDStructDataSolverTimeModeManager.h | 6 +- CFDStruct/CFDStructGUI/CFDStructGUI.pro | 2 + .../CFDStructGUI/CFDStructMainWindow.cpp | 150 +++++++--------- CFDStruct/CFDStructGUI/CFDTreeWidget.cpp | 165 ++++++++---------- CFDStruct/CUIProperty/CUI.cpp | 114 ++++++------ CFDStruct/CUIProperty/CUI.h | 10 +- CFDStruct/CUIProperty/CUIComboBox.cpp | 40 ++--- CFDStruct/CUIProperty/CUIConfig.cpp | 8 +- CFDStruct/CUIProperty/CUIConfig.h | 9 +- CFDStruct/CUIProperty/CUIGroupBox.cpp | 8 +- CFDStruct/CUIProperty/CUILineEdit.h | 3 +- CFDStruct/CUIProperty/CUITabWidget.cpp | 6 +- CFDStruct/CUIProperty/CUIWidget.cpp | 8 +- 21 files changed, 341 insertions(+), 382 deletions(-) diff --git a/CFDStruct/CFDOperatorsModel/CFDOperatorsBasicModelManager.cpp b/CFDStruct/CFDOperatorsModel/CFDOperatorsBasicModelManager.cpp index e4fdb4e..bf08dd7 100644 --- a/CFDStruct/CFDOperatorsModel/CFDOperatorsBasicModelManager.cpp +++ b/CFDStruct/CFDOperatorsModel/CFDOperatorsBasicModelManager.cpp @@ -15,8 +15,7 @@ namespace ModelOper { CFDOperatorsBasicModelManager::CFDOperatorsBasicModelManager() { - qDebug()<<"build Time Mode Manager"; - + qDebug() << "build Time Mode Manager"; } CFDOperatorsBasicModelManager::~CFDOperatorsBasicModelManager() @@ -26,12 +25,14 @@ namespace ModelOper bool CFDOperatorsBasicModelManager::execGUI() { QWidget* widget = nullptr; - GUI::MainWindow* mainWindow = dynamic_cast(FITKAPP->getGlobalData()->getMainWindow()); - if (mainWindow == nullptr)return false; + if (mainWindow == nullptr) { + return false; + } GUI::PropertyWidget* propertyWidget = mainWindow->getPropertyWidget(); - if (propertyWidget == nullptr)return false; - + if (propertyWidget == nullptr) { + return false; + } // switch (_operType){ // case ModelOper::OperManagerBase::Edit: // { @@ -39,62 +40,58 @@ namespace ModelOper // break; // } // } - - qDebug()<<"Time Mode Manager11111111111"; + qDebug() << "Time Mode Manager11111111111"; widget = new QLabel("Time Mode Manager11111"); - - CUI* cui = new CUI(new CUIConfig({ - {"type","Widget"} - },{ - new CUIConfig({ - {"type","LineEidt"}, - {"name","Solver type"} - }), - new CUIConfig({ - {"type","ComboBox"}, - {"name","flow model"} - },{}), - new CUIConfig({ - {"type","PushButton"}, - {"name","flow model"} - }), - new CUIConfig({ - {"type","GroupBox"}, - {"name","Fluid properties"} - },{ - new CUIConfig({ - {"type","LineEdit"}, - {"name","Gas composition"} - }), - new CUIConfig({ - {"type","LineEdit"}, - {"name","Gas constant (R)"} - }), - new CUIConfig({ - {"type","LineEdit"}, - {"name","Heat ratio"} - }), - new CUIConfig({ - {"type","LineEdit"}, - {"name","Laminar Prandtl number"} - }), - new CUIConfig({ - {"type","LineEdit"}, - {"name","Turbulent Prandtl number"} - }), - }) - - })); - widget = cui->getUI(); +// CUI* cui = new CUI(new CUIConfig({ +// {"type","Widget"} +// },{ +// new CUIConfig({ +// {"type","LineEidt"}, +// {"name","Solver type"} +// }), +// new CUIConfig({ +// {"type","ComboBox"}, +// {"name","flow model"} +// },{}), +// new CUIConfig({ +// {"type","PushButton"}, +// {"name","flow model"} +// }), +// new CUIConfig({ +// {"type","GroupBox"}, +// {"name","Fluid properties"} +// },{ +// new CUIConfig({ +// {"type","LineEdit"}, +// {"name","Gas composition"} +// }), +// new CUIConfig({ +// {"type","LineEdit"}, +// {"name","Gas constant (R)"} +// }), +// new CUIConfig({ +// {"type","LineEdit"}, +// {"name","Heat ratio"} +// }), +// new CUIConfig({ +// {"type","LineEdit"}, +// {"name","Laminar Prandtl number"} +// }), +// new CUIConfig({ +// {"type","LineEdit"}, +// {"name","Turbulent Prandtl number"} +// }), +// }) +// })); +// widget = cui->getUI(); // if (mainWindow->getPropertyWidget() && widget) { - propertyWidget->setWidget(widget); + propertyWidget->setWidget(widget); // } - return false; } bool CFDOperatorsBasicModelManager::execProfession() { - return true; + return true; } } diff --git a/CFDStruct/CFDOperatorsModel/CFDOperatorsTimeModeManager.cpp b/CFDStruct/CFDOperatorsModel/CFDOperatorsTimeModeManager.cpp index e742468..ccfc478 100644 --- a/CFDStruct/CFDOperatorsModel/CFDOperatorsTimeModeManager.cpp +++ b/CFDStruct/CFDOperatorsModel/CFDOperatorsTimeModeManager.cpp @@ -7,6 +7,8 @@ #include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h" #include "CFDStruct/CUIProperty/CUI.h" #include "CUIProperty/CUIConfig.h" +#include "CFDStructDataManager/CFDStructDataManager.h" +#include "CFDStructDataManager/CFDStructSigsCenter.h" #include #include @@ -16,6 +18,13 @@ namespace ModelOper CFDOperatorsTimeModeManager::CFDOperatorsTimeModeManager() { qDebug() << "build Time Mode Manager"; + CFDStructSigsCenter* sigsCenter = CFDStructSigsCenter::getInstance(); + connect(sigsCenter, &CFDStructSigsCenter::sig_solverTimeModeDataChanged, this, [ = ]() { + QObject sender; + sender.setObjectName("actionTimeModeEdit"); + this->setEmitter(&sender); + this->execGUI(); + }); } CFDOperatorsTimeModeManager::~CFDOperatorsTimeModeManager() @@ -33,41 +42,15 @@ namespace ModelOper if (propertyWidget == nullptr) { return false; } -// switch (_operType){ -// case ModelOper::OperManagerBase::Edit: -// { -// widget = new GUI::TimeModeWidget(this); -// break; -// } -// } qDebug() << " ---------------------- senderName: " << _senderName; qDebug() << "Time Mode Manager11111111111"; widget = new QLabel("Time Mode Manager11111"); - CUI* cui = new CUI(new CUIConfig({ - {"type", "Widget"} - }, { - new CUIConfig({ - {"type", "ComboBox"}, - {"name", "Time Mode"}, - }, { - new CUIConfig({ - {"type", "Item"}, - {"name", "steady"} - }), - new CUIConfig({ - {"type", "Item"}, - {"name", "unsteady"} - }) - }), - new CUIConfig({ - {"type", "LineEdit"}, - {"name", "iteration count"} - }, {}) - })); - widget = cui->getUI(); -// if (mainWindow->getPropertyWidget() && widget) { + if (_senderName == "actionTimeModeEdit") { + CUIConfig* uiConfig = CFDStructDataManager::getInstance()->getActionParamUIConfig(1); +// uiConfig->printConfig(); + widget = new CUI(nullptr, uiConfig); + } propertyWidget->setWidget(widget); -// } return false; } diff --git a/CFDStruct/CFDOperatorsModel/CFDOperatorsTimeModeManager.h b/CFDStruct/CFDOperatorsModel/CFDOperatorsTimeModeManager.h index 5c47b11..37ad131 100644 --- a/CFDStruct/CFDOperatorsModel/CFDOperatorsTimeModeManager.h +++ b/CFDStruct/CFDOperatorsModel/CFDOperatorsTimeModeManager.h @@ -5,11 +5,13 @@ #include "OperatorsModel/OperManagerBase.h" //#include "CFDStructDataManager/CFDStructDataManager.h" -namespace ModelOper { +namespace ModelOper +{ - class CFDOperatorsTimeModeManager : public OperManagerBase { + class CFDOperatorsTimeModeManager : public OperManagerBase + { Q_OBJECT; - public: + public: /** * @brief Construct a new Operators Mesh Base Manager object */ diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataDefine.h b/CFDStruct/CFDStructDataManager/CFDStructDataDefine.h index 54f9e20..4628371 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataDefine.h +++ b/CFDStruct/CFDStructDataManager/CFDStructDataDefine.h @@ -11,6 +11,7 @@ Q_DECLARE_METATYPE(int*) Q_DECLARE_METATYPE(bool*) Q_DECLARE_METATYPE(double*) Q_DECLARE_METATYPE(QString*) +Q_DECLARE_METATYPE(QString) #endif // CFDSTRUCTDATADEFINE_H diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp b/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp index 7e97f2e..88c8d12 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp +++ b/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp @@ -3,9 +3,10 @@ #include "CFDStructDataSolverTimeModeManager.h" #include "CUIProperty/CUIConfig.h" -CFDStructDataManager* m_instance = NULL; +CFDStructDataManager* CFDStructDataManager::m_instance = NULL; CFDStructDataManager::CFDStructDataManager() { + this->initDataManagers(); } CFDStructDataManager *CFDStructDataManager::getInstance() @@ -16,8 +17,9 @@ CFDStructDataManager *CFDStructDataManager::getInstance() return m_instance; } -CUIConfig CFDStructDataManager::getActionParamUIConfig(int i) +CUIConfig* CFDStructDataManager::getActionParamUIConfig(int i) { + return m_solverTimeModeManager->getParamUIConfig(); } void CFDStructDataManager::initDataManagers() diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataManager.pri b/CFDStruct/CFDStructDataManager/CFDStructDataManager.pri index 0ec530c..560a44a 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataManager.pri +++ b/CFDStruct/CFDStructDataManager/CFDStructDataManager.pri @@ -1,9 +1,11 @@ SOURCES += \ $$PWD/CFDStructDataSolverTimeModeManager.cpp \ + $$PWD/CFDStructSigsCenter.cpp \ CFDStructDataManager.cpp \ HEADERS += \ $$PWD/CFDStructDataDefine.h \ $$PWD/CFDStructDataSolverTimeModeManager.h \ + $$PWD/CFDStructSigsCenter.h \ CFDStructDataManager_global.h \ CFDStructDataManager.h diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataManager.pro b/CFDStruct/CFDStructDataManager/CFDStructDataManager.pro index 16f44a0..bb20f1e 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataManager.pro +++ b/CFDStruct/CFDStructDataManager/CFDStructDataManager.pro @@ -59,6 +59,7 @@ win32{ -lFITKInterfaceFlowOF \ -lFITKFlowOFIOHDF5 \ -lOperatorsModel \ + -lCUIProperty \ # -lCFDStructDataManager \ @@ -91,6 +92,7 @@ win32{ -lFITKInterfaceFlowOF \ -lFITKFlowOFIOHDF5 \ -lOperatorsModel \ + -lCUIProperty \ # -lCFDStructDataManager \ diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.cpp b/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.cpp index 5fe4de1..30be010 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.cpp +++ b/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.cpp @@ -1,8 +1,11 @@ #include "CFDStructDataSolverTimeModeManager.h" #include "CUIProperty/CUIConfig.h" +#include "CFDStructDataDefine.h" +#include CFDStructDataSolverTimeModeManager::CFDStructDataSolverTimeModeManager(QObject *parent) : QObject(parent) { + m_uiConfig = nullptr; } CFDStructDataSolverTimeModeManager::~CFDStructDataSolverTimeModeManager() @@ -22,29 +25,35 @@ CUIConfig *CFDStructDataSolverTimeModeManager::getParamUIConfig() // 如果是定常 if (m_runtype == 0) { m_uiConfig = this->genSteadyModeUIConfig(); + qDebug() << " steady ============"; } else { // 如果是非定常 m_uiConfig = this->genUnsteadyModeUIConfig(); + qDebug() << " unsteady ============"; } + m_uiConfig->printConfig(); return m_uiConfig; } CUIConfig *CFDStructDataSolverTimeModeManager::genSteadyModeUIConfig() { return new CUIConfig({ - {"type", "Widget"} - }, { + {"type", "Widget"}}, { new CUIConfig({ {"type", "ComboBox"}, {"name", "Time Mode"}, + {"valueType", "Int"}, + {"valueOrigin", QVA_GLOBAL(&m_runtype)} }, { new CUIConfig({ {"type", "Item"}, - {"name", "steady"} + {"name", "steady"}, + {"data", "0"}, }), new CUIConfig({ {"type", "Item"}, - {"name", "unsteady"} + {"name", "unsteady"}, + {"data", "1"}, }) }), new CUIConfig({ @@ -53,7 +62,6 @@ CUIConfig *CFDStructDataSolverTimeModeManager::genSteadyModeUIConfig() }) }); } - CUIConfig *CFDStructDataSolverTimeModeManager::genUnsteadyModeUIConfig() { return new CUIConfig({ @@ -62,6 +70,8 @@ CUIConfig *CFDStructDataSolverTimeModeManager::genUnsteadyModeUIConfig() new CUIConfig({ {"type", "ComboBox"}, {"name", "Time Mode"}, + {"valueType", "Int"}, + {"valueOrigin", QVA_GLOBAL(&m_runtype)} }, { new CUIConfig({ {"type", "Item"}, @@ -88,8 +98,5 @@ CUIConfig *CFDStructDataSolverTimeModeManager::genUnsteadyModeUIConfig() {"type", "LineEdit"}, {"name", "mcyc"} }) - }); } - - diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.h b/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.h index 236274f..028d62b 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.h +++ b/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.h @@ -2,10 +2,10 @@ #define CFDSTRUCTDATASOLVERTIMEMODEMANAGER_H #include - +#include "CFDStructDataManager_global.h" class CUIConfig; -class CFDStructDataSolverTimeModeManager : public QObject +class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataSolverTimeModeManager : public QObject { Q_OBJECT public: @@ -34,7 +34,7 @@ private: // 鏃跺潎缁熻閲忔暟鎹噰鏍0,1 int m_timeaverage = 0; - CUIConfig* m_uiConfig; + CUIConfig* m_uiConfig = nullptr; }; #endif // CFDSTRUCTDATASOLVERTIMEMODEMANAGER_H diff --git a/CFDStruct/CFDStructGUI/CFDStructGUI.pro b/CFDStruct/CFDStructGUI/CFDStructGUI.pro index c04a097..5c5f95c 100644 --- a/CFDStruct/CFDStructGUI/CFDStructGUI.pro +++ b/CFDStruct/CFDStructGUI/CFDStructGUI.pro @@ -37,6 +37,7 @@ win32{ -lFITKCore \ -lOperatorsInterface \ -lFITKInterfaceGeometry \ + -lCFDStructDataManager \ Debug:CONFIG += console @@ -56,6 +57,7 @@ win32{ -lFITKCore \ -lOperatorsInterface \ -lFITKInterfaceGeometry \ + -lCFDStructDataManager \ Debug:LIBS += -L$$PWD/../../Tools/Win64/SARibbon/libd/ \ -lSARibbonBard \ diff --git a/CFDStruct/CFDStructGUI/CFDStructMainWindow.cpp b/CFDStruct/CFDStructGUI/CFDStructMainWindow.cpp index 991acfe..9843238 100644 --- a/CFDStruct/CFDStructGUI/CFDStructMainWindow.cpp +++ b/CFDStruct/CFDStructGUI/CFDStructMainWindow.cpp @@ -35,68 +35,56 @@ using namespace GUI; -CFDStructMainWindow::CFDStructMainWindow() { +CFDStructMainWindow::CFDStructMainWindow() +{ qDebug() << "new Empty CFDStructMainWindow"; initMainWindowMenu(); initCentralWidget(); initPropertyWidget(); - - setWindowTitle("AreoFlow"); } void CFDStructMainWindow::initCentralWidget() { - - // 子部件水平排布 - QSplitter* spliterLayout = new QSplitter(Qt::Horizontal); - spliterLayout->setMouseTracking(true); - spliterLayout->setHandleWidth(5); - - int mainWindSize = QMainWindow::width(); + // 子部件水平排布 + QSplitter* spliterLayout = new QSplitter(Qt::Horizontal); + spliterLayout->setMouseTracking(true); + spliterLayout->setHandleWidth(5); + int mainWindSize = QMainWindow::width(); // _treeWidget = new MainTreeWidget(this); - m_PropertyWidget = new PropertyWidget(this); - m_PropertyWidget->setMinimumWidth(mainWindSize * 0.65); - _treeWidget = new CFDMainTreeWidget(this,m_PropertyWidget); - - _treeWidget->setMinimumWidth(mainWindSize * 0.4); - _treeWidget->setMaximumWidth(mainWindSize * 0.4); - - m_RenderWidget = new RenderWidget(this); - _tabWidgete = new TabWidget(this); - //m_GroupPropertyWidget = new GroupPropertyWidget(this); - - //添加树界面 - spliterLayout->addWidget(_treeWidget); - - - //添加属性界面 - spliterLayout->addWidget(m_PropertyWidget); - - QSplitter* verLayout = new QSplitter(Qt::Vertical); - spliterLayout->setMouseTracking(true); - spliterLayout->setHandleWidth(5); - verLayout->addWidget(m_RenderWidget); - verLayout->addWidget(_tabWidgete); - - spliterLayout->addWidget(verLayout); - //spliterLayout->addWidget(m_GroupPropertyWidget); - // 设置大小 - spliterLayout->setSizes({ 200, 300, 1000, 200 }); - - auto mainLayout = new QGridLayout(); - mainLayout->setObjectName("CentralGridLayout"); - mainLayout->setContentsMargins(5, 5, 5, 10); - mainLayout->addWidget(spliterLayout); - - _currentWidget->setLayout(mainLayout); - setCentralWidget(_currentWidget); - + m_PropertyWidget = new PropertyWidget(this); + m_PropertyWidget->setMinimumWidth(mainWindSize * 0.65); + _treeWidget = new CFDMainTreeWidget(this, m_PropertyWidget); + _treeWidget->setMinimumWidth(mainWindSize * 0.4); + _treeWidget->setMaximumWidth(mainWindSize * 0.4); + m_RenderWidget = new RenderWidget(this); + _tabWidgete = new TabWidget(this); + //m_GroupPropertyWidget = new GroupPropertyWidget(this); + //添加树界面 + spliterLayout->addWidget(_treeWidget); + //添加属性界面 + spliterLayout->addWidget(m_PropertyWidget); + QSplitter* verLayout = new QSplitter(Qt::Vertical); + spliterLayout->setMouseTracking(true); + spliterLayout->setHandleWidth(5); + verLayout->addWidget(m_RenderWidget); + verLayout->addWidget(_tabWidgete); + spliterLayout->addWidget(verLayout); + //spliterLayout->addWidget(m_GroupPropertyWidget); + // 设置大小 + spliterLayout->setSizes({ 200, 300, 1000, 200 }); + auto mainLayout = new QGridLayout(); + mainLayout->setObjectName("CentralGridLayout"); + mainLayout->setContentsMargins(5, 5, 5, 10); + mainLayout->addWidget(spliterLayout); + _currentWidget->setLayout(mainLayout); + setCentralWidget(_currentWidget); } -void CFDStructMainWindow::initPropertyWidget() { +void CFDStructMainWindow::initPropertyWidget() +{ //CUI* cuiWidget = new CUI(new CUIConfig({ // "type", "Widget", // "name", "main_widget" @@ -108,12 +96,9 @@ void CFDStructMainWindow::initPropertyWidget() { // new CUIConfig({}, {}), // new CUIConfig({}, {}) //})); - - QWidget* cuiwidget = new QWidget(); QVBoxLayout* cuilayout = new QVBoxLayout(); cuiwidget->setLayout(cuilayout); - QGroupBox* gb1 = new QGroupBox("Model"); cuilayout->addWidget(gb1); gb1->setLayout(new QVBoxLayout()); @@ -122,82 +107,71 @@ void CFDStructMainWindow::initPropertyWidget() { gb1->layout()->addWidget(new QRadioButton("RANS")); gb1->layout()->addWidget(new QRadioButton("DES")); gb1->layout()->addWidget(new QRadioButton("CLES")); - QGroupBox* gb2 = new QGroupBox("RANS"); cuilayout->addWidget(gb2); gb2->setLayout(new QVBoxLayout()); gb2->layout()->addWidget(new QRadioButton("S-A")); gb2->layout()->addWidget(new QRadioButton("Menters's κ-ω")); gb2->layout()->addWidget(new QRadioButton("κ-ε")); - QGroupBox* gb3 = new QGroupBox("S-A type"); cuilayout->addWidget(gb3); gb3->setLayout(new QVBoxLayout()); gb3->layout()->addWidget(new QRadioButton("standard")); gb3->layout()->addWidget(new QRadioButton("Edwards")); - QWidget* spacer = new QWidget; spacer->setFixedHeight(400); - // 将弹簧添加到布局中 cuilayout->addWidget(spacer); - - CUI* cui = new CUI(new CUIConfig({ - {"type", "Widget"} - }, { - new CUIConfig({ - {"type", "GroupBox"}, - {"name", "GroupBox_name"} - }, {}) - })); - +// CUI* cui = new CUI(new CUIConfig({ +// {"type", "Widget"} +// }, { +// new CUIConfig({ +// {"type", "GroupBox"}, +// {"name", "GroupBox_name"} +// }, {}) +// })); // CUIConfig* cuiconfig = new CUIConfig({ // {"type","type"}, // {"name","name"} // }); // cuiconfig->printConfig(); - - cuilayout->addWidget(cui->getUI()); - +// cuilayout->addWidget(cui->getUI()); m_PropertyWidget->setWidget(cuiwidget); } -void CFDStructMainWindow::initMainWindowMenu() { - +void CFDStructMainWindow::initMainWindowMenu() +{ initApplicationButton(); - addSARibbonCategoryGeometry(); addSARibbonCategoryMesh(); addSARibbonCategoryCalculation(); addSARibbonCategoryPostProcessing(); addSARibbonCategoryTool(); addSARibbonCategoryCivilAircraftTemplateLibrary(); - _ribbonBar->setCurrentIndex(0); } -void CFDStructMainWindow::addSARibbonCategoryGeometry() { +void CFDStructMainWindow::addSARibbonCategoryGeometry() +{ QString type = tr("Geometry"); SARibbonCategory* gategory = _ribbonBar->addCategoryPage(type); _ribbonBar->raiseCategory(gategory); } -void CFDStructMainWindow::addSARibbonCategoryMesh() { +void CFDStructMainWindow::addSARibbonCategoryMesh() +{ QString type = tr("Mesh"); SARibbonCategory* gategory = _ribbonBar->addCategoryPage(type); _ribbonBar->raiseCategory(gategory); } -void CFDStructMainWindow::addSARibbonCategoryCalculation() { - +void CFDStructMainWindow::addSARibbonCategoryCalculation() +{ // ����һ���µı�ǩ QString type = tr("Calculation"); SARibbonCategory* gategory = _ribbonBar->addCategoryPage(type); _ribbonBar->raiseCategory(gategory); - - QAction* action = nullptr; - //pannel ����һ������ "��������" SARibbonPannel* pannel = gategory->addPannel(tr("Simulation Run")); //action = getAction("actionImportGeometry"); @@ -205,7 +179,6 @@ void CFDStructMainWindow::addSARibbonCategoryCalculation() { action = createAction(tr("Start Calculation"), "actionStartCalculation", ":/icons/createbox.png", tr("Start Calculation")); //��ͼ�����������,������ͼ���С pannelAddAction(pannel, action, SARibbonPannelItem::Large); - //�������� "����͵���" pannel = gategory->addPannel(tr("Import and Export")); //����ͼ��"������" @@ -216,7 +189,6 @@ void CFDStructMainWindow::addSARibbonCategoryCalculation() { action = createAction(tr("Import"), "actionImport", ":/icons/createsphere.png", tr("Import")); //"����"����"����͵���" pannelAddAction(pannel, action, SARibbonPannelItem::Large); - //��������"���������" pannel = gategory->addPannel(tr("Solver Settings")); //����ͼ�� ʱ��ģʽ @@ -234,8 +206,7 @@ void CFDStructMainWindow::addSARibbonCategoryCalculation() { //����ͼ�� �˶����� action = createAction(tr("Motion Properties"), "actionMotionProperties", ":/icons/BoolCommon.png", tr("Motion Properties")); - - //��������"�߽������ͳ�ʼ����" + //��������"�߽������ͳ�ʼ����" pannel = gategory->addPannel(tr("Boundary Conditions and Initial Conditions")); //����ͼ�� �߽����� action = createAction(tr("Boundary Conditions"), "actionBoundaryConditions", ":/icons/BoolCommon.png", tr("Boundary Conditions")); @@ -247,13 +218,13 @@ void CFDStructMainWindow::addSARibbonCategoryCalculation() { action = createAction(tr("Initialization"), "actionInitialization", ":/icons/BoolCommon.png", tr("Initialization")); pannelAddAction(pannel, action, SARibbonPannelItem::Large); - //��������"�������" + //��������"�������" pannel = gategory->addPannel(tr("Computational Control")); //����ͼ�� ������� action = createAction(tr("Computational Control"), "actionComputational Control", ":/icons/Computational Control.png", tr("Computational Control")); pannelAddAction(pannel, action, SARibbonPannelItem::Large); - //��������"�����" + //��������"�����" pannel = gategory->addPannel(tr("Monitors")); //����ͼ�� �в� action = createAction(tr("Residuals"), "actionResiduals", ":/icons/Residuals.png", tr("Residuals")); @@ -267,19 +238,22 @@ void CFDStructMainWindow::addSARibbonCategoryCalculation() { } void CFDStructMainWindow::addSARibbonCategoryPostProcessing() { - QString type = tr("Post Processing"); + + QString type = tr("Post Processing"); SARibbonCategory* gategory = _ribbonBar->addCategoryPage(type); _ribbonBar->raiseCategory(gategory); } void CFDStructMainWindow::addSARibbonCategoryTool() { - QString type = tr("Tool"); + + QString type = tr("Tool"); SARibbonCategory* gategory = _ribbonBar->addCategoryPage(type); _ribbonBar->raiseCategory(gategory); } void CFDStructMainWindow::addSARibbonCategoryCivilAircraftTemplateLibrary() { - QString type = tr("CivilAircraft Template sLibrary"); + + QString type = tr("CivilAircraft Template sLibrary"); SARibbonCategory* gategory = _ribbonBar->addCategoryPage(type); _ribbonBar->raiseCategory(gategory); } diff --git a/CFDStruct/CFDStructGUI/CFDTreeWidget.cpp b/CFDStruct/CFDStructGUI/CFDTreeWidget.cpp index 67a14ef..078f433 100644 --- a/CFDStruct/CFDStructGUI/CFDTreeWidget.cpp +++ b/CFDStruct/CFDStructGUI/CFDTreeWidget.cpp @@ -32,10 +32,12 @@ #include #include -namespace GUI { +namespace GUI +{ CFDTreeWidget::CFDTreeWidget(QWidget* parent, PropertyWidget* m_PropertyWidget): - TreeWidget(parent) { + TreeWidget(parent) + { this->m_PropertyWidget = m_PropertyWidget; //右键 不可少否则右键无反应 setContextMenuPolicy(Qt::CustomContextMenu); @@ -44,160 +46,134 @@ namespace GUI { connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onModelCustomContextMenu(QPoint))); } - void CFDTreeWidget::updateTree(QString s) { + void CFDTreeWidget::updateTree(QString s) + { this->clear(); - if (s == "SolutionAnalysis") { addTreeSolutionAnalysis(); - } else if (s == "Postprocessing") { addTreePostprocessing(); - } else if (s == "Preprocessing") { addTreePreprocessing(); } - setItemsExpandable(true); expandAll(); } - void CFDTreeWidget::addTreePreprocessing() { + void CFDTreeWidget::addTreePreprocessing() + { QTreeWidgetItem* GeometryAndMeshingItem = new QTreeWidgetItem(); - - GeometryAndMeshingItem->setText(0,tr("Preprocessing")); - GeometryAndMeshingItem->setData(1,0,-1); + GeometryAndMeshingItem->setText(0, tr("Preprocessing")); + GeometryAndMeshingItem->setData(1, 0, -1); // GeometryAndMeshingItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_GeometryandMeshing)); - this->addTopLevelItem(GeometryAndMeshingItem); } - void CFDTreeWidget::addTreeSolutionAnalysis() { + void CFDTreeWidget::addTreeSolutionAnalysis() + { QTreeWidgetItem* GeometryAndMeshingItem = new QTreeWidgetItem(); - - GeometryAndMeshingItem->setText(0,tr("Geometry and Meshing")); - GeometryAndMeshingItem->setData(1,0,-1); + GeometryAndMeshingItem->setText(0, tr("Geometry and Meshing")); + GeometryAndMeshingItem->setData(1, 0, -1); GeometryAndMeshingItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_GeometryandMeshing)); - this->addTopLevelItem(GeometryAndMeshingItem); QTreeWidgetItem* mesh = new QTreeWidgetItem(); - - mesh->setText(0,tr("Mesh001")); - mesh->setData(1,0,-1); + mesh->setText(0, tr("Mesh001")); + mesh->setData(1, 0, -1); // mesh->setdata(2,0,QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::)) - GeometryAndMeshingItem->addChild(mesh); QTreeWidgetItem* ComputationalSetupItem = new QTreeWidgetItem(); - - ComputationalSetupItem->setText(0,tr("Computational Setup")); - ComputationalSetupItem->setData(1,0,-1); + ComputationalSetupItem->setText(0, tr("Computational Setup")); + ComputationalSetupItem->setData(1, 0, -1); ComputationalSetupItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetup)); - this->addTopLevelItem(ComputationalSetupItem); QTreeWidgetItem* TimeModeItem = new QTreeWidgetItem(); - - TimeModeItem->setText(0,tr("Time Mode")); - TimeModeItem->setData(1,0,-1); + TimeModeItem->setText(0, tr("Time Mode")); + TimeModeItem->setData(1, 0, -1); TimeModeItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupTimeMode)); - ComputationalSetupItem->addChild(TimeModeItem); QTreeWidgetItem* ComputationalDomainItem = new QTreeWidgetItem(); - - ComputationalDomainItem->setText(0,tr("Computational Domain")); - ComputationalDomainItem->setData(1,0,-1); + ComputationalDomainItem->setText(0, tr("Computational Domain")); + ComputationalDomainItem->setData(1, 0, -1); ComputationalDomainItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomain)); - ComputationalSetupItem->addChild(ComputationalDomainItem); QTreeWidgetItem* SolverItem = new QTreeWidgetItem(); - - SolverItem->setText(0,tr("Solver")); - SolverItem->setData(1,0,-1); + SolverItem->setText(0, tr("Solver")); + SolverItem->setData(1, 0, -1); SolverItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolver)); - ComputationalDomainItem->addChild(SolverItem); QTreeWidgetItem* BasicModelItem = new QTreeWidgetItem(); - - BasicModelItem->setText(0,tr("Basic Model")); - BasicModelItem->setData(1,0,-1); + BasicModelItem->setText(0, tr("Basic Model")); + BasicModelItem->setData(1, 0, -1); BasicModelItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverBasicModel)); SolverItem->addChild(BasicModelItem); QTreeWidgetItem* ViscosityModelItem = new QTreeWidgetItem(); - ViscosityModelItem->setText(0,tr("Viscosity Model")); - ViscosityModelItem->setData(1,0,-1); + ViscosityModelItem->setText(0, tr("Viscosity Model")); + ViscosityModelItem->setData(1, 0, -1); ViscosityModelItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverViscosityModel)); SolverItem->addChild(ViscosityModelItem); QTreeWidgetItem* NumericalMethodsItem = new QTreeWidgetItem(); - NumericalMethodsItem->setText(0,tr("Numerical Methods")); - NumericalMethodsItem->setData(1,0,-1); + NumericalMethodsItem->setText(0, tr("Numerical Methods")); + NumericalMethodsItem->setData(1, 0, -1); NumericalMethodsItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverNumericalMethods)); - SolverItem->addChild(NumericalMethodsItem); QTreeWidgetItem* MotionPropertiesItem = new QTreeWidgetItem(); - - MotionPropertiesItem->setText(0,tr("Motion Properties")); - MotionPropertiesItem->setData(1,0,-1); + MotionPropertiesItem->setText(0, tr("Motion Properties")); + MotionPropertiesItem->setData(1, 0, -1); MotionPropertiesItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverMotionProperties)); - ComputationalDomainItem->addChild(MotionPropertiesItem); QTreeWidgetItem* motion1Item = new QTreeWidgetItem(); motion1Item->setText(0, tr("motion-1")); motion1Item->setData(1, 0, -1); MotionPropertiesItem->addChild(motion1Item); QTreeWidgetItem* BoundaryConditionsItem = new QTreeWidgetItem(); - - BoundaryConditionsItem->setText(0,tr("Boundary Conditions")); - BoundaryConditionsItem->setData(1,0,-1); + BoundaryConditionsItem->setText(0, tr("Boundary Conditions")); + BoundaryConditionsItem->setData(1, 0, -1); BoundaryConditionsItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverBoundaryConditions)); - ComputationalDomainItem->addChild(BoundaryConditionsItem); QTreeWidgetItem* pressureinletItem = new QTreeWidgetItem(); - - pressureinletItem->setText(0,tr("Pressure-Inlet")); - pressureinletItem->setData(1,0,-1); + pressureinletItem->setText(0, tr("Pressure-Inlet")); + pressureinletItem->setData(1, 0, -1); pressureinletItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverBoundaryConditionsPressureInlet)); - BoundaryConditionsItem->addChild(pressureinletItem); QTreeWidgetItem* InitializationItem = new QTreeWidgetItem(); - - InitializationItem->setText(0,tr("Initialization")); - InitializationItem->setData(1,0,-1); + InitializationItem->setText(0, tr("Initialization")); + InitializationItem->setData(1, 0, -1); InitializationItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverInitialization)); - ComputationalDomainItem->addChild(InitializationItem); QTreeWidgetItem* ComputationalControlItem = new QTreeWidgetItem(); - - ComputationalControlItem->setText(0,tr("Computational Control")); - ComputationalControlItem->setData(1,0,-1); + ComputationalControlItem->setText(0, tr("Computational Control")); + ComputationalControlItem->setData(1, 0, -1); ComputationalControlItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverComputationalControl)); - ComputationalDomainItem->addChild(ComputationalControlItem); QTreeWidgetItem* ReferenceQuantityItem = new QTreeWidgetItem(); - ReferenceQuantityItem->setText(0,tr("Reference Quantity")); - ReferenceQuantityItem->setData(1,0,-1); + ReferenceQuantityItem->setText(0, tr("Reference Quantity")); + ReferenceQuantityItem->setData(1, 0, -1); ReferenceQuantityItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverComputationalControlReferenceQuantity)); ComputationalControlItem->addChild(ReferenceQuantityItem); QTreeWidgetItem* MonitorsItem = new QTreeWidgetItem(); - MonitorsItem->setText(0,tr("Monitors")); - MonitorsItem->setData(1,0,-1); + MonitorsItem->setText(0, tr("Monitors")); + MonitorsItem->setData(1, 0, -1); MonitorsItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverMonitors)); ComputationalDomainItem->addChild(MonitorsItem); QTreeWidgetItem* ResidualItem = new QTreeWidgetItem(); - ResidualItem->setText(0,tr("Residual")); - ResidualItem->setData(1,0,-1); + ResidualItem->setText(0, tr("Residual")); + ResidualItem->setData(1, 0, -1); ResidualItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverMonitorsResidual)); MonitorsItem->addChild(ResidualItem); QTreeWidgetItem* AerodynamicForceItem = new QTreeWidgetItem(); - AerodynamicForceItem->setText(0,tr("Aerodynamic Force")); - AerodynamicForceItem->setData(1,0,-1); + AerodynamicForceItem->setText(0, tr("Aerodynamic Force")); + AerodynamicForceItem->setData(1, 0, -1); AerodynamicForceItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverMonitorsAerodynamicForce)); MonitorsItem->addChild(AerodynamicForceItem); QTreeWidgetItem* TurbomachineryPerformanceItem = new QTreeWidgetItem(); - TurbomachineryPerformanceItem->setText(0,tr("Turbomachinery Performance")); - TurbomachineryPerformanceItem->setData(1,0,-1); + TurbomachineryPerformanceItem->setText(0, tr("Turbomachinery Performance")); + TurbomachineryPerformanceItem->setData(1, 0, -1); TurbomachineryPerformanceItem->setData(2, 0, QVariant::fromValue(GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverMonitorsTurbomachineryPerformance)); MonitorsItem->addChild(TurbomachineryPerformanceItem); } - void CFDTreeWidget::addTreePostprocessing() { + void CFDTreeWidget::addTreePostprocessing() + { // _treePostprocessing = new TreeWidget(this); // tabWidget->addTab(_treePostprocessing,tr("Postprocessing")); // qDebug()<<"!!!"; @@ -242,43 +218,46 @@ namespace GUI { void CFDTreeWidget::onItemClicked(QTreeWidgetItem *item, int column) { EventOper::TreeEventOperator* treeOper = Core::FITKOperatorRepo::getInstance()->getOperatorT("ModelTreeEvent"); - if (treeOper == nullptr) return; + if (treeOper == nullptr) { + return; + } EventOper::GraphEventOperator* graphOper = FITKOPERREPO->getOperatorT("GraphPreprocess"); - if (graphOper == nullptr)return; + if (graphOper == nullptr) { + return; + } graphOper->clearHighlight(); - - - if (item == nullptr)return; + if (item == nullptr) { + return; + } int objID = item->data(1, 0).toInt(); GUI::SolutionAnalysisTreeEnum treeType = item->data(2, 0).value(); Interface::FITKGeoEnum::FITKGeometryComType geometryType = item->data(3, 0).value(); - QString name = ""; - switch (treeType) { - case GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupTimeMode:name = "actionTimeModeEdit"; break; - case GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverBasicModel:name = "actionBasicModelEdit"; break; - default:name = ""; + case GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupTimeMode: + name = "actionTimeModeEdit"; + break; + case GUI::SolutionAnalysisTreeEnum::SATree_ComputationalSetupComputationalDomainSolverBasicModel: + name = "actionBasicModelEdit"; + break; + default: + name = ""; } - - qDebug()<getOperatorT(name); - if (acOper == nullptr){ + if (acOper == nullptr) { qDebug("acOper is nullptr"); return; } acOper->setEmitter(&sender); acOper->setArgs("objID", objID); acOper->actionTriggered(); - } - else { + } else { treeOper->moveProcessToStep(0); } - } diff --git a/CFDStruct/CUIProperty/CUI.cpp b/CFDStruct/CUIProperty/CUI.cpp index 65708d0..6311fec 100644 --- a/CFDStruct/CUIProperty/CUI.cpp +++ b/CFDStruct/CUIProperty/CUI.cpp @@ -11,15 +11,17 @@ #include #include #include +#include /** * @brief CUI::CUI 构造函数 * @param conf 配置信息 */ -CUI::CUI(CUIConfig *conf) +CUI::CUI(QWidget *parent, CUIConfig *conf): QWidget(parent) { this->conf = conf; - this->conf->printConfig(); +// this->conf->printConfig(); + qDebug() << "----------------------"; buildUI(); } @@ -28,42 +30,37 @@ CUI::CUI(CUIConfig *conf) */ void CUI::buildUI() { -// QString type = conf->property["type"]; + QWidget* widget = nullptr; QString type = conf->getPropertyValue("type"); - if(type == "") + if(type == "") { return; - - - if(type == "Widget") - { - uiWidget = new CUIWidget(conf,subCUI); - } - if(type == "GroupBox") - { - uiGroupBox = new CUIGroupBox(conf,subCUI); - } - if(type == "LineEdit") - { - uiLineEdit = new CUILineEdit(conf,subCUI); - } - if(type == "TabWidget") - { - uiTabWidget = new CUITabWidget(conf,subCUI); - } - if(type == "ComboBox"){ - uiComboBox = new CUIComboBox(conf,subCUI); - } - if(type == "PushButton"){ - uiPushButton = new CUIPushButton(conf,subCUI); - } - if(type == "CheckBox"){ - uiCheckBox = new CUICheckBox(conf,subCUI); } - if(type == "RadioButton"){ - uiRadioButton = new CUIRadioButton(conf,subCUI); - } - if(type == "ButtonBox"){ - uiButtonBox = new CUIButtonBox(conf,subCUI); + if(type == "Widget") { + widget = new CUIWidget(conf, subCUI); + } else if(type == "GroupBox") { + widget = new CUIGroupBox(conf, subCUI); + } else if(type == "LineEdit") { + widget = new CUILineEdit(conf, subCUI); + } else if(type == "TabWidget") { + widget = new CUITabWidget(conf, subCUI); + } else if(type == "ComboBox") { + widget = new CUIComboBox(conf, subCUI); + } else if(type == "PushButton") { + widget = new CUIPushButton(conf, subCUI); + } else if(type == "CheckBox") { + widget = new CUICheckBox(conf, subCUI); + } else if(type == "RadioButton") { + widget = new CUIRadioButton(conf, subCUI); + } else if(type == "ButtonBox") { + widget = new CUIButtonBox(conf, subCUI); + } + if (widget) { + qDebug() << "----------- ui widget is not null"; + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(widget); + this->setLayout(layout); + } else { + qDebug() << "----------- ui widget is null"; } } @@ -81,37 +78,42 @@ void CUI::check() QWidget *CUI::getUI() { QString type = conf->getPropertyValue("type"); - if(type == "Widget"){ + if(type == "Item") { + return NULL; + } else { + return this; + } + return NULL; + if(type == "Widget") { return uiWidget; } - if(type == "GroupBox"){ + if(type == "GroupBox") { return uiGroupBox; } - if(type == "LineEdit"){ + if(type == "LineEdit") { return uiLineEdit; } - if(type == "TabWidget"){ + if(type == "TabWidget") { return uiTabWidget; } - if(type == "ComboBox"){ + if(type == "ComboBox") { return uiComboBox; } - if(type == "Item"){ + if(type == "Item") { return NULL; } - if(type == "PushButton"){ + if(type == "PushButton") { return uiPushButton; } - if(type == "CheckBox"){ + if(type == "CheckBox") { return uiCheckBox; } - if(type == "ButtonBox"){ + if(type == "ButtonBox") { return uiButtonBox; } - if(type == "RadioButton"){ + if(type == "RadioButton") { return uiRadioButton; } - return NULL; } @@ -144,14 +146,13 @@ qint32 CUI::getMaxLabelWidth() { qint32 res = INT_MIN; QString type = conf->getPropertyValue("type"); - if(type == "LineEdit"){ + if(type == "LineEdit") { res = uiLineEdit->getLabelWidth(); - } - else if(type == "ComboBox"){ + } else if(type == "ComboBox") { res = uiComboBox->getLabelWidth(); - }else{ - for(auto &ui:subCUI){ - res = qMax(res,ui->getMaxLabelWidth()); + } else { + for(auto &ui : subCUI) { + res = qMax(res, ui->getMaxLabelWidth()); } } return res; @@ -160,13 +161,12 @@ qint32 CUI::getMaxLabelWidth() void CUI::setLabelWidth(qint32 width) { QString type = conf->getPropertyValue("type"); - if(type == "LineEdit"){ + if(type == "LineEdit") { uiLineEdit->setLabelWidth(width); - } - else if(type == "ComboBox"){ + } else if(type == "ComboBox") { uiComboBox->setLabelWidth(width); - }else{ - for(auto &ui:subCUI){ + } else { + for(auto &ui : subCUI) { ui->setLabelWidth(width); } } diff --git a/CFDStruct/CUIProperty/CUI.h b/CFDStruct/CUIProperty/CUI.h index bdf4034..dba3cd6 100644 --- a/CFDStruct/CUIProperty/CUI.h +++ b/CFDStruct/CUIProperty/CUI.h @@ -3,6 +3,8 @@ #include #include +#include +#include "CUIPropertyAPI.h" class CUIConfig; class QWidget; class CUIWidget; @@ -19,10 +21,12 @@ class CUIButtonBox; /** * @brief The CUI class 管理类,通过处理config来创建相应的组件并提供服务 */ -class CUI +class CUIPropertyAPI CUI: public QWidget { + Q_OBJECT public: - CUI(CUIConfig* conf); + CUI(QWidget* parent = nullptr, CUIConfig* conf = nullptr); +// CUI(CUIConfig* conf); void buildUI(); void check(); QWidget* getUI(); @@ -44,7 +48,7 @@ private: QVector subCUI; - const QSet haveLabelType = {"LineEdit","ComboBox"}; + const QSet haveLabelType = {"LineEdit", "ComboBox"}; qint32 getMaxLabelWidth(); void setLabelWidth(qint32 width); }; diff --git a/CFDStruct/CUIProperty/CUIComboBox.cpp b/CFDStruct/CUIProperty/CUIComboBox.cpp index 759a3d9..53f5e76 100644 --- a/CFDStruct/CUIProperty/CUIComboBox.cpp +++ b/CFDStruct/CUIProperty/CUIComboBox.cpp @@ -6,6 +6,7 @@ #include #include #include +#include "CFDStructDataManager/CFDStructDataDefine.h" /** * @brief CUIComboBox::CUIComboBox 构造函数 @@ -49,18 +50,16 @@ void CUIComboBox::iniUI(QVector &subCUI) this->setLayout(layout); layout->addWidget(label); layout->addWidget(comboBox); - // layout->setStretchFactor(label,1); - layout->setStretchFactor(comboBox,1); + layout->setStretchFactor(comboBox, 1); // comboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon); // comboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); // label->setMinimumWidth(114); - - qDebug()<minimumSizeHint()<<" combobox"; - + qDebug() << label->minimumSizeHint() << " combobox"; iniComoboBox(); - connect(comboBox,QOverload::of(&QComboBox::activated),[=](int idx){ - qDebug()<itemData(idx); + connect(comboBox, QOverload::of(&QComboBox::activated), [ = ](int idx) { + qDebug() << comboBox->itemData(idx); + this->conf->setValue(idx); }); } @@ -69,22 +68,23 @@ void CUIComboBox::iniUI(QVector &subCUI) */ void CUIComboBox::iniComoboBox() { - for(auto cui:conf->getSub()){ + for(auto cui : conf->getSub()) { QString type = cui->getPropertyValue("type"); - if(type != "Item"){ - qDebug()<<"wrong type!!!"; + if(type != "Item") { + qDebug() << "wrong type!!!"; return; } - - CUI* temp = new CUI(cui); + CUI* temp = new CUI(nullptr, cui); Items.push_back(temp); - - if(temp->getProperty("data_type") == "int") - comboBox->addItem(temp->getProperty("name"),temp->getProperty("data").toInt()); - else if(temp->getProperty("data_type") == "double") - comboBox->addItem(temp->getProperty("name"),temp->getProperty("data").toDouble()); - else - comboBox->addItem(temp->getProperty("name"),temp->getProperty("data")); - + if(temp->getProperty("data_type") == "int") { + comboBox->addItem(temp->getProperty("name"), temp->getProperty("data").toInt()); + } else if(temp->getProperty("data_type") == "double") { + comboBox->addItem(temp->getProperty("name"), temp->getProperty("data").toDouble()); + } else { + comboBox->addItem(temp->getProperty("name"), temp->getProperty("data")); + } } + QVariant vOrigin = conf->getPropertyOriginValue("valueOrigin"); + int *ptr = qvariant_cast(vOrigin); + comboBox->setCurrentIndex(*ptr); } diff --git a/CFDStruct/CUIProperty/CUIConfig.cpp b/CFDStruct/CUIProperty/CUIConfig.cpp index 827116b..dc0d2e8 100644 --- a/CFDStruct/CUIProperty/CUIConfig.cpp +++ b/CFDStruct/CUIProperty/CUIConfig.cpp @@ -1,6 +1,8 @@ #include "CUIConfig.h" #include #include "CFDStructDataManager/CFDStructDataDefine.h" +#include "CFDStructDataManager/CFDStructSigsCenter.h" +#include /** * @brief CUIConfig::CUIConfig 构造函数 @@ -95,9 +97,13 @@ void CUIConfig::setValue(QVariant value) { // TODO QVariant pValue = property["valueOrigin"]; - if (property["valueType"] == "int") { + 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); +// } } } diff --git a/CFDStruct/CUIProperty/CUIConfig.h b/CFDStruct/CUIProperty/CUIConfig.h index 2e6a50e..3d535e1 100644 --- a/CFDStruct/CUIProperty/CUIConfig.h +++ b/CFDStruct/CUIProperty/CUIConfig.h @@ -1,11 +1,12 @@ #ifndef CUICONFIG_H #define CUICONFIG_H -#include -#include -#include +#include +#include +#include +#include "CUIPropertyAPI.h" -class CUIConfig +class CUIPropertyAPI CUIConfig { public: CUIConfig(QMap temp); diff --git a/CFDStruct/CUIProperty/CUIGroupBox.cpp b/CFDStruct/CUIProperty/CUIGroupBox.cpp index ba2dddf..15a9a80 100644 --- a/CFDStruct/CUIProperty/CUIGroupBox.cpp +++ b/CFDStruct/CUIProperty/CUIGroupBox.cpp @@ -27,11 +27,9 @@ void CUIGroupBox::iniUI(QVector &subCUI) // appLayout(); layout = appLayout(conf); this->setLayout(layout); - - qDebug()<conf->getSub().size(); - for(auto conf : this->conf->getSub()){ - CUI* tmp = new CUI(conf); - + qDebug() << this->conf->getSub().size(); + for(auto conf : this->conf->getSub()) { + CUI* tmp = new CUI(nullptr, conf); subCUI.push_back(tmp); layout->addWidget(tmp->getUI()); } diff --git a/CFDStruct/CUIProperty/CUILineEdit.h b/CFDStruct/CUIProperty/CUILineEdit.h index f2d96a7..d97fe5b 100644 --- a/CFDStruct/CUIProperty/CUILineEdit.h +++ b/CFDStruct/CUIProperty/CUILineEdit.h @@ -2,13 +2,14 @@ #define CUILINEEDIT_H #include +#include "CUIPropertyAPI.h" class CUIConfig; class QLabel; class QHBoxLayout; class CUI; -class CUILineEdit : public QWidget +class CUIPropertyAPI CUILineEdit : public QWidget { Q_OBJECT public: diff --git a/CFDStruct/CUIProperty/CUITabWidget.cpp b/CFDStruct/CUIProperty/CUITabWidget.cpp index 652bfc5..e642688 100644 --- a/CFDStruct/CUIProperty/CUITabWidget.cpp +++ b/CFDStruct/CUIProperty/CUITabWidget.cpp @@ -20,9 +20,9 @@ CUITabWidget::CUITabWidget(CUIConfig* conf, QVector &subCUI, QWidget *pare */ void CUITabWidget::iniUI(QVector &subCUI) { - for(auto conf:conf->getSub()){ - CUI* subui = new CUI(conf); + for(auto conf : conf->getSub()) { + CUI* subui = new CUI(nullptr, conf); subCUI.push_back(subui); - this->addTab(subui->getUI(),conf->getPropertyValue("name")); + this->addTab(subui->getUI(), conf->getPropertyValue("name")); } } diff --git a/CFDStruct/CUIProperty/CUIWidget.cpp b/CFDStruct/CUIProperty/CUIWidget.cpp index 394f652..6b29d58 100644 --- a/CFDStruct/CUIProperty/CUIWidget.cpp +++ b/CFDStruct/CUIProperty/CUIWidget.cpp @@ -12,7 +12,7 @@ * @param conf 配置信息 * @param parent */ -CUIWidget::CUIWidget(CUIConfig *conf,QVector &subCUI, QWidget *parent):QWidget(parent) +CUIWidget::CUIWidget(CUIConfig *conf, QVector &subCUI, QWidget *parent): QWidget(parent) { this->conf = conf; iniUI(subCUI); @@ -25,11 +25,9 @@ void CUIWidget::iniUI(QVector &subCUI) { layout = appLayout(conf); this->setLayout(layout); - - // qDebug()<<"widget add layout"; - for(auto &conf : this->conf->getSub()){ - CUI* tmp = new CUI(conf); + for(auto &conf : this->conf->getSub()) { + CUI* tmp = new CUI(nullptr, conf); subCUI.push_back(tmp); layout->addWidget(tmp->getUI()); }