|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "MouseTool.h"
|
|
|
|
|
#include "GlobalDrawMgr.h"
|
|
|
|
|
#include "GlobalFunction.h"
|
|
|
|
|
#include "CommandCreat.h"
|
|
|
|
|
#include "CommandMgr.h"
|
|
|
|
|
#include "GlobalDrawMgr.h"
|
|
|
|
|
|
|
|
|
|
CMouseTool::CMouseTool(void)
|
|
|
|
|
{
|
|
|
|
|
m_Status = _STATUS_1;//<2F><>ʼΪ<CABC><CEAA>һ<EFBFBD><D2BB>
|
|
|
|
|
ClearFirstPoint();
|
|
|
|
|
m_bFirstMove = true;//<2F><><EFBFBD>ڱ<EFBFBD><DAB1>ǵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
CMouseTool::~CMouseTool(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
void CMouseTool::AddObject(CObjBase *p)
|
|
|
|
|
{
|
|
|
|
|
Sptr<CObjBase> sPtr(p);
|
|
|
|
|
m_TmpObjContainer.AddObject(sPtr);
|
|
|
|
|
gLayer.AddTmpObject(sPtr);
|
|
|
|
|
}
|
|
|
|
|
void CMouseTool::SaveDownPoint(CPoint point)
|
|
|
|
|
{
|
|
|
|
|
SaveDownPoint(gDraw->CPoint2Dbxy(point));
|
|
|
|
|
}
|
|
|
|
|
void CMouseTool::SaveDownPoint(Dbxy point)
|
|
|
|
|
{
|
|
|
|
|
m_DownPoint = point;
|
|
|
|
|
}
|
|
|
|
|
bool CMouseTool::HasPreMovePt()
|
|
|
|
|
{
|
|
|
|
|
if(m_PreMovePt.x == 0 && m_PreMovePt.y == 0)
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
void CMouseTool::ClearFirstPoint()
|
|
|
|
|
{
|
|
|
|
|
m_DownPoint.x = 0;
|
|
|
|
|
m_DownPoint.y = 0;
|
|
|
|
|
m_PreMovePt.x = 0;
|
|
|
|
|
m_PreMovePt.y = 0;
|
|
|
|
|
}
|
|
|
|
|
void CMouseTool::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
|
|
|
|
|
{
|
|
|
|
|
//<2F>DZ༭ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>
|
|
|
|
|
if(!gDraw->IsbObjEditMode())
|
|
|
|
|
return;
|
|
|
|
|
SaveDownPoint(point);
|
|
|
|
|
}
|
|
|
|
|
void CMouseTool::OnRButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
|
|
|
|
|
{
|
|
|
|
|
GetCurViewPtr()->OnEscape();
|
|
|
|
|
}
|
|
|
|
|
void CMouseTool::OperateOver()
|
|
|
|
|
{
|
|
|
|
|
ClearFirstPoint();
|
|
|
|
|
m_bFirstMove = true;
|
|
|
|
|
//ɾ<><C9BE>layer <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>-----------------------------------
|
|
|
|
|
gLayer.ClearTmpObj();
|
|
|
|
|
}
|
|
|
|
|
void CMouseTool::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
|
|
|
|
|
{
|
|
|
|
|
OperateOver();
|
|
|
|
|
}
|
|
|
|
|
void CMouseTool::AddCreatCommand()
|
|
|
|
|
{
|
|
|
|
|
if(!m_TmpObjContainer.Empty())
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>-------start
|
|
|
|
|
CCommandCreat *p = new CCommandCreat;
|
|
|
|
|
gCommandMgr.AddUndoCommand(p,m_TmpObjContainer.GetObjVec());
|
|
|
|
|
p->Excute();
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>-------end
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|
|
|
|
m_TmpObjContainer.Clear();
|
|
|
|
|
}
|
|
|
|
|
void CMouseTool::OnEscapeKey()
|
|
|
|
|
{
|
|
|
|
|
m_TmpObjContainer.Clear();
|
|
|
|
|
OperateOver();
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>״̬
|
|
|
|
|
void CMouseTool::ToNextStatus()
|
|
|
|
|
{
|
|
|
|
|
switch(m_Status)
|
|
|
|
|
{
|
|
|
|
|
case _STATUS_1:
|
|
|
|
|
m_Status = _STATUS_2;
|
|
|
|
|
break;
|
|
|
|
|
case _STATUS_2:
|
|
|
|
|
m_Status = _STATUS_3;
|
|
|
|
|
break;
|
|
|
|
|
case _STATUS_3:
|
|
|
|
|
m_Status = _STATUS_4;
|
|
|
|
|
break;
|
|
|
|
|
case _STATUS_4:
|
|
|
|
|
m_Status = _STATUS_5;
|
|
|
|
|
break;
|
|
|
|
|
case _STATUS_5:
|
|
|
|
|
m_Status = _STATUS_6;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bool CMouseTool::IsEndStatus()
|
|
|
|
|
{
|
|
|
|
|
return (m_Status ==_STATUS_END);
|
|
|
|
|
}
|
|
|
|
|
bool CMouseTool::IsStartStatus()
|
|
|
|
|
{
|
|
|
|
|
return (m_Status ==_STATUS_1);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|
|
|
|
void CMouseTool::CreatOpSimulateObj()
|
|
|
|
|
{
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1>ѡ<EFBFBD><D1A1>obj <20>ľ<EFBFBD><C4BE><EFBFBD>
|
|
|
|
|
DbRect rect = gLayer.GetSelObjRect();
|
|
|
|
|
m_OpSimulateObjBak.CreatRect(rect);
|
|
|
|
|
}
|
|
|
|
|
//<2F>ػ<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CMouseTool::XorRedrawOpSimulateObj(CDC* pDC)
|
|
|
|
|
{
|
|
|
|
|
int old_rop = pDC->SetROP2(R2_XORPEN);
|
|
|
|
|
m_OpSimulateObj.Draw(pDC,gDraw->GetSelObjectPen());
|
|
|
|
|
pDC->SetROP2(old_rop);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CMouseTool::OpSimulateObj(SObjOperatePar &par)
|
|
|
|
|
{
|
|
|
|
|
//ÿ<>ζ<EFBFBD><CEB6>ӱ<EFBFBD><D3B1>ݶ<EFBFBD><DDB6><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_OpSimulateObj.DelAllPt();
|
|
|
|
|
m_OpSimulateObj.CopyPt(m_OpSimulateObjBak);
|
|
|
|
|
m_OpSimulateObj.Operate(par);
|
|
|
|
|
}
|