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.

145 lines
4.1 KiB
C++

#include "StdAfx.h"
#include "MouseToolRect.h"
#include "ObjPline.h"
#include "GlobalFunction.h"
#include "GlobalDrawMgr.h"
#include "LogMgr.h"
CMouseToolRect::CMouseToolRect(void)
{
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_RECT_FIRST_PT);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
m_Width = 0;
m_Hight = 0;
}
CMouseToolRect::~CMouseToolRect(void)
{
}
void CMouseToolRect::OperateOver()
{
//------------------------------------<2D><>־start
CString val1;
val1.Format("%lf",m_Width);
CString val2;
val2.Format("%lf",m_Hight);
gLogMgr->WriteCmd(CMD_RECT_SIZE,val1,val2);
//------------------------------------<2D><>־end
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
AddCreatCommand();
//<2F><><EFBFBD><EFBFBD>
m_Status = _STATUS_END;
CMouseTool::OperateOver();
}
void CMouseToolRect::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
{
Dbxy pt = gDraw->CPoint2Dbxy(point);
if(m_Status==_STATUS_1)
{
SaveDownPoint(point);
CObjPline *p = new CObjPline;
p->Creat(pt,m_Width,m_Hight);
AddObject(p);
//------------------------------------<2D><>־start
CString val1;
val1.Format("%lf",pt.x);
CString val2;
val2.Format("%lf",pt.y);
gLogMgr->WriteCmd(CMD_RECT_FIRST_PT,val1,val2);
//------------------------------------<2D><>־end
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_RECT_SIZE);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
ToNextStatus();
}
else
{
OperateOver();
}
}
void CMouseToolRect::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
{
}
void CMouseToolRect::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_Width = pt.x-m_DownPoint.x;
m_Hight = pt.y-m_DownPoint.y;
m_TmpObjContainer.XorRedrawObj(&dc,false);
p->Creat(m_DownPoint,m_Width,m_Hight);
m_TmpObjContainer.XorRedrawObj(&dc,false);
//״̬<D7B4><CCAC>-----------------------------start
CString str1 = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>[<5B><><EFBFBD><EFBFBD>] [<5B>߶<EFBFBD>]";
CString str2;
str2.Format("%lf",m_Width);
CString str3;
str3.Format("%lf",m_Hight);
GetFrame()->ResetStatusBarExtStr();
GetFrame()->SetStatusBarExtStr(str1,str2,str3);
//״̬<D7B4><CCAC>-----------------------------end
}
}
}
bool CMouseToolRect::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 == 2 && Val1>0 && Val2>0)//<2F><><EFBFBD>ȸ߶<C8B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>0 ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫͬʱ<CDAC><CAB1><EFBFBD><EFBFBD>
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
if(m_Width<0)
{
m_Width = Val1*(-1);
}
else
{
m_Width = Val1;
}
if(m_Hight<0)
{
m_Hight = Val2*(-1);
}
else
{
m_Hight = Val2;
}
CObjBase *pCurOptObject = m_TmpObjContainer.GetCurOpObj();
if(pCurOptObject)
{
CObjPline *p = dynamic_cast<CObjPline*>(pCurOptObject);
p->Creat(m_DownPoint,m_Width,m_Hight);
}
OperateOver();
return true;
}
}
}
return false;
}