/*=========================================================================
* //ANNECY CO SPOFLAG 03/02/98
* 
* EDTdFlag.cpp :  Flags Dialog - Implementation file
* 
*
* Version			1.0
* Creation date		
* Revision date
*
* Shaitan
*=======================================================================*/

#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"

#include "EDTdFlag.hpp"
#include "EDTBase.hpp"
#include "EDTSObj.hpp"
#include "EDTdEdit.hpp"

#include "ITF.h"

//#################################################################################
// EDT_DialogFlag dialog
//#################################################################################

/*----------------------------------------
----------------------------------------*/
CPA_Interface * EDT_DialogFlag::GetInterface (void)
{
	return m_pEditor->GetInterface();
}

/*----------------------------------------
----------------------------------------*/
EDT_DialogFlag::EDT_DialogFlag(CWnd* pParent /*=NULL*/)
	: CDialog(EDT_DialogFlag::IDD, &g_oBaseFrame)
{
	//{{AFX_DATA_INIT(EDT_DialogFlag)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


/*----------------------------------------
----------------------------------------*/
void EDT_DialogFlag::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(EDT_DialogFlag)
	DDX_Control(pDX, EDT_IDC_CHECKPICKING, m_cCheckPicking);
	DDX_Control(pDX, EDT_IDC_CHECKHIDDEN, m_cCheckHidden);
//ANNECY Shaitan SPOFlags 17/02/98
	DDX_Control(pDX, EDT_IDC_CHECKTRANSFORMMATRIX, m_cCheckTransformMatrix);
	DDX_Control(pDX, EDT_IDC_CHECKZOOMFORSCALE, m_cCheckZoomForScale);
//ANNECY TQ 27/02/98{
	DDX_Control(pDX, EDT_IDC_CHECKBOUNDINGBOX, m_cCheckBoundingBox);
	DDX_Control(pDX, EDT_IDC_CHECKIMPOSE, m_cCheckImpose);
	DDX_Control(pDX, EDT_IDC_CHECKNORAYTRACE, m_cCheckNoRayTrace);
	DDX_Control(pDX, EDT_IDC_CHECKCHILDREN, m_cCheckChildren);
	DDX_Control(pDX, EDT_IDC_CHECKNOSHADOW, m_cCheckNoShadowOnMe);
//ENDANNECY TQ}

//ENDANNECY Shaitan SPOFlags 
	//}}AFX_DATA_MAP
}


/*----------------------------------------
----------------------------------------*/
BEGIN_MESSAGE_MAP(EDT_DialogFlag, CDialog)
	//{{AFX_MSG_MAP(EDT_DialogFlag)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


//#################################################################################
// EDT_DialogFlag message handlers
//#################################################################################

/*----------------------------------------
----------------------------------------*/
void EDT_DialogFlag::fn_vDoDialog (EDT_HierarchyEditor *pEditor, EDT_SuperObject *pSupObj) 
{
	// init parameters
	m_pEditor = pEditor;
	m_pSuperObject = pSupObj;
	// this dialog is modal
	DoModal();
}

/*----------------------------------------
----------------------------------------*/
BOOL EDT_DialogFlag::OnInitDialog () 
{
	CPA_DLLBase *pObjectDLL;
	
	// Create the dialog
	CDialog::OnInitDialog();

	// get flags
	m_ulInitialFlags = m_pSuperObject->GetFlags();

//ANNECY Shaitan SPOFlags 19/02/98
	// ask permission for each flag
	pObjectDLL = m_pSuperObject->GetObjectDLL();
	m_cCheckPicking.EnableWindow(pObjectDLL ? pObjectDLL->fn_bAcceptModifFlag(m_pSuperObject, HIE_C_Flag_ulNotPickable) : TRUE);
	m_cCheckHidden.EnableWindow(pObjectDLL ? pObjectDLL->fn_bAcceptModifFlag(m_pSuperObject, HIE_C_Flag_ulHidden) : TRUE);
	m_cCheckTransformMatrix.EnableWindow(pObjectDLL ? pObjectDLL->fn_bAcceptModifFlag(m_pSuperObject, HIE_C_Flag_ulNoTransformationMatrix) : TRUE);
	m_cCheckZoomForScale.EnableWindow(pObjectDLL ? pObjectDLL->fn_bAcceptModifFlag(m_pSuperObject, HIE_C_Flag_ulZoomInsteadOfScale) : TRUE);
//ANNECY TQ 27/02/98{
	m_cCheckBoundingBox.EnableWindow(pObjectDLL ? pObjectDLL->fn_bAcceptModifFlag(m_pSuperObject, HIE_C_Flag_ulTypeOfBoundingVolume) : TRUE);  
	m_cCheckImpose.EnableWindow(pObjectDLL ? pObjectDLL->fn_bAcceptModifFlag(m_pSuperObject, HIE_C_Flag_ulSuperimposed) : TRUE);
	m_cCheckNoRayTrace.EnableWindow(pObjectDLL ? pObjectDLL->fn_bAcceptModifFlag(m_pSuperObject, HIE_C_Flag_ulNotHitByRayTrace) : TRUE);
	m_cCheckNoShadowOnMe.EnableWindow(pObjectDLL ? pObjectDLL->fn_bAcceptModifFlag(m_pSuperObject, HIE_C_Flag_ulNoShadowOnMe) : TRUE);
	m_cCheckChildren.EnableWindow(pObjectDLL ? pObjectDLL->fn_bAcceptModifFlag(m_pSuperObject, HIE_C_Flag_ulCheckChildren) : TRUE);
//ENDANNECY TQ}
//ENDANNECY Shaitan SPOFlags
	
	// update check boxes
	m_cCheckPicking.SetCheck(HIE_fn_SO_bIsNotPickable(m_pSuperObject->GetStruct()));
	m_cCheckHidden.SetCheck(HIE_fn_SO_bIsHidden(m_pSuperObject->GetStruct()));
//ANNECY Shaitan SPOFlags 17/02/98
	m_cCheckTransformMatrix.SetCheck(HIE_fn_SO_bHasNoTransformationMatrix(m_pSuperObject->GetStruct()));
	m_cCheckZoomForScale.SetCheck(HIE_fn_SO_bHasZoomInsteadOfScale(m_pSuperObject->GetStruct()));
//ANNECY TQ 27/02/98{
	m_cCheckBoundingBox.SetCheck(HIE_fn_SO_bHasABoxBoundingVolume(m_pSuperObject->GetStruct()));
	m_cCheckNoRayTrace.SetCheck(m_ulInitialFlags & HIE_C_Flag_ulNotHitByRayTrace);
	m_cCheckNoShadowOnMe.SetCheck(m_ulInitialFlags & HIE_C_Flag_ulNoShadowOnMe);
	m_cCheckImpose.SetCheck(HIE_fn_SO_bIsSuperimposed(m_pSuperObject->GetStruct()));
	m_cCheckChildren.SetCheck(HIE_fn_SO_bCheckChildren(m_pSuperObject->GetStruct()));
//ENDANNECY TQ}

//ENDANNECY Shaitan SPOFlags 

	return TRUE;
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogFlag::OnOK() 
{
	unsigned long	ulFlags = 0;

	// update super-object flags
	if (m_cCheckPicking.GetCheck())
		ulFlags |= HIE_C_Flag_ulNotPickable;
	if (m_cCheckHidden.GetCheck())
		ulFlags |= HIE_C_Flag_ulHidden;
//ANNECY Shaitan SPOFlags 17/02/98
	if (m_cCheckTransformMatrix.GetCheck())
		ulFlags |= HIE_C_Flag_ulNoTransformationMatrix;
	if (m_cCheckZoomForScale.GetCheck())
		ulFlags |= HIE_C_Flag_ulZoomInsteadOfScale;
//ENDANNECY Shaitan SPOFlags 
//ANNECY TQ 02/03/98{
	if (m_cCheckBoundingBox.GetCheck())
		ulFlags |= HIE_C_Flag_ulTypeOfBoundingVolume;
	if (m_cCheckImpose.GetCheck())
		ulFlags |= HIE_C_Flag_ulSuperimposed;
	if (m_cCheckNoRayTrace.GetCheck())
		ulFlags |= HIE_C_Flag_ulNotHitByRayTrace;
	if (m_cCheckNoShadowOnMe.GetCheck())
		ulFlags |= HIE_C_Flag_ulNoShadowOnMe;
//ANNECY TQ 19/05/98{
	if(m_cCheckChildren.GetCheck())
		ulFlags |= HIE_C_Flag_ulCheckChildren;
//ENDANNECY TQ}

//ENDANNECY TQ}

	if (ulFlags != m_ulInitialFlags)
	{
		m_pSuperObject->SetFlags(ulFlags);
//ANNECY Shaitan SPOFlags 19/02/98
		m_pSuperObject->GetObjectDLL()->fn_vOnModifFlag(m_pSuperObject, m_ulInitialFlags, ulFlags);
//ENDANNECY Shaitan SPOFlags 
	}

	m_pEditor->GetDialogEdit()->fn_vUpdateDialog();

	// close dialog
	CDialog::OnOK();
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogFlag::OnCancel() 
{
	// close dialog
	CDialog::OnCancel();
}



#endif // ACTIVE_EDITOR
