|
|
|
|
#include "nmWxChangeAnal.h"
|
|
|
|
|
|
|
|
|
|
#include "iSubWndFitting.h"
|
|
|
|
|
#include "nmDataAnalyzeManager.h"
|
|
|
|
|
#include "nmSubWxsAnalyzeContext.h"
|
|
|
|
|
#include "nmSubWxsAnalyzeContextProvider.h"
|
|
|
|
|
#include "ZxBaseUtil.h"
|
|
|
|
|
#include "ZxMainWindow.h"
|
|
|
|
|
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QVariant>
|
|
|
|
|
#include <QVector>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
nmWxChangeAnal::nmWxChangeAnal(QWidget* parent, ZxMainWindow* pMainWindow)
|
|
|
|
|
: iDlgBase(parent),
|
|
|
|
|
m_pMainWindow(pMainWindow),
|
|
|
|
|
m_pAnalysisComboBox(nullptr)
|
|
|
|
|
{
|
|
|
|
|
setWindowTitle(tr("Switch analysis"));
|
|
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
|
|
|
|
|
|
|
|
// 布局创建与列表填充分开,初始大小由字体、主题和最终内容共同决定。
|
|
|
|
|
setupUI();
|
|
|
|
|
fillAnalysisList();
|
|
|
|
|
adjustSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxChangeAnal::setupUI()
|
|
|
|
|
{
|
|
|
|
|
QVBoxLayout* pMainLayout = new QVBoxLayout(this);
|
|
|
|
|
pMainLayout->setContentsMargins(12, 10, 12, 0);
|
|
|
|
|
pMainLayout->setSpacing(10);
|
|
|
|
|
|
|
|
|
|
// 表单随窗口横向伸展,控件高度使用字体和主题推荐值。
|
|
|
|
|
QWidget* pForm = new QWidget(this);
|
|
|
|
|
pForm->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
QHBoxLayout* pFormLayout = new QHBoxLayout(pForm);
|
|
|
|
|
pFormLayout->setContentsMargins(0, 5, 0, 5);
|
|
|
|
|
pFormLayout->setSpacing(6);
|
|
|
|
|
QLabel* pAnalysisLabel = new QLabel(tr("Analysis"), pForm);
|
|
|
|
|
pAnalysisLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
|
|
|
pAnalysisLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
|
|
|
|
m_pAnalysisComboBox = new QComboBox(pForm);
|
|
|
|
|
// 用字符数确定推荐宽度,避免固定像素宽度在不同字体和缩放下过窄。
|
|
|
|
|
m_pAnalysisComboBox->setMinimumContentsLength(24);
|
|
|
|
|
m_pAnalysisComboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
|
|
|
|
m_pAnalysisComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
pFormLayout->addWidget(pAnalysisLabel);
|
|
|
|
|
pFormLayout->addWidget(m_pAnalysisComboBox, 1);
|
|
|
|
|
pMainLayout->addWidget(pForm);
|
|
|
|
|
// 纵向余量由表单与按钮区之间的空白吸收,不拉高下拉框。
|
|
|
|
|
pMainLayout->addStretch(1);
|
|
|
|
|
|
|
|
|
|
// 标签和按钮仅在此处使用,由 Qt 父子关系管理,不保留为成员变量。
|
|
|
|
|
QWidget* pFooter = new QWidget(this);
|
|
|
|
|
pFooter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
|
|
|
|
QHBoxLayout* pFooterLayout = new QHBoxLayout(pFooter);
|
|
|
|
|
pFooterLayout->setContentsMargins(4, 5, 4, 5);
|
|
|
|
|
pFooterLayout->setSpacing(8);
|
|
|
|
|
pFooterLayout->addStretch();
|
|
|
|
|
QDialogButtonBox* pButtons = new QDialogButtonBox(
|
|
|
|
|
QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, pFooter);
|
|
|
|
|
QPushButton* pConfirmButton = pButtons->button(QDialogButtonBox::Ok);
|
|
|
|
|
pConfirmButton->setText(tr("OK"));
|
|
|
|
|
pConfirmButton->setIcon(zxLoadIcon("OK"));
|
|
|
|
|
QPushButton* pCancelButton = pButtons->button(QDialogButtonBox::Cancel);
|
|
|
|
|
pCancelButton->setText(tr("Cancel"));
|
|
|
|
|
pCancelButton->setIcon(zxLoadIcon("Cancel"));
|
|
|
|
|
pFooterLayout->addWidget(pButtons);
|
|
|
|
|
pMainLayout->addWidget(pFooter);
|
|
|
|
|
|
|
|
|
|
// 仅按钮触发原有确认、取消流程,下拉框改选不执行切换。
|
|
|
|
|
connect(pConfirmButton, SIGNAL(clicked()), this, SLOT(onConfirmButtonClicked()));
|
|
|
|
|
connect(pCancelButton, SIGNAL(clicked()), this, SLOT(onCancelButtonClicked()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxChangeAnal::fillAnalysisList()
|
|
|
|
|
{
|
|
|
|
|
// 沿用原候选范围:列出当前成果中已初始化数值数据的分析。
|
|
|
|
|
ZxMainWindow* pMainWnd1 = m_pMainWindow;
|
|
|
|
|
if (nullptr != pMainWnd1)
|
|
|
|
|
{
|
|
|
|
|
ZxTabWidget* pTabWx = pMainWnd1->getCurTabWx();
|
|
|
|
|
QVector<iSubWnd*> vecSubWnds = pMainWnd1->getAllSubWndsOf(pTabWx);
|
|
|
|
|
foreach (iSubWnd* pSub, vecSubWnds)
|
|
|
|
|
{
|
|
|
|
|
iSubWndFitting* pSubWndF = dynamic_cast<iSubWndFitting*>(pSub);
|
|
|
|
|
// 分析窗口存在,并且有对应的数据中心已经初始化了边界、井等相关信息
|
|
|
|
|
if (nullptr != pSubWndF && nmDataAnalyzeManager::findManagerByFitting(pSubWndF) != nullptr)
|
|
|
|
|
{
|
|
|
|
|
// 添加项并绑定指针
|
|
|
|
|
int index = m_pAnalysisComboBox->count();
|
|
|
|
|
m_pAnalysisComboBox->addItem(pSubWndF->windowTitle());
|
|
|
|
|
m_pAnalysisComboBox->setItemData(index, QVariant::fromValue<void*>(pSubWndF));
|
|
|
|
|
|
|
|
|
|
// 如果是当前分析项,设为选中
|
|
|
|
|
if (pSubWndF == nmDataAnalyzeManager::getCurrentFitting())
|
|
|
|
|
{
|
|
|
|
|
m_pAnalysisComboBox->setCurrentIndex(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 确认按钮点击处理
|
|
|
|
|
void nmWxChangeAnal::onConfirmButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
// 获取当前选中项的索引
|
|
|
|
|
int index = m_pAnalysisComboBox->currentIndex();
|
|
|
|
|
if (index >= 0)
|
|
|
|
|
{
|
|
|
|
|
// 通过索引获取关联的指针
|
|
|
|
|
QVariant data = m_pAnalysisComboBox->itemData(index);
|
|
|
|
|
if (data.isValid() && data.canConvert<void*>())
|
|
|
|
|
{
|
|
|
|
|
iSubWndFitting* pCurSubWndF = static_cast<iSubWndFitting*>(data.value<void*>());
|
|
|
|
|
|
|
|
|
|
// 切换了分析,则处理
|
|
|
|
|
if (pCurSubWndF != nmDataAnalyzeManager::getCurrentFitting())
|
|
|
|
|
{
|
|
|
|
|
// 创建/获取数据中心类
|
|
|
|
|
nmDataAnalyzeManager::getInstanceByFitting(pCurSubWndF);
|
|
|
|
|
// 设置当前操作的分析
|
|
|
|
|
nmDataAnalyzeManager::setCurrentFitting(pCurSubWndF);
|
|
|
|
|
|
|
|
|
|
//// 遍历主窗口下的所有的流动段分析名称
|
|
|
|
|
ZxMainWindow* pMainWnd1 = const_cast<ZxMainWindow*>(m_pMainWindow);
|
|
|
|
|
nmSubWxsAnalyzeContextProvider* pProvider = nmSubWxsAnalyzeContext::provider();
|
|
|
|
|
if (nullptr != pProvider) {
|
|
|
|
|
pProvider->updateWindowsForCurrentAnalyze(pMainWnd1, pCurSubWndF);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this->accept(); // 接受对话框
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 取消按钮点击处理
|
|
|
|
|
void nmWxChangeAnal::onCancelButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
this->reject(); // 拒绝对话框
|
|
|
|
|
}
|