Friday, February 22, 2013

Mapping Modes


Mapping Modes:
The mapping modes are used on windows platform for drawing graphical object at correct position.
To control the orientation of the axis of the device context, SetMapMode() is a method of CDC class which is used.
Syntax:
 SetMapMode(int name_of_mapping_mode);
Various mapping modes are –
1.     Text mapping mode
2.     Fixed scale mapping mode
3.     Variable scale mapping mode

1.     Text mapping mode:
In this mapping mode the unit is 1 pixel. Page space in the MM_TEXT mapping mode is equivalent to physical device space. The value of x increases from left to right. The value of y increases from top to bottom. We can change the origin using the function SetViewportOrg and SetWindowOrg.
The window default mapping mode is text mapping mode.
Ex:
Void projView::OnDraw(CDC *pDC)
{
            pDC->SetMapMode(MM_TEXT);
            pDC->SetWindowOrg(CPoint(100,100));
            pDC->Rectangle(CRect(100,100,300,300));
}

Note: proj is project created through MFC AppWizard(.exe)

2.     Fixed scale mapping mode:
Various mapping modes in fixed scale mapping are –



Mapping Mode
Logical Unit
MM_LOENGLISH
0.01 inch
MM_HIENGLISH
0.001 inch
MM_LOMETRIC
0.1 mm
MM_HIMETRIC
0.01 mm
MM_TWIPS
1/440 inch

Ex:
Void projView::OnDraw(CDC *pDC)
{
            pDC->SetMapMode(MM_LOMETRIC);
            pDC->SetWindowOrg(CPoint(100,100));
            pDC->Rectangle(CRect(100,100,300,300));
}

3.     Variable scale mapping mode:
In this mapping mode, there are two mapping modes used to draw and graphical object –
MM_ISOTROPIC
MM_ANISOTROPIC

1.     MM_ISOTROPIC:
Each unit is mapped to an application defined unit. The 1:1 aspect ratio is always preserved in this mode.

2.     MM_ANISOTROPIC:
Each unit is mapped to an application specific unit in device space. The axis may or may not be equally scrolled(x,y).

0 comments:

Post a Comment

Powered by Blogger.