明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1789|回复: 0

紧急求助,有关AcEdJig 非常奇怪的问题

[复制链接]
发表于 2007-4-26 01:48:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2007-4-27 0:31:35 编辑

我用AcEdJig产生几个命令Move/Copy/Mirror/Rotate 来操作我自己定义的 entity. 这些命令在AutoCAD2002/2004运行地很好,但当我升级到AutoCAD2007后,这些命令总是在拖动鼠标时死掉,  那位知道AcEdJig用在AutoCAD2007时与AutoCAD2002/2004版本有何不同. 需要注意些什么.是否有其他途径来实现Move/Copy/Mirror/Rotate命令.

我定义了以下entity 实现选择物体的Matrix转换和worldDraw.  

class TransformedObjects : public AcDbEntity

{ .............

   public:

            virtual void viewportDraw(AcGiViewportDraw* pVpDraw);

            virtual Adesk::Boolean worldDraw(AcGiWorldDraw* mode);

   ........ 

  private:

            AcDbObjectIdArray mObjectIds; //objects to be drawn

            AcGeMatrix3d mTransform; //Matrix定义

};

我定义Move如下:

class ObjectJig : public AcEdJig

{

public:

            ObjectJig();

            ~ObjectJig();

            virtual AcDbEntity *entity() const;

            virtual DragStatus sampler();

            virtual Adesk::Boolean update();

            virtual DragStatus Run(CString Prompt);

            void setTransform(AcGeMatrix3d trans);

            void addObject(AcDbObjectId id);

            void addObjects(AcDbObjectIdArray &ids);

            void applyTransform(); //Matrix操作

private:

            TransformedObjects     mTransObject;

            AcGeMatrix3d             mTransform;

}

class MoveJig : public ObjectJig

{

public:

            virtual DragStatus sampler();

            virtual DragStatus Run(CString Prompt);

            void setRefPoint(AcGePoint3d pt) {mRefPoint = pt;}

private:

            AcGePoint3d mRefPoint;

            AcGePoint3d mPoint;

};

程序在运行Move时在virtual DragStatus sampler();内部死掉,virtual DragStatus sampler()定义如下

AcEdJig::DragStatus MoveJig::sampler()

{

           AcEdJig::DragStatus ds;

            AcGePoint3d Pt;

            setUserInputControls(AcEdJig::kAccept3dCoordinates);

            ds = acquirePoint(Pt, mRefPoint);

            if(ds == AcEdJig::kCancel)

                        return ds;

            if(mPoint.isEqualTo(Pt))

                        return AcEdJig::kNoChange;

            mPoint = Pt;

            setTransform(AcGeMatrix3d::translation(mPoint - mRefPoint));

            return ds;

}

  private:

            AcDbObjectIdArray mObjectIds; //objects to be drawn

            AcGeMatrix3d mTransform; //Matrix定义

};

我定义Move如下:

class ObjectJig : public AcEdJig

{

public:

            ObjectJig();

            ~ObjectJig();

            virtual AcDbEntity *entity() const;

            virtual DragStatus sampler();

            virtual Adesk::Boolean update();

            virtual DragStatus Run(CString Prompt);

            void setTransform(AcGeMatrix3d trans);

            void addObject(AcDbObjectId id);

            void addObjects(AcDbObjectIdArray &ids);

            void applyTransform(); //Matrix操作

private:

            TransformedObjects     mTransObject;

            AcGeMatrix3d             mTransform;

}

class MoveJig : public ObjectJig

{

public:

            virtual DragStatus sampler();

            virtual DragStatus Run(CString Prompt);

            void setRefPoint(AcGePoint3d pt) {mRefPoint = pt;}

private:

            AcGePoint3d mRefPoint;

            AcGePoint3d mPoint;

};

程序在运行Move时在virtual DragStatus sampler();内部死掉,virtual DragStatus sampler()定义如下

AcEdJig::DragStatus MoveJig::sampler()

{

           AcEdJig::DragStatus ds;

            AcGePoint3d Pt;

            setUserInputControls(AcEdJig::kAccept3dCoordinates);

            ds = acquirePoint(Pt, mRefPoint);

            if(ds == AcEdJig::kCancel)

                        return ds;

            if(mPoint.isEqualTo(Pt))

                        return AcEdJig::kNoChange;

            mPoint = Pt;

            setTransform(AcGeMatrix3d::translation(mPoint - mRefPoint));

            return ds;

}

 具体实施Move的函数如下

AcEdJig::DragStatus MoveJig::Run(CString Prompt)

{

          AcEdJig::DragStatus status;

            mPoint = mRefPoint;

            setDispPrompt(Prompt);

            status = drag();

            if(status == AcEdJig::kNormal)

                        applyTransform();

            return status;

}

望那位高手指点迷津,多谢了

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 20:53 , Processed in 0.177559 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表