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.
nmWATI/Src/nmNum/nmSubWxs/nmWxNewNormalDlg.cpp

205 lines
7.0 KiB
C++

#include "nmWxNewNormalDlg.h"
#include <QFormLayout>
#include <QScrollArea>
#include <QLabel>
#include <QLineEdit>
#include <QCheckBox>
#include <QPushButton>
#include <QDebug>
#include <QVBoxLayout>
#include <QListWidget>
#include "nmData/nmDataLogFile.h"
#include "nmData/nmDataDemo.h"
#include "nmData/nmDefines.h"
#include "ZxResolutionHelper.h"
#include "zxLogInstance.h"
#include "ZxDataObjectDbl.h"
nmWxNewNormalDlg::nmWxNewNormalDlg(nmDataDemo* dataPtr)
{
this->m_pAnalyzeData = dataPtr;
m_mainLayout = NULL;
m_nameEdit = NULL;
m_checkboxWater = NULL;
m_checkboxOil = NULL;
m_checkboxGas = NULL;
m_pvtListWidget = NULL;
m_iiListWidget = NULL;
this->setWindowTitle("New Analyze");
this->initUI();
this->setMinimumSize(QSize(_resoSizeW(400), _resoSizeW(200)));
}
nmWxNewNormalDlg::~nmWxNewNormalDlg()
{
}
void nmWxNewNormalDlg::initUI()
{
nmDataLogFile::getInstance()->writeLog("initUI nmNewDlg");
m_mainLayout = new QVBoxLayout();
Q_ASSERT (NULL != m_mainLayout);
m_mainLayout->setSpacing(20);
m_mainLayout->setMargin(5);
m_mainLayout->setSizeConstraint(QVBoxLayout::SetMinAndMaxSize);
//以ScrollArea来显示,出现滚动条
{
QWidget* pWxBk = new QWidget();
Q_ASSERT (NULL != pWxBk);
pWxBk->setContextMenuPolicy(Qt::CustomContextMenu);
pWxBk->setAutoFillBackground(true);
pWxBk->setLayout(m_mainLayout);
// Area,设置Widget
QScrollArea* pArea = new QScrollArea();
pArea->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
pArea->setWidgetResizable(true);
pArea->setWidget(pWxBk);
pArea->setContextMenuPolicy(Qt::CustomContextMenu);//*/
// Layout, 设置Area。
QVBoxLayout* pLayoutBk = new QVBoxLayout();
pLayoutBk->setSpacing(0);
pLayoutBk->setMargin(0);
pLayoutBk->addWidget(pArea);
setLayout(pLayoutBk);
}
this->renderComponents();
}
void nmWxNewNormalDlg::renderComponents()
{
// TODO渲染新建分析需要的组件
QFormLayout* fLayout = new QFormLayout;
// 创建标签和输入框
// Job名称
QLabel *nameLabel = new QLabel("Job name:");
m_nameEdit = new QLineEdit();
// 相态选择
QLabel *phaseLabel = new QLabel("Phase selection:");
// 创建三个三态复选框
QHBoxLayout *phaseLayout = new QHBoxLayout;
m_checkboxOil = new QCheckBox("Oil");
m_checkboxGas = new QCheckBox("Gas");
m_checkboxWater = new QCheckBox("Water");
phaseLayout->addWidget(m_checkboxOil);
phaseLayout->addWidget(m_checkboxGas);
phaseLayout->addWidget(m_checkboxWater);
// 将标签和输入框添加到表单布局中
fLayout->addRow(nameLabel, m_nameEdit);
fLayout->addRow(phaseLabel, phaseLayout);
// 添加到主框架上
m_mainLayout->addLayout(fLayout);
// PVT和相渗选择
// QHBoxLayout* hLayout = new QHBoxLayout;
QGridLayout* gLayout = new QGridLayout;
gLayout->setMargin(0);
gLayout->setSpacing(2);
this->initPVTList();
this->initIIList();
gLayout->addWidget(new QLabel("PVT"), 0, 0);
gLayout->addWidget(new QLabel("Interinfiltration"), 0, 1);
gLayout->addWidget(m_pvtListWidget, 1, 0);
gLayout->addWidget(m_iiListWidget, 1, 1);
m_mainLayout->addLayout(gLayout);
// 底部按钮
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);
m_mainLayout->addLayout(hLayout);
nmDataLogFile::getInstance()->writeLog("renderComponents nmNewDlg!!!");
}
void nmWxNewNormalDlg::initPVTList()
{
QStringList items;
// items << "New PVT" << "PVT 1" << "PVT 2" << "PVT 3" << "PVT 4" << "PVT 5";
items << "PVT 1" << "PVT 2" << "PVT 3" << "PVT 4" << "PVT 5";
m_pvtListWidget = this->initListWidget("PVT", items);
// 监听itemSelectionChanged
connect(m_pvtListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(on_pvtSelected()));
}
void nmWxNewNormalDlg::initIIList()
{
QStringList items;
// items << "New Interinfiltration" << "Interinfiltration 1" << "Interinfiltration 2" << "Interinfiltration 3" << "Interinfiltration 4" << "Interinfiltration 5";
items << "Interinfiltration 1" << "Interinfiltration 2" << "Interinfiltration 3" << "Interinfiltration 4" << "Interinfiltration 5";
m_iiListWidget = this->initListWidget("Interinfiltration", items);
// 监听itemSelectionChanged
connect(m_iiListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(on_IISelected()));
}
QListWidget *nmWxNewNormalDlg::initListWidget(QString listName, QStringList items)
{
// 创建 QListWidget 实例
QListWidget *listWidget = new QListWidget();
// 设置窗口标题
listWidget->setWindowTitle(listName);
// 将数据添加到 QListWidget
listWidget->addItems(items);
// 设置 QListWidget 为多选模式
listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
listWidget->setMinimumSize(QSize(200, 100));
if (items.length() > 0) {
listWidget->setCurrentRow(0);
}
return listWidget;
}
void nmWxNewNormalDlg::on_pvtSelected()
{
nmDataLogFile::getInstance()->writeLog("on_pvtSelected nmNewDlg!!!");
nmDataLogFile::getInstance()->writeLog(m_pvtListWidget->currentItem()->text());
}
void nmWxNewNormalDlg::on_IISelected()
{
nmDataLogFile::getInstance()->writeLog("on_IISelected nmNewDlg!!!");
nmDataLogFile::getInstance()->writeLog(m_iiListWidget->currentItem()->text());
}
void nmWxNewNormalDlg::on_save()
{
nmDataLogFile::getInstance()->writeLog("on_save nmNewDlg!!!");
// TODO判断是否设置了名称
QString analyzeName = m_nameEdit->text().trimmed();
if (analyzeName.length() == 0) {
QMessageBox::information(NULL, zxAppID, QObject::tr("name is empty"));
return;
} else {
if (m_pAnalyzeData != NULL) {
m_pAnalyzeData->setAnalyzeName(analyzeName);
} else {
QMessageBox::information(NULL, zxAppID, QObject::tr("m_pAnalyzeData is NULL"));
}
}
// TODO判断是否设置了多相流
QList<NM_PHASE_TYPE> phaseList;
if (m_checkboxOil->isChecked()) {
phaseList.append(NM_PHASE_TYPE::PHASE_Oil);
}
if (m_checkboxGas->isChecked()) {
phaseList.append(NM_PHASE_TYPE::PHASE_Gas);
}
if (m_checkboxWater->isChecked()) {
phaseList.append(NM_PHASE_TYPE::PHASE_Water);
}
if (phaseList.length() == 0) {
QMessageBox::information(NULL, zxAppID, QObject::tr("phase is empty"));
return;
} else {
m_pAnalyzeData->setAnalyzeMultiphase(phaseList);
}
// TODO判断是否设置了PVT
m_pAnalyzeData->setAnalyzePVTIndex(m_pvtListWidget->currentRow());
// TODO判断是否设置了相渗
m_pAnalyzeData->setAnalyzeIIIndex(m_iiListWidget->currentRow());
this->accept();
}