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.

122 lines
3.0 KiB
C++

#include "StdAfx.h"
#include "MouseToolCopy.h"
#include "GlobalFunction.h"
#include "GlobalDrawMgr.h"
#include "LogMgr.h"
#include "CommandCopy.h"
#include "DrawSimpleShape.h"
#include "CommandMgr.h"
CMouseToolCopy::CMouseToolCopy(void)
{
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_TOOL_COPY_BASE_PT);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
}
CMouseToolCopy::~CMouseToolCopy(void)
{
}
void CMouseToolCopy::OperateOver()
{
//obj <20><><EFBFBD><EFBFBD>
SObjOperatePar par;
par.OpType = _OP_MOVE;
par.MoveX = m_MoveDisX;
par.MoveY = m_MoveDisY;
//ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD>obj
m_TmpObjContainer.OperateObj(par,true);
m_TmpObjContainer.DelSelObj();
m_TmpObjContainer.AllObjAddToLayer();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>-------start
CCommandCopy *p = new CCommandCopy;
gCommandMgr.AddUndoCommand(p,m_TmpObjContainer.GetObjVec());
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>-------end
CMouseTool::OperateOver();
m_Status = _STATUS_END;
}
void CMouseToolCopy::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
{
Dbxy pt = gDraw->CPoint2Dbxy(point);
//obj <20><><EFBFBD><EFBFBD>
SObjOperatePar par;
par.OpType = _OP_MOVE;
par.MoveX = m_MoveDisX;
par.MoveY = m_MoveDisY;
//ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD>obj
m_TmpObjContainer.OperateObj(par,true);
//<2F><>¡<EFBFBD><C2A1>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
//<2F>Ȱ<EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ѡ<EFBFBD><D1A1>״̬
m_TmpObjContainer.NotSelAllObj();
//<2F>ٵ<EFBFBD><D9B5>뵱ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD>obj
gLayer.CloneObj(m_TmpObjContainer,true);
if(m_Status==_STATUS_1)//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
m_BasePoint = pt;
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
CreatOpSimulateObj();
ToNextStatus();
}
else
{
//<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>ǰλ<C7B0><CEBB>
m_MoveDisX = pt.x - m_BasePoint.x;
m_MoveDisY = pt.y - m_BasePoint.y;
//<2F><><EFBFBD><EFBFBD><E2BDAB>һ<EFBFBD><D2BB>λ<EFBFBD>ò<EFBFBD><C3B2><EFBFBD>
m_bFirstMove = true;
}
}
void CMouseToolCopy::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
{
}
void CMouseToolCopy::OnMouseMove(UINT nFlag, CPoint point,CClientDC &dc)
{
Dbxy OldPt = gDraw->CPoint2Dbxy(m_PreMovePt);
Dbxy CurPt = gDraw->CPoint2Dbxy(point);
if(m_Status==_STATUS_2)
{
if(m_bFirstMove==false)
{
//<2F>ػ<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
XorRedrawOpSimulateObj(&dc);
}
m_bFirstMove = false;
if(HasPreMovePt())//<2F><><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD>
{
XorDrawLine(&dc,gDraw->GetObjectPen(),m_BasePoint,OldPt);
}
XorDrawLine(&dc,gDraw->GetObjectPen(),m_BasePoint,CurPt);//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
//<2F><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>
m_MoveDisX = CurPt.x - m_BasePoint.x;
m_MoveDisY = CurPt.y - m_BasePoint.y;
//obj <20><><EFBFBD><EFBFBD>
SObjOperatePar par;
par.OpType = _OP_MOVE;
par.MoveX = m_MoveDisX;
par.MoveY = m_MoveDisY;
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
OpSimulateObj(par);
//<2F>ػ<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
XorRedrawOpSimulateObj(&dc);
SavePreMovePt(point);
}
}
void CMouseToolCopy::OnEscapeKey()
{
OperateOver();
}
bool CMouseToolCopy::OnSetCmd(CString str)
{
return false;
}