当前位置: 代码迷 >> 综合 >> 绘矢量方向箭头,该箭头在当前窗口中可见,刷新后消失
  详细解决方案

绘矢量方向箭头,该箭头在当前窗口中可见,刷新后消失

热度:42   发布时间:2024-03-10 00:44:45.0

//绘矢量方向箭头,该箭头在当前窗口中可见,刷新后消失
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[0];
    ctrP.y = val.resval.rpoint[1];
    //屏幕高宽比率
    double ratio;
    ads_real X, Y;
    acedGetVar(_T("screensize"), &val);
    X = val.resval.rpoint[0];
    Y = val.resval.rpoint[1];
    ratio = Y / X;
    //屏幕高
    acedGetVar(_T("viewsize"), &val);
    double h = val.resval.rreal;
    //屏幕宽
    double w = h / ratio;
    LeftButtomP.x = ctrP.x - 0.5 * w;
    LeftButtomP.y = ctrP.y - 0.5 * h;
    RightTopP.x = ctrP.x + 0.5 * w;
    RightTopP.y = ctrP.y + 0.5 * w;
}

  相关解决方案