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/nmWxGridDlg.cpp

80 lines
2.4 KiB
C++

#include "nmWxGridDlg.h"
#include <QComboBox>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>
nmWxGridDlg::nmWxGridDlg(double *pPebiGridControl):
m_pPebiGridControl(pPebiGridControl),
m_dPebiGridControlTmp(pPebiGridControl ? *pPebiGridControl : 150.0)
{
// 当前网格划分入口只保留PEBI, 这里初始化GridControl临时值.
this->initUI();
this->setWindowTitle(tr("Grid setting"));
this->resize(540, 140);
}
void nmWxGridDlg::on_save()
{
// 保存PEBI GridControl, GridType固定为PEBI, 仅在界面展示.
if (m_pPebiGridControl != NULL) {
*m_pPebiGridControl = m_dPebiGridControlTmp;
}
this->accept();
}
void nmWxGridDlg::on_pebiGridControlChanged(QString newValue)
{
m_dPebiGridControlTmp = newValue.toDouble();
}
void nmWxGridDlg::initUI()
{
QVBoxLayout* mainLayout = new QVBoxLayout;
this->setLayout(mainLayout);
// 内容区域
QGridLayout* contentLayout = new QGridLayout;
contentLayout->addWidget(new QLabel(tr("GridType")), 0, 0);
contentLayout->addWidget(initGridTypeComboBox(), 0, 1);
contentLayout->addWidget(new QLabel(tr("GridSize")), 1, 0);
contentLayout->addWidget(initPebiGridControlEdit(), 1, 1);
contentLayout->addWidget(new QLabel(tr("m")), 1, 2);
mainLayout->addLayout(contentLayout);
// 底部按钮
QHBoxLayout* hLayout = new QHBoxLayout;
QPushButton* saveBT = new QPushButton(tr("Save"));
QPushButton* cancelBT = new QPushButton(tr("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::initPebiGridControlEdit()
{
QLineEdit* pEdit = new QLineEdit;
pEdit->setText(QString::number(m_dPebiGridControlTmp));
// 该值对应PEBI接口中的HX_NWTM_GRID_INPUT::GridControl.
// 监听输入变化
connect(pEdit, SIGNAL(textChanged(QString)), this, SLOT(on_pebiGridControlChanged(QString)));
return pEdit;
}
QComboBox *nmWxGridDlg::initGridTypeComboBox()
{
QComboBox* pComboBox = new QComboBox;
pComboBox->addItem(tr("PEBI"));
pComboBox->setCurrentIndex(0);
// 仅展示PEBI, 不允许切换到其它网格类型.
pComboBox->setEnabled(false);
return pComboBox;
}