Home > Software engineering >  For help! How can use first draw the 1:20 (MM_HIMETRIC) mode 0 a vertical bar. Then use MM_ANISOTROP
For help! How can use first draw the 1:20 (MM_HIMETRIC) mode 0 a vertical bar. Then use MM_ANISOTROP

Time:10-31

(1) to determine the depth of the drawing ratio relations, such as according to 1 0 drawing, the computer screen Y 1 mm to represent the actual depth of 200 mm; The X-axis represents the corresponding well depth measurement data, determined by the calibration type and corresponding channel width its coordinates, does not exist and the actual corresponding proportion
(2) set the mapping mode, drawing according to set the mapping mode and determine the relationship between drawing ratio, the actual well depth data into logical coordinates, and corresponding well depth measurement values according to user selection (the user can choose channel width, scale linear or logarithmic scale, etc.) is transformed into logical coordinates;
(3) using existing mapping function GetWindowExt and GetViewportExt access mode (MM_HIMETRIC) under the window range windowsize and viewport viewsize;
(4) to set the mapping mode to MM_ANISOTROPIC;
(5) SetWindowEx functions to determine the scope of the window as the windowsize;
In my part of the code is on prepare dc initialization, and then draw in ontouch:
 void CZyView: : OnPrepareDC (CDC * pDC, CPrintInfo * pInfo) 
{
PDC - & gt; SetMapMode (MM_ANISOTROPIC);
CRect rcClient;
GetClientRect (rcClient);
Cx=rcClient int. Width ();
Int cy=rcClient. Height ();
//pDC - & gt; Cx/2, SetViewportOrg (cy/2);
PDC - & gt; SetViewportOrg (0, 0);

//pDC - & gt; Cx, SetViewportExt (cy);
PDC - & gt; SetViewportExt (1000, 1000);

PDC - & gt; SetWindowOrg (0, 0);
PDC - & gt; SetWindowExt (1000, 1000);

}


 void CZyView: : ontouch * pDC (CDC) 
{
CZyDoc * pDoc=GetDocument ();
ASSERT_VALID (pDoc);
//TODO: add the draw code for native data here
CRect rcClient;
GetClientRect (rcClient);
Cx=rcClient int. Width ();
Int cy=rcClient. Height ();
The CDC memDc;
//create a memory DC
MemDc. CreateCompatibleDC (NULL);
CBitmap memBtm;
//create a memory bitmap
MemBtm. CreateCompatibleBitmap (pDC, cx, cy);
MemDc. SelectObject (& amp; MemBtm);
//set the mapping mode
MemDc. SetMapMode (MM_ANISOTROPIC);
Cx/2,//memDc. SetViewportOrg (cy/2);
MemDc. SetViewportOrg (0, 0);
MemDc. SetWindowOrg (0, 0);
Cx,//memDc. SetViewportExt (cy);
MemDc. SetViewportExt (1000, 1000);
MemDc. SetWindowExt (1000, 1000);
//device coordinates into logical coordinates
MemDc. DPtoLP (rcClient);
MemDc. BitBlt (rcClient rcClient. Left, top, rcClient. The Width (), rcClient. Height (),
PDC, rcClient left, rcClient. Top SRCCOPY);
//populate memory sketchpad color
MemDc. FillSolidRect (rcClient rcClient. Left, top, rcClient. The Width (), rcClient. Height (), RGB (255255255));

CPen pen;
Pen. CreatePen (PS_SOLID, 1, RGB (0, 0));
CPen * pOldPen=(CPen *) memDc SelectObject (& amp; Pen);
MemDc. MoveTo (100, 100);
MemDc. LineTo (100, 200);
MemDc. MoveTo (200, 100);
MemDc. LineTo (200, 200);
MemDc. SelectObject (pOldPen);
Pen. DeleteObject ();

PDC - & gt; BitBlt (rcClient rcClient. Left, top, rcClient. The Width (), rcClient. Height (),
& MemDc, rcClient left, rcClient. Top SRCCOPY);

ReleaseDC (& amp; MemDc);

}


  • Related