|
[code] // 提示用户选择一个点(无论当前是否在UCS中工作,直接返回该点的WCS坐标)
// basePoint: 基于WCS的点坐标
// 返回值:与acedGetPoint函数相同
static int GetPointReturnCode(const AcGePoint3d &basePoint, const TCHAR* prompt, AcGePoint3d &point);
static bool GetPoint(const AcGePoint3d &basePoint, const TCHAR* prompt, AcGePoint3d &point);
static int GetPointReturnCode(const TCHAR* prompt, AcGePoint3d &point);
static bool GetPoint(const TCHAR* prompt, AcGePoint3d &point);
// 将一个点从用户坐标系坐标转换到世界坐标系
static AcGePoint3d UcsToWcsPoint(const AcGePoint3d &point);
// 将一个点从世界坐标系坐标转换到显示坐标系
static AcGePoint3d WcsToUcsPoint(const AcGePoint3d &point);[/code]
[code]int CArcBlockJig::GetPointReturnCode(const AcGePoint3d &basePoint, const TCHAR* prompt, AcGePoint3d &point)
{
// 将基点转换为UCS坐标
AcGePoint3d ucsBasePoint = CArcBlockJig::WcsToUcsPoint(basePoint);
int nReturn = acedGetPoint(asDblArray(ucsBasePoint), prompt, asDblArray(point));
if (nReturn == RTNORM)
{
// acedGetPoint得到UCS坐标,转换为WCS
point = CArcBlockJig::UcsToWcsPoint(point);
}
return nReturn;
}
int CArcBlockJig::GetPointReturnCode(const TCHAR* prompt, AcGePoint3d &point)
{
int nReturn = acedGetPoint(NULL, prompt, asDblArray(point));
if (nReturn == RTNORM)
{
point = CArcBlockJig::UcsToWcsPoint(point);
}
return nReturn;
}
bool CArcBlockJig::GetPoint(const AcGePoint3d &basePoint, const TCHAR* prompt, AcGePoint3d &point)
{
return (GetPointReturnCode(basePoint, prompt, point) == RTNORM);
}
bool CArcBlockJig::GetPoint(const TCHAR* prompt, AcGePoint3d &point)
{
return (GetPointReturnCode(prompt, point) == RTNORM);
}
AcGePoint3d CArcBlockJig::UcsToWcsPoint(const AcGePoint3d &point)
{
// 转换成世界坐标
AcGePoint3d pt;
struct resbuf rbFrom, rbTo;
rbFrom.restype = RTSHORT;
rbFrom.resval.rint = 1; // from UCS
rbTo.restype = RTSHORT;
rbTo.resval.rint = 0; // to WCS
acedTrans(asDblArray(point), &rbFrom, &rbTo, Adesk::kFalse, asDblArray(pt));
return pt;
}
AcGePoint3d CArcBlockJig::WcsToUcsPoint(const AcGePoint3d &point)
{
// 转换成世界坐标
AcGePoint3d pt;
struct resbuf rbFrom, rbTo;
rbFrom.restype = RTSHORT;
rbFrom.resval.rint = 0; // from WCS
rbTo.restype = RTSHORT;
rbTo.resval.rint = 1; // to UCS
acedTrans(asDblArray(point), &rbFrom, &rbTo, Adesk::kFalse, asDblArray(pt));
return pt;
}
[/code] |
|