//*****************************************************************************
//*  _zInterf.hpp                                                             *
//*****************************************************************************
//*                                                                           *
//* This file contains the definition of the ZDx_Interface class.             *
//*                                                                           *
//*****************************************************************************
//* Author : Alexis Vaisse                                                    *
//*****************************************************************************


#ifndef __ZINTERF_HPP__
#define __ZINTERF_HPP__

#pragma once

// if you want only one instance of your DLL, activate the next line
#define DLL_ONLY_ONE_INSTANCE

#include "IncITF.h"

// Actors dll "include"
class CPA_Actor;
class EdtList;
class CPA_tdoNameList;

// Physical Object dll "include"
class EditorPO;

// Family dll "include"
// ANNECY AV CLEAN_MEC {
//class CPA_TestPointsList;
// END ANNECY AV }

typedef enum eZDxConstraintType_ { eZDxNormal , eZDxModifyAllActors , eZDxModifyOneActor } tdeZDxConstraintType;

// personal "include"
#include "_zObject.hpp"
class ZDx_Object;
class ZDx_Modif;
class CDisplayControlWindow;
class CList1Window;
class CList2Window;
class CZDxInfoWindow;
class EdtList;

// Flags for the function : ShowZDxOfInstance
#define  C_ucHideAllZDx            0
#define  C_ucShowZDD               1
#define  C_ucShowZDE               2
#define  C_ucShowZDM               4
#define  C_ucShowZDR               8
#define  C_ucShowAllZDx            (C_ucShowZDD + C_ucShowZDE + C_ucShowZDM + C_ucShowZDR)
// ANNECY AV CLEAN_MEC {
//#define  C_ucShowTestPoint        16
// END ANNECY AV }

// Constant for the RefreshDisplay function
#define  C_lOnInsertActor          1
#define  C_lOnDeleteActor          2
#define  C_lOnInsertZDxOfActor     3
#define  C_lOnDeleteZDxOfActor     4
#define  C_lOnInsertZDxOfModule    5
#define  C_lOnDeleteZDxOfModule    6
#define  C_lOnInsertBV             7
#define  C_lOnDeleteBV             8
// ANNECY AV CLEAN_MEC {
//#define  C_lOnInsertTestPoint      9
//#define  C_lOnDeleteTestPoint     10
// END ANNECY AV }
#define  C_lOnSelectActor         11
#define  C_lOnSelectZDxOfActor    12
#define  C_lOnMouseMove           13
#define  C_lOnSelChangeTreeCtrl1  14
#define  C_lOnSelChangeTreeCtrl2  15
#define  C_lOnSelChangeCombo2     16
#define  C_lOnCheckBoxShowActor   17
#define  C_lOnCheckBoxShowModule  18
#define  C_lOnCheckBoxesZDx       19
#define  C_lOnButtonAllZDx        20
#define  C_ucSetCamera            21
#define  C_lRedrawZDxObject       22
#define  C_lModifZDx              23
#define  C_lModifDeleteDo         24
#define  C_lModifDeleteUndo       25
#define  C_lShowZDxOfAllActors    26
#define  C_lOnButtonAllActors     27
#define  C_lShowZDxSelectedActor  28
#define  C_lHideZDxSelectedActor  29
#define  C_lShowModuleZDxActor    30
#define  C_lHideModuleZDxActor    31
#define  C_lPopupMenuShowZone     32
#define  C_lShowZDxOfOneModule    33
#define  C_lShowZDxOfAllModule    34
#define  C_lEnterBoundingVolume   35
#define  C_lLeaveBoundingVolume   36
// ANNECY AV CLEAN_MEC {
//#define  C_lEnterTestPoint        37
//#define  C_lLeaveTestPoint        38
// END ANNECY AV }
#define  C_lLButtonDown           39

// Name of the list of ZDx models
#define C_szZDxListName           "Zone"

//-----------------------------------------------------------------------------
// stSizeChangingMode structure
// used when the user changes the size of the ZDx object with the mouse
//-----------------------------------------------------------------------------
typedef struct stSizeChangingMode_
{
    BOOL              bActiveMode;              // Are we in "size changing" mode ?
    CPA_SuperObject * pSelectedZDxSuperObject;  // The ZDx object whose size is changing
    MTH3D_tdstVector    GlobalSelectedPoint;      // The 3D coordinates of the point of the ZDx object pointed by the mouse in the global repere
    MTH3D_tdstVector    LocalSelectedPoint;       // The 3D coordinates of the same point in the local repere
    MTH3D_tdstVector    CenterInMousePlane;       // The 3D coordinates of the center of the sphere, projected into the plane where the mouse moves into
    ZDx_Modif       * pZDxModif;
    BOOL              bChangeTopPointOfCone;    // When changing the size of a cone : if TRUE, change the top point, else change the radius
} tdstSizeChangingMode;


//-----------------------------------------------------------------------------
// Object DLL interface class
//-----------------------------------------------------------------------------
class ZDx_Interface : public CPA_ObjectDLLBase
{
public:
    ZDx_Interface (void);                // Constructor


//-------------------------------------------
//--- Virtual functions of the base class ---                                            (file : _zInterf.cpp)
//-------------------------------------------

// --- General functions for editor ---
      
public:
    void          fn_vJustAfterRegistered(void);                                         // Called for the first initializations
    void          fn_vConstruct          (void);                                         // Called once the 3D window is constructed
    void          fn_vBeforeEditor       (void);                                         // Called just before entering editor mode
    void          fn_vBeforeEngine       (void);                                         // Called just before leaving editor mode
    void          fn_vOnActivateEditor   (CPA_List<CPA_BaseObject> * pParams , BOOL bBackActivated = FALSE);
                                                                                         // Called when somebody wants to open the ZDx editor
	void          fn_vOnCloseEditor      (void);                                         // Called when somebody wants to close the ZDx editor
    BOOL          fn_bHasGainedFocus     (void);                                         // Called when the dll becomes the current dll
    void          fn_vHasLostFocus       (void);                                         // Called when the dll is no longer the current dll
    long          OnQueryAction          (CPA_EditorBase * pCallingDll , WPARAM , LPARAM);
                                                                                         // To communicate with the dll
    long          OnQueryInfos           (CPA_EditorBase * pCallingDll , WPARAM , LPARAM);
                                                                                         // To communicate with the dll
/*===========================================================================
	Dialog Bar - Mircea Dunka 31 Aug. 1998
=========================================================================*/
public:
	void fn_vDefineDlgBarBtnIcon (tde_DlgBarCategory wCategory, tds_DlgBarBtn *_pDlgBarBtn);


// --- Menu ---

public:
    BOOL          fn_bDefineSubMenu      (EDT_SubMenu   * _p_oEDTSubMenu);               // This function lets the dll add an entry in a sub menu
    void          _OnSubMenuCommand      (EDT_SubMenu   * _p_oEDTSubMenu,UINT uiMsgID);  // Called when the user clics on an entry in a sub menu
    BOOL          fn_bDefinePopupMenu    (EDT_PopUpMenu * pPopup , CPA_List<CPA_SuperObject> * pSelection , BOOL bAsCurrentEditor);
                                                                                         // This function lets the dll add an entry in the popup menu
    void          _OnPopUpMenuCommand    (UINT m_IDCmdMsg);                              // Called when the user clics on an entry in the popup menu


// --- Questions to manage ZDx objects ---

public:
    BOOL          fn_bCanActivateEditor  (CPA_List<CPA_BaseObject> * _pParams);          // Return if the editor can be activated
    BOOL          fn_bCanHandleThisType  (long lEngineType);                             // The type of the objects we can handle
    tdePermission fn_eAcceptNewEditor    (CPA_EditorBase * pNewDLL)                      // When another editor is activated, we want to close the window
                                       { return C_CloseBefore; }
    BOOL          fn_bAcceptModifRotate  (CPA_List<CPA_SuperObject> * pListObjects , tdeStatus eStatus)
                                                                                         // We don't want the rotation matrix of a ZDx object to be modified
                                       { return eStatus != C_AsConcernedDLL; }
    BOOL          fn_bAcceptModifScale   (CPA_SuperObject * pEdObj , tdeStatus eStatus)  // We don't want the scale of a ZDx object to be modified
                                       { return eStatus != C_AsConcernedDLL; }
    BOOL          fn_bAcceptModifParent  (CPA_List<CPA_SuperObject> * pListObjects , tdeStatus eStatus);
                                                                                         // One cannot change the parent of a zone
    BOOL          fn_bAcceptModifCopy    (CPA_List<CPA_SuperObject> * pListObjects , tdeStatus eStatus);
                                                                                         // A ZDx object can be copied
    BOOL          fn_bAcceptAsChild      (CPA_BaseObject * pParent, CPA_BaseObject * pChild)
                                       { return FALSE; }                                 // We don't want any child for a ZDx object
    BOOL          fn_bAcceptAsParent     (CPA_BaseObject * pChild , CPA_BaseObject * pParent);
                                                                                         // Only actors or modules can be parent for a ZDx object
    BOOL          fn_bAcceptModifInsert  (CPA_SuperObject * pSuperObjectToInsert, CPA_SuperObject *pParent, tdeStatus eStatus);
                                                                                         // Called before a object is inserted into the hierarchy

// --- Functions to manage ZDx objects ---

public:
    void                  fn_vInitListByType       (CPA_World * pWorld);                 // To register the different types of objects
  	void                  fn_vInitListsOfModels    ();                                   // To register the different types of models
    tdeTypeSO		      GetTypeInstance		   (CString csTypeName , CString csModelName)
                                                   { return C_Protected; }               // Return the type of the super object of a ZDx object
//ANNECY Shaitan EmptySectors 25/02/98
	tdeSaveStatus		  GetStatusInstance		   (CString csTypeName, CString csModelName)
                                                   { return E_ss_NoSave; }
//ENDANNECY Shaitan EmptySectors
    CPA_SuperObject *     GetNewInstance           (CString csTypeName , CString csModelName , CPA_SuperObject * pParent);
                                                                                         // To insert a new ZDx object into the world
    BOOL                  fn_bChooseInsertPosition (CPA_SuperObject * pNewInstance , CPA_SuperObject * pParent ,
                                                    tdstPosition * pPosition);           // To choose the position where to insert the ZDx object
    CPA_SuperObject *     GetParentForInsertion	   (CString csTypeName , CString csModelName , tdstPosition * pPosition);
                                                                                         // To choose the parent when inserting a ZDx object
    CPA_BaseObject  *     Duplicate                (CPA_BaseObject * pObject, CPA_SuperObject * pSuperObject);
                                                                                         // To copy a ZDx object
    CPA_SuperObject *     GetCopyOfProtectedChild  (CPA_SuperObject * pChild, CPA_SuperObject * pNewOwner);
                                                                                         // To copy a protected child of a ZDx object
	void                  fn_vComputeBoundingVolume (CPA_BaseObject * _pObject);         // Compute bounding volume of a ZDx object
	ACP_tdxHandleOfObject fn_hGetBoundingVolume     (CPA_BaseObject * _pObject);         // Return bounding volume of a ZDx object


// --- Modifications ---
    
public:
    void          fn_vOnModifInsert      (CPA_SuperObject * pEdObj    , CPA_SuperObject * pParent, 
                                          tdstPosition * p_stPosition , tdeTypeModif , tdeStatus eStatus);
                                                                                         // Called when an object is inserted
    void          fn_vOnModifDelete      (CPA_List<EDT_SaveParents> * , tdeTypeModif , tdeStatus eStatus);
                                                                                         // Called when an object is deleted
    void          fn_vOnCancelInsertion  (CPA_SuperObject * _pSuperObject);
                                                                                         // This function is called when an insertion is canceled
    void          fn_vOnModifCopy        (CPA_List<EDT_SaveParents> * , tdeTypeModif , tdeStatus eStatus);
                                                                                         // Called when an object has been copied    
    void          fn_vOnBeginMove        (CPA_List<CPA_SuperObject> * pListObjects   ,
                                          CPA_List<CPA_SuperObject> * pListConcerned , tdeStatus eStatus);
	                                                                                     // This funtion is called just before a move
//CPA2 (Corneliu Babiuc) 15-04-1998
    void          fn_vOnMoving           (CPA_List<CPA_SuperObject> * pListObjects ,
	                                      CPA_List<CPA_SuperObject> * pListConcerned, tdeStatus eStatus);
																						// This function is called when a ZDx object is moved
//END CPA2 (Corneliu Babiuc) 15-04-1998
    void          fn_vOnModifMove        (CPA_List<EDT_SavePos>     * pListObjects , CPA_List<EDT_SaveGlobalPos> * pListConcerned ,
                                          tdeTypeModif eType, tdeStatus eStatus);        // This function is called after a ZDx object has been moved
    void          fn_vOnSelect           (CPA_SuperObject *pSuperObject, tdeTypeModif eType, tdeStatus eStatus);
                                                                                         // This function is called when a ZDx Object is selected

// --- Windows messages ---
      
public:
    BOOL          _OnKeyDown             (UINT nChar , UINT nRepCnt , UINT nFlags);      // Called when a key is pressed
    BOOL          _OnKeyUp               (UINT nChar , UINT nRepCnt , UINT nFlags);      // Called when a key is released
    BOOL          _OnMouseMove           (UINT nFlags, tdstMousePos * p_stPos, MTH3D_tdstVector * p_stObject);
                                                                                         // Called when the mouse moves
    BOOL          _OnLButtonDown         (UINT nFlags, tdstMousePos * p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo * p_stObject);
                                                                                         // Called when the left button is pressed
    BOOL          _OnLButtonUp           (UINT nFlags, tdstMousePos * p_stPos);          // Called when the left button is released
//ROMTEAM WorldEditor
	BOOL          _OnLButtonDblClk       (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo); // Called when the left button is double clicked 
//ENDROMTEAM WorldEditor


//--------------------------
//--- Internal functions ---
//--------------------------
    
// --- Internal functions for questions ---

private:
    BOOL          AcceptModifInsertZDxOfActor     (CPA_SuperObject * pSuperObjectToInsert , CPA_SuperObject * pParent);
                                                                                         // Called before a ZDx of actor is inserted into the hierarchy
    BOOL          AcceptModifInsertZDxOfModule    (CPA_SuperObject * pSuperObjectToInsert , CPA_SuperObject * pParent);
                                                                                         // Called before a ZDx of module is inserted into the hierarchy
    BOOL          AcceptModifInsertBoundingVolume (CPA_SuperObject * pSuperObjectToInsert , CPA_SuperObject * pParent);
                                                                                         // Called before a ZDx which is a bounding volume is inserted into the hierarchy
// ANNECY AV CLEAN_MEC {
//    BOOL          AcceptModifInsertTestPoint      (CPA_SuperObject * pSuperObjectToInsert , CPA_SuperObject * pParent);
                                                                                         // Called before a ZDx which is a test point is inserted into the hierarchy
// END ANNECY AV }

    
// --- Internal functions for modifications ---

private:
    void          OnInsertActor                   (CPA_SuperObject * _pActorSuperObject);
                                                                                         // Called when an actor is inserted into the hierarchy
    void          OnDeleteActor                   (CPA_SuperObject * _pActorSuperObject);
                                                                                         // Called when an actor is deleted  from the hierarchy
    void          OnInsertZDxOfActor              (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pActorSuperObject );
                                                                                         // Called when a ZDx of actor  is inserted into the hierarchy
    void          OnDeleteZDxOfActor              (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pActorSuperObject );
                                                                                         // Called when a ZDx of actor  is deleted  from the hierarchy
    void          OnInsertZDxOfModule             (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pModuleSuperObject);
                                                                                         // Called when a ZDx of module is inserted into the hierarchy
    void          OnDeleteZDxOfModule             (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pModuleSuperObject);
                                                                                         // Called when a ZDx of module is deleted  from the hierarchy
    void          OnInsertBoundingVolume          (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pActorSuperObject , BOOL bCreateBdV = TRUE);
                                                                                         // Called when a ZDx that is a bounding volume is inserted into the hierarchy
    void          OnDeleteBoundingVolume          (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pActorSuperObject );
                                                                                         // Called when a ZDx that is a bounding volume is deleted  from the hierarchy
// ANNECY AV CLEAN_MEC {
//    void          OnInsertTestPoint               (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pActorSuperObject );
                                                                                         // Called when a ZDx that is a test point is inserted into the hierarchy
//    void          OnDeleteTestPoint               (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pActorSuperObject );
                                                                                         // Called when a ZDx that is a test point is deleted  from the hierarchy
// END ANNECY AV }
    void          OnSelectActor                   (CPA_SuperObject * _pActorSuperObject , tdeTypeModif eType);
                                                                                         // Called when an actor is selected or unselected
    void          OnSelectZDxOfActor              (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pActorSuperObject , tdeTypeModif eType);
                                                                                         // Called when a ZDx of actor is selected or unselected
    void          OnSelectModule                  (CPA_SuperObject * _pModuleSuperObject , tdeTypeModif eType);
                                                                                         // Called when a module is selected or unselected
    void          OnSelectZDxOfModule             (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pModuleSuperObject , tdeTypeModif eType);
                                                                                         // Called when a ZDx of a module is selected or unselected
    void          OnSelectBoundingVolume          (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pModuleSuperObject , tdeTypeModif eType);
                                                                                         // Called when a ZDx objct that is a bounding volume is selected or unselected
// ANNECY AV CLEAN_MEC {
//    void          OnSelectTestPoint               (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pModuleSuperObject , tdeTypeModif eType);
                                                                                         // Called when a ZDx objct that is a test point is selected or unselected
// END ANNECY AV }

//---------------------
//--- Personal data ---
//---------------------

private:
    CPA_KeyActionConfiguration
                          * m_pZDxKeyActionConfiguration;  // To use the keyboard
    BOOL                    m_bSizeKeyPressed;             // To store the key state
//CPA2 (Corneliu Babiuc) 13-04-1997
	BOOL                    m_bMoveOnlyActorKeyPressed;    // Is TRUE when the key for "moving actor only" is pressed
	BOOL                    m_bMoveOnlyActor;              // Is TRUE when the "moving actor only" mode is activated
//END CPA2 (Corneliu Babiuc) 13-04-1997
    BOOL                    m_bMoveHasBegun;               // Is TRUE when a object move has begun (to differentiate move and move-to)
    BOOL                    m_bIsSelectingObject;          // Is TRUE when selecting an object
    BOOL                    m_bIsAskingToSelectObject;     // Is TRUE when asking the hierarchy editor to select an object
    BOOL                    m_bIsShowingOrHidingZDx;       // Is TRUE when showing or hiding ZDx
    BOOL                    m_bIsInsertingZDxObject;       // Is TRUE when inserting a ZDx into the hierarchy
    BOOL                    m_bIsDeletingZDxObject;        // Is TRUE when deleting a ZDx from the hierarchy
    BOOL                    m_bIsInsideOnModifInsertDelete;// Is TRUE inside the OnModifInsert or OnModifDelete function
    BOOL                    m_bAskToEditModuleZone;        // Is TRUE when one wants to edit the module zones when one opens the editor
    long                    m_lRefreshDisplayCallerID;     // The ID of the function that will refresh the display
    CPA_SuperObject       * m_pActorSuperObjectToUnselect; // Actor  whose ZDx must be hidden
    CPA_SuperObject       * m_pModuleSuperObjectToUnselect;// Module whose ZDx must be hidden
    ACP_tdxHandleOfObject   m_GlobalBoundingVolume;        // Used to give the bounding volume of a ZDx

    CSplitFrame           * m_pSplitFrame;                 // Frame where all the windows are
    CDisplayControlWindow * m_pDisplayControlWindow;       // Window associated to the frame for the display control
    CList1Window          * m_pList1Window;                // Window associated to the frame for the first list
    CList2Window          * m_pList2Window;                // Window associated to the frame for the second list
    CZDxInfoWindow        * m_pEditWindow;                 // Window associated to the frame where one can edit a ZDx

    tdstSizeChangingMode    m_stSizeChangingMode;          // Used when the user changes the size of a ZDx object with the mouse


//--------------------------
//--- Personal functions ---                                                             (file : _zInterf.inc)
//--------------------------

// --- Get functions for windows ---

public:
    CList1Window          * GetList1Window          ()     { return m_pList1Window;          }
    CList2Window          * GetList2Window          ()     { return m_pList2Window;          }
    CZDxInfoWindow        * GetEditWindow           ()     { return m_pEditWindow;           }
    CDisplayControlWindow * GetDisplayControlWindow ()     { return m_pDisplayControlWindow; }


// --- Personal low-level functions
    
private:
    void          ConvertVectorGlobalToLocal (MTH3D_tdstVector * pDest , POS_tdstCompletePosition * pAbsoluteMatrix , MTH3D_tdstVector * pSource);
                                                                                         // Function to convert a vector from the global repere to a local repere
    void          ConvertVectorLocalToGlobal (MTH3D_tdstVector * pDest , POS_tdstCompletePosition * pAbsoluteMatrix , MTH3D_tdstVector * pSource);
                                                                                         // Function to convert a vector from a local repere to the global repere
    void          ConvertPointGlobalToLocal  (MTH3D_tdstVector * pDest , POS_tdstCompletePosition * pAbsoluteMatrix , MTH3D_tdstVector * pSource);
                                                                                         // Function to convert a point from the global repere to a local repere
    void          ConvertPointLocalToGlobal  (MTH3D_tdstVector * pDest , POS_tdstCompletePosition * pAbsoluteMatrix , MTH3D_tdstVector * pSource);
                                                                                         // Function to convert a point from a local repere to the global
//CPA2 (Corneliu Babiuc) 15-04-1998
	//this function is intended to set the local translation vector of a zone to keep unchanged its global position
	void          MoveBackZone               (CPA_SuperObject * _pZDxSuperObject, MTH3D_tdstVector * p_stVector = NULL);
//END CPA2 (Corneliu Babiuc) 15-04-1998
// --- Various functions ---

private:
    char *            GetZDxTypeName              (tdeZDxType _eZDxType);                // return the name ("Zdd"...) of the ZDx type

    CPA_SuperObject * GetSelectedActorSuperObject ();                                    // Return the selected actor. NULL if none

public:
    unsigned char     ConvertZDxTypeToEngineType  (tdeZDxType _eZDxType);                // Convert a ZDx type to a type used by the engine

    CPA_SuperObject * GetZDxSuperObject           (ZDx_Object * , CPA_SuperObject * _pParentSuperObject);
                                                                                         // Look at all childs of _pParentSuperObject to find the super object
                                                                                         // associated with the given ZDx object
    BOOL              IsInsideOnModifInsertDelete () { return m_bIsInsideOnModifInsertDelete; }// Is TRUE inside the OnModifInsert or OnModifDelete function
// --- Personal functions for models ---

private:
    void          AddModelOfZDx              ();                                         // Add all the models of ZDx into the model window
    void          RemoveModelOfZDx           ();                                         // Remove all the models of ZDx from the model window


// --- Personal functions for ZDx creation ---

private:
    CPA_SuperObject * CreateSuperObject               ();                                // Create a super object
public:
//ROMTEAM WorldEditor
    Shape3D         * CreateGraphicObject             (tdeZDxGeometricType /*, ACP_tdxHandleOfElement * */,
                                                       char * _szDataPath , const CString _csReferenceSectionName);
                                                                                         // Create graphic object (sphere, box...)
private:
    CPA_SuperObject * CreateGraphicSuperObject        (tdeZDxGeometricType /*, ACP_tdxHandleOfElement *  */,
                                                       char * _szDataPath , const CString _csReferenceSectionName);
                                                                                         // Create a graphic super object (sphere, box...)
// ENDROMTEAM WorldEditor
    
	CPA_BaseObject  * GetFamilyForNewInstance         (CPA_BaseObject * _pParent);       // Give the family of a new created ZDx object

    void              ComputeSectionNameForNewInstance (char * * _p_szDataPath , CString * _p_csReferenceSectionName ,
                                                        CPA_BaseObject * _pParent);       // Compute the data path and the reference section name to give to a created ZDx object
    CPA_SuperObject * GetNewInstanceWithSameZDxObject (ZDx_Object * pZDxObject , char * szZDxGeometricTypeName);
                                                                                         // Same function as GetNewInstance, but use an existing ZDx object
    ZDx_Object      * CreateZdxObject                 (LPARAM lParam);                   // Create a new Zdx with an existing engine zone
// ANNECY AV CLEAN_MEC {
//    void              CreateZdxTestPoints             (CPA_TestPointsList *);            // For each test point in the given list, create an associated ZDx object
// END ANNECY AV }

// --- Communication with hierarchy editor ---

public:
    void          AskHierarchyEditorToSelectObject    (CPA_SuperObject * _pSuperObject); // Ask the hierarchy editor to select an actor
    void          InsertZDxObjectIntoHierarchy        (CPA_SuperObject * _pZDxSuperObject , CPA_SuperObject * _pParentSuperObject);
                                                                                         // Ask the hierarchy editor to insert a ZDx object into the hierarchy
    void          DeleteZDxObjectFromHierarchy        (CPA_SuperObject * _pZDxSuperObject);
                                                                                         // Ask the hierarchy editor to delete a ZDx object from the hierarchy

// --- Show / Hide ZDx objects ---

private:
    void          SetDisplayFlag              (EdtList * , tdeZDxDisplayType);           // Set the display zone flag of all ZDx of the list
// ANNECY AV CLEAN_MEC {
//    void          SetDisplayFlag              (CPA_TestPointsList * , tdeZDxDisplayType);// Set the display zone flag of all test points of the list
// END ANNECY AV }
    void          SetDisplayFlagOfAllActors   (BOOL _bNewFlag);                          // Set the display zone flag of all actors

    void          SetAspectOfZDx              (CPA_SuperObject * , BOOL _bSelected);     // Set the graphical aspect of a ZDx : selected or not selected
    
public:
    void          PutZDxIntoHierarchy         (CPA_SuperObject * _pFatherSuperObject ,   // Put a ZDx as child of a super object into the hierarchy
                                               ZDx_Object      * _pZDxObject         ,
                                               BOOL              _bSelectZDx ,
                                               BOOL              _bSetEditProtected = FALSE);
private:
    void          CheckAndPutZDxIntoHierarchy (CPA_SuperObject * _pFatherSuperObject ,   // Check if the ZDx must be put into the hierarchy
                                               ZDx_Object      * _pZDxObject         ,
                                               BOOL              _bSelectZDx         ,
                                               BOOL              _bSetEditProtected = FALSE);
    void          PutListOfZDxIntoHierarchy   (EdtList         * _pListOfZDx         ,   // Put a list of ZDx as childs of a super object into the hierarchy
                                               CPA_SuperObject * _pFapherSuperObject ,
                                               ZDx_Object      * _pZDxObjectToSelect ,
                                               BOOL              _bUseDisplayFlag    ,
                                               BOOL              _bSetEditProtected = FALSE);
// ANNECY AV CLEAN_MEC {
/*
    void          PutListOfTestPointIntoHierarchy                                        // Put a list of test points as childs of a super object into the hierarchy
                                           (CPA_TestPointsList * _pTestPointList ,
                                               CPA_SuperObject * _pFapherSuperObject ,
                                               ZDx_Object      * _pZDxObjectToSelect ,
                                               BOOL              _bUseDisplayFlag    ,
                                               BOOL              _bSetEditProtected = FALSE);
*/
// END ANNECY AV }

public:
    void          ShowZDxOfActor              (CPA_SuperObject * _pActorSuperObject , unsigned char _ZDxToShow ,
                                               ZDx_Object      * _pZDxToSelect = NULL ,  // Show the ZDx of an actor which have the correct type, select one ZDx if necessaray
                                               BOOL              _bUseDisplayFlag = TRUE ,
                                               BOOL              _bSetEditProtected = FALSE);
    void          ShowAllZDxOfAllActors       (unsigned char _ucZDxToShow , BOOL _bShowOnlySelected);
                                                                                         // Show all ZDx of all actors. If _bShowOnlySelected = TRUE,
                                                                                         // show only the zones of actors that have the bDisplayZone flag set
    void          ShowZDxOfModule             (CPA_SuperObject * _pModuleSuperObject , unsigned char _ucZDxToShow ,
                                               ZDx_Object * _pZDxToSelect = NULL , BOOL _bSetEditProtected = FALSE);
                                                                                         // Show the ZDx of a module (insert ZDx objects in the hierarchy)
    void          ShowBoundingVolume          (CPA_SuperObject * _pActorSuperObject , ZDx_Object * _pBoundingVolume , BOOL _bSelectZDx);
                                                                                         // Show the bounding volume of an actor
private:
    void          ShowModuleZDxRecursiv       (CPA_SuperObject * _pModuleSuperObject);   // Show all zdx of a module and of all of its module childs
public:
    void          ShowModuleZDxOfActor        (CPA_SuperObject * _pActorSuperObject);    // Show all ZDx of all modules of an actor
private:
    void          HideModuleZDxRecursiv       (CPA_SuperObject * _pModuleSuperObject);   // Hide all zdx of a module and of all of its module childs
public:
    void          HideModuleZDxOfActor        (CPA_SuperObject * _pActorSuperObject);    // Hide all ZDx of all modules of an actor
private:
    void          ShowZDxOfAllModule          (unsigned char _ucZDxToShow);              // Show or hide the ZDx of all modules in the world
    void          ShowZDxOfSelectedActor      ();                                        // Show all ZDx of selected actor
    void          HideZDxOfSelectedActor      ();                                        // Hide all ZDx of selected actor


// --- Refresh display ---

public:
    BOOL          IWillRefreshDisplay    (long _lCallerID);                              // Someone say he will refresh the display later (to prevent multiple refreshes)
                                                                                         // Return TRUE if nobody else has asked it before
    BOOL          RefreshDisplay         (long _lCallerID , BOOL _bRefreshDisplay = TRUE);
                                                                                         // Refresh the display if the caller has asked it before (to prevent from multiple refreshes)

// --- Check if ZDx are displayed ---

private:
    BOOL          AreZDxOfActorDisplayed          (CPA_SuperObject * _pActorSuperObject); // Return if the ZDx of the actor are displayed or not
    BOOL          AreZDxOfModuleDisplayed         (CPA_SuperObject * _pModuleSuperObject);// Return if the ZDx of the module are displayed or not
    BOOL          AreZDxOfAllModuleDisplayed      ();                                     // Return TRUE if at least one ZDx of one module in the world is displayed
    BOOL          AreZDxOfModuleDisplayedRecursiv (CPA_SuperObject * _pModuleSuperObject);// Return if the ZDx of the given module and of all its module childs are displayed or not
    BOOL          AreModuleZDxOfActorDisplayed    (CPA_SuperObject * _pActorSuperObject); // Return if the module ZDx of the actor are displayed or not


// --- Check if an actor has ZDx ---

public:
    BOOL          DoesActorHaveZDx            (CPA_BaseObject  * _pActor);                // Return if an actor has some ZDx or not
    BOOL          DoesActorHaveModuleZDx      (CPA_SuperObject * _pActorSuperObject);     // Return if an actor has some ZDx of module or not


// --- List of zones ---

private:
    long          GetNumberOfZDxInList        (EdtList * _pEdtList);                     // Get the number of existing ZDx in a list

public:
    CString       ConvertZDxTypeToListType    (tdeZDxType);                              // Convert a ZDx type to a list type
    tdeZDxType    ConvertListTypeToZDxType    (CString);                                 // Convert a list type to a ZDx type

    CPA_tdoNameList
                * GetNameList                 (CPA_BaseObject * _pActor , tdeZDxType _eZDxType);
                                                                                         // Call the Actors dll to get the list of names of an actor for a specific type
    EdtList     * CreateANewZDxList           (CPA_BaseObject * _pActor , tdeZDxType _eZDxType);
                                                                                         // Call the Actors dll to create a new list of ZDx
    EdtList     * GetZDxList                  (CPA_BaseObject * _pActor , tdeZDxType _eZDxType);
                                                                                         // Call the Actors dll to get the list of ZDx of an actor
    void          SetZDxList                  (CPA_BaseObject * _pActor , tdeZDxType _eZDxType , EdtList * _pZDxList);
                                                                                         // Call the Actors dll to set the list of ZDx of an actor
    BOOL          DeleteZDxList               (CPA_BaseObject * _pActor , tdeZDxType _eZDxType);
                                                                                         // Call the Actors dll to delete a list of ZDx of an actor ; return FALSE if failure
    void          SetZDxObjectInList          (CPA_BaseObject * _pActor , tdeZDxType _eZDxType ,
                                               long _lIndexInList , ZDx_Object * pZDxObject ,
                                               tdeZDxConstraintType _eZDxConstraintType = eZDxNormal);
                                                                                         // Call the Actors dll to set a ZDx in a list of ZDx of an actor
    BOOL          InsertZDxIntoList           (EdtList * , ZDx_Object * , long * plPosition ,
                                               CPA_BaseObject * _pActor , tdeZDxConstraintType _eZDxConstraintType = eZDxNormal);
                                                                                         // Insert a ZDx object into a list at a specific position.
                                                                                         // If Position = -1, insert it at the first unused position.
                                                                                         // Failure -> return FALSE (no more unused position)
    void          RemoveZDxFromList           (EdtList * , ZDx_Object * , CPA_BaseObject * _pActor ,
                                               BOOL _bEnableListCreation = FALSE);       // Remove a ZDx object from a list

private:
    void          AZDxHasBeenChangedInList    (void * _pEdtListMess);                    // Called when a ZDx has been changed in a list of ZDx
    BOOL          IsObjectInList              (CPA_BaseObject * _pObject, CPA_BaseObject * _pActor , tdeZDxType _eZDxType);
                                                                                         // Return TRUE if the given object is in a list of ZDx

// --- Physical objects ---

public:
    ZDx_Object *  GetZDxOfPhysicalObject (EditorPO * , tdeZDxType);                      // return the ZDx object of a given type of a physical object
    void          SetZDxOfPhysicalObject (EditorPO * , ZDx_Object * , tdeZDxType);       // set the ZDx object (can be NULL) of a given type  for a physical object
private:
    BOOL          DoesModuleHaveZDx           (EditorPO *);                              // Return if a module has some ZDx of not
    BOOL          DoesModuleHaveZDxRecursiv   (CPA_SuperObject * _pModuleSuperObject);   // Return if a module or one of its module childs has some ZDx or not
    BOOL          DoesAtLeastOneModuleHaveZDx ();                                        // Return TRUE if at least one module in the world has some ZDx


// --- Personal functions for size changing --- 

private:
//ROMTEAM WorldEditor
/*
    void          ChangeSizeZDxSphereObject  (MTH3D_tdstVector * p_stDeplacement);	     // Called by the OnMouseMove function when changing the size of a sphere
	void          ChangeSizeZDxBoxObject     (MTH3D_tdstVector * p_stDeplacement);	     // Called by the OnMouseMovefunction  when changing the size of a box
    void          ChangeSizeZDxConeObject    (MTH3D_tdstVector * p_stDeplacement);         // Called by the OnMouseMove function when changing the size of a cone
    void          OnBeginChangingSize        (ACP_tdxIndex xIndex , HIE_tdstPickInfo * p_stObject);
                                                                                         // Called when the user begins to change the size of a ZDx object
    void          OnEndChangingSize          ();                                         // Called when the user has finished to change the size of a ZDx object
*/
//ENDROMTEAM WorldEditor

// --- Compute dimension of objects ---

private:
  //ANNECY TQ 19/03/98{
  void          ComputeBoundingBoxOfObject          (CPA_BaseObject   * _pObject , POS_tdstCompletePosition * _pGlobalMatrix ,POS_tdstCompletePosition * _pLocalMatrix ,
                                                       MTH3D_tdstVector * _pMinPoint    , MTH3D_tdstVector * _pMaxPoint);
   
//ENDANNECY TQ}
                                                                                      // Compute the bounding box of a geometric object, and return its limits in _pMinPoint and _pMaxPoint
    void          ComputeBoundingBoxOfObjectAndChilds (CPA_SuperObject  * _pSuperObject ,
                                                       MTH3D_tdstVector * _pMinPoint, MTH3D_tdstVector *_pMaxPoint);
                                                                                         // Compute the bounding box of an object and all of its childs, and return the limits in _pMinPoint and _pMaxPoint
public:
    void          ComputeInitialSizeOfBox             (CPA_SuperObject  * _pSuperObject ,
                                                       MTH3D_tdstVector * MinPoint      , MTH3D_tdstVector * MaxPoint);
                                                                                         // Compute the bounding box dimension of an object and all of its childs
    MTH_tdxReal   ComputeInitialSizeOfSphere          (CPA_SuperObject  * _pSuperObject , MTH3D_tdstVector * Center);

//ROMTEAM WorldEditor (Cristi Petrescu 12/12/97)
	long m_lGetTypeOfZoneByGeometricObject (Geometry3D *pGeometry3D);
//ENDROMTEAM WorldEditor (Cristi Petrescu)
	//CPA2 Stegaru Cristian 98-04
	BOOL mfn_bObjectIsOutsideTheBV (ZDx_Object *pBVolume, ZDx_Object *pZDxObject);
	BOOL mfn_bIs1SphereOutsideThe2Sphere (MTH3D_tdstVector *ptdstMasterCenter, GLI_tdxValue tdxMasterRadius, MTH3D_tdstVector *ptdstSlaveCenter, GLI_tdxValue tdxSlaveRadius);
	void mfn_vCheckActorsZonesAndBV (CPA_SuperObject * pActorSuperObject);
	//End CPA2 Stegaru Cristian 98-04
};


//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------

// the DLL global definition
extern tdstDLLIdentity g_stZDxDllIdentity;


#endif // __ZINTERF_HPP__
