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.
85 lines
2.4 KiB
C++
85 lines
2.4 KiB
C++
#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;
|
|
//先找到第一个在rect 的obj -----------------------------------------------
|
|
Sptr<CObjBase> pObj = layer.GetFirstNodeObjInRect(rect);
|
|
m_TmpObjContainer.AddObject(pObj);
|
|
//获得obj 在rect 中的第一个node 点-----------------------------------------------
|
|
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;
|
|
//获得NodePt 在obj 的序号
|
|
m_NodeIdx = pObj->GetNodePtIdx(NodePt);
|
|
if(m_NodeIdx!=-1)
|
|
{
|
|
//记录旧的坐标
|
|
m_OldPt = NodePt;
|
|
ToNextStatus();
|
|
}
|
|
|
|
}
|
|
}
|
|
void CMouseToolMoveNode::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
|
|
{
|
|
if(!m_TmpObjContainer.Empty())
|
|
{
|
|
//创建撤销指令-------start
|
|
CCommandMoveNode *p = new CCommandMoveNode;
|
|
p->SetPar(m_NodeIdx,m_OldPt,m_NewPt);
|
|
gCommandMgr.AddUndoCommand(p,m_TmpObjContainer.GetObjVec());
|
|
p->Excute();
|
|
//创建撤销指令-------end
|
|
}
|
|
//清空临时容器
|
|
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);//擦除之前的
|
|
}
|
|
m_bFirstMove = false;
|
|
m_TmpObjContainer.SetNodePtByIdx(m_NodeIdx,CurPt);
|
|
//记录新的坐标
|
|
m_NewPt = CurPt;
|
|
|
|
layer.XorRedrawObj(&dc);//重绘
|
|
}
|
|
}
|
|
|