|
|
|
|
#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);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|
|
|
|
CreatOpSimulateObj();
|
|
|
|
|
ToNextStatus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CMouseToolStretch::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>undo <20>õ<EFBFBD>ָ<EFBFBD><D6B8>-----start
|
|
|
|
|
CCommandStretch *pCmd = new CCommandStretch;
|
|
|
|
|
|
|
|
|
|
//obj <20><><EFBFBD><EFBFBD>
|
|
|
|
|
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);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>undo <20>õ<EFBFBD>ָ<EFBFBD><D6B8>-----end
|
|
|
|
|
pCmd->Excute();
|
|
|
|
|
|
|
|
|
|
OperateOver();
|
|
|
|
|
m_Status = _STATUS_END;
|
|
|
|
|
}
|
|
|
|
|
void CMouseToolStretch::OperateObj(Dbxy StartPt,Dbxy EndPt)
|
|
|
|
|
{
|
|
|
|
|
m_OpSimulateObj.DelAllPt();
|
|
|
|
|
m_OpSimulateObj.CopyPt(m_OpSimulateObjBak);
|
|
|
|
|
//obj <20><><EFBFBD><EFBFBD>
|
|
|
|
|
DIRECTION dir = gEasyOperationMgr->GetOprDir();
|
|
|
|
|
//<2F><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
|
|
|
|
|
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;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
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;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
//<2F>ػ<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
XorRedrawOpSimulateObj(&dc);
|
|
|
|
|
}
|
|
|
|
|
m_bFirstMove = false;
|
|
|
|
|
OperateObj(m_DownPoint,CurPt);//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
XorRedrawOpSimulateObj(&dc);
|
|
|
|
|
}
|
|
|
|
|
}
|