|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "MouseToolDelNode.h"
|
|
|
|
|
#include "GlobalDrawMgr.h"
|
|
|
|
|
#include "Layer.h"
|
|
|
|
|
#include "GlobalFunction.h"
|
|
|
|
|
#include "CommandDelNode.h"
|
|
|
|
|
#include "CommandMgr.h"
|
|
|
|
|
#include "LogMgr.h"
|
|
|
|
|
|
|
|
|
|
CMouseToolDelNode::CMouseToolDelNode(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
CMouseToolDelNode::~CMouseToolDelNode(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
void CMouseToolDelNode::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
|
|
|
|
|
{
|
|
|
|
|
Dbxy pt = gDraw->CPoint2Dbxy(point);
|
|
|
|
|
DbRect rect = gDraw->GetCurPointRect(pt);
|
|
|
|
|
|
|
|
|
|
CLayer &layer = gLayer;
|
|
|
|
|
if(!layer.HasObjectInRect(rect))
|
|
|
|
|
{
|
|
|
|
|
gLogMgr->WriteDebugLog("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD>Χ֮<EFBFBD><EFBFBD>",_LOG_ERROR);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>rect <20><>obj -----------------------------------------------
|
|
|
|
|
Sptr<CObjBase> pObj = layer.GetFirstObjInRect(rect);
|
|
|
|
|
if(pObj->GetPtCnt()<=2)//ֻɾ<D6BB><C9BE>3 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵĶ<CFB5><C4B6><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
gLogMgr->WriteDebugLog("ֻ<EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵĶ<EFBFBD><EFBFBD><EFBFBD>",_LOG_ERROR);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>obj <20><>rect <20>еĵ<D0B5>һ<EFBFBD><D2BB>node <20><>-----------------------------------------------
|
|
|
|
|
vector<DbLine> LineVec;
|
|
|
|
|
pObj->GetLineInRect(rect,LineVec,false);
|
|
|
|
|
|
|
|
|
|
if(LineVec.empty())
|
|
|
|
|
return;
|
|
|
|
|
Dbxy NodePt = LineVec[0].m_pt1.GetPt();
|
|
|
|
|
if(!IsPointInRect(NodePt,rect))
|
|
|
|
|
{
|
|
|
|
|
NodePt = LineVec[0].m_pt2.GetPt();
|
|
|
|
|
}
|
|
|
|
|
if(!IsPointInRect(NodePt,rect))
|
|
|
|
|
{
|
|
|
|
|
gLogMgr->WriteDebugLog("<EFBFBD>ڵ㲻<EFBFBD>ڷ<EFBFBD>Χ<EFBFBD><EFBFBD>",_LOG_ERROR);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>NodePt <20><>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int idx = pObj->GetNodePtIdx(NodePt);
|
|
|
|
|
if(idx!=-1 && idx!=0)
|
|
|
|
|
{
|
|
|
|
|
pObj->DelNodePtByIdx(idx);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>-----------------------------------
|
|
|
|
|
CCommandDelNode *p = new CCommandDelNode;
|
|
|
|
|
p->SetPar(idx,NodePt);
|
|
|
|
|
p->AddOpObj(pObj);
|
|
|
|
|
gCommandMgr.AddUndoCommand(p);
|
|
|
|
|
//ˢ<><CBA2>
|
|
|
|
|
GetCurViewPtr()->RefreshView();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|