- UID
- 1
- 积分
- 15891
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- void arxzoom()
- {
- AcDbViewTableRecord view;
- struct resbuf rb;
- struct resbuf wcs, dcs, ccs; // ads_trans coord system flags
- ads_point vpDir;
- ads_point wmin, wmax; // min and max corners of the zoom window
- ads_point wdcsmax, wdcsmin; // windows corners in device coords
- AcGeVector3d viewDir;
- AcGePoint2d cenPt;
- ads_real lenslength,
- viewtwist,
- frontz,
- backz;
- ads_point target;
- int viewmode,
- tilemode,
- cvport;
- // Get window to zoom to:
- ads_point pt1, pt2;
- if (RTNORM != ads_getpoint(NULL, "\nSelect first corner: ", pt1))
- return;
- if (RTNORM != ads_getcorner(pt1, "\nSelect second corner: ", pt2))
- return;
- // sort window corners to upper right and lower left
-
- if (pt1[X] >= pt2[X])
- {
- wmax[X] = pt1[X];
- wmin[X] = pt2[X];
- }
- else
- {
- wmax[X] = pt2[X];
- wmin[X] = pt1[X];
- }
- if (pt1[Y] >= pt2[Y])
- {
- wmax[Y] = pt1[Y];
- wmin[Y] = pt2[Y];
- }
- else
- {
- wmax[Y] = pt2[Y];
- wmin[Y] = pt1[Y];
- }
- wmax[Z] = 0.0;
- wmin[Z] = 0.0;
- wcs.restype = RTSHORT; // WORLD coord system flag
- wcs.resval.rint = 0;
- ccs.restype = RTSHORT; // CURRENT coord system flag
- ccs.resval.rint = 1;
- dcs.restype = RTSHORT; // DEVICE coord system flag
- dcs.resval.rint = 2;
- // Get the 'VPOINT' direction vector
- ads_getvar("VIEWDIR", &rb);
- ads_trans(rb.resval.rpoint, &ccs, &wcs, 0, vpDir);
- viewDir.set(vpDir[X], vpDir[Y], vpDir[Z]);
- // convert upper right window corner to DCS
- ads_trans(wmax, &ccs, &dcs, 0, wdcsmax);
- // convert lower left window corner to DCS
- ads_trans(wmin, &ccs, &dcs, 0, wdcsmin);
-
- // calculate and set view center point
- cenPt.set(wdcsmin[X] + ((wdcsmax[X] - wdcsmin[X]) / 2.0),
- wdcsmin[Y] + ((wdcsmax[Y] - wdcsmin[Y]) / 2.0)
- );
- view.setCenterPoint(cenPt);
- // set view height and width and direction
- view.setHeight(fabs(wdcsmax[Y] - wdcsmin[Y]));
- view.setWidth(fabs(wdcsmax[X] - wdcsmin[X]));
- view.setViewDirection(viewDir);
- // get and set other properties
- ads_getvar("LENSLENGTH", &rb);
- lenslength = rb.resval.rreal;
- view.setLensLength(lenslength);
- ads_getvar("VIEWTWIST", &rb);
- viewtwist = rb.resval.rreal;
- view.setViewTwist(viewtwist);
- ads_getvar("FRONTZ", &rb);
- frontz = rb.resval.rreal;
- ads_getvar("BACKZ", &rb);
- backz = rb.resval.rreal;
- ads_getvar("VIEWMODE", &rb);
- viewmode = rb.resval.rint;
- view.setPerspectiveEnabled(viewmode & 1);
- view.setFrontClipEnabled(viewmode & 2);
- view.setBackClipEnabled(viewmode & 4);
- view.setFrontClipAtEye(!(viewmode & 16));
- ads_getvar("TILEMODE", &rb);
- tilemode = rb.resval.rint;
- ads_getvar("CVPORT", &rb);
- cvport = rb.resval.rint;
- // Paperspace flag
- Adesk::Boolean paperspace =
- ((tilemode == 0) && (cvport == 1)) ? Adesk::kTrue :
- Adesk::kFalse;
- view.setIsPaperspaceView(paperspace);
- if (Adesk::kFalse == paperspace)
- {
- view.setFrontClipDistance(frontz);
- view.setBackClipDistance(backz);
- }
- else
- {
- view.setFrontClipDistance(0.0);
- view.setBackClipDistance(0.0);
- }
-
- ads_getvar("TARGET", &rb);
- ads_trans(rb.resval.rpoint, &ccs, &wcs, 0, target);
- view.setTarget(AcGePoint3d(target[X], target[Y], target[Z]));
- // update view
- acdbSetCurrentView( &view, NULL );
- }
复制代码 |
|