Available in LEADTOOLS Vector Imaging toolkits. |
Start with the project you created in Vector Tools.
Take the following steps to add scale, rotation and translation to the sample program:
1. |
For this tutorial, the VectorWindow must capture and process keystrokes. To process keystrokes, you must derive a class from LVectorWindow and override the MsgProcCallBack (). |
2. |
Click the "Class View" tab in the project workspace. |
3. |
Right click "tutorial classes" and choose "Add Class..." |
4. |
In the Template select c++ class and click add. |
5. |
In the Name edit box, enter "MyVectorWindow". |
6. |
In the Base Class edit box type "LVectorWindow". And click Finish. |
8. |
Double click the "MyVectorWindow" to open the file "MyVectorWindow.h" and immediately before the class declaration, add the line: |
#include "ltwrappr.h"
9. |
Double click the "CTutorialDoc" to open "tutorialDoc.h" and immediately before the class declaration, add the line: |
#include "MyVectorWindow.h"
10. |
Change the definition of *m_pVectorWindow from: |
LVectorWindow *m_pVectorWindow;
to
MyVectorWindow *m_pVectorWindow;
11. |
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 ();
}
12. |
Click the Class View tab in the project workspace. |
13. |
Right-click the class "MyVectorWindow" and choose "Add Function..." |
14. |
Enter LRESULT for the function return type. |
15. |
Enter MsgProcCallBack for the function name, and add the following parameters: (HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) |
16. |
Select the "Protected" from the Access combo box. |
17. |
Click Finish. |
18. |
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);
}
19. |
Edit Stdafx.h and add the following lines: |
#include "ltwrappr.h"
#include "MyVectorWindow.h"
#include "Tutorial.h"
20. |
Compile and run the demo. |
21. |
Select File/Open… From the program menu, browse to the “%UserProfile%\My Documents\LEADTOOLS Images" folder of your LEAD installation. Open the image random.dxf and click OK. |
22. |
Now you should be able to rotate the vector drawing around any axis using the x, y and z keys on your keyboard. |