/*
///////////////////////////////////////////////////////////////////////////////////////////////////
// Description : LinkObj.hpp
//   
//  Definition of the link editors objects            
//
///////////////////////////////////////////////////////////////////////////////////////////////////
// inherit from  :	CPA_Object
//					CPA_EdMot<WP_tdhWayPoint>
///////////////////////////////////////////////////////////////////////////////////////////////////
// Creation date: 21 jan 1997                        Author: J Thénoz
///////////////////////////////////////////////////////////////////////////////////////////////////
// Modification date:			                      Author: 
// 
//
// 
//
///////////////////////////////////////////////////////////////////////////////////////////////////
*/

//ANNECY Shaitan Nettoyage (12/05/98) {
/*

#ifndef __LinkOBJECT_HPP__
#define __LinkOBJECT_HPP__

#define C_ucLink 1997

//----------------------------------------------------------------------
// Definition of the name of the models
static char* pszLineModelName = "Line";
static char* pszArcModelName = "Arc";
static char* pszSplineModelName = "Spline";
//----------------------------------------------------------------------


class DiaLink;
class RotationDia;
class Link;

typedef struct tdst_LinkObject_
{
	char szName [10];
	char cType;
	Link* (*fn_pConstruct) ( CPA_ObjectDLLBase* , CPA_BaseObject*, WP_tdhLink  );
} tdst_LinkObject;

class WayPoint;
class Way;
class Waypoint_Interface;
class Tangent;

class Link : public CPA_BaseObject, public CPA_EdMot<WP_tdhLink>
{
protected :
	static Waypoint_Interface*		ms_poInterface;  // Interface
	static DiaLink*	ms_poDiaLink;			// Dialog 
	static RotationDia*	ms_poRotationDia;	// Rotation Dialog 
	static CPA_List<tdst_LinkObject> ms_oListLinkObject; // List of the present links
	static long ms_lNbLink;		// Number of created link

	CPA_SuperObject* m_poSuperObject;	// super object
	Way*		m_poParent;     // Father of the link
	WayPoint*	m_poFirstWP;	// First WP of the link
	WayPoint*	m_poSecondWP;	// Second WP of the link
	Tangent*	m_poFirstOrientationTangent;	// orientation at first WP location
	Tangent*	m_poSecondOrientationTangent;	// orientation at second WP location

	MTH_tdxReal m_xOrientationTangentLenght;	// lenght of orientation tangent

	BOOL m_bAddInHierarchy;		// The link is insert in the hierarchy
	BOOL m_bRemoveInHierarchy;	// The link has been in the hierarchy, but was retired
	BOOL m_bDraw;				// The link is ok in the hierachy but must be draw
	BOOL m_bCanDrawOutHierarchy;// can we run the fn_vDrawOutHierarchy function ?
	BOOL m_bRotationMode;		// Link is in rotation edition mode
	BOOL m_bFirstEdition;
	
	MTH_tdxReal m_xFirstTwistOrientation;	// twist at first WP location
	MTH_tdxReal m_xSecondTwistOrientation;	// twist at second WP location
	BOOL m_bXDirectOrientation;	// Ox rotation in trigo way	
	BOOL m_bYDirectOrientation;	// Oy rotation in trigo way
	BOOL m_bZDirectOrientation;	// twist in trigo way
	long	m_lNbLapXOrientation;	// Number of complete laps in Ox rotation
	long	m_lNbLapYOrientation;	// Number of complete laps in Oy rotation
	long	m_lNbLapZOrientation;	// Number of complete laps in Oz rotation


public:
	// static
	static void fn_vInitObject (Waypoint_Interface* poInterface);
	static SCRIPT_tdeReturnValue CallBackLoad (FILE *p_fFile, char *szAction, char *szParams[], SCRIPT_tdeAction cType);
	static void fn_vSetDialog ( DiaLink* poDiaLink, RotationDia* poRotationDia );
	static DiaLink* fn_pGetDialog ( void ) { return ms_poDiaLink; }
	static RotationDia* fn_pGetRotationDialog (void) { return ms_poRotationDia; }

	static Link* fn_pCreateLink ( Way* poWay, char cType, WayPoint* poFirstWP=NULL, WayPoint* poSecondWP=NULL, WP_tdhLink hLink=NULL );  // create a new link with it's associated super object
	static Link* fn_pCreateLink ( Way* poWay, WP_tdhLink hLink, WayPoint* poFirstWP, WayPoint* poSecondWP );

	static Link* CloneLink ( Way* poWay, Link* poLink, CString& szNewLinkName );

	Link ( CPA_ObjectDLLBase *p_oDLL, CPA_BaseObject *p_oOwner, WP_tdhLink hLink );
	Link ( CPA_ObjectDLLBase *p_oDLL, CPA_BaseObject *p_oOwner );
	void *GetEngineStruct (void) { return GetStruct(); }

	//--- data
	long GetDataType (void);
	void* GetData (void);

	// super object
	void SetSuperObject ( CPA_SuperObject* poSuperObject) { m_poSuperObject=poSuperObject; }
	CPA_SuperObject* GetSuperObject (void) { return m_poSuperObject; }


	void fn_vSplitLink ( Way* poWay, WayPoint* poWP, Link** pLinkBefore, Link** pLinkAfter );
	Link* fn_pMergeLink ( Way* poWay, Link* pLink );

	// save link
	void fn_vSave ( SCR_tdst_File_Description *_p_stFile );

	// set
	void fn_vSetAddInHierarchy ( BOOL bAddInHierarchy ) { m_bAddInHierarchy=bAddInHierarchy; }
	void fn_vSetRemoveInHierarchy ( BOOL bRemoveInHierarchy ) { m_bRemoveInHierarchy=bRemoveInHierarchy; }
	void fn_vSetDraw ( BOOL bDraw ) { m_bDraw=bDraw; }
	void fn_vSetDrawOutHierarchy (BOOL bDraw) { m_bCanDrawOutHierarchy = bDraw; }
	void fn_vSetXDirectOrientation ( BOOL bXDirectOrientation );
	void fn_vSetYDirectOrientation ( BOOL bYDirectOrientation );
	void fn_vSetZDirectOrientation ( BOOL bZDirectOrientation );
	void fn_vSetNbLapXOrientation ( long lNbLapXOrientation );
	void fn_vSetNbLapYOrientation ( long lNbLapYOrientation );
	void fn_vSetNbLapZOrientation ( long lNbLapZOrientation );
	void fn_vSetFirstTwistOrientation ( MTH_tdxReal xFirstTwistOrientation );
	void fn_vSetSecondTwistOrientation ( MTH_tdxReal xSecondTwistOrientation );
	virtual void fn_vSetWaypoints ( WayPoint* poFirstWP, WayPoint* poSecondWP ) { if(poFirstWP) m_poFirstWP=poFirstWP; if (poSecondWP) m_poSecondWP=poSecondWP; }
	
	// get
	static CPA_List <tdst_LinkObject>* fn_pGetListObject (void) { return &ms_oListLinkObject; }
	BOOL fn_bIsAddInHierarchy ( void ) { return m_bAddInHierarchy; }
	BOOL fn_bIsRemoveInHierarchy ( void ) { return m_bRemoveInHierarchy; }
	BOOL fn_bIsDraw ( void ) { return m_bDraw; }
	BOOL fn_bCanDrawOutHierarchy (void) { return m_bCanDrawOutHierarchy; }
	void fn_vGetWaypoints ( WayPoint** poFirstWP, WayPoint** poSecondWP ) { *poFirstWP=m_poFirstWP; *poSecondWP=m_poSecondWP; }
	BOOL fn_bIsWaypoint ( WayPoint* poWp ) { return (m_poFirstWP==poWp) || (m_poSecondWP==poWp); }
	Way* fn_pGetWay (void) { return m_poParent; }
	BOOL fn_bIsRotationMode (void) { return m_bRotationMode; }
	BOOL fn_bIsXDirectOrientation (void)	{ return m_bXDirectOrientation; }
	BOOL fn_bIsYDirectOrientation (void)	{ return m_bYDirectOrientation; }
	BOOL fn_bIsZDirectOrientation (void)	{ return m_bZDirectOrientation; }
	long fn_lGetNbLapXOrientation (void)	{ return m_lNbLapXOrientation; }
	long fn_lGetNbLapYOrientation (void)	{ return m_lNbLapYOrientation; }
	long fn_lGetNbLapZOrientation (void)	{ return m_lNbLapZOrientation; }
	MTH_tdxReal fn_xGetFirstTwistOrientation (void) { return m_xFirstTwistOrientation; }	
	MTH_tdxReal fn_xGetSecondTwistOrientation (void) { return m_xSecondTwistOrientation; }	

	//---- Object dependant functions
	virtual char fn_cGetType ( void )=0;
	virtual char* fn_pGetName ( void )=0;

	// draw
	virtual void fn_vConstructGraphic (void);				// construct the graphic son's
	virtual void fn_vInitGraphic (void);					// init the graphic son after it has been put into the hierarchy
	virtual void fn_vRotationGraphic (BOOL bRotation);	// Set/Unset rotation mode
	virtual void fn_vDrawNormal (void) {}				// refresh the draw when in normal mode
	virtual void fn_vDrawRotation (void) {}					// refresh the draw when in rotation mode
	virtual void fn_vInitEditorFromEngine (void) {}			// init editor data when engine exist
	virtual void fn_vGetSaveInfo ( char dszParam [20][20], long& lNbParam )=0; // ask for saving data

	virtual void fn_vDrawOutHierarchy (GLD_tdstViewportAttributes *pViewportAttributes) {}		// This function is call to draw out of the hierarchy

	virtual void fn_vStartEdit (void) { };				// this link is selected
	virtual void fn_vStopEdit (void) { };				// this link is no longer selected
	virtual void fn_vChangeNeighbourTangent (Tangent* pTangent);	
	virtual void fn_vChangeAllTangent (Tangent* pTangent);	
	
	// A tangent son of this link change


	void fn_vDraw (void);		// refreh the draw according to the mode


	// dialog
	virtual CDialog* fn_pGetSpecificDialog (CWnd* pParentWnd) { return NULL; }	 // return a pointer on a specific dialog son of pParentWnd
	virtual void fn_vFreeSpecificDialog (CDialog* pDialog) {}	 
	virtual BOOL fn_bIsPlane (void) { return FALSE; }
	
	Waypoint_Interface* GetInterface (void);
	void fn_vWayNotifySave (void);

	void fn_vEdit (void);
	void fn_vSelectWay (void);
	void fn_vSetAllOrientationTangent ( MTH3D_tdstVector* pTangentVertex );
	void fn_vReinitOrientationTangent (Tangent* poTangent);

protected :
	void fn_vRefreshEngineOrientation (void);
	void fn_vComputeAxis (void);	// Modify local axis
	void fn_vSetType ( WP_tde_ucConnectionType cType );
	void fn_vSetOrientationTangent ( int iSide, MTH3D_tdstVector* pTangentVertex );
 

	void fn_vVertex2Rotation (MTH_tdxReal* pxXRot, MTH_tdxReal* pxYRot, MTH_tdxReal* pxZRot, MTH3D_tdstVector* pstVector, MTH_tdxReal* pxRot );
	void fn_vRotation2Vertex ( MTH3D_tdstVector* pstVector, MTH_tdxReal* pxRot, MTH_tdxReal* pxXRot, MTH_tdxReal* pxYRot, MTH_tdxReal* pxZRot );
	void fn_vComputeModulusRotation ( MTH_tdxReal* xStartRot, MTH_tdxReal* xEndRot, BOOL bDirectOrientation, long lNbLapOrientation );
	void fn_vExtractModulusRotation ( BOOL* bDirectOrientation, long* lNbLapOrientation, MTH_tdxReal& xStartRot, MTH_tdxReal& xEndRot );


private:	
	void fn_vCorrectNulValue ( MTH3D_tdstVector* pstVector );
	inline BOOL fn_bIsRealNul ( MTH_tdxReal& rReal );

};

#endif //__LinkOBJECT_HPP__


*/
//ENDANNECY Shaitan Nettoyage }
