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 "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.

  7. Double click the "MyVectorWindow" to open the file "MyVectorWindow.h" and immediately before the class declaration, add the line:

    #include "ltwrappr.h" 

  8. Double click the "CTutorialDoc" to open "tutorialDoc.h" and immediately before the class declaration, add the line:

    #include "MyVectorWindow.h" 

  9. Change the definition of *m_pVectorWindow from:

    LVectorWindow *m_pVectorWindow;  
    to 
    MyVectorWindow *m_pVectorWindow; 

  10. 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 (); 
    } 

  11. Click the Class View tab in the project workspace.

  12. Right-click the class "MyVectorWindow" and choose "Add Function..."

  13. Enter LRESULT for the function return type.

  14. Enter MsgProcCallBack for the function name, and add the following parameters: (HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)

  15. Select the "Protected" from the Access combo box.

  16. Click Finish.

  17. 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); 
    } 

  18. Edit Stdafx.h and add the following lines:

    #include "ltwrappr.h" 
    #include "MyVectorWindow.h" 
    #include "Tutorial.h" 

  19. Compile and run the demo.

  20. Select File/Open From the program menu, browse to the "C:\LEADTOOLS23\Resources\Images" folder. 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.

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Vector C++ Class Library Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.