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++
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)
|
|
{
|
|
//标签栏-------------------------start
|
|
GetFrame()->ResetCaptionBar();
|
|
GetFrame()->SetCaptionCmdStr(CMD_TOOL_MOVE_FIRST_PT);
|
|
GetFrame()->RefreashCaptionBar();
|
|
//标签栏-------------------------end
|
|
}
|
|
CMouseToolMove2::~CMouseToolMove2(void)
|
|
{
|
|
}
|
|
void CMouseToolMove2::OperateOver()
|
|
{
|
|
//标签栏-------------------------start
|
|
GetFrame()->ResetCaptionBar();
|
|
//标签栏-------------------------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)//指定基点
|
|
{
|
|
SaveDownPoint(point);
|
|
//------------------------------------日志start
|
|
CString val1;
|
|
val1.Format("%lf",pt.x);
|
|
CString val2;
|
|
val2.Format("%lf",pt.y);
|
|
gLogMgr->WriteCmd(CMD_TOOL_MOVE_FIRST_PT,val1,val2);
|
|
//------------------------------------日志end
|
|
//标签栏-------------------------start
|
|
GetFrame()->ResetCaptionBar();
|
|
GetFrame()->SetCaptionCmdStr(CMD_TOOL_MOVE_DIS);
|
|
GetFrame()->RefreashCaptionBar();
|
|
//标签栏-------------------------end
|
|
ToNextStatus();
|
|
//将选中obj 复制到m_TmpObjContainer
|
|
m_TmpObjContainer.Clear();
|
|
gLayer.CloneObj(m_TmpObjContainer,true);
|
|
|
|
//创建模拟操作的对象
|
|
CreatOpSimulateObj();
|
|
}
|
|
else
|
|
{
|
|
//需要重新计算移动距离,因为可能有捕捉位置
|
|
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)
|
|
{
|
|
//重绘模拟对象
|
|
XorRedrawOpSimulateObj(&dc);
|
|
}
|
|
m_bFirstMove = false;
|
|
|
|
if(HasPreMovePt())//擦除之前的线
|
|
{
|
|
XorDrawLine(&dc,gDraw->GetObjectPen(),m_DownPoint,OldPt);
|
|
}
|
|
XorDrawLine(&dc,gDraw->GetObjectPen(),m_DownPoint,CurPt);//绘制一条临时线
|
|
|
|
//计算移动距离
|
|
m_MoveDisX = CurPt.x - m_DownPoint.x;
|
|
m_MoveDisY = CurPt.y - m_DownPoint.y;
|
|
//obj 操作
|
|
SObjOperatePar par;
|
|
par.OpType = _OP_MOVE;
|
|
par.MoveX = m_MoveDisX;
|
|
par.MoveY = m_MoveDisY;
|
|
//操作模拟对象
|
|
OpSimulateObj(par);
|
|
|
|
XorRedrawOpSimulateObj(&dc);
|
|
|
|
//状态栏-----------------------------start
|
|
CString str1 = "移动距离[x 方向] [y 方向]";
|
|
CString str2;
|
|
str2.Format("%lf",m_MoveDisX);
|
|
CString str3;
|
|
str3.Format("%lf",m_MoveDisY);
|
|
GetFrame()->ResetStatusBarExtStr();
|
|
GetFrame()->SetStatusBarExtStr(str1,str2,str3);
|
|
//状态栏-----------------------------end
|
|
SavePreMovePt(point);
|
|
}
|
|
}
|
|
bool CMouseToolMove2::OnSetCmd(CString str)
|
|
{
|
|
if(m_Status==_STATUS_2)
|
|
{
|
|
double Val1=0;//x 距离
|
|
double Val2=0;//y 距离
|
|
int result = GetTwoNum(str,Val1,Val2);
|
|
if(result>0)
|
|
{
|
|
if(result == 2)//需要同时输入
|
|
{
|
|
m_MoveDisX = Val1;
|
|
m_MoveDisY = Val2;
|
|
OperateOver();
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|