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.

142 lines
3.9 KiB
C++

#include "StdAfx.h"
#include "MouseToolMove2.h"
#include "GlobalFunction.h"
#include "CommandMove.h"
#include "GlobalDrawMgr.h"
#include "LogMgr.h"
#include "DrawSimpleShape.h"
CMouseToolMove2::CMouseToolMove2(void)
{
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_TOOL_MOVE_FIRST_PT);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
}
CMouseToolMove2::~CMouseToolMove2(void)
{
}
void CMouseToolMove2::OperateOver()
{
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
if(m_Status==_STATUS_2)
{
SObjOperatePar par;
par.OpType = _OP_MOVE;
par.MoveX = m_MoveDisX;
par.MoveY = m_MoveDisY;
//gLayer.OperateObj(par,true,true);
gLayer.OnMove(m_MoveDisX,m_MoveDisY);
}
CMouseTool::OperateOver();
m_Status = _STATUS_END;
}
void CMouseToolMove2::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
{
Dbxy pt = gDraw->CPoint2Dbxy(point);
if(m_Status==_STATUS_1)//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
SaveDownPoint(point);
//------------------------------------<2D><>־start
CString val1;
val1.Format("%lf",pt.x);
CString val2;
val2.Format("%lf",pt.y);
gLogMgr->WriteCmd(CMD_TOOL_MOVE_FIRST_PT,val1,val2);
//------------------------------------<2D><>־end
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_TOOL_MOVE_DIS);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
ToNextStatus();
//<2F><>ѡ<EFBFBD><D1A1>obj <20><><EFBFBD>Ƶ<EFBFBD>m_TmpObjContainer
m_TmpObjContainer.Clear();
gLayer.CloneObj(m_TmpObjContainer,true);
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
CreatOpSimulateObj();
}
else
{
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EBA3AC>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD>׽λ<D7BD><CEBB>
m_MoveDisX = pt.x - m_DownPoint.x;
m_MoveDisY = pt.y - m_DownPoint.y;
OperateOver();
}
}
void CMouseToolMove2::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
{
}
void CMouseToolMove2::OnMouseMove(UINT nFlags, 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_DownPoint,OldPt);
}
XorDrawLine(&dc,gDraw->GetObjectPen(),m_DownPoint,CurPt);//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
//<2F><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>
m_MoveDisX = CurPt.x - m_DownPoint.x;
m_MoveDisY = CurPt.y - m_DownPoint.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);
XorRedrawOpSimulateObj(&dc);
//״̬<D7B4><CCAC>-----------------------------start
CString str1 = "<EFBFBD>ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[x <20><><EFBFBD><EFBFBD>] [y <20><><EFBFBD><EFBFBD>]";
CString str2;
str2.Format("%lf",m_MoveDisX);
CString str3;
str3.Format("%lf",m_MoveDisY);
GetFrame()->ResetStatusBarExtStr();
GetFrame()->SetStatusBarExtStr(str1,str2,str3);
//״̬<D7B4><CCAC>-----------------------------end
SavePreMovePt(point);
}
}
bool CMouseToolMove2::OnSetCmd(CString str)
{
if(m_Status==_STATUS_2)
{
double Val1=0;//x <20><><EFBFBD><EFBFBD>
double Val2=0;//y <20><><EFBFBD><EFBFBD>
int result = GetTwoNum(str,Val1,Val2);
if(result>0)
{
if(result == 2)//<2F><>Ҫͬʱ<CDAC><CAB1><EFBFBD><EFBFBD>
{
m_MoveDisX = Val1;
m_MoveDisY = Val2;
OperateOver();
return true;
}
}
}
return false;
}