166 lines
3.4 KiB
C++
166 lines
3.4 KiB
C++
#include "stdafx.h"
|
|
#include "KTTempZoom.h"
|
|
#include "dbxutil.h"
|
|
#include "math.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
KTTempZoom::KTTempZoom()
|
|
{
|
|
}
|
|
|
|
|
|
KTTempZoom::~KTTempZoom()
|
|
{
|
|
|
|
}
|
|
|
|
#define UP PI/2.0
|
|
#define DOWN PI+PI/2.0
|
|
#define LEFT PI
|
|
#define RIGHT 0.0
|
|
|
|
int KTTempZoom::ScrSize(ads_real *width, ads_real *height)
|
|
{
|
|
struct resbuf screensize, viewsize;
|
|
|
|
ads_getvar(_T("SCREENSIZE"), &screensize);
|
|
ads_getvar(_T("VIEWSIZE"), &viewsize);
|
|
|
|
*height = viewsize.resval.rreal;
|
|
*width = screensize.resval.rpoint[X] / screensize.resval.rpoint[Y]*(*height);
|
|
return RTNORM;
|
|
}
|
|
|
|
void KTTempZoom::InitView(AcDbViewTableRecord& view)
|
|
{
|
|
struct resbuf rb0,rb1,rb2;
|
|
|
|
rb0.restype = RTSHORT;
|
|
rb0.resval.rint = 0;
|
|
rb0.rbnext = NULL;
|
|
|
|
rb1.restype = RTSHORT;
|
|
rb1.resval.rint = 1;//WCS 0 UCS 1
|
|
rb1.rbnext = NULL;
|
|
|
|
rb2.restype = RTSHORT;
|
|
rb2.resval.rint = 2;
|
|
rb2.rbnext = NULL;
|
|
|
|
struct resbuf rb;
|
|
acedGetVar(_T("VIEWMODE"),&rb);
|
|
int viewmode = rb.resval.rint;
|
|
|
|
ads_point ptViewCtr;
|
|
acedGetVar(_T("VIEWCTR"),&rb);
|
|
ads_point_set(rb.resval.rpoint,ptViewCtr);
|
|
|
|
ads_point ptDcs;
|
|
acedTrans(ptViewCtr, &rb1, &rb2, 0, ptDcs);
|
|
|
|
acedGetVar(_T("CVPORT"),&rb);
|
|
int nCurVp = rb.resval.rint;
|
|
|
|
view.setIsPaperspaceView(nCurVp==1);
|
|
view.setCenterPoint(asPnt2d(ptDcs));
|
|
|
|
double nWidth, nHeight;
|
|
ScrSize(&nWidth, &nHeight);
|
|
view.setHeight( nHeight);
|
|
view.setWidth( nWidth );
|
|
|
|
ads_point vtViewDir;
|
|
acedGetVar(_T("VIEWDIR"),&rb);
|
|
ads_point_set(rb.resval.rpoint,vtViewDir);
|
|
|
|
acedTrans(vtViewDir, &rb1, &rb2, 1, vtViewDir);
|
|
view.setViewDirection(asPnt3d(vtViewDir).asVector());
|
|
|
|
acedGetVar(_T("VIEWTWIST"),&rb);
|
|
double viewtwist = rb.resval.rreal;
|
|
|
|
view.setViewTwist(viewtwist);
|
|
|
|
ads_point target;
|
|
acedGetVar(_T("TARGET"),&rb);
|
|
ads_point_set(rb.resval.rpoint,target);
|
|
|
|
acedTrans(target, &rb1, &rb0, 0, target);
|
|
view.setTarget(asPnt3d(target));
|
|
|
|
AcGeMatrix3d mat;
|
|
acedGetCurrentUCS(mat);
|
|
|
|
AcGePoint3d ptUcsOrg;
|
|
AcGeVector3d vtXAxis,vtYAxis,vtZAxis;
|
|
mat.getCoordSystem(ptUcsOrg,vtXAxis,vtYAxis,vtZAxis);
|
|
view.setUcs(ptUcsOrg,vtXAxis,vtYAxis);
|
|
|
|
if(viewmode & 0x01)
|
|
{
|
|
/*view.setPerspectiveEnabled(true);
|
|
if(viewmode & 0x04)
|
|
{
|
|
acedGetVar(_T("BACKZ"),&rb);
|
|
double backz = rb.resval.rreal;
|
|
|
|
view.setBackClipEnabled(true);
|
|
view.setBackClipDistance(backz);
|
|
}
|
|
if(viewmode & 0x02)
|
|
{
|
|
view.setFrontClipEnabled(true);
|
|
if(viewmode & 0x10)
|
|
{
|
|
view.setFrontClipAtEye(false);
|
|
|
|
acedGetVar(_T("FRONTZ"),&rb);
|
|
double frontz = rb.resval.rreal;
|
|
view.setFrontClipDistance(frontz);
|
|
}
|
|
else
|
|
{
|
|
view.setFrontClipAtEye(true);
|
|
}
|
|
}*/
|
|
|
|
acedGetVar(_T("LENSLENGTH"),&rb);
|
|
double lenslength = rb.resval.rreal;
|
|
view.setLensLength(lenslength);
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus KTTempZoom::arxZoom(const ads_point ptLow, const ads_point ptUp)
|
|
{
|
|
AcDbViewTableRecord view;
|
|
InitView(view);
|
|
|
|
AcGePoint2d max_2d = asPnt2d(ptUp), min_2d = asPnt2d(ptLow);
|
|
ads_point ptCen;
|
|
Midpoint(ptLow, ptUp, ptCen);
|
|
|
|
struct resbuf rb0,rb2;
|
|
rb0.restype = RTSHORT;
|
|
rb0.resval.rint = 1;//WCS 0 UCS 1
|
|
rb0.rbnext = NULL;
|
|
|
|
rb2.restype = RTSHORT;
|
|
rb2.resval.rint = 2;
|
|
rb2.rbnext = NULL;
|
|
|
|
ads_point ptDcs;
|
|
ads_trans(ptCen, &rb0, &rb2, 0, ptDcs);
|
|
|
|
view.setCenterPoint(asPnt2d(ptDcs));
|
|
|
|
view.setHeight( fabs(ptUp[1] - ptLow[1]) );
|
|
view.setWidth( fabs(ptUp[0] - ptLow[0]) );
|
|
Acad::ErrorStatus es= acedSetCurrentView( &view, NULL );
|
|
|
|
return es;
|
|
} |