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

38 lines
1.8 KiB
C

#ifndef NMWXLAYERGEOMETRYPREVIEW_H
#define NMWXLAYERGEOMETRYPREVIEW_H
#include "nmLayerGeometry.h"
#include <QPoint>
#include <QRectF>
#include <QWidget>
// 只消费几何快照的剖面预览,提供层命中查询,不负责弹出编辑器、单位转换或持久化。
// 深度方向按真实顶底深度缩放,旧工程的间隙显示为留白。
class nmWxLayerGeometryPreview : public QWidget
{
public:
// 控件由 Qt 父子关系管理;不持有外部层对象或数据源。
explicit nmWxLayerGeometryPreview(QWidget* parent = 0);
// 复制显示快照并请求重绘;selectedRow 为零起始行号,-1 表示不高亮任何层。
void setGeometryData(const nmLayerGeometry& geometry, int selectedRow);
// 查询控件局部坐标对应的零起始层索引;无效几何、边距和历史间隙均返回 -1。
// 供外层窗口处理色带交互,控件本身不直接改动层颜色。
int layerAtPoint(const QPoint& pos) const;
// 以字体尺寸给出初始推荐大小,不限制布局后续拉伸。
virtual QSize sizeHint() const;
protected:
// 以整个顶底深度跨度计算比例,无效/空快照只绘制背景和边框。
virtual void paintEvent(QPaintEvent* event);
private:
// 绘制与命中检测共用同一色带矩形,避免窗口缩放后点击位置与实际图形不一致。
// 调用前须确认快照有效且 nRow 在范围内;返回值采用控件局部逻辑像素坐标。
QRectF layerRect(int nRow) const;
nmLayerGeometry m_oGeometry; // 独立的米制显示快照,不反向修改表格数据。
int m_nSelectedRow; // 与表格当前行同步的零起始索引;-1 表示无选中层,仅影响边框高亮。
};
#endif // NMWXLAYERGEOMETRYPREVIEW_H