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++
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)
|
|
{
|
|
//标签栏-------------------------start
|
|
GetFrame()->ResetCaptionBar();
|
|
GetFrame()->SetCaptionCmdStr(CMD_TOOL_COPY_BASE_PT);
|
|
GetFrame()->RefreashCaptionBar();
|
|
//标签栏-------------------------end
|
|
}
|
|
CMouseToolCopy::~CMouseToolCopy(void)
|
|
{
|
|
}
|
|
void CMouseToolCopy::OperateOver()
|
|
{
|
|
//obj 操作
|
|
SObjOperatePar par;
|
|
par.OpType = _OP_MOVE;
|
|
par.MoveX = m_MoveDisX;
|
|
par.MoveY = m_MoveDisY;
|
|
//只操作当前选择的obj
|
|
m_TmpObjContainer.OperateObj(par,true);
|
|
|
|
m_TmpObjContainer.DelSelObj();
|
|
m_TmpObjContainer.AllObjAddToLayer();
|
|
//创建撤销指令-------start
|
|
CCommandCopy *p = new CCommandCopy;
|
|
gCommandMgr.AddUndoCommand(p,m_TmpObjContainer.GetObjVec());
|
|
//创建撤销指令-------end
|
|
CMouseTool::OperateOver();
|
|
m_Status = _STATUS_END;
|
|
}
|
|
void CMouseToolCopy::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
|
|
{
|
|
Dbxy pt = gDraw->CPoint2Dbxy(point);
|
|
|
|
//obj 操作
|
|
SObjOperatePar par;
|
|
par.OpType = _OP_MOVE;
|
|
par.MoveX = m_MoveDisX;
|
|
par.MoveY = m_MoveDisY;
|
|
//只操作当前选择的obj
|
|
m_TmpObjContainer.OperateObj(par,true);
|
|
//克隆已选择的obj 到临时容器
|
|
//先把之前的置为非选择状态
|
|
m_TmpObjContainer.NotSelAllObj();
|
|
//再导入当前选择的obj
|
|
gLayer.CloneObj(m_TmpObjContainer,true);
|
|
if(m_Status==_STATUS_1)//指定基点
|
|
{
|
|
m_BasePoint = pt;
|
|
//创建模拟操作的对象
|
|
CreatOpSimulateObj();
|
|
ToNextStatus();
|
|
}
|
|
else
|
|
{
|
|
//移动到当前位置
|
|
m_MoveDisX = pt.x - m_BasePoint.x;
|
|
m_MoveDisY = pt.y - m_BasePoint.y;
|
|
//避免将第一个位置擦除
|
|
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)
|
|
{
|
|
//重绘模拟对象
|
|
XorRedrawOpSimulateObj(&dc);
|
|
}
|
|
m_bFirstMove = false;
|
|
|
|
if(HasPreMovePt())//擦除之前的线
|
|
{
|
|
XorDrawLine(&dc,gDraw->GetObjectPen(),m_BasePoint,OldPt);
|
|
}
|
|
XorDrawLine(&dc,gDraw->GetObjectPen(),m_BasePoint,CurPt);//绘制一条临时线
|
|
|
|
//计算移动距离
|
|
m_MoveDisX = CurPt.x - m_BasePoint.x;
|
|
m_MoveDisY = CurPt.y - m_BasePoint.y;
|
|
//obj 操作
|
|
SObjOperatePar par;
|
|
par.OpType = _OP_MOVE;
|
|
par.MoveX = m_MoveDisX;
|
|
par.MoveY = m_MoveDisY;
|
|
//操作模拟对象
|
|
OpSimulateObj(par);
|
|
|
|
//重绘模拟对象
|
|
XorRedrawOpSimulateObj(&dc);
|
|
SavePreMovePt(point);
|
|
}
|
|
}
|
|
void CMouseToolCopy::OnEscapeKey()
|
|
{
|
|
OperateOver();
|
|
}
|
|
bool CMouseToolCopy::OnSetCmd(CString str)
|
|
{
|
|
|
|
return false;
|
|
}
|
|
|