#include "stdafx.h"
#include "UtilCoord.h"		// For mm2lg.etc.
#include "DynamicDraw.h"			// For FFGetApp.
#include "ObjLine.h"	// For FCObjLine.
#include "ToolLine.h"	// This header.

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


// 02.12.05 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
//FCToolLine	g_toolLine;

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FFTLResizeCheck
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDiKiDfEiDeDiDfJiDgAiDeGiDgCiDeOjHhAiCmMiDfCiBfLiDiLiDgPiDgCiDeOiKnGjAjEiBeC_xHqqkZx_OnLButtonDown_xZkqqHx_jCiGiCmF_xHqqkZx_
 *			FCResizeWork::OnResizeFirst_xZkqqHx_iCmMiIpIjAjEiCmGiClFiCmEjDgOiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	objp	:OnResizeFirst_xZkqqHx_iCmFjAnNjCoIiClFiClNjFjEjFgJiCkKjAnNjCoIiClDiCoKiCoJiBeC_xHqqkZx_
 *			bXPosi	:X_xZkqqHx_jFpLiMpMiCmMjElNjDfNiCkKiCkAiCoJiPoKiNiHiCmN_xHqqkZx_TRUE_xZkqqHx_iCkKjAnNjCoIiClDiCoKiCoJiBeC_xHqqkZx_
 *			bYPosi	:Y_xZkqqHx_jFpLiMpMiCmMjElNjDfNiCkKiCkAiCoJiPoKiNiHiCmN_xHqqkZx_TRUE_xZkqqHx_iCkKjAnNjCoIiClDiCoKiCoJiBeC_xHqqkZx_
 *			mmrtNew	:_xZkqqHx_iDiKiDfEiDeDiDfJiMoDiCmMiNmAjFfHiCkKjAnNjCoIiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iDiKiDfEi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qHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
static BOOL FFTLResizeCheck (const FCObjDynabase* objp, BOOL bXPosi, BOOL bYPosi,
							 const DBLRect& mmrtNew)
{
	// _xZkqqHx_iPgDiBeFiJkBiCmGiCoAiCePiCmJiCmIiCoJiDiKiDfEiDeDiDfJiCmNiLjGiClDiCoKiCmIiCkCiBeC_xHqqkZx_
	if (mmrtNew.Width() == 0.0 && mmrtNew.Height() == 0.0) return FALSE;
	// _xZkqqHx_iPgDiBeFiJkBiCkCiClIiCoKiCkJiCkKiCePiCmFiCmIiCkPiCoKiCmOjHmHiCkCiBeC_xHqqkZx_
	return TRUE;
} // FFTLResizeCheck.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolLine::FCToolLine
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfCiDjDiDfIiDgHiDiJiDeOiDfO_xHqqkZx_
 *************************************************************************/
FCToolLine::FCToolLine ()
{
//----- 05.07.15 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//	// _xZkqqHx_iDgDiBfLiDiLjDoAjFjEjFjEjFgJiBeC_xHqqkZx_
//	m_objpReference = NULL;
//----- 05.07.15 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----
} // FCToolLine::FCToolLine.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolLine::CreateInsideObject
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_jDoAjFjEjFjEjFgJiCpAiNoMjAkMiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_jDoAjFjEjFjEjFgJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.07.15 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
FCObjDynabase* FCToolLine::CreateInsideObject ()
{
	FCObjDynabase* pObj = new FCObjLine();
	pObj->CalcResizeFrame();
//----- 06.11.26 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
	// _xZkqqHx_jFjEjFgJiCpAiNjFjAeGiDhJiDjDiCmFiPiJiKpKiJlLiBeC_xHqqkZx_
	InitInsideObject(pObj);
//----- 06.11.26 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----
	return pObj;
} // FCToolLine::CreateInsideObject.

//----- 05.07.15 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
///*************************************************************************
// * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolLine::OnViewCreate
// *
// * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	CFCDynamicDrawView::OnCreate_xZkqqHx_iCkJiCoH_xHqqkZx_Call.Tool_xZkqqHx_iCmMiPiJiKpKiJlL_xHqqkZx_.
// *
// * <_xZkqqHx_jCiNiInD_xHqqkZx_>	_xZkqqHx_iClHiCnHiCmEiCmMiDfEiDhFiDeOiDiJiDfIiCmFjFeLjAhL_xHqqkZx_.
// *************************************************************************/
//void FCToolLine::OnViewCreate ()
//{
//	BASE_CLASS::OnViewCreate();
//	//----- _xZkqqHx_iDiKiDhEiDeAiDiMiDjDiDfIjFjEjFgJiCmMiNoMjAkM_xHqqkZx_ -----
//	m_objpReference = new FCObjLine();
//	m_objpReference->CalcResizeFrame();
//// 05.05.02 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
////	m_objpReference->CalcOuterFrame();
//} // FCToolLine::OnViewCreate.
//----- 05.07.15 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

//----- 05.07.15 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
///*************************************************************************
// * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolLine::OnViewDestroy
// *
// * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	CFCDynamicDrawView::OnDestroy_xZkqqHx_iCkJiCoH_xHqqkZx_Call.Tool_xZkqqHx_iCmMiPeJjHlJiPiIjHjN_xHqqkZx_.
// *
// * <_xZkqqHx_jCiNiInD_xHqqkZx_>	_xZkqqHx_iClHiCnHiCmEiCmMiDfEiDhFiDeOiDiJiDfIiCmFjFeLjAhL_xHqqkZx_.
// *************************************************************************/
//void FCToolLine::OnViewDestroy ()
//{
//	delete m_objpReference;
//
//	BASE_CLASS::OnViewDestroy();
//} // FCToolLine::OnViewDestroy.
//----- 05.07.15 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

//----- 00.01.18 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
///*************************************************************************
// * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolLine::OnLButtonDown
// *
// * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iNlGiDhLiDfOiDjDiCkKiJjPiClDiCoKiClNiOjOiCmJ_xHqqkZx_View_xZkqqHx_iCkJiCoHiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
// *
// * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pDC		: _xZkqqHx_jFgAiJoGjHhA_xHqqkZx_CDC
// *			pPoint	: _xZkqqHx_iDhNiDeFiDfIiNmAjFfH_xHqqkZx_
// *			nFlags	: _xZkqqHx_iDeMiBfLiCpAjClCiCnHiCoJiDhEiDiJiDeP_xHqqkZx_
// *
// * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	99.04.23 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
// *************************************************************************/
//void FCToolLine::OnLButtonDown (CDC* pDC, const DBLPoint& mmptMsc, UINT nFlags)
//{
//	// Superclass_xZkqqHx_iKnGjAjEiCpAiOmAiNhDiBeC_xHqqkZx_
//	BASE_CLASS::OnLButtonDown(pDC, mmptMsc, nFlags);
//	// FCToolBaseCreate::OnLButtonDown_xZkqqHx_iCmFjAfGiLeLjFjEjFgJiCkKiNoMjAkMiClDiCoKiCmEiCkCiCmIiCkPiCoKiCmOjBkGiOjOjFjMiLeBiBeC_xHqqkZx_
//	if (m_objpNew == NULL) return;
//	// _xZkqqHx_jAiFjFlNjApMiBeFjAiCjClMjApMiCpAiInKjDkOiDhMiDeDiDjDiDgHiCmMiInKjDkOjEmNiImNiCmJjCmHiJmBiBeC_xHqqkZx_
//	const DBLPoint mmptFix = m_resizeWork.GetFixPoint();
//	m_resizeWork.AddLimitLine(DBLLine(mmptFix, mmptFix + DBLPoint(10, 0)));
//	m_resizeWork.AddLimitLine(DBLLine(mmptFix, mmptFix + DBLPoint(0, 10)));
//	// _xZkqqHx_jApMjFjEjFgJjAoKjHhAiCmMiDiKiDfEiDeDiDfJiDgAiDeGiDgCiDeOiKnGjAjEiCpAjAnNjCoIiBeC_xHqqkZx_
//	m_resizeWork.SetResizeCheck(FFTLResizeCheck);
//} // FCToolLine::OnLButtonDown.
//----- 00.01.18 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolLine::GetDefaultIdleCursor
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	StateIdle_xZkqqHx_iCmFiDgGiDhEiDeIiDiLiDgHiCmJiOgHiCoNiCoKiCoJiDeKiBfLiDfMiDiLiDgOiDjDiDgIiDiLiCpAjFnEiClHiBeC_xHqqkZx_
 *			_xZkqqHx_jFfHiPiAiCmMiDeKiBfLiDfMiDiLiCmMiPoKiNiHiCmN_xHqqkZx_ NULL_xZkqqHx_iCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.07.20 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
HCURSOR FCToolLine::GetDefaultIdleCursor () const
{
	return FFGetApp()->LoadCursor(IDC_CURSOR_TOOL_LINE);
} // FCToolLine::GetDefaultIdleCursor.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolLine::InitNewObject
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDhNiDeFiDfIiCkKiJjPiClDiCoKiClNiOjOiCmJiNoMjAkMiClFiClNjFjEjFgJiCpAiPiJiKpKiJlLiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pObj	:_xZkqqHx_jFjEjFgJiCpAiOhHjCoIiBeC_xHqqkZx_
 *			mmpt	:_xZkqqHx_jFjEjFgJiCmMiNlGiPoDiImKjChFiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iPiJiKpKiJlLiCmJjAkMiMpHiClFiClNiPoKiNiHiCmN_xHqqkZx_ TRUE_xZkqqHx_iBeBiOlIjEhDiClFiClNiPoKiNiHiCmN_xHqqkZx_ FALSE _xZkqqHx_iCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iJpAjAoA_xHqqkZx_>	_xZkqqHx_iDiKiDhEiDeAiDiMiDjDiDfIjFjEjFgJiCmMjBkOjAkLiCkKiLlGiCmBiCmEiCkCiCoJiPoKiNiHiBgJiJkBjFjNiCePiCmGiCkJiBgKiBeBiClBiClBiCmF_xHqqkZx_
 *			_xZkqqHx_jFoCjAlDiClFiCmEiBeBiClLiCmMiMoDiCmMiDiKiDfEiDeDiDfJiCpAiJmCjEfMiCmJiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	00.01.27 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL FCToolLine::InitNewObject (FCObjDynabase* pObj, const DBLPoint& mmpt) const
{
	//----- _xZkqqHx_jApMiCmMiKeKiOgOjDfPiCmGiPeJjHlJjDfPiCpAjAnNjCoIiBeCjAiFjFlNjApMiBeFjAiCjClMjApMiCmJiCmIiCoJiCmMiCpAjGgIiCkOiClNiCnP_xHqqkZx_ -----
	FCObjLine* pLine = (FCObjLine*)pObj;
	pLine->SetFromEndX(mmpt.x);
	pLine->SetFromEndY(mmpt.y);
	pLine->SetToEndX(mmpt.x + lg2mm(10));
	pLine->SetToEndY(mmpt.y + lg2mm(10));
	return BASE_CLASS::InitNewObject(pObj, mmpt);
} // FCToolLine::InitNewObject.

//----- 05.07.15 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
///*************************************************************************
// * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolLine::GetInsideObject
// *
// * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_jFjEjFgJiCmMjAlGjAkMiCmJiOgHjHhAiClDiCoKiCoJiDgDiBfLiDiLjDoAjFjEjFjEjFgJiCpAjFnEiClH_xHqqkZx_.
// *
// * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iDgDiBfLiDiLjDoAjFjEjFjEjFgJiCmMiDhMiDeDiDjDiDfO_xHqqkZx_.
// *
// * <_xZkqqHx_iJpAjAoA_xHqqkZx_>	_xZkqqHx_iClBiCmMjFjEjFgJiCpAiOgHiCmBiCmEiBeBiDhNiDeFiDfIiInKjDkOiOjOiCmMjFgAiJoGiCoCjFjEjFgJiCmMjAlGjAkMiCpAiNhDiCkE_xHqqkZx_.
// *
// * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	98.09.24 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
// *************************************************************************/
//FCObjDynabase* FCToolLine::GetInsideObject () const
//{
//	return m_objpReference;
//} // FCToolLine::GetInsideObject.
//----- 05.07.15 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCToolLine::StateStartCreate
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iNoMjAkMiKeKiOgOiPiIjHjNiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pDC	:_xZkqqHx_jFgAiJoGjHhAiDgGiDgPiDeDiDfIiDfCiDjDiDgFiDeMiDfIiDgHiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	00.01.18 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void FCToolLine::StateStartCreate (CDC* pDC)
{
	TRACE(_T("StateStartCreate\r\n"));
	// Superclass_xZkqqHx_iKnGjAjEiOmAiNhDiBeC_xHqqkZx_
	BASE_CLASS::StateStartCreate(pDC);
	if (m_objpNew != NULL)
	{
		// _xZkqqHx_jAiFjFlNjApMiBeFjAiCjClMjApMiCpAiInKjDkOiDhMiDeDiDjDiDgHiCmMiInKjDkOjEmNiImNiCmJjCmHiJmBiBeC_xHqqkZx_
		const DBLPoint mmptFix = m_resizeWork.GetFixPoint();
		m_resizeWork.AddLimitLine(DBLLine(mmptFix, mmptFix + DBLPoint(10, 0)));
		m_resizeWork.AddLimitLine(DBLLine(mmptFix, mmptFix + DBLPoint(0, 10)));
		// _xZkqqHx_jApMjFjEjFgJjAoKjHhAiCmMiDiKiDfEiDeDiDfJiDgAiDeGiDgCiDeOiKnGjAjEiCpAjAnNjCoIiBeC_xHqqkZx_
		m_resizeWork.SetResizeCheck(FFTLResizeCheck);
	}
} // FCToolLine::StateStartCreate.
