/*=========================================================================
*
* EDTsobj.hpp
*
*
* Version			1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#ifdef ACTIVE_EDITOR

#ifndef __EDTSOBJ_HPP__
#define __EDTSOBJ_HPP__


#include "stdafx.h"
#include <afxtempl.h>

#pragma warning(disable:4786)

#define HieFriend
#include "incSPO.h"
#undef HieFriend

#include "itf/CPASObj.hpp"

#include "SCR.h"

class EDT_HierarchyEditor;
class EDT_TempModif;


//**************************************
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
//**************************************


//=====================================================================
// type name for super objects (constant)
#define C_szSuperObjectTypeName "SuperObject"
//=====================================================================

/*===========================================================================
*		Description:	class EDT_SuperObject
*		Creation date:
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                        Author:
*=========================================================================*/
class EDT_SuperObject :	public CPA_SuperObject
{

private:
	// matrix
	CPA_SectionObject	*m_pMatrixSection;
	// temporary modification
	EDT_TempModif		*m_pTempModif;
	//CPA2 Stegaru Cristian 98-02
	CString				m_csModifSectionName;
	CString				m_csInitialSPOName;
	//End CPA2 Stegaru Cristian 98-02

public:

//================ Constructors ===========================

    EDT_SuperObject (EDT_HierarchyEditor		*pEditor,
					 HIE_tdxHandleToSuperObject hEngineSO, 
					 tdeSaveStatus				eStatus, 
					 tdeTypeSO					eTypeSO		= C_NoType, 
					 CString					csName		= "", 
					 CString					csFileName	= ""
					 ); 

	EDT_SuperObject (EDT_HierarchyEditor		*pEditor,
					 tdeSaveStatus				eStatus, 
					 tdeTypeSO					eTypeSO , 
					 CString					csName		= "", 
					 CString					csFileName	= ""
					 );

    EDT_SuperObject (EDT_SuperObject &r_oSource);

    ~EDT_SuperObject (void);


//ANNECY CO SPOFLAG 03/02/98
//================ Flag ===========================

	unsigned long	GetFlags (void);
	void			SetFlags (unsigned long ulFlags);
//ANNECY CO SPOFLAG 

//ANNECY CO SPOFLAG 05/02/98
	BOOL		fn_bIsEditProtected (void);
//ENDANNECY CO SPOFLAG

//ANNECY Shaitan Transparency 26/03/98 {
//================ Transparency ===========================
	float fn_fGetTransparencyLevel (void);
	void  fn_vSetTransparencyLevel (float fNewLevel);
//ENDANNECY Shaitan Transparency }
	
	
//================ Engine Struct ===========================

	void SetEngineStruct (HIE_tdxHandleToSuperObject hEngineSO);

	HIE_tdxHandleToSuperObject GetEngineStruct (void) { return GetStruct(); }

//================ Editor ===========================

	EDT_HierarchyEditor * GetSuperObjectEditor (void) { return (EDT_HierarchyEditor *) CPA_SuperObject::GetEditor(); }

//================ Section Object ===========================

	void fn_vInitSectionName	(const CString csEngineFileName);
	void fn_vUpdateSectionName	(void);

//================ Matrix Section ===========================

	CPA_SectionObject *	GetMatrixSection		(void) { return m_pMatrixSection; }
	CString				GetMatrixSectionName	(void);

//================ Dialogs ===========================

	CString GetNameToDraw	(void);
	CString	GetTypeToDraw	(void);
	CString GetOwnerToDraw	(void);

//================ Object & DLL ===========================

	void MyObjectIsAlsoACopy	(EDT_SuperObject *p_oSource);


//================ Name & Name to draw ===========================

	void	SetNameForCopy		(EDT_SuperObject *pDesc);
	void	SetNameForPaste		(EDT_SuperObject *pDesc);

	CString	GetOwnerName		(void);
	CString	GetLevelName		(void);

//================ Modifications ===========================

	// moves
	void fn_vTranslate			(MTH3D_tdstVector *p_stVector, BOOL bAbsolute);
	void fn_vRotate				(POS_tdstCompletePosition *p_stMatrix);
	void fn_vSetPosition		(POS_tdstCompletePosition *pRefMatrix);

	// parent
	void fn_vInsertUnderParent	(EDT_SuperObject *pEdParent, EDT_SuperObject *pBrother = NULL, BOOL bUpdatePos = FALSE, POS_tdstCompletePosition *pRefMatrix = NULL);
	BOOL fn_bAcceptAsParent		(EDT_SuperObject *pEdObj);
	BOOL fn_bAcceptAsChild		(EDT_SuperObject *pEdObj);

	// protected childs
	void fn_vRemoveNonProtectedChilds (void);

//================ Temporary Modifications ===========================

	EDT_TempModif * GetTemporaryModif			(void)	{ return m_pTempModif; }
	CString			GetTempModifSectionName		(void);
	//CPA2 Stegaru Cristian 98-02
	void			mfn_vSetTempModifSectionName (CString csModifSectionName) { m_csModifSectionName = csModifSectionName;}
	void			mfn_vSetInitialSPOName (CString csInitialSPOName) { m_csInitialSPOName = csInitialSPOName;}
	CString			mfn_csGetInitialSPOName () { return m_csInitialSPOName;}
	//End CPA2 Stegaru Cristian 98-02
	BOOL			fn_bIsTemporary				(void)	{ return (m_pTempModif != NULL); }

	void	SetTemporaryModif			(EDT_TempModif *pTempSO);
	BOOL	fn_bInitTemporarySO			(void);
	void	fn_vUpdateTemporaryModif	(CString csTypeModif, BOOL bAddModif);
		
	void fn_vSetOnState		(const CString csModificationType, BOOL bOnInitialState);
    void fn_vValidateState	(const CString csModificationType, BOOL bInitialState);
	BOOL fn_bCanBeValidated (void);

//================ Notify ===========================

	void fn_vNotifySave		(void);
	void fn_vNotifyUnSave	(void);
	void fn_vNotifyRestore	(void);
	void fn_vNotifyRename	(void);

	BOOL fn_bCanBeNotified	(void); 

	tdeMissingCriteria	fn_eCheckValidity (const CString csNewName);

	void fn_vUpdateReference (CPA_SaveObject *pReferencedObject);
	
	CString fn_csComputeReferencedSectionName (const CString csNewName) ;

//================ Scripts ===========================
	
	void fn_vSaveMatrix (SCR_tdst_File_Description *p_stFile, GEO_tdxHandleToMatrix hMatrix, CString csMatrixName);
	
	static void CallBackSave		(SCR_tdst_File_Description *p_stFile, char *szSectionName, void *p_vData, SCR_tde_Ntfy_Action eAction);
	static void CallBackSaveMatrix	(SCR_tdst_File_Description *p_stFile, char *szSectionName, void *p_vData, SCR_tde_Ntfy_Action eAction);

	// load
	static SCR_tde_Anl_ReturnValue	CallBackLoadModif (SCR_tdst_File_Description *p_fFile, char *szName, char *szParams[], SCR_tde_Anl_Action eAction);

//================ Display ===========================

	void SetDrawingFlag (tdeDrawingFlag eNewFlag);

//================ Matrix ===========================

	BOOL fn_bHasSamePosition (GEO_tdxHandleToMatrix hInitialMatrix, GEO_tdxHandleToMatrix hFinalMatrix);

// Begin Silviu Simen 18 August 1998 Cut/Paste Mechanism
	void fn_vSetOnlyPosition (MTH3D_tdstVector *pTransMatrix);
// End Silviu Simen 18 August 1998 Cut/Paste Mechanism
};


#endif //__EDTSOBJ_HPP__

#endif //ACTIVE_EDITOR
