//绘矢量方向箭头,该箭头在当前窗口中可见,刷新后消失
void CMyDraw::drawVecArrow(AcGePoint3d p, AcGeVector3d vec)
{
vec = vec.normalize();
AcGePoint3d leftButtomP, rightTopP;
//获得当前屏幕的左下角点和右上角点
getViewSize(leftButtomP, rightTopP);
double len = 0.1 * leftButtomP.distanceTo(rightTopP);
AcGePoint3d ep1, ep2;
ep1 = p - rotateVector(vec, 0.05 * PI) * len;
ep2 = p - rotateVector(vec, -0.05 * PI) * len;
acedGrDraw(asDblArray(p), asDblArray(ep1), 3, 0);
acedGrDraw(asDblArray(p), asDblArray(ep2), 3, 0);
acedGrDraw(asDblArray(ep1), asDblArray(ep2), 3, 0);
}
//获取当前视窗的左下角点和右上角点
void CMyDraw::getViewSize(AcGePoint3d &LeftButtomP, AcGePoint3d &RightTopP)
{
struct resbuf val;
acedGetVar(_T("viewctr"), &val);
//屏幕中心点坐标
AcGePoint3d ctrP;
ctrP.x = val.resval.rpoint
绘矢量方向箭头,该箭头在当前窗口中可见,刷新后消失
最新推荐文章于 2023-09-15 15:10:49 发布
这段代码展示了如何在AutoCAD中绘制一个矢量方向的箭头,箭头在当前窗口可见,但窗口刷新后会消失。`drawVecArrow`函数首先规范化输入的矢量,然后确定屏幕的左下角和右上角点,计算出合适的长度,最后通过`acedGrDraw`绘制箭头的三个部分。`getViewSize`函数则用于获取当前视口的尺寸。
摘要由CSDN通过智能技术生成