马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
问题: 如何定义透明的命令,允许在屏幕四个方向分别PAN半个屏幕
解决方案:
The following code defines a transparent pan command for each of the four main
compass directions:
#include "rxregsvc.h"
#include "aced.h"
#include "dbsymtb.h"
#include "adscodes.h"
// Required for AutoCAD 2000
#include "migrtion.h"
// Deal with renaming of function in ObjectARX 2000
#define acdbSetCurrentView acedSetCurrentView
void panleft();
void panright();
void panup();
void pandown();
void
initApp()
{
acedRegCmds->addCommand( "PANNER", // Group name
"panl", // Global function name
"panl", // Local function name
ACRX_CMD_TRANSPARENT, // Type
&panleft ); // Function pointer
acedRegCmds->addCommand( "PANNER", // Group name
"panr", // Global function name
"panr", // Local function name
ACRX_CMD_TRANSPARENT, // Type
&panright ); // Function pointer
acedRegCmds->addCommand( "PANNER", // Group name
"panu", // Global function name
"panu", // Local function name
ACRX_CMD_TRANSPARENT, // Type
&panup ); // Function pointer
acedRegCmds->addCommand( "PANNER", // Group name
"pand", // Global function name
"pand", // Local function name
ACRX_CMD_TRANSPARENT, // Type
&pandown ); // Function pointer
}
void
unloadApp()
{
acedRegCmds->removeGroup( "PANNER" );
}
extern "C" AcRx::AppRetCode acrxEntryPoint( AcRx::AppMsgCode msg, void *p )
{
switch (msg)
{
case AcRx::kInitAppMsg:
acrxRegisterAppMDIAware(p);
acrxUnlockApplication(p); // try to allow unloading
initApp();
break;
case AcRx::kUnloadAppMsg:
unloadApp();
break;
default:
break;
}
return AcRx::kRetOK;
}
void
getCurrentView( AcDbViewTableRecord &view )
{
struct resbuf var;
struct resbuf WCS, UCS, DCS;
WCS.restype = RTSHORT;
WCS.resval.rint = 0;
UCS.restype = RTSHORT;
UCS.resval.rint = 1;
DCS.restype = RTSHORT;
DCS.resval.rint = 2;
ads_getvar("VIEWMODE", &var);
view.setPerspectiveEnabled(var.resval.rint & 1);
view.setFrontClipEnabled(var.resval.rint & 2 ? true : false);
view.setBackClipEnabled(var.resval.rint & 4 ? true : false);
view.setFrontClipAtEye(!(var.resval.rint & 16));
ads_getvar("BACKZ", &var);
view.setBackClipDistance(var.resval.rreal);
ads_getvar("VIEWCTR", &var);
ads_trans(var.resval.rpoint, &UCS, &DCS, NULL, var.resval.rpoint);
view.setCenterPoint(AcGePoint2d(var.resval.rpoint[X],
var.resval.rpoint[Y]));
ads_getvar("FRONTZ", &var);
view.setFrontClipDistance(var.resval.rreal);
ads_getvar("LENSLENGTH", &var);
view.setLensLength(var.resval.rreal);
ads_getvar("TARGET", &var);
ads_trans(var.resval.rpoint, &UCS, &WCS, NULL, var.resval.rpoint);
view.setTarget(AcGePoint3d(var.resval.rpoint[X], var.resval.rpoint[Y],
var.resval.rpoint[Z]));
ads_getvar("VIEWDIR", &var);
ads_trans(var.resval.rpoint, &UCS, &WCS, TRUE, var.resval.rpoint);
view.setViewDirection(AcGeVector3d(var.resval.rpoint[X],
var.resval.rpoint[Y], var.resval.rpoint[Z]));
ads_getvar("VIEWSIZE", &var);
view.setHeight(var.resval.rreal);
double tst = view.width();
}
void
panleft()
{
AcDbViewTableRecord view;
getCurrentView( view );
AcGePoint2d viewCen = view.centerPoint();
viewCen[X] = viewCen[X] - ( view.width() / 2 );
view.setCenterPoint( viewCen );
acdbSetCurrentView( &view, NULL );
}
void
panright()
{
AcDbViewTableRecord view;
getCurrentView( view );
AcGePoint2d viewCen = view.centerPoint();
viewCen[X] = viewCen[X] + ( view.width() / 2 );
view.setCenterPoint( viewCen );
acdbSetCurrentView( &view, NULL );
}
下面是pandown()和panup()的定义函数
void
pandown()
{
AcDbViewTableRecord view;
getCurrentView( view );
AcGePoint2d viewCen = view.centerPoint();
viewCen[Y] = viewCen[Y] - ( view.height() / 2 );
view.setCenterPoint( viewCen );
acdbSetCurrentView( &view, NULL );
}
void
panup()
{
AcDbViewTableRecord view;
getCurrentView( view );
AcGePoint2d viewCen = view.centerPoint();
viewCen[Y] = viewCen[Y] + ( view.height() / 2 );
view.setCenterPoint( viewCen );
acdbSetCurrentView( &view, NULL );
}
|