缩放实体

18 篇文章 1 订阅
// 调用接口/* 全局函数(实现在ZoomHelper.cpp中) */
/* 参见附件 */
extern void ExecuteZoomCommand1(const AcGePoint3d& minPt, const AcGePoint3d& maxPt);
extern void ExecuteZoomCommand2(const AcGePoint3d& minPt, const AcGePoint3d& maxPt);
//extern void ZommWindowUseCom(const AcGePoint3d& minPt, const AcGePoint3d& maxPt);
extern void ZoomWindowUseView(const AcGePoint3d& minPt, const AcGePoint3d& maxPt);
// 无效
extern void ZoomWindowUseGSView(const AcGePoint3d& minPt, const AcGePoint3d& maxPt);


static void ZoomEntity_Helper(const AcGePoint3d& minPt, const AcGePoint3d& maxPt)
{

//acutPrintf(_T("\n最小点%.3f,%.3f,%.3f)\t最大点%.3f,%.3f,%.3f)\n"), minPt.x, minPt.y, minPt.z, maxPt.x, maxPt.y, maxPt.z);



// 沿着对角线由内向外放大(最小点变小,最大点变大)

double c = 0.618; // 黄金比例值


// 1) 使用sendStringToExecute方法
// 缺点:在命令行显示一些提示字符串,有点烦人(例如: "命令:zoom w 指定第一个位置 ... ")
//ExecuteZoomCommand1(minPt, maxPt);

// 2) 使用acedCommand方法
// 缺点: 在modelss dialog中无法使用(具体的说是在application context下无法执行)
// 参见:arxdoc.chm->Advanced Topics->The Multiple Document Interface
//        ->Application Execution Context
//        ->Code Differences under the Application Execution Context
//ExecuteZoomCommand2(minPt, maxPt);

// 3) 使用com
// 缺点: 显示一些空的命令提示(例如"命令: ")
//ZommWindowUseCom(minPt, maxPt);

// 4) 使用view
// 缺点:如果在缩放的时候,对图元进行了修改,例如修改颜色,并不会马上更新
//        只有当前焦点在cad的绘图窗口时,才会更新
// 参见:<<ObjectARX开发实例教程-20090826>>中的"4.4 视图"小节
ZoomWindowUseView(minPt, maxPt);

// 5) 使用AcGsView(失败)
// AcGsView只能用于3d模式
//ZoomWindowUseGSView(minPt, maxPt);
}

void ArxEntityHelper::ZoomToEntity( const AcDbObjectId& objId )
{
    AcTransaction* pTrans = actrTransactionManager->startTransaction();
    if(pTrans == 0) return;

    AcDbObject* pObj;
    if(Acad::eOk != pTrans->getObject(pObj, objId, AcDb::kForRead))
    {
       actrTransactionManager->abortTransaction();
        return;
    }

    AcDbEntity* pEnt = AcDbEntity::cast(pObj);
    if(pEnt == 0)
    {
      actrTransactionManager->abortTransaction();
       return;
    }

    AcDbExtents extents;
    bool ret = (Acad::eOk == pEnt->getGeomExtents(extents));

    actrTransactionManager->endTransaction();

    if(ret)
    {
        ZoomEntity_Helper(extents.minPoint(), extents.maxPoint());
    }
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值