#ifndef __ToolLink_h
#define __ToolLink_h

#include "ToolBaseEdit.h"	// Super class.
#include "ToolSelectTmpl.h"	// Super class.

#ifdef SUPER_CLASS
#undef SUPER_CLASS
#endif
//#define SUPER_CLASS FCToolBaseEdit
#define SUPER_CLASS FCToolSelectTmpl<FCToolBaseEdit, DWORD, FCToolLinkId>

// FCToolSelectTmpl _xZkqqHx_iCmMiDgFiDjDiDhGiDiMiBfLiDgH_xHqqkZx_ID_xZkqqHx_iCpAjCoIiLgAiBeC_xHqqkZx_
typedef struct FCToolLinkId {} *XXX_Link;
#define XXX_LINK	XXX_Link(NULL)


struct FCMolipRec;
class FCObjDynabase;
class FCPolyJoint;

struct FCTLMolipInfo
{
	long				m_lMolipCount;
	map<long, DBLPoint>	m_mpIdToOffset;
}; // struct FCTLMolipInfo.

class FCToolLink : public SUPER_CLASS
{
protected:
typedef SUPER_CLASS BASE_CLASS;

public:
	//----- _xZkqqHx_iDfEiDhFiDeOiDiJiDfIiCmFjEeDiInD_xHqqkZx_ -----
// 06.12.09 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
//	virtual void	OnDraw (CDC* pDC);
// 05.07.25 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
//	virtual void	OnDraw (CDC* pDC, const DBLRect* pmmrtRgn = NULL, long lRgnSize = 0);
	virtual void	OnSelectObjModified ();
	virtual void	Select (CDC* pDC);
	virtual void	Unselect (CDC* pDC);
	virtual BOOL	CanSelectTool () const;
	virtual BOOL	CanHandle (const FCObjDynabase* pObj) const;

	virtual void	DrawSelectMark (CDC* pDC, FCObjDynabase* pObj);
	virtual void	OnAppendSelectObj (CDC* pDC, FCObjDynabase* pObj);
	virtual void	OnRemoveSelectObj (CDC* pDC, FCObjDynabase* pObj);

	virtual BOOL	CanObjectProperties () const;
	virtual void	OnObjectProperties ();

	virtual BOOL	CanDelete () const;
	virtual void	OnDelete (CDC* pDC);

//----- 05.10.26 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
	virtual BOOL	CanExchangeHeadTail () const;
	virtual void	OnExchangeHeadTail ();
//----- 05.10.26 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----

protected:
	//----- _xZkqqHx_iClBiCmMiDeOiDiJiDfIiMmFjHeMiCmMiKnGjAjE_xHqqkZx_ -----
// 05.06.10 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
//	virtual void	GetSelObjLink (DWORDSet& setLink) const;
	virtual void	Calc3Joint (FCPolyJoint jointArray[], DWORD dwLinkID) const;
	virtual void	DrawLinkLine (CDC* pDC, BOOL bIsBold, const DBLRect* mmrtpClip,
									DWORD dwLinkID) const;
	virtual void	DrawSelectLink (DWORD dwLinkID, CDC* pDC) const;
//----- 05.06.10 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//	virtual BOOL	IsSelectLink (DWORD dwLinkID) const;
//	virtual void	AppendSelectLink (DWORD dwLinkID, CDC* pDC);
//	virtual void	RemoveSelectLink (DWORD dwLinkID, CDC* pDC);
//	virtual void	ClearSelectLink (CDC* pDC);
//----- 05.06.10 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

//----- 05.06.10 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//	virtual BOOL	IsLinkInRect (DWORD dwLinkID, const CRect& lgrtFrame) const;
//	virtual BOOL	CheckHitLink ();
//----- 05.06.10 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

	virtual BOOL	CheckHitMolip ();
	virtual void	GetMyMolipPos (DBLPoint& mmpt, const FCObjDynabase* pObj, long lMolipId) const;


	//----- FCToolBaseFDA_xZkqqHx_iCmMiDfEiDhFiDeOiDiJiDfIiCmFjFeLjHhGiCmJiJjOiClGiCmE_xHqqkZx_ -----
	virtual HCURSOR	GetDefaultIdleCursor () const;
// 05.10.24 Fukushiro M. 1_xZkqqHx_iNhDjCmHiJmB_xHqqkZx_ ()
	virtual int		GetSubMenuIndex () const;
// 06.12.09 Fukushiro M. 1_xZkqqHx_iNhDjCmHiJmB_xHqqkZx_ ()
	virtual void	OnDrawState (CDC* pDC, int iState);
	virtual int		TransFDA (int iState, int iEvent);
	virtual void	StateFDA (int iState, CDC* pDC);
	//----- _xZkqqHx_jBeKiInKiPpDjBnEiPiIjHjNiBgJiDeJiBfLiDgPiBfLiDiJiDeDiDgIiBgK_xHqqkZx_ -----
	virtual void	StateIdle (CDC* pDC);				// _xZkqqHx_jBnCiClPiBeC_xHqqkZx_
	//----- _xZkqqHx_jBeKiInKiPpDjBnEiPiIjHjN_xHqqkZx_ -----
//----- 05.06.10 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//	virtual void	StateEnterOpeLink (CDC* pDC);		// _xZkqqHx_iDiKiDjDiDeOjBiAiNoMjDpMiMpLiBeC_xHqqkZx_
//	virtual void	StatePreUnselLink (CDC* pDC);		// _xZkqqHx_iDiKiDjDiDeOjBeJjBpAiJpAiPjMjBePiBeC_xHqqkZx_
//	virtual void	StateUnselLink (CDC* pDC);			// _xZkqqHx_iDiKiDjDiDeOjBeJjBpAiJpAiPjMiBeC_xHqqkZx_
//	virtual void	StateClrselSelLink (CDC* pDC);		// _xZkqqHx_iDiKiDjDiDeOjBeJjBpAiPmBiLiOjCmHiJmBiBeC_xHqqkZx_
//	virtual void	StateStartEncloseLink (CDC* pDC);	// _xZkqqHx_iDiKiDjDiDeOjFoPiImNiKeKiOgOiBeC_xHqqkZx_
//	virtual void	StateEnclosingLink (CDC* pDC);		// _xZkqqHx_iDiKiDjDiDeOjFoPiImNjCiGiBeC_xHqqkZx_
//	virtual void	StateStopEncloseLink (CDC* pDC);	// _xZkqqHx_iDiKiDjDiDeOjFoPiImNiPeJjHlJiBeC_xHqqkZx_
//	virtual void	StateExitOpeLink (CDC* pDC);		// _xZkqqHx_iDiKiDjDiDeOjBiAiNoMiPgPiMpLiBeC_xHqqkZx_
//----- 05.06.10 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

	virtual void	StateStartLink (CDC* pDC);			// _xZkqqHx_iDiKiDjDiDeOiKeKiOgOiBeC_xHqqkZx_
	virtual void	StateLinking (CDC* pDC);			// _xZkqqHx_iDiKiDjDiDeOjCiGiBeC_xHqqkZx_
	virtual void	StateContextMenuMkl (CDC* pDC);		// _xZkqqHx_iDiBiDgKiDiFiBfLjFfMiOkG_xHqqkZx___xZkqqHx_iDiKiDjDiDeOiNoMjAkMiBeC_xHqqkZx_
	virtual void	StateMklCommand (CDC* pDC);			// _xZkqqHx_iDiKiDjDiDeOiNoMjAkM_xHqqkZx___xZkqqHx_iDfCiDhNiDjDiDgIiBeC_xHqqkZx_
	virtual void	StateStopLink (CDC* pDC);			// _xZkqqHx_iDiKiDjDiDeOiPeJjHlJiBeC_xHqqkZx_

//----- 01.08.20 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
	virtual void	StateStartMoveMolipMark (CDC* pDC);	// _xZkqqHx_iDiCiDiKiDhGiDhNiBfLiDeOiInKjDkOiKeKiOgOiBeC_xHqqkZx_
	virtual void	StateMovingMolipMark (CDC* pDC);	// _xZkqqHx_iDiCiDiKiDhGiDhNiBfLiDeOiInKjDkOjCiGiBeC_xHqqkZx_
	virtual void	StateStopMoveMolipMark (CDC* pDC);	// _xZkqqHx_iDiCiDiKiDhGiDhNiBfLiDeOiInKjDkOiPeJjHlJiBeC_xHqqkZx_
//----- 01.08.20 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----

	//----- FCToolBaseEdit_xZkqqHx_iCmMiDfEiDhFiDeOiDiJiDfIiCmFjFeLjAhL_xHqqkZx_ -----
	virtual void	ResetEditHandleList ();

//----- 05.06.10 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
	//----- FCToolSelectTmpl_xZkqqHx_iCmMiDfEiDhFiDeOiDiJiDfIiCmFjFeLjAhL_xHqqkZx_ -----
	virtual DWORD	InvalidValueXXX (XXX_Link) const;
	virtual long	GetSelectedXXX (XXX_Link, vector<DWORD>* vXxx = NULL, set<DWORD>* stXxx = NULL) const;
	virtual long	GetSelectableXXX (XXX_Link, vector<DWORD>* vXxx = NULL) const;
	virtual void	SelectXXX (XXX_Link, DWORD xxx, CDC* pDC);
	virtual void	UnselectXXX (XXX_Link, DWORD xxx, CDC* pDC);
	virtual DBLRect	GetFrameRectXXX (XXX_Link, DWORD xxx) const;

	//----- FCToolSelectTmpl_xZkqqHx_iCmMiDfEiDhFiDeOiDiJiDfIiCmFjEeDiInD_xHqqkZx_ -----
	virtual BOOL	CheckHitNextXXX (XXX_Link, DWORD* hitXxx, DWORD lastXxx);
//----- 05.06.10 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----

protected:
// _xZkqqHx_iClBiCmMiDeOiDiJiDfIiMmFjHeMiCmMjCoIiLgAiBeC_xHqqkZx_
enum
{
	STATE_BEGIN = BASE_CLASS::STATE_END,	// _xZkqqHx_iPpDjBnEiKeKiOgOiBeC_xHqqkZx_
// 05.06.06 Fukushiro M. 1_xZkqqHx_iNhDjFmPiNfI_xHqqkZx_ ()
//	STATE_ENTER_OPE_LINK = FCToolSelect::STATE_END,	// _xZkqqHx_iDiKiDjDiDeOjBiAiNoMjDpMiMpLiBeC_xHqqkZx_
//----- 05.06.10 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//	STATE_ENTER_OPE_LINK,		// _xZkqqHx_iDiKiDjDiDeOjBiAiNoMjDpMiMpLiBeC_xHqqkZx_
//	STATE_PRE_UNSEL_LINK,		// _xZkqqHx_iDiKiDjDiDeOjBeJjBpAiJpAiPjMjBePiBeC_xHqqkZx_
//	STATE_UNSEL_LINK,			// _xZkqqHx_iDiKiDjDiDeOjBeJjBpAiJpAiPjMiBeC_xHqqkZx_
//	STATE_CLRSEL_SEL_LINK,		// _xZkqqHx_iDiKiDjDiDeOjBeJjBpAiPmBiLiOjCmHiJmBiBeC_xHqqkZx_
//	STATE_START_ENCLOSE_LINK,	// _xZkqqHx_iDiKiDjDiDeOjFoPiImNiKeKiOgOiBeC_xHqqkZx_
//	STATE_ENCLOSING_LINK,		// _xZkqqHx_iDiKiDjDiDeOjFoPiImNjCiGiBeC_xHqqkZx_
//	STATE_STOP_ENCLOSE_LINK,	// _xZkqqHx_iDiKiDjDiDeOjFoPiImNiPeJjHlJiBeC_xHqqkZx_
//	STATE_EXIT_OPE_LINK,		// _xZkqqHx_iDiKiDjDiDeOjBiAiNoMiPgPiMpLiBeC_xHqqkZx_
//----- 05.06.10 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

	STATE_START_LINK,			// _xZkqqHx_iDiKiDjDiDeOiKeKiOgOiBeC_xHqqkZx_
	STATE_LINKING,				// _xZkqqHx_iDiKiDjDiDeOjCiGiBeC_xHqqkZx_
	STATE_CONTEXT_MENU_MKL,		// _xZkqqHx_iDiBiDgKiDiFiBfLjFfMiOkG_xHqqkZx___xZkqqHx_iDiKiDjDiDeOiNoMjAkMiBeC_xHqqkZx_
	STATE_MKL_COMMAND,			// _xZkqqHx_iDiKiDjDiDeOiNoMjAkM_xHqqkZx___xZkqqHx_iDfCiDhNiDjDiDgIiBeC_xHqqkZx_
	STATE_STOP_LINK,			// _xZkqqHx_iDiKiDjDiDeOiPeJjHlJiBeC_xHqqkZx_

//----- 01.08.20 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
	STATE_START_MOVE_MOLIP_MARK,// _xZkqqHx_iDiCiDiKiDhGiDhNiBfLiDeOiInKjDkOiKeKiOgOiBeC_xHqqkZx_
	STATE_MOVING_MOLIP_MARK,	// _xZkqqHx_iDiCiDiKiDhGiDhNiBfLiDeOiInKjDkOjCiGiBeC_xHqqkZx_
	STATE_STOP_MOVE_MOLIP_MARK,	// _xZkqqHx_iDiCiDiKiDhGiDhNiBfLiDeOiInKjDkOiPeJjHlJiBeC_xHqqkZx_
//----- 01.08.20 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----

	STATE_END,					// _xZkqqHx_iPpDjBnEiPeJjHlJiBeC_xHqqkZx_
};

//----- 05.06.07 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//friend BOOL myGetMolipPos (	DBLPoint& mmpt, DWORD dwData, const FCObjDynabase* pObj,
//							long lMolipId, long lTerminalIdx);
//----- 05.06.07 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

protected:
	//----- _xZkqqHx_iDiCiDiKiDhGiInKjDkOiDeJiDhEiDfKiDgCiDgHjFmPjAjE_xHqqkZx_(_xZkqqHx_jFnLjBlGiPoOjFpB_xHqqkZx_) -----
// 05.06.06 Fukushiro M. 1_xZkqqHx_iNhDjFmPiNfI_xHqqkZx_ ()
//	map<DWORD, FCTLMolipInfo>	m_mpObjIdToMolipInfo;
	map< pair<DWORD, long>, DBLPoint >	m_mpMolipIdToOffset;

	//----- _xZkqqHx_iDiKiDjDiDeOiMjPiNpFiDhBiDgCiDgHiLeMjIfOjHhAjFmPjAjE_xHqqkZx_ -----
// 05.06.10 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
//	DWORD		m_dwHitLinkID;		// _xZkqqHx_iDfOiBfLiDfBiDgCiDgHjCiGiCmMiDiKiDjDiDeO_xHqqkZx_ID_xZkqqHx_iBeC_xHqqkZx_

	DBLPoint	m_mmptLast;			// _xZkqqHx_iDhNiDeFiDfIiInKjDkOiCmMiNmFiMoDiCmMiImKjChFiCpAiLeMjIfOiBeC_xHqqkZx_

	//----- _xZkqqHx_iDiKiDjDiDeOjApMjFgAiJoGjHhAjFmPjAjE_xHqqkZx_ -----
	FCObjDynabase*	m_pFromObj;			// _xZkqqHx_iDiKiDjDiDeOiMlDiDiCiDiKiDhGjFjEjFgJiBeC_xHqqkZx_
	long		m_lFromMolipId;		// _xZkqqHx_iDiKiDjDiDeOiMlDiDiCiDiKiDhG_xHqqkZx_ID_xZkqqHx_iBeC_xHqqkZx_
	DBLPoint	m_mmptFromMolip;	// _xZkqqHx_iDiKiDjDiDeOiMlDiDiCiDiKiDhGiNmAjFfHiBeC_xHqqkZx_

	DWORD		m_dwLinkKind;		// _xZkqqHx_iNoMjAkMjCiGiCmMiDiKiDjDiDeOiOoNiBeC_xHqqkZx_

	//----- _xZkqqHx_jBeJjBpAjCiGiDiKiDjDiDeOiPoOjFpB_xHqqkZx_(_xZkqqHx_jFnLjBlGiPoOjFpB_xHqqkZx_) -----
	DWORDSet	m_setSelLinkID;		// _xZkqqHx_jBeJjBpAjCiGiCmMiDiKiDjDiDeO_xHqqkZx_ID_xZkqqHx_iPfHiNiHiBeC_xHqqkZx_
}; // class FCToolLink.

// 02.12.05 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
//extern FCToolLink g_toolLink;

#endif//__ToolLink_h
