From be701c29e2cdfaf52b2d71d632729356c2cd9078 Mon Sep 17 00:00:00 2001 From: lvjunjie Date: Mon, 29 Jun 2026 16:40:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=95=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=90=8E=E5=90=8C=E6=AD=A5=E5=88=B0map=E5=92=8C=E5=B7=A6?= =?UTF-8?q?=E4=BE=A7=E8=8A=82=E7=82=B9=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/nmNum/nmPlot/nmObjPointWell.cpp | 8 ++++++++ Src/nmNum/nmPlot/nmPlotGraphicBinder.cpp | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Src/nmNum/nmPlot/nmObjPointWell.cpp b/Src/nmNum/nmPlot/nmObjPointWell.cpp index c8baf3c..7f00cfd 100644 --- a/Src/nmNum/nmPlot/nmObjPointWell.cpp +++ b/Src/nmNum/nmPlot/nmObjPointWell.cpp @@ -567,6 +567,14 @@ void nmObjPointWell::paintBack(QPainter* painter, const ZxPaintParam& param) m_pGraphicBinder->syncWellData(this); } + // 同步名称标签(用户在属性面板改名后更新画布显示) + if (m_pNameLabel != nullptr) { + QString sName = this->getName(); + if (m_pNameLabel->getText() != sName) { + m_pNameLabel->setText(sName); + } + } + if (m_pWellData == nullptr) { return; } diff --git a/Src/nmNum/nmPlot/nmPlotGraphicBinder.cpp b/Src/nmNum/nmPlot/nmPlotGraphicBinder.cpp index 20d5f39..213f17b 100644 --- a/Src/nmNum/nmPlot/nmPlotGraphicBinder.cpp +++ b/Src/nmNum/nmPlot/nmPlotGraphicBinder.cpp @@ -1364,9 +1364,7 @@ void nmPlotGraphicBinder::removeWellBinding(nmObjPointWell* pGraphic) } // 兜底同步:由井图元在 paintBack 中调用 -// 注意:不同步名称。图元 getName() 返回自动生成的对象名,用它会覆盖数据中心井名, -// 导致重新加载时名称匹配失败。井名通过 afterCreated() 正确设置。 -// 位置/半径等同步已在 paintBack() 主体中完成。此处仅同步图元外观属性用于持久化。 +// 同步图元名称、外观属性到数据中心,用于持久化保存。 void nmPlotGraphicBinder::syncWellData(nmObjPointWell* pGraphic) { if (!pGraphic) return; @@ -1374,6 +1372,19 @@ void nmPlotGraphicBinder::syncWellData(nmObjPointWell* pGraphic) nmDataWellBase* pData = m_mapWellData.value(pGraphic, nullptr); if (!pData) return; + // 同步名称(用户在属性面板改名后,同步到数据中心和框架数据) + QString sName = pGraphic->getName(); + if (!sName.isEmpty()) { + if (pData->getWellName() != sName) { + pData->setWellName(sName); + } + ZxDataWell* pWellData = pGraphic->getWellData(); + if (pWellData && pWellData->getName() != sName) { + pWellData->setName(sName); + pWellData->save(); + } + } + // 同步图元外观属性到井数据(用于保存到 JSON) ZxDot dot = pGraphic->getDot(); pData->setDotStyle(static_cast(dot.style()));