- UID
- 482730
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2006-8-26
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
我自定义了一个矩形类,就是可以拖放的那种.但是不知道为什么当我拖放完成时候会出现致命错误.无法完成矩形的最终绘制.
哪位大哥可以帮小弟看看是什么原因.
拖放结束后出现: Unhandled Expception C0000005(Access Violation Reading Ox0054)at address 65462AC9h
关掉AUTCAD后 出现 :INTERNAL ERROR!XCOMMAND.cpp@3337:Was Open For Write
代码如下:
class CMARectWindow : public AcDbEntity
{
public:
ACRX_DECLARE_MEMBERS(CMARectWindow);
CMARectWindow();
virtual ~CMARectWindow();
virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;
virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* pFiler);
virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* pFiler);
virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* pFiler)const;
virtual Acad::ErrorStatus getGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapMasks, AcDbIntArray& geomIds) const;
virtual Acad::ErrorStatus moveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset);
virtual Adesk::Boolean worldDraw(AcGiWorldDraw* mode);
AcGePoint3d m_UpLeftPt;
AcGePoint3d m_DownRightPt;
AcGePoint3d m_DownLeftPt;
AcGePoint3d m_UpRightPt;
private:
};
ACRX_DXF_DEFINE_MEMBERS(CMARectWindow, AcDbEntity,
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
0,
CUSTOMENTITY, /*MSG0*/AUTOCAD);
CMARectWindow::CMARectWindow()
{
}
CMARectWindow::~CMARectWindow()
{}
Acad::ErrorStatus CMARectWindow::getGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapMasks, AcDbIntArray& geomIds)const
{
assertReadEnabled();
AcGePoint3d um,lm,rm,bm;
um=m_UpLeftPt+0.5*(m_UpRightPt-m_UpLeftPt);
lm=m_DownLeftPt+0.5*(m_UpLeftPt-m_DownLeftPt);
rm=m_DownRightPt+0.5*(m_UpRightPt-m_DownRightPt);
bm=m_DownLeftPt+0.5*(m_DownRightPt-m_DownLeftPt);
gripPoints.append(um);
gripPoints.append(rm);
gripPoints.append(bm);
gripPoints.append(lm);
return Acad::eOk;
}
Acad::ErrorStatus CMARectWindow::moveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset)
{
assertWriteEnabled();
switch(indices[0]) {
case 0:
m_UpLeftPt[Y]+=offset.y;
m_UpRightPt[Y]+=offset.y;
break;
case 1:
m_UpRightPt[X]+=offset.x;
m_DownRightPt[X]+=offset.y;
break;
case 2:
m_DownLeftPt[Y]-=offset.y;
m_DownRightPt[Y]-=offset.y;
break;
case 3:
m_DownLeftPt[X]-=offset.x;
m_UpLeftPt[X]-=offset.x;
break;
default:
break;
}
return Acad::eOk;
}
Adesk::Boolean CMARectWindow::worldDraw(AcGiWorldDraw* mode)
{
assertReadEnabled();
m_DownLeftPt[0]=m_UpLeftPt[0];
m_DownLeftPt[1]=m_DownRightPt[1];
m_DownLeftPt[2]=0;
m_UpRightPt[0]=m_DownRightPt[0];
m_UpRightPt[1]=m_UpLeftPt[1];
m_UpRightPt[2]=0;
AcGePoint3d pLineArray[5];
pLineArray[0] =m_UpLeftPt;
pLineArray[1] =m_UpRightPt;
pLineArray[2] =m_DownRightPt;
pLineArray[3] =m_DownLeftPt;
pLineArray[4] =m_UpLeftPt;
mode->geometry().polyline(5, pLineArray);
return Adesk::kTrue;
}
Acad::ErrorStatus CMARectWindow::dwgInFields(AcDbDwgFiler* pFiler)
{
assertWriteEnabled();
Acad::ErrorStatus es;
if ((es = AcDbEntity::dwgInFields(pFiler)) != Acad::eOk)
{
return es;
}
pFiler->readItem(&m_UpLeftPt);
pFiler->readItem(&m_DownRightPt);
pFiler->readItem(&m_DownLeftPt);
pFiler->readItem(&m_UpRightPt);
return pFiler->filerStatus();
}
Acad::ErrorStatus CMARectWindow::dwgOutFields(AcDbDwgFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es;
if ((es = AcDbEntity::dwgOutFields(pFiler)) != Acad::eOk)
{
return es;
}
pFiler->writeItem(m_UpLeftPt);
pFiler->writeItem(m_DownRightPt);
pFiler->writeItem(m_UpRightPt);
pFiler->writeItem(m_DownLeftPt);
return pFiler->filerStatus();
}
Acad::ErrorStatus CMARectWindow::dxfInFields(AcDbDxfFiler* pFiler)
{
assertWriteEnabled();
Acad::ErrorStatus es=Acad::eOk;
resbuf rb;
if ((AcDbEntity::dxfInFields(pFiler)!=Acad::eOk)||!pFiler->atSubclassData("CMARectWindow"))
{
return pFiler->filerStatus();
}
AcGePoint3d ulPt,urPt,dlPt,drPt;
while ((es==Acad::eOk)&&(es=pFiler->readResBuf(&rb))==Acad::eOk)
{
switch(rb.restype) {
case kDxfXCoord:
ulPt=asPnt3d(rb.resval.rpoint);
break;
case kDxfXCoord+1:
urPt=asPnt3d(rb.resval.rpoint);
break;
case kDxfXCoord+2:
dlPt=asPnt3d(rb.resval.rpoint);
break;
case kDxfXCoord+3:
drPt=asPnt3d(rb.resval.rpoint);
break;
default:
pFiler->pushBackItem();
es=Acad::eEndOfFile;
break;
}
}
if (es!=Acad::eEndOfFile)
{
return Acad::eInvalidResBuf;
}
return es;
}
Acad::ErrorStatus CMARectWindow::dxfOutFields(AcDbDxfFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es;
if ((es=AcDbEntity::dxfOutFields(pFiler))!=Acad::eOk)
{
return es;
}
pFiler->writeItem(AcDb::kDxfSubclass,"CMARectWindow");
pFiler->writeItem(AcDb::kDxfXCoord,m_UpLeftPt);
pFiler->writeItem(AcDb::kDxfXCoord+1,m_UpRightPt);
pFiler->writeItem(AcDb::kDxfXCoord+2,m_DownRightPt);
pFiler->writeItem(AcDb::kDxfXCoord+3,m_DownLeftPt);
return es;
}
class AsdkRectJig:public AcEdJig
{
public:
AsdkRectJig(AcGePoint3d &);
void doIt();
virtual DragStatus sampler();
virtual Adesk::Boolean update();
virtual AcDbEntity* entity() const;
protected:
private:
CMARectWindow *mpRect;
AcGePoint3d mUpLeftPt,mDownRightPt;
double m_length,m_height;
AcGeVector3d mNormal;
};
AsdkRectJig::AsdkRectJig(AcGePoint3d &Pt)
{
mpRect=new CMARectWindow();
mpRect->m_UpLeftPt=Pt;
}
void AsdkRectJig::doIt()
{
setDispPrompt("\nRect choose the second point:");
AcEdJig::DragStatus stat=drag();
append();
}
AcEdJig::DragStatus
AsdkRectJig::sampler()
{
DragStatus stat;
setUserInputControls((UserInputControls)
(AcEdJig::kGovernedByOrthoMode
|AcEdJig::kAccept3dCoordinates
|AcEdJig::kNoNegativeResponseAccepted
|AcEdJig::kNoZeroResponseAccepted));
static AcGePoint3d axispointTemp;
stat=acquirePoint(mDownRightPt);
if (axispointTemp!=mDownRightPt)
{
axispointTemp=mDownRightPt;
}
else if(stat==AcEdJig::kNormal)
{
return AcEdJig::kNoChange;
}
return stat;
}
Adesk::Boolean
AsdkRectJig::update()
{
mpRect->m_DownRightPt=mDownRightPt;
return Adesk::kTrue;
}
AcDbEntity *
AsdkRectJig::entity() const
{
return mpRect;
}
// This is command 'REC'
void studyrectrec()
{
// TODO: Implement the command
AcGePoint3d tempPt;
struct resbuf rbFrom,rbTo;
ads_getpoint(NULL,"\nRect choose the first point:",asDblArray(tempPt));
rbFrom.restype=RTSHORT;
rbFrom.resval.rint=1;
rbTo.restype=RTSHORT;
rbTo.resval.rint=0;
ads_trans(asDblArray(tempPt),&rbFrom,&rbTo,Adesk::kFalse,asDblArray(tempPt));
AsdkRectJig *pJig=new AsdkRectJig(tempPt);
pJig->doIt();
delete pJig;
} |
|