Files
envi-code/SourceCode/Code2026/Dimension/HDbEquipment.h
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

239 lines
6.7 KiB
C++

#pragma once
#include "PipePrototype.h"
#include "DbPipeLabel.h"
class CHDbEquipment : public CDbPipeNode, public CLabelStyle
{
public:
ACRX_DECLARE_MEMBERS(CHDbEquipment);
private:
static const Adesk::UInt8 g_nVersion;
public:
CHDbEquipment();
protected:
AcDbHardPointerId m_idBlock2d; // 二维图块
AcDbHardPointerId m_idBlock3d; // 三维图块
XPoint m_ptLocation; // 设备基点
XVector3D m_vtDirection; // 设备方向
TPipeSys::ModelType m_modelType; // 模型类型
double m_dSysAngle; // 系统图的角度
Adesk::UInt8 m_nMirror; // 图块镜像
double m_dSizeX, m_dSizeY, m_dSizeZ; // 设备的长宽高
XString m_sLabel; // 标注内容
BOOL m_bDrawLabel; // 是否显示标注
XPoint m_ptLabel, m_ptLabelOut; // 标注点,引注点
AcDbHardPointerId m_idLabelLayer;// 标注文字图层
public: // Set、Get函数
void SetBlock2d(const AcDbObjectId &id) { // 二维图块
assertWriteEnabled();
m_idBlock2d = id;
}
AcDbObjectId GetBlock2d() const {
return m_idBlock2d;
}
void SetBlock3d(const AcDbObjectId &id) { // 三维图块
assertWriteEnabled();
m_idBlock3d = id;
}
AcDbObjectId GetBlock3d() const {
return m_idBlock3d;
}
void SetLocation(const XPoint &pt); // 设备基点
virtual XPoint GetLocation() const { return m_ptLocation; }
void SetDirection(const XVector3D &vt, BOOL bApply = TRUE); // 设备方向
XVector3D GetDirection() const {
return m_vtDirection;
}
void SetAngle(double dAngle, BOOL bApply = TRUE) { // bApply:应用到接口、标注
SetDirection(XVector3D(cos(dAngle), sin(dAngle), 0), bApply);
}
double GetAngle() const {
return ads_angle(XPoint(), m_vtDirection);
}
void SetLabelLocation(const XPoint &pt) { // 标注位置
assertWriteEnabled();
if (m_ptLabelOut == m_ptLabel)
m_ptLabelOut = pt;
m_ptLabel = pt;
}
XPoint GetLabelLocation() const {
return m_ptLabel;
}
void SetLabelOut(const XPoint &pt) { // 引出位置
assertWriteEnabled();
m_ptLabelOut = pt;
}
XPoint GetLabelOut() const {
return m_ptLabelOut;
}
void EnableDrawLabel(BOOL bFlag) {
assertWriteEnabled();
m_bDrawLabel = bFlag;
}
BOOL IsDrawLabel() const {
return m_bDrawLabel;
}
void SetLabelLayer(const AcDbObjectId& id) {
assertWriteEnabled();
m_idLabelLayer = id;
}
AcDbObjectId GetLabelLayer() const {
return m_idLabelLayer;
}
void SetLabel(const TCHAR* sLabel) {
assertWriteEnabled();
m_sLabel = sLabel;
}
const TCHAR* GetLabel() const {
return (const TCHAR*)m_sLabel;
}
// 显示比例(bApply:应用到接口、标注)
void SetSize(double x, double y, double z, BOOL bApply = TRUE);
void GetSize(double &x, double &y, double &z) const {
x = m_dSizeX;
y = m_dSizeY;
z = m_dSizeZ;
}
void SetSizeX(double x,BOOL bApply = TRUE) {
SetSize(x, GetSizeY(), GetSizeZ(), bApply);
}
double GetSizeX() const {
return m_dSizeX; }
void SetSizeY(double y,BOOL bApply = TRUE) {
SetSize(GetSizeX(), y, GetSizeZ(), bApply);
}
double GetSizeY() const {
return m_dSizeY; }
void SetSizeZ(double z, BOOL bApply = TRUE) {
SetSize(GetSizeX(), GetSizeY(), z, bApply);
}
double GetSizeZ() const {
return m_dSizeZ; }
// 设备(图块)X、Y轴的镜像,X轴方向为m_vtDirection方向
void MirrorByX(BOOL bFlag = TRUE);
BOOL IsMirrorByX() const {
return (m_nMirror&MIRROR_XAXIS)!=0;
}
void MirrorByY(BOOL bFlag = TRUE);
BOOL IsMirrorByY() const {
return (m_nMirror&MIRROR_YAXIS)!=0;
}
BOOL IsSysType() const { // 是否系统图
return m_modelType==TPipeSys::kSystem;
}
void SetModelType(TPipeSys::ModelType modelType) { // 模型图或原理图或系统图
assertWriteEnabled();
m_modelType = modelType;
}
TPipeSys::ModelType GetModelType() const { // 模型图或原理图或系统图
return m_modelType;
}
void SetSysAngle(double dAngle) { // 系统图角度
assertWriteEnabled();
m_dSysAngle = dAngle;
}
double GetSysAngle() const {
return m_dSysAngle;
}
public: // 有关Interface的函数
// 新建接口(sName:接口名称,存储于m_sSysLabel)
void AddInterface(XString sName, const XPoint& ptLoc, const XVector3D& vt);
CPipeInterface* FindInterface(XString sName); // 查找
BOOL RemoveInterface(XString sName); // 删除指定名称的接口
public:
AcGeScale3d GetInsert2dScale() const; // 图块插入比例
AcGeScale3d GetInsert3dScale() const;
BOOL IsLabelValid() const { return CLabelStyle::IsValid(); }
BOOL IsOutLabel() const { // 是否是引出标注
return m_ptLabel!=m_ptLabelOut;
}
public: // Override TDbPipeNode
// 对st类型的接口进行重新连接
virtual void UpdateLinkage(const XPoint &ptAt, TPipeSys::SysType st,
const DList<AcDbObjectId> &idPipes);
// 判断节点是否可以连接管段. nPos: 0--start; 1--end
virtual BOOL CanLinkSide(const AcDbObjectId &idPipe, int nPos) const;
virtual BOOL IsDrawBlock() const { return TRUE; }
public: // Override TDbEntity
virtual Acad::ErrorStatus Draw2d(AcGiDraw &dc) const;
virtual Acad::ErrorStatus Draw3d(AcGiDraw &dc) const;
virtual void CopyPropertiesFrom(AcDbEntity *pSrc, unsigned gMatchFlag);
virtual Acad::ErrorStatus GetGripText(int idx, CString &cs) const;
virtual Acad::ErrorStatus GetExtents(XPoint &ptLow, XPoint &ptUp) const;
virtual void GetTips(DList<ObjInfoUnit> &) const; // 取动态属性显示数据
//virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const;
virtual int GetGripNumber() const;
virtual int GetStretchNumber() const;
public: // Override AcDbEntity
virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler*);
virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler*) const;
virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler*);
virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler*) const;
Acad::ErrorStatus subGetOsnapPoints(AcDb::OsnapMode osnapMode,
INT_PTR gsSelectionMark,
const AcGePoint3d& ptPick,
const AcGePoint3d& lastPoint,
const AcGeMatrix3d& viewXform,
AcGePoint3dArray& snapPoints,
AcDbIntArray& geomIds) const;
virtual Acad::ErrorStatus subGetGripPoints(AcGePoint3dArray& gripPoints,
AcDbIntArray& osnapModes,
AcDbIntArray& geomIds) const;
virtual Acad::ErrorStatus subGetStretchPoints(AcGePoint3dArray & stretchPoints) const;
virtual Acad::ErrorStatus subMoveGripPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset);
virtual Acad::ErrorStatus subMoveStretchPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset);
virtual Acad::ErrorStatus subTransformBy(const AcGeMatrix3d& xform);
private:
Acad::ErrorStatus _ExplodeOrDraw2d(AcGiDraw &dc, BOOL bZEqual0 = TRUE) const;
Acad::ErrorStatus DrawSystem(AcGiDraw &dc, BOOL bZEqual0 = TRUE) const;
Acad::ErrorStatus DrawLabelText(AcGiDraw &dc) const;
Acad::ErrorStatus MoveGSPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset);
};