【原创】研究AcDbGripData类

目的:
实现夹点操作过程中,一系列要控制的功能(比如:各个夹点的提示语、夹点样子、对应的动态标注等)。
我们都知道,CAD的自定义实体中支撑用户自定义夹点的接口(getGripPoints和moveGripPointsAt)。而CAD支持的夹点对象就是AcDbGripData类。所以,如果需要依靠夹点操作这一套机制来实现我们要的一些功能,就需要研究研究这个类,否则就要自己写了(这样,复杂,并且有些效果并不一定能实现)。庆幸的是,ARX为AcDbGripData内置了一系列的回调函数(其实就是钩子函数来获取二次开发者对其的一些行为的定义),下面,我们就来慢慢的剖析这个类。
在这其中,我们只需要知道以下私有成员变量的用途即可:
private:
AcGePoint3d         m_gripPt;  
//用来保存夹点位置   

AcGePoint3d*        m_pAltBasePt;
//用来设置夹点编辑操作时,拖动的基点

void*               m_pAppData;    
//非常有用,用来保存用户自定义数据的地址

GripOperationPtr    m_pHotGripFunc;
//夹点被拉伸时的回调函数,在这里,返回不同的值,将导致夹点进行不同的操作,比如返回eGetNewGripPoints将导致重新调用实体的getGripPoints
typedef AcDbGripOperations::ReturnValue (*GripOperationPtr)(AcDbGripData* pThis,
    const AcDbObjectId& entId, int contextFlags);

GripOperationPtr    m_pHoverFunc;
//鼠标放在夹点上时的回调函数,这里,返回不同的值,将导致夹点进行不同的操作,比如返回eRedrawGrip将导致重新调用夹点的WORLDDRAW和VIEWPORTDRAW回调函数
typedef AcDbGripOperations::ReturnValue (*GripOperationPtr)(AcDbGripData* pThis,
    const AcDbObjectId& entId, int contextFlags);

GripRtClkHandler    m_pRtClk;
//当选中一个夹点,点击右键时,触发,在这里,你可以给定一个MENU的句柄,使其在不同的夹点上右击,弹出不同的菜单
typedef AcDbGripOperations::ReturnValue (*GripRtClkHandler)(AcDbGripDataArray& hotGrips,
    const AcDbObjectIdArray& ents, ACHAR *& menuName, HMENU& menu,
    ContextMenuItemIndexPtr& cb);

GripWorldDrawPtr    m_pWorldDraw;
//夹点WorldDraw回调函数,像十字型、三角型等不同类型的夹点形状,可以在这里定义(默认的为方型)
typedef bool (*GripWorldDrawPtr)(AcDbGripData* pThis, AcGiWorldDraw* pWd,
    const AcDbObjectId& entId, AcDbGripOperations::DrawType type,
    AcGePoint3d* imageGripPoint, double dGripSize);

GripViewportDrawPtr m_pViewportDraw;
//夹点ViewportDraw回调函数
typedef void (*GripViewportDrawPtr)(AcDbGripData* pThis, AcGiViewportDraw* pWd,
    const AcDbObjectId& entId, AcDbGripOperations::DrawType type,
    AcGePoint3d* imageGripPoint, int gripSize);

GripOpStatusPtr     m_pGripOpStatFunc;
//夹点操作时的回调函数,判断当前是对夹点进行什么操作,返回操作状态
typedef void (*GripOpStatusPtr)(AcDbGripData* pThis, const AcDbObjectId& entId,
    AcDbGripOperations::GripStatus stat);

GripToolTipPtr      m_pToolTipFunc;
//夹点提示回调函数,像那什么按CTRL切换的,就是在这里设置的提示语
typedef const ACHAR * (*GripToolTipPtr)(AcDbGripData* pThis);

GripDimensionPtr    m_pHoverDimensionFunc;
//鼠标放在夹点的标注回调函数,在这里也可以定义标注,但一般与被拉伸时定义成一样的
typedef void (*GripDimensionPtr)(AcDbGripData* pThis, const AcDbObjectId& entId,
    double dimScale, AcDbDimDataPtrArray& dimData);

GripDimensionPtr    m_pHotGripDimensionFunc;
//夹点被拉伸的标注回调函数,一般的动态标注在这里定义。
typedef void (*GripDimensionPtr)(AcDbGripData* pThis, const AcDbObjectId& entId,
    double dimScale, AcDbDimDataPtrArray& dimData);

unsigned int        m_bitFlags;
//用来设置夹点的一些动作特征标志
//像,可以设置夹点被拉伸时,是否出现橡皮条、是否有关键字提示等

GripInputPointPtr   m_pInputPointFunc;
//在夹点编辑状态输入一个三维点时触发,从而可以做到控件用户的操作,其中的这些参数有点类似于CAD的用户输入点过滤或监视类的参数
typedef AcDbGripOperations::ReturnValue (*GripInputPointPtr)(
    AcDbGripData* pThis, const AcDbObjectId& entId, bool& changedPoint,
    AcGePoint3d& newPoint, const AcGiViewport& viewContext,
    const AcDbObjectId& viewportId, bool pointComputed, int history,
    const AcGePoint3d& lastPoint, const AcGePoint3d& rawPoint,
    const AcGePoint3d& grippedPoint, const AcGePoint3d& cartesianSnappedPoint,
    const AcGePoint3d& osnappedPoint, AcDb::OsnapMask osnapMask,
    const AcArray<AcDbCustomOsnapMode*>& customOsnapModes,
    AcDb::OsnapMask osnapOverrides,
    const AcArray<AcDbCustomOsnapMode*>& customOsnapOverrides,
    const AcArray<AcDbObjectId>& pickedEntities,
    const AcArray< AcDbObjectIdArray,
        AcArrayObjectCopyReallocator< AcDbObjectIdArray > >& nestedPickedEntities,
    const AcArray<Adesk::GsMarker>& gsSelectionMark,
    const AcArray<AcDbObjectId>& keyPointEntities,
    const AcArray< AcDbObjectIdArray,
        AcArrayObjectCopyReallocator< AcDbObjectIdArray > >& nestedKeyPointEntities,
    const AcArray<Adesk::GsMarker>& keyPointGsSelectionMark,
    const AcArray<AcGeCurve3d*>& alignmentPaths, const AcGePoint3d& computedPoint);

AcRxClass*          m_pAppDataClass;
//这个就不用讲了,每个ACDB对象都会有,用来识别对象等操作的。

posted @ 2013-04-14 13:04  编号一百零二  阅读(1137)  评论(0编辑  收藏  举报