- UID
- 4265
- 积分
- 72
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-4-23
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本想通过选二直线的交点,来拖动此二直线的位置
结果,屏幕上出了一堆射线一样的怪东西
程序如下:
// LineJig.h: interface for the LineJig class.
#include "dbpl.h"
class LineJig : public AcEdJig
{
public:
LineJig(const AcGePoint3d point1,const AcGePoint3d point2,const AcGePoint3d point3);
void doIt();
virtual DragStatus sampler();
virtual Adesk::Boolean update();
virtual ~LineJig();
virtual AcDbEntity* entity()const;
private:
AcGePoint3d mPoint;
AcGePoint3d sPoint;
AcGePoint3d ePoint;
AcDbPolyline* pPolyLine;
};
// LineJig.cpp: implementation of the LineJig class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "resource.h"
#include "LineJig.h"
#include "dbjig.h"
#include "stdarx.h"
#include "geassign.h"
#include "geent3d.h"
#include "acdb.h"
#include "dbents.h" // 'old' 2D polyline
#include "dbcurve.h" // Curve base class
#include "dbmain.h" // Entity base class
#include "acgi.h"
#include "acedads.h"
#include "dbapserv.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
static AcGePoint3d midPoint;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
LineJig::LineJig(const AcGePoint3d point1,const AcGePoint3d point2,const AcGePoint3d point3)
{
sPoint=point1;
mPoint=point2;
ePoint=point3;
pPolyLine=new AcDbPolyline();
AcGePoint2d sPoint1,mPoint1,ePoint1;
sPoint1.x=sPoint.x;
sPoint1.y=sPoint.y;
mPoint1.x=mPoint.x;
mPoint1.y=mPoint.y;
ePoint1.x=ePoint.x;
ePoint1.y=ePoint.y;
pPolyLine->addVertexAt(0,sPoint1);
pPolyLine->addVertexAt(1,mPoint1);
pPolyLine->addVertexAt(2,ePoint1);
}
LineJig::~LineJig()
{
}
void LineJig::doIt()
{
// AcDbLine* line1=new AcDbLine(sPoint,mPoint);
// AcDbLine* line2=new AcDbLine(mPoint,ePoint);
AcEdJig::DragStatus stat;
setDispPrompt("\n请重新选择交点:");
stat=drag();
if(stat=kNormal)
append();
else
delete pPolyLine;
}
AcEdJig::DragStatus LineJig::sampler()
{
DragStatus stat=kNormal;
setUserInputControls((UserInputControls)
(AcEdJig::kAccept3dCoordinates));
stat=acquirePoint(midPoint,sPoint);
if(midPoint!=mPoint)
mPoint=midPoint;
else if(stat==AcEdJig::kNormal)
return AcEdJig::kNoChange;
return stat;
}
Adesk::Boolean LineJig::update()
{
AcGePoint2d sPoint1,mPoint1,ePoint1;
sPoint1.x=sPoint.x;
sPoint1.y=sPoint.y;
mPoint1.x=mPoint.x;
mPoint1.y=mPoint.y;
ePoint1.x=ePoint.x;
ePoint1.y=ePoint.y;
pPolyLine->addVertexAt(0,sPoint1);
pPolyLine->addVertexAt(1,mPoint1);
pPolyLine->addVertexAt(2,ePoint1);
return Adesk::kTrue;
}
AcDbEntity* LineJig::entity()const
{
return pPolyLine;
}
// This is command 'CRTPLINE'
void chencrtpline()
{
// TODO: Implement the command
ads_point joinPt;
if(acedGetPoint(NULL,"\n请选择一个交点:",joinPt)==RTNORM);
ads_name ssname;
char sbuf[10];
strcpy(sbuf,"LINE");
struct resbuf eb;
eb.restype=0;
eb.resval.rstring=sbuf;
eb.rbnext=NULL;
ads_point pt1, pt2;
pt1[X] = joinPt[X] - 1;
pt2[X] = joinPt[X] + 1;
pt1[Y] = joinPt[Y] - 1;
pt2[Y] = joinPt[Y] + 1;
acedSSGet("C", pt1, pt2,&eb,ssname);
ads_name m_line1,m_line2;
AcGeLine3d line1,line2;
acedSSName(ssname,0,m_line1);
acedSSName(ssname,1,m_line2);
AcDbObjectId eId1,eId2;
acdbGetObjectId(eId1,m_line1);
acdbGetObjectId(eId2,m_line2);
acedSSFree(ssname);
AcDbLine *pEnt1,*pEnt2;
acdbOpenObject(pEnt1,eId1,AcDb::kForRead);
acdbOpenObject(pEnt2,eId2,AcDb::kForRead);
AcGePoint3d point1,point2,point3;
point2.x=joinPt[X];
point2.y=joinPt[Y];
// point1=point2==pEnt1->startPoint()?pEnt1->endPoint():pEnt1->startPoint();
// point3=point2==pEnt1->startPoint()?pEnt2->endPoint():pEnt2->startPoint();
if(point2==pEnt1->startPoint())
point1=pEnt1->endPoint();
else
point1=pEnt1->startPoint();
if(point2==pEnt2->startPoint())
point1=pEnt2->endPoint();
else
point1=pEnt2->startPoint();
// point3=point2==pEnt1->startPoint()?pEnt2->endPoint():pEnt2->startPoint();
pEnt1->close();
pEnt2->close();
LineJig* pJig=new LineJig(point1,point2,point3);
pJig->doIt();
delete pJig;
}
能帮帮我吗? |
|