Draw.cpp
资源名称:CAD.zip [点击查看]
上传用户:hehe2haha
上传日期:2013-08-16
资源大小:161k
文件大小:1k
源码类别:
CAD
开发平台:
Visual C++
- // Draw.cpp: implementation of the Draw class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Draw.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CDraw::CDraw()
- {
- }
- CDraw::~CDraw()
- {
- }
- //功能:画圆
- void CDraw::DrawCircle(HDC hdc,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(hdc,nLeft,nTop,nRight,nBottom);
- }
- //功能:求两点间距
- int CDraw::Distance(POINT ptPos1, POINT ptPos2)
- {
- double dbD = sqrt( (ptPos1.x - ptPos2.x) * (ptPos1.x - ptPos2.x) +
- (ptPos1.y - ptPos2.y) *(ptPos1.y - ptPos2.y) );
- return (int)dbD;
- }
- //功能:画直线
- void CDraw::DrawLine(HDC hdc,POINT ptFirstPos, POINT ptSecondPos)
- {
- ::MoveToEx(hdc,ptFirstPos.x,ptFirstPos.y,NULL);
- ::LineTo(hdc,ptSecondPos.x,ptSecondPos.y);
- }