LineTool.cpp
资源名称:CAD2006.rar [点击查看]
上传用户:ckg1000
上传日期:2013-01-26
资源大小:630k
文件大小:1k
源码类别:
CAD
开发平台:
Visual C++
- // LineTool.cpp: implementation of the CLineTool class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "CAD2006.h"
- #include "LineTool.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CLineTool::CLineTool()
- {
- }
- CLineTool::~CLineTool()
- {
- }
- void CLineTool::Draw(CDC *pDC)
- {
- }
- void CLineTool::OnLButtonDown(CPoint point)
- {
- POINT currentPos; //当前鼠标坐标
- currentPos.x = point.x;
- currentPos.y = point.y;
- switch(m_toolState)
- {
- case noClick: //工具状态为noClick时
- {
- //确定(一次画线行为) 的起始点坐标 m_ptBeginPos
- m_ptBeginPos = m_ptOldPos = point;
- //状态转换为clicked
- m_toolState = Clicked;
- }
- break;
- case Clicked: //工具状态为Clicked时
- {
- //确定(一次画线行为) 的结束点坐标 m_ptEndPos
- m_ptEndPos = point;
- //状态转换为noClick
- m_toolState = noClick;
- }
- break;
- }
- }
- //响应WM_MOUSEMOVE消息
- void CLineTool::OnMouseMove(CDC *pDC,CPoint point)
- {
- POINT currentPos; //当前鼠标坐标
- currentPos.x = point.x;
- currentPos.y = point.y;
- m_ptEndPos = point;
- if(m_toolState == Clicked)
- {
- Draw(CDC *pDC);
- m_ptOldPos = point;
- }
- }