//*****************************************************************************
//*  _zWList1.cpp                                                             *
//*****************************************************************************
//*                                                                           *
//* This file contains all the functions for the first list window            *
//*                                                                           *
//*****************************************************************************
//* Author : Alexis Vaisse                                                    *
//*****************************************************************************


// "standard" include
#include "stdafx.h"
#include "ACP_Base.h"

#include "TFA.h"        // Family dll include 

#define HieFriend
#include "IncGAM.h"
#include "ITF.h"
#include "..\Main\Inc\_EditID.h"

// personal include
#include "_zRes.h"                                // File created by Microsoft Developer Studio
#include "_zWList1.hpp"
#include "_zWList2.hpp"
#include "_zWEdit.hpp"
#include "_zInterf.hpp"
#include "_zObject.hpp"
#include "_zModif.hpp"
    
#include "OAC.h"        // Actors dll include
#include "OPD.h"        // Physical Object dll include
#include "TUT.h"        // Tutorial dll include

class EdActors_EditorActorInstance;
class EdActors_EditorActorModel;
class CPA_Family;

#define  C_uiPopupMenuIDCreateListZDD  2000
#define  C_uiPopupMenuIDCreateListZDE  2001
#define  C_uiPopupMenuIDCreateListZDM  2002
#define  C_uiPopupMenuIDCreateListZDR  2003


//**************************************²***************************************
// class TreeControl
//
// Class used instead of TreeCtrl
//*****************************************************************************

//-----------------------------------------------------------------------------
// class TreeControl : InsertItem
// Insert a element into the tree
//-----------------------------------------------------------------------------
HTREEITEM TreeControl::InsertItem (LPCTSTR Name , tdeTreeElementType _eType , CPA_BaseObject * _pObject ,
                                   CPA_SuperObject * _pSuperObject , HTREEITEM hParent , HTREEITEM hInsertAfter)
{
    // Insert the element into the tree
    HTREEITEM hHandle = CTreeCtrl::InsertItem (Name , hParent , hInsertAfter);

    // Set the correct image, depending on the type
    int IconNumber;
    switch (_eType)
    {
    case eFamilyElement:        IconNumber = C_ucIconFamily;        break;
    case eModelElement:         IconNumber = C_ucIconModel;         break;
    case eInstanceElement:      IconNumber = C_ucIconInstance;      break;
    case eModuleElement:        IconNumber = C_ucIconModule;        break;
    case eZddElement:
    case eZdeElement:
    case eZdmElement:
    case eZdrElement:
    case eBoundingVolumeElement:IconNumber = C_ucIconZDx;           break;
    case eBigGlobalZoneElement: IconNumber = C_ucIconBigGlobalZone; break;
    }
    SetItemImage (hHandle , IconNumber , IconNumber);

    // Create a TreeElementData to store the type of the element and a pointer to it
    tdstTreeElementData * pTreeElementData = new tdstTreeElementData;
    pTreeElementData -> eType        = _eType;
    pTreeElementData -> pSuperObject = _pSuperObject;
    pTreeElementData -> pObject      = _pObject;

    SetItemData (hHandle , (DWORD) pTreeElementData);

    return hHandle;
}

//-----------------------------------------------------------------------------
// class TreeControl : DeleteItemRecursive
// we delete the TreeElementData associated to an element and to its childs...
//-----------------------------------------------------------------------------
void TreeControl::DeleteItemRecursive (HTREEITEM hHandle)
{
    delete (tdstTreeElementData *) GetItemData (hHandle);
    SetItemData (hHandle , NULL);

    HTREEITEM hChildHandle;
    if (hChildHandle = GetChildItem (hHandle))    // = is not an error
        DeleteItemRecursive (hChildHandle);

    HTREEITEM hBrotherHandle;
    if (hBrotherHandle = GetNextItem (hHandle , TVGN_NEXT))
        DeleteItemRecursive (hBrotherHandle);
}

//-----------------------------------------------------------------------------
// class TreeControl : DeleteAllItems
// we delete the list of TreeElementData
//-----------------------------------------------------------------------------
BOOL TreeControl::DeleteAllItems ()
{
    if (GetRootItem ())  DeleteItemRecursive (GetRootItem());
    return CTreeCtrl::DeleteAllItems ();
}

//-----------------------------------------------------------------------------
// class TreeControl : DestroyWindow
// we delete the list of TreeElementData
//-----------------------------------------------------------------------------
BOOL TreeControl::DestroyWindow ()
{
    DeleteAllItems ();
    return CTreeCtrl::DestroyWindow ();
}


//*****************************************************************************
// class CList1Window
//
// Window that shows different lists
//*****************************************************************************

#define M_List1GetTreeElementData(hItem)  ((tdstTreeElementData *) m_Tree_Ctrl_1 . GetItemData (hItem))

IMPLEMENT_DYNCREATE (CList1Window , CFormView)

//-----------------------------------------------------------------------------
// class CList1Window : constructor
//-----------------------------------------------------------------------------
CList1Window::CList1Window (CWnd* pParent /*=NULL*/)
	: CFormView (CList1Window::IDD)
{
	//{{AFX_DATA_INIT(CList1Window)
	m_Combo_Box_String_List_1 = _T("");
	//}}AFX_DATA_INIT

    // Init private variables
    m_pZDxInterface                 = NULL;

    m_eList1Type                    = eListOfFamily;

    m_pSelectedFamily               = NULL;
    m_pSelectedModel                = NULL;
    m_pSelectedActor                = NULL;
    m_pSelectedActorSuperObject     = NULL;
    m_pSelectedBigGlobalZone        = NULL;

    m_bIsCreatingList               = FALSE;

    m_bCanSelectListOfFamily        =
    m_bCanSelectListOfModel         =
    m_bCanSelectListOfModelOfFamily =
    m_bCanSelectListOfInstance      =
    m_bCanSelectListOfModule        = TRUE;

    // Init button bitmap
    m_ButtonReturnBitmap         . LoadBitmap (IDB_Bitmap_Return);
    m_ButtonShowActorBitmap      . LoadBitmap (IDB_Bitmap_Show_Actor);
    m_ButtonShowModuleBitmap     . LoadBitmap (IDB_Bitmap_Show_Module);
    m_ButtonShowModuleZDxBitmap  . LoadBitmap (IDB_Bitmap_Show_Module_ZDx);
    m_ButtonBoundingVolumeBitmap . LoadBitmap (IDB_Bitmap_Bounding_Volume);
    m_ButtonTestPointBitmap      . LoadBitmap (IDB_Bitmap_Test_Point);
}

//-----------------------------------------------------------------------------
// class CList1Window : general functions
//-----------------------------------------------------------------------------
void CList1Window::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CList1Window)
	DDX_Control(pDX, IDC_Check_Button_Show_Actor, m_Check_Button_Show_Actor);
    DDX_Control(pDX, IDC_Check_Button_Show_Module, m_Check_Button_Show_Module);
    DDX_Control(pDX, IDC_Check_Button_Show_Module_ZDx, m_Check_Button_Show_Module_ZDx);
    DDX_Control(pDX, IDC_Check_Button_Bounding_Volume, m_Check_Button_Bounding_Volume);
    DDX_Control(pDX, IDC_Check_Button_Test_Point, m_Check_Button_Test_Point);
	DDX_Control(pDX, IDC_Button_Return, m_Button_Return);
	DDX_Control(pDX, IDC_Combo_Box_List_1, m_Combo_Box_List_1);
	DDX_Control(pDX, IDC_Tree_Ctrl_1, m_Tree_Ctrl_1);
	DDX_CBString(pDX, IDC_Combo_Box_List_1, m_Combo_Box_String_List_1);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CList1Window, CFormView)
	//{{AFX_MSG_MAP(CList1Window)
	ON_WM_SIZE()
	ON_CBN_SELCHANGE(IDC_Combo_Box_List_1, On_Selection_Has_Changed_Combo_Box_List_1)
	ON_BN_CLICKED(IDC_Button_Return, On_Return_Button)
	ON_NOTIFY(NM_DBLCLK, IDC_Tree_Ctrl_1, On_Double_Click_Tree_Ctrl_1)
	ON_NOTIFY(TVN_SELCHANGED, IDC_Tree_Ctrl_1, On_Selection_Has_Changed_Tree_Ctrl_1)
	ON_WM_DRAWITEM()
	ON_NOTIFY(NM_RCLICK, IDC_Tree_Ctrl_1, On_Right_Click_Tree_Ctrl_1)
	ON_BN_CLICKED(IDC_Check_Button_Show_Actor, On_Check_Button_Show_Actor)
	ON_BN_CLICKED(IDC_Check_Button_Show_Module, On_Check_Button_Show_Module)
	ON_BN_CLICKED(IDC_Check_Button_Show_Module_ZDx, On_Check_Button_Show_Module_ZDx)
    ON_BN_CLICKED(IDC_Check_Button_Bounding_Volume, On_Check_Button_Bounding_Volume)
    ON_BN_CLICKED(IDC_Check_Button_Test_Point, On_Check_Button_Test_Point)
	ON_NOTIFY(TVN_KEYDOWN, IDC_Tree_Ctrl_1, On_Key_Down_Tree_Ctrl_1)
	ON_NOTIFY(TVN_BEGINLABELEDIT, IDC_Tree_Ctrl_1, On_Begin_Change_Name_Tree_Ctrl_1)
	ON_NOTIFY(TVN_ENDLABELEDIT, IDC_Tree_Ctrl_1, On_End_Change_Name_Tree_Ctrl_1)
	//}}AFX_MSG_MAP
    ON_NOTIFY_EX(TTN_NEEDTEXT, 0, SetToolTipText)
END_MESSAGE_MAP()

//-----------------------------------------------------------------------------
// class CList1Window - Create
// init the window
//-----------------------------------------------------------------------------
BOOL CList1Window::Create (LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
{
    // Call the standard create. Return TRUE if Ok
	if (CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext))
    {
        UpdateData (FALSE);         // To call DoDataExchange

        // Init the Combo Box list
        if ((m_Combo_Box_List_1 . AddString (C_szListOfFamily)        == CB_ERR) ||
            (m_Combo_Box_List_1 . AddString (C_szListOfModel)         == CB_ERR) ||
            (m_Combo_Box_List_1 . AddString (C_szListOfModelOfFamily) == CB_ERR) ||
            (m_Combo_Box_List_1 . AddString (C_szListOfInstance)      == CB_ERR) ||
            (m_Combo_Box_List_1 . AddString (C_szListOfModule)        == CB_ERR))
            MessageBox ("Error with Combo Box" , "Debug" , MB_OK + MB_ICONSTOP + MB_TASKMODAL);

        // Init buttons
        m_Button_Return                . SetBitmap (HBITMAP (m_ButtonReturnBitmap        ));
        m_Check_Button_Show_Actor      . SetBitmap (HBITMAP (m_ButtonShowActorBitmap     ));
        m_Check_Button_Show_Module     . SetBitmap (HBITMAP (m_ButtonShowModuleBitmap    ));
        m_Check_Button_Show_Module_ZDx . SetBitmap (HBITMAP (m_ButtonShowModuleZDxBitmap ));
        m_Check_Button_Bounding_Volume . SetBitmap (HBITMAP (m_ButtonBoundingVolumeBitmap));
        m_Check_Button_Test_Point      . SetBitmap (HBITMAP (m_ButtonTestPointBitmap     ));

        // Init icons for the tree
        m_stImageList . Create       (16 , 16 , FALSE, 0, 10);
        m_stImageList . Add          (M_GetMainApp () -> LoadIcon (IDI_Icon_Family         ));
        m_stImageList . Add          (M_GetMainApp () -> LoadIcon (IDI_Icon_Model          ));
        m_stImageList . Add          (M_GetMainApp () -> LoadIcon (IDI_Icon_Instance       ));
        m_stImageList . Add          (M_GetMainApp () -> LoadIcon (IDI_Icon_Module         ));
        m_stImageList . Add          (M_GetMainApp () -> LoadIcon (IDI_Icon_Used_Module    ));
        m_stImageList . Add          (M_GetMainApp () -> LoadIcon (IDI_Icon_ZDx            ));
        m_stImageList . Add          (M_GetMainApp () -> LoadIcon (IDI_Icon_Big_Global_Zone));
        m_Tree_Ctrl_1 . SetImageList (& m_stImageList , TVSIL_NORMAL);

        // Init tooltip control
        m_ToolTipCtrl . Create   (this , WS_VISIBLE | TTS_ALWAYSTIP);
        m_ToolTipCtrl . AddTool  (GetDlgItem (IDC_Combo_Box_List_1            ));
        m_ToolTipCtrl . AddTool  (GetDlgItem (IDC_Button_Return               ));
        m_ToolTipCtrl . AddTool  (GetDlgItem (IDC_Check_Button_Show_Actor     ));
        m_ToolTipCtrl . AddTool  (GetDlgItem (IDC_Check_Button_Show_Module    ));
        m_ToolTipCtrl . AddTool  (GetDlgItem (IDC_Check_Button_Show_Module_ZDx));
        m_ToolTipCtrl . AddTool  (GetDlgItem (IDC_Check_Button_Bounding_Volume));
        m_ToolTipCtrl . AddTool  (GetDlgItem (IDC_Check_Button_Test_Point     ));
        m_ToolTipCtrl . Activate (TRUE);
        EnableToolTips ();

        // Register controls for the tutorial
        TUT_M_vGetTutDll ();
        TUT_M_vRegisterControlID (IDC_Combo_Box_List_1             , "TUT_List1_Combo"    , TUT_e_ComboBox);
        TUT_M_vRegisterControlID (IDC_Tree_Ctrl_1                  , "TUT_List1_Tree"     , TUT_e_TreeCtrl);
        TUT_M_vRegisterControlID (IDC_Button_Return                , "TUT_Return"         , TUT_e_Button);
        TUT_M_vRegisterControlID (IDC_Check_Button_Show_Actor      , "TUT_ShowActor"      , TUT_e_Button);
        TUT_M_vRegisterControlID (IDC_Check_Button_Show_Module     , "TUT_ShowModule"     , TUT_e_Button);
        TUT_M_vRegisterControlID (IDC_Check_Button_Show_Module_ZDx , "TUT_ShowModuleZDx"  , TUT_e_Button);
        TUT_M_vRegisterControlID (IDC_Check_Button_Bounding_Volume , "TUT_BoundingVolume" , TUT_e_Button);
        TUT_M_vRegisterControlID (IDC_Check_Button_Test_Point      , "TUT_TestPoint"      , TUT_e_Button);

        return TRUE;
    }
    else return FALSE;
}

//-----------------------------------------------------------------------------
// class CList1Window - OnSize
// called when the window is resized : we change the size of the elements
//-----------------------------------------------------------------------------
void CList1Window::OnSize (UINT nType, int cx, int cy) 
{
	CFormView::OnSize(nType, cx, cy);

    RECT WindowPos;
    GetClientRect (& WindowPos);

    // Set the width of the combo box to the same size
    if (m_Combo_Box_List_1 . m_hWnd)
    {
        RECT ComboPos;
        m_Combo_Box_List_1 . GetWindowRect (& ComboPos);
        ScreenToClient                     (& ComboPos);
        ComboPos . right = WindowPos . right;
        m_Combo_Box_List_1 . MoveWindow    (& ComboPos);
    }

    // Set the width of the tree to the same size
    if (m_Tree_Ctrl_1 . m_hWnd)
    {
        RECT TreePos;
        m_Tree_Ctrl_1 . GetWindowRect (& TreePos);
        ScreenToClient                (& TreePos);
        TreePos . right  = WindowPos . right;
        TreePos . bottom = WindowPos . bottom;
        m_Tree_Ctrl_1 . MoveWindow    (& TreePos);
    }
}

//-----------------------------------------------------------------------------
// class CList1Window - ComboBoxLineEnabled
// Return if the given name must be enabled or disabled in the combo box
//-----------------------------------------------------------------------------
BOOL CList1Window::ComboBoxLineEnabled (char * _szName)
{
    return    ((strcmp (_szName , C_szListOfFamily       ) == 0) && m_bCanSelectListOfFamily)
           || ((strcmp (_szName , C_szListOfModel        ) == 0) && m_bCanSelectListOfModel)
           || ((strcmp (_szName , C_szListOfModelOfFamily) == 0) && m_bCanSelectListOfModelOfFamily)
           || ((strcmp (_szName , C_szListOfInstance     ) == 0) && m_bCanSelectListOfInstance)
           || ((strcmp (_szName , C_szListOfModule       ) == 0) && m_bCanSelectListOfModule);
}

//-----------------------------------------------------------------------------
// class CList1Window - ComboBoxChoseCorrectName
// Input:  _szOldName is the standard name to draw in the combo box
// Output: _szNewName is the corrected name to draw
//-----------------------------------------------------------------------------
void CList1Window::ComboBoxChoseCorrectName (char * _szNewName , char * _szOldName)
{
    strcpy (_szNewName , _szOldName);

    if (strcmp (_szOldName , C_szListOfModelOfFamily) == 0)
    {
        if (m_pSelectedFamily)
        {
            strcpy (_szNewName , C_szListOfModelOfGivenFamily);
            strcat (_szNewName , m_pSelectedFamily -> GetName ());
        }
    }
        else
    if (strcmp (_szOldName , C_szListOfInstance) == 0)
    {
        if (m_pSelectedModel)
        {
            strcpy (_szNewName , C_szListOfInstanceOfGivenModel);
            strcat (_szNewName , m_pSelectedModel -> GetName ());
        }
    }
        else
    if (strcmp (_szOldName , C_szListOfModule) == 0)
    {
        if (m_pSelectedActor)
        {
            strcpy (_szNewName , C_szListOfModuleOfGivenTable);
            strcat (_szNewName , m_pSelectedActor -> GetName ());
        }
    }
}

//-----------------------------------------------------------------------------
// class CList1Window - ComboBoxDrawLine
// Draw one line of the combo box
//-----------------------------------------------------------------------------
void CList1Window::ComboBoxDrawLine (LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    // Get the drawing device
    CDC        * pDC           = CDC::FromHandle (lpDrawItemStruct -> hDC);

    // Get the string to draw
    char         szName        [255];
    char         szCorrectName [255];
    m_Combo_Box_List_1 . GetLBText (lpDrawItemStruct -> itemID, szName);

    // Get if the line is selected or not
    BOOL         bSelected     = lpDrawItemStruct -> itemState & ODS_SELECTED;

    // Get if the line must be enabled or disabled
    BOOL bEnabled = ComboBoxLineEnabled (szName);

    // Chose the correct name to draw
    ComboBoxChoseCorrectName (szCorrectName , szName);

    // Select colors
    pDC -> FillSolidRect (& lpDrawItemStruct -> rcItem , 
                          GetSysColor (bEnabled && bSelected ? COLOR_HIGHLIGHT : COLOR_WINDOW));
    pDC -> SetBkMode     (TRANSPARENT);
    pDC -> SetTextColor  (GetSysColor (bEnabled ? (bSelected ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT)
                                                : COLOR_GRAYTEXT));

    // Draw text
    pDC -> DrawText (szCorrectName , strlen (szCorrectName) , & lpDrawItemStruct -> rcItem , DT_SINGLELINE | DT_LEFT | DT_VCENTER);
}

//-----------------------------------------------------------------------------
// class CList1Window - OnDrawItem
// Called when something need to be redrawed.
// We used it to disable some entries in the combo box
//-----------------------------------------------------------------------------
void CList1Window::OnDrawItem (int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
    switch (nIDCtl)
    {
    case IDC_Combo_Box_List_1:  if (m_Combo_Box_List_1 . IsWindowEnabled ())
                                    ComboBoxDrawLine (lpDrawItemStruct);
                                else
                                    CFormView::OnDrawItem (nIDCtl , lpDrawItemStruct);
                                break;

    default:                    CFormView::OnDrawItem (nIDCtl , lpDrawItemStruct);
                                break;
    }
}

//-----------------------------------------------------------------------------
// class CList1Window - SetToolTipText
// Set the text that will be shown in a tool tip
//-----------------------------------------------------------------------------
BOOL CList1Window::SetToolTipText (UINT uiControlId , NMHDR * pNMHDR , LRESULT * pResult)
{
    LPTOOLTIPTEXT lpToolTipText = (LPTOOLTIPTEXT) pNMHDR;
	uiControlId                 = ::GetDlgCtrlID ((HWND) pNMHDR -> idFrom);

    switch (uiControlId)
    {
        case IDC_Combo_Box_List_1        : lpToolTipText -> lpszText = "Choose a list to show";   break;

        case IDC_Button_Return           : switch (m_eList1Type)
                                           {
                                            case eListOfFamily        : lpToolTipText -> lpszText = "";                                  break;
                                            case eListOfModel         :
                                            case eListOfModelOfFamily : lpToolTipText -> lpszText = "Go back to the list of families";   break;
                                            case eListOfInstance      : lpToolTipText -> lpszText = "Go back to the list of models";     break;
                                            case eListOfModule        : lpToolTipText -> lpszText = "Go back to the list of actors";     break;
                                            default                   : ASSERT (0);
                                                                        lpToolTipText -> lpszText = "";                                  break;
                                           }
                                           break;

        case IDC_Check_Button_Show_Actor : if (IsEditingZDxOfModule ())  lpToolTipText -> lpszText = "Show module alone";
                                                                    else lpToolTipText -> lpszText = "Show actor alone";
                                           break;

        case IDC_Check_Button_Show_Module: if (m_Check_Button_Show_Module . GetCheck ())
                                                lpToolTipText -> lpszText = "Leave module zones edition";
                                           else lpToolTipText -> lpszText = "Edit module zones";
                                           break;

        case IDC_Check_Button_Show_Module_ZDx
                                         : if (m_Check_Button_Show_Module_ZDx . GetCheck ())
                                                lpToolTipText -> lpszText = "Hide module zones";
                                           else lpToolTipText -> lpszText = "Show module zones";
                                           break;

        case IDC_Check_Button_Bounding_Volume
                                         : if (IsEditingBoundingVolume ())
                                                lpToolTipText -> lpszText = "Leave bounding volume edition";
                                           else lpToolTipText -> lpszText = "Edit bounding volume";
                                           break;

        case IDC_Check_Button_Test_Point : if (m_Check_Button_Test_Point . GetCheck ())
                                                lpToolTipText -> lpszText = "Leave test points edition";
                                           else lpToolTipText -> lpszText = "Edit family test points";
                                           break;

        default                          : lpToolTipText -> lpszText = "";                        break;
    }

    return TRUE;
}

//-----------------------------------------------------------------------------
// class CList1Window - PreTranslateMessage
// We intercept the WM_NOTIFY message
//-----------------------------------------------------------------------------
BOOL CList1Window::PreTranslateMessage (MSG * pMsg) 
{
    switch (pMsg -> message)
    {
         case WM_LBUTTONDOWN :
         case WM_MOUSEMOVE   :
         case WM_LBUTTONUP   :
         case WM_RBUTTONDOWN :
         case WM_MBUTTONDOWN :
         case WM_RBUTTONUP   :
         case WM_MBUTTONUP   : m_ToolTipCtrl . RelayEvent (pMsg);
                               break;

         case  WM_KEYDOWN    : switch (pMsg -> wParam)
                               {
                                   case VK_RETURN : TreeView_EndEditLabelNow (m_Tree_Ctrl_1 . m_hWnd , FALSE);
                                                    return TRUE;
                                   case VK_ESCAPE : TreeView_EndEditLabelNow (m_Tree_Ctrl_1 . m_hWnd , TRUE);
                                                    return TRUE;
                               }
    }

	return CFormView::PreTranslateMessage(pMsg);
}

//-----------------------------------------------------------------------------
// class CList1Window - On_Selection_Has_Changed_Combo_Box_List_1
// We change the associated list
//-----------------------------------------------------------------------------
void CList1Window::On_Selection_Has_Changed_Combo_Box_List_1() 
{
    char szOldName [255];
    strcpy (szOldName , m_Combo_Box_String_List_1);

    UpdateData (TRUE);              // Update variables from screen

    // If the selected entry is disabled, we select the previous entry
    if (! ComboBoxLineEnabled (m_Combo_Box_String_List_1 . GetBuffer (255)))
    {
        m_Combo_Box_String_List_1 = szOldName;
        UpdateData (FALSE);
        return;
    }

    // If we were editing the bounding volume, we leave the edition
    if (IsEditingBoundingVolume ())
    {
        CString SaveString = m_Combo_Box_String_List_1;
        LeaveEditionOfBoundingVolume ();
        m_Combo_Box_String_List_1 = SaveString;
    }
// ANNECY AV CLEAN_MEC {
/*
    else
    if (IsEditingTestPoint ())
    {
        CString SaveString = m_Combo_Box_String_List_1;
        LeaveEditionOfTestPoint ();
        m_Combo_Box_String_List_1 = SaveString;
    }
*/
// END ANNECY AV }

    if (strcmp (m_Combo_Box_String_List_1 , C_szListOfFamily)        == 0)
         CreateListOfFamily (m_pSelectedFamily , m_pSelectedModel);
    else
    if (strcmp (m_Combo_Box_String_List_1 , C_szListOfModel)         == 0)
         CreateListOfModel  (m_pSelectedModel , m_pSelectedActor);
    else
    if (strcmp (m_Combo_Box_String_List_1 , C_szListOfModelOfFamily) == 0)
         CreateListOfModelOfFamily (m_pSelectedFamily , m_pSelectedModel , m_pSelectedActor);
    else
    if (strcmp (m_Combo_Box_String_List_1 , C_szListOfInstance)      == 0)
         CreateListOfInstance (m_pSelectedModel , m_pSelectedActor , m_pSelectedBigGlobalZone);
    else
    if (strcmp (m_Combo_Box_String_List_1 , C_szListOfModule)        == 0)
         CreateListOfModule   (m_pSelectedActorSuperObject);
    else ASSERT (0);
}

//-----------------------------------------------------------------------------
// class CList1Window - On_Selection_Has_Changed_Tree_Ctrl_1
// We enable or disable the different entries of the combo box,
// depending of the type of the selected element
//-----------------------------------------------------------------------------
void CList1Window::On_Selection_Has_Changed_Tree_Ctrl_1(NMHDR * pNMHDR, LRESULT * pResult) 
{
	NM_TREEVIEW * pNMTreeView = (NM_TREEVIEW *) pNMHDR;
    * pResult = FALSE;  // Allow the selection

    // We don't do anything when a list is been creating
    if (m_bIsCreatingList)  return;

    // Get the selected item
    HTREEITEM hSelectedItem = m_Tree_Ctrl_1 . GetSelectedItem ();
    // If there is no selected item, we do nothing
    if (! hSelectedItem)  return;
    // Get the element data
    tdstTreeElementData * pTreeElementData = M_List1GetTreeElementData (hSelectedItem);
    // If there is no element data, we do nothing
    if (! pTreeElementData)  return;

    // Say that we will refresh the display
    m_pZDxInterface -> IWillRefreshDisplay (C_lOnSelChangeTreeCtrl1);

    // If we were editing the bounding volume, we leave the edition
    if (IsEditingBoundingVolume ())
    {
        LeaveEditionOfBoundingVolume ();
        return;
    }
// ANNECY AV CLEAN_MEC {
/*
    if (IsEditingTestPoint ())
    {
        LeaveEditionOfTestPoint ();
        return;
    }
*/
// END ANNECY AV }

    tdeTreeElementType    eType =  pTreeElementData -> eType;

    switch (eType)
    {
    case eFamilyElement:
        m_pSelectedFamily           = pTreeElementData -> pObject;
        m_pSelectedModel            = NULL;
        m_pSelectedActor            = NULL;
        m_pSelectedActorSuperObject = NULL;
        m_pSelectedBigGlobalZone    = NULL;
        m_pZDxInterface -> GetList2Window () -> CreateListOfZDx (NULL , NULL , NULL , NULL , NULL);
        m_Check_Button_Show_Actor      . EnableWindow (FALSE);
        m_Check_Button_Show_Module     . EnableWindow (FALSE);
        m_Check_Button_Show_Module_ZDx . EnableWindow (FALSE);
        m_Check_Button_Bounding_Volume . EnableWindow (FALSE);
        m_Check_Button_Test_Point      . EnableWindow (FALSE);
        break;

    case eModelElement:
        m_pSelectedModel            = pTreeElementData -> pObject;
        m_pSelectedFamily           = m_pSelectedModel -> GetOwner ();
        m_pSelectedActor            = NULL;
        m_pSelectedActorSuperObject = NULL;
        m_pSelectedBigGlobalZone    = NULL;
        m_pZDxInterface -> GetList2Window () -> CreateListOfZDx (NULL , NULL , NULL , NULL , NULL);
        m_Check_Button_Show_Actor      . EnableWindow (FALSE);
        m_Check_Button_Show_Module     . EnableWindow (FALSE);
        m_Check_Button_Show_Module_ZDx . EnableWindow (FALSE);
        m_Check_Button_Bounding_Volume . EnableWindow (FALSE);
        m_Check_Button_Test_Point      . EnableWindow (FALSE);
        break;

    case eInstanceElement:
        {
        m_pSelectedActor            = pTreeElementData    -> pObject;
        m_pSelectedActorSuperObject = pTreeElementData    -> pSuperObject;
        m_pSelectedModel            = m_pSelectedActor ? m_pSelectedActor -> GetOwner () : NULL;
        m_pSelectedFamily           = m_pSelectedModel ? m_pSelectedModel -> GetOwner () : NULL;
        m_pSelectedBigGlobalZone    = NULL;

        EdtList              * pListOfZdd       = m_pZDxInterface -> GetZDxList (m_pSelectedActor , eZdd);
        EdtList              * pListOfZde       = m_pZDxInterface -> GetZDxList (m_pSelectedActor , eZde);
        EdtList              * pListOfZdm       = m_pZDxInterface -> GetZDxList (m_pSelectedActor , eZdm);
        EdtList              * pListOfZdr       = m_pZDxInterface -> GetZDxList (m_pSelectedActor , eZdr);
        m_Check_Button_Show_Actor      . EnableWindow (TRUE);
        m_Check_Button_Show_Module     . EnableWindow (TRUE);
        m_Check_Button_Show_Module_ZDx . SetCheck     (FALSE);
        m_Check_Button_Show_Module_ZDx . EnableWindow (m_pZDxInterface -> DoesActorHaveModuleZDx (m_pSelectedActorSuperObject));
        m_Check_Button_Bounding_Volume . EnableWindow (TRUE);
        m_Check_Button_Test_Point      . EnableWindow (TRUE);

        // If the T3D tool is open, we change the actor to show
        if (m_Check_Button_Show_Actor . GetCheck ())
        {
            // We get the T3D tool
            CPA_ToolDLLBase * pT3DDll = m_pZDxInterface -> GetMainWorld () -> GetToolDLLWithName (C_szDLLTool3DName);
            // We get the current showed actor
            CPA_World       * pWorld               = (CPA_World *) pT3DDll -> OnQueryInfos (m_pZDxInterface , C_wTool3D_QI_GetWorld , NULL);
            CPA_SuperObject * pRoot                = pWorld ? pWorld -> GetRoot () : NULL;
            CPA_SuperObject * pSelectedSuperObject = (CPA_SuperObject *) (pRoot ? pRoot -> GetHeadElement () : NULL);
            CPA_BaseObject  * pShowedActor     = pSelectedSuperObject ? pSelectedSuperObject -> GetObject () : NULL;
            // If there is a new actor to select, we hide its zones, so they will be able to be showed again later
            if (pShowedActor != m_pSelectedActor)
			{
                m_pZDxInterface -> ShowZDxOfActor (m_pSelectedActorSuperObject , C_ucHideAllZDx);
                pT3DDll -> OnQueryAction (m_pZDxInterface , C_wTool3D_QA_NewChar ,
                                          (long) m_pSelectedActorSuperObject);
			}
        }
        // We set the check boxes because they are used when selecting an actor to know what types of ZDx to show
        if (! m_pZDxInterface -> IsInsideOnModifInsertDelete ())
            m_pZDxInterface -> GetList2Window () -> SetZDxCheckBoxes (pListOfZdd != NULL , pListOfZde != NULL ,
                                                                      pListOfZdm != NULL , pListOfZdr != NULL);
        // Then we select the instance. This inserts the ZDx to show into the hierarchy
        m_pZDxInterface -> AskHierarchyEditorToSelectObject (m_pSelectedActorSuperObject);
        // And we refresh the list of ZDx. This sets the correct aspect of the selected ZDx
        m_pZDxInterface -> GetList2Window () -> 
            CreateListOfZDx (m_pSelectedActorSuperObject , pListOfZdd , pListOfZde , pListOfZdm , pListOfZdr ,
                             TRUE , ! m_pZDxInterface -> IsInsideOnModifInsertDelete ());

        }
        break;

    case eModuleElement:
        {
        EditorPO        * pSelectedModule            = (EditorPO *) pTreeElementData -> pObject;
        CPA_SuperObject * pSelectedModuleSuperObject = pTreeElementData -> pSuperObject;

        // m_pSelectedModel and m_pSelectedFamily must not change
        m_pSelectedBigGlobalZone = NULL;

        // We select the module
        m_pZDxInterface -> AskHierarchyEditorToSelectObject (pSelectedModuleSuperObject);

        // If the T3D tool is open, we change the module to show
        if (m_Check_Button_Show_Actor . GetCheck ())
        {
            // We get the T3D tool
            CPA_ToolDLLBase * pT3DDll = m_pZDxInterface -> GetMainWorld () -> GetToolDLLWithName (C_szDLLTool3DName);
            // We get the current showed module
            CPA_World       * pWorld               = (CPA_World *) pT3DDll -> OnQueryInfos (m_pZDxInterface , C_wTool3D_QI_GetWorld , NULL);
            CPA_SuperObject * pRoot                = pWorld ? pWorld -> GetRoot () : NULL;
            CPA_SuperObject * pSelectedSuperObject = (CPA_SuperObject *) (pRoot ? pRoot -> GetHeadElement () : NULL);
            CPA_BaseObject  * pShowedModule        = pSelectedSuperObject ? pSelectedSuperObject -> GetObject () : NULL;
            // If there is a new actor to select, we show it
            if (pShowedModule != pSelectedModule)
                pT3DDll -> OnQueryAction (m_pZDxInterface , C_wTool3D_QA_NewObject , (long) pSelectedModule);
        }

        if (pSelectedModule)
        {
             m_pZDxInterface -> GetList2Window () -> SetZDxCheckBoxes        (TRUE , TRUE , TRUE , TRUE);
             m_pZDxInterface -> GetList2Window () -> CreateListOfZDxOfModule (pSelectedModuleSuperObject , TRUE);
        }
        else m_pZDxInterface -> GetList2Window () -> CreateListOfZDxOfModule (NULL);

        m_Check_Button_Show_Actor      . EnableWindow (TRUE);
        m_Check_Button_Show_Module     . EnableWindow (TRUE);
        m_Check_Button_Show_Module_ZDx . EnableWindow (FALSE);
        m_Check_Button_Bounding_Volume . EnableWindow (FALSE);
        m_Check_Button_Test_Point      . EnableWindow (FALSE);
        }
        break;

    case eBigGlobalZoneElement:
        {
        m_pSelectedBigGlobalZone     = (EdtList *) pTreeElementData -> pObject;
        HTREEITEM  hHandleOfInstance = m_Tree_Ctrl_1 . GetParentItem (hSelectedItem);
        m_pSelectedActor             = M_List1GetTreeElementData (hHandleOfInstance) -> pObject;
        m_pSelectedActorSuperObject  = M_List1GetTreeElementData (hHandleOfInstance) -> pSuperObject;
        m_pSelectedModel             = m_pSelectedActor -> GetOwner ();
        m_pSelectedFamily            = m_pSelectedModel -> GetOwner ();

        tdeZDxType          eZDxType = m_pZDxInterface -> ConvertListTypeToZDxType 
                                           (m_pSelectedBigGlobalZone -> fn_csGetListType ());
        m_Check_Button_Show_Actor      . EnableWindow (TRUE);
        m_Check_Button_Show_Module     . EnableWindow (TRUE);
        m_Check_Button_Show_Module_ZDx . EnableWindow (m_pZDxInterface -> DoesActorHaveModuleZDx (m_pSelectedActorSuperObject));
        m_Check_Button_Bounding_Volume . EnableWindow (FALSE);
        m_Check_Button_Test_Point      . EnableWindow (FALSE);

        // If the T3D tool is open, we change the actor to show
        if (m_Check_Button_Show_Actor . GetCheck ())
        {
            // We get the T3D tool
            CPA_ToolDLLBase * pT3DDll = m_pZDxInterface -> GetMainWorld () -> GetToolDLLWithName (C_szDLLTool3DName);
            // We get the current showed actor
            CPA_World       * pWorld               = (CPA_World *) pT3DDll -> OnQueryInfos (m_pZDxInterface , C_wTool3D_QI_GetWorld , NULL);
            CPA_SuperObject * pRoot                = pWorld ? pWorld -> GetRoot () : NULL;
            CPA_SuperObject * pSelectedSuperObject = (CPA_SuperObject *) (pRoot ? pRoot -> GetHeadElement () : NULL);
            CPA_BaseObject  * pShowedActor         = pSelectedSuperObject ? pSelectedSuperObject -> GetObject () : NULL;
            // If there is a new actor to select, we hide its zones, so they will be able to be showed again later
            if (pShowedActor != m_pSelectedActor)
			{
                m_pZDxInterface -> ShowZDxOfActor (m_pSelectedActorSuperObject , C_ucHideAllZDx);
                pT3DDll -> OnQueryAction (m_pZDxInterface , C_wTool3D_QA_NewChar , (long) m_pSelectedActorSuperObject);
			}
        }
        // We set the check boxes because they are used when selecting an actor to know what types of ZDx to show
        m_pZDxInterface -> GetList2Window () -> SetZDxCheckBoxes (eZDxType);
        // Then we select the instance. This inserts the ZDx to show into the hierarchy
        m_pZDxInterface -> AskHierarchyEditorToSelectObject (m_pSelectedActorSuperObject);
        // And we refresh the list of ZDx. This sets the correct aspect of the selected ZDx
        m_pZDxInterface -> GetList2Window () -> CreateASpecificListOfZDx (m_pSelectedActorSuperObject , m_pSelectedBigGlobalZone , eZDxType);
        }
        break;

    case eZddElement:
    case eZdeElement:
    case eZdmElement:
    case eZdrElement:
        {
        // We get the module of the ZDx object
        tdstTreeElementData * pTreeElementDataParent = M_List1GetTreeElementData (m_Tree_Ctrl_1 . GetParentItem (hSelectedItem));
        EditorPO        * pSelectedModule            = (EditorPO *) pTreeElementDataParent -> pObject;
        CPA_SuperObject * pSelectedModuleSuperObject =              pTreeElementDataParent -> pSuperObject;

        // If the T3D tool is open, we change the module to show
        if (m_Check_Button_Show_Actor . GetCheck ())
        {
            // We get the T3D tool
            CPA_ToolDLLBase * pT3DDll = m_pZDxInterface -> GetMainWorld () -> GetToolDLLWithName (C_szDLLTool3DName);
            // We get the current showed module
            CPA_World       * pWorld               = (CPA_World *) pT3DDll -> OnQueryInfos (m_pZDxInterface , C_wTool3D_QI_GetWorld , NULL);
            CPA_SuperObject * pRoot                = pWorld ? pWorld -> GetRoot () : NULL;
            CPA_SuperObject * pSelectedSuperObject = (CPA_SuperObject *) (pRoot ? pRoot -> GetHeadElement () : NULL);
            CPA_BaseObject  * pShowedModule        = pSelectedSuperObject ? pSelectedSuperObject -> GetObject () : NULL;
            // If there is a new actor to select, we hide its zones, so they will be able to be showed again later
            if (pShowedModule != pSelectedModule)
			{
                m_pZDxInterface -> ShowZDxOfModule (pSelectedModuleSuperObject , C_ucHideAllZDx);
                pT3DDll -> OnQueryAction (m_pZDxInterface , C_wTool3D_QA_NewObject , (long) pSelectedModule);
			}
        }

        // If this module is not edited in the List2, we edit it
        if (m_pZDxInterface -> GetList2Window () -> GetModule () != pSelectedModule)
            m_pZDxInterface -> GetList2Window () -> CreateListOfZDxOfModule (pSelectedModuleSuperObject);
        // We select the module (to hide the zones of the previous module)
        m_pZDxInterface -> AskHierarchyEditorToSelectObject (pSelectedModuleSuperObject);
        // We select the ZDx object into the List2
        m_pZDxInterface -> GetList2Window () -> SelectZDx ((ZDx_Object *) pTreeElementData -> pObject);
        m_pZDxInterface -> ShowZDxOfModule (pSelectedModuleSuperObject , m_pZDxInterface -> GetList2Window () -> GetZDxTypeToShow () ,
                                            (ZDx_Object *) pTreeElementData -> pObject);

        m_Check_Button_Show_Actor      . EnableWindow (TRUE);
        m_Check_Button_Show_Module     . EnableWindow (TRUE);
        m_Check_Button_Show_Module_ZDx . EnableWindow (FALSE);
        m_Check_Button_Bounding_Volume . EnableWindow (FALSE);
        m_Check_Button_Test_Point      . EnableWindow (FALSE);
        }
        break;

    default:
        ASSERT (0);
        break;
    }

    m_bCanSelectListOfFamily         = TRUE;
    m_bCanSelectListOfModel          = TRUE;
    m_bCanSelectListOfModelOfFamily  = m_pSelectedFamily   != NULL;
    m_bCanSelectListOfInstance       = m_pSelectedModel    != NULL;
    m_bCanSelectListOfModule         = m_pSelectedActor    != NULL;

    m_pZDxInterface -> RefreshDisplay (C_lOnSelChangeTreeCtrl1);
}

//-----------------------------------------------------------------------------
// class CList1Window - On_Right_Click_Tree_Ctrl_1
// Right click on the tree : we open a popup menu
//-----------------------------------------------------------------------------
void CList1Window::On_Right_Click_Tree_Ctrl_1 (NMHDR * pNMHDR, LRESULT * pResult) 
{
	* pResult = 0;

    // Select the element where the user has pointed onto
    TV_HITTESTINFO HitTestInfo;
    GetCursorPos                   (& HitTestInfo . pt);
    m_Tree_Ctrl_1 . ScreenToClient (& HitTestInfo . pt);

    HTREEITEM hSelectedItem = m_Tree_Ctrl_1 . HitTest (& HitTestInfo);
    if (! hSelectedItem)  return;

    m_Tree_Ctrl_1 . EnsureVisible (hSelectedItem);
    m_Tree_Ctrl_1 . SelectItem    (hSelectedItem);

    tdstTreeElementData * pTreeElementData = M_List1GetTreeElementData (hSelectedItem);

    // If a instance is selected, we check its lists of ZDx
    if (pTreeElementData -> eType == eInstanceElement)
    {
        CPA_BaseObject * pActor = pTreeElementData -> pObject;
        BOOL bZddListExist = m_pZDxInterface -> GetZDxList (pActor , eZdd) != NULL;
        BOOL bZdeListExist = m_pZDxInterface -> GetZDxList (pActor , eZde) != NULL;
        BOOL bZdmListExist = m_pZDxInterface -> GetZDxList (pActor , eZdm) != NULL;
        BOOL bZdrListExist = m_pZDxInterface -> GetZDxList (pActor , eZdr) != NULL;

        // If at least one list does not exist, we open a popup menu
        if (! bZddListExist || ! bZdeListExist || ! bZdmListExist || ! bZdrListExist)
        {
            CMenu PopMenu;
            POINT Pos;
            GetCursorPos (& Pos);

            PopMenu . CreatePopupMenu () ;

            if (! bZddListExist)  PopMenu . AppendMenu     (MF_STRING , C_uiPopupMenuIDCreateListZDD , "Create a new list of ZDD");
            if (! bZdeListExist)  PopMenu . AppendMenu     (MF_STRING , C_uiPopupMenuIDCreateListZDE , "Create a new list of ZDE");
            if (! bZdmListExist)  PopMenu . AppendMenu     (MF_STRING , C_uiPopupMenuIDCreateListZDM , "Create a new list of ZDM");
            if (! bZdrListExist)  PopMenu . AppendMenu     (MF_STRING , C_uiPopupMenuIDCreateListZDR , "Create a new list of ZDR");

            PopMenu . TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON , Pos . x , Pos . y , this);
            PopMenu . DestroyMenu    ();
        }
    }
}

//-----------------------------------------------------------------------------
// class CList1Window - OnCommand
// Used for the popup menu
//-----------------------------------------------------------------------------
BOOL CList1Window::OnCommand (WPARAM wParam , LPARAM lParam)
{
	switch (LOWORD (wParam))
    {
    case C_uiPopupMenuIDCreateListZDD :  CreateANewListOfZDx (eZdd);
                                         return TRUE;
    case C_uiPopupMenuIDCreateListZDE :  CreateANewListOfZDx (eZde);
                                         return TRUE;
    case C_uiPopupMenuIDCreateListZDM :  CreateANewListOfZDx (eZdm);
                                         return TRUE;
    case C_uiPopupMenuIDCreateListZDR :  CreateANewListOfZDx (eZdr);
                                         return TRUE;
    default :                            return CFormView::OnCommand (wParam , lParam);
    }
}

//-----------------------------------------------------------------------------
// class CList1Window - On_Double_Click_Tree_Ctrl_1
// We select a new list
//-----------------------------------------------------------------------------
void CList1Window::On_Double_Click_Tree_Ctrl_1 (NMHDR * pNMHDR, LRESULT * pResult) 
{
    tdstTreeElementData * pTreeElementData = M_List1GetTreeElementData (m_Tree_Ctrl_1 . GetSelectedItem ());

    switch (pTreeElementData -> eType)
    {
    // if we double-click on a family element, we open the list of the models of this family
    case eFamilyElement:        CreateListOfModelOfFamily (m_pSelectedFamily , m_pSelectedModel , m_pSelectedActor);
                                break;
    // if we double-click on a model or instance element, we open the list of the instances of this model
    case eModelElement:
    case eInstanceElement:      if (m_eList1Type != eListOfInstance)  CreateListOfInstance (m_pSelectedModel , m_pSelectedActor);
                                                                else  SetCameraOnActor (pTreeElementData -> pSuperObject);
                                break;
    }

	* pResult = TRUE;   // Do not allow the change
}

//-----------------------------------------------------------------------------
// class CList1Window - On_Return_Button
// Called when the user clic on the Return button
//-----------------------------------------------------------------------------
void CList1Window::On_Return_Button () 
{
    // If we were editinh the bounding volume, we leave the edition
    if (IsEditingBoundingVolume ())  LeaveEditionOfBoundingVolume ();
// ANNECY AV CLEAN_MEC {
/*
    else
    if (IsEditingTestPoint      ())  LeaveEditionOfTestPoint      ();
*/
// END ANNECY AV }

    switch (m_eList1Type)
    {
        case eListOfFamily:         break;
        case eListOfModel:
        case eListOfModelOfFamily:  CreateListOfFamily (m_pSelectedFamily , m_pSelectedModel);
                                    break;
        case eListOfInstance:       CreateListOfModel (m_pSelectedModel , m_pSelectedActor);
                                    break;
        case eListOfModule:         CreateListOfInstance (m_pSelectedModel , m_pSelectedActor);
                                    break;

        default:                    ASSERT (0);
                                    break;
    }
}

//-----------------------------------------------------------------------------
// class CList1Window - ShowActorAlone
// Use the Tool 3D to show the actor alone with its zones
//-----------------------------------------------------------------------------
void CList1Window::ShowActorAlone ()
{
    UpdateData (TRUE);

    // Get the T3D tool dll
    CPA_ToolDLLBase * pT3DDll = m_pZDxInterface -> GetMainWorld () -> GetToolDLLWithName (C_szDLLTool3DName);
    if (! pT3DDll)
    {
        MessageBox ("Unable to find the T3D tool dll. Operation canceled" , "Warning" , MB_OK + MB_ICONSTOP + MB_TASKMODAL);
        m_Check_Button_Show_Actor . SetCheck (FALSE);
        return;
    }

	m_pZDxInterface -> IWillRefreshDisplay (C_lOnCheckBoxShowActor);

    // If we were editing the bounding volume, we leave the edition
    if (IsEditingBoundingVolume ())
    {
        BOOL bSaveCheck = m_Check_Button_Show_Actor . GetCheck ();
        m_Check_Button_Show_Actor . SetCheck (FALSE);

        LeaveEditionOfBoundingVolume ();

        m_Check_Button_Show_Actor . SetCheck (bSaveCheck);
    }
    else
// ANNECY AV CLEAN_MEC {
/*
    if (IsEditingTestPoint ())
    {
        BOOL bSaveCheck = m_Check_Button_Show_Actor . GetCheck ();
        m_Check_Button_Show_Actor . SetCheck (FALSE);

        LeaveEditionOfTestPoint ();

        m_Check_Button_Show_Actor . SetCheck (bSaveCheck);
    }
*/
// END ANNECY AV }

    if (m_Check_Button_Show_Actor . GetCheck ())
    {
        // We find the actor to show
        ASSERT (m_pSelectedActorSuperObject);

		// We hide the zones of the selected actor, so they will be able to be shown again later
        m_pZDxInterface -> ShowZDxOfActor (m_pSelectedActorSuperObject , C_ucHideAllZDx);

        // We call the T3D tool dll to show the actor
        pT3DDll -> OnQueryOpen (m_pZDxInterface , C_wTool3D_Char , (long) m_pSelectedActorSuperObject);
        CPA_SuperObject *pSupObj = m_pZDxInterface -> M_GetWorld () -> GetRoot () -> GetSuperObjectFirstChild ();

		if (!pSupObj)
		{
			MessageBox ("This actor has no module : you cannot display it in Tool 3D" , "Warning" , MB_OK + MB_ICONSTOP + MB_TASKMODAL);
			pT3DDll -> OnQueryClose (m_pZDxInterface , 0 , 0);
			m_Check_Button_Show_Actor . SetCheck (0);
		}
		else
		{
			m_pSelectedActorSuperObject =  pSupObj;
			ReCreateCurrentList ();

			// We show the zones of the actor again
			m_pZDxInterface -> ShowZDxOfActor (m_pSelectedActorSuperObject ,
											   m_pZDxInterface -> GetList2Window () -> GetZDxTypeToShow () ,
											   m_pZDxInterface -> GetList2Window () -> GetSelectedZDx ());
		}
    }
    else
    {
		// We hide the zones of the actor, so they will be able to be showed again later
		m_pZDxInterface -> ShowZDxOfActor (m_pSelectedActorSuperObject , C_ucHideAllZDx);
        // We call the T3D tool dll to close the world
        pT3DDll -> OnQueryClose (m_pZDxInterface , 0 , 0);
        ReCreateCurrentList ();    // To compute m_pSelectedActorSuperObject again
		m_pZDxInterface -> ShowZDxOfActor (m_pSelectedActorSuperObject ,
										   m_pZDxInterface -> GetList2Window () -> GetZDxTypeToShow () ,
										   m_pZDxInterface -> GetList2Window () -> GetSelectedZDx   ());
    }

    m_pZDxInterface -> RefreshDisplay (C_lOnCheckBoxShowActor);
}

//-----------------------------------------------------------------------------
// class CList1Window - ShowModuleAlone
// Use the Tool 3D to show a module lone with its zones
//-----------------------------------------------------------------------------
void CList1Window::ShowModuleAlone ()
{
    UpdateData (TRUE);

    // Get the T3D tool dll
    CPA_ToolDLLBase * pT3DDll = m_pZDxInterface -> GetMainWorld () -> GetToolDLLWithName (C_szDLLTool3DName);
    ASSERT (pT3DDll);

	m_pZDxInterface -> IWillRefreshDisplay (C_lOnCheckBoxShowModule);

    // Find the module to show or to hide
    CPA_SuperObject * pModuleSuperObject = GetSelectedModuleSuperObject ();

	// We hide the zones of the selected module, so they will be able to be shown again later
    m_pZDxInterface -> ShowZDxOfModule (pModuleSuperObject , C_ucHideAllZDx);

    if (m_Check_Button_Show_Actor . GetCheck ())
    {
        // We call the T3D tool dll to show the module
        pT3DDll -> OnQueryOpen (m_pZDxInterface , C_wTool3D_Object , (long) pModuleSuperObject -> GetObject ());
        pModuleSuperObject = m_pZDxInterface -> M_GetWorld () -> GetRoot () -> GetSuperObjectFirstChild ();
        ReCreateCurrentList ();

		// We show the zones of the module again
		m_pZDxInterface -> ShowZDxOfModule (pModuleSuperObject ,
			                                m_pZDxInterface -> GetList2Window () -> GetZDxTypeToShow () ,
						                    m_pZDxInterface -> GetList2Window () -> GetSelectedZDx ());
    }
    else
    {
        // Go back to the list of module
        m_eList1Type = eListOfFamily;  // So that the CreateListOfModule function redraws the grid
        CreateListOfModule (m_pSelectedActorSuperObject , pModuleSuperObject -> GetObject ());
    }

    m_pZDxInterface -> RefreshDisplay (C_lOnCheckBoxShowModule);
}

//-----------------------------------------------------------------------------
// class CList1Window - On_Check_Button_Show_Actor
// Called when the user clic on the show actor button
//-----------------------------------------------------------------------------
void CList1Window::On_Check_Button_Show_Actor ()
{
    if (IsEditingZDxOfModule ())  ShowModuleAlone ();
                             else ShowActorAlone  ();
}

//-----------------------------------------------------------------------------
// class CList1Window - On_Check_Button_Show_Module
// Called when the user clic on the show module button
//-----------------------------------------------------------------------------
void CList1Window::On_Check_Button_Show_Module ()
{
    UpdateData (TRUE);

    // If we were editing the bounding volume, we leave the edition
    if (IsEditingBoundingVolume ())  LeaveEditionOfBoundingVolume ();
// ANNECY AV CLEAN_MEC {
/*
    else
    if (IsEditingTestPoint      ())  LeaveEditionOfTestPoint      ();
*/
// END ANNECY AV }

    if (m_Check_Button_Show_Module . GetCheck ())  CreateListOfModule   (m_pSelectedActorSuperObject);
                                             else  CreateListOfInstance (m_pSelectedModel , m_pSelectedActor);
}

//-----------------------------------------------------------------------------
// class CList1Window - On_Check_Button_Show_Module_ZDx
// Called when the user clic on the show module ZDx button
//-----------------------------------------------------------------------------
void CList1Window::On_Check_Button_Show_Module_ZDx ()
{
    UpdateData (TRUE);

    // If we were editinh the bounding volume, we leave the edition
    if (IsEditingBoundingVolume ())  LeaveEditionOfBoundingVolume ();
// ANNECY AV CLEAN_MEC {
/*
    else
    if (IsEditingTestPoint      ())  LeaveEditionOfTestPoint      ();
*/
// END ANNECY AV }

    if (m_Check_Button_Show_Module_ZDx . GetCheck ())  m_pZDxInterface -> ShowModuleZDxOfActor (m_pSelectedActorSuperObject);
                                                 else  m_pZDxInterface -> HideModuleZDxOfActor (m_pSelectedActorSuperObject);
}

//-----------------------------------------------------------------------------
// class CList1Window - On_Check_Button_Bounding_Volume
// Called when the user clic on the bounding volume button
//-----------------------------------------------------------------------------
void CList1Window::On_Check_Button_Bounding_Volume ()
{
    UpdateData (TRUE);

    if (m_Check_Button_Bounding_Volume . GetCheck ())  EnterEditionOfBoundingVolume ();
                                                  else LeaveEditionOfBoundingVolume ();
}

//-----------------------------------------------------------------------------
// class CList1Window - On_Check_Button_Test_Point
// Called when the user clic on the test point button
//-----------------------------------------------------------------------------
void CList1Window::On_Check_Button_Test_Point ()
{
    UpdateData (TRUE);

// ANNECY AV CLEAN_MEC {
/*
    if (m_Check_Button_Test_Point. GetCheck ())  EnterEditionOfTestPoint ();
                                            else LeaveEditionOfTestPoint ();
*/
// END ANNECY AV }
}

//-----------------------------------------------------------------------------
// class CList1Window - CreateANewListOfZDx
// Create a new list of ZDx
//-----------------------------------------------------------------------------
void CList1Window::CreateANewListOfZDx (tdeZDxType _eType)
{
    CPA_BaseObject * pActor = M_List1GetTreeElementData (m_Tree_Ctrl_1 . GetSelectedItem ()) -> pObject;

    EdtList * pBigGlobalZone = m_pZDxInterface -> CreateANewZDxList (pActor , _eType);
    if (! pBigGlobalZone)
    {
        MessageBox ("The model must have a list of names before you can create a list of objects" , "Warning" , MB_OK + MB_ICONSTOP + MB_TASKMODAL);
        return;
    }

    // Refresh the list and select the created big global zone
    SelectBigGlobalZone (pActor , pBigGlobalZone , TRUE);
}

//-----------------------------------------------------------------------------
// class CList1Window - On_Begin_Change_Name_Tree_Ctrl_1
// We see if the anme can be changed or not
//-----------------------------------------------------------------------------
void CList1Window::On_Begin_Change_Name_Tree_Ctrl_1 (NMHDR * pNMHDR , LRESULT * pResult) 
{
	TV_DISPINFO * pTVDispInfo = (TV_DISPINFO *) pNMHDR;

    HTREEITEM hSelectedItem = pTVDispInfo -> item . hItem;
    tdstTreeElementData * pTreeElementData = M_List1GetTreeElementData (hSelectedItem);

    if (pTreeElementData -> eType == eBigGlobalZoneElement)
    {
        * pResult = FALSE;    // Allow the user to change the name
    }
    else * pResult = TRUE;    // Do not allow the user to change the name
}

//-----------------------------------------------------------------------------
// class CList1Window - On_End_Change_Name_Tree_Ctrl_1
// Called when a name has been changed
//-----------------------------------------------------------------------------
void CList1Window::On_End_Change_Name_Tree_Ctrl_1 (NMHDR * pNMHDR , LRESULT * pResult) 
{
	TV_DISPINFO * pTVDispInfo = (TV_DISPINFO *) pNMHDR;

    HTREEITEM hSelectedItem = pTVDispInfo -> item . hItem;
    tdstTreeElementData * pTreeElementData = M_List1GetTreeElementData (hSelectedItem);

    // The selected item must be a big global zone
    ASSERT (pTreeElementData -> eType == eBigGlobalZoneElement);

    EdtList * pEdtList = (EdtList *) pTreeElementData -> pObject;

    // We notify the name list that the list of zones will be renamed
    pEdtList -> fn_bUnValidate ();
    ((CPA_SaveObject *) pEdtList -> GetOwner ()) -> fn_vUpdateReference (pEdtList);
    pEdtList -> fn_bValidate ();
    
    // Try to set the new name
    CString NewName = pTVDispInfo -> item . pszText;
    if (NewName . Mid (3 , 1) == ":")  NewName = NewName . Mid (4);    // remove "ZDx:" if needed
    if (! NewName . IsEmpty ())
        switch (pEdtList -> fn_eRename (NewName))
        {
        case E_mc_None             : break;  // Correct name
        case E_mc_ScriptCharacters : MessageBox ("This name contains invalid characters (space...)" , "Warning" , MB_OK + MB_ICONSTOP + MB_TASKMODAL);
                                     break;
        default                    : MessageBox ("This name already exists" , "Warning" , MB_OK + MB_ICONSTOP + MB_TASKMODAL);
        }

    // Notify the name list that the list of zones has been renamed
    ((CPA_SaveObject *) pEdtList -> GetOwner ()) -> fn_vUpdateReference (pEdtList);

    // Refresh the name to display
    ReCreateCurrentList ();

	* pResult = FALSE;
}

//-----------------------------------------------------------------------------
// class CList1Window - DeleteSelectedElement
// Delete an element
//-----------------------------------------------------------------------------
void CList1Window::DeleteSelectedElement ()
{
    // Get the selected item
    HTREEITEM hSelectedItem = m_Tree_Ctrl_1 . GetSelectedItem ();
    if (! hSelectedItem)  return;

    // One can only delete big global zones
    tdstTreeElementData * pTreeElementData = M_List1GetTreeElementData (hSelectedItem);
    if (pTreeElementData -> eType != eBigGlobalZoneElement)  return;

    tdeZDxType eZDxType = m_pZDxInterface -> ConvertListTypeToZDxType (m_pSelectedBigGlobalZone -> fn_csGetListType ());
    if (m_pZDxInterface -> DeleteZDxList (m_pSelectedActor , eZDxType))
         ReCreateCurrentList ();
    else MessageBox ("You can not delete this list because another actor or model is using it" , "Warning" , MB_OK + MB_ICONSTOP + MB_TASKMODAL);
}

//-----------------------------------------------------------------------------
// class CList1Window - On_Key_Down_Tree_Ctrl_1
// Called when a key is pressed
//-----------------------------------------------------------------------------
void CList1Window::On_Key_Down_Tree_Ctrl_1 (NMHDR * pNMHDR , LRESULT * pResult)
{
    TV_KEYDOWN * pTVKeyDown = (TV_KEYDOWN *) pNMHDR;

    switch (pTVKeyDown -> wVKey)
    {
        case VK_DELETE : DeleteSelectedElement ();  break;
    }
	
	* pResult = TRUE;
}

//-----------------------------------------------------------------------------
// class CList1Window - CreateListOfFamily
// Create the list of families
//-----------------------------------------------------------------------------
void CList1Window::CreateListOfFamily (CPA_BaseObject * _pFamilyToSelect , CPA_BaseObject * _pModelToSelect)
{
    m_bIsCreatingList = TRUE;

    if (m_eList1Type == eListOfModule)  LeaveListOfModule ();

    // _pFamilyToSelect must be the family of _pModelToSelect
    ASSERT (_pModelToSelect == NULL || _pModelToSelect -> GetOwner () == _pFamilyToSelect);

    // Init variables
    m_eList1Type = eListOfFamily;
    m_Combo_Box_String_List_1 = C_szListOfFamily;
    m_Button_Return . EnableWindow (FALSE);

    m_Tree_Ctrl_1 . DeleteAllItems ();
    HTREEITEM hHandleToSelect = NULL;

    // Get the list of all families and go through it
    CPA_BaseObjectList * pListOfFamily = M_GetMainApp () -> fn_p_oGetMainWorld () -> fn_p_oGetOriginalObjectList (C_szFamilyTypeName);
    for (long PosFamily = 0 ; PosFamily < pListOfFamily -> GetCount () ; PosFamily ++)
    {
        CPA_BaseObject * pFamily = pListOfFamily -> GetObjectWithIndex (PosFamily);

        // Insert a family into the tree
        HTREEITEM hHandleOfFamily = m_Tree_Ctrl_1 . InsertItem (pFamily -> GetName () , eFamilyElement , pFamily , NULL);

        // We select the family to select (should be good, isn't it ?). If it does not exist, we select the first family
        if (! _pFamilyToSelect)  _pFamilyToSelect = pFamily;
        if (pFamily == _pFamilyToSelect)  hHandleToSelect = hHandleOfFamily;

        // Get the list of the models of this family
        CPA_List<CPA_BaseObject> ListOfModel;
        M_GetMainApp () -> fn_p_oGetMainWorld () -> fn_lFindObjects (& ListOfModel , "" , C_szActorModelTypeName , pFamily);
        for (POSITION PosModel = ListOfModel . GetHeadPosition () ; PosModel ; )
        {
            CPA_BaseObject * pModel = ListOfModel . GetNext (PosModel);
            HTREEITEM hHandleOfModel     = m_Tree_Ctrl_1 . InsertItem (pModel -> GetName () , eModelElement , pModel , NULL , hHandleOfFamily);

            if (_pModelToSelect == pModel)  hHandleToSelect = hHandleOfModel;
        }
    }

    m_pSelectedFamily           = _pFamilyToSelect;
    m_pSelectedModel            = _pModelToSelect;
    m_pSelectedActor            = NULL;
    m_pSelectedActorSuperObject = NULL;
    m_pSelectedBigGlobalZone    = NULL;

    m_bIsCreatingList = FALSE;

    m_Tree_Ctrl_1 . Expand        (hHandleToSelect , TVE_EXPAND);
    m_Tree_Ctrl_1 . EnsureVisible (hHandleToSelect);
    m_Tree_Ctrl_1 . SelectItem    (hHandleToSelect);

    UpdateData (FALSE);             // Update the screen
}

//-----------------------------------------------------------------------------
// class CList1Window - CreateListOfModel
// Create the list of all models
//-----------------------------------------------------------------------------
void CList1Window::CreateListOfModel (CPA_BaseObject * _pModelToSelect ,
                                      CPA_BaseObject * _pActorToSelect)
{
    m_bIsCreatingList = TRUE;

    if (m_eList1Type == eListOfModule)  LeaveListOfModule ();

    // _pModelToSelect must be the model of _pInstanceToSelect
    ASSERT (_pActorToSelect == NULL || _pActorToSelect -> GetOwner () == _pModelToSelect);

    // Init variables
    m_eList1Type = eListOfModel;
    m_Combo_Box_String_List_1 = C_szListOfModel;
    m_Button_Return . EnableWindow (TRUE);

    m_Tree_Ctrl_1 . DeleteAllItems ();
    HTREEITEM hHandleToSelect = NULL;

    m_pSelectedActor            = NULL;
    m_pSelectedActorSuperObject = NULL;

    // Get the list of all models and go through it
    CPA_BaseObjectList * pListOfModel = M_GetMainApp () -> fn_p_oGetMainWorld () -> fn_p_oGetOriginalObjectList (C_szActorModelTypeName);
    for (long PosModel = 0 ; PosModel < pListOfModel -> GetCount () ; PosModel ++)
    {
        CPA_BaseObject * pModel = pListOfModel -> GetObjectWithIndex (PosModel);

        // Insert a model into the tree
        HTREEITEM hHandleOfModel = m_Tree_Ctrl_1 . InsertItem (pModel -> GetName () , eModelElement , pModel , NULL);

        // We select the model to select. If it does not exist, we select the first model
        if (! _pModelToSelect)  _pModelToSelect = pModel;
        if (pModel == _pModelToSelect)  hHandleToSelect = hHandleOfModel;

        // Get the list of the instances of this model
        CPA_List<CPA_SuperObject> * pListOfActorSuperObject = m_pZDxInterface -> GetInterface () -> GetObjectListByType (C_szActorInstanceTypeName);
        for (POSITION Pos = pListOfActorSuperObject -> GetHeadPosition () ; Pos ; )
        {
            CPA_SuperObject * pActorSuperObject = pListOfActorSuperObject -> GetNext (Pos);
            CPA_BaseObject  * pActor            = pActorSuperObject -> GetObject ();
            if (pActor -> GetOwner () == pModel)
            {
                HTREEITEM hHandleOfInstance     = m_Tree_Ctrl_1 . InsertItem (pActor -> GetName () , eInstanceElement , pActor , pActorSuperObject , hHandleOfModel);

                if (pActor == _pActorToSelect)
                {
                    hHandleToSelect = hHandleOfInstance;
                    m_pSelectedActor            = pActor;
                    m_pSelectedActorSuperObject = pActorSuperObject;
                }
            }
        }
    }

    m_pSelectedModel         = _pModelToSelect;
    m_pSelectedFamily        = m_pSelectedModel ? m_pSelectedModel -> GetOwner () : NULL;
    m_pSelectedBigGlobalZone = NULL;

    m_bIsCreatingList = FALSE;

    m_Tree_Ctrl_1 . Expand        (hHandleToSelect , TVE_EXPAND);
    m_Tree_Ctrl_1 . EnsureVisible (hHandleToSelect);
    m_Tree_Ctrl_1 . SelectItem    (hHandleToSelect);

    UpdateData (FALSE);             // Update the screen
}

//-----------------------------------------------------------------------------
// class CList1Window - CreateListOfModelOfFamily
// Create the list of the models of a given family
//-----------------------------------------------------------------------------
void CList1Window::CreateListOfModelOfFamily (CPA_BaseObject * _pFamily ,
                                              CPA_BaseObject * _pModelToSelect ,
                                              CPA_BaseObject * _pActorToSelect)
{
    m_bIsCreatingList = TRUE;

    if (m_eList1Type == eListOfModule)  LeaveListOfModule ();

    // _pFamily must be the family of _pModelToSelect
    ASSERT (_pModelToSelect == NULL || _pModelToSelect -> GetOwner () == _pFamily);
    // _pModelToSelect must be the model of _pActorToSelect
    ASSERT (_pActorToSelect == NULL || _pActorToSelect -> GetOwner () == _pModelToSelect);

    // Init variables
    m_eList1Type = eListOfModelOfFamily;
    m_Combo_Box_String_List_1 = C_szListOfModelOfFamily;
    m_Button_Return . EnableWindow (TRUE);

    m_Tree_Ctrl_1 . DeleteAllItems ();
    HTREEITEM hHandleToSelect = NULL;

    m_pSelectedActor            = NULL;
    m_pSelectedActorSuperObject = NULL;

    // Get the list of the models of the family and go through it
    CPA_List<CPA_BaseObject> ListOfModel;
    M_GetMainApp () -> fn_p_oGetMainWorld () -> fn_lFindObjects (& ListOfModel , "" , C_szActorModelTypeName , _pFamily);
    for (POSITION PosModel = ListOfModel . GetHeadPosition () ; PosModel ; )
    {
        // Insert a model into the tree
        CPA_BaseObject * pModel = ListOfModel . GetNext (PosModel);
        HTREEITEM hHandleOfModel = m_Tree_Ctrl_1 . InsertItem (pModel -> GetName () , eModelElement , pModel , NULL);

        // We select the model to select. If it does not exist, we select the first model
        if (! _pModelToSelect)  _pModelToSelect = pModel;
        if (pModel == _pModelToSelect)  hHandleToSelect = hHandleOfModel;

        // Get the list of the instances of this model
        CPA_List<CPA_SuperObject> * pListOfActorSuperObject = m_pZDxInterface -> GetInterface () -> GetObjectListByType (C_szActorInstanceTypeName);
        for (POSITION Pos = pListOfActorSuperObject -> GetHeadPosition () ; Pos ; )
        {
            CPA_SuperObject * pActorSuperObject = pListOfActorSuperObject -> GetNext (Pos);
            CPA_BaseObject  * pActor            = pActorSuperObject -> GetObject ();
            if (pActor -> GetOwner () == pModel)
            {
                HTREEITEM hHandleOfInstance     = m_Tree_Ctrl_1 . InsertItem (pActor -> GetName () , eInstanceElement , pActor , pActorSuperObject , hHandleOfModel);

                if (pActor == _pActorToSelect)
                {
                    hHandleToSelect = hHandleOfInstance;
                    m_pSelectedActor            = pActor;
                    m_pSelectedActorSuperObject = pActorSuperObject;
                }
            }
        }
    }

    m_pSelectedFamily        = _pFamily;
    m_pSelectedModel         = _pModelToSelect;
    m_pSelectedBigGlobalZone = NULL;

    m_bIsCreatingList = FALSE;

    m_Tree_Ctrl_1 . Expand        (hHandleToSelect , TVE_EXPAND);
    m_Tree_Ctrl_1 . EnsureVisible (hHandleToSelect);
    m_Tree_Ctrl_1 . SelectItem    (hHandleToSelect);

    UpdateData (FALSE);             // Update the screen
}

//-----------------------------------------------------------------------------
// class CList1Window - CreateListOfInstance
// Create the list of the instances of a given model
//-----------------------------------------------------------------------------
void CList1Window::CreateListOfInstance (CPA_BaseObject * _pModel ,
                                         CPA_BaseObject * _pActorToSelect ,
                                         EdtList        * _pBigGlobalZoneToSelect)
{
    m_bIsCreatingList = TRUE;

    if (m_eList1Type == eListOfModule)  LeaveListOfModule ();


    // _pModel must be the model of _pInstanceToSelect
    ASSERT (_pActorToSelect == NULL || _pActorToSelect -> GetOwner () == _pModel);

    // Init variables
    m_eList1Type = eListOfInstance;
    m_Combo_Box_String_List_1 = C_szListOfInstance;
    m_Button_Return . EnableWindow (TRUE);

    m_Tree_Ctrl_1 . DeleteAllItems ();
    HTREEITEM hHandleToSelect = NULL;

    // Get the list of the instances of the model and go through it
    CPA_List<CPA_SuperObject> * pListOfActorSuperObject = m_pZDxInterface -> GetInterface () -> GetObjectListByType (C_szActorInstanceTypeName);
    for (POSITION Pos = pListOfActorSuperObject -> GetHeadPosition () ; Pos ; )
    {
        CPA_SuperObject * pActorSuperObject = pListOfActorSuperObject -> GetNext (Pos);
        CPA_BaseObject  * pActor            = pActorSuperObject -> GetObject ();
        if (pActor -> GetOwner () == _pModel)
        {
            // Insert an instance into the tree
            HTREEITEM hHandleOfActor = m_Tree_Ctrl_1 . InsertItem (pActor -> GetName () , eInstanceElement , pActor , pActorSuperObject);

            // We select the instance to select. If it does not exist, we select the first instance
            if (! _pActorToSelect)  _pActorToSelect = pActor;
            if (pActor == _pActorToSelect)
            {
                hHandleToSelect             = hHandleOfActor;
                m_pSelectedActorSuperObject = pActorSuperObject;
            }

            // Insert the 4 big global zones of the actor into the tree, if they exist
            EdtList * pBigGlobalZone;
            char Name [256];
            if (pBigGlobalZone = m_pZDxInterface -> GetZDxList (pActor , eZdd))
            {
                strcpy (Name , "ZDD:");
                strcat (Name , pBigGlobalZone -> GetName ());
                HTREEITEM hHandleOfBigGlobalZone = m_Tree_Ctrl_1 . InsertItem
                                        (Name , eBigGlobalZoneElement , pBigGlobalZone , NULL , hHandleOfActor);
                if (_pBigGlobalZoneToSelect == pBigGlobalZone && pActor == _pActorToSelect)  hHandleToSelect = hHandleOfBigGlobalZone;
            }
            if (pBigGlobalZone = m_pZDxInterface -> GetZDxList (pActor , eZde))
            {
                strcpy (Name , "ZDE:");
                strcat (Name , pBigGlobalZone -> GetName ());
                HTREEITEM hHandleOfBigGlobalZone = m_Tree_Ctrl_1 . InsertItem
                                        (Name , eBigGlobalZoneElement , pBigGlobalZone , NULL , hHandleOfActor);
                if (_pBigGlobalZoneToSelect == pBigGlobalZone && pActor == _pActorToSelect)  hHandleToSelect = hHandleOfBigGlobalZone;
            }
            if (pBigGlobalZone = m_pZDxInterface -> GetZDxList (pActor , eZdm))
            {
                strcpy (Name , "ZDM:");
                strcat (Name , pBigGlobalZone -> GetName ());
                HTREEITEM hHandleOfBigGlobalZone = m_Tree_Ctrl_1 . InsertItem
                                        (Name , eBigGlobalZoneElement , pBigGlobalZone , NULL , hHandleOfActor);
                if (_pBigGlobalZoneToSelect == pBigGlobalZone && pActor == _pActorToSelect)  hHandleToSelect = hHandleOfBigGlobalZone;
            }
            if (pBigGlobalZone = m_pZDxInterface -> GetZDxList (pActor , eZdr))
            {
                strcpy (Name , "ZDR:");
                strcat (Name , pBigGlobalZone -> GetName ());
                HTREEITEM hHandleOfBigGlobalZone = m_Tree_Ctrl_1 . InsertItem
                                        (Name , eBigGlobalZoneElement , pBigGlobalZone , NULL , hHandleOfActor);
                if (_pBigGlobalZoneToSelect == pBigGlobalZone && pActor == _pActorToSelect)  hHandleToSelect = hHandleOfBigGlobalZone;
            }
        }
    }

    m_pSelectedModel         = _pModel;
    m_pSelectedFamily        = m_pSelectedModel ? m_pSelectedModel -> GetOwner () : NULL;

    m_bIsCreatingList = FALSE;

    if (hHandleToSelect)
    {
        m_pSelectedActor         = _pActorToSelect;
        m_pSelectedBigGlobalZone = _pBigGlobalZoneToSelect;

        m_Tree_Ctrl_1 . Expand        (hHandleToSelect , TVE_EXPAND);
        m_Tree_Ctrl_1 . EnsureVisible (hHandleToSelect);
        m_Tree_Ctrl_1 . SelectItem    (hHandleToSelect);
    }
    else
    {
        m_pSelectedActor            = NULL;
        m_pSelectedActorSuperObject = NULL;
        m_pSelectedBigGlobalZone    = NULL;
        m_Check_Button_Show_Actor      . EnableWindow (FALSE);
        m_Check_Button_Show_Module     . EnableWindow (FALSE);
        m_Check_Button_Show_Module_ZDx . EnableWindow (FALSE);
        m_Check_Button_Bounding_Volume . EnableWindow (FALSE);
        m_Check_Button_Test_Point      . EnableWindow (FALSE);
    }

    UpdateData (FALSE);             // Update the screen
}

//-----------------------------------------------------------------------------
// class CList1Window - CreateListOfModule
// Create the list of the modules of a given table
//-----------------------------------------------------------------------------
void CList1Window::CreateListOfModule (CPA_SuperObject * _pActorSuperObject ,
                                       CPA_BaseObject  * _pModuleToSelect ,
                                       BOOL              _bOpenGrid /* = TRUE */) 
{
    m_bIsCreatingList = TRUE;

    // We set the state of the buttons
    m_Check_Button_Show_Module     . SetCheck (TRUE);
    m_Check_Button_Show_Module_ZDx . SetCheck (FALSE);

    CPA_Actor      * pActor  = (CPA_Actor *) _pActorSuperObject -> GetObject ();
    CPA_BaseObject * pFamily = pActor -> GetOwner () -> GetOwner ();

    // We get the object table
   tdxHandleToObjectsTablesList  hObjectTable = fn_h3dDataGetCurrentObjectsTable (M_GetMSHandle (_pActorSuperObject -> GetStruct () , 3dData));
    CPA_BaseObject             * pObjectTable = m_pZDxInterface -> GetMainWorld () -> fn_p_oFindObjectWithEngine (hObjectTable , C_szObjectTableTypeName , pFamily);

    if (! pObjectTable)
    {
        MessageBox ("This actor has no object table" , "Warning" , MB_OK + MB_ICONSTOP + MB_TASKMODAL);
        m_Check_Button_Show_Module . SetCheck (FALSE);
        UpdateData (FALSE);
        m_bIsCreatingList = FALSE;
        return;
    }

    if (m_eList1Type != eListOfModule && _bOpenGrid)
    {
        // Get the T3D tool dll
        CPA_ToolDLLBase * pT3DDll = m_pZDxInterface -> GetMainWorld () -> GetToolDLLWithName (C_szDLLTool3DName);
        if (! pT3DDll)
        {
            MessageBox ("Unable to find the T3D tool dll. You will not be able to edit module zones" , "Warning" , MB_OK + MB_ICONSTOP + MB_TASKMODAL);
            m_Check_Button_Show_Module . SetCheck (FALSE);
            UpdateData (FALSE);
            m_bIsCreatingList = FALSE;
            return;
        }

	    // We hide the zones of the selected actor, so they will be able to be shown again later
        m_pZDxInterface -> ShowZDxOfActor (_pActorSuperObject , C_ucHideAllZDx);
        m_pZDxInterface -> HideModuleZDxOfActor (_pActorSuperObject);

		if (((CPA_Actor *) m_pSelectedActor)->m_fn_bIsAnAlways())
		{
			pT3DDll->OnQueryClose(m_pZDxInterface, 0, 0);
		}
        // We call the T3D tool dll to show the object table into the grid
        BOOL bGridOpen = (BOOL) pT3DDll -> OnQueryOpen (m_pZDxInterface , C_wTool3D_Table , (long) pObjectTable);
        if (! bGridOpen)
        {
            MessageBox ("This actor does not have any module" , "Warning" , MB_OK + MB_ICONSTOP + MB_TASKMODAL);
            m_Check_Button_Show_Module . SetCheck (FALSE);
            UpdateData (FALSE);
            m_bIsCreatingList = FALSE;
            return;
        }
    }

    m_Tree_Ctrl_1 . LockWindowUpdate ();    // Prevent from redrawing the tree needlessly

    // Init variables
    m_eList1Type = eListOfModule;
    m_Combo_Box_String_List_1 = C_szListOfModule;
    m_Button_Return . EnableWindow (TRUE);

    m_Tree_Ctrl_1 . DeleteAllItems ();
    HTREEITEM hHandleToSelect = NULL;

    // Get the list of the module in the object table and go through it
    CPA_SuperObject * pRootSuperObject   = m_pZDxInterface -> M_GetWorld () -> GetRoot ();
    CPA_SuperObject * pModuleSuperObject = pRootSuperObject -> GetSuperObjectFirstChild ();
    while (pModuleSuperObject)
    {
        CPA_BaseObject * pObject = pModuleSuperObject -> GetObject ();
        if (pObject == NULL || ! pObject -> fn_bIsOfType (C_szPhysicalObjectTypeName))
        {
            pModuleSuperObject = pRootSuperObject -> GetSuperObjectNextChild (pModuleSuperObject);
            continue;
        }

        EditorPO * pModule = (EditorPO *) pObject;

        // Insert a module into the tree
        HTREEITEM hHandleOfModule = m_Tree_Ctrl_1 . InsertItem (pModule -> GetName () , eModuleElement , pModule , pModuleSuperObject);
        // We select the module to select. If it does not exist, we select the first module
        if (hHandleToSelect == NULL || pModule == _pModuleToSelect)  hHandleToSelect = hHandleOfModule;

        // Insert the Zdd into the tree
        ZDx_Object * pZdd = (ZDx_Object *) pModule -> GetZone (C_ucTypeZdd);
        if (pZdd)  m_Tree_Ctrl_1 . InsertItem (pZdd -> GetName () , eZddElement , pZdd , NULL , hHandleOfModule);

        // Insert the Zde into the tree
        ZDx_Object * pZde = (ZDx_Object *) pModule -> GetZone (C_ucTypeZde);
        if (pZde)  m_Tree_Ctrl_1 . InsertItem (pZde -> GetName () , eZdeElement , pZde , NULL , hHandleOfModule);

        // Insert the Zdm into the tree
        ZDx_Object * pZdm = (ZDx_Object *) pModule -> GetZone (C_ucTypeZdm);
        if (pZdm)  m_Tree_Ctrl_1 . InsertItem (pZdm -> GetName () , eZdmElement , pZdm , NULL , hHandleOfModule);

        // Insert the Zdr into the tree
        ZDx_Object * pZdr = (ZDx_Object *) pModule -> GetZone (C_ucTypeZdr);
//ROMTEAM WorldEditor (Cristi Petrescu 12/97)
        if (pZdr && pZdr -> fn_bIsOfType (C_szZdrName))  m_Tree_Ctrl_1 . InsertItem (pZdr -> GetName () , eZdrElement , pZdr , NULL , hHandleOfModule);
//ENDROMTEAM WorldEditor (Cristi Petrescu)

        pModuleSuperObject = pRootSuperObject -> GetSuperObjectNextChild (pModuleSuperObject);
    }

    // Now look what modules are used in the current frame of the current animation of the actor
    CPA_SuperObject * pChildSuperObject = _pActorSuperObject -> GetSuperObjectFirstChild ();
    while (pChildSuperObject)
    {
        ChangeIconOfModuleAndChild (pChildSuperObject);
        pChildSuperObject = _pActorSuperObject -> GetSuperObjectNextChild (pChildSuperObject);
    }

    m_pSelectedBigGlobalZone = NULL;
    m_pSelectedActorSuperObject = _pActorSuperObject;
    m_pSelectedActor            = pActor;
    m_pSelectedModel            = m_pSelectedActor ? m_pSelectedActor -> GetOwner () : NULL;
    m_pSelectedFamily           = m_pSelectedModel ? m_pSelectedModel -> GetOwner () : NULL;

    m_bIsCreatingList = FALSE;

    m_Tree_Ctrl_1 . Expand        (hHandleToSelect , TVE_EXPAND);
    m_Tree_Ctrl_1 . EnsureVisible (hHandleToSelect);
    m_Tree_Ctrl_1 . SelectItem    (hHandleToSelect);

    m_Tree_Ctrl_1 . UnlockWindowUpdate ();  // Allow to redraw the tree
    m_Tree_Ctrl_1 . Invalidate ();          // Redraw the tree

    UpdateData (FALSE);             // Update the screen
}

//-----------------------------------------------------------------------------
// class CList1Window - LeaveListOfModule
// Close the T3D world
//-----------------------------------------------------------------------------
void CList1Window::LeaveListOfModule ()
{
    // We uncheck the "Show module" button, and the "Show actor" button (this is necessary)
    m_Check_Button_Show_Module . SetCheck (FALSE);
    m_Check_Button_Show_Actor  . SetCheck (FALSE);

    // Get the T3D tool dll
    CPA_ToolDLLBase * pT3DDll = m_pZDxInterface -> GetMainWorld () -> GetToolDLLWithName (C_szDLLTool3DName);
    ASSERT (pT3DDll);    // It must be there

    // We hide the zones of the actor, so they will be able to be showed again later
	m_pZDxInterface -> ShowZDxOfActor (m_pSelectedActorSuperObject , C_ucHideAllZDx);
    // We call the T3D tool dll to close the world
    pT3DDll -> OnQueryClose (m_pZDxInterface , 0 , 0);
    m_pSelectedActorSuperObject = ((CPA_Actor *) m_pSelectedActor) -> m_pub_fn_pclGetSuperObject ();
	if (((CPA_Actor *) m_pSelectedActor)->m_fn_bIsAnAlways())
	{
		pT3DDll->OnQueryOpen(m_pZDxInterface, C_wTool3D_Char, (long)m_pSelectedActorSuperObject);
	}
	m_pZDxInterface -> ShowZDxOfActor (m_pSelectedActorSuperObject ,
                                       m_pZDxInterface -> GetList2Window () -> GetZDxTypeToShow () ,
                                       m_pZDxInterface -> GetList2Window () -> GetSelectedZDx   ());

    UpdateData (FALSE);    //   Refresh the screen
}

//-----------------------------------------------------------------------------
// class CList1Window - ReCreateCurrentList
// Refresh the current list
//-----------------------------------------------------------------------------
void CList1Window::ReCreateCurrentList ()
{
    switch (m_eList1Type)
    {
    case eListOfFamily:         CreateListOfFamily        (m_pSelectedFamily , m_pSelectedModel);                    break;
    case eListOfModel:          CreateListOfModel         (m_pSelectedModel  , m_pSelectedActor);                    break;
    case eListOfModelOfFamily:  CreateListOfModelOfFamily (m_pSelectedFamily , m_pSelectedModel , m_pSelectedActor); break;
    case eListOfInstance:       CreateListOfInstance      (m_pSelectedModel , m_pSelectedActor , m_pSelectedBigGlobalZone);
                                                                                                                     break;
    case eListOfModule:         CreateListOfModule        (m_pSelectedActorSuperObject , GetSelectedModule ());      break;
    default:                    ASSERT (0);                                                                          break;
    }

    if (m_pSelectedActor == NULL)
        m_pZDxInterface -> GetList2Window () -> CreateListOfZDx (NULL , NULL , NULL , NULL , NULL);
}

//-----------------------------------------------------------------------------
// class CList1Window - FindAnElementInTree
// Recursiv function to find in the current tree the element whose data is _pData.
// Returns a handle to this element
//-----------------------------------------------------------------------------
HTREEITEM CList1Window::FindAnElementInTree (HTREEITEM _hItem , void * _pObject , void * _pParentObject /* = NULL */)
{
    while (_hItem)
    {
        // Is it this item and Parent is null ?
        if (_pParentObject == NULL && M_List1GetTreeElementData (_hItem) -> pObject == _pObject)  return _hItem;

        // If we have found the parent, we send NULL instead so that the function will be able to find pObject
        void * pParentObjectToSend;
        if (M_List1GetTreeElementData (_hItem) -> pObject == _pParentObject)   pParentObjectToSend = NULL;
                                                                         else  pParentObjectToSend = _pParentObject;
        // Get the first child
        HTREEITEM hChildItem = m_Tree_Ctrl_1 . GetChildItem (_hItem);
        if (hChildItem)
        {
            // Recursiv call. 
            HTREEITEM hResultItem = FindAnElementInTree (hChildItem , _pObject , pParentObjectToSend);
            if (hResultItem)  return hResultItem;
        }

        // Get the next brother
        _hItem = m_Tree_Ctrl_1 . GetNextItem (_hItem , TVGN_NEXT);
    }

    // Not found
    return NULL;
}

//-----------------------------------------------------------------------------
// class CList1Window - ChangeIconOfModuleAndChild
// Change the icon in the list of the given module and its childs
//-----------------------------------------------------------------------------
void CList1Window::ChangeIconOfModuleAndChild (CPA_SuperObject * _pSuperObject)
{
    CPA_BaseObject * pObject = _pSuperObject -> GetObject ();
    if (pObject && pObject -> fn_bIsOfType (C_szPhysicalObjectTypeName))
    {
        HTREEITEM hItem = FindAnElementInTree (m_Tree_Ctrl_1 . GetRootItem () , pObject);
        if (hItem)  m_Tree_Ctrl_1 . SetItemImage (hItem , C_ucIconUsedModule , C_ucIconUsedModule);
    }

    CPA_SuperObject * pChildSuperObject = _pSuperObject -> GetSuperObjectFirstChild ();
    while (pChildSuperObject)
    {
        ChangeIconOfModuleAndChild (pChildSuperObject);
        pChildSuperObject = _pSuperObject -> GetSuperObjectNextChild (pChildSuperObject);
    }
}

//-----------------------------------------------------------------------------
// class CList1Window - SelectInstance
// Select a instance in the list. If necessary, change the list
//-----------------------------------------------------------------------------
void CList1Window::SelectInstance (CPA_BaseObject * _pInstanceToSelect , BOOL bRefreshNeeded)
{
    switch (m_eList1Type)
    {
    case eListOfFamily:
    case eListOfModule:
        {
        CPA_BaseObject * pModel  = _pInstanceToSelect -> GetOwner ();
        CreateListOfInstance (pModel , _pInstanceToSelect);
        }
        break;

    case eListOfModelOfFamily:
        // if the instance to select does not have the same family as the current family,
        // we create the list again with the correct family
        if (_pInstanceToSelect -> GetOwner () -> GetOwner () != m_pSelectedFamily)
        {
            CreateListOfModelOfFamily (_pInstanceToSelect -> GetOwner () -> GetOwner () , _pInstanceToSelect -> GetOwner () ,
                                       _pInstanceToSelect);
            break;
        }
        // else, we find the instance into the tree

    case eListOfInstance:
        // if the instance to select does not have the same model as the current model,
        // we create the list again with the correct model
        if (_pInstanceToSelect -> GetOwner () != m_pSelectedModel)
        {
            CreateListOfInstance (_pInstanceToSelect -> GetOwner () , _pInstanceToSelect);
            break;
        }
        // else, we find the instance into the tree

    case eListOfModel:
        {
        if (bRefreshNeeded)  ReCreateCurrentList ();    // If needed, refresh the list

        // Find the instance to select
        HTREEITEM hItem = FindAnElementInTree (m_Tree_Ctrl_1 . GetRootItem () , _pInstanceToSelect);
        ASSERT (hItem);

        m_Tree_Ctrl_1 . Expand        (hItem , TVE_EXPAND);
        m_Tree_Ctrl_1 . EnsureVisible (hItem);
        m_Tree_Ctrl_1 . SelectItem    (hItem);
        }
        break;

    default:
        ASSERT (0);
    }
}

//-----------------------------------------------------------------------------
// class CList1Window - SelectBigGlobalZone
// Select a big global zone in the list. If necessary, change the list
//-----------------------------------------------------------------------------
void CList1Window::SelectBigGlobalZone (CPA_BaseObject * _pActor ,
                                        EdtList        * _pBigGlobalZoneToSelect , BOOL bRefreshNeeded)
{
    switch (m_eList1Type)
    {
    case eListOfFamily:
    case eListOfModel:
    case eListOfModelOfFamily:
    case eListOfModule:
        {
        CPA_BaseObject * pModel  = _pActor -> GetOwner ();
        CreateListOfInstance (pModel , _pActor , _pBigGlobalZoneToSelect);
        }
        break;

    case eListOfInstance:
        // if the Actor to select does not have the same model as the current model,
        // we create the list again with the correctmodel
        if (_pActor -> GetOwner () != m_pSelectedModel)
        {
            CreateListOfInstance (_pActor -> GetOwner () , _pActor , _pBigGlobalZoneToSelect);
            break;
        }
        // else, we find the Actor into the tree
        {
        if (bRefreshNeeded)  ReCreateCurrentList ();    // If needed, refresh the list

        // Find the Actor
        HTREEITEM hItem = FindAnElementInTree (m_Tree_Ctrl_1 . GetRootItem () , _pActor);
        ASSERT (hItem);
        // Find the big global zone to select among the childs of the Actor
        hItem = m_Tree_Ctrl_1 . GetChildItem (hItem);
        while (M_List1GetTreeElementData (hItem) -> pObject != _pBigGlobalZoneToSelect)
        {
            hItem = m_Tree_Ctrl_1 . GetNextItem (hItem , TVGN_NEXT);
            // We must find the big global zone before we reach the end
            ASSERT (hItem);
        }

        // We select the big global zone
        m_Tree_Ctrl_1 . SelectItem    (hItem);
        m_Tree_Ctrl_1 . EnsureVisible (hItem);
        }
    }
}

//-----------------------------------------------------------------------------
// class CList1Window - SelectZDxOfActor
// Select a ZDx in the list. If necessary, change the list
//-----------------------------------------------------------------------------
void CList1Window::SelectZDxOfActor (CPA_BaseObject * _pActor , ZDx_Object * _pZDxObject , BOOL _bRefreshNeeded)
{
    // If the selected item is _pActor, we only select the ZDx in the List2Window
    HTREEITEM hSelectedItem = m_Tree_Ctrl_1 . GetSelectedItem ();
    if (hSelectedItem)
    {
        CPA_BaseObject * pSelectedObject = M_List1GetTreeElementData (hSelectedItem) -> pObject;
        if (pSelectedObject == _pActor)
        {
            if (_bRefreshNeeded)  ReCreateCurrentList ();

            m_pZDxInterface -> GetList2Window () -> SelectZDx (_pZDxObject);
            return;
        }
    }

    // Otherwise, we select the Actor in the list 1, and the zone in the list 2
    SelectInstance (_pActor , _bRefreshNeeded);
    m_pZDxInterface -> GetList2Window () -> SelectZDx (_pZDxObject);
}

//-----------------------------------------------------------------------------
// class CList1Window - SelectZDxOfModule
// Select a ZDx in the list
//-----------------------------------------------------------------------------
void CList1Window::SelectZDxOfModule (CPA_BaseObject * _pModule , ZDx_Object * _pZDxObject , BOOL _bRefreshNeeded)
{
    // The current list must be the list of module
    ASSERT (m_eList1Type == eListOfModule);

    if (_bRefreshNeeded)  CreateListOfModule (m_pSelectedActorSuperObject , _pModule);

    // Find the ZDx object
    HTREEITEM hItem = FindAnElementInTree (m_Tree_Ctrl_1 . GetRootItem () , _pZDxObject , _pModule);

    // Sometimes, the item is not into the list (for an Undo delete for instance, the zone is reinserted into the hierarchy and so selected,
    // before it is inserted into the module, so when creating the list, one cannot find it). In this case, we do nothing
    if (! hItem)  return;   

    // We select the ZDx object
    m_Tree_Ctrl_1 . SelectItem    (hItem);
    m_Tree_Ctrl_1 . EnsureVisible (hItem);

    // We select the ZDx object into the list 2
    m_pZDxInterface -> GetList2Window () -> SelectZDx (_pZDxObject);
}

//-----------------------------------------------------------------------------
// class CList1Window - GetSelectedModuleSuperObject
// Get the selected module super object in the list
//-----------------------------------------------------------------------------
CPA_SuperObject * CList1Window::GetSelectedModuleSuperObject ()
{
    ASSERT (m_eList1Type == eListOfModule);

    // We get the selected item
    HTREEITEM             hSelectedItem    = m_Tree_Ctrl_1 . GetSelectedItem ();
    tdstTreeElementData * pTreeElementData = M_List1GetTreeElementData (hSelectedItem);
    // If it is a module, ok
    if (pTreeElementData -> eType == eModuleElement)  return pTreeElementData -> pSuperObject;
    else
    // Else, if it is a zone, we return its parent
    if (pTreeElementData -> eType == eZddElement || pTreeElementData -> eType == eZdeElement ||
        pTreeElementData -> eType == eZdmElement || pTreeElementData -> eType == eZdrElement)
        return M_List1GetTreeElementData (m_Tree_Ctrl_1 . GetParentItem (hSelectedItem)) -> pSuperObject;
    else
    {
        ASSERT (0);
        return NULL;
    }
}

//-----------------------------------------------------------------------------
// class CList1Window - GetSelectedModule
// Get the selected module in the list
//-----------------------------------------------------------------------------
CPA_BaseObject * CList1Window::GetSelectedModule ()
{
    return GetSelectedModuleSuperObject () -> GetObject ();
}

//-----------------------------------------------------------------------------
// class CList1Window - SelectModule
// Select a module in the list
//-----------------------------------------------------------------------------
void CList1Window::SelectModule (CPA_BaseObject * _pModule , BOOL _bRefreshNeeded)
{
    // The current list must be the list of module
    ASSERT (m_eList1Type == eListOfModule);

    if (_bRefreshNeeded)  ReCreateCurrentList ();

    // Find the module, and it MUST exist
    HTREEITEM hItem = FindAnElementInTree (m_Tree_Ctrl_1 . GetRootItem () , _pModule);
    ASSERT (hItem);

    // We select the module
    m_Tree_Ctrl_1 . Expand        (hItem , TVE_EXPAND);
    m_Tree_Ctrl_1 . SelectItem    (hItem);
    m_Tree_Ctrl_1 . EnsureVisible (hItem);
}

//-----------------------------------------------------------------------------
// class CList1Window - SetShowActorButtonState
// Set the state of the "Show Actor" check button
//-----------------------------------------------------------------------------
void CList1Window::SetShowActorButtonState (BOOL _bButtonChecked)
{
    m_Check_Button_Show_Actor . SetCheck (_bButtonChecked);
    UpdateData (FALSE);    // Refresh the screen
}

//-----------------------------------------------------------------------------
// class CList1Window - SetCameraOnActor
// Set the focus of the current camera to the given actor
//-----------------------------------------------------------------------------
void CList1Window::SetCameraOnActor (CPA_SuperObject * _pActorSuperObject)
{
    m_pZDxInterface -> IWillRefreshDisplay (C_ucSetCamera);

    DEV_ViewPort3D * pViewPort = (DEV_ViewPort3D *) m_pZDxInterface -> GetInterface   () -> GetMultiDevice ()
                                                                    -> GetFocusDevice () -> GetViewPort ();
    CPA_CameraDLLBase * pCameraInterface = pViewPort -> GetCameraInterface ();
    CPA_BaseObject    * pCamera          = pViewPort -> GetCamera          ();
    
    pCameraInterface -> SetTargetSuperObject (pCamera , _pActorSuperObject);
    pCameraInterface -> SetTargetType        (pCamera , tSuperObject);
    pCameraInterface -> Update               (pCamera);
    pCameraInterface -> SetTargetType        (pCamera , tNone);

    m_pZDxInterface -> RefreshDisplay (C_ucSetCamera);
}

//-----------------------------------------------------------------------------
// class CList1Window - EnterEditionOfBoundingVolume
// Enter the edition of the bounding volume of a family
//-----------------------------------------------------------------------------
void CList1Window::EnterEditionOfBoundingVolume ()
{
    m_pZDxInterface -> IWillRefreshDisplay (C_lEnterBoundingVolume);

// ANNECY AV CLEAN_MEC {
//    if (IsEditingTestPoint ())  LeaveEditionOfTestPoint ();
// END ANNECY AV }

    m_Check_Button_Bounding_Volume . SetCheck (TRUE);
    UpdateData (FALSE);

    // Show the global zones but they cannot be selected
    m_pZDxInterface -> ShowZDxOfActor (m_pSelectedActorSuperObject , m_pZDxInterface -> GetList2Window () -> GetZDxTypeToShow () ,
                                       NULL , FALSE , TRUE);

    // Show the bounding volume, if it exists
    ZDx_Object * pBoundingVolume = (ZDx_Object *) ((CPA_Family *) m_pSelectedFamily) -> mfn_p_oGetBoundingVolume ();
//    if (pBoundingVolume)
//        m_pZDxInterface -> ShowBoundingVolume (m_pSelectedActorSuperObject , pBoundingVolume , TRUE);

    m_pZDxInterface -> GetList2Window () -> CreateBoundingVolume (m_pSelectedActorSuperObject   , pBoundingVolume);

    m_pZDxInterface -> RefreshDisplay (C_lEnterBoundingVolume);
}

//-----------------------------------------------------------------------------
// class CList1Window - LeaveEditionOfBoundingVolume
// Leave the edition of the bounding volume of a family
//-----------------------------------------------------------------------------
void CList1Window::LeaveEditionOfBoundingVolume ()
{
	GEO_tdxHandleToBoundingSphere	hFamilyBoundingSphere;
	MTH3D_tdstVector				stCenter;
	MTH_tdxReal						xRadius;

//ANNECY TQ 30/06/98{
// ANNECY AV {
    if (((CPA_Family *)m_pSelectedFamily)->mfn_p_oGetBoundingVolume())    // Don't try to update the bounding volume if it does not exist !
// END ANNECY AV }
    {
	    hFamilyBoundingSphere = fn_vGetBoundingVolumeOfFamily(((CPA_Family *)m_pSelectedFamily)->GetStruct());
	    GEO_fn_vGetInfoFromGeometricSphere(&stCenter, &xRadius, (GEO_tdstGeometricObject *)(((CPA_Family *)m_pSelectedFamily)->mfn_p_oGetBoundingVolume()->GetData()));
	    GEO_fn_vSetBoundingSphere(hFamilyBoundingSphere, &stCenter, xRadius);
    }
//ENDANNECY TQ}

    m_pZDxInterface -> IWillRefreshDisplay (C_lLeaveBoundingVolume);
	
    m_Check_Button_Bounding_Volume . SetCheck (FALSE);
    UpdateData (FALSE);
    // Hide the bounding volume and show the global zones so that they can be selected
    m_pZDxInterface -> ShowZDxOfActor (m_pSelectedActorSuperObject , m_pZDxInterface -> GetList2Window () -> GetZDxTypeToShow ());
	ReCreateCurrentList ();
	
    m_pZDxInterface -> RefreshDisplay (C_lLeaveBoundingVolume);
}

//-----------------------------------------------------------------------------
// class CList1Window - EnterEditionOfTestPoint
// Enter the edition of the test points of a family
//-----------------------------------------------------------------------------
// ANNECY AV CLEAN_MEC {
/*
void CList1Window::EnterEditionOfTestPoint ()
{
    m_pZDxInterface -> IWillRefreshDisplay (C_lEnterTestPoint);

    if (IsEditingBoundingVolume ())  LeaveEditionOfBoundingVolume ();

    m_Check_Button_Test_Point . SetCheck (TRUE);
    UpdateData (FALSE);

    // Hide the global zones
    m_pZDxInterface -> ShowZDxOfActor (m_pSelectedActorSuperObject , C_ucHideAllZDx);

    m_pZDxInterface -> GetList2Window () -> CreateListOfTestPoint (m_pSelectedActorSuperObject);

    m_pZDxInterface -> RefreshDisplay (C_lEnterTestPoint);
}
*/
// END ANNECY AV }

//-----------------------------------------------------------------------------
// class CList1Window - LeaveEditionOfTestPoint
// Leave the edition of the test points of a family
//-----------------------------------------------------------------------------
// ANNECY AV CLEAN_MEC {
/*
void CList1Window::LeaveEditionOfTestPoint ()
{
    m_pZDxInterface -> IWillRefreshDisplay (C_lLeaveTestPoint);

    m_Check_Button_Test_Point . SetCheck (FALSE);
    UpdateData (FALSE);

    m_pZDxInterface -> GetList2Window () -> LeaveEditionOfTestPoint ();

    //???

    ReCreateCurrentList ();

    m_pZDxInterface -> RefreshDisplay (C_lLeaveTestPoint);
}
*/
// END ANNECY AV }
