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++
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)
|
|
{
|
|
//标签栏-------------------------start
|
|
GetFrame()->ResetCaptionBar();
|
|
GetFrame()->SetCaptionCmdStr(CMD_TOOL_ROTATO_CENTER);
|
|
GetFrame()->RefreashCaptionBar();
|
|
//标签栏-------------------------end
|
|
}
|
|
CMouseToolRotate::~CMouseToolRotate(void)
|
|
{
|
|
}
|
|
void CMouseToolRotate::OperateOver()
|
|
{
|
|
if(m_Status==_STATUS_2)
|
|
{
|
|
//------------------------------------日志start
|
|
CString val1;
|
|
val1.Format("%lf",m_Angle);
|
|
gLogMgr->WriteCmd(CMD_TOOL_ROTATO_ANGLE,val1,STR_NULL);
|
|
//------------------------------------日志end
|
|
//标签栏-------------------------start
|
|
GetFrame()->ResetCaptionBar();
|
|
//标签栏-------------------------end
|
|
//旋转
|
|
SObjOperatePar par;
|
|
par.OpType = _OP_ROTATO;
|
|
par.BasePt = m_CenterPt;
|
|
par.Angle = m_Angle;
|
|
|
|
//创建undo 用的指令-----start
|
|
CCommandRotato *p = new CCommandRotato;
|
|
p->SetOperatePar(par);
|
|
gCommandMgr.AddUndoCommand(p);
|
|
p->Excute();
|
|
//创建undo 用的指令-----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;//记录旋转中心点
|
|
m_DownPoint.x+=20;
|
|
//------------------------------------日志start
|
|
CString val1;
|
|
val1.Format("%lf",pt.x);
|
|
CString val2;
|
|
val2.Format("%lf",pt.y);
|
|
gLogMgr->WriteCmd(CMD_TOOL_ROTATO_CENTER,val1,val2);
|
|
//------------------------------------日志end
|
|
//标签栏-------------------------start
|
|
GetFrame()->ResetCaptionBar();
|
|
GetFrame()->SetCaptionCmdStr(CMD_TOOL_ROTATO_ANGLE);
|
|
GetFrame()->RefreashCaptionBar();
|
|
//标签栏-------------------------end
|
|
ToNextStatus();
|
|
//将选中obj 复制到m_TmpObjContainer
|
|
m_TmpObjContainer.Clear();
|
|
gLayer.CloneObj(m_TmpObjContainer,true);
|
|
|
|
//创建模拟操作的对象
|
|
CreatOpSimulateObj();
|
|
}
|
|
else
|
|
{
|
|
//最后计算一次,避免捕捉点影响
|
|
double Angle=CalAngle(m_CenterPt,m_DownPoint,pt);
|
|
m_Angle = AngleTo360(Angle);//记录旋转角度
|
|
OperateOver();
|
|
}
|
|
}
|
|
void CMouseToolRotate::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
|
|
{
|
|
|
|
}
|
|
void CMouseToolRotate::OperateObj(Dbxy StartPt,Dbxy EndPt)
|
|
{
|
|
//计算反正切角
|
|
double Angle=CalAngle(m_CenterPt,StartPt,EndPt);
|
|
m_Angle = AngleTo360(Angle);//记录旋转角度
|
|
}
|
|
void CMouseToolRotate::OnMouseMove(UINT nFlags, CPoint point,CClientDC &dc)
|
|
{
|
|
Dbxy CurPt = gDraw->CPoint2Dbxy(point);
|
|
if(m_Status==_STATUS_2)
|
|
{
|
|
if(m_bFirstMove==false)
|
|
{
|
|
//重绘模拟对象
|
|
XorRedrawOpSimulateObj(&dc);
|
|
}
|
|
m_bFirstMove = false;
|
|
//计算反正切角
|
|
double Angle=CalAngle(m_CenterPt,m_DownPoint,CurPt);
|
|
m_Angle = AngleTo360(Angle);//记录旋转角度
|
|
|
|
SObjOperatePar par;
|
|
par.OpType = _OP_ROTATO;
|
|
par.BasePt = m_CenterPt;
|
|
par.Angle = m_Angle;
|
|
|
|
//操作模拟对象
|
|
OpSimulateObj(par);
|
|
|
|
//重绘模拟对象
|
|
XorRedrawOpSimulateObj(&dc);
|
|
}
|
|
}
|
|
bool CMouseToolRotate::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)
|
|
{
|
|
m_Angle = Val1;
|
|
OperateOver();
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|