www.pudn.com > roll.rar > GEOMWND.CPP
// GeomWnd.cpp : implementation file // #include "stdafx.h" #include "roll.h" #include "GeomWnd.h" #include "bbroll.h" #include "comnfun.h" #include#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CGeomWnd CGeomWnd::CGeomWnd() { } CGeomWnd::~CGeomWnd() { } BEGIN_MESSAGE_MAP(CGeomWnd, CWnd) //{{AFX_MSG_MAP(CGeomWnd) ON_WM_PAINT() ON_WM_SIZE() ON_WM_DESTROY() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CGeomWnd message handlers BOOL CGeomWnd::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext); } void CGeomWnd::DrawRoller(CDC* dc,CFPoint point[7]) { Line_f(dc,point[0].x,point[0].y,point[1].x,point[1].y); Arc_f(dc,point[3].x,point[3].y,theRoll.m_r1,theRoll.m_r1,point[2].x,point[2].y,point[1].x,point[1].y); Line_f(dc,point[2].x,point[2].y,point[4].x,point[4].y); Arc_f(dc,point[6].x,point[6].y,theRoll.m_r2,theRoll.m_r2,point[4].x,point[4].y,point[5].x,point[5].y); } void CGeomWnd::OnPaint() { CPaintDC dc(this); // device context for painting CRect rect; int ratio; double alfa,sita; GetClientRect(&rect); dc.SetMapMode(MM_ISOTROPIC); ratio=(rect.right>rect.bottom)?rect.bottom:rect.right; sita=2.0*(theRoll.RCENOUT+theRoll.m_r2+theRoll.m_r1); alfa=double(ratio)/sita; if( alfa < 1.0 ) { alfa = 1.0/alfa; ratio = int(alfa)+1; dc.SetWindowExt(ratio,ratio); dc.SetViewportExt(1,-1); } else { ratio = int(alfa); dc.SetWindowExt(1,-1); dc.SetViewportExt(ratio,ratio); } dc.SetViewportOrg(rect.right/2,rect.bottom/2); _Global_Ratio=1.0; CFPoint point[NUMPOINT]; DrawRoller(&dc,theRoll.roller); double step=M_PI2/(double)theRoll.m_teethnum; for(ratio=1;ratio