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++
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)
|
|
{
|
|
//标签栏-------------------------start
|
|
GetFrame()->ResetCaptionBar();
|
|
GetFrame()->SetCaptionCmdStr(CMD_RECT_FIRST_PT);
|
|
GetFrame()->RefreashCaptionBar();
|
|
//标签栏-------------------------end
|
|
m_Width = 0;
|
|
m_Hight = 0;
|
|
}
|
|
CMouseToolRect::~CMouseToolRect(void)
|
|
{
|
|
}
|
|
void CMouseToolRect::OperateOver()
|
|
{
|
|
//------------------------------------日志start
|
|
CString val1;
|
|
val1.Format("%lf",m_Width);
|
|
CString val2;
|
|
val2.Format("%lf",m_Hight);
|
|
gLogMgr->WriteCmd(CMD_RECT_SIZE,val1,val2);
|
|
//------------------------------------日志end
|
|
//标签栏-------------------------start
|
|
GetFrame()->ResetCaptionBar();
|
|
//标签栏-------------------------end
|
|
//添加指令
|
|
AddCreatCommand();
|
|
//结束
|
|
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);
|
|
p->SetbOffsetAreaRect(true);//设置为偏移调整区域对象
|
|
AddObject(p);
|
|
//------------------------------------日志start
|
|
CString val1;
|
|
val1.Format("%lf",pt.x);
|
|
CString val2;
|
|
val2.Format("%lf",pt.y);
|
|
gLogMgr->WriteCmd(CMD_RECT_FIRST_PT,val1,val2);
|
|
//------------------------------------日志end
|
|
//标签栏-------------------------start
|
|
GetFrame()->ResetCaptionBar();
|
|
GetFrame()->SetCaptionCmdStr(CMD_RECT_SIZE);
|
|
GetFrame()->RefreashCaptionBar();
|
|
//标签栏-------------------------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);
|
|
|
|
//状态栏-----------------------------start
|
|
CString str1 = "矩形[宽度] [高度]";
|
|
CString str2;
|
|
str2.Format("%lf",m_Width);
|
|
CString str3;
|
|
str3.Format("%lf",m_Hight);
|
|
GetFrame()->ResetStatusBarExtStr();
|
|
GetFrame()->SetStatusBarExtStr(str1,str2,str3);
|
|
//状态栏-----------------------------end
|
|
}
|
|
}
|
|
}
|
|
bool CMouseToolRect::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 == 2 && Val1>0 && Val2>0)//宽度高度要大于0 ,而且需要同时输入
|
|
{
|
|
//根据鼠标的位置来判断
|
|
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;
|
|
}
|
|
|