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.

152 lines
4.6 KiB
C++

#include "StdAfx.h"
#include "MouseToolCircle.h"
#include "GlobalFunction.h"
#include "GlobalDrawMgr.h"
#include "ObjCircle.h"
#include "LogMgr.h"
#include "DrawSimpleShape.h"
#include "ObjArc.h"
#define DEFUALT_EDGE_CNT 100//Բ<><D4B2>Ĭ<EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD>
CMouseToolCircle::CMouseToolCircle(void)
{
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_TOOL_CIRCLE_CENTER);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
m_Radius = 0;
m_EdgeCnt = DEFUALT_EDGE_CNT;
}
CMouseToolCircle::~CMouseToolCircle(void)
{
}
void CMouseToolCircle::OperateOver()
{
//------------------------------------<2D><>־start
CString val1;
val1.Format("%lf",m_Radius*2);
CString val2;
val2.Format("%ld",m_EdgeCnt);
gLogMgr->WriteCmd(CMD_TOOL_CIRCLE_DIA_EDGE,val1,val2);
//------------------------------------<2D><>־end
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
AddCreatCommand();
//<2F><><EFBFBD><EFBFBD>
m_Status = _STATUS_END;
CMouseTool::OperateOver();
}
void CMouseToolCircle::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
{
Dbxy pt = gDraw->CPoint2Dbxy(point);
if(m_Status==_STATUS_1)
{
SaveDownPoint(point);
CObjCircle *pCircle = new CObjCircle;
CCirclePar ObjCirclePar;
ObjCirclePar.CenterPt = pt;
ObjCirclePar.Radius =m_Radius;
pCircle->Creat(ObjCirclePar);
AddObject(pCircle);
//------------------------------------<2D><>־start
CString val1;
val1.Format("%lf",pt.x);
CString val2;
val2.Format("%lf",pt.y);
gLogMgr->WriteCmd(CMD_TOOL_CIRCLE_CENTER,val1,val2);
//------------------------------------<2D><>־end
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_TOOL_CIRCLE_DIA_EDGE);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>״̬
ToNextStatus();
}
else
{
OperateOver();
}
}
void CMouseToolCircle::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
{
}
void CMouseToolCircle::OnMouseMove(UINT nFlag, CPoint point,CClientDC &dc)
{
Dbxy OldPt = gDraw->CPoint2Dbxy(m_PreMovePt);
Dbxy pt = gDraw->CPoint2Dbxy(point);
if(m_Status!=_STATUS_1)
{
m_Radius = CalDistance(m_DownPoint,pt);
CObjBase *pCurOptObject = m_TmpObjContainer.GetCurOpObj();
if(pCurOptObject)
{
CObjCircle *p = dynamic_cast<CObjCircle*>(pCurOptObject);
m_TmpObjContainer.XorRedrawObj(&dc,false);
CCirclePar ObjCirclePar;
ObjCirclePar.CenterPt = m_DownPoint;
ObjCirclePar.Radius =m_Radius;
ObjCirclePar.DEdgeCnt = m_EdgeCnt;
p->Creat(ObjCirclePar);
m_TmpObjContainer.XorRedrawObj(&dc,false);
//״̬<D7B4><CCAC>-----------------------------start
CString str1 = "Բ[ֱ<><D6B1>] ";
CString str2;
str2.Format("%lf",m_Radius*2);
GetFrame()->ResetStatusBarExtStr();
GetFrame()->SetStatusBarExtStr(str1,str2,STR_NULL);
//״̬<D7B4><CCAC>-----------------------------end
}
SavePreMovePt(point);
}
}
bool CMouseToolCircle::OnSetCmd(CString str)
{
if(m_Status==_STATUS_2)//<2F><><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2>
{
double Val1=0;//<2F>
double Val2=0;//<2F><><EFBFBD><EFBFBD>
int result = GetTwoNum(str,Val1,Val2);
if(result>0)
{
if(result == 1)//ֻ<><D6BB><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>
{
Val2 = DEFUALT_EDGE_CNT;
}
if(Val1>0)//ֱ<><D6B1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>0
{
m_Radius = Val1/2;
//EdgeCnt Ҫ<><D2AA>4<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>,<2C><>СΪ4
int min = 4;
m_EdgeCnt = (int)(Val2/min)*min;
if(m_EdgeCnt<min)
{
m_EdgeCnt = min;
}
CObjBase *pCurOptObject = m_TmpObjContainer.GetCurOpObj();
if(pCurOptObject)
{
CObjCircle *p = dynamic_cast<CObjCircle*>(pCurOptObject);
CCirclePar ObjCirclePar;
ObjCirclePar.CenterPt = m_DownPoint;
ObjCirclePar.Radius =m_Radius;
ObjCirclePar.DEdgeCnt = m_EdgeCnt;
p->Creat(ObjCirclePar);
}
OperateOver();
return true;
}
}
}
return false;
}