To add scale, rotation and translation to a sample program:
Start with the project you created in Vector Load and Save.
1. |
Add this local variable under L_INT nRet; in the WndProc function: |
VECTORPOINT Point; 2. |
Add these cases under the WM_COMMAND case: |
case WM_CHAR:switch( wParam ){case 'x':case 'X':case 'y':case 'Y':case 'z':case 'Z':// get current rotation valueL_VecGetRotation ( &Vector, &Point );Point.x += ( wParam == 'x' || wParam == 'X' ) ? 5.0 : 0;Point.y += ( wParam == 'y' || wParam == 'Y' ) ? 5.0 : 0;Point.z += ( wParam == 'z' || wParam == 'Z' ) ? 5.0 : 0;// set new rotation valueL_VecSetRotation ( &Vector, &Point, NULL, NULL, 0 );InvalidateRect( hWnd, NULL, FALSE );break;case '+':case '-':// get current scale valueL_VecGetScale ( &Vector, &Point );Point.x += ( wParam == '+' ) ? 0.1 : -0.1;Point.y += ( wParam == '+' ) ? 0.1 : -0.1;Point.z += ( wParam == '+' ) ? 0.1 : -0.1;// set new scale valueL_VecSetScale ( &Vector, &Point, NULL, NULL, 0 );InvalidateRect( hWnd, NULL, FALSE );break;}break;case WM_KEYDOWN:switch( wParam ){case VK_UP:case VK_DOWN:case VK_LEFT:case VK_RIGHT:// get current translationL_VecGetTranslation ( &Vector, &Point );if( wParam == VK_LEFT ) Point.x -= 1.0;if( wParam == VK_RIGHT ) Point.x += 1.0;if( wParam == VK_UP ) Point.y += 1.0;if( wParam == VK_DOWN ) Point.y -= 1.0;// set new translation valueL_VecSetTranslation ( &Vector, &Point, NULL, 0 );InvalidateRect( hWnd, NULL, FALSE );break;}break;
3. |
Compile and run the demo. |
4. |
Select File/Open from the program menu. Browse to C:\users\Public\Documents\LEADTOOLS Images\random.dxf and click OK. |
5. |
Now you should be able to rotate the vector drawing around any axis using the x, y and z keys on your keyboard and scale up and down using the + and keys. |