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.

124 lines
3.7 KiB
C++

#include "StdAfx.h"
#include "MouseToolMeasure.h"
#include "GlobalFunction.h"
#include "CommandMove.h"
#include "GlobalDrawMgr.h"
#include "LogMgr.h"
#include "DrawSimpleShape.h"
CMouseToolMeasure::CMouseToolMeasure(void)
{
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_TOOL_MEASURE_FIRST_PT);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
}
CMouseToolMeasure::~CMouseToolMeasure(void)
{
}
void CMouseToolMeasure::OperateOver()
{
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
CMouseTool::OperateOver();
m_Status = _STATUS_END;
}
void CMouseToolMeasure::OnLButtonDown(UINT nFlags, CPoint point,CClientDC &dc)
{
Dbxy pt = gDraw->CPoint2Dbxy(point);
if(m_Status==_STATUS_1)
{
SaveDownPoint(point);
//------------------------------------<2D><>־start
CString val1;
val1.Format("%lf",pt.x);
CString val2;
val2.Format("%lf",pt.y);
gLogMgr->WriteDebugLog(CMD_TOOL_MEASURE_FIRST_PT,STR_NULL,STR_NULL,pt.x,pt.y);
//------------------------------------<2D><>־end
//<2F><>ǩ<EFBFBD><C7A9>-------------------------start
GetFrame()->ResetCaptionBar();
GetFrame()->SetCaptionCmdStr(CMD_TOOL_MEASURE_SECOND_PT);
GetFrame()->RefreashCaptionBar();
//<2F><>ǩ<EFBFBD><C7A9>-------------------------end
ToNextStatus();
}
else
{
//------------------------------------<2D><>־start
{
CString val1;
val1.Format("%lf",pt.x);
CString val2;
val2.Format("%lf",pt.y);
gLogMgr->WriteDebugLog(CMD_TOOL_MEASURE_SECOND_PT,STR_NULL,STR_NULL,pt.x,pt.y);
}
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_Dis = CalDistance(m_DownPoint,pt);
gLogMgr->WriteDebugLog(CMD_TOOL_MEASURE_RESULT,STR_NULL,m_Dis);
}
{
gLogMgr->WriteDebugLog(CMD_TOOL_MEASURE_RESULT2,STR_NULL,STR_NULL,pt.x-m_DownPoint.x,pt.y-m_DownPoint.y);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD>
{
double Ang = Cal360AngleByTwoPt(pt,m_DownPoint);
gLogMgr->WriteDebugLog(CMD_TOOL_MEASURE_RESULT3,STR_NULL,Ang);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(0,0)<29><><EFBFBD>ļн<C4BC>
{
double Ang = Cal360AngleByTwoPt(pt,Dbxy(0,0));
gLogMgr->WriteDebugLog(CMD_TOOL_MEASURE_RESULT4,STR_NULL,Ang);
}
{
double Ang = Cal360AngleByTwoPt(m_DownPoint,Dbxy(0,0));
gLogMgr->WriteDebugLog(CMD_TOOL_MEASURE_RESULT4,STR_NULL,Ang);
}
//------------------------------------<2D><>־end
ClearFirstPoint();
m_Status = _STATUS_1;
}
}
void CMouseToolMeasure::OnLButtonUp(UINT nFlags, CPoint point,CClientDC &dc)
{
}
void CMouseToolMeasure::OnMouseMove(UINT nFlags, CPoint point,CClientDC &dc)
{
Dbxy OldPt = gDraw->CPoint2Dbxy(m_PreMovePt);
Dbxy CurPt = gDraw->CPoint2Dbxy(point);
CLayer &layer = gLayer;
if(m_Status!=_STATUS_1)
{
if(HasPreMovePt())//<2F><><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD>
{
XorDrawLine(&dc,gDraw->GetMeasurePen(),m_DownPoint,OldPt);
}
XorDrawLine(&dc,gDraw->GetMeasurePen(),m_DownPoint,CurPt);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_Dis = CalDistance(m_DownPoint,CurPt);
//״̬<D7B4><CCAC>-----------------------------start
CString str1 = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>[<5B><><EFBFBD><EFBFBD>]";
CString str2;
str2.Format("%lf",m_Dis);
GetFrame()->ResetStatusBarExtStr();
GetFrame()->SetStatusBarExtStr(str1,str2,STR_NULL);
//״̬<D7B4><CCAC>-----------------------------end
SavePreMovePt(point);
}
}
void CMouseToolMeasure::OnEscapeKey()
{
if(m_Status!=_STATUS_1)//<2F>ڶ<EFBFBD><DAB6>ε<EFBFBD>
{
OperateOver();
}
}