|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "MouseToolLine.h"
|
|
|
|
|
#include "LogMgr.h"
|
|
|
|
|
#include "ObjPLine.h"
|
|
|
|
|
#include "GlobalFunction.h"
|
|
|
|
|
#include "GlobalDrawMgr.h"
|
|
|
|
|
CMouseToolLine::CMouseToolLine(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><>
|
|
|
|
|
}
|
|
|
|
|
CMouseToolLine::~CMouseToolLine(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
void CMouseToolLine::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 CMouseToolLine::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
|
|
|
|
|
{
|
|
|
|
|
//ÿ<><C3BF>һ<EFBFBD>´<EFBFBD><C2B4><EFBFBD>һ<EFBFBD><D2BB>ֱ<EFBFBD><D6B1>
|
|
|
|
|
Dbxy pt = gDraw->CPoint2Dbxy(point);
|
|
|
|
|
CreatOneLine(pt);
|
|
|
|
|
}
|
|
|
|
|
void CMouseToolLine::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void CMouseToolLine::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>ָ<EFBFBD><D6B8>
|
|
|
|
|
AddCreatCommand();
|
|
|
|
|
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
|
|
|
|
|
GetFrame()->ResetCaptionBar();
|
|
|
|
|
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
m_Status = _STATUS_END;
|
|
|
|
|
OperateOver();
|
|
|
|
|
}
|
|
|
|
|
void CMouseToolLine::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 CMouseToolLine::OnEscapeKey()
|
|
|
|
|
{
|
|
|
|
|
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>obj
|
|
|
|
|
m_TmpObjContainer.DeleteLastObj();
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|
|
|
|
AddCreatCommand();
|
|
|
|
|
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
|
|
|
|
|
GetFrame()->ResetCaptionBar();
|
|
|
|
|
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
|
|
|
|
|
m_Status = _STATUS_END;
|
|
|
|
|
OperateOver();
|
|
|
|
|
}
|
|
|
|
|
bool CMouseToolLine::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;
|
|
|
|
|
}
|