日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

LiteCAD参考文档的学习七(图像窗口、放大窗口、鸟瞰图、对象属性窗口、极轴跟踪、跳线、事件、用户自定义命令、其它功能)

發布時間:2024/3/12 编程问答 37 豆豆

LiteCAD API reference

一、Graphics window

The LiteCAD graphics window is used to display and edit graphics data contained in the drawing object. Put it as a child-window it on the desired window/form of your application, by call the function lcCreateWindow, and link it with a drawing by the function lcWndSetBlock.
LiteCAD graphics window have service objects Magnifier and Aerial View.

These are some LiteCAD window functions:

1.Defines hover text.BOOL lcWndHoverText (HANDLE hLcWnd,LPCWSTR szText,int X,int Y,int Align);

Hover text demo
When user presses left mouse button - the hover text with cursor coordinates will appear at left-bottom corner of graphics window.When user moves cursor - the text disappear.

... lcEventSetProc( LC_EVENT_MOUSEMOVE, EventProc, 0, 0 ); lcEventSetProc( LC_EVENT_LBDOWN, EventProc, 0, 0 ); ...//----------------------------------------------- void CALLBACK EventProc (HANDLE hEvent) {int EventType;EventType = lcPropGetInt( hEvent, LC_PROP_EVENT_TYPE );switch( EventType ){...case LC_EVENT_MOUSEMOVE: OnMouseMove( hEvent ); break;case LC_EVENT_LBDOWN: OnLBDown( hEvent ); break;...} }double Xcur = 0.0; double Ycur = 0.0;//----------------------------------------------- void OnLBDown (HANDLE hEvent) {HANDLE hLcWnd;double X, Y;int WndW, WndH;WCHAR szText[64];// graphics window handlehLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );// get window size (pixels)WndW = lcPropGetInt( hLcWnd, LC_PROP_WND_WIDTH );WndH = lcPropGetInt( hLcWnd, LC_PROP_WND_HEIGHT );// cursor coordinates (drawing coordinate space)X = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT1 );Y = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT2 );swprintf( szText, L" X=%.2f Y=%.2f ", X, Y );Xcur = X;Ycur = Y;// draw text at left bottom corner of the windowlcWndHoverText( hLcWnd, szText, 10, WndH-10, LC_TA_LEFBOT ); }//----------------------------------------------- void OnMouseMove (HANDLE hEvent) {HANDLE hLcWnd;double X, Y;hLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );X = lcPropGetFloat( hLcWnd, LC_PROP_WND_CURX );Y = lcPropGetFloat( hLcWnd, LC_PROP_WND_CURY );...if (X!=Xcur || Y!=Ycur){// hide hover textlcWndHoverText( hLcWnd, L"", 0, 0, 0 );} }

2.lcWndGetEntByPointlcWndGetEntByPoint2

HANDLE lcWndGetEntByPoint (HANDLE hLcWnd,int Xwin,int Ywin);Returns handle to the entity located at the specified window point, within pickbox surroundings. The size of the pickbox is defined by the LC_PROP_G_PICKBOXSIZE property.
HANDLE lcWndGetEntByPoint2 (HANDLE hLcWnd,double X,double Y,double Delta);Returns a handle to an entity which is touched by specified point. If several entities was found then the function will return the later created entity.

Get one entity by LC_EVENT_LBDOWN event:When user presses left mouse button and key, we try to retrieve an entity at cursor position.If any entity have been found, we change its color to red/yellow.

... lcEventSetProc( LC_EVENT_LBDOWN, EventProc, 0, 0 ); ...//----------------------------------------------- void CALLBACK EventProc (HANDLE hEvent) {int EventType;EventType = lcPropGetInt( hEvent, LC_PROP_EVENT_TYPE );switch( EventType ){...case LC_EVENT_LBDOWN: OnLBDown( hEvent ); break;...} }// Variant 1 //----------------------------------------------- void OnLBDown (HANDLE hEvent) {HANDLE hLcWnd, hEnt;BOOL bCtrl;int Xwin, Ywin;int Color;// State of Ctrl key: 1-pressed, 0-releasedbCtrl = lcPropGetInt( hEvent, LC_PROP_EVENT_INT4 ); if (bCtrl){// graphics window handlehLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );// cursor coordinates (window coordinate space, pixels)Xwin = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );Ywin = lcPropGetInt( hEvent, LC_PROP_EVENT_INT2 );// get entity under cursorhEnt = lcWndGetEntByPoint( hLcWnd, Xwin, Ywin );if (hEnt){// change entity colorColor = lcPropGetInt( hEnt, LC_PROP_ENT_COLOR );if (Color == RGB(255,0,0)){lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,255,0) );}else{lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,0,0) );}lcWndRedraw( hLcWnd );}// disable LiteCAD default actions on LBDown eventlcEventReturnCode( 1 );} }// Variant 2 //----------------------------------------------- void OnLBDown (HANDLE hEvent) {HANDLE hLcWnd, hEnt;BOOL bCtrl;double X, Y, Delta;int Color;// State of Ctrl key: 1-pressed, 0-releasedbCtrl = lcPropGetInt( hEvent, LC_PROP_EVENT_INT4 ); if (bCtrl){// graphics window handlehLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );// get size of pickbox squareDelta = lcPropGetFloat( hLcWnd, LC_PROP_WND_PICKBOXSIZE );// cursor coordinates (drawing coordinate space)X = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT1 );Y = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT2 );// get entity near X, YhEnt = lcWndGetEntByPoint2( hLcWnd, X, Y, Delta );if (hEnt){// change entity colorColor = lcPropGetInt( hEnt, LC_PROP_ENT_COLOR );if (Color == RGB(255,0,0)){lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,255,0) );}else{lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,0,0) );}lcWndRedraw( hLcWnd );}// disable LiteCAD default actions on LBDown eventlcEventReturnCode( 1 );} }

3.lcWndGetEntsByPoint

Gets an array of entities at specified position (window coordinates): int lcWndGetEntsByPoint (HANDLE hLcWnd,int Xwin,int Ywin,int nMaxEnts);
Parameters:
hLcWnd(Handle to LiteCAD graphics window.);Xwin Ywin(Coordinate in LiteCAD window. If -1 specified for both parameters,
then cursor coordinates will be used. );nMaxEnts(Maximal number of entities that can be retrieved.You can specify -1 to retrieve unlimited number of entities.In order to free the inner memory buffer set 0. ).
Return Value:
A number of found entities.
Remarks:
Found entities can be retrieved by the lcWndGetEntity function.

Get several entities by LC_EVENT_LBDOWN event:When user presses left mouse button and key, we try to retrieve all
entities at cursor position.For each found entity, we change its color to yellow/red.

... lcEventSetProc( LC_EVENT_LBDOWN, EventProc, 0, 0 ); ...//----------------------------------------------- void CALLBACK EventProc (HANDLE hEvent) {int EventType;EventType = lcPropGetInt( hEvent, LC_PROP_EVENT_TYPE );switch( EventType ){...case LC_EVENT_LBDOWN: OnLBDown( hEvent ); break;...} }//----------------------------------------------- void OnLBDown (HANDLE hEvent) {HANDLE hLcWnd, hEnt;int i, nEnts, Color, Xwin, Ywin;BOOL bCtrl;// State of Ctrl key: 1-pressed, 0-releasedbCtrl = lcPropGetInt( hEvent, LC_PROP_EVENT_INT4 ); if (bCtrl){// graphics window handlehLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );// get cursor coordinates (window coordinate space, pixels)Xwin = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );Ywin = lcPropGetInt( hEvent, LC_PROP_EVENT_INT2 );// get entities under cursor positionnEnts = lcWndGetEntsByPoint( hLcWnd, Xwin, Ywin, -1 );if (nEnts > 0){for (i=0; i<nEnts; ++i){hEnt = lcWndGetEntity( i );// change entity colorColor = lcPropGetInt( hEnt, LC_PROP_ENT_COLOR );if (Color == RGB(255,0,0)){lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,255,0) );lcPropPutInt( hEnt, LC_PROP_ENT_FCOLOR, RGB(255,255,0) );}else{lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,0,0) );lcPropPutInt( hEnt, LC_PROP_ENT_FCOLOR, RGB(255,0,0) );}}lcWndGetEntity( -1 ); // free memorylcWndRedraw( hLcWnd );}// disable LiteCAD default actions on this eventlcEventReturnCode( 1 );} }

4.lcWndGetEntsByRect

Returns an array of entities which are placed inside or crossed by the specified rectangle: int lcWndGetEntsByRect (HANDLE hLcWnd,double Left,double Bottom,double Right,double Top,BOOL bCross,int nMaxEnts);
Parameters:
hLcWnd(Handle to LiteCAD graphics window.);Left Bottom Right Top(Specify a selecting rectangle coordinates, on the view coordinate space.In order to use currenly visible area, specify zero for all parameters.);bCross(If TRUE, then the function will retrieve entities which are inside or crossed by the specified rectangle.If FALSE, then the function will retrieve entities which are completely inside of the specified rectangle.)nMaxEnts(Maximal number of entities that can be retrieved.You can specify -1 to retrieve unlimited number of entities.In order to free the inner memory buffer set 0. ).
Return Value:
A number of found entities.
Remarks:
Found entities can be retrieved by the lcWndGetEntity function.

Get several entities by LC_EVENT_LBDOWN event:When user presses left mouse button and key, we try to retrieve all
entities at cursor position.For each found entity, we change its color to yellow/red.

... lcEventSetProc( LC_EVENT_LBDOWN, EventProc, 0, 0 ); ...//----------------------------------------------- void CALLBACK EventProc (HANDLE hEvent) {int EventType;EventType = lcPropGetInt( hEvent, LC_PROP_EVENT_TYPE );switch( EventType ){...case LC_EVENT_LBDOWN: OnLBDown( hEvent ); break;...} }// Variant 1 //----------------------------------------------- void OnLBDown (HANDLE hEvent) {HANDLE hLcWnd, hEnt;int i, nEnts, Color;double X, Y, Delta, Lef, Bot, Rig, Top;BOOL bCtrl;// State of Ctrl key: 1-pressed, 0-releasedbCtrl = lcPropGetInt( hEvent, LC_PROP_EVENT_INT4 ); if (bCtrl){// graphics window handlehLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );// get size of pickbox squareDelta = lcPropGetFloat( hLcWnd, LC_PROP_WND_PICKBOXSIZE );// cursor coordinates (drawing coordinate space)X = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT1 );Y = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT2 );// get all entities that crossed by pickboxLef = X - Delta;Bot = Y - Delta;Rig = X + Delta;Top = Y + Delta;nEnts = lcWndGetEntsByRect( hLcWnd, Lef, Bot, Rig, Top, true, -1 );if (nEnts > 0){for (i=0; i<nEnts; ++i){hEnt = lcWndGetEntity( i );// change entity colorColor = lcPropGetInt( hEnt, LC_PROP_ENT_COLOR );if (Color == RGB(255,0,0)){lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,255,0) );}else{lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,0,0) );}}lcWndGetEntity( -1 ); // free memorylcWndRedraw( hLcWnd );}// disable LiteCAD default actions on this eventlcEventReturnCode( 1 );} }// Variant 2 //----------------------------------------------- void OnLBDown (HANDLE hEvent) {HANDLE hLcWnd, hEnt;int i, nEnts, Color;double Lef, Bot, Rig, Top;BOOL bCtrl;// State of Ctrl key: 1-pressed, 0-releasedbCtrl = lcPropGetInt( hEvent, LC_PROP_EVENT_INT4 ); if (bCtrl){// graphics window handlehLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );// pickbox coordinatesLef = lcPropGetFloat( hLcWnd, LC_PROP_WND_CURLEF );Bot = lcPropGetFloat( hLcWnd, LC_PROP_WND_CURBOT );Rig = lcPropGetFloat( hLcWnd, LC_PROP_WND_CURRIG );Top = lcPropGetFloat( hLcWnd, LC_PROP_WND_CURTOP );nEnts = lcWndGetEntsByRect( hLcWnd, Lef, Bot, Rig, Top, true, -1 );if (nEnts > 0){for (i=0; i<nEnts; ++i){hEnt = lcWndGetEntity( i );// change entity colorColor = lcPropGetInt( hEnt, LC_PROP_ENT_COLOR );if (Color == RGB(255,0,0)){lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,255,0) );}else{lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,0,0) );}}lcWndGetEntity( -1 ); // free memorylcWndRedraw( hLcWnd );}// disable LiteCAD default actions on this eventlcEventReturnCode( 1 );} }

二、Magnifier

Magnifier is a frame at the right-bottom corner of in LiteCAD graphics window (see the picture below).It displays enlarged area of a drawing which is currently under cursor. As user moves a cursor over a drawing, image in the magnifier is being changed accordingly, in real-time.

三、Aerial view (Navigator)

“Aerial View” is a floating window which displays an image of entire drawing. The window also contains red rectangle which indicates a part of a drawing that is currenly visible in LiteCAD graphics window.User can move this rectangle inside of “Aerial View” window, thereby changing the view in the LiteCAD graphics window. By rotating mouse wheel user changes size of the red rectangle and visible part of a drawing.

四、Object properties window

The properties window is used to display and edit properties of various LiteCAD objects.In Litecad.exe program this window is placed at left side of the design window. When you select an entity, its properties appear in the window, so you can modify it (see the picture below).

In your application you can put it on desired place.In order to link the properties window with a drawing, youhave to call the lcWndSetProps function.
These are the functions of the properties window:lcCreateProps(Creates the properties window);lcDeleteProps(Deletes the properties window);lcPropsResize(Changes the size and position of the properties window);lcPropsUpdate(Updates the properties window).

五、Polar Tracking

Setting polar tracking on/off:
lcPropPutBool ( hLcWnd, LC_PROP_WND_PTRACK, true );
lcPropPutBool ( hLcWnd, LC_PROP_WND_PTRACK, false );
Setting base point for polar tracking:
lcWndSetBasePoint (hLcWnd, true, X, Y );

Code sample:
lcPropPutBool( hLcWnd, LC_PROP_WND_PTRACK, true );
lcPropPutBool( hLcWnd, LC_PROP_WND_PTRACK_DIST, true );
lcPropPutFloat( hLcWnd, LC_PROP_WND_PTRACK_DIST, 5.0 );
lcPropPutFloat( hLcWnd, LC_PROP_WND_PTRACK_ANGLE, 22.5*LC_DEG_TO_RAD );

六、Jump Lines

If LC_PROP_WND_JUMPLINES property is set to true, then LiteCAD graphics window displays draw direction of graphics objects and pen movement between them, as shown on the picture below. This arrows are called “Jump Lines”.In Litecad.exe program you can switch this option by main menu item “View / Jump lines”.

七、Events

Event processing permits you to control user actions while the user is running your application. LiteCAD features several types of events that can be used to instantiate additional procedural code. For each of these events you create an “event procedure” in your application. It has the following syntax:
void __stdcall EventProc (HANDLE hEvent);

These are some LiteCAD types of events:

1.LC_EVENT_SNAP

LiteCAD generates LC_EVENT_SNAP event when a user moves a mouse inside of the graphics window.In the event procedure your application can analyse the current cursor position and correct it, to make an effect of sticking cursor to specific points when it goes nearby (like magnet).
In order to notify LiteCAD that cursor must be snapped to specific point, within the event procedure call lcEventReturnCode function with non-zero parameter, and set properties LC_PROP_EVENT_FLOAT1 and LC_PROP_EVENT_FLOAT2
with coordinates X, Y of the specific point.

//----------------------------------------------- void LcAppPaint::OnSnap (HANDLE hEvent) {int i;CGePoint Pnt[6];HANDLE hLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );double X = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT1 );double Y = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT2 );double Delta = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT3 );double Lef, Bot, Rig, Top;Pnt[0].Set(50,90);Pnt[1].Set(60,100);Pnt[2].Set(70,90);Pnt[3].Set(80,100);Pnt[4].Set(90,90);Pnt[5].Set(70,80);Lef = X - Delta;Bot = Y - Delta;Rig = X + Delta;Top = Y + Delta;for (i=0; i<6; i++){X = Pnt[i].x;Y = Pnt[i].y;if (Lef<X && X<Rig && Bot<Y && Y<Top){lcPropPutFloat( hEvent, LC_PROP_EVENT_FLOAT1, X );lcPropPutFloat( hEvent, LC_PROP_EVENT_FLOAT2, Y );lcEventReturnCode( 1 );return;}} }

2.LC_EVENT_ENTPROP

LiteCAD generates LC_EVENT_ENTPROP event when a property of graphic entity has been changed.

Properties of “HANDLE” type use object identifier, for example,we have to catch a moment when text style of text entity was changed:

//----------------------------------------------- void OnEntProp (HANDLE hEvent) {HANDLE hDrw, hEnt, hStyle;int idProp, ival;WCHAR szBuf[256];hDrw = lcPropGetHandle( hEvent, LC_PROP_EVENT_DRW );hEnt = lcPropGetHandle( hEvent, LC_PROP_EVENT_ENTITY );idProp = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );switch( idProp ){case LC_PROP_TEXT_STYLE:// text style of entity hEnt was changed ival = lcPropGetInt( hEvent, LC_PROP_EVENT_INT3 ); // previous text style IDival = lcPropGetInt( hEvent, LC_PROP_EVENT_INT4 ); // current text style ID// get text style handle by its IDhStyle = lcDrwGetObjectByID( hDrw, LC_OBJ_TEXTSTYLE, ival );if (hStyle){// get name of current text stylewcsncpy( szBuf, lcPropGetStr( hStyle, LC_PROP_TSTYLE_NAME ), 250 );}break; ... } }//----------------------------------------------- void CALLBACK EventProc (HANDLE hEvent) {int EventType;EventType = lcPropGetInt( hEvent, LC_PROP_EVENT_TYPE );switch( EventType ){case LC_EVENT_ENTPROP: OnEntProp( hEvent ); break;...} }

3.LC_EVENT_DRAWIMAGE

LiteCAD generates LC_EVENT_DRAWIMAGE event when required to display an image object created via the lcBlockAddImagePlace function.

Draw custom raster image (rendered by application)

...// register event procedurelcEventSetProc( LC_EVENT_DRAWIMAGE, DrawImageProc, 0, 0 ); ...// create image object in a drawingHANDLE hImgRef;hImgRef = lcBlockAddImagePlace( hBlock, 105, 10,20,100,50, true );lcBlockUpdate( hBlock, false, hImgRef );lcWndRedraw( m_hLcWnd ); ...// This function is called on LC_EVENT_DRAWIMAGE event //----------------------------------------------- void CALLBACK DrawImageProc (HANDLE hEvent) {COkDib Dib;OK_DIBDRAWPRM Prm;double W, H, PixelSize;int idImage;HANDLE hLcWnd;if (Dib.Load( L"d:/Pictures/SomeImage.bmp" ) == false){return;}hLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );idImage = lcPropGetInt( hEvent, LC_PROP_EVENT_INT6 ); // ID passed by lcBlockAddImagePlace()W = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT1 ); // image width (drawing's units)H = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT2 ); // image height (drawing's units)memset( &Prm, 0, sizeof(Prm) );Prm.hDC = (HDC)lcPropGetHandle( hEvent, LC_PROP_EVENT_HDC );Prm.ImgLeft = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );Prm.ImgBottom = lcPropGetInt( hEvent, LC_PROP_EVENT_INT2 );PixelSize = lcPropGetFloat( hLcWnd, LC_PROP_WND_PIXELSIZE );Prm.ImgWidth = (UINT)(W/PixelSize + 0.5); // 0 for non-scalable imagePrm.ImgHeight = (UINT)(H/PixelSize + 0.5); // 0 for non-scalable image // Prm.Align = 1; // alignment for non-scalable image, 0: center, 1: left-bottomPrm.bDevRectValid = true; // if TRUE then a device rectangle (below parameters) are validPrm.DevLeft = 0;Prm.DevTop = 0;Prm.DevRight = lcPropGetInt( hEvent, LC_PROP_EVENT_INT3 );Prm.DevBottom = lcPropGetInt( hEvent, LC_PROP_EVENT_INT4 );// the next function draws the image using WinAPI function StretchDIBitsDib.Draw( Prm ); }

4.lcCreateCommand

Creates a custom command object.This function can be called only within the LC_EVENT_ADDCMD event procedure.
HANDLE lcCreateCommand (HANDLE hLcWnd,int Id,LPCWSTR szName);
Parameters:
hLcWnd(Handle to LiteCAD graphics window.);Id(Command identifier. Must be unique for any command. Use offset from the constant LC_CMD_CUSTOM, in order do not collide with LiteCAD inner commands.This identifier will be used to call custom command by the lcWndExeCommand function. );szName(Command name.).
Return Value:
Handle to the created command object.If the function fails, the return value is NULL.
Code sample

八、Custom Commands

  • Register custom command events with the lcEventSetProc functions.
  • When LiteCAD fires the LC_EVENT_ADDCMD event, create your custom commands objects with the lcCreateCommand function.
  • Call your command with the lcWndExeCommand function.
  • During the command execution, LiteCAD will fire LC_EVENT_CCMD events
  • In order to finish the command, call lcCmdExit function fromevent procedure.
//Event.cpp //----------------------------------------------- void CALLBACK EventProc (HANDLE hEvent) {int EventType;HANDLE hLcWnd;LcApplication* pApp = (LcApplication*)lcPropGetHandle( hEvent, LC_PROP_EVENT_APPPRM2 );if (pApp){EventType = lcPropGetInt( hEvent, LC_PROP_EVENT_TYPE );switch( EventType ){case LC_EVENT_MOUSEMOVE: pApp->OnMouseMove( hEvent ); break;case LC_EVENT_WNDVIEW: pApp->OnWndView( hEvent ); break;case LC_EVENT_HELP: pApp->OnHelp( hEvent ); break;case LC_EVENT_ADDSTR: pApp->OnAddStr( hEvent ); break;case LC_EVENT_KEYDOWN: pApp->OnKeyDown( hEvent ); break;case LC_EVENT_ADDCMD:// add custom commandshLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );lcCreateCommand( hLcWnd, CMD_SKETCH, L"Sketch" );lcCreateCommand( hLcWnd, CMD_EXPLOD, L"Explod" );break;}} }//----------------------------------------------- void ProcCmdCreate (HANDLE hEvent) {int idCmd = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );switch( idCmd ){case CMD_SKETCH: CmdSketch_Create( hEvent ); break;case CMD_EXPLOD: CmdExplod_Create( hEvent ); break;} } //----------------------------------------------- void ProcCmdDestroy (HANDLE hEvent) {int idCmd = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );switch( idCmd ){case CMD_SKETCH: CmdSketch_Destroy( hEvent ); break;case CMD_EXPLOD: CmdExplod_Destroy( hEvent ); break;} } //----------------------------------------------- void ProcCmdStart (HANDLE hEvent) {int idCmd = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );switch( idCmd ){case CMD_SKETCH: CmdSketch_Start( hEvent ); break;case CMD_EXPLOD: CmdExplod_Start( hEvent ); break;} } //----------------------------------------------- void ProcCmdFinish (HANDLE hEvent) {int idCmd = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );switch( idCmd ){case CMD_SKETCH: CmdSketch_Finish( hEvent ); break;case CMD_EXPLOD: CmdExplod_Finish( hEvent ); break;} } //----------------------------------------------- void ProcCmdLBDown (HANDLE hEvent) {int idCmd = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );switch( idCmd ){case CMD_SKETCH: CmdSketch_LBDown( hEvent ); break;case CMD_EXPLOD: CmdExplod_LBDown( hEvent ); break;} }//----------------------------------------------- void ProcCmdLBUp (HANDLE hEvent) {int idCmd = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );switch( idCmd ){case CMD_SKETCH: CmdSketch_LBUp( hEvent ); break;case CMD_EXPLOD: CmdExplod_LBUp( hEvent ); break;} }//----------------------------------------------- void ProcCmdRBDown (HANDLE hEvent) {int idCmd = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );switch( idCmd ){case CMD_SKETCH: CmdSketch_RBDown( hEvent ); break;case CMD_EXPLOD: CmdExplod_RBDown( hEvent ); break;} }//----------------------------------------------- void ProcCmdRBUp (HANDLE hEvent) {int idCmd = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );switch( idCmd ){case CMD_SKETCH: CmdSketch_RBUp( hEvent ); break;case CMD_EXPLOD: CmdExplod_RBUp( hEvent ); break;} }//----------------------------------------------- void ProcCmdMouseMove (HANDLE hEvent) {int idCmd = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );switch( idCmd ){case CMD_SKETCH: CmdSketch_MouseMove( hEvent ); break;case CMD_EXPLOD: CmdExplod_MouseMove( hEvent ); break;} }//----------------------------------------------- void ProcCmdPaint (HANDLE hEvent) {int idCmd = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );switch( idCmd ){case CMD_SKETCH: CmdSketch_Paint( hEvent ); break;case CMD_EXPLOD: CmdExplod_Paint( hEvent ); break;} }//----------------------------------------------- void ProcCmdSnap (HANDLE hEvent) {int idCmd = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );switch( idCmd ){case CMD_SKETCH: CmdSketch_Snap( hEvent ); break;case CMD_EXPLOD: CmdExplod_Snap( hEvent ); break;} }//----------------------------------------------- void CALLBACK EventProcCmd (HANDLE hEvent) {int Mode = lcPropGetInt( hEvent, LC_PROP_EVENT_MODE );switch( Mode ){case LC_CCMD_CREATE: ProcCmdCreate( hEvent ); break;case LC_CCMD_DESTROY: ProcCmdDestroy( hEvent ); break;case LC_CCMD_START: ProcCmdStart( hEvent ); break;case LC_CCMD_FINISH: ProcCmdFinish( hEvent ); break;case LC_CCMD_LBDOWN: ProcCmdLBDown( hEvent ); break;case LC_CCMD_LBUP: ProcCmdLBUp( hEvent ); break;case LC_CCMD_RBDOWN: ProcCmdRBDown( hEvent ); break;case LC_CCMD_RBUP: ProcCmdRBUp( hEvent ); break;case LC_CCMD_MOUSEMOVE: ProcCmdMouseMove( hEvent ); break;case LC_CCMD_PAINT: ProcCmdPaint( hEvent ); break;case LC_CCMD_SNAP: ProcCmdSnap( hEvent ); break;} }//----------------------------------------------- bool LcApplication::Init (HINSTANCE hInst, LPCWSTR szAppDir) {...lcEventSetProc( LC_EVENT_MOUSEMOVE, EventProc, 0, (HANDLE)this );lcEventSetProc( LC_EVENT_WNDVIEW , EventProc, 0, (HANDLE)this );lcEventSetProc( LC_EVENT_HELP , EventProc, 0, (HANDLE)this );lcEventSetProc( LC_EVENT_ADDSTR , EventProc, 0, (HANDLE)this );lcEventSetProc( LC_EVENT_KEYDOWN , EventProc, 0, (HANDLE)this );lcEventSetProc( LC_EVENT_ADDCMD , EventProc, 0, (HANDLE)this );lcEventSetProc( LC_EVENT_CCMD, EventProcCmd, 0, (HANDLE)this );bInit = lcInitialize();... } //File "CmdSketch.cpp" #include "stdafx.h"static HANDLE hCmd; // this command static HANDLE hPtbuf; // points buffer static int nPnts; static HANDLE hLcWnd; // CAD window static HANDLE hBlock; // current block static BOOL bDraw; // flag "Pen is down"//----------------------------------------------- void CmdSketch_Create (HANDLE hEvent) {hCmd = lcPropGetHandle( hEvent, LC_PROP_EVENT_HCMD );hPtbuf = lcPaint_CreatePtbuf(); // Creates point buffer objectnPnts = 0;hLcWnd = 0;hBlock = 0;bDraw = false; }//----------------------------------------------- void CmdSketch_Destroy (HANDLE hEvent) {lcPaint_DeletePtbuf( hPtbuf );hPtbuf = 0;nPnts = 0; }//----------------------------------------------- void CmdSketch_Start (HANDLE hEvent) {bDraw = false;hLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );lcPaint_PtbufClear( hPtbuf );nPnts = 0;lcEventReturnCode( 1 ); // continue command (wait mouse click) }//----------------------------------------------- void CmdSketch_Finish (HANDLE hEvent) { }//----------------------------------------------- void CmdSketch_LBDown (HANDLE hEvent) {double x, y;x = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT1 );y = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT2 );if (lcPaint_PtbufAddPoint2( hPtbuf, x, y )){++nPnts;}bDraw = true;lcWndRedraw( hLcWnd ); }//----------------------------------------------- void CmdSketch_LBUp (HANDLE hEvent) {HANDLE hPline;bDraw = false;hPline = lcBlockAddPolyline( hBlock, 0, false, false );lcPlineFromPtbuf( hPline, hPtbuf );lcBlockUpdate( hBlock, false, hPline );lcWndRedraw( hLcWnd );lcPaint_PtbufClear( hPtbuf );nPnts = 0; }//----------------------------------------------- void CmdSketch_RBDown (HANDLE hEvent) {lcCmdExit( hCmd ); // exit command }//----------------------------------------------- void CmdSketch_RBUp (HANDLE hEvent) { }//----------------------------------------------- void CmdSketch_MouseMove (HANDLE hEvent) {double x, y;if (bDraw){if (nPnts == 1){lcCmdCursorText( hCmd, L"Move cursor to draw" );}else{lcCmdCursorText( hCmd, L"Release button to stop" );}x = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT1 );y = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT2 );if (lcPaint_PtbufAddPoint2( hPtbuf, x, y )){++nPnts;}lcPaint_DrawPtbuf( hLcWnd, hPtbuf, false );}else{lcCmdCursorText( hCmd, L"Press left button" );} }//----------------------------------------------- void CmdSketch_Paint (HANDLE hEvent) { }//----------------------------------------------- void CmdSketch_Snap (HANDLE hEvent) { } //File "CmdExplod.cpp" #include "stdafx.h"static HANDLE hCmd; // this command static HANDLE hLcWnd; // CAD window static HANDLE hBlock; // current block //----------------------------------------------- void CmdExplod_Create (HANDLE hEvent) {hCmd = lcPropGetHandle( hEvent, LC_PROP_EVENT_HCMD );hLcWnd = 0;hBlock = 0; }//----------------------------------------------- void CmdExplod_Destroy (HANDLE hEvent) { }//----------------------------------------------- void CmdExplod_Start (HANDLE hEvent) {hLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );lcPropPutBool( hCmd, LC_PROP_CMD_CURSORCROSS, false );lcEventReturnCode( 1 ); // continue command (wait mouse click) }//----------------------------------------------- void CmdExplod_Finish (HANDLE hEvent) {lcPropPutBool( hCmd, LC_PROP_CMD_CURSORCROSS, true ); }//----------------------------------------------- void CmdExplod_LBDown (HANDLE hEvent) {HANDLE hEnt, hEnt2;int nPlines, iPline, nVers, iVer;double xc, yc, x0, y0, x1, y1, x2, y2, x3, y3, dx, dy;double Angle, Dist;BOOL bRet;hEnt = lcWndGetEntByPoint( hLcWnd, -1, -1 ); // at cursor positionif (hEnt){xc = lcPropGetFloat( hEnt, LC_PROP_ENT_XCEN );yc = lcPropGetFloat( hEnt, LC_PROP_ENT_YCEN );iPline = 0;nPlines = lcExpEntity( hEnt, LC_EXP_OUTLINE, false );while( 1 ){nVers = lcExpGetPline(0);if (nVers > 0){++iPline;iVer = 0;while( 1 ){bRet = lcExpGetVertex( &x1, &y1 );if (bRet == FALSE){// exit vertices cyclebreak;}// here X,Y has vertex valueif (iVer > 0){hEnt2 = lcBlockAddLine( hBlock, x0, y0, x1, y1 );x2 = (x0 + x1) / 2.0;y2 = (y0 + y1) / 2.0;lcGetPolarPrm( xc, yc, x2, y2, &Angle, &Dist );Dist = Dist * 1.5;lcGetPolarPoint( xc, yc, Angle, Dist, &x3, &y3 );dx = x3 - x2;dy = y3 - y2;lcEntMove( hEnt2, dx, dy );}++iVer;x0 = x1;y0 = y1;}}else{// exit polylines cyclebreak;}}lcEntErase( hEnt, true ); lcBlockUpdate( hBlock, true, 0 );lcWndRedraw( hLcWnd );} }//----------------------------------------------- void CmdExplod_LBUp (HANDLE hEvent) { }//----------------------------------------------- void CmdExplod_RBDown (HANDLE hEvent) {lcCmdExit( hCmd ); // exit command }//----------------------------------------------- void CmdExplod_RBUp (HANDLE hEvent) { }//----------------------------------------------- void CmdExplod_MouseMove (HANDLE hEvent) {lcPaint_DrawPickBox( hLcWnd );lcCmdCursorText( hCmd, L"Pick entity" ); }//----------------------------------------------- void CmdExplod_Paint (HANDLE hEvent) { }//----------------------------------------------- void CmdExplod_Snap (HANDLE hEvent) { }

九、Miscellaneous functions

總結

以上是生活随笔為你收集整理的LiteCAD参考文档的学习七(图像窗口、放大窗口、鸟瞰图、对象属性窗口、极轴跟踪、跳线、事件、用户自定义命令、其它功能)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 成人观看网站 | 久久这里只有精品6 | 亚洲精品美女视频 | 亚洲aaaa级特黄毛片 | 成人污| 久久久久久久久久久网 | 免费大黄网站 | 美国一区二区 | 亚洲男人天堂2018 | 精品无码av一区二区三区不卡 | 内射一区二区 | 国产日韩欧美在线观看 | 少妇人妻偷人精品无码视频 | 性色av一区二区三区免费 | 国产一级免费在线观看 | 日本视频在线播放 | 日韩黄色免费 | 亚洲播放 | 欧美综合网站 | 香蕉av网 | 亚洲成人少妇 | 婷婷在线综合 | 九九九九精品九九九九 | 草逼视频网站 | 超碰狠狠 | 久久成| 国产精品久久久久影院 | 美女屁股网站 | 嫩草一区二区 | 鲁丝av| 亚洲一区二区三区影院 | 波多野结衣爱爱 | 国产69久久 | a天堂视频在线观看 | 黄色片久久 | 亚洲精品一区二区三区中文字幕 | 国产欧美日韩中文字幕 | 精品欧美一区二区精品少妇 | 国产一区二区三区在线 | 天天操人人 | 成人毛片一区二区三区 | 亚洲第六页 | 亚洲激情图片区 | 91亚洲精品视频 | 九九视频精品在线 | 天天操国产 | 一区二区三区四区免费视频 | 催眠美妇肉奴系统 | 色综合中文综合网 | 精品伦精品一区二区三区视频密桃 | 亚洲视频小说 | 亚洲乱码国产乱码精品精 | 黄色永久网站 | 国产精品美女www爽爽爽视频 | 欧美不卡在线视频 | 日韩丰满少妇 | 成人福利视频在线观看 | 国产一区一区 | 毛片入口 | 中文字幕人妻一区二区三区 | 国产成人av片 | 亚洲电影在线看 | 殴美一级特黄aaaaaa | 美女被娇喘视频 | 素人一区 | 久久久精品视频在线观看 | 高清在线一区二区 | videos亚洲| 在线色站 | 无遮挡裸光屁屁打屁股男男 | 成人性生交大片免费看96 | 欧美性精品 | 耳光调教vk | 国产亚洲精品久久久 | 爱搞逼综合 | 久久精品色妇熟妇丰满人妻 | 毛片xxx | 日批av| 天天干,天天操 | 依人综合网 | 日日网| 一区二区三区在线免费视频 | 欧美在线观看一区二区三区 | 欧美黑人xxx | 蜜臀av性久久久久蜜臀aⅴ麻豆 | 欧美成人精品 | 99re中文字幕 | 中文字幕在线字幕中文 | 国产精品免费观看视频 | 国产一区二区a | 超碰最新上传 | www.啪| av不卡在线 | av天天网| 超碰碰97| 男同激情视频 | 国产粉嫩一区二区三区 | 国模精品一区 | 动漫女生光屁股 |