找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 728|回复: 5

[ARX函数]:BOOL filterMouse(MSG *pMsg) 取坐标为何与状态栏的现实有一定的误差?

[复制链接]
发表于 2004-6-20 23:40:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
BOOL filterMouse(MSG *pMsg)
{   
if( pMsg->message == WM_MOUSEMOVE )   
{        
  acedDwgPoint cpt;        
  ads_point ptDCS, ptWCS, norm;        
  AcGePoint3d  origin;        
  AcGeVector3d e0, e1, e2;        
  AcGeMatrix3d  matUcs2Wcs, matWcs2Ucs;        
  // 1: Get the Mouse coords in DCS        
  CPoint cPnt (pMsg->lParam) ;        
  acedCoordFromPixelToWorld (cPnt, cpt) ;        
  acdbPointSet ( cpt, ptDCS );            
  //acutPrintf ( "\nMouse in Ucs %f, %f, %f",  ptDCS[X], ptDCS[Y],ptDCS[Z] );      
   //return FALSE;        
  // 2: Transform the Mouse coords from DCS to WCS        
  // For this we use the    acdbEcs2Ucs  function with the         
  // value of the VIEWDIR system variable as the input normalvector of ECS        
  // (Sure we have to transform the VIEWDIR value from UCS to WCS        
  struct resbuf rbview;        
  acedGetVar( "viewdir", &rbview );        
  ads_point_set( rbview.resval.rpoint, norm );        
  // If the view direction is 0, 0, 1, then acedCoordFromPixelToWorld()        
  // needs special handling -> we only have to translate the thepoint      
   // by the distance the origin of the current UCS was moved        
  double tol = 1e-10;        
  if ((fabs(norm[X]) < tol) && (fabs(norm[Y]) < tol) &&((fabs(norm[Z]) - 1.0) < tol))
  {            
   AcGePoint3d acadPt;            
   acadPt.x = cpt[0];            
   acadPt.y = cpt[1];            
   acadPt.z = cpt[2];            
   acdbUcsMatrix ( matUcs2Wcs );                     
   matUcs2Wcs.invert();            
   matUcs2Wcs.getCoordSystem( origin, e0, e1, e2);            
   acadPt += origin.asVector();            
   acutPrintf ( "\nMouse in Ucs %f, %f, %f",  acadPt[X],acadPt[Y], acadPt[Z] );            
   return FALSE;        
  }        
  //transfoming VIEWDIR  to WCS        
  acdbUcs2Wcs ( norm, norm, Adesk::kTrue );        
  // Transforming the mouse coords from DCS to WCS        
  acdbEcs2Wcs( ptDCS, ptWCS, norm, Adesk::kTrue );        
  // 3: Get the Mouse coordinates in UCS        //        
  // For this we have to project the WCS coordinates to the UCSplane using         
  // the VIEWDIR vector as projection direction.        //        
  // Getting the UCS->WCS transformation matrix        
  acdbUcsMatrix ( matUcs2Wcs );                 
  matUcs2Wcs.getCoordSystem( origin, e0, e1, e2);        
  // Creating a plane which lies on the current UCS        
  //        
  AcGePlane thePlane ( origin, e0, e1);        
  AcGePoint3d  pntMouseInWCS( ptWCS[X], ptWCS[Y], ptWCS[Z] );        
  AcGeVector3d vecViewdir( norm [X], norm [Y], norm [Z] );        
  // Making the projection        
  AcGePoint3d resPnt = pntMouseInWCS.project (thePlane, vecViewdir);        
  // Transforming the point coordinates to UCS.        
  matWcs2Ucs = matUcs2Wcs.inverse();        
  resPnt.transformBy ( matWcs2Ucs );        
  //this line prints the same coordinates as the coordinates         
  //shown in  AutoCAD's status bar        
  acutPrintf ( "\nMouse in Ucs %f, %f, %f",  resPnt[X], resPnt[Y],resPnt[Z] );    }   
  return FALSE; // continue
}
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2004-6-22 09:40:22 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
你将视区放大,会发现差值越来越小
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
 楼主| 发表于 2004-6-22 11:05:58 | 显示全部楼层
非常感谢,可有什么办法解决吗?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-6-23 08:50:07 | 显示全部楼层
没有办法,提供的只是大约的数字。
要准确的话就提供捕捉或直接输入坐标
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2004-6-23 09:11:24 | 显示全部楼层
谢谢~~~
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-6-23 12:01:05 | 显示全部楼层
AcEdInputPointMonitor
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-21 20:25 , Processed in 0.307537 second(s), 43 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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