You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

274 lines
7.5 KiB
C++

#include "StdAfx.h"
#include "GlobalDrawMgr.h"
#include "GlobalFunction.h"
#include "MouseToolmgr.h"
#include "MouseToolPointer.h"
#include "MouseToolRect.h"
#include "MouseToolLine.h"
#include "MouseToolCircle.h"
#include "MouseToolMove.h"
#include "MouseToolRotate.h"
#include "MarkObjPropertieMgr.h"
#include "MouseToolMove2.h"
#include "MouseToolMeasure.h"
#include "MouseToolCopy.h"
#include "MouseToolCut.h"
#include "MouseToolPline.h"
#include "MouseToolDelNode.h"
#include "MouseToolAddNode.h"
#include "MouseToolBreakNode.h"
#include "MouseToolMoveNode.h"
#include "MouseToolOnePoint.h"
#include "CatchMgr.h"
#include "MouseToolStretch.h"
#include "EasyOperationMgr.h"
#include "MouseToolLaserCoord.h"
//ȫ<><C8AB>ָ<EFBFBD><EFBFBD>߹<EFBFBD><DFB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CMouseToolMgr gMouseToolMgr;
CMouseToolMgr::CMouseToolMgr(void)
{
m_MouseToolType = _TOOL_POINT;
}
CMouseToolMgr::~CMouseToolMgr(void)
{
ReleseTool();
}
void CMouseToolMgr::ReleseTool()
{
if(m_pMouseTool)
delete m_pMouseTool;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EAB9A4>
void CMouseToolMgr::SetMouseTool(MOUSE_TOOL MouseToolType)
{
GetCurViewPtr()->SetCursorStyle(MouseToolType);
//<2F><><EFBFBD><EFBFBD>֮ǰ<D6AE>Ĺ<EFBFBD><C4B9><EFBFBD>
m_OldMouseToolType = m_MouseToolType;
m_MouseToolType = MouseToolType;
//<2F><>ɾ<EFBFBD><C9BE>ԭ<EFBFBD><D4AD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD>
ReleseTool();
//<2F><><EFBFBD><EFBFBD><EFBFBD>¹<EFBFBD><C2B9><EFBFBD>
m_pMouseTool = CreatMouseTool(MouseToolType);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD><CBA2>
if(GetFrame())
{
//һЩ<D2BB><D0A9><EFBFBD>߽<EFBFBD><DFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view <20><><EFBFBD><EFBFBD>
if(m_MouseToolType != _TOOL_POINT)
{
GetCurViewPtr()->LimitCursor();
}
else
{
GetCurViewPtr()->ReleseLimitCursor();
}
}
}
CMouseTool * CMouseToolMgr::CreatMouseTool(MOUSE_TOOL MouseToolType)
{
CMouseTool *pMouseTool = NULL;
switch(MouseToolType)
{
case _TOOL_POINT:
pMouseTool = new CMouseToolPointer;
break;
case _TOOL_RECT:
pMouseTool = new CMouseToolRect;
break;
case _TOOL_CIRCLE:
pMouseTool = new CMouseToolCircle;
break;
case _TOOL_LINE:
pMouseTool = new CMouseToolLine;
break;
case _TOOL_PLINE:
pMouseTool = new CMouseToolPline;
break;
case _TOOL_MOVE:
pMouseTool = new CMouseToolMove;
break;
case _TOOL_MOVE2:
pMouseTool = new CMouseToolMove2;
break;
case _TOOL_ROTATO:
pMouseTool = new CMouseToolRotate;
break;
case _TOOL_MEASURE:
pMouseTool = new CMouseToolMeasure;
break;
case _TOOL_COPY:
pMouseTool = new CMouseToolCopy;
break;
case _TOOL_CUT:
pMouseTool = new CMouseToolCut;
break;
case _TOOL_DEL_NODE:
pMouseTool = new CMouseToolDelNode;
break;
case _TOOL_ADD_NODE:
pMouseTool = new CMouseToolAddNode;
break;
case _TOOL_BREAK_NODE:
pMouseTool = new CMouseToolBreakNode;
break;
case _TOOL_MOVE_NODE:
pMouseTool = new CMouseToolMoveNode;
break;
case _TOOL_ONE_POINT:
pMouseTool = new CMouseToolOnePoint;
break;
case _TOOL_STRETCH:
pMouseTool = new CMouseToolStretch;
break;
case _TOOL_LASER_COORD:
pMouseTool = new CMouseToolLaserCoord;
break;
default:
break;
}
return pMouseTool;
}
void CMouseToolMgr::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD>,ʹ<>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
CPoint CatchPoint;
if(gCatchMgr.GetCatchPoint(CatchPoint))
{
point = CatchPoint;
}
m_pMouseTool->OnLButtonDown(nFlags,point,dc);
}
void CMouseToolMgr::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
{
Dbxy pt = gDraw->CPoint2Dbxy(point);
m_pMouseTool->OnLButtonUp(nFlags,point,dc);
if(m_pMouseTool->NeedToPointTool())
{
GetCurViewPtr()->RefreshView();
if(m_pMouseTool->IsEndStatus())
{
SetMouseTool(_TOOL_POINT);
ResetCatchPoint(&dc);
}
}
//<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
gMarkObjPropertieMgr->UpdateSelMarkObjPropertie();
}
void CMouseToolMgr::OnRButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
{
m_pMouseTool->OnRButtonDown(nFlags,point,dc);
if(m_MouseToolType == _TOOL_LINE
||m_MouseToolType == _TOOL_PLINE)
{
SetMouseTool(_TOOL_POINT);
ResetCatchPoint(&dc);
}
}
void CMouseToolMgr::OnRButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
{
m_pMouseTool->OnRButtonUp(nFlags,point,dc);
}
void CMouseToolMgr::OnMouseMove(UINT nFlags, CPoint point,CClientDC &dc)
{
//<2F><>׽point <20><><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>
CatchPoint(point,dc);
//<2F><><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD>׽<EFBFBD><D7BD><EFBFBD><EFBFBD>ʹ<EFBFBD>ò<EFBFBD>׽<EFBFBD><D7BD>
CPoint CatchPoint;
if(gCatchMgr.GetCatchPoint(CatchPoint))
{
point = CatchPoint;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>øı<C4B1>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>
ChangeMouseTool(nFlags,point);
m_pMouseTool->OnMouseMove(nFlags,point,dc);
}
void CMouseToolMgr::CatchPoint(CPoint point,CClientDC &dc)
{
Dbxy pt = gDraw->CPoint2Dbxy(point);
Dbxy DownPt = m_pMouseTool->GetDownPoint();
//һЩ<D2BB><D0A9><EFBFBD>߲<EFBFBD><DFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EAB8BD><EFBFBD>ĵ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>)
if(m_MouseToolType==_TOOL_LINE
||m_MouseToolType==_TOOL_PLINE)
{
gCatchMgr.Catch(DownPt,pt,&dc,true);
}
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
else if(m_MouseToolType==_TOOL_RECT
||m_MouseToolType==_TOOL_CIRCLE
||m_MouseToolType==_TOOL_MEASURE
||m_MouseToolType==_TOOL_ADD_NODE
||m_MouseToolType==_TOOL_DEL_NODE
||m_MouseToolType==_TOOL_ONE_POINT
||m_MouseToolType==_TOOL_LASER_COORD
||m_MouseToolType==_TOOL_MOVE_NODE
||m_MouseToolType==_TOOL_PT_MOVE_TO_CCD
||m_MouseToolType==_TOOL_SET_MARK_PT
||m_MouseToolType==_TOOL_BREAK_NODE)
{
gCatchMgr.Catch(DownPt,pt,&dc,false);
}
else if(m_MouseToolType==_TOOL_MOVE2
||m_MouseToolType==_TOOL_COPY
||m_MouseToolType==_TOOL_ROTATO)
{
//<2F><>Щ<EFBFBD><D0A9><EFBFBD><EFBFBD>ֻ<EFBFBD>ڳ<EFBFBD>ʼ״̬<D7B4><CCAC>׽<EFBFBD><D7BD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
if(m_pMouseTool->GetStatus()==_STATUS_1)
{
gCatchMgr.Catch(DownPt,pt,&dc,true);
}
else
{
gCatchMgr.Catch(DownPt,pt,&dc,false);
}
}
}
void CMouseToolMgr::ResetCatchPoint(CDC* pDC)
{
gCatchMgr.ResetCatchPoint(pDC);
}
void CMouseToolMgr::OnEscapeKey(CDC* pDC)
{
ResetCatchPoint(pDC);
m_pMouseTool->OnEscapeKey();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>øı<C4B1>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>
void CMouseToolMgr::ChangeMouseTool(UINT nFlags, CPoint point)
{
if((m_MouseToolType==_TOOL_POINT && m_pMouseTool->IsStartStatus())
||(m_MouseToolType==_TOOL_MOVE||m_MouseToolType==_TOOL_STRETCH||m_MouseToolType==_TOOL_MOVE_NODE) && !(nFlags&MK_LBUTTON ))
{
//<2F>жϵ<D0B6>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MOUSE_TOOL type = gLayer.JudgeMouseToolType(gDraw->CPoint2Dbxy(point));
if(type == _TOOL_POINT)
{
type = gEasyOperationMgr->JudgeMouseToolType(gDraw->CPoint2Dbxy(point));
}
SetMouseTool(type);
}
}
bool CMouseToolMgr::OnSetCmd(CString str)
{
if(m_pMouseTool->OnSetCmd(str))
{
if(m_MouseToolType == _TOOL_CIRCLE
||m_MouseToolType == _TOOL_MOVE2
||m_MouseToolType == _TOOL_ROTATO
||m_MouseToolType == _TOOL_RECT)
{
if(m_pMouseTool->IsEndStatus())
{
SetMouseTool(_TOOL_POINT);
GetCurViewPtr()->RefreshView();
}
}
//<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
gMarkObjPropertieMgr->UpdateSelMarkObjPropertie();
return true;
}
else
{
return false;
}
}