|
|
|
|
@ -37,44 +37,33 @@
|
|
|
|
|
|
|
|
|
|
// 静态成员变量定义
|
|
|
|
|
nmWxTimeDependentSkin* nmWxTimeDependentSkin::s_instance = nullptr;
|
|
|
|
|
QString nmWxTimeDependentSkin::s_currentWellName = "";
|
|
|
|
|
nmDataWellBase* nmWxTimeDependentSkin::s_currentWellData = nullptr;
|
|
|
|
|
|
|
|
|
|
void nmWxTimeDependentSkin::showForCurrentWell(nmDataWellBase* pSpecificWellData, QWidget* parent)
|
|
|
|
|
{
|
|
|
|
|
QString currentWellName;
|
|
|
|
|
if (pSpecificWellData) currentWellName = pSpecificWellData->getWellName();
|
|
|
|
|
else {
|
|
|
|
|
auto* cur = nmDataAnalyzeManager::getCurrentInstance()->getCurWellData();
|
|
|
|
|
if (!cur) return;
|
|
|
|
|
currentWellName = cur->getWellName();
|
|
|
|
|
// 绑定实际井对象;同名井或不同分析不能共用旧窗口的数据和图表状态。
|
|
|
|
|
nmDataWellBase* pWellData = pSpecificWellData;
|
|
|
|
|
if (!pWellData) {
|
|
|
|
|
nmDataAnalyzeManager* pManager = nmDataAnalyzeManager::getCurrentInstance();
|
|
|
|
|
if (!pManager) return;
|
|
|
|
|
pWellData = pManager->getCurWellData();
|
|
|
|
|
}
|
|
|
|
|
if (currentWellName.isEmpty()) return;
|
|
|
|
|
|
|
|
|
|
if (s_instance && s_currentWellName == currentWellName) {
|
|
|
|
|
bool isSameDataSource = (pSpecificWellData && s_currentWellData == pSpecificWellData)
|
|
|
|
|
|| (!pSpecificWellData && !s_currentWellData);
|
|
|
|
|
if (isSameDataSource) {
|
|
|
|
|
// 同步父子关系和模态
|
|
|
|
|
if (parent && s_instance->parent() != parent)
|
|
|
|
|
s_instance->setParent(parent, Qt::Dialog);
|
|
|
|
|
|
|
|
|
|
// 刷新数据
|
|
|
|
|
s_instance->reloadFromDataSource(pSpecificWellData);
|
|
|
|
|
if (!pWellData) return;
|
|
|
|
|
|
|
|
|
|
if (s_instance) {
|
|
|
|
|
// 只激活仍在编辑的同一窗口,关闭后重新构造默认的压力/流量界面。
|
|
|
|
|
if (s_instance->isVisible() && s_instance->m_currentWell == pWellData &&
|
|
|
|
|
s_instance->parentWidget() == parent) {
|
|
|
|
|
s_instance->show();
|
|
|
|
|
s_instance->raise();
|
|
|
|
|
s_instance->activateWindow();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
s_instance->close();
|
|
|
|
|
delete s_instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 新建实例
|
|
|
|
|
s_instance = new nmWxTimeDependentSkin(pSpecificWellData, parent);
|
|
|
|
|
s_currentWellName = currentWellName;
|
|
|
|
|
s_currentWellData = pSpecificWellData;
|
|
|
|
|
// 仅入口创建的堆对象关闭即释放,井编辑器中的栈对象仍由调用方管理。
|
|
|
|
|
s_instance = new nmWxTimeDependentSkin(pWellData, parent);
|
|
|
|
|
s_instance->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
|
|
|
|
|
|
s_instance->show();
|
|
|
|
|
s_instance->raise();
|
|
|
|
|
@ -105,6 +94,10 @@ nmWxTimeDependentSkin::nmWxTimeDependentSkin(nmDataWellBase* pWellData, QWidget
|
|
|
|
|
// 使用当前井数据, 来自nmWxNumericalDesign
|
|
|
|
|
m_currentWell = nmDataAnalyzeManager::getCurrentInstance()->getCurWellData();
|
|
|
|
|
}
|
|
|
|
|
// 分析关闭或井对象被替换时立即关闭窗口,避免继续访问上一分析的数据。
|
|
|
|
|
if (m_currentWell) {
|
|
|
|
|
connect(m_currentWell, SIGNAL(destroyed(QObject*)), this, SLOT(onWellDestroyed()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_currentWell != nullptr) {
|
|
|
|
|
// 获取压力和流量数据
|
|
|
|
|
@ -227,44 +220,9 @@ nmWxTimeDependentSkin::~nmWxTimeDependentSkin()
|
|
|
|
|
// 如果静态实例指针指向当前对象,清空静态变量
|
|
|
|
|
if (s_instance == this) {
|
|
|
|
|
s_instance = nullptr;
|
|
|
|
|
s_currentWellName = "";
|
|
|
|
|
s_currentWellData = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxTimeDependentSkin::reloadFromDataSource(nmDataWellBase* pWellData)
|
|
|
|
|
{
|
|
|
|
|
// 1) 重新决定数据源
|
|
|
|
|
m_currentWell = (pWellData != nullptr)
|
|
|
|
|
? pWellData
|
|
|
|
|
: nmDataAnalyzeManager::getCurrentInstance()->getCurWellData();
|
|
|
|
|
|
|
|
|
|
if (!m_currentWell) return;
|
|
|
|
|
if (m_pPressureChart) m_pPressureChart->setCurrentWellData(m_currentWell);
|
|
|
|
|
if (m_pFlowRateChart) m_pFlowRateChart->setCurrentWellData(m_currentWell);
|
|
|
|
|
|
|
|
|
|
// 2) 重新抓取并处理数据
|
|
|
|
|
pressurePoints = m_currentWell->getPressurePoints();
|
|
|
|
|
QVector<QPointF> rawFlowData = m_currentWell->getFlowPoints();
|
|
|
|
|
flowPoints = processFlowData(rawFlowData);
|
|
|
|
|
|
|
|
|
|
// 3) 重新取选中射孔段的副本(保留索引边界)
|
|
|
|
|
int perfCount = m_currentWell->getPerforationCount();
|
|
|
|
|
if (m_currentPerforationIndex >= perfCount) m_currentPerforationIndex = 0;
|
|
|
|
|
m_perforationData = m_currentWell->getPerforationCopy(m_currentPerforationIndex);
|
|
|
|
|
|
|
|
|
|
// 4) 做一次与构造期相同的默认值兜底
|
|
|
|
|
if (m_perforationData.getFlowSegments().isEmpty()) initializeDefaultFlowSegment();
|
|
|
|
|
if (m_perforationData.getSkin0().getValue().toString().isEmpty()) m_perforationData.getSkin0().setValue("0.0");
|
|
|
|
|
if (m_perforationData.getdSkindq().getValue().toString().isEmpty()) m_perforationData.getdSkindq().setValue("0.0");
|
|
|
|
|
double x1,y1,x2,y2; m_perforationData.getLinePositions(x1,y1,x2,y2);
|
|
|
|
|
if (x1==-999.0 || y1==-999.0 || x2==-999.0 || y2==-999.0) m_perforationData.setLinePositions(100.0,0.0,200.0,0.0);
|
|
|
|
|
|
|
|
|
|
// 5) 刷新UI
|
|
|
|
|
updateCharts();
|
|
|
|
|
updateTableFromFlowSegments();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxTimeDependentSkin::initUI()
|
|
|
|
|
{
|
|
|
|
|
// 创建主布局
|
|
|
|
|
@ -2024,6 +1982,12 @@ void nmWxTimeDependentSkin::onAccept()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 对比模式临时禁用了流量相关项,提交前恢复原设置并保存当前拟合线。
|
|
|
|
|
if(m_pChartWidget) {
|
|
|
|
|
saveChartPositionsToData();
|
|
|
|
|
restoreStateAfterSkinVsRate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 副本数据同步回原始射孔段
|
|
|
|
|
m_currentWell->updatePerforation(m_currentPerforationIndex, m_perforationData);
|
|
|
|
|
|
|
|
|
|
@ -2035,6 +1999,15 @@ void nmWxTimeDependentSkin::onReject()
|
|
|
|
|
reject();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxTimeDependentSkin::onWellDestroyed()
|
|
|
|
|
{
|
|
|
|
|
// 数据源已失效,只关闭窗口,不再提交副本或处理图表交互。
|
|
|
|
|
m_currentWell = nullptr;
|
|
|
|
|
m_pPressureChart->setCurrentWellData(nullptr);
|
|
|
|
|
m_pFlowRateChart->setCurrentWellData(nullptr);
|
|
|
|
|
reject();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxTimeDependentSkin::initializeDefaultFlowSegment()
|
|
|
|
|
{
|
|
|
|
|
if(m_currentWell == nullptr) {
|
|
|
|
|
|