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/nmPlot/nmObjRound.h

95 lines
2.9 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 "nmObjBase.h"
#include "nmDefines.h"
#include "nmPlot_global.h"
// 数值试井绘图对象(圆形)
class NM_PLOT_EXPORT nmObjRound : public nmObjBase
{
Q_OBJECT
ZX_DECLARE_DYNAMIC
public:
nmObjRound();
nmObjRound(const QString& sName, \
ZxSubAxisX* pAxisX, \
ZxSubAxisY* pAxisY);
~nmObjRound();
// 设置初始参数
virtual void init(const QString& sName, \
ZxSubAxisX* pAxisX, \
ZxSubAxisY* pAxisY) override;
// 设置Tools
virtual void initTools() override;
protected:
// 设置图元对象的属性标志
virtual void initFlags() override;
// 共用圆形绘制,派生类可在控制点下方绘制自己的选中轮廓。
void paintCircle(QPainter* painter, const QPen& selectionPen) const;
public:
// 场景点集的固定布局,供拖动和方向光标共用。
enum ControlPointIndex {
TopControlPoint = 2,
RightControlPoint,
BottomControlPoint,
LeftControlPoint
};
// 击中
virtual bool hitTest(const QPointF& pt) override;
// 控制点和圆周使用固定像素命中范围;圆周用于选中,选中后可拖动内部。
// 只返回本次命中结果,不修改图元命中状态。
virtual bool _runHitTest(const QPointF& pt, \
int& nOption, int& nSubIndex) override;
// 击中后,ButtonUp后的处理
// pt1:鼠标Down点,pt2:鼠标Up点
virtual bool runMove(const QPointF& pt1, const QPointF& pt2) override;
// 将拖动起止点作为直径两端,生成创建预览和提交共用的场景点集。
static bool calculateCreationPoints(const QPointF& start, const QPointF& end,
QVector<QPointF>& points);
// 计算拖动后的绘图坐标,供工具预览和 runMove 提交共用;不修改图元或业务数据。
// ptStart、ptEnd 为鼠标按下和当前位置;oHitOption、nHitIndex 指定本次拖动的部位。
// 上下控制点只取纵向位移,左右控制点只取横向位移,内部拖动保持半径不变。
// vecPos 按圆心、半径占位、上/右/下/左控制点排列;操作无效时返回 false,不写入结果。
bool calculateMovePoints(const QPointF& ptStart, const QPointF& ptEnd,
ObjHitOption oHitOption, int nHitIndex,
QVector<QPointF>& vecPos) const;
public:
// 属性填充内容
virtual void fillPtyPano(IxPtyPano* sheet) override;
// 选中
virtual void paintBack(QPainter* painter, \
const ZxPaintParam& param) override;
public:
// 填充背景颜色
QColor getBackgrdColor() const;
void setBackgrdColor(QColor color);
public:
QColor m_clrBackgrd;//填充颜色
private:
// 按圆心到纵向控制点的距离恢复场景半径,避免把半径占位当成绝对坐标。
bool getSceneCircle(QPointF& center, qreal& radius) const;
};