setView的实现
来源:互联网 发布:淘宝怎么拆分订单付款 编辑:程序博客网 时间:2024/06/05 20:25
昨天文章中提到的setView的函数,采用了如下代码实现。其中,先获取当前DwgView的尺寸,然后在保证pt1/pt2的显示范围的前提下,以指定矩形中心点为中心,计算出符合当前DwgView比例的范围,然后再外扩,从而得到相关的显示范围。以下代码权作备份吧,如果有开发类似的也可以以此作参考。
//设置当前显示范围
void setView(AcGePoint2d Pt1, AcGePoint2d Pt2, double ex_ratio)
{
AcGePoint2d CenterPt;
//若X坐标或Y坐标重合,判为意外,不进行SetView操作
if ((fabs(Pt1.x-Pt2.x)<1e-6)||(fabs(Pt1.y-Pt2.y)<1e-6))
return;
//确保两个坐标点分别为左上角和右下角
if (Pt1.x>Pt2.x) {
double tmp;
tmp = Pt1.x;
Pt1.x = Pt2.x;
Pt2.x = tmp;
}
if (Pt2.y>Pt1.y) {
double tmp;
tmp = Pt1.y;
Pt1.y = Pt2.y;
Pt2.y = tmp;
}
//获取当前DwgView的尺寸
CRect CADrect;
acedGetAcadDwgView()->GetClientRect(&CADrect);
double width,height,ratio;
ratio = (double)(CADrect.right-CADrect.left)/(double)(CADrect.bottom-CADrect.top);
if (fabs(ratio)<1e-6)
return;
if ((Pt2.x-Pt1.x)/(Pt1.y-Pt2.y) > ratio) {
width = Pt2.x-Pt1.x;
height = width/ratio;
}else{
height = Pt1.y-Pt2.y;
width = height * ratio;
}
//设置当前视图中心点
CenterPt.x = (Pt1.x+Pt2.x)/2;
CenterPt.y = (Pt1.y+Pt2.y)/2;
//改变当前视图
AcDbViewTableRecord pVwRec;
pVwRec.setCenterPoint(CenterPt);
pVwRec.setWidth(width * ex_ratio);
pVwRec.setHeight(height * ex_ratio);
acedSetCurrentView( &pVwRec, NULL );
}
- setView的实现
- Toast实现setView布局
- 关于Android AlertDialog的setView
- AlertDialog实现setView及点击事件
- 关于AlertDialog的setView与setContentView区别
- Android的AlertDialog,setView后去除黑色边框
- android中AlertDialog 中setView用法的一些小结
- Android的AlertDialog,setView后去除黑色边框
- 《转载》Android AlertDialog 方法setView(view,0,0,0,0)的使用
- Acrobat PDF的ActiveObject控件js方法SetView控制页面展示类型
- 【Android基础篇】AlertDialog自定义setView方法的控件响应方法
- 【Android基础篇】AlertDialog自定义setView方法的控件响应方法
- Dialog.setContentView( View ) AlertDialog.setView( View ) 区别
- new AlertDialog.Builder(mContext).setView(linearlayout).show();
- Android--添加子视图(addView和setView)
- Android--添加子视图(addView和setView)
- Android--添加子视图(addView和setView)
- toast里面有一个setview方法
- Delphi中使用ActiveX的一些心得
- [STAThread] 这个是什么意思? 是个什么用法?
- 浅谈对数据库模型进行性能优化
- Initial CDT/RSE Integration plugin
- C++ RTTI: 2个宏实现“根据对象名创建对象”
- setView的实现
- (原创,呕心沥血之作,强烈推荐)MS SQL新旧库数据字典比较脚本
- [武侠小说]《血鹦鹉》摘录(古龙作品)
- 奇怪的现象:用了验证控件后按钮失效!
- 浅析C#中图形编程
- 软件开发过程(简洁)
- javascript实现繁体简体转换
- developer express右键菜单显示问题
- 111111111112121