diff --git a/Include/nmNum/nmData/nmDataAnalyzeManager.h b/Include/nmNum/nmData/nmDataAnalyzeManager.h index ab55625..9ca2441 100644 --- a/Include/nmNum/nmData/nmDataAnalyzeManager.h +++ b/Include/nmNum/nmData/nmDataAnalyzeManager.h @@ -547,6 +547,10 @@ class NM_DATA_EXPORT nmDataAnalyzeManager : public ZxDataObjectBin // 获取属性注册表 nmAttrRegistry* getAttrRegistry() const; + /// @brief 注册所有井的参数到 nmAttrRegistry + /// @note wellCode + "_W_XX" 作为注册名,使双向绑定链路适用于井参数 + void registerWellAttrs(); + signals: void dataChanged(); diff --git a/Include/nmNum/nmGUI/nmGridRowUtils.h b/Include/nmNum/nmGUI/nmGridRowUtils.h index ec3429b..9c516d5 100644 --- a/Include/nmNum/nmGUI/nmGridRowUtils.h +++ b/Include/nmNum/nmGUI/nmGridRowUtils.h @@ -94,6 +94,10 @@ public: /// @param map wellCode到显示名称的映射,如 {"W001": "Well-1", "W002": "测试井A"} void setWellNames(QMap map); + /// @brief 剥离 wellCode 前缀,返回基础参数名(如 "W001_W_X" → "W_X") + /// @return 剥离后的基名;若无前缀匹配则返回空字符串 + QString stripWellPrefix(QString sPara) const; + // ================================================================ // 序列化 // ================================================================ @@ -164,6 +168,11 @@ protected: /// @param bDnMode 是否为设计模式 void buildWellGroups(QMap& mapWellParas, bool bDnMode); + /// @brief 为井分组中的参数项补齐 nameInner(含 wellCode 前缀) + /// @param mapWellParas wellCode → 基参数名列表 + /// @note 必须在 bkAllItems 之后调用,因为 bkAllItems 会重建 m_vecAllItems + void applyWellParaNameInners(const QMap& mapWellParas); + public slots: /// @brief 获取指定参数的当前值(供子项内部查询用) diff --git a/Src/nmNum/nmData/nmDataAnalyzeManager.cpp b/Src/nmNum/nmData/nmDataAnalyzeManager.cpp index 44b2136..e5bbd3b 100644 --- a/Src/nmNum/nmData/nmDataAnalyzeManager.cpp +++ b/Src/nmNum/nmData/nmDataAnalyzeManager.cpp @@ -1350,6 +1350,50 @@ nmAttrRegistry* nmDataAnalyzeManager::getAttrRegistry() const return m_pAttrRegistry; } +// 井基参数名 → 数据成员访问器的映射描述 +struct WellParaDesc { + const char* sName; // 参数基名,如 "W_X" + nmDataAttribute* (*getAttr)(nmDataWellBase&); // 访问器函数指针 +}; + +static nmDataAttribute* getParaX(nmDataWellBase& w) { return &w.getX(); } +static nmDataAttribute* getParaY(nmDataWellBase& w) { return &w.getY(); } +static nmDataAttribute* getParaRw(nmDataWellBase& w) { return &w.getRadius(); } +static nmDataAttribute* getParaC(nmDataWellBase& w) { return &w.getWellboreStorage(); } +static nmDataAttribute* getParaSkin(nmDataWellBase& w) +{ + return w.getPerforationCount() > 0 ? &w.getPerforation(0)->getSkin() : NULL; +} + +static const WellParaDesc WELL_PARA_DESCS[] = { + {"W_X", &getParaX}, + {"W_Y", &getParaY}, + {"W_Rw", &getParaRw}, + {"W_C", &getParaC}, + {"W_Skin", &getParaSkin}, +}; +static const int WELL_PARA_DESC_COUNT = sizeof(WELL_PARA_DESCS) / sizeof(WELL_PARA_DESCS[0]); + +void nmDataAnalyzeManager::registerWellAttrs() +{ + if (m_pAttrRegistry == NULL) return; + + foreach (nmDataWellBase* pWell, m_vWellData) + { + QString code = pWell->getWellCode(); + if (code.isEmpty()) continue; + + for (int i = 0; i < WELL_PARA_DESC_COUNT; ++i) + { + nmDataAttribute* pAttr = WELL_PARA_DESCS[i].getAttr(*pWell); + if (pAttr != NULL) + { + m_pAttrRegistry->regAttr(code + "_" + WELL_PARA_DESCS[i].sName, pAttr); + } + } + } +} + nmDataReservoir nmDataAnalyzeManager::getReservoirDataCopy() const { if(m_reservoirData) { diff --git a/Src/nmNum/nmGUI/nmGridRowUtils.cpp b/Src/nmNum/nmGUI/nmGridRowUtils.cpp index c9549f1..c810e40 100644 --- a/Src/nmNum/nmGUI/nmGridRowUtils.cpp +++ b/Src/nmNum/nmGUI/nmGridRowUtils.cpp @@ -51,7 +51,6 @@ bool nmGridRowUtils::buildRowUtils(QStringList listParas, { return false; } - // 构建井分组 if (!mapWellParas.isEmpty()) { @@ -61,6 +60,9 @@ bool nmGridRowUtils::buildRowUtils(QStringList listParas, bkAllItems(); bindItems(); + // 为井参数项补齐 nameInner(含 wellCode 前缀) + applyWellParaNameInners(mapWellParas); + double h = getUtilHeight(); QRectF rt = QRectF(0, 0, 300, h); setBounds(rt); @@ -70,6 +72,28 @@ bool nmGridRowUtils::buildRowUtils(QStringList listParas, return true; } +void nmGridRowUtils::applyWellParaNameInners(const QMap& mapWellParas) +{ + foreach (const QString& sCode, m_mapWellNames.keys()) + { + QString sPrefix = sCode + "_"; + foreach (iGridRowItem* pItem, m_vecAllItems) + { + if (!pItem) + continue; + const QStringList& listBases = mapWellParas.value(sCode); + foreach (const QString& sBase, listBases) + { + if (pItem->getName() == sBase && !sBase.isEmpty()) + { + pItem->setNameInner(sPrefix + sBase); + break; + } + } + } + } +} + // ================================================================ // 参数读写 // ================================================================ @@ -84,6 +108,19 @@ bool nmGridRowUtils::getParaValue(QString sPara, QVariant& o) return iGridRowUtils::getParaValue(sPara, o); } +QString nmGridRowUtils::stripWellPrefix(QString sPara) const +{ + foreach (const QString& sCode, m_mapWellNames.keys()) + { + QString sPrefix = sCode + "_"; + if (sPara.startsWith(sPrefix)) + { + return sPara.mid(sPrefix.length()); + } + } + return QString(); +} + bool nmGridRowUtils::getAllParaValues(QMap& map, bool bOnlyFitted, bool bClearMap) diff --git a/Src/nmNum/nmSubWnd/nmSubWndUtils.cpp b/Src/nmNum/nmSubWnd/nmSubWndUtils.cpp index 941b407..497aff5 100644 --- a/Src/nmNum/nmSubWnd/nmSubWndUtils.cpp +++ b/Src/nmNum/nmSubWnd/nmSubWndUtils.cpp @@ -430,6 +430,8 @@ bool nmSubWndUtils::fillNmDockWxs(iSubWnd* pSubWnd) pDataManager->createReservoir(); // 1.3 初始化当前井数据 pDataManager->initCurWellData(); + // 注册井参数到 nmAttrRegistry(必须在 initCurWellData 之后,面板构建之前) + pDataManager->registerWellAttrs(); // 1.4 初始化边界数据 nmDataWellBase* pCurWell = pDataManager->getCurWellData(); Q_ASSERT(nullptr != pCurWell); @@ -865,6 +867,8 @@ bool nmSubWndUtils::loadRsts(iSubWnd* pSubWnd, \ pDataManager->initPvtParaFromSubFit(); // 加载本地文件的数据到数据中心里的数据体里(含用户选择的模型类型,覆盖PVT推导结果) pDataManager->loadNmResult(sDir); + // 注册井参数到 nmAttrRegistry(必须在 loadNmResult 之后,面板构建之前) + pDataManager->registerWellAttrs(); // 切换左侧参数视图 pSubWndF->swapAnaNmDocks(true); diff --git a/Src/nmNum/nmSubWxs/nmWxParaPropertyPebi.cpp b/Src/nmNum/nmSubWxs/nmWxParaPropertyPebi.cpp index 4654038..db4ec93 100644 --- a/Src/nmNum/nmSubWxs/nmWxParaPropertyPebi.cpp +++ b/Src/nmNum/nmSubWxs/nmWxParaPropertyPebi.cpp @@ -153,6 +153,13 @@ void nmWxParaPropertyPebi::restoreOldParas(QMap& map) QString sPara = iter.key(); iParameter* p = _paraHelper->getPara(sPara, s_Nm_Serie); + // 带前缀的井参数(如 "W001_W_X")在 XML 中查不到,需剥掉 wellCode 前缀 + if (nullptr == p) + { + QString sBase = m_pGridItemUtils->stripWellPrefix(sPara); + if (!sBase.isEmpty()) + p = _paraHelper->getPara(sBase, s_Nm_Serie); + } if (nullptr == p || p->m_bReadonly) { continue;