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.

142 lines
3.8 KiB
C++

#include "StdAfx.h"
#include "MouseToolRotate.h"
#include "GlobalFunction.h"
#include "CommandRotato.h"
#include "GlobalDrawMgr.h"
#include "LogMgr.h"
#include "CommandMgr.h"
CMouseToolRotate::CMouseToolRotate(void)
{
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_TOOL_ROTATO_CENTER);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
}
CMouseToolRotate::~CMouseToolRotate(void)
{
}
void CMouseToolRotate::OperateOver()
{
if(m_Status==_STATUS_2)
{
//------------------------------------<2D><>־start
CString val1;
val1.Format("%lf",m_Angle);
gLogMgr->WriteCmd(CMD_TOOL_ROTATO_ANGLE,val1,STR_NULL);
//------------------------------------<2D><>־end
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
//<2F><>ת
SObjOperatePar par;
par.OpType = _OP_ROTATO;
par.BasePt = m_CenterPt;
par.Angle = m_Angle;
//<2F><><EFBFBD><EFBFBD>undo <20>õ<EFBFBD>ָ<EFBFBD><D6B8>-----start
CCommandRotato *p = new CCommandRotato;
p->SetOperatePar(par);
gCommandMgr.AddUndoCommand(p);
p->Excute();
//<2F><><EFBFBD><EFBFBD>undo <20>õ<EFBFBD>ָ<EFBFBD><D6B8>-----end
CMouseTool::OperateOver();
m_Status = _STATUS_END;
}
}
void CMouseToolRotate::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
{
Dbxy pt = gDraw->CPoint2Dbxy(point);
if(m_Status==_STATUS_1)
{
SaveDownPoint(point);
m_CenterPt = pt;//<2F><>¼<EFBFBD><C2BC>ת<EFBFBD><D7AA><EFBFBD>ĵ<EFBFBD>
m_DownPoint.x+=20;
//------------------------------------<2D><>־start
CString val1;
val1.Format("%lf",pt.x);
CString val2;
val2.Format("%lf",pt.y);
gLogMgr->WriteCmd(CMD_TOOL_ROTATO_CENTER,val1,val2);
//------------------------------------<2D><>־end
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_TOOL_ROTATO_ANGLE);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
ToNextStatus();
//<2F><>ѡ<EFBFBD><D1A1>obj <20><><EFBFBD>Ƶ<EFBFBD>m_TmpObjContainer
m_TmpObjContainer.Clear();
gLayer.CloneObj(m_TmpObjContainer,true);
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
CreatOpSimulateObj();
}
else
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>Σ<EFBFBD><CEA3><EFBFBD><EFBFBD>Ⲷ׽<E2B2B6><D7BD>Ӱ<EFBFBD><D3B0>
double Angle=CalAngle(m_CenterPt,m_DownPoint,pt);
m_Angle = AngleTo360(Angle);//<2F><>¼<EFBFBD><C2BC>ת<EFBFBD>Ƕ<EFBFBD>
OperateOver();
}
}
void CMouseToolRotate::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
{
}
void CMouseToolRotate::OperateObj(Dbxy StartPt,Dbxy EndPt)
{
//<2F><><EFBFBD><EFBFBD><E3B7B4><EFBFBD>н<EFBFBD>
double Angle=CalAngle(m_CenterPt,StartPt,EndPt);
m_Angle = AngleTo360(Angle);//<2F><>¼<EFBFBD><C2BC>ת<EFBFBD>Ƕ<EFBFBD>
}
void CMouseToolRotate::OnMouseMove(UINT nFlags, CPoint point,CClientDC &dc)
{
Dbxy CurPt = gDraw->CPoint2Dbxy(point);
if(m_Status==_STATUS_2)
{
if(m_bFirstMove==false)
{
//<2F>ػ<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
XorRedrawOpSimulateObj(&dc);
}
m_bFirstMove = false;
//<2F><><EFBFBD><EFBFBD><E3B7B4><EFBFBD>н<EFBFBD>
double Angle=CalAngle(m_CenterPt,m_DownPoint,CurPt);
m_Angle = AngleTo360(Angle);//<2F><>¼<EFBFBD><C2BC>ת<EFBFBD>Ƕ<EFBFBD>
SObjOperatePar par;
par.OpType = _OP_ROTATO;
par.BasePt = m_CenterPt;
par.Angle = m_Angle;
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
OpSimulateObj(par);
//<2F>ػ<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
XorRedrawOpSimulateObj(&dc);
}
}
bool CMouseToolRotate::OnSetCmd(CString str)
{
if(m_Status==_STATUS_2)
{
double Val1=0;//<2F><>ת<EFBFBD>Ƕ<EFBFBD>
double Val2=0;
int result = GetTwoNum(str,Val1,Val2);
if(result>0)
{
if(result == 1)
{
m_Angle = Val1;
OperateOver();
return true;
}
}
}
return false;
}