diff --git a/Include/nmNum/nmCalculation/nmCalculationDefine.h b/Include/nmNum/nmCalculation/nmCalculationDefine.h index f2a7f5c..cfce67a 100644 --- a/Include/nmNum/nmCalculation/nmCalculationDefine.h +++ b/Include/nmNum/nmCalculation/nmCalculationDefine.h @@ -1,6 +1,12 @@ #ifndef NMCALCULATIONDEFINE_H #define NMCALCULATIONDEFINE_H - +// 网格类型 +enum NM_Grid_Type { + NM_Grid_Triangle = 0, // 三角形 + NM_Grid_Quadrilateral, // 四边形 + NM_Grid_Hexagon, // 六边形 + NM_Grid_UNKNWON +}; #endif // NMCALCULATIONDEFINE_H diff --git a/Include/nmNum/nmSubWxs/nmWxGridDlg.h b/Include/nmNum/nmSubWxs/nmWxGridDlg.h new file mode 100644 index 0000000..1e2bf32 --- /dev/null +++ b/Include/nmNum/nmSubWxs/nmWxGridDlg.h @@ -0,0 +1,34 @@ +#ifndef NMWXGRIDDLG_H +#define NMWXGRIDDLG_H + +#include +#include "nmSubWxs_global.h" +#include "nmCalculationDefine.h" + +class QLineEdit; +class QComboBox; + +class NM_SUB_WXS_EXPORT nmWxGridDlg : public QDialog +{ + Q_OBJECT +public: + nmWxGridDlg(double *pGridSize = NULL, int *pGridType = NULL); +private slots: + void on_save(); + void on_gridSizeChanged(QString); + void on_gridTypeChanged(int); +private: + void initUI(); + QLineEdit* initGridSizeEdit(); + QComboBox* initGridTypeComboBox(); +private: + // 网格大小 + double *m_pGridSize; + double m_dGridSizeTmp; + // 网格类型 + int *m_pGridType; + int m_iGridTypeTmp; + +}; + +#endif // NMWXGRIDDLG_H diff --git a/Src/nmNum/nmSubWnd/nmSubWndGrid.cpp b/Src/nmNum/nmSubWnd/nmSubWndGrid.cpp index fffe746..82fe53e 100644 --- a/Src/nmNum/nmSubWnd/nmSubWndGrid.cpp +++ b/Src/nmNum/nmSubWnd/nmSubWndGrid.cpp @@ -24,11 +24,11 @@ #include "ZxDataProject.h" #include "ZxRstJobWnd.h" #ifdef QT_DEBUG -#include "ZxDataGaugeP.h" + #include "ZxDataGaugeP.h" #endif #ifdef QT_DEBUG -#include "nmXmlHelper.h" + #include "nmXmlHelper.h" #endif #include "nmSubWndGrid.h" @@ -41,6 +41,7 @@ #include "nmGuiPlot.h" #include "nmWxGridVTKContainerWidget.h" +#include "nmWxGridDlg.h" #include #include @@ -62,14 +63,12 @@ nmSubWndGrid::~nmSubWndGrid() void nmSubWndGrid::configWnd() { iSubWndBaseAF::configWnd(); - if(NULL != m_pMainWindow) { disconnect(this, SIGNAL(sigAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea)), \ m_pMainWindow, SLOT(slotAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea))); connect(this, SIGNAL(sigAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea)), \ m_pMainWindow, SLOT(slotAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea))); } - initUI(); } @@ -82,9 +81,7 @@ void nmSubWndGrid::initUI() // initUiDockWxs(); // initUiDockPtys(); } - #ifdef QT_DEBUG - // 示例:如何加载xml文件 if(_nmXmlHelper->loadXmlDefines()) { foreach(nmXmlData* pData, *(_nmXmlHelper->getVecNmXmlDataPtrs())) { @@ -92,22 +89,21 @@ void nmSubWndGrid::initUI() zxLogRunD(QString("%1: %2").arg(pData->m_sName).arg(pData->m_sAlias)); } } - #endif } QWidget* nmSubWndGrid::initUiMainWx() { + // TODO拿到网格设置参数 + // 类型:三角形、四边形和六边形 // 拿到多边形的边界和井的数据 nmGuiPlot* pPlot = (nmGuiPlot*)m_pAnalyzeData->getWxPlot(); QVector outlineInformation = pPlot->getOutlinePoints(); nmDataLogFile::getInstance()->writeLog("==== outline start ===="); - for(int i = 0; i < outlineInformation.count(); i++) { QPointF p = outlineInformation[i]; nmDataLogFile::getInstance()->writeLog(QString("%1 %2").arg(p.x()).arg(p.y())); } - nmDataLogFile::getInstance()->writeLog("==== outline end ===="); QVector> wellList = pPlot->getWellsInformation(); nmDataLogFile::getInstance()->writeLog("==== " + QString::number(outlineInformation.count()) + " ===="); @@ -132,7 +128,6 @@ bool nmSubWndGrid::runCmdBy(QString sName, QString sID) if(sID.toInt() == 5401) { return true; } - return false; } @@ -140,7 +135,6 @@ void nmSubWndGrid::genGeo(QVector outlinePoints, QVector circles; - for(int i = 0; i < vWellsInfo.count(); i++) { QVector vWellInfo = vWellsInfo[i]; QPointF center(vWellInfo[0], vWellInfo[1]); @@ -148,7 +142,6 @@ void nmSubWndGrid::genGeo(QVector outlinePoints, QVectorwriteLog("Command failed to start."); return ; } - // 等待命令执行结束 if(!process.waitForFinished()) { nmDataLogFile::getInstance()->writeLog("Command failed to finish."); return; } - // 读取命令的输出 QByteArray output = process.readAllStandardOutput(); nmDataLogFile::getInstance()->writeLog("Gen grid command output: " + output); @@ -209,21 +197,17 @@ void nmSubWndGrid::genWellFile(QVector> vWellsInfo) double gridNum = 12; QString sDir = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/PreProcessing"); QString sFile = sDir + "oil-2d-wells.txt"; - QFile file(sFile); - //检查 if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { qWarning("Cannot open file for writing: %s", qPrintable(file.errorString())); return; } - QTextStream out(&file); out << vWellsInfo.size() << "\n"; for(int i = 0; i < vWellsInfo.size(); i++) { QVector wellInfo = vWellsInfo[i]; out << wellInfo[0] << " " << wellInfo[1] << " " << wellInfo[2] << " " << gridNum << "\n"; } - file.close(); -} \ No newline at end of file +} diff --git a/Src/nmNum/nmSubWnd/nmSubWndUtils.cpp b/Src/nmNum/nmSubWnd/nmSubWndUtils.cpp index 3a65fc8..6fa58fc 100644 --- a/Src/nmNum/nmSubWnd/nmSubWndUtils.cpp +++ b/Src/nmNum/nmSubWnd/nmSubWndUtils.cpp @@ -19,6 +19,8 @@ #endif #include "nmWxWizard.h" +#include "nmWxGridDlg.h" +#include "nmCalculationDefine.h" #include "nmDataAnalInfo.h" #include "nmDataAnalRun.h" @@ -31,7 +33,6 @@ iSubWnd* nmSubWndUtils::createSubWnd(iRibbonXmlCmd* pCmdInfo) if (NULL == pCmdInfo) { return NULL; } - return createSubWnd(pCmdInfo->m_sID, pCmdInfo->m_sExtInfo); } @@ -40,21 +41,26 @@ iSubWnd* nmSubWndUtils::createSubWnd(QString sID, QString sExt) iSubWnd* pSubWnd = NULL; // Here is your own codes int nID = sID.toInt(); - if (nID == 5001) { // 初始化一个数据类 // TODO,先弹窗做新建分析,再创建subWnd nmWxNewNormalDlg dlg(NULL); - if (dlg.exec() == QDialog::Rejected) { // 对话框被用户显式拒绝 // 在这里处理你的逻辑 return nullptr; } - // TODO,是否已经建立了新建分析 - nmSubWndMain* pSubWndMain = new nmSubWndMain(NULL, sExt); - pSubWnd = pSubWndMain; + // TODO,是否已经建立了新建分析 + nmSubWndMain* pSubWndMain = new nmSubWndMain(NULL, sExt); + pSubWnd = pSubWndMain; } else if (nID == 5114) { + double dGridSize = 0.5; + int iGridType = NM_Grid_Triangle; + // 网格大小、类型 + nmWxGridDlg dlg(&dGridSize, &iGridType); + if (dlg.exec() == QDialog::Rejected) { + return NULL; + } // 网格 nmSubWndGrid* pSubWndGrid = new nmSubWndGrid(NULL, sExt); pSubWnd = pSubWndGrid; @@ -63,12 +69,10 @@ iSubWnd* nmSubWndUtils::createSubWnd(QString sID, QString sExt) nmSubWndPostprocessing* pSubWndPostProcessing = new nmSubWndPostprocessing(NULL, sExt); pSubWnd = pSubWndPostProcessing; } - if (NULL != pSubWnd) { // TODO 此处根据需要设置 改变 标识 pSubWnd->setModified(true); } - return pSubWnd; } @@ -77,7 +81,6 @@ bool nmSubWndUtils::runCmdBySpecial(iRibbonXmlCmd* pCmdInfo) if (NULL == pCmdInfo) { return false; } - return runCmdBySpecial(pCmdInfo->m_sID, pCmdInfo->m_sExtInfo); } @@ -98,7 +101,6 @@ bool nmSubWndUtils::isEnableOfID_Common(QString sID, QString sName, const bool b if (sID.toInt() == 5001) { return true; } - // Here is your own codes if (_isSame(sName, "NmDemo")) { return (bLicensed); @@ -124,12 +126,10 @@ bool nmSubWndUtils::runCmd_NewAnal() pAnalRun->setLoaded(true); // Wizard nmWxWizard* m_pWxWizard = NULL; - if (NULL != m_pWxWizard) { delete m_pWxWizard; m_pWxWizard = NULL; } - m_pWxWizard = new nmWxWizard(); Q_ASSERT (NULL != m_pWxWizard); m_pWxWizard->setWsm(nmWxWizard::NM_WSM_All); @@ -138,14 +138,12 @@ bool nmSubWndUtils::runCmd_NewAnal() m_pWxWizard->appendSubWx(pAnalRun->getWxDataOf(2)); m_pWxWizard->initUI(); Q_ASSERT (NULL != m_pWxWizard); - if (m_pWxWizard->exec() != QDialog::Accepted) { // 删除上面新建 delete pAnalRun; pAnalRun = NULL; return false; } - /* // 把Anal放入内存并且保存 { @@ -238,4 +236,4 @@ bool nmSubWndUtils::runCmd_NewAnal() } }//*/ return true; -} \ No newline at end of file +} diff --git a/Src/nmNum/nmSubWxs/nmWxGridDlg.cpp b/Src/nmNum/nmSubWxs/nmWxGridDlg.cpp new file mode 100644 index 0000000..df4e643 --- /dev/null +++ b/Src/nmNum/nmSubWxs/nmWxGridDlg.cpp @@ -0,0 +1,87 @@ +#include "nmWxGridDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +nmWxGridDlg::nmWxGridDlg(double *pGridSize, int *pGridType): + m_pGridSize(pGridSize), m_pGridType(pGridType) +{ + // 设置初始值 + m_dGridSizeTmp = pGridSize ? *pGridSize : 0.5; + m_iGridTypeTmp = pGridType ? *pGridType : NM_Grid_Triangle; + this->initUI(); +} + +void nmWxGridDlg::on_save() +{ + // 检查第1列是否都写了值,如何不全则不能提交 + qDebug() << "=================" << m_dGridSizeTmp << " " << m_iGridTypeTmp; + if (m_pGridSize != NULL) { + *m_pGridSize = m_dGridSizeTmp; + } + if (m_pGridType != NULL) { + *m_pGridType = m_iGridTypeTmp; + } + this->accept(); +} + +void nmWxGridDlg::on_gridSizeChanged(QString newValue) +{ + qDebug() << newValue; + m_dGridSizeTmp = newValue.toDouble(); +} + +void nmWxGridDlg::on_gridTypeChanged(int index) +{ + m_iGridTypeTmp = index; +} + +void nmWxGridDlg::initUI() +{ + QVBoxLayout* mainLayout = new QVBoxLayout; + this->setLayout(mainLayout); + // 设置内容区域 + QFormLayout* contentLayout = new QFormLayout; + contentLayout->addRow(new QLabel(tr("GridType")), initGridTypeComboBox()); + contentLayout->addRow(new QLabel(tr("GridSize")), initGridSizeEdit()); + mainLayout->addLayout(contentLayout); + // 底部按钮 + QHBoxLayout* hLayout = new QHBoxLayout; + QPushButton* saveBT = new QPushButton("Save"); + QPushButton* cancelBT = new QPushButton("Cancel"); + connect(saveBT, SIGNAL(clicked()), this, SLOT(on_save())); + connect(cancelBT, SIGNAL(clicked()), this, SLOT(reject())); + hLayout->addStretch(); + hLayout->addWidget(saveBT); + hLayout->addWidget(cancelBT); + mainLayout->addLayout(hLayout); +} + +QLineEdit *nmWxGridDlg::initGridSizeEdit() +{ + QLineEdit* pEdit = new QLineEdit; + pEdit->setText(QString::number(m_dGridSizeTmp)); + pEdit->setValidator(new QDoubleValidator(0, 100, 10)); + pEdit->setPlaceholderText(QString("{%1 - %2}").arg(0).arg(100)); + // 监听变化 + connect(pEdit, SIGNAL(textChanged(QString)), this, SLOT(on_gridSizeChanged(QString))); + return pEdit; +} + +QComboBox *nmWxGridDlg::initGridTypeComboBox() +{ + QComboBox* pComboBox = new QComboBox; + QStringList options; + options << tr("Triangle") << tr("Quadrilateral") << tr("Hexagon"); + pComboBox->addItems(options); + pComboBox->setCurrentIndex(m_iGridTypeTmp); + // 监听变化 + connect(pComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_gridTypeChanged(int))); + return pComboBox; +} diff --git a/Src4/nmNum/nmSubWxs/nmSubWxs.pro b/Src4/nmNum/nmSubWxs/nmSubWxs.pro index 7b41061..5c870f5 100644 --- a/Src4/nmNum/nmSubWxs/nmSubWxs.pro +++ b/Src4/nmNum/nmSubWxs/nmSubWxs.pro @@ -63,6 +63,7 @@ INCLUDEPATH += $${wtInclude}/mTool/mToolPvt INCLUDEPATH += $${wtInclude}/nmNum INCLUDEPATH += $${wtInclude}/nmNum/nmData INCLUDEPATH += $${wtInclude}/nmNum/nmSubWxs +INCLUDEPATH += $${wtInclude}/nmNum/nmCalculation INCLUDEPATH += $${wtInclude}/nmNum/nmSubWxs/SubWxs SOURCES += $${wtSrc}/nmNum/nmSubWxs/*.cpp