#include "nmWxRCWell.h" #include #include #include #include #include #include #include nmWxRCWell::nmWxRCWell(QVector wellNames, QVector wellsRadius, QWidget *parent) : m_vWellNames(wellNames), m_vWellsRadius(wellsRadius), QWidget(parent) { this->initDefaultValue(); this->initUI(); } void nmWxRCWell::on_selectWell(int index) { qDebug() << index; this->showWellDetail(index); } void nmWxRCWell::on_wellSkinChanged(QString v) { int index = m_pWellListWidget->currentRow(); m_vWellsSkin[index] = v.toDouble(); } void nmWxRCWell::initDefaultValue() { // 根据井的数量初始化默认值 for (int i = 0; i < m_vWellNames.size(); i++) { // 井的表皮系数 m_vWellsSkin.append(0); // 井储系数 m_vWellsReservoirFactor.append(0.1); // 流量段 m_vWellsTimeNum.append(2); } } void nmWxRCWell::initUI() { QHBoxLayout* layout = new QHBoxLayout; this->setLayout(layout); QListWidget* wellListWidget = this->initListWidget(); // 坐标的列表页 layout->addWidget(wellListWidget); QWidget* detailWidget = this->initWellDetailWidget(); // 右边的详情页 layout->addWidget(detailWidget); // 设置宽度比例 layout->setStretchFactor(wellListWidget, 1); layout->setStretchFactor(detailWidget, 2); // 设置默认是第1口井 wellListWidget->setCurrentRow(0); } QListWidget* nmWxRCWell::initListWidget() { m_pWellListWidget = new QListWidget; m_pWellListWidget->addItems(m_vWellNames.toList()); connect(m_pWellListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(on_selectWell(int))); return m_pWellListWidget; } QWidget* nmWxRCWell::initWellDetailWidget() { QWidget* detailWidget = new QWidget; QVBoxLayout* mainLayout = new QVBoxLayout; detailWidget->setLayout(mainLayout); // 1、井的通用设置 QFormLayout* layout = new QFormLayout; // 显示井的半径 m_pWellRadiusEdit = new QLineEdit; m_pWellRadiusEdit->setEnabled(false); layout->addRow(new QLabel(tr("radius")), m_pWellRadiusEdit); // 井的表皮系数 m_pWellSkinEdit = new QLineEdit; connect(m_pWellSkinEdit, SIGNAL(textChanged(QString)), this, SLOT(on_wellSkinChanged(QString))); layout->addRow(new QLabel(tr("skin")), m_pWellSkinEdit); // 井储系数 m_pWellReservoirFactorEdit = new QLineEdit; layout->addRow(new QLabel(tr("RF")), m_pWellReservoirFactorEdit); // 井的流量段,比如:井的流量段时2,则有2个持续时间和2个流量 m_pWellTimeEdit = new QLineEdit; layout->addRow(new QLabel(tr("TimeNum")), m_pWellTimeEdit); mainLayout->addLayout(layout); // 勾选是 统一设置,还是 单独设置 // 2、井的流量设置 m_pTimeTableWidget = new QTableWidget; mainLayout->addWidget(m_pTimeTableWidget); return detailWidget; } void nmWxRCWell::showWellDetail(int index) { qDebug() << "show well detail " << index << m_vWellsRadius.size(); m_pWellRadiusEdit->setText(QString::number(m_vWellsRadius[index])); // 井的表皮系数 m_pWellSkinEdit->setText(QString::number(m_vWellsSkin[index])); // 井储系数 m_pWellReservoirFactorEdit->setText(QString::number(m_vWellsReservoirFactor[index])); // 井的流量段,比如:井的流量段时2,则有2个持续时间和2个流量 m_pWellTimeEdit->setText(QString::number(m_vWellsTimeNum[index])); }