fix: 禁止通过数据层和地图删除入口移除当前井

feature/UI-20260528
lh 6 days ago
parent c8cdbafc68
commit 418c8e4d99

@ -496,6 +496,16 @@ bool nmDataAnalyzeManager::removeWell(nmDataWellBase* pWellData)
void nmDataAnalyzeManager::removeWellDataAndPlot(nmDataWellBase* pWellData)
{
// 参数校验
if(pWellData == nullptr) {
return;
}
// 公共删井入口中不允许删除当前井,避免活动井引用失效
if(pWellData == getCurWellData()) {
return;
}
nmDataPlotContextProvider* pPlotContextProvider = nmDataPlotContext::provider();
if (m_pNmGuiPlot != nullptr && pPlotContextProvider != nullptr)
{

@ -44,7 +44,8 @@
#include "nmObjRegion.h"
#include "nmObjDeleteTool.h"
#include "nmObjDeleteTool.h"
#include "nmDataAnalyzeManager.h"
#include "nmDataOutline.h"
@ -53,7 +54,8 @@
#include "ZxDataGaugeP.h"
#include "ZxDataGaugeF.h"
#include <QWidget>
#include <QWidget>
nmGuiPlot::nmGuiPlot(bool bUseBtns, QWidget *parent) :
iGuiPlot(bUseBtns, parent)
@ -74,7 +76,8 @@ nmGuiPlot::nmGuiPlot(bool bUseBtns, QWidget *parent) :
setWindowTitle(tr("nmGuiPlot"));
m_iRegionMarkCount = 0;
}
}
nmGuiPlot::~nmGuiPlot()
{
@ -885,6 +888,11 @@ void nmGuiPlot::slotDeleteWell(QString wellID)
return;
}
// 当前井作为活动分析井保留,不允许从地图中直接删除
if(obj->getNmWellData() == nmDataAnalyzeManager::getCurrentInstance()->getCurWellData()) {
return;
}
// // 创建一个QTimer对象
// QTimer* timer = new QTimer();
// // 创建一个要执行的单次任务
@ -1324,6 +1332,30 @@ void nmGuiPlot::slotDeleteOneObj(QString sName, void* obj)
}
if(sName != NULL) {
// 删除前先校验目标对象。
// 如果目标不存在,或目标井就是当前活动井,则结束删除工具并直接返回,
// 避免当前井被从地图上删除,同时保证界面退出删除状态。
nmObjDeleteTool* pDeleteTool = static_cast<nmObjDeleteTool*>(obj);
nmObjBase* nmObj = dynamic_cast<nmObjBase*>(m_pPlot->getObjByName(sName));
if(nmObj == nullptr) {
if(pDeleteTool) {
m_pPlot->removeTools(pDeleteTool);
}
return;
}
if(nmObjPointWell* pWellObj = dynamic_cast<nmObjPointWell*>(nmObj)) {
nmDataWellBase* pCurWell = nmDataAnalyzeManager::getCurrentInstance()->getCurWellData();
if(pWellObj->getNmWellData() == pCurWell) {
if(pDeleteTool) {
m_pPlot->removeTools(pDeleteTool);
}
return;
}
}
nmPlotDialogContextProvider* pDialogProvider = nmPlotDialogContext::provider();
if(pDialogProvider != nullptr && pDialogProvider->confirmDeleteObject()) {

Loading…
Cancel
Save