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.

183 lines
5.2 KiB
C++

#include "StdAfx.h"
#include "MouseToolPline.h"
#include "LogMgr.h"
#include "ObjPLine.h"
#include "GlobalFunction.h"
#include "GlobalDrawMgr.h"
CMouseToolPline::CMouseToolPline(void)
{
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_LINE_FIRST_PT);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
m_Length = 0;//<2F><><EFBFBD><EFBFBD>
m_Angle = 0;//360 <20><>
}
CMouseToolPline::~CMouseToolPline(void)
{
}
void CMouseToolPline::CreatOneLine(Dbxy pt)
{
CObjPline *p = new CObjPline;
p->Creat(pt,pt);
AddObject(p);
//-------------------------------------------<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>start
if(m_Status==_STATUS_1)
{
CString val1;
val1.Format("%lf",pt.x);
CString val2;
val2.Format("%lf",pt.y);
gLogMgr->WriteCmd(CMD_LINE_FIRST_PT,val1,val2);
ToNextStatus();
}
else
{
CString val1;
val1.Format("%lf",m_Length);
CString val2;
val2.Format("%lf",m_Angle);
gLogMgr->WriteCmd(CMD_LINE_NEXT_PT,val1,val2);
}
//-------------------------------------------<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>end
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_LINE_NEXT_PT);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
SaveDownPoint(pt);
}
void CMouseToolPline::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
{
//ÿ<><C3BF>һ<EFBFBD>´<EFBFBD><C2B4><EFBFBD>һ<EFBFBD><D2BB>ֱ<EFBFBD><D6B1>
Dbxy pt = gDraw->CPoint2Dbxy(point);
CreatOneLine(pt);
}
void CMouseToolPline::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
{
}
void CMouseToolPline::OnRButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
{
//<2F><><EFBFBD><EFBFBD>
m_TmpObjContainer.XorDrawLastObj(&dc);
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>obj
m_TmpObjContainer.DeleteLastObj();
//<2F><><EFBFBD>е<EFBFBD>line <20><><EFBFBD>ϳ<EFBFBD>pline
AlllineCombToPline();
//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
AddCreatCommand();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
//<2F><><EFBFBD><EFBFBD>
m_Status = _STATUS_END;
OperateOver();
}
void CMouseToolPline::OnMouseMove(UINT nFlag, CPoint point,CClientDC &dc)
{
Dbxy pt = gDraw->CPoint2Dbxy(point);
if(m_Status!=_STATUS_1)
{
CObjBase *pCurOptObject = m_TmpObjContainer.GetCurOpObj();
if(pCurOptObject)
{
CObjPline *p = dynamic_cast<CObjPline*>(pCurOptObject);
m_TmpObjContainer.XorDrawLastObj(&dc);
p->Creat(m_DownPoint,pt);
m_TmpObjContainer.XorDrawLastObj(&dc);
m_Length = CalDistance(m_DownPoint,pt);//<2F><><EFBFBD><EFBFBD>
m_Angle = Cal360AngleByTwoPt(m_DownPoint,pt);//360 <20><>
//״̬<D7B4><CCAC>-----------------------------start
CString str1 = "<EFBFBD>߶<EFBFBD>[<5B><><EFBFBD><EFBFBD>] [<5B>Ƕ<EFBFBD>]";
CString str2;
str2.Format("%lf",m_Length);
CString str3;
str3.Format("%lf",m_Angle);
GetFrame()->ResetStatusBarExtStr();
GetFrame()->SetStatusBarExtStr(str1,str2,str3);
//״̬<D7B4><CCAC>-----------------------------end
}
}
}
void CMouseToolPline::OnEscapeKey()
{
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>obj
m_TmpObjContainer.DeleteLastObj();
//<2F><><EFBFBD>е<EFBFBD>line <20><><EFBFBD>ϳ<EFBFBD>pline
AlllineCombToPline();
//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
AddCreatCommand();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
m_Status = _STATUS_END;
OperateOver();
}
bool CMouseToolPline::OnSetCmd(CString str)
{
if(m_Status==_STATUS_2)
{
double Val1=0;//<2F><><EFBFBD><EFBFBD>
double Val2=0;//<2F>Ƕ<EFBFBD>
int result = GetTwoNum(str,Val1,Val2);
if(result>0)
{
if(result==1)//ֻ<><D6BB><EFBFBD><EFBFBD><EBB3A4>
{
Val2 = m_Angle;
}
if(Val1>0)//<2F><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>0
{
m_Length = Val1;
m_Angle = Val2;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>
Dbxy SetPoint = GetPoint2(m_DownPoint,Val1,_360ToAngle(Val2));
//<2F>Ȱѵ<C8B0>ǰ<EFBFBD><C7B0><EFBFBD>߶<EFBFBD><DFB6><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CObjBase *pCurOptObject = m_TmpObjContainer.GetCurOpObj();
if(pCurOptObject)
{
CObjPline *p = dynamic_cast<CObjPline*>(pCurOptObject);
p->Creat(m_DownPoint,SetPoint);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><E3B4B4><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD>
CreatOneLine(SetPoint);
//ǿ<><C7BF>ˢ<EFBFBD><CBA2>
GetCurViewPtr()->RefreshView();
return true;
}
}
}
return false;
}
//<2F><><EFBFBD>е<EFBFBD>line <20><><EFBFBD>ϳ<EFBFBD>pline
void CMouseToolPline::AlllineCombToPline()
{
if(m_TmpObjContainer.Empty())
return;
CObjPline *p = NULL;
vector<Sptr<CObjBase>> &vec = m_TmpObjContainer.GetObjVec();
int size = vec.size();
for(int i=0;i<size;i++)
{
if(i==0)
{
p = new CObjPline;
p->Creat(vec[0]->GetFirstPt(),vec[0]->GetLastPt());
}
else
{
CDataPoint DataPoint(vec[i]->GetLastPt());
DataPoint.SetIsNode(true);
p->AddDataPoint(DataPoint);
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶ε<DFB6><CEB5>м<EFBFBD><D0BC><EFBFBD>Ϊ<EFBFBD><CEAA>׽<EFBFBD><D7BD>
p->CreatMidNode();
m_TmpObjContainer.Clear();
AddObject(p);
}