|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "MouseToolMoveNode.h"
|
|
|
|
|
#include "GlobalDrawMgr.h"
|
|
|
|
|
#include "GlobalFunction.h"
|
|
|
|
|
#include "CommandMoveNode.h"
|
|
|
|
|
#include "CommandMgr.h"
|
|
|
|
|
|
|
|
|
|
CMouseToolMoveNode::CMouseToolMoveNode(void)
|
|
|
|
|
{
|
|
|
|
|
m_NodeIdx = -1;
|
|
|
|
|
}
|
|
|
|
|
CMouseToolMoveNode::~CMouseToolMoveNode(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
void CMouseToolMoveNode::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
|
|
|
|
|
{
|
|
|
|
|
if(m_Status==_STATUS_1)
|
|
|
|
|
{
|
|
|
|
|
Dbxy pt = gDraw->CPoint2Dbxy(point);
|
|
|
|
|
DbRect rect = gDraw->GetCurPointRect(pt);
|
|
|
|
|
|
|
|
|
|
CLayer &layer = gLayer;
|
|
|
|
|
if(!layer.HasSelNodeInRect(rect))
|
|
|
|
|
return;
|
|
|
|
|
//<2F><><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>rect <20><>obj -----------------------------------------------
|
|
|
|
|
Sptr<CObjBase> pObj = layer.GetFirstNodeObjInRect(rect);
|
|
|
|
|
m_TmpObjContainer.AddObject(pObj);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>obj <20><>rect <20>еĵ<D0B5>һ<EFBFBD><D2BB>node <20><>-----------------------------------------------
|
|
|
|
|
vector<DbLine> LineVec;
|
|
|
|
|
pObj->GetLineInRect(rect,LineVec,false);
|
|
|
|
|
Dbxy NodePt = LineVec[0].m_pt1.GetPt();
|
|
|
|
|
if(!IsPointInRect(NodePt,rect))
|
|
|
|
|
{
|
|
|
|
|
NodePt = LineVec[0].m_pt2.GetPt();
|
|
|
|
|
}
|
|
|
|
|
if(!IsPointInRect(NodePt,rect))
|
|
|
|
|
return;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>NodePt <20><>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_NodeIdx = pObj->GetNodePtIdx(NodePt);
|
|
|
|
|
if(m_NodeIdx!=-1)
|
|
|
|
|
{
|
|
|
|
|
//<2F><>¼<EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_OldPt = NodePt;
|
|
|
|
|
ToNextStatus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CMouseToolMoveNode::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
|
|
|
|
|
{
|
|
|
|
|
if(!m_TmpObjContainer.Empty())
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>-------start
|
|
|
|
|
CCommandMoveNode *p = new CCommandMoveNode;
|
|
|
|
|
p->SetPar(m_NodeIdx,m_OldPt,m_NewPt);
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
OperateOver();
|
|
|
|
|
m_Status = _STATUS_END;
|
|
|
|
|
}
|
|
|
|
|
void CMouseToolMoveNode::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)
|
|
|
|
|
{
|
|
|
|
|
layer.XorRedrawObj(&dc);//<2F><><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0>
|
|
|
|
|
}
|
|
|
|
|
m_bFirstMove = false;
|
|
|
|
|
m_TmpObjContainer.SetNodePtByIdx(m_NodeIdx,CurPt);
|
|
|
|
|
//<2F><>¼<EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_NewPt = CurPt;
|
|
|
|
|
|
|
|
|
|
layer.XorRedrawObj(&dc);//<2F>ػ<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|