ARX自定义捕捉(AcDbCustomOsnapInfo)中的两个问题
<P>ARX自定义捕捉(AcDbCustomOsnapInfo)中的两个问题</P><P>1. 如果同时捕捉一条直线的中点与最近点,例子如下,但在捕捉中点的时候非常不易,总是受最近点的影响. 猜想可以pickPoint与中点之间的显</P>
<P>示距离小于一定像素时,只追加中点,而不再追加最近点,但又不能计算它们之间的显示距离(像素值)</P>
<P>Acad::ErrorStatus<BR>AsdkThirdOsnapCurveInfo::getOsnapInfo(<BR> AcDbEntity* pickedObject,<BR> int gsSelectionMark,<BR> const AcGePoint3d& pickPoint,<BR> const AcGePoint3d& lastPoint,<BR> const AcGeMatrix3d& viewXform,<BR> AcArray<AcGePoint3d>& snapPoints,<BR> AcArray<int>& geomIdsForPts,<BR> AcArray<AcGeCurve3d*>& snapCurves,<BR> AcArray<int>& geomIdsForLines)<BR>{<BR> if(pickedObject->isKindOf(AcDbLine::desc()))<BR> {<BR> AcDbLine *pLine=AcDbLine::cast(pickedObject);<BR> double startParam, endParam;<BR> Acad::ErrorStatus es=pLine->getStartParam( startParam);<BR> es=pLine->getEndParam( endParam );</P>
<P> AcGePoint3d pt;<BR> es=pLine->getPointAtParam( 0.5*(startParam + endParam), pt );<BR> snapPoints.append(pt);</P>
<P> pLine->getClosestPointTo(pickPoint, pt);<BR> snapPoints.append(pt);<BR> }<BR> return Acad::eOk;<BR>}</P>
<P>2. 怎样捕捉圆(圆弧的圆心)?问题是:鼠标移到圆弧上时,并没有显示圆心符号. 如果加上以下一段:<BR> AcGeLine3d *pLine1=new AcGeLine3d(pt, pt+AcGeVector3d(1, 0, 0));<BR> snapCurves.append(pLine1);<BR> 能显示圆心符号,并能进行X方向的对象追踪,但鼠标移到圆心位置时,圆心符号即消失.</P>
<P><BR>AsdkThirdOsnapCurveInfo::getOsnapInfo(<BR> AcDbEntity* pickedObject,<BR> int gsSelectionMark,<BR> const AcGePoint3d& pickPoint,<BR> const AcGePoint3d& lastPoint,<BR> const AcGeMatrix3d& viewXform,<BR> AcArray<AcGePoint3d>& snapPoints,<BR> AcArray<int>& geomIdsForPts,<BR> AcArray<AcGeCurve3d*>& snapCurves,<BR> AcArray<int>& geomIdsForLines)<BR>{<BR> if(pickedObject->isKindOf(AcDbArc::desc()))<BR> {<BR> AcDbArc *pArc=AcDbArc::cast(pickedObject);<BR> AcGePoint3d pt;<BR> pArc->getStartPoint(pt);<BR> snapPoints.append(pt);<BR> pArc->getEndPoint(pt);<BR> snapPoints.append(pt);</P>
<P> pt=pArc->center();<BR> snapPoints.append(pt);<BR> //AcGeLine3d *pLine1=new AcGeLine3d(pt, pt+AcGeVector3d(1, 0, 0));<BR> //snapCurves.append(pLine1);<BR> //AcGeLine3d *pLine2=new AcGeLine3d(pt, pt+AcGeVector3d(0, 1, 0));<BR> //snapCurves.append(pLine2);<BR> //AcGeCircArc3d *pCircle=new AcGeCircArc3d(pt, AcGeVector3d(0, 0, 1), 1);<BR> //snapCurves.append(pCircle);</P>
<P> pArc->getClosestPointTo(pickPoint, pt);<BR> snapPoints.append(pt);</P>
<P> geomIdsForPts.append(pArc->id().asOldId());<BR> geomIdsForPts.append(pArc->id().asOldId());</P>
<P> return Acad::eOk;<BR> }<BR> return Acad::eOk;<BR>}</P>
<P>高手快来帮一把啊,这两个问题搞得我很郁闷.<BR></P>
页:
[1]