|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "MouseToolAddNode.h"
|
|
|
|
|
#include "GlobalDrawMgr.h"
|
|
|
|
|
#include "Layer.h"
|
|
|
|
|
#include "GlobalFunction.h"
|
|
|
|
|
#include "CommandAddNode.h"
|
|
|
|
|
#include "CommandMgr.h"
|
|
|
|
|
|
|
|
|
|
CMouseToolAddNode::CMouseToolAddNode(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
CMouseToolAddNode::~CMouseToolAddNode(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
void CMouseToolAddNode::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
|
|
|
|
|
{
|
|
|
|
|
Dbxy pt = gDraw->CPoint2Dbxy(point);
|
|
|
|
|
DbRect rect = gDraw->GetCurPointRect(pt);
|
|
|
|
|
|
|
|
|
|
CLayer &layer = gLayer;
|
|
|
|
|
if(!layer.HasObjectInRect(rect))
|
|
|
|
|
return;
|
|
|
|
|
//<2F><><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>rect <20><>obj -----------------------------------------------
|
|
|
|
|
Sptr<CObjBase> pObj = layer.GetFirstObjInRect(rect);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>obj <20><>rect <20>еĵ<D0B5>һ<EFBFBD><D2BB><EFBFBD>߶<EFBFBD>-----------------------------------------------
|
|
|
|
|
vector<DbLine> LineVec;
|
|
|
|
|
pObj->GetLineInRect(rect,LineVec,false);
|
|
|
|
|
Dbxy LinePt1 = LineVec[0].m_pt1.GetPt();
|
|
|
|
|
Dbxy LinePt2 = LineVec[0].m_pt2.GetPt();
|
|
|
|
|
|
|
|
|
|
if(IsPointInRect(LinePt1,rect)||IsPointInRect(LinePt2,rect))//<2F><>Ҫ<EFBFBD>ڶ˵㸽<CBB5><E3B8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>rect <20>߶εĽ<CEB5><C4BD><EFBFBD>--------------------------------------------------
|
|
|
|
|
Dbxy MousePt = IntersectionOfRectAndLine(LinePt1,LinePt2,rect);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>LinePt1 <20><>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int idx = pObj->GetNodePtIdx(LinePt1);
|
|
|
|
|
if(idx!=-1)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD>뵽LinePt1 <20><><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>-------------------------
|
|
|
|
|
pObj->InsertNode(idx+1,MousePt);
|
|
|
|
|
pObj->SetSelected(true);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>-----------------------------------
|
|
|
|
|
CCommandAddNode *p = new CCommandAddNode;
|
|
|
|
|
p->SetPar(idx+1,MousePt);
|
|
|
|
|
p->AddOpObj(pObj);
|
|
|
|
|
gCommandMgr.AddUndoCommand(p);
|
|
|
|
|
//ˢ<><CBA2>
|
|
|
|
|
GetCurViewPtr()->RefreshView();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|