You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWTAI-Platform/Include/nmNum/nmSubWxs/nmWellPressureFlowPage.h

177 lines
7.1 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include "nmSubWxs_global.h"
#include "nmDefines.h"
#include "nmDataGaugeRecord.h"
#include <QPointF>
#include <QString>
#include <QVector>
#include <QWidget>
class iUnitGroup;
class iUnitItem;
class nmDataWellBase;
class nmWxPressFlowChartWidget;
class QComboBox;
class QSplitter;
class QStackedWidget;
class QTableWidget;
class ZxTableHeaderViewUnit;
/**
* @brief 显示当前井工作副本中的只读压力和流量数据。
* @note 页面不拥有井对象只保存以h、m³/d和MPa为基准的数据副本。
*/
class NM_SUB_WXS_EXPORT nmWellPressureFlowPage : public QWidget
{
Q_OBJECT
public:
/** @brief 创建只读压力流量页面。 */
explicit nmWellPressureFlowPage(QWidget* pParent = nullptr);
/**
* @brief 绑定当前井工作副本,不立即读取数据。
* @param pWell 井工作副本,不转移所有权。
*/
void setWell(nmDataWellBase* pWell);
/** @brief 从已绑定井重新读取原始数据并刷新全部视图。 */
void refreshData();
/** @brief 解除井绑定并清空全部显示数据。 */
void clearData();
private slots:
/** @brief 从原始副本重新生成指定单位的表格和曲线。 */
void slotUnitChanged(int nColumn,
const iUnitItem* pSourceUnit,
const iUnitItem* pDestinationUnit);
/** @brief 将表格当前行同步为两张曲线的高亮流量段。 */
void slotFlowRowChanged(int nCurrentRow,
int nCurrentColumn,
int nPreviousRow,
int nPreviousColumn);
/** @brief 将流量曲线点击时间映射为表格行选择。 */
void slotFlowChartPointClicked(double dTimePoint);
/** @brief 切换压力记录预览,仅刷新页面,不修改井的计算记录选择。 */
void slotPressureGaugePreviewChanged(int nIndex);
/** @brief 切换流量记录预览,仅刷新页面,不修改井的计算记录选择。 */
void slotFlowGaugePreviewChanged(int nIndex);
/** @brief 切换显示相下拉框,仅重新按新相取点刷新视图,不改变井数据。 */
void slotDisplayPhaseChanged(int nIndex);
private:
/** @brief 创建左右分栏、上下图表和只读流量表格。 */
void createUi();
/** @brief 创建顶部压力/流量记录与显示相三个下拉框所在行。 */
void createRecordSelectionBar();
/** @brief 填充压力记录预览下拉框,优先恢复页面预览项。 */
void populatePressureGaugeCombo();
/** @brief 填充流量记录预览下拉框,优先恢复页面预览项。 */
void populateFlowGaugeCombo();
/** @brief 按当前选中流量记录的真实相填充显示相下拉框;至多 1 项时隐藏整行。 */
void populateDisplayPhaseCombo(const nmFlowGaugeRecord* pRecord);
/** @brief 返回记录的默认显示相:优先井别参考相,否则记录中第一个有真实数据的相。 */
NM_PHASE_TYPE defaultDisplayPhase(const nmFlowGaugeRecord* pRecord) const;
/** @brief 在缓存中查找当前预览的压力记录。 */
const nmPressureGaugeRecord* currentPressureRecord() const;
/** @brief 在缓存中查找当前预览的流量记录。 */
const nmFlowGaugeRecord* currentFlowRecord() const;
/** @brief 重新获取框架单位组并同步双行表头。 */
void initializeUnitSupport();
/** @brief 将表头恢复为当前已成功应用的单位。 */
void updateUnitHeader();
/** @brief 由基准副本生成表格显示点和目标单位精度。 */
bool buildFlowTableData(
const QString& sTimeUnit,
const QString& sFlowUnit,
QVector<QPointF>& vecFlowPoints,
int& nTimeDigit,
int& nFlowDigit) const;
/** @brief 使用指定单位组转换一个值。 */
bool convertValue(iUnitGroup* pUnitGroup,
const QString& sBaseUnit,
const QString& sDestinationUnit,
double dSourceValue,
double& dDestinationValue,
int* pDestinationDigit = nullptr) const;
/** @brief 刷新表格、图表、空状态和选中段。 */
void updateViews();
/** @brief 从原始流量持续时间生成基准单位阶梯曲线点。 */
QVector<QPointF> createFlowChartPoints() const;
/** @brief 刷新流量时序表并恢复有效选中行。 */
void updateFlowTable();
/** @brief 按原始压力和流量数据的时间并集同步图表范围。 */
void updateXAxisRange(
const QVector<QPointF>& vecFlowChartPoints);
/** @brief 根据共享流量段索引刷新两张曲线高亮。 */
void updateSelectedFlowSegment();
/** @brief 统一应用表格与曲线共享的零基流量点索引。 */
void applyFlowSegmentSelection(int nSegmentIndex);
/** @brief 按表格当前时间单位查找点击时间所属的流量点。 */
int findFlowSegmentByTableTime(double dTimePoint) const;
/** @brief 清空数据副本和视图,但保留当前单位及井绑定。 */
void resetDataViews();
nmDataWellBase* m_pWell; ///< 当前工作副本,不拥有。
QStackedWidget* m_pContentStack;
QSplitter* m_pHorizontalSplitter;
QSplitter* m_pChartSplitter;
QStackedWidget* m_pPressureChartStack;
QStackedWidget* m_pFlowChartStack;
QStackedWidget* m_pFlowTableStack;
nmWxPressFlowChartWidget* m_pPressureChart;
nmWxPressFlowChartWidget* m_pFlowChart;
QTableWidget* m_pFlowTable;
ZxTableHeaderViewUnit* m_pFlowHeader;
iUnitGroup* m_pTimeUnitGroup; ///< 框架拥有。
iUnitGroup* m_pFlowUnitGroup; ///< 框架拥有。
QVector<QPointF> m_vecRawPressurePoints;
QVector<QPointF> m_vecRawFlowPoints;
QVector<QPointF> m_vecTableFlowPoints;
QString m_sTimeBaseUnit;
QString m_sFlowBaseUnit;
QString m_sTimeUnit;
QString m_sFlowUnit;
int m_nTimeDigit;
int m_nFlowDigit;
int m_nSelectedFlowSegment;
QWidget* m_pRecordSelectionBar; ///< 顶部压力/流量记录与显示相下拉框所在行容器。
QComboBox* m_pPressureGaugeCombo; ///< 压力记录预览选择itemData 存 Gauge Code。
QComboBox* m_pFlowGaugeCombo; ///< 流量记录预览选择itemData 存 Gauge Code。
QComboBox* m_pDisplayPhaseCombo; ///< 显示相下拉框itemData 存 NM_PHASE_TYPE。
QWidget* m_pDisplayPhaseContainer; ///< 承载显示相下拉框与标签,整体隐藏用。
NM_PHASE_TYPE m_eDisplayPhase; ///< 当前预览的流量相,纯展示状态,不写回井对象。
QString m_sPreviewPressureGaugeCode; ///< 当前页面预览的压力记录,不持久化。
QString m_sPreviewFlowGaugeCode; ///< 当前页面预览的流量记录,不持久化。
QVector<nmPressureGaugeRecord> m_vecPressureGaugeRecords; ///< 压力记录页面缓存。
QVector<nmFlowGaugeRecord> m_vecFlowGaugeRecords; ///< 每次填充流量下拉框时缓存的记录列表,供 currentFlowRecord() 安全返回内部指针。
};