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/nmData/nmDataOutline.h

126 lines
4.0 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 NMDATARECTOUTLINE_H
#define NMDATARECTOUTLINE_H
#include "nmData_global.h"
#include <QColor>
#include <QPen>
#include "nmDefines.h"
#include "nmDataAttribute.h"
#include "nmDataBase.h"
class NM_DATA_EXPORT nmDataOutline : public nmDataBase {
Q_OBJECT
public:
nmDataOutline();
nmDataOutline(const nmDataOutline& other); // 拷贝构造函数
nmDataOutline& operator=(const nmDataOutline& other); // 赋值运算符
~nmDataOutline();
// 实现 nmDataBase 的抽象方法:将当前 C++ 对象序列化为 RapidJSON Value
virtual rapidjson::Value ToJsonValue(rapidjson::Document::AllocatorType& allocator) const override;
// 实现 nmDataBase 的抽象方法:从 RapidJSON Value 反序列化数据到当前 C++ 对象
virtual void FromJsonValue(const rapidjson::Value& jsonValue) override;
QString getName();
void setName(const QString& sName);
QVector<QPointF> getOutlinePoints();
void setOutlinePoints(const QVector<QPointF>& vecPts);
int getOutlinePointCount() const;
nmDataAttribute* getPointXAttribute(int nIndex) const;
nmDataAttribute* getPointYAttribute(int nIndex) const;
nmDataAttribute& getLeftAttribute();
nmDataAttribute& getRightAttribute();
nmDataAttribute& getTopAttribute();
nmDataAttribute& getBottomAttribute();
nmDataAttribute& getCenterXAttribute();
nmDataAttribute& getCenterYAttribute();
nmDataAttribute& getRadiusAttribute();
QVector<int> getFlowTypeList() const;
void setFlowTypeList(const QVector<int>& vecFlowTypeList);
NM_Data_Outline_Type getOutlineType() const;
void setOutlineType(NM_Data_Outline_Type eOutlineType);
QPointF getCenter() const;
void setCenter(const QPointF& ptCenter);
double getRadius() const;
void setRadius(double dRadius);
bool getPlotVisible() const;
void setPlotVisible(const bool newState);
// 读取边界画笔。旧成果只保存线宽,线色和线型沿用图元默认值。
QPen getPen(const QPen& defaultPen) const;
// 保存当前图元画笔,供成果打开及撤销恢复使用。
void setPen(const QPen& pen);
QColor getBackgrdColor() const;
void setBackgrdColor(const QColor& clr);
int getBackgrdAlpha() const;
void setBackgrdAlpha(int nAlpha);
// 视觉属性是否有效;未创建过Map图元的边界保持false。
bool hasVisualProps() const;
// 设置视觉属性有效状态,图元完成样式同步后置为true。
void setVisualPropsValid(bool bValid);
signals:
// 参数面板修改数据后,通知 Binder 刷新图元。
void sigOutlineDataChanged();
private slots:
void onGeometryAttributeChanged();
private:
void initGeometryAttributes();
void clearPointAttributes();
void syncGeometryAttributes();
void syncPointAttributes();
void syncRectAttributes();
void syncRoundAttributes();
void updateRectPointsFromAttributes();
void updateRoundPointsFromAttributes();
// m_vecPts 及固定几何量的面板绑定属性,不单独参与序列化。
QVector<nmDataAttribute*> m_vPointXAttributes;
QVector<nmDataAttribute*> m_vPointYAttributes;
nmDataAttribute m_left;
nmDataAttribute m_right;
nmDataAttribute m_top;
nmDataAttribute m_bottom;
nmDataAttribute m_centerX;
nmDataAttribute m_centerY;
nmDataAttribute m_radius;
// 防止“点集 -> 属性 -> 点集”递归同步。
bool m_bSyncingGeometryAttributes;
QString m_sName;// 边界名称
QVector<QPointF> m_vecPts; // 边界点的数据;
QVector<int> m_vFlowTypeList; //边界压力类型
NM_Data_Outline_Type m_eOutlineType; // 边界类型
// 对于圆形边界,特殊处理
QPointF m_ptCenter; // 圆心
double m_dRadius; // 半径
bool m_bPlotVisible; // 图元是否可见
// 视觉属性
QPen m_pen; // 画笔样式。读取旧成果时仅包含有效线宽。
bool m_bHasPenStyle; // 成果包含线色和线型,或已由图元同步完整画笔。
QColor m_clrBackgrd; // 填充背景色
int m_nBackgrdAlpha; // 填充透明度 (0-255)
bool m_bHasVisualProps; // 视觉属性是否已由Map图元初始化
};
#endif // NMDATARECTOUTLINE_H