Vector Tools

Start with the project you created in Vector load and save.

Take the following steps to add panning, selecting, and rotating capabilities:

1.

In the project workspace, click on the Resource View tab and then click to open the "Tutorial resouces" branch.

2.

Click to open the "Menu" branch and double click IDR_MAINFRAME.

3.

Add a menu item called "Tools" between the Edit and View.

4.

Create this Menu structure under the Tools Menu item:

&None with ID = ID_TOOLS_NONE

&Pan with ID = ID_TOOLS_PAN

&Select with ID = ID_TOOLS_SELECT

&Rotate with  ID = ID_TOOLS_ROTATE

5.

Choose View->Class Wizard.

6.

Under the "Class Name" drop down box, select "CTutorialDoc".

7.

Under Object IDs select ID_TOOLS_NONE.

8.

Under Messages, select COMMAND.

9.

Click the "Add Function" button and then the "OK" button.

10.

Under Messages, select UPDATE_COMMAND_UI.

11.

Click the "Add Function" button and then the "OK" button.

12.

Repeat steps 6 through 11 for ID_TOOLS_PAN, ID_TOOLS_ROTATE, ID_TOOLS_SELECT.

13.

Click the Edit Code button.

14.

Add the following code for the eight newly created functions:

void CTutorialDoc::OnToolsNone() 
{
   m_pVectorWindow->SetToolType (TOOL_VECTOR_USERMODE);
}

void CTutorialDoc::OnUpdateToolsNone(CCmdUI* pCmdUI) 
{
   pCmdUI->SetCheck (m_pVectorWindow->GetToolType () == TOOL_VECTOR_USERMODE);
}

void CTutorialDoc::OnToolsPan() 
{
   m_pVectorWindow->SetToolType (TOOL_VECTOR_PANIMAGE);
}

void CTutorialDoc::OnUpdateToolsPan(CCmdUI* pCmdUI) 
{
   pCmdUI->SetCheck(m_pVectorWindow->GetToolType () == TOOL_VECTOR_PANIMAGE);
}

void CTutorialDoc::OnToolsSelect() 
{
   m_pVectorWindow->SetToolType (TOOL_VECTOR_SELECT);
}

void CTutorialDoc::OnUpdateToolsSelect(CCmdUI* pCmdUI) 
{
   pCmdUI->SetCheck(m_pVectorWindow->GetToolType () == TOOL_VECTOR_SELECT);
}

void CTutorialDoc::OnToolsRotate() 
{
   m_pVectorWindow->SetToolType (TOOL_VECTOR_ROTATE);
}

void CTutorialDoc::OnUpdateToolsRotate(CCmdUI* pCmdUI) 
{
   pCmdUI->SetCheck(m_pVectorWindow->GetToolType () == TOOL_VECTOR_ROTATE);
}

15.

Compile and run the program. Load an image. Hit the "+" key on the numeric keypad several times to zoom on the image. Select the Pan tool. A hand appears. Click anywhere on the image and drag. Now choose the Select tool. Click and drag on the image to select objects. Left-double click to select all objects. Right double-click to unselect all objects. Choose the Rotate tool. Left click and drag to rotate about the x and y axes. Right click and drag to rotate along the Z-axis.