|
[code]static void panView()
{
AcDbDatabase *pDb =
acdbHostApplicationServices()->workingDatabase();
acedVports2VportTableRecords();
//get the active viewport object
AcDbViewportTable *pVpT = NULL;
AcDbViewportTableRecord *pActVp = NULL;
//get the *Active view port
pDb->getViewportTable(pVpT,AcDb::kForRead);
pVpT->getAt(_T("*Active"),pActVp,AcDb::kForWrite);
pVpT->close();
//get the view center point
//assume we need to pan the view along X & Y in 10
double panStep = 10;
AcGePoint2d mCentPt = pActVp->centerPoint();
mCentPt.x += panStep;
mCentPt.y += panStep;
//set the view center
pActVp->setCenterPoint(mCentPt);
//close the Active viewport
pActVp->close();
//update the viewport
acedVportTableRecords2Vports();
}
static void zoomView()
{
AcDbDatabase *pDb =
acdbHostApplicationServices()->workingDatabase();
acedVports2VportTableRecords();
//get the active viewport object
AcDbViewportTable *pVpT = NULL;
AcDbViewportTableRecord *pActVp = NULL;
//get the *Active view port
pDb->getViewportTable(pVpT,AcDb::kForRead);
pVpT->getAt(_T("*Active"),pActVp,AcDb::kForWrite);
pVpT->close();
//assume we need to zoom the view out in scaling 10
double zoomFactor = 10;
pActVp->setHeight(pActVp->height() * zoomFactor);
pActVp->setWidth(pActVp->width() * zoomFactor);
//close the Active viewport
pActVp->close();
//update the viewport
acedVportTableRecords2Vports();
}
static void orbitView()
{
AcDbDatabase *pDb =
acdbHostApplicationServices()->workingDatabase();
acedVports2VportTableRecords();
//get the active viewport object
AcDbViewportTable *pVpT = NULL;
AcDbViewportTableRecord *pActVp = NULL;
//get the *Active view port
pDb->getViewportTable(pVpT,AcDb::kForRead);
pVpT->getAt(_T("*Active"),pActVp,AcDb::kForWrite);
pVpT->close();
//assume we need to orbit the view direction
// along (1,0,0) in angle 30 degree.
AcGeVector3d oOldDir = pActVp->viewDirection();
AcGeMatrix3d oM;
oM.setToRotation(30 * 3.1415926 / 180,AcGeVector3d(1,0,0),AcGePoint3d::kOrigin);
oOldDir.transformBy(oM);
pActVp->setViewDirection(oOldDir);
//close the Active viewport
pActVp->close();
//update the viewport
acedVportTableRecords2Vports();
}[/code] |
|