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.
124 lines
3.4 KiB
C++
124 lines
3.4 KiB
C++
#include "StdAfx.h"
|
|
#include "MouseToolStretch.h"
|
|
#include "EnumDirection.h"
|
|
#include "EasyOperationMgr.h"
|
|
#include "GlobalDrawMgr.h"
|
|
#include "GlobalFunction.h"
|
|
#include "CommandStretch.h"
|
|
#include "CommandMgr.h"
|
|
|
|
CMouseToolStretch::CMouseToolStretch(void)
|
|
{
|
|
}
|
|
CMouseToolStretch::~CMouseToolStretch(void)
|
|
{
|
|
}
|
|
void CMouseToolStretch::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
|
|
{
|
|
if(m_Status==_STATUS_1)
|
|
{
|
|
SaveDownPoint(point);
|
|
//创建模拟操作的对象
|
|
CreatOpSimulateObj();
|
|
ToNextStatus();
|
|
}
|
|
}
|
|
void CMouseToolStretch::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
|
|
{
|
|
//创建undo 用的指令-----start
|
|
CCommandStretch *pCmd = new CCommandStretch;
|
|
|
|
//obj 操作
|
|
DIRECTION dir = gEasyOperationMgr->GetOprDir();
|
|
if(dir == _DIR_L || dir == _DIR_R)
|
|
{
|
|
pCmd->SetOperatePar(m_ParX);
|
|
}
|
|
else if(dir == _DIR_U || dir == _DIR_D)
|
|
{
|
|
pCmd->SetOperatePar(m_ParY);
|
|
}
|
|
else
|
|
{
|
|
pCmd->SetOperatePar(m_ParX);
|
|
pCmd->SetOperateParY(m_ParY);
|
|
}
|
|
gCommandMgr.AddUndoCommand(pCmd);
|
|
//创建undo 用的指令-----end
|
|
pCmd->Excute();
|
|
|
|
OperateOver();
|
|
m_Status = _STATUS_END;
|
|
}
|
|
void CMouseToolStretch::OperateObj(Dbxy StartPt,Dbxy EndPt)
|
|
{
|
|
m_OpSimulateObj.DelAllPt();
|
|
m_OpSimulateObj.CopyPt(m_OpSimulateObjBak);
|
|
//obj 操作
|
|
DIRECTION dir = gEasyOperationMgr->GetOprDir();
|
|
//保持比例
|
|
if(dir == _DIR_LB || dir == _DIR_RB || dir == _DIR_LT || dir == _DIR_RT)
|
|
{
|
|
if(abs(EndPt.x - StartPt.x)<abs(EndPt.y - StartPt.y))
|
|
{
|
|
if(EndPt.y>StartPt.y)
|
|
{
|
|
EndPt.y = StartPt.y + abs(EndPt.x - StartPt.x);
|
|
}
|
|
else
|
|
{
|
|
EndPt.y = StartPt.y - abs(EndPt.x - StartPt.x);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(EndPt.x>StartPt.x)
|
|
{
|
|
EndPt.x = StartPt.x + abs(EndPt.y - StartPt.y);
|
|
}
|
|
else
|
|
{
|
|
EndPt.x = StartPt.x - abs(EndPt.y - StartPt.y);
|
|
}
|
|
}
|
|
}
|
|
|
|
if(dir != _DIR_U && dir != _DIR_D)
|
|
{
|
|
m_ParX.OpType = _OP_STRETCH;
|
|
m_ParX.BasePt = gEasyOperationMgr->GetBasePt();
|
|
m_ParX.OldSize = gEasyOperationMgr->GetSize(_X);
|
|
m_ParX.Diff = gEasyOperationMgr->GetDiff(StartPt,EndPt).x;
|
|
m_ParX.NewSize = m_ParX.OldSize + m_ParX.Diff;
|
|
m_ParX.xy = _X;
|
|
//操作模拟对象
|
|
m_OpSimulateObj.Operate(m_ParX);
|
|
}
|
|
if(dir != _DIR_L && dir != _DIR_R)
|
|
{
|
|
m_ParY.OpType = _OP_STRETCH;
|
|
m_ParY.BasePt = gEasyOperationMgr->GetBasePt();
|
|
m_ParY.OldSize = gEasyOperationMgr->GetSize(_Y);
|
|
m_ParY.Diff = gEasyOperationMgr->GetDiff(StartPt,EndPt).y;
|
|
m_ParY.NewSize = m_ParY.OldSize + m_ParY.Diff;
|
|
m_ParY.xy = _Y;
|
|
//操作模拟对象
|
|
m_OpSimulateObj.Operate(m_ParY);
|
|
}
|
|
}
|
|
void CMouseToolStretch::OnMouseMove(UINT nFlags, CPoint point,CClientDC &dc)
|
|
{
|
|
Dbxy CurPt = gDraw->CPoint2Dbxy(point);
|
|
CLayer &layer = gLayer;
|
|
if(nFlags&MK_LBUTTON && (m_Status!=_STATUS_1))
|
|
{
|
|
if(m_bFirstMove==false)
|
|
{
|
|
//重绘模拟对象
|
|
XorRedrawOpSimulateObj(&dc);
|
|
}
|
|
m_bFirstMove = false;
|
|
OperateObj(m_DownPoint,CurPt);//操作
|
|
XorRedrawOpSimulateObj(&dc);
|
|
}
|
|
} |