Line.cpp
资源名称:CAD.zip [点击查看]
上传用户:hehe2haha
上传日期:2013-08-16
资源大小:161k
文件大小:1k
源码类别:
CAD
开发平台:
Visual C++
- // Line.cpp: implementation of the CLine class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Line.h"
- #include "WinApp.h"
- extern CWinApp g_theApp;
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CLine::CLine()
- {
- strcpy(m_className,"CLine");
- }
- CLine::~CLine()
- {
- }
- void CLine::Draw(HDC hdc)
- {
- HPEN hPen = ::CreatePen( fnPenStyle,nWidth,crColor);
- HPEN hOldPen = (HPEN)::SelectObject(hdc,hPen);
- CDraw::DrawLine(hdc,m_ptFirstPos,m_ptSecondPos);
- ::SelectObject(hdc,hOldPen);
- ::DeleteObject(hPen);
- if(isPick == TRUE)
- {
- DrawRect(hdc);
- }
- }
- BOOL CLine::pick(POINT pt)
- {
- int dblLength = CDraw::Distance(m_ptFirstPos,m_ptSecondPos);
- int dblLength1 = CDraw::Distance(m_ptFirstPos,pt);
- int dblLength2 = CDraw::Distance(m_ptSecondPos,pt);
- if(dblLength1 + dblLength2 - dblLength < 3)
- return TRUE;
- else
- return FALSE;
- }
- //绘制图形已被拾取的标记点
- void CLine::DrawRect(HDC hdc)
- {
- Ellipse(hdc,m_ptFirstPos.x - Rect,m_ptFirstPos.y - Rect,
- m_ptFirstPos.x + Rect,m_ptFirstPos.y + Rect);
- Ellipse(hdc,m_ptSecondPos.x - Rect,m_ptSecondPos.y - Rect,
- m_ptSecondPos.x + Rect,m_ptSecondPos.y + Rect);
- }