Start with the project you created in Vector Tools.
Take the following steps to add scale, rotation and translation to the sample program:
For this tutorial, the VectorWindow must capture and process keystrokes. To process keystrokes, you must derive a class from LVectorWindow and override the MsgProcCallBack().
Click the "Class View" tab in the project workspace.
Right click "tutorial classes" and choose "Add Class..."
In the Template select c++ class and click add.
In the Name edit box, enter "MyVectorWindow".
In the Base Class edit box type "LVectorWindow". And click Finish.
Double click the "MyVectorWindow" to open the file "MyVectorWindow.h" and immediately before the class declaration, add the line:
#include "ltwrappr.h"
Double click the "CTutorialDoc" to open "tutorialDoc.h" and immediately before the class declaration, add the line:
#include "MyVectorWindow.h"
Change the definition of *m_pVectorWindow from:
LVectorWindow *m_pVectorWindow;
to
MyVectorWindow *m_pVectorWindow;
Open the "CTutorialDoc" branch, and double click the CTutorialDoc() constructor. Change the CTutorialDoc() constructor as follows:
CTutorialDoc::CTutorialDoc()
{
m_pVectorWindow = new MyVectorWindow;
m_pVectorWindow->SetBackgroundColor ();
}
Click the Class View tab in the project workspace.
Right-click the class "MyVectorWindow" and choose "Add Function..."
Enter LRESULT for the function return type.
Enter MsgProcCallBack for the function name, and add the following parameters: (HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
Select the "Protected" from the Access combo box.
Click Finish.
Add the following code to the newly created MsgProcCallBack() member function:
LRESULT MyVectorWindow::MsgProcCallBack(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
VECTORPOINT VecPoint;
switch (uMsg)
{
case WM_CHAR:
{
switch( wParam )
{
case 'x':
case 'X':
case 'y':
case 'Y':
case 'z':
case 'Z':
// get current rotation value
GetRotation(&VecPoint);
VecPoint.x += ( wParam == 'x' || wParam == 'X' ) ? 5.0 : 0;
VecPoint.y += ( wParam == 'y' || wParam == 'Y' ) ? 5.0 : 0;
VecPoint.z += ( wParam == 'z' || wParam == 'Z' ) ? 5.0 : 0;
// set new rotation value
SetRotation(&VecPoint);
break;
}
}
}
return LVectorWindow::MsgProcCallBack ( hWnd, uMsg, wParam, lParam);
}
Edit Stdafx.h and add the following lines:
#include "ltwrappr.h"
#include "MyVectorWindow.h"
#include "Tutorial.h"
Compile and run the demo.
Select File/Open From the program menu, browse to the "C:\LEADTOOLS22\Resources\Images" folder. Open the image 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.