自定义实体
AcDbEntity 是所有具有图形表现的数据库对象的基类。它由AcDbObject派生。创建自定义实体包括以下步骤:
1.从AcDbEntity派生一个自定义类;
2.重载所有必要的AcDbObject函数;
3.重载要求的AcDbEntity函数;
4.重载支持自定义功能的其它函数;
5.如果要支持MATCHPROP命令,执行AcDbMatchProperties作为扩展协议;
6.如果要为自定义实体创建拖曳序列,执行自定义的AcEdJig。
(1)必须重载的AcDbEntity函数
当从AcDbEntity派生自定义类时,下述函数必须重载:
virtual Adesk::Boolean worldDraw(AcGiWorldDraw* mode);
virtual Acad::ErrorStatus getGeomExtents(AcDbExtents& extents)const;
virtual Acad::ErrorStatus transformBy(const AcGeMatrix3d& xform);
virtual Acad::ErrorStatus getTransformedCopy(const AcGeMatrix3d& xform,AcDbEntity*& ent)const;
virtual Acad::ErrorStatus getGripPoint,AcDbIntArray& osnapModes,AcDbIntArray& getomIds)const;
virtual Acad::ErrorStatus moveGripPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset);
(2)通常需要重载的AcDbEntity函数
当从AcDbEntity派生自定义类时,下述函数通常需要重载,是否重载它们取决于自定义类的功能。
virtual void viewportDraw(AcGiViewportDraw* mode);
virtual void list() const;
vitual Acad::ErrorStatus intersectWith(const AcDbEntity* ent,AcDb::Intersect intType,AcGePoint3dArray& points,int thisGsMarker=0,int otherGsMarker=0)const;
virtual Acad::ErrorStatus intersectWith(const AcDbEntity* ent,AcDb::Intersect intType,const AcGePlane& projPlane,AcGePoint3dArray& points,int thisGsMarker=0,int otherGsMarker=0)const;
vitual Acad::ErrorStatus getOsnapPoints(AcDb::OsnapMode osnapMode,int gsSelectionMark,const AcGePoint3d& pickPoint,const AcGePoint3d& lastPoint,const AcGeMatrixed& viewXform,AcGePoint3dArray& snapPoints,AcDbIntArray& geomIds)const;
virtual Acad::ErrorStatus getStretchPoints(AcGePoint3dArray&)const;
virtual Acad::ErrorStatus moveStretchPointsAt(const AcDbIntArray& indeces,const AcGeVector3d& offset);
virtual Acad::ErrorStatus explode(AcDbVoidPtrArray& entitySet)const;
virtual Acad::ErrorStatus getSubentPathsAtGsMarker(AcDb::SubentType type,int gsMark,const AcGePoint3d& pickPoint,const AcGeMatrix3d& viewXform,int& numPaths,AcDbFullSubentPaths*& subentPaths,int numInserts=0,AcDbObjectId* entAndInsertStack=NULL)const;
virtual Acad::ErrorStatus applyPartialUndo(AcDbDwgFiler* undoFiler,AcRxClass* classObj);
virtual void subSetDatabaseDefaults(AcDbDatabase* pDb);
virtual void saveAs(AcGiWorldDraw *mode,AcDb::SaveType st);
(3)很少重载的AcDbEntity函数
virtual Acad::ErrorStatus setColor(const AcCmColor &color);
virtual Acad::ErrorStatus setColorIndex(Adesk::UInt16 color);
virtual Acad::ErrorStatus setLinetype(const char* newVal);
virtual Acad::ErrorStatus setLinetype(AcDbObjectId newVal);
virtual void getEcs(AcGeMatrix3d& retVal)const;
virtual Acad::ErrorStatus gerGsMarkersAtSubentPath(const AcDbFullSubentPath& subPath,AcDbIntArray& gsMarkers)const;
virtual Acad::ErrorStatus highlight(const AcDbFullSubentPath& subId=kNullSubent)const;
virtual Acad::ErrorStatus unhighlight(const AcDbFullSubentPath& subId=kNullSubent)const;
virtual AcDbEntity* subentPtr(const AcDbFullSubentPath& id)const;
virtual Adesk::Boolean saveImagesByDefault() const;
virtual void setAttributes(AcGiSubEntityTraits* pTraits);