www.pudn.com > my2cadtest07261930.rar > CircleTool.cpp, change:2006-07-25,size:1436b


// CircleTool.cpp: implementation of the CCircleTool class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "CircleTool.h" 
#include "Shape.h" 
#include "Circle.h" 
extern CList<CShape *> m_list; 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CCircleTool::CCircleTool(HWND hWnd):CTool(hWnd) 
{ 
 
} 
 
CCircleTool::~CCircleTool() 
{ 
 
} 
 
void CCircleTool::PreDraw() 
{	 
	int Radius = m_begPT.DistanceTo(m_oldPT); 
    DrawCircle(m_begPT.GetPoint(), Radius); 
 
	Radius = m_begPT.DistanceTo(m_endPT.GetPoint()); 
	DrawCircle(m_begPT.GetPoint(), Radius); 
	m_oldPT = m_endPT; 
} 
 
void CCircleTool::Draw() 
{ 
	int Radius = m_begPT.DistanceTo(m_oldPT); 
    DrawCircle(m_begPT.GetPoint(), Radius); 
} 
 
void CCircleTool::SaveSelf() 
{ 
	CShape *newcircle = new CCircle(m_begPT,m_endPT); 
	newcircle->SetLOGPEN(penattrib->GetPenStyle(false)); 
    newcircle->SetLOGBRUSH(penattrib->GetBrushStyle(false)); 
	 
	m_list.AddTail(newcircle); 
    m_list.SetEditStatus(true); 
 
} 
 
void CCircleTool::DrawCircle(POINT ptCenter, int nRadius) 
{ 
	int nLeft   = ptCenter.x - nRadius; 
	int nTop    = ptCenter.y - nRadius; 
	int nRight  = ptCenter.x + nRadius; 
	int nBottom = ptCenter.y + nRadius; 
	::Ellipse(m_hdc,nLeft,nTop,nRight,nBottom); 
}