/*=========================================================================
* 
* EDTModif.hpp :  Class Modif* 
* 
*
* Version			1.0
* Creation date		
* Revision date
*
* Shaitan
*=======================================================================*/
#ifdef ACTIVE_EDITOR


#ifndef __EDTMODIF_HPP__
#define __EDTMODIF_HPP__

//**************************************
#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
//**************************************


#define TYPE_DELETE		1
#define TYPE_INSERT		2
#define TYPE_MOVE		3
#define TYPE_NAME		4
#define TYPE_PARENT		5
#define TYPE_PASTE		6
#define TYPE_RENAME		7
#define TYPE_STATE		8
#define TYPE_VALIDATE	9


#include "itf/CPAMdf.hpp"
#include "itf/CPASObj.hpp"
#include "itf/objdllb.hpp"
#include "itf/CPALists.hpp"

class EDT_HierarchyEditor;
class EDT_SuperObject;
class EDT_TempModif;
class CPA_Interface;

//CPA2 Stegaru Cristian 98-02
static char szStaticExt [] = {".SPO"};
static char szModifExt [] = {".MDT"};
static char szFinalModifExt [] = {".MDF"};
//End CPA2 Stegaru Cristian 98-02

//#################################################################################
// TO SAVE PARENT MODIFICATION
//#################################################################################
/*===========================================================================
		List For DLLs
=========================================================================*/
class EDT_ParentByType : public CObject
{
public:
	CPA_ObjectDLLBase *m_poDLL;
	CPA_List<EDT_SaveParents> m_stListObjects;
	CPA_List<EDT_SaveParents> m_stListProtected;

	EDT_ParentByType (CPA_ObjectDLLBase *p_oDLL)
	{
		m_poDLL = p_oDLL;
		m_stListObjects.RemoveAll();
		m_stListProtected.RemoveAll();
	}

	~EDT_ParentByType (void)
	{
		while (m_stListObjects.GetCount() > 0)
			delete m_stListObjects.RemoveTail();
		while (m_stListProtected.GetCount() > 0)
			delete m_stListProtected.RemoveTail();
	}
};


//#################################################################################
// TO SAVE POSITION MODIFICATION
//#################################################################################

/*===========================================================================
		List For DLLs
=========================================================================*/
class EDT_PosByType : public CObject
{
public:
	CPA_ObjectDLLBase *m_poDLL;
	// moved objects
	CPA_List<EDT_SavePos> m_stListObjects;
	CPA_List<EDT_SaveGlobalPos> m_stListConcerned;
	// protected objects
	CPA_List<EDT_SavePos> m_stListProtected;
	CPA_List<EDT_SaveGlobalPos> m_stListProtectConcerned;

	EDT_PosByType (void) 
	{
		m_stListObjects.RemoveAll();
		m_stListConcerned.RemoveAll();
		m_stListProtected.RemoveAll();
		m_stListProtectConcerned.RemoveAll();
	}

	EDT_PosByType (CPA_ObjectDLLBase *p_oDLL)
	{
		m_poDLL = p_oDLL;
		m_stListObjects.RemoveAll();
		m_stListConcerned.RemoveAll();
		m_stListProtected.RemoveAll();
		m_stListProtectConcerned.RemoveAll();
	}

	~EDT_PosByType (void)
	{
		while (!(m_stListObjects.IsEmpty()))
			delete m_stListObjects.RemoveTail();
		while (!(m_stListConcerned.IsEmpty()))
			delete m_stListConcerned.RemoveTail();
		while (!(m_stListObjects.IsEmpty()))
			delete m_stListObjects.RemoveTail();
		while (!(m_stListProtectConcerned.IsEmpty()))
			delete m_stListProtectConcerned.RemoveTail();
	}
};


//#################################################################################
// CLASS MODIF*
//#################################################################################

/*===========================================================================
*		Description:	ModifInsert 
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:		     Author:         
*=========================================================================*/
class EDT_ModifInsert : public CPA_Modif
{
private:
	EDT_HierarchyEditor *m_pEditor;
	BOOL				m_bFirstTime;
	BOOL				m_bSelect;
	BOOL				m_bUpdate;
	
	CPA_List<EDT_SaveParents>	m_stListInsert;
	EDT_SuperObject				*m_pInsertedObject;
	EDT_SuperObject				*m_pParent;
	EDT_SuperObject				*m_pBrother;
	CString						m_csType;

	tdstPosition m_stPosition;
// Cut Paste
	MTH3D_tdstVector			m_stTranslation, m_stLocale;
  	BOOL						m_bUpdatePosition;
	BOOL						m_bCutSpecial;
// Cut Paste

public:
// parent editor
	EDT_HierarchyEditor * GetParentEditor	(void) { return m_pEditor; }
	CPA_Interface		* GetInterface		(void);

// creation
	EDT_ModifInsert(EDT_HierarchyEditor *pEditor, EDT_SuperObject *pEdObj,
					EDT_SuperObject *pParent, tdstPosition *p_stPosition, 
					EDT_SuperObject *pBrother = NULL, BOOL bUpdateDrawing = TRUE,
					BOOL bSelectOnInsertion = TRUE, BOOL pBlock = FALSE,
					BOOL bUpdatePosition=FALSE, 
					BOOL bCutSpecial=FALSE); // Silviu Simen 18 August 1998 Cut/Paste of Special Obj

	~EDT_ModifInsert (void);

// actions
	BOOL Do (void);
	BOOL Undo (void);

// functions
	void fn_vFillListForInsertion (EDT_SuperObject *pEdObj, EDT_SuperObject *pParent);
	void fn_vSendMessageInsert (tdeTypeModif eType, tdstPosition *p_stPosition);
};


/*===========================================================================
*		Description:	ModifDelete 
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                    Author:         
*=========================================================================*/
class EDT_ModifDelete : public CPA_Modif
{
private:
	EDT_HierarchyEditor *m_pEditor;
	BOOL				m_bFirstTime;
	BOOL				m_bUpdate;
	BOOL				m_bDestroy;
	BOOL				m_bSelect;

	CPA_List<EDT_ParentByType>  m_lstModifByType;
	CPA_List<EDT_SaveParents>	m_stListObjects;
	CPA_List<EDT_SaveParents>	m_stListForTools;
	BOOL						m_bDeleted;
	CString						m_csType;
// Begin Silviu Simen 18 August 1998 Cut/Paste of Special Obj.
	BOOL						m_bCutSpecial; 
// End Silviu Simen 18 August 1998 Cut/Paste  of Special Obj.

public:
// parent editor
	EDT_HierarchyEditor * GetParentEditor	(void) { return m_pEditor; }
	CPA_Interface		* GetInterface		(void);

// creation 
	EDT_ModifDelete (EDT_HierarchyEditor *pEditor, CPA_List<EDT_ListByDLL> *pSelectByDLL, 
					 CString csType, BOOL bUpdateDrawing = TRUE, BOOL bDestroy = TRUE,
					 BOOL bSelectOnUndo = TRUE, BOOL pBlock = FALSE,
 					 BOOL bCutSpecial = FALSE); // Silviu Simen Cut/Paste of Special Objs.

	EDT_ModifDelete (EDT_HierarchyEditor *pEditor, EDT_SuperObject *pObjectToDelete, 
					 CString csType, BOOL bUpdateDrawing = TRUE, BOOL bDestroy = TRUE,
					 BOOL bSelectOnUndo = TRUE, BOOL pBlock = FALSE,
					 BOOL bCutSpecial = FALSE); // Silviu Simen Cut/Paste of Special Objs.

	~EDT_ModifDelete (void);

// actions 
	BOOL Do (void);
	BOOL Undo (void);

// functions
	EDT_ParentByType * fn_pstFindParentListFromObj (EDT_SuperObject *pEdObj);
	void fn_vFillListForDLLs (EDT_SuperObject *pEdObj);
// message
	void fn_vSendMessageDelete (tdeTypeModif eType);
};


/*===========================================================================
*		Description:	ModifPaste
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                    Author:         
*=========================================================================*/
class EDT_ModifPaste : public CPA_Modif
{
private:
	EDT_HierarchyEditor *m_pEditor;
	BOOL				m_bFirstTime;
	BOOL				m_bUpdate;

	CPA_List<EDT_ParentByType> m_lstModifByType;
	CPA_List<EDT_SaveParents>  m_stListObjects;
	CPA_List<EDT_SaveParents>  m_stListForTools;
	BOOL					   m_bDone;
	CString					   m_csType;

public:
// parent editor
	EDT_HierarchyEditor * GetParentEditor	(void) { return m_pEditor; }
	CPA_Interface		* GetInterface		(void);

// creation 
	EDT_ModifPaste(EDT_HierarchyEditor *pEditor, CPA_List<EDT_SaveParents> *pListObj, 
			CString csType, long lNbCopy, BOOL bUpdateDrawing = TRUE); 
	
	~EDT_ModifPaste (void);

// actions 
	BOOL Do (void);
	BOOL Undo (void);
	
// functions
	EDT_ParentByType * fn_pstFindParentListFromObj (EDT_SuperObject *pEdObj);
	void fn_vFillListForDLLs (EDT_SuperObject *pEdObj);

	void fn_vSendMessageCopy (tdeTypeModif eType);
};


/*===========================================================================
*		Description:	ModifParent 
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                    Author:         
*=========================================================================*/
class EDT_ModifParent : public CPA_Modif
{
private:
	EDT_HierarchyEditor *m_pEditor;
	BOOL				m_bFirstTime;
	BOOL				m_bUpdate;

	CPA_List<EDT_ParentByType>	m_lstModifByType;
	CPA_List<EDT_SaveParents>	m_stListForTools;
	CString						m_csType;

public:
// parent editor
	EDT_HierarchyEditor * GetParentEditor	(void) { return m_pEditor; }
	CPA_Interface		* GetInterface		(void);

// creation 
	EDT_ModifParent(EDT_HierarchyEditor *pEditor, CPA_List<EDT_ListByDLL> *pSelectByDLL, 
		EDT_SuperObject *pParent, CString csType, BOOL bUpdateDrawing = TRUE); 

	EDT_ModifParent(EDT_HierarchyEditor *pEditor, CPA_List<EDT_SaveParents> *pListModif, CString csType); 

	~EDT_ModifParent (void);

// actions 
	BOOL Do (void);
	BOOL Undo (void);

// functions
	void fn_vSendMessageParent (tdeTypeModif eType);
	EDT_ParentByType * GetOrCreateListByDLL (CPA_ObjectDLLBase *p_oDLL);
};


/*===========================================================================
*		Description:	ModifMove 
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
class EDT_ModifMove : public CPA_Modif
{
private:
	EDT_HierarchyEditor *m_pEditor;
	BOOL				m_bFirstTime;
	BOOL				m_bUpdate;

	CPA_List<EDT_PosByType>		m_lstModifByType;
	EDT_PosByType				m_stListForTools;
	EDT_ModifParent				*m_pModifParent;
	CString						m_csType;

public:
// paent editor
	EDT_HierarchyEditor * GetParentEditor	(void) { return m_pEditor; }
	CPA_Interface		* GetInterface		(void);

// creation
	EDT_ModifMove(EDT_HierarchyEditor *pEditor, CPA_List<EDT_ListByDLL> *pSelectByDLL, 
				  CString csType, BOOL bUpdateDrawing = TRUE); 

	~EDT_ModifMove (void);

// actions
	BOOL Do (void);
	BOOL Undo (void);
	BOOL Cancel (void);

// functions
	void fn_vSendMessageMove	(tdeTypeModif eType);
	void fn_vInitListModif		(CPA_List<EDT_SaveParents> *pListModif);
	void fn_vRegisterPositions	(void);
};


/*===========================================================================
*		Description:	ModifName 
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
class EDT_ModifName : public CPA_Modif
{
private:
	EDT_HierarchyEditor *m_pEditor;
	BOOL				m_bFirstTime;

	CPA_ObjectDLLBase	*m_poDLL;
	EDT_SuperObject		*m_pModifiedObject;
	CString				m_csInitialName;
	CString				m_csFinalName;
	CString				m_csType;
	BOOL				m_bRenameObject;
	BOOL				m_bHasObjectName;

public:
// paent editor
	EDT_HierarchyEditor * GetParentEditor	(void) { return m_pEditor; }
	CPA_Interface		* GetInterface		(void);

// creation
	EDT_ModifName(EDT_HierarchyEditor *pEditor, EDT_SuperObject	*pModifiedObject, CString csFinalName, BOOL bRenameObject = TRUE); 
	~EDT_ModifName (void);

// actions
	BOOL Do (void);
	BOOL Undo (void);

// functions
	void fn_vSendMessageName (tdeTypeModif eType);
};


/*===========================================================================
*		Description:	ModifState 
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
class EDT_ModifState : public CPA_Modif
{
private:
	EDT_HierarchyEditor *m_pEditor;
	BOOL				m_bFirstTime;

	EDT_SuperObject		*m_pModifiedObject;
	CString				m_csTypeModif;
	BOOL				m_bInitialState;

	GEO_tdxHandleToMatrix	m_hInitialMatrix;
	GEO_tdxHandleToMatrix	m_hFinalMatrix;
	EDT_SuperObject			*m_pInitialParent;
	EDT_SuperObject			*m_pFinalParent;
	CString					m_csInitialName;
	CString					m_csFinalName;

	CPA_List<EDT_ParentByType>  m_lstParentByType;
	CPA_List<EDT_SaveParents>	m_stParentForTools;

	CPA_List<EDT_PosByType>		m_lstPosByType;
	EDT_PosByType				m_stPosForTools;

public:
// parent editor
	EDT_HierarchyEditor * GetParentEditor	(void) { return m_pEditor; }
	CPA_Interface		* GetInterface		(void);
// creation
	EDT_ModifState(EDT_HierarchyEditor *pEditor, EDT_SuperObject *pModifiedObject, 
				   CString csTypeModif, BOOL bInitialState); 
	~EDT_ModifState (void);

// actions
	BOOL Do (void);
	BOOL Undo (void);

// functions
	void fn_vInsertInHierarchy (void);
	void fn_vRemoveFromHierarchy (void);
	
	EDT_ParentByType * fn_pstFindParentListFromObj (EDT_SuperObject *pEdObj);
	void			   fn_vFillListForDelete	   (EDT_SuperObject *pEdObj, EDT_SuperObject *pInitialFather, EDT_SuperObject *pFinalFather);

	EDT_PosByType * fn_pstFindPosListFromObj (EDT_SuperObject *pEdObj);
	void			fn_vFillListForMove		 (EDT_SuperObject *pEdObj);
	void			fn_vRegisterPositions	 (void);

	void fn_vSendMessageCreate	(tdeTypeModif eType);
	void fn_vSendMessageDelete	(tdeTypeModif eType);
	void fn_vSendMessageParent	(tdeTypeModif eType);
	void fn_vSendMessageMove	(tdeTypeModif eType);
	void fn_vSendMessageName	(tdeTypeModif eType);
};


/*===========================================================================
*		Description:	ModifState 
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
class EDT_ModifValidate : public CPA_Modif
{
private:
	EDT_HierarchyEditor *m_pEditor;
	BOOL				m_bFirstTime;

	EDT_ModifState		*m_pModifState;
	EDT_SuperObject		*m_pModifiedObject;
	EDT_TempModif		*m_pTempModif;
	CString				m_csTypeModif;
	BOOL				m_bInitialState;

	BOOL					  m_bCreated;
	BOOL					  m_bDeleted;
	CString					  m_csOriginalName;
	EDT_SuperObject			* m_pOriginalFather;
	GEO_tdxHandleToMatrix	  m_hOriginalPosition;

public:
// parent editor
	EDT_HierarchyEditor * GetParentEditor	(void) { return m_pEditor; }
	CPA_Interface		* GetInterface		(void);
// creation
	EDT_ModifValidate (EDT_HierarchyEditor *pEditor, EDT_SuperObject *pModifiedObject, 
					   CString csTypeModif, BOOL bInitialState); 
	~EDT_ModifValidate (void);

// actions
	BOOL Do (void);
	BOOL Undo (void);
};

#endif // __EDTMODIF_HPP__
#endif // ACTIVE_EDITOR

