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()));