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.

150 lines
4.4 KiB
C++

#include "StdAfx.h"
#include "MouseToolLine.h"
#include "LogMgr.h"
#include "ObjPLine.h"
#include "GlobalFunction.h"
#include "GlobalDrawMgr.h"
CMouseToolLine::CMouseToolLine(void)
{
//깃푯으-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_LINE_FIRST_PT);
GetFrame()->RefreashCaptionBar();
//깃푯으-------------------------end
m_Length = 0;//낀똑
m_Angle = 0;//360 실
}
CMouseToolLine::~CMouseToolLine(void)
{
}
void CMouseToolLine::CreatOneLine(Dbxy pt)
{
CObjPline *p = new CObjPline;
p->Creat(pt,pt);
AddObject(p);
//-------------------------------------------츱즈으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);
}
//-------------------------------------------츱즈으end
//깃푯으-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_LINE_NEXT_PT);
GetFrame()->RefreashCaptionBar();
//깃푯으-------------------------end
SaveDownPoint(pt);
}
void CMouseToolLine::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
{
//첼듐寧苟눼쉔寧係殮窟
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)
{
//꼰뇜
m_TmpObjContainer.XorDrawLastObj(&dc);
//<2F>뇜離빈寧몸obj
m_TmpObjContainer.DeleteLastObj();
//警속寧즈
AddCreatCommand();
//깃푯으-------------------------start
GetFrame()->ResetCaptionBar();
//깃푯으-------------------------end
//써監
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);//낀똑
m_Angle = Cal360AngleByTwoPt(m_DownPoint,pt);//360 실
//榴檄으-----------------------------start
CString str1 = "窟뙈[낀똑] [실똑]";
CString str2;
str2.Format("%lf",m_Length);
CString str3;
str3.Format("%lf",m_Angle);
GetFrame()->ResetStatusBarExtStr();
GetFrame()->SetStatusBarExtStr(str1,str2,str3);
//榴檄으-----------------------------end
}
}
}
void CMouseToolLine::OnEscapeKey()
{
//<2F>뇜離빈寧몸obj
m_TmpObjContainer.DeleteLastObj();
//警속寧즈
AddCreatCommand();
//깃푯으-------------------------start
GetFrame()->ResetCaptionBar();
//깃푯으-------------------------end
m_Status = _STATUS_END;
OperateOver();
}
bool CMouseToolLine::OnSetCmd(CString str)
{
if(m_Status==_STATUS_2)
{
double Val1=0;//낀똑
double Val2=0;//실똑
int result = GetTwoNum(str,Val1,Val2);
if(result>0)
{
if(result==1)//怜渴흙낀똑
{
Val2 = m_Angle;
}
if(Val1>0)//낀똑狼댕黨0
{
m_Length = Val1;
m_Angle = Val2;
//셕炬놔寧땍듐
Dbxy SetPoint = GetPoint2(m_DownPoint,Val1,_360ToAngle(Val2));
//邱겉뎠품돨窟뙈젯쌈돕侶몸듐<EBAAB8>
CObjBase *pCurOptObject = m_TmpObjContainer.GetCurOpObj();
if(pCurOptObject)
{
CObjPline *p = dynamic_cast<CObjPline*>(pCurOptObject);
p->Creat(m_DownPoint,SetPoint);
}
//疼鹿侶몸듐槨폅듐눼쉔劤窟뙈
CreatOneLine(SetPoint);
//퓻齡岬劤
GetCurViewPtr()->RefreshView();
return true;
}
}
}
return false;
}