You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWTAI-Platform/Src/nmNum/nmSubWxs/nmWxPropertyInterpolationDl...

147 lines
5.8 KiB
C++

#include "nmWxPropertyInterpolationDlg.h"
#include <QAbstractItemView>
#include <QComboBox>
#include <QCoreApplication>
#include <QDoubleSpinBox>
#include <QFormLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QHeaderView>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QTableWidget>
#include <QVBoxLayout>
namespace
{
// 使用独立翻译上下文,便于统一维护对话框文本
QString interpolationText(const char* sourceText)
{
return QCoreApplication::translate("nmWxPropertyInterpolationDlg", sourceText);
}
// 创建统一格式的非负数值输入框
QDoubleSpinBox* createNumberSpinBox(QWidget* parent, double value)
{
QDoubleSpinBox* spinBox = new QDoubleSpinBox(parent);
spinBox->setRange(0.0, 1.0e12);
spinBox->setDecimals(6);
spinBox->setValue(value);
spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
return spinBox;
}
}
nmWxPropertyInterpolationDlg::nmWxPropertyInterpolationDlg(QWidget* parent)
: iDlgBase(parent),
m_pPropertyCombo(NULL),
m_pNameEdit(NULL),
m_pNewValueSpin(NULL),
m_pMapPickButton(NULL),
m_pPointTable(NULL),
m_pDeletePointButton(NULL),
m_pClearPointsButton(NULL),
m_pNuggetSpin(NULL),
m_pSillSpin(NULL),
m_pRangeSpin(NULL),
m_pModelCombo(NULL),
m_pPreviewButton(NULL),
m_pApplyButton(NULL)
{
setWindowTitle(interpolationText("Property Interpolation"));
setWindowModality(Qt::NonModal);
setModal(false);
setMinimumSize(520, 620);
resize(560, 680);
initInterpolationUI();
}
void nmWxPropertyInterpolationDlg::initInterpolationUI()
{
QVBoxLayout* mainLayout = new QVBoxLayout(this);
// 插值属性及名称设置
QFormLayout* dataSetLayout = new QFormLayout;
m_pPropertyCombo = new QComboBox(this);
m_pPropertyCombo->addItem(interpolationText("Permeability k"), QString("k"));
m_pPropertyCombo->addItem(interpolationText("Porosity phi"), QString("phi"));
m_pPropertyCombo->addItem(interpolationText("Reservoir thickness h"), QString("h"));
dataSetLayout->addRow(interpolationText("Property:"), m_pPropertyCombo);
m_pNameEdit = new QLineEdit(interpolationText("Permeability"), this);
dataSetLayout->addRow(interpolationText("Name:"), m_pNameEdit);
mainLayout->addLayout(dataSetLayout);
// 测点数据录入区域
QGroupBox* pointGroup = new QGroupBox(interpolationText("Measurement Points"), this);
QVBoxLayout* pointLayout = new QVBoxLayout(pointGroup);
QHBoxLayout* newPointLayout = new QHBoxLayout;
newPointLayout->addWidget(new QLabel(interpolationText("New value:"), pointGroup));
m_pNewValueSpin = createNumberSpinBox(pointGroup, 0.0);
newPointLayout->addWidget(m_pNewValueSpin, 1);
m_pMapPickButton = new QPushButton(interpolationText("Select on Map"), pointGroup);
m_pMapPickButton->setCheckable(true);
// 地图选点功能将在后续阶段接入
m_pMapPickButton->setEnabled(false);
newPointLayout->addWidget(m_pMapPickButton);
pointLayout->addLayout(newPointLayout);
// 每个测点保存坐标及对应的属性值
m_pPointTable = new QTableWidget(0, 3, pointGroup);
QStringList headers;
headers << interpolationText("X") << interpolationText("Y") << interpolationText("Value");
m_pPointTable->setHorizontalHeaderLabels(headers);
m_pPointTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
m_pPointTable->setSelectionBehavior(QAbstractItemView::SelectRows);
m_pPointTable->setSelectionMode(QAbstractItemView::SingleSelection);
m_pPointTable->setAlternatingRowColors(true);
pointLayout->addWidget(m_pPointTable, 1);
// 测点列表管理按钮
QHBoxLayout* pointButtonLayout = new QHBoxLayout;
pointButtonLayout->addStretch();
m_pDeletePointButton = new QPushButton(interpolationText("Delete Selected"), pointGroup);
m_pDeletePointButton->setEnabled(false);
pointButtonLayout->addWidget(m_pDeletePointButton);
m_pClearPointsButton = new QPushButton(interpolationText("Clear"), pointGroup);
m_pClearPointsButton->setEnabled(false);
pointButtonLayout->addWidget(m_pClearPointsButton);
pointLayout->addLayout(pointButtonLayout);
mainLayout->addWidget(pointGroup, 1);
// Kriging插值参数设置
QGroupBox* parameterGroup = new QGroupBox(interpolationText("Kriging Parameters"), this);
QFormLayout* parameterLayout = new QFormLayout(parameterGroup);
m_pNuggetSpin = createNumberSpinBox(parameterGroup, 0.01);
parameterLayout->addRow(interpolationText("Nugget:"), m_pNuggetSpin);
m_pSillSpin = createNumberSpinBox(parameterGroup, 100.0);
parameterLayout->addRow(interpolationText("Sill:"), m_pSillSpin);
m_pRangeSpin = createNumberSpinBox(parameterGroup, 1000.0);
parameterLayout->addRow(interpolationText("Range:"), m_pRangeSpin);
m_pModelCombo = new QComboBox(parameterGroup);
m_pModelCombo->addItem(interpolationText("Spherical (0)"), 0);
m_pModelCombo->addItem(interpolationText("Exponential (1)"), 1);
m_pModelCombo->addItem(interpolationText("Gaussian (2)"), 2);
parameterLayout->addRow(interpolationText("Model:"), m_pModelCombo);
mainLayout->addWidget(parameterGroup);
// 底部操作按钮
QHBoxLayout* buttonLayout = new QHBoxLayout;
m_pPreviewButton = new QPushButton(interpolationText("Preview"), this);
// 插值计算和预览功能将在后续阶段接入
m_pPreviewButton->setEnabled(false);
buttonLayout->addWidget(m_pPreviewButton);
buttonLayout->addStretch();
m_pApplyButton = new QPushButton(interpolationText("Apply"), this);
m_pApplyButton->setEnabled(false);
buttonLayout->addWidget(m_pApplyButton);
QPushButton* closeButton = new QPushButton(interpolationText("Close"), this);
buttonLayout->addWidget(closeButton);
mainLayout->addLayout(buttonLayout);
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
}