![]() |
【转帖】[原创]用tab键移动视图的程序
[原创]用tab键移动视图的程序
[原创]用tab键移动视图的程序 自己用sdk中pretranslate的例子写了一个移动视图的程序,挺简单的 附上工程中唯一的cpp文件,用它来替代sdk下pretranslate中的cpp文件再编译即可 ////////////////////////////////////////////////////////////// // // includes // ////////////////////////////////////////////////////////////// #define _afx_noforce_libs // we do not want to link to mfc dlls or libs #ifdef _debug #define was_debug #undef _debug #endif #include "afxwin.h" // need this because rxmfcapi.h needs windows header. #ifdef was_debug #undef was_debug #define _debug #endif #include "aced.h" #include "adslib.h" #include "rxmfcapi.h" #include <windef.h> #include<accmd.h> //acedcommand #include<acedads.h> //acedsetvar #include<adscodes.h> #include<adsdef.h> //resbuf #include <rxmfcapi.h> #include<dbsymtb.h> //acdbviewtablerecord #include<gepnt3d.h> //acgepoint3d #include<dbapserv.h> //acdbhostapplicationservices #include<gepnt2d.h> //acgepoint2d ////////////////////////////////////////////////////////////// // // standard c test function // ////////////////////////////////////////////////////////////// void snaptab(); // arx callbacks //void zoomextents(); //void zoomextents(); void moveview(); bool filtertab(msg *pmsg); // hook function for capsing. // preventing from inserting the same hook twice. static bool tabdone = false; static long px=0; static long py=0; /*static struct resbuf wcs, ucs;*/ // 转换坐标时使用的坐标系统标记 ////////////////////////////////////////////////////////////// // // rx interface // ////////////////////////////////////////////////////////////// void initapp() { ////snaptab(); acedregcmds->addcommand( "mkevents", // group name "caps", // global function name "caps", // local function name acrx_cmd_modal, // type &snaptab ); // function pointer //acutprintf( ".ok!\n" ); } void unloadapp() { if (tabdone == true) acedremovefilterwinmsg(filtertab); } ////////////////////////////////////////////////////////////// // // entry point // ////////////////////////////////////////////////////////////// extern "c" acrx::appretcode acrxentrypoint( acrx::appmsgcode msg, void* pkt) { switch( msg ) { case acrx::kinitappmsg: //initapp(); snaptab(); acrxunlockapplication(pkt); acrxdynamiclinker->registerappmdiaware(pkt); acutprintf( ".ok!\n" ); break; case acrx::kunloadappmsg: unloadapp(); break; default: break; } return acrx::kretok; } ////////////////////////////////////////////////////////////// bool filtertab(msg *pmsg) { // change all lowercase to caps!! if (pmsg->message == wm_char && pmsg->wparam == 9)//tab键 { moveview(); }else if (pmsg->message == wm_mousemove || pmsg->message == wm_lbuttondown || pmsg->message == wm_lbuttonup){ px=loword(pmsg->lparam); py=hiword(pmsg->lparam); } return false; // continue } void snaptab() { if (tabdone == true) // already has the hook?? return; acutprintf( "capsing...\n" ); if (acedregisterfilterwinmsg(filtertab) == false) acutprintf("can't register windows msg hook - lower->upper\n"); else tabdone = true; } void moveview() { //acutprintf("移动视口!\n"); //本函数用来移动视口 struct resbuf wcs, ucs; // 转换坐标时使用的坐标系统标记 wcs.restype = rtshort; wcs.resval.rint = 0; ucs.restype = rtshort; ucs.resval.rint = 1; double screenx,screeny,vscal;// 1/2 屏幕 宽高 比例:像素/图形单位 struct resbuf viewctr1 ; double vhight,vwidth; ads_point ptcurrent; acgepoint2d center_2d,ocenter_2d;//前一个为待移动的中心点 后一个为当前中心点 acedgetvar("screensize",&viewctr1);//二维点 以像素为单位存储当前视口的大小 screenx=viewctr1.resval.rpoint[x]/2;// 1/2 屏幕 宽 screeny=viewctr1.resval.rpoint[y]/2;// 1/2 屏幕 高 acedgetvar("viewsize",&viewctr1);//类型:实数 按图形单位存储当前视口的高度。 vhight=viewctr1.resval.rreal;//当前视口的高度 类型:实数 vscal=screeny/vhight*2;//比例:像素/图形单位 vwidth= screenx/vscal ;//当前视口的宽度 类型:实数 //********************************************************************* acedgetvar("viewctr",&viewctr1); //类型:三维点 存储当前视口中视图的中心点。该值用 ucs 坐标表示。 ocenter_2d[x]=viewctr1.resval.rpoint[x]; ocenter_2d[y]=viewctr1.resval.rpoint[y]; //************************************************************* ptcurrent[x]=(px-screenx)/vscal+ocenter_2d[x]; ptcurrent[y]=(screeny-py)/vscal+ocenter_2d[y]; acedtrans(ptcurrent, &ucs, &wcs, 0, ptcurrent); center_2d[x]=ptcurrent[x]; center_2d[y]=ptcurrent[y]; acdbviewtablerecord view ;// view2; view.setcenterpoint (center_2d); view.setheight(vhight);//设定图形单位高 view.setwidth(vwidth);//设定图形单位宽 //acutprintf("调用!x:%lf y:%lf\n" ,vwidth,vhight); acedsetcurrentview (&view, null);//null acdbhostapplicationservices()->workingdatabase()->updateext(true);//true } 获赠明经币帖,共获得 0 个明经币 我这里出现很多错误 --------------------configuration: pretranslate - win32 debug-------------------- linking... creating library .\debug/pretranslate.lib and object .\debug/pretranslate.exp link : warning lnk4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /nodefaultlib:library rxtemplt.obj : error lnk 这是工程文件 需要解密fas、vlx请联系本人。email:lidejun_55@tom.com 赠送楼主 0个明经币 看到下面的文字吗? 附上工程中唯一的cpp文件,用它来替代sdk下pretranslate中的cpp文件再编译即可 赠送楼主 0个明经币 问题出在引入的库文件上面,可能是有些库文件没引用,我用的的sdk 还是有很多错误: --------------------configuration: pretranslate - win32 debug-------------------- linking... creating library .\debug/pretranslate.lib and object .\debug/pretranslate.exp rxtemplt.obj : error lnk acge15.lib 这个呢? 赠送楼主 0个明经币 |
| 所有的时间均为北京时间。 现在的时间是 01:25 AM. |