Transformation
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 "New Class..." |
4. |
In the drop down box "Class Type" choose Generic Class. |
5. |
In the Name dialog box, enter "MyVectorWindow". |
6. |
In the "Derived From" list box entry, type "LVectorWindow". |
7. |
A message box appears stating that "The New Class Wizard could not find the appropriate header file(s) to include for the base class(es) LVectorWindow". Click the "OK" button. |
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 Member Function..." |
14. |
Enter LRESULT for the function type. |
15. |
Enter MsgProcCallBack(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) for the function declaration. |
16. |
Select the "Protected" radio button. |
17. |
Click OK. |
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. |
Compile and run the demo. |
20. |
Select File/Open… From the program menu, browse to the "images" folder of your LEAD installation. Open the image random.dxf and click OK. |
21. |
Now you should be able to rotate the vector drawing around any axis using the x, y and z keys on your keyboard. |