创建协议扩展类
若要创建自定义对象捕捉模式,必须创建协议扩展类来处理每个实体的输入点处理。该类定义每个自定义对象捕捉模式必须为相关实体实现的协议。此基类包含函数 ,该函数对实体执行输入点处理:AcDbCustomOsnapInfogetOsnapInfo() class AcDbCustomOsnapInfo : public AcRxObject { public: ACRX_DECLARE_MEMBERS(AcDbCustomOsnapInfo); virtual Acad::ErrorStatus getOsnapInfo( AcDbEntity* pickedObject, int gsSelectionMark, const AcGePoint3d& pickPoint, const AcGePoint3d& lastPoint, const AcGeMatrix3d& viewXform, AcArray<AcGePoint3d>& snapPoints, AcArray<int>& geomIdsForPts, AcArray<AcGeLine3d>& snapLines, AcArray<int>& geomIdsForLines); }; 为自定义对象捕捉模式创建协议扩展类
class AcmeSocketInfo : public AcDbCustomOsnapInfo{ public: ACRX_DECLARE_MEMBERS(AcDbSocketInfo); virtual Acad::ErrorStatus getOsnapInfo( AcDbEntity* pickedObject, int gsSelectionMark, const AcGePoint3d& pickPoint, const AcGePoint3d& lastPoint, const AcGeMatrix3d& viewXform, AcArray<AcGePoint3d>& snapPoints, AcArray<int>& geomIdsForPts, AcArray<AcGeLine3d>& snapLines, AcArray<int>& geomIdsForLines); }; ACRX_NO_CONS_DEFINE_MEMBERS(AcmeSocketInfo, AcDbCustomOsnapInfo); 初始化基本协议扩展类,并将其添加到运行时类层次结构中。 例如,将以下行添加到函数中:acrxEntryPoint() AcmeSocketInfo::rxInit(); acrxBuildClassHierarchy(); 对于每个相关的实体类,从基类派生一个协议扩展类。 例如,可以派生一个名为 implements 的类,用于处理行的输入点处理。AcmeSocketForLinesgetOsnapInfo() 注意:对于派生自 的每个注册类,应将默认实现与相关联。AcDbEntityAcDbCustomOsnapInfo
创建每个协议扩展对象的实例,并使用该函数将对象添加到相应的描述符对象。AcRxClassaddX() 例如: pSocketForLine = new AcmeSocketForLine; AcDbLine::desc()->addX(AcmeSocketInfo::desc(), pSocketForLine); 父主题: |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 11:56
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.