明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2013|回复: 0

ARX自定义捕捉(AcDbCustomOsnapInfo)中的两个问题

[复制链接]
发表于 2006-7-8 11:00:00 | 显示全部楼层 |阅读模式

ARX自定义捕捉(AcDbCustomOsnapInfo)中的两个问题

1. 如果同时捕捉一条直线的中点与最近点,例子如下,但在捕捉中点的时候非常不易,总是受最近点的影响. 猜想可以pickPoint与中点之间的显

示距离小于一定像素时,只追加中点,而不再追加最近点,但又不能计算它们之间的显示距离(像素值)

Acad::ErrorStatus
AsdkThirdOsnapCurveInfo::getOsnapInfo(
 AcDbEntity*    pickedObject,
 int      gsSelectionMark,
 const AcGePoint3d&  pickPoint,
 const AcGePoint3d&  lastPoint,
 const AcGeMatrix3d&  viewXform,
 AcArray<AcGePoint3d>& snapPoints,
 AcArray<int>&   geomIdsForPts,
 AcArray<AcGeCurve3d*>& snapCurves,
 AcArray<int>&   geomIdsForLines)
{
 if(pickedObject->isKindOf(AcDbLine::desc()))
 {
  AcDbLine *pLine=AcDbLine::cast(pickedObject);
  double startParam, endParam;
  Acad::ErrorStatus es=pLine->getStartParam( startParam);
  es=pLine->getEndParam( endParam );

  AcGePoint3d pt;
  es=pLine->getPointAtParam( 0.5*(startParam + endParam), pt );
  snapPoints.append(pt);

  pLine->getClosestPointTo(pickPoint, pt);
  snapPoints.append(pt);
 }
 return Acad::eOk;
}

2. 怎样捕捉圆(圆弧的圆心)?问题是:鼠标移到圆弧上时,并没有显示圆心符号. 如果加上以下一段:
  AcGeLine3d *pLine1=new AcGeLine3d(pt, pt+AcGeVector3d(1, 0, 0));
  snapCurves.append(pLine1);
 能显示圆心符号,并能进行X方向的对象追踪,但鼠标移到圆心位置时,圆心符号即消失.


AsdkThirdOsnapCurveInfo::getOsnapInfo(
 AcDbEntity*    pickedObject,
 int      gsSelectionMark,
 const AcGePoint3d&  pickPoint,
 const AcGePoint3d&  lastPoint,
 const AcGeMatrix3d&  viewXform,
 AcArray<AcGePoint3d>& snapPoints,
 AcArray<int>&   geomIdsForPts,
 AcArray<AcGeCurve3d*>& snapCurves,
 AcArray<int>&   geomIdsForLines)
{
 if(pickedObject->isKindOf(AcDbArc::desc()))
 {
  AcDbArc *pArc=AcDbArc::cast(pickedObject);
  AcGePoint3d pt;
  pArc->getStartPoint(pt);
  snapPoints.append(pt);
  pArc->getEndPoint(pt);
  snapPoints.append(pt);

  pt=pArc->center();
  snapPoints.append(pt);
  //AcGeLine3d *pLine1=new AcGeLine3d(pt, pt+AcGeVector3d(1, 0, 0));
  //snapCurves.append(pLine1);
  //AcGeLine3d *pLine2=new AcGeLine3d(pt, pt+AcGeVector3d(0, 1, 0));
  //snapCurves.append(pLine2);
  //AcGeCircArc3d *pCircle=new AcGeCircArc3d(pt, AcGeVector3d(0, 0, 1), 1);
  //snapCurves.append(pCircle);

  pArc->getClosestPointTo(pickPoint, pt);
  snapPoints.append(pt);

  geomIdsForPts.append(pArc->id().asOldId());
  geomIdsForPts.append(pArc->id().asOldId());

  return Acad::eOk;
 }
 return Acad::eOk;
}

高手快来帮一把啊,这两个问题搞得我很郁闷.

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

本版积分规则

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

GMT+8, 2024-11-25 23:43 , Processed in 0.160375 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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