1、提供网格设置的弹窗;

feature/ribbon-menu-20240927
simonyan 11 hours ago
parent 1c71e44da7
commit 3497a09f45

@ -1,6 +1,12 @@
#ifndef NMCALCULATIONDEFINE_H #ifndef NMCALCULATIONDEFINE_H
#define 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 #endif // NMCALCULATIONDEFINE_H

@ -0,0 +1,34 @@
#ifndef NMWXGRIDDLG_H
#define NMWXGRIDDLG_H
#include <QDialog>
#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

@ -41,6 +41,7 @@
#include "nmGuiPlot.h" #include "nmGuiPlot.h"
#include "nmWxGridVTKContainerWidget.h" #include "nmWxGridVTKContainerWidget.h"
#include "nmWxGridDlg.h"
#include <QVector> #include <QVector>
#include <QProcess> #include <QProcess>
@ -62,14 +63,12 @@ nmSubWndGrid::~nmSubWndGrid()
void nmSubWndGrid::configWnd() void nmSubWndGrid::configWnd()
{ {
iSubWndBaseAF::configWnd(); iSubWndBaseAF::configWnd();
if(NULL != m_pMainWindow) { if(NULL != m_pMainWindow) {
disconnect(this, SIGNAL(sigAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea)), \ disconnect(this, SIGNAL(sigAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea)), \
m_pMainWindow, SLOT(slotAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea))); m_pMainWindow, SLOT(slotAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea)));
connect(this, SIGNAL(sigAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea)), \ connect(this, SIGNAL(sigAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea)), \
m_pMainWindow, SLOT(slotAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea))); m_pMainWindow, SLOT(slotAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea)));
} }
initUI(); initUI();
} }
@ -82,9 +81,7 @@ void nmSubWndGrid::initUI()
// initUiDockWxs(); // initUiDockWxs();
// initUiDockPtys(); // initUiDockPtys();
} }
#ifdef QT_DEBUG #ifdef QT_DEBUG
// 示例如何加载xml文件 // 示例如何加载xml文件
if(_nmXmlHelper->loadXmlDefines()) { if(_nmXmlHelper->loadXmlDefines()) {
foreach(nmXmlData* pData, *(_nmXmlHelper->getVecNmXmlDataPtrs())) { foreach(nmXmlData* pData, *(_nmXmlHelper->getVecNmXmlDataPtrs())) {
@ -92,22 +89,21 @@ void nmSubWndGrid::initUI()
zxLogRunD(QString("%1: %2").arg(pData->m_sName).arg(pData->m_sAlias)); zxLogRunD(QString("%1: %2").arg(pData->m_sName).arg(pData->m_sAlias));
} }
} }
#endif #endif
} }
QWidget* nmSubWndGrid::initUiMainWx() QWidget* nmSubWndGrid::initUiMainWx()
{ {
// TODO拿到网格设置参数
// 类型:三角形、四边形和六边形
// 拿到多边形的边界和井的数据 // 拿到多边形的边界和井的数据
nmGuiPlot* pPlot = (nmGuiPlot*)m_pAnalyzeData->getWxPlot(); nmGuiPlot* pPlot = (nmGuiPlot*)m_pAnalyzeData->getWxPlot();
QVector<QPointF> outlineInformation = pPlot->getOutlinePoints(); QVector<QPointF> outlineInformation = pPlot->getOutlinePoints();
nmDataLogFile::getInstance()->writeLog("==== outline start ===="); nmDataLogFile::getInstance()->writeLog("==== outline start ====");
for(int i = 0; i < outlineInformation.count(); i++) { for(int i = 0; i < outlineInformation.count(); i++) {
QPointF p = outlineInformation[i]; QPointF p = outlineInformation[i];
nmDataLogFile::getInstance()->writeLog(QString("%1 %2").arg(p.x()).arg(p.y())); nmDataLogFile::getInstance()->writeLog(QString("%1 %2").arg(p.x()).arg(p.y()));
} }
nmDataLogFile::getInstance()->writeLog("==== outline end ===="); nmDataLogFile::getInstance()->writeLog("==== outline end ====");
QVector<QVector<double >> wellList = pPlot->getWellsInformation(); QVector<QVector<double >> wellList = pPlot->getWellsInformation();
nmDataLogFile::getInstance()->writeLog("==== " + QString::number(outlineInformation.count()) + " ===="); nmDataLogFile::getInstance()->writeLog("==== " + QString::number(outlineInformation.count()) + " ====");
@ -132,7 +128,6 @@ bool nmSubWndGrid::runCmdBy(QString sName, QString sID)
if(sID.toInt() == 5401) { if(sID.toInt() == 5401) {
return true; return true;
} }
return false; return false;
} }
@ -140,7 +135,6 @@ void nmSubWndGrid::genGeo(QVector<QPointF> outlinePoints, QVector<QVector<double
{ {
// 井数据结构 // 井数据结构
QVector<CircleWell> circles; QVector<CircleWell> circles;
for(int i = 0; i < vWellsInfo.count(); i++) { for(int i = 0; i < vWellsInfo.count(); i++) {
QVector<double> vWellInfo = vWellsInfo[i]; QVector<double> vWellInfo = vWellsInfo[i];
QPointF center(vWellInfo[0], vWellInfo[1]); QPointF center(vWellInfo[0], vWellInfo[1]);
@ -148,7 +142,6 @@ void nmSubWndGrid::genGeo(QVector<QPointF> outlinePoints, QVector<QVector<double
int wellGridNum = 13; int wellGridNum = 13;
circles.append(CircleWell(center, radius, wellGridNum)); circles.append(CircleWell(center, radius, wellGridNum));
} }
// 面网格设置 // 面网格设置
double gridSize = 0.5; double gridSize = 0.5;
nmDataGeo geo(outlinePoints, circles, gridSize); nmDataGeo geo(outlinePoints, circles, gridSize);
@ -171,25 +164,20 @@ void nmSubWndGrid::genGrid(bool is3D)
// gmsh.exe -2 oil.geo -o oil.vtk // gmsh.exe -2 oil.geo -o oil.vtk
// gmsh.exe -2 oil-2d.geo -o oil-2d.vtk // gmsh.exe -2 oil-2d.geo -o oil-2d.vtk
QString geoName = "oil.geo"; QString geoName = "oil.geo";
if(!is3D) { if(!is3D) {
geoName = "oil-2d.geo"; geoName = "oil-2d.geo";
} }
process.start("gmsh.exe", QStringList() << "-2" << geoName << "-o" << QString(geoName).replace("geo", "vtk") << " -saveall"); process.start("gmsh.exe", QStringList() << "-2" << geoName << "-o" << QString(geoName).replace("geo", "vtk") << " -saveall");
// 等待命令启动 // 等待命令启动
if(!process.waitForStarted()) { if(!process.waitForStarted()) {
nmDataLogFile::getInstance()->writeLog("Command failed to start."); nmDataLogFile::getInstance()->writeLog("Command failed to start.");
return ; return ;
} }
// 等待命令执行结束 // 等待命令执行结束
if(!process.waitForFinished()) { if(!process.waitForFinished()) {
nmDataLogFile::getInstance()->writeLog("Command failed to finish."); nmDataLogFile::getInstance()->writeLog("Command failed to finish.");
return; return;
} }
// 读取命令的输出 // 读取命令的输出
QByteArray output = process.readAllStandardOutput(); QByteArray output = process.readAllStandardOutput();
nmDataLogFile::getInstance()->writeLog("Gen grid command output: " + output); nmDataLogFile::getInstance()->writeLog("Gen grid command output: " + output);
@ -209,21 +197,17 @@ void nmSubWndGrid::genWellFile(QVector<QVector<double >> vWellsInfo)
double gridNum = 12; double gridNum = 12;
QString sDir = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/PreProcessing"); QString sDir = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/PreProcessing");
QString sFile = sDir + "oil-2d-wells.txt"; QString sFile = sDir + "oil-2d-wells.txt";
QFile file(sFile); QFile file(sFile);
//检查 //检查
if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qWarning("Cannot open file for writing: %s", qPrintable(file.errorString())); qWarning("Cannot open file for writing: %s", qPrintable(file.errorString()));
return; return;
} }
QTextStream out(&file); QTextStream out(&file);
out << vWellsInfo.size() << "\n"; out << vWellsInfo.size() << "\n";
for(int i = 0; i < vWellsInfo.size(); i++) { for(int i = 0; i < vWellsInfo.size(); i++) {
QVector<double> wellInfo = vWellsInfo[i]; QVector<double> wellInfo = vWellsInfo[i];
out << wellInfo[0] << " " << wellInfo[1] << " " << wellInfo[2] << " " << gridNum << "\n"; out << wellInfo[0] << " " << wellInfo[1] << " " << wellInfo[2] << " " << gridNum << "\n";
} }
file.close(); file.close();
} }

@ -19,6 +19,8 @@
#endif #endif
#include "nmWxWizard.h" #include "nmWxWizard.h"
#include "nmWxGridDlg.h"
#include "nmCalculationDefine.h"
#include "nmDataAnalInfo.h" #include "nmDataAnalInfo.h"
#include "nmDataAnalRun.h" #include "nmDataAnalRun.h"
@ -31,7 +33,6 @@ iSubWnd* nmSubWndUtils::createSubWnd(iRibbonXmlCmd* pCmdInfo)
if (NULL == pCmdInfo) { if (NULL == pCmdInfo) {
return NULL; return NULL;
} }
return createSubWnd(pCmdInfo->m_sID, pCmdInfo->m_sExtInfo); return createSubWnd(pCmdInfo->m_sID, pCmdInfo->m_sExtInfo);
} }
@ -40,12 +41,10 @@ iSubWnd* nmSubWndUtils::createSubWnd(QString sID, QString sExt)
iSubWnd* pSubWnd = NULL; iSubWnd* pSubWnd = NULL;
// Here is your own codes // Here is your own codes
int nID = sID.toInt(); int nID = sID.toInt();
if (nID == 5001) { if (nID == 5001) {
// 初始化一个数据类 // 初始化一个数据类
// TODO先弹窗做新建分析再创建subWnd // TODO先弹窗做新建分析再创建subWnd
nmWxNewNormalDlg dlg(NULL); nmWxNewNormalDlg dlg(NULL);
if (dlg.exec() == QDialog::Rejected) { if (dlg.exec() == QDialog::Rejected) {
// 对话框被用户显式拒绝 // 对话框被用户显式拒绝
// 在这里处理你的逻辑 // 在这里处理你的逻辑
@ -55,6 +54,13 @@ iSubWnd* nmSubWndUtils::createSubWnd(QString sID, QString sExt)
nmSubWndMain* pSubWndMain = new nmSubWndMain(NULL, sExt); nmSubWndMain* pSubWndMain = new nmSubWndMain(NULL, sExt);
pSubWnd = pSubWndMain; pSubWnd = pSubWndMain;
} else if (nID == 5114) { } 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); nmSubWndGrid* pSubWndGrid = new nmSubWndGrid(NULL, sExt);
pSubWnd = pSubWndGrid; pSubWnd = pSubWndGrid;
@ -63,12 +69,10 @@ iSubWnd* nmSubWndUtils::createSubWnd(QString sID, QString sExt)
nmSubWndPostprocessing* pSubWndPostProcessing = new nmSubWndPostprocessing(NULL, sExt); nmSubWndPostprocessing* pSubWndPostProcessing = new nmSubWndPostprocessing(NULL, sExt);
pSubWnd = pSubWndPostProcessing; pSubWnd = pSubWndPostProcessing;
} }
if (NULL != pSubWnd) { if (NULL != pSubWnd) {
// TODO 此处根据需要设置 改变 标识 // TODO 此处根据需要设置 改变 标识
pSubWnd->setModified(true); pSubWnd->setModified(true);
} }
return pSubWnd; return pSubWnd;
} }
@ -77,7 +81,6 @@ bool nmSubWndUtils::runCmdBySpecial(iRibbonXmlCmd* pCmdInfo)
if (NULL == pCmdInfo) { if (NULL == pCmdInfo) {
return false; return false;
} }
return runCmdBySpecial(pCmdInfo->m_sID, pCmdInfo->m_sExtInfo); 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) { if (sID.toInt() == 5001) {
return true; return true;
} }
// Here is your own codes // Here is your own codes
if (_isSame(sName, "NmDemo")) { if (_isSame(sName, "NmDemo")) {
return (bLicensed); return (bLicensed);
@ -124,12 +126,10 @@ bool nmSubWndUtils::runCmd_NewAnal()
pAnalRun->setLoaded(true); pAnalRun->setLoaded(true);
// Wizard // Wizard
nmWxWizard* m_pWxWizard = NULL; nmWxWizard* m_pWxWizard = NULL;
if (NULL != m_pWxWizard) { if (NULL != m_pWxWizard) {
delete m_pWxWizard; delete m_pWxWizard;
m_pWxWizard = NULL; m_pWxWizard = NULL;
} }
m_pWxWizard = new nmWxWizard(); m_pWxWizard = new nmWxWizard();
Q_ASSERT (NULL != m_pWxWizard); Q_ASSERT (NULL != m_pWxWizard);
m_pWxWizard->setWsm(nmWxWizard::NM_WSM_All); m_pWxWizard->setWsm(nmWxWizard::NM_WSM_All);
@ -138,14 +138,12 @@ bool nmSubWndUtils::runCmd_NewAnal()
m_pWxWizard->appendSubWx(pAnalRun->getWxDataOf(2)); m_pWxWizard->appendSubWx(pAnalRun->getWxDataOf(2));
m_pWxWizard->initUI(); m_pWxWizard->initUI();
Q_ASSERT (NULL != m_pWxWizard); Q_ASSERT (NULL != m_pWxWizard);
if (m_pWxWizard->exec() != QDialog::Accepted) { if (m_pWxWizard->exec() != QDialog::Accepted) {
// 删除上面新建 // 删除上面新建
delete pAnalRun; delete pAnalRun;
pAnalRun = NULL; pAnalRun = NULL;
return false; return false;
} }
/* /*
// 把Anal放入内存并且保存 // 把Anal放入内存并且保存
{ {

@ -0,0 +1,87 @@
#include "nmWxGridDlg.h"
#include <QDebug>
#include <QVBoxLayout>
#include <QFormLayout>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
#include <QComboBox>
#include <QDoubleValidator>
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;
}

@ -63,6 +63,7 @@ INCLUDEPATH += $${wtInclude}/mTool/mToolPvt
INCLUDEPATH += $${wtInclude}/nmNum INCLUDEPATH += $${wtInclude}/nmNum
INCLUDEPATH += $${wtInclude}/nmNum/nmData INCLUDEPATH += $${wtInclude}/nmNum/nmData
INCLUDEPATH += $${wtInclude}/nmNum/nmSubWxs INCLUDEPATH += $${wtInclude}/nmNum/nmSubWxs
INCLUDEPATH += $${wtInclude}/nmNum/nmCalculation
INCLUDEPATH += $${wtInclude}/nmNum/nmSubWxs/SubWxs INCLUDEPATH += $${wtInclude}/nmNum/nmSubWxs/SubWxs
SOURCES += $${wtSrc}/nmNum/nmSubWxs/*.cpp SOURCES += $${wtSrc}/nmNum/nmSubWxs/*.cpp

Loading…
Cancel
Save