To add scale, rotation and translation to a sample program:
Start with the project you created in Vector Load and Save.
Add this local variable under L_INT nRet; in the WndProc function:
VECTORPOINT Point;
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 value
L_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 value
L_VecSetRotation ( &Vector, &Point, NULL, NULL, 0 );
InvalidateRect( hWnd, NULL, FALSE );
break;
case '+':
case '-':
// get current scale value
L_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 value
L_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 translation
L_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 value
L_VecSetTranslation ( &Vector, &Point, NULL, 0 );
InvalidateRect( hWnd, NULL, FALSE );
break;
}
break;
Compile and run the demo.
Select File/Open from the program menu. Browse to C:\LEADTOOLS21\Resources\Images\random.dxf and click OK.
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.