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/nmWxGridDlg.h

56 lines
2.6 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.

#ifndef NMWXGRIDDLG_H
#define NMWXGRIDDLG_H
#include "iDlgBase.h"
#include "nmSubWxs_global.h"
#include <QString>
class QLineEdit;
class QComboBox;
class QPushButton;
class iUnitGroup;
// PEBI 网格尺度编辑器:只持有米制数值副本,所属分析及建网流程由调用方管理。
// 单位列表、换算和显示精度来自框架;取消或关闭窗口不会修改分析参数。
class NM_SUB_WXS_EXPORT nmWxGridDlg : public iDlgBase
{
Q_OBJECT
public:
// 使用所属分析的已保存尺度初始化窗口;dGridControl 的单位为米。
explicit nmWxGridDlg(double dGridControl, QWidget* pParent = 0);
// 返回米制尺度副本,仅在窗口返回 Accepted 后用于提交或建网。
double gridControl() const;
public slots:
// 确定与回车共用入口,只接受有限正数;无效输入保留编辑状态,不弹出校验提示。
virtual void accept();
private slots:
// 记录真实文本编辑;仅切换显示单位时不重新解析舍入后的显示值。
void onGridControlEdited();
// 按旧单位读取待编辑文本,再由框架换算到新单位;失败时恢复旧单位和原文。
void onLengthUnitChanged();
// 根据当前输入控制确定按钮,禁止空值、零、负数或非有限值进入建网流程。
void updateActions();
private:
// 创建只读网格类型、尺度及单位字段,沿用统一边距和数值/单位 8:5 布局。
void initUI();
// 判断长度单位服务及米制基准是否可用,不自行补写单位系数。
bool unitsAvailable() const;
// 读取米制尺度;文本未变化时保留缓存精度,避免仅切换单位造成参数漂移。
bool readGridControl(double& dGridControl) const;
// 按目标单位配置的小数位格式化显示,不对内部米制值作舍入。
QString displayValue(double dGridControl, const QString& sUnit) const;
iUnitGroup* m_pLengthUnitGroup; // 框架共享的长度单位组,不负责销毁
QLineEdit* m_pGridControlEdit; // 网格尺度编辑器,宽度随窗口伸缩
QComboBox* m_pLengthUnitCombo; // 框架长度单位列表,保持主题推荐高度
QPushButton* m_pOkButton; // 仅输入有效时启用的确定按钮
double m_dGridControl; // 完整精度米制副本,确认前不写入所属分析
QString m_sDisplayUnit; // 当前文本所用的单位,切换失败时用于回退
bool m_bGridControlEdited; // 当前文本是否经过编辑,区分用户输入与程序换算回显
};
#endif // NMWXGRIDDLG_H