//*****************************************************************************
//*  _zModif.hpp                                                              *
//*****************************************************************************
//*                                                                           *
//* This file contains the definitions of the modif classes                   *
//*                                                                           *
//*****************************************************************************
//* Author : Alexis Vaisse                                                    *
//*****************************************************************************


#ifndef __ZMODIF_H
#define __ZMODIF_H

#pragma once

// Actor dll "include"
class EdtList;

// Physical Object dll "include"
class EditorPO;

// personal "include"
class ZDx_Interface;
class ZDx_Object;
#include "_zObject.hpp"

typedef struct stBackupDataForSphere_
{
    MTH3D_tdstVector  stCenter;
    GLI_tdxValue    Radius;
} tdstBackupDataForSphere;

typedef struct stBackupDataForBox_
{
    MTH3D_tdstVector  stMinPoint;
    MTH3D_tdstVector  stMaxPoint;
} tdstBackupDataForBox;

typedef struct stBackupDataForPoint_
{
    MTH3D_tdstVector  stPoint;
} tdstBackupDataForPoint;

typedef struct stBackupDataForCone_
{
    MTH3D_tdstVector stTopPoint;
    MTH3D_tdstVector stBasePoint;
    GLI_tdxValue   Radius;
} tdstBackupDataForCone;


//-----------------------------------------------------------------------------
// class ZDx_Modif
//
// This class deals with all the modifications of a ZDx Object
//-----------------------------------------------------------------------------
class ZDx_Modif : public CPA_Modif
{
private:
    ZDx_Object * m_pZDxObject;           // the ZDx object to modify

	BOOL m_bFirstTime;

    // backup data
    char * m_BackupName;
    void * m_pBackupData;                // Point to a tdstBackupDataFor... structure, depends on the ZDx type

    BOOL   m_bIsDoingUndo;               // Is TRUE when doing an Undo

    void   BackupSphereData ();
    void   BackupBoxData    ();
    void   BackupPointData  ();
    void   BackupConeData   ();

    void   ExchangeBackupSphereData ();
    void   ExchangeBackupBoxData    ();
    void   ExchangeBackupPointData  ();
    void   ExchangeBackupConeData   ();

public:
    ZDx_Modif (ZDx_Object * , char * );  // constructor with the ZDx object which will be modified
                                         // and the name of the modif ("Modification ZDx" for instance)
    ~ZDx_Modif ();                       // destructor
    void SetZDxObject (ZDx_Object *);    // set the ZDx object which will be modified

    BOOL Do ();
    BOOL Undo ();                        // Standard Undo : it refreshes the window by default
    BOOL Undo (BOOL _bRefreshWindow);    // personal Undo : if we don't want the window to be refreshed
};


//-----------------------------------------------------------------------------
// class ZDx_Modif_Exchange
//
// This class deals with the exchange of two ZDx object within two objects lists
//-----------------------------------------------------------------------------
class ZDx_Modif_Exchange : public CPA_Modif
{
private:
    ZDx_Interface       * m_pZDxInterface;
    ZDx_Object          * m_pZDxObject1        , * m_pZDxObject2;
    long                  m_lIndexInList1      ,   m_lIndexInList2;
    EdtList             * m_pZDxList1          , * m_pZDxList2;
    tdeZDxType            m_eTypeOfList1       ,   m_eTypeOfList2;
    CPA_BaseObject      * m_pActor1            , * m_pActor2;
    CPA_SuperObject     * m_pActorSuperObject1 , * m_pActorSuperObject2;

public:
    // Constructor
    ZDx_Modif_Exchange (ZDx_Object * , long lIndexInList1 , EdtList * , CPA_SuperObject * _pActorSuperObject1 ,
                        ZDx_Object * , long lIndexInList2 , EdtList * , CPA_SuperObject * _pActorSuperObject2 ,
                        ZDx_Interface *);

    BOOL Do ();
    BOOL Undo ();
};

//-----------------------------------------------------------------------------
// class ZDx_Modif_Delete
//
// This class deals with the deletion of a ZDx object from a list
//-----------------------------------------------------------------------------
class ZDx_Modif_Delete : public CPA_Modif
{
private:
    ZDx_Interface       * m_pZDxInterface;
    CPA_SuperObject     * m_pZDxSuperObject;
    ZDx_Object          * m_pZDxObject;
    long                  m_lIndexInList;
    EdtList             * m_pZDxList;
    CPA_SuperObject     * m_pModuleSuperObject;
    EditorPO            * m_pModule;
    CPA_SuperObject     * m_pActorSuperObject;
    CPA_BaseObject      * m_pActor;

public:
    // Constructor
    ZDx_Modif_Delete (CPA_SuperObject * _pZDxSuperObject , long lIndexInList , EdtList * ,
                      CPA_SuperObject * _pModuleSuperObject , CPA_SuperObject * _pActorSuperObject ,
                      ZDx_Interface *);
    ~ZDx_Modif_Delete ();    // Destructor

    BOOL Do ();
    BOOL Undo ();
};

//-----------------------------------------------------------------------------
// class ZDx_Modif_Change_ZDx_List
//
// This class deals with the change of a list of ZDx for an actor
//-----------------------------------------------------------------------------
class ZDx_Modif_Change_ZDx_List : public CPA_Modif
{
private:
    ZDx_Interface       * m_pZDxInterface;
    CPA_SuperObject     * m_pActorSuperObject;
    CPA_BaseObject      * m_pActor;
    tdeZDxType            m_eTypeOfList;
    EdtList             * m_pZDxList;

public:
    // Constructor
    ZDx_Modif_Change_ZDx_List (ZDx_Interface * , CPA_SuperObject * _pActorSuperObject , tdeZDxType , EdtList *);

    BOOL Do ();
    BOOL Undo ();
};
#endif // __ZMODIF_H
