#pragma once #include "nmSubWxs_global.h" #include #include #include #include #include class nmDataWellBase; class nmDataPerforation; class nmIParameterUnitService; class nmParameterField; struct nmWellParameterGroupInfo; class QComboBox; class QVBoxLayout; /** * @brief 编辑井左侧参数分组面板。 * @note 井型变化时重建分组,普通数据变化只刷新现有字段。 */ class NM_SUB_WXS_EXPORT nmWellParameterPanel : public QWidget { Q_OBJECT public: /** @brief 创建参数面板并注入窗口级单位服务。 */ explicit nmWellParameterPanel( nmIParameterUnitService* pUnitService, QWidget* pParent = nullptr); /** @brief 解除工作副本信号连接并释放字段控件。 */ virtual ~nmWellParameterPanel(); /** @brief 绑定新的井型工作副本并创建对应分组。 */ bool setWellData(nmDataWellBase* pWell, QString& sError); /** @brief 校验并一次性写入当前可见字段。 */ bool commitPendingEdits(QString& sError); /** @brief 返回全部可见输入是否有效。 */ bool isInputValid(); /** @brief 将焦点移动到第一个无效字段。 */ void focusFirstInvalid(); public slots: /** @brief 从工作副本刷新字段,不重建分组控件。 */ void reloadFromWell(); signals: /** @brief 参数有效状态发生变化。 */ void sigValidityChanged(bool bValid); /** @brief 返回当前输入错误,空文字表示有效。 */ void sigValidationMessageChanged(const QString& sMessage); private slots: /** @brief 输入过程中只刷新校验状态,不立即写工作副本。 */ void slotFieldValueEdited(); /** @brief 输入结束后批量提交当前字段。 */ void slotFieldEditingFinished(); /** @brief 保存当前射孔输入后切换到目标射孔段。 */ void slotPerforationChanged(int nIndex); /** @brief 响应轨迹交互产生的数据变化并刷新现有字段。 */ void slotWellDataChanged(); private: /** @brief 清空当前井型生成的全部分组和字段映射。 */ void clearGroups(); /** @brief 根据目录描述创建一个参数分组。 */ bool buildGroup(const nmWellParameterGroupInfo& oGroupInfo, QString& sError); /** @brief 增量同步射孔选择器并保持当前射孔索引。 */ void reloadPerforationSelector(); /** @brief 返回指定射孔在选择器中的显示名称。 */ QString perforationDisplayName(int nPerforationIndex) const; /** @brief 仅同步当前射孔名称,不改变选择器结构和当前选中项。 */ void updateCurrentPerforationItem(); /** @brief 收集基准单位值并执行字段及关联规则校验。 */ bool collectValues(QMap& mapValues, QString& sError, QVector* pVecPerforations = nullptr); /** @brief 校验全部射孔并按需返回与校验完全一致的最终快照。 */ bool validatePerforationValues( const QMap& mapValues, QString& sError, QVector* pVecPerforations); /** @brief 按稳定参数ID查找当前井型字段。 */ nmParameterField* field(const QString& sParameterId) const; /** @brief 为跨射孔校验错误补充可定位的射孔序号。 */ QString perforationErrorText(int nPerforationIndex, const QString& sRuleError) const; /** @brief 标记指定射孔的起止字段或选择器错误。 */ void setPerforationError(int nPerforationIndex, const QString& sError); nmIParameterUnitService* m_pUnitService; ///< 单位服务,不拥有所有权。 nmDataWellBase* m_pWell; ///< 当前工作副本,不拥有所有权。 QVBoxLayout* m_pMainLayout; ///< 单列分组布局。 QComboBox* m_pPerforationComboBox; ///< 当前射孔选择器。 QList m_listFields; ///< 当前井型字段。 QMap m_mapFields; ///< 稳定ID字段映射。 int m_nCurrentPerforationIndex; ///< 当前射孔索引。 bool m_bReloading; ///< 程序刷新控件标记。 bool m_bUpdatingModel; ///< 批量写工作副本标记。 };