/*=========================================================================
* 
* EDTdEdit.cpp :  Implementation file
* 
*
* Version			1.0
* Creation date		
* Revision date
*
* Shaitan
*=======================================================================*/

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

#include "ITF.h" 
#include "POS.h"

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

#include "incMTH.h"

#include "..\Main\Inc\_EditID.h"
#include "TUT.h"

#define M_GetToolDLLs()		m_pEditor->GetMainWorld()->GetToolDLLReceivingEvtEditorMsg()
#define M_GetTempManager()	m_pEditor->GetTempManager()


//#################################################################################
// EDT_DialogEdit dialog
//#################################################################################

/*----------------------------------------
----------------------------------------*/
EDT_DialogEdit::EDT_DialogEdit(CWnd *pParent)
	: CFormView(EDT_DialogEdit::IDD)
{
	//{{AFX_DATA_INIT(EDT_DialogEdit)
	//}}AFX_DATA_INIT
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(EDT_DialogEdit)
// supobj
	DDX_Control(pDX, EDT_IDC_SUPOBJNAME, m_cSupObjName);
	DDX_Control(pDX, EDT_IDC_SUPOBJOWNER, m_cSupObjOwner);
	DDX_Control(pDX, EDT_IDC_SUPOBJLEVEL, m_cSupObjLevel);
	DDX_Control(pDX, EDT_IDC_OBJECTGO, m_cSupObjGo);
//ANNECY CO SPOFLAG 03/02/98
	DDX_Control(pDX, EDT_IDC_SUPOBJFLAGS, m_cSupObjFlags);
//ENDANNECY CO SPOFLAG 
//ANNECY Shaitan Transparency 26/03/98 {
	DDX_Control(pDX, EDT_IDC_EDITTRANSP, m_cEditTransparency);
	DDX_Control(pDX, EDT_IDC_SLIDERTRANS, m_cSliderTransparency);
//ENDANNECY Shaitan Transparency }
	DDX_Control(pDX, EDT_IDC_TEMP, m_cTemp);
// object
	DDX_Control(pDX, EDT_IDC_EDITNAME, m_cObjectName);
	DDX_Control(pDX, EDT_IDC_EDITOWNER, m_cObjectOwner);
	DDX_Control(pDX, EDT_IDC_EDITTYPE, m_cObjectType);
	DDX_Control(pDX, EDT_IDC_EDITDESC, m_cObjectDesc);
// parent
	DDX_Control(pDX, EDT_IDC_PARENTNAME, m_cParentName);
	DDX_Control(pDX, EDT_IDC_PARENTOBJ, m_cParentObject);
	DDX_Control(pDX, EDT_IDC_PARENTTYPE, m_cParentType);
	DDX_Control(pDX, EDT_IDC_PARENTOWNER, m_cParentOwner);
	DDX_Control(pDX, EDT_IDC_PARENTGO, m_cParentGo);
// position
	DDX_Control(pDX, EDT_IDC_POSX, m_cPosX);
	DDX_Control(pDX, EDT_IDC_POSY, m_cPosY);
	DDX_Control(pDX, EDT_IDC_POSZ, m_cPosZ);
	DDX_Control(pDX, EDT_IDC_SCALEX, m_cScaleX);
	DDX_Control(pDX, EDT_IDC_SCALEY, m_cScaleY);
	DDX_Control(pDX, EDT_IDC_SCALEZ, m_cScaleZ);
	DDX_Control(pDX, EDT_IDC_ROTX, m_cRotX);
	DDX_Control(pDX, EDT_IDC_ROTY, m_cRotY);
	DDX_Control(pDX, EDT_IDC_ROTZ, m_cRotZ);
	DDX_Control(pDX, EDT_IDC_SLIDERX, m_cSliderX);
	DDX_Control(pDX, EDT_IDC_SLIDERY, m_cSliderY);
	DDX_Control(pDX, EDT_IDC_SLIDERZ, m_cSliderZ);
// mode
	DDX_Control(pDX, EDT_IDC_GLOBALMODE, m_cGlobalMode);
	DDX_Control(pDX, EDT_IDC_APPLY, m_cApply);
// default
	DDX_Control(pDX, EDT_IDC_DEFAULT, m_cDefault);
	//}}AFX_DATA_MAP
}

/*----------------------------------------
----------------------------------------*/
BEGIN_MESSAGE_MAP(EDT_DialogEdit, CFormView)
	//{{AFX_MSG_MAP(EDT_DialogEdit)
// supobj
	ON_EN_KILLFOCUS(EDT_IDC_SUPOBJNAME, OnChangeSupObjName)
	ON_BN_CLICKED(EDT_IDC_OBJECTGO, OnObjectGo)
//ANNECY CO SPOFLAG 03/02/98
	ON_BN_CLICKED(EDT_IDC_SUPOBJFLAGS, OnFlags)
//ENDANNECY CO SPOFLAG
//ANNECY Shaitan Transparency 26/03/98 {
	ON_EN_KILLFOCUS(EDT_IDC_EDITTRANSP, OnChangeTransparency)
	ON_WM_HSCROLL()
//ENDANNECY Shaitan Transparency }
// object
	ON_EN_KILLFOCUS(EDT_IDC_EDITNAME, OnChangeEditName)
// parent
	ON_BN_CLICKED(EDT_IDC_PARENTGO, OnParentGo)
// position
	ON_EN_KILLFOCUS(EDT_IDC_POSX, OnChangePosx)
	ON_EN_KILLFOCUS(EDT_IDC_POSY, OnChangePosy)
	ON_EN_KILLFOCUS(EDT_IDC_POSZ, OnChangePosz)
	ON_EN_KILLFOCUS(EDT_IDC_SCALEX, OnChangeScalex)
	ON_EN_KILLFOCUS(EDT_IDC_SCALEY, OnChangeScaley)
	ON_EN_KILLFOCUS(EDT_IDC_SCALEZ, OnChangeScalez)
	ON_WM_VSCROLL()
	ON_EN_KILLFOCUS(EDT_IDC_ROTX, OnChangeRotx)
	ON_EN_KILLFOCUS(EDT_IDC_ROTY, OnChangeRoty)
	ON_EN_KILLFOCUS(EDT_IDC_ROTZ, OnChangeRotz)
// mode
	ON_BN_CLICKED(EDT_IDC_GLOBALMODE, OnGlobalMode)
	ON_BN_CLICKED(EDT_IDC_APPLY, OnApply)
// default
	ON_BN_CLICKED(EDT_IDC_DEFAULT, OnDefaultButton)
	ON_WM_SIZE()
	ON_WM_DESTROY()

	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


//#################################################################################
// EDT_DialogList functions
//#################################################################################

/*===========================================================================
*		Description:	Init Dialog
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
CPA_Interface * EDT_DialogEdit::GetInterface (void)
{
	return m_pEditor->GetInterface();
}

/*===========================================================================
*		Description:	Init Dialog
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vInitDialog (EDT_HierarchyEditor *pEditor, FRMBase *pFrame)
{
	// create the dialog
	m_bInitialised = FALSE;
	m_pEditor = pEditor;
	CFormView::Create(NULL, "", WS_VISIBLE|WS_CHILD, CRect(0,0,0,0), pFrame, AFX_IDW_PANE_FIRST, NULL);

	// init vector
	MTH3D_M_vNullVector(&m_stTranslation);
    MTH3D_M_vNullVector(&m_stAngles);
	MTH3D_M_vNullVector(&m_stScales);
	// init flags
	m_bUpdatingPos   = FALSE;
    m_bUpdatingRot   = FALSE;
    m_bUpdatingScale = FALSE;
	m_bGlobalMove = FALSE;
	// init parameters
	m_pEditedObject  = NULL;
	m_pEditMove = NULL;

	// init data for dialog
	CFormView::UpdateData(FALSE);

// FOR TUTORIAL
	TUT_M_vGetTutDll();

	// super-object
    TUT_M_vRegisterControl(m_cSupObjName.m_hWnd,	"EDT_DEDIT_EDIT_SUPOBJNAME",	TUT_e_TextEdit);
    TUT_M_vRegisterControl(m_cSupObjGo.m_hWnd,		"EDT_DEDIT_BUTTON_SUPOBJGO",	TUT_e_Button);
    TUT_M_vRegisterControl(m_cTemp.m_hWnd,			"EDT_DEDIT_BUTTON_SUPOBJTEMP",	TUT_e_Button);
	// object
    TUT_M_vRegisterControl(m_cObjectName.m_hWnd,	"EDT_DEDIT_EDIT_OBJECTNAME",	TUT_e_TextEdit);
	// parent
    TUT_M_vRegisterControl(m_cParentGo.m_hWnd,		"EDT_DEDIT_BUTTON_PARENTGO",	TUT_e_Button);
	// position
    TUT_M_vRegisterControl(m_cPosX.m_hWnd,			"EDT_DEDIT_EDIT_POSX",			TUT_e_TextEdit);
    TUT_M_vRegisterControl(m_cPosY.m_hWnd,			"EDT_DEDIT_EDIT_POSY",			TUT_e_TextEdit);
    TUT_M_vRegisterControl(m_cPosZ.m_hWnd,			"EDT_DEDIT_EDIT_POSZ",			TUT_e_TextEdit);
    TUT_M_vRegisterControl(m_cScaleX.m_hWnd,		"EDT_DEDIT_EDIT_SCALEX",		TUT_e_TextEdit);
    TUT_M_vRegisterControl(m_cScaleY.m_hWnd,		"EDT_DEDIT_EDIT_SCALEY",		TUT_e_TextEdit);
    TUT_M_vRegisterControl(m_cScaleZ.m_hWnd,		"EDT_DEDIT_EDIT_SCALEZ",		TUT_e_TextEdit);
    TUT_M_vRegisterControl(m_cRotX.m_hWnd,			"EDT_DEDIT_EDIT_ROTX",			TUT_e_TextEdit);
    TUT_M_vRegisterControl(m_cRotY.m_hWnd,			"EDT_DEDIT_EDIT_ROTY",			TUT_e_TextEdit);
    TUT_M_vRegisterControl(m_cRotZ.m_hWnd,			"EDT_DEDIT_EDIT_ROTZ",			TUT_e_TextEdit);
    TUT_M_vRegisterControl(m_cSliderX.m_hWnd,		"EDT_DEDIT_SLIDER_ROTX",		TUT_e_Slider);
    TUT_M_vRegisterControl(m_cSliderY.m_hWnd,		"EDT_DEDIT_SLIDER_ROTY",		TUT_e_Slider);
    TUT_M_vRegisterControl(m_cSliderZ.m_hWnd,		"EDT_DEDIT_SLIDER_ROTZ",		TUT_e_Slider);
    TUT_M_vRegisterControl(m_cGlobalMode.m_hWnd,	"EDT_DEDIT_BUTTON_GLOBAL",		TUT_e_Button);
    TUT_M_vRegisterControl(m_cApply.m_hWnd,			"EDT_DEDIT_BUTTON_APPLY",		TUT_e_Button);
	// default button
    TUT_M_vRegisterControl(m_cDefault.m_hWnd,		"EDT_DEDIT_BUTTON_DEFAULT",		TUT_e_Button);
// END TUTORIAL

	// init supobj
	m_cSupObjName.EnableWindow(FALSE);
	m_cSupObjGo.EnableWindow(FALSE);
	m_cTemp.EnableWindow(FALSE);
//ANNECY Shaitan correction 17/02/98
	m_cSupObjFlags.EnableWindow(FALSE);
//ENDANNECY Shaitan correction
//ANNECY Shaitan Transparency 26/03/98 {
	m_cEditTransparency.EnableWindow(FALSE);
	m_cSliderTransparency.EnableWindow(FALSE);
	m_cSliderTransparency.SetRange(0, 255);
//ENDANNECY Shaitan Transparency }
	// init object
	m_cObjectName.EnableWindow(FALSE);
	// init parent
	m_cParentGo.EnableWindow(FALSE);
	// init position
	m_cPosX.EnableWindow(FALSE);
	m_cPosY.EnableWindow(FALSE);
	m_cPosZ.EnableWindow(FALSE);
	// init scale
	m_cScaleX.EnableWindow(FALSE);
	m_cScaleY.EnableWindow(FALSE);
	m_cScaleZ.EnableWindow(FALSE);
	// init rotation
	m_cRotX.EnableWindow(FALSE);
	m_cRotY.EnableWindow(FALSE);
	m_cRotZ.EnableWindow(FALSE);
	m_cSliderX.EnableWindow(FALSE);
	m_cSliderY.EnableWindow(FALSE);
	m_cSliderZ.EnableWindow(FALSE);
	m_cSliderX.SetRange(-179, 180);
	m_cSliderY.SetRange(-179, 180);
	m_cSliderZ.SetRange(-179, 180);
	// init mode
	m_cGlobalMode.SetCheck(0);
	m_cGlobalMode.EnableWindow(FALSE);
	m_cApply.EnableWindow(FALSE);

	// update data
	fn_vUpdateDialog();

	m_bInitialised = TRUE;
}

/*===========================================================================
*		Description:	update dialog when object changes
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vUpdateDialog (void)
{
	CPA_SuperObject *pSupObj;
	EDT_SuperObject *pNewObj;
	
	if ((m_bUpdatingPos)||(m_bUpdatingRot)||(m_bUpdatingScale))
		return;
	
	// change edited object
	pSupObj = (M_GetCountSelected() == 1) ? M_GetSingleSelection() : NULL;
	pNewObj = (EDT_SuperObject *) pSupObj;

//ANNECY Shaitan SPOFlags 17/02/98
//	if (pNewObj != m_pEditedObject)
//	{
//ENDANNECY Shaitan SPOFlags
	// change edited object
	m_pEditedObject = pNewObj;
	// translation
	m_cPosX.EnableWindow(fn_bCanTranslate());
	m_cPosY.EnableWindow(fn_bCanTranslate());
	m_cPosZ.EnableWindow(fn_bCanTranslate());
	// scale 
	m_cScaleX.EnableWindow(fn_bCanScale());
//ANNECY Shaitan SPOFlags 17/02/98
	m_cScaleY.EnableWindow((fn_bCanScale() && !fn_bZoomForScale()));
	m_cScaleZ.EnableWindow((fn_bCanScale() && !fn_bZoomForScale()));
//ENDANNECY Shaitan SPOFlags
	// rotation
	m_cRotX.EnableWindow(fn_bCanRotate());
	m_cRotY.EnableWindow(fn_bCanRotate());
	m_cRotZ.EnableWindow(fn_bCanRotate());
	m_cSliderX.EnableWindow(fn_bCanRotate());
	m_cSliderY.EnableWindow(fn_bCanRotate());
	m_cSliderZ.EnableWindow(fn_bCanRotate());
	// mode
	m_cGlobalMode.EnableWindow((m_pEditedObject != NULL));
	m_cApply.EnableWindow((m_pEditedObject != NULL)&&(m_bGlobalMove));
//ANNECY Shaitan SPOFlags 17/02/98
//	}
//ENDANNECY Shaitan SPOFlags
	// update all controls
	fn_vUpdateSuperObject();
	fn_vUpdateObject();
	fn_vUpdateParent();
	// update positions
	m_bUpdatingPos = FALSE;
	m_bUpdatingRot = FALSE;
	m_bUpdatingScale = FALSE;
	fn_vUpdatePosition();
	fn_vUpdateRotation();
	fn_vUpdateScale();
}

/*===========================================================================
*		Description:	Update super-object infos
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vUpdateSuperObject (void)
{
	char szTransparency[10];

	// no selection => RAZ
	if (!m_pEditedObject)
	{
		// update states
		m_cSupObjName.EnableWindow(FALSE);
		m_cSupObjGo.EnableWindow(FALSE);
//ANNECY Shaitan correction 17/02/98
		m_cSupObjFlags.EnableWindow(FALSE);
//ENDANNECY Shaitan correction
//ANNECY Shaitan Transparency 26/03/98 {
	m_cEditTransparency.EnableWindow(FALSE);
	m_cSliderTransparency.EnableWindow(FALSE);
	m_cEditTransparency.SetWindowText("");
	m_cSliderTransparency.SetPos(0);
//ENDANNECY Shaitan Transparency }
		// update text
		m_cSupObjName.SetWindowText("");
		m_cSupObjOwner.SetWindowText("");
		m_cSupObjLevel.SetWindowText("");
		m_cTemp.SetCheck(FALSE);
		return;
	}

	// update text
	m_cSupObjName.SetWindowText(m_pEditedObject->GetName());
	m_cSupObjOwner.SetWindowText(m_pEditedObject->GetOwnerName());
	m_cSupObjLevel.SetWindowText(m_pEditedObject->GetLevelName());
	m_cTemp.SetCheck(m_pEditedObject->fn_bIsTemporary());
	// update state
	m_cSupObjName.EnableWindow(fn_bCanRenameSuperObject());
	m_cSupObjGo.EnableWindow(TRUE);
//ANNECY Shaitan correction 17/02/98
	m_cSupObjFlags.EnableWindow(TRUE);
//ENDANNECY Shaitan correction

//ANNECY Shaitan Transparency 26/03/98 {
	// update controls
	m_cEditTransparency.EnableWindow(TRUE);
	m_cSliderTransparency.EnableWindow(TRUE);
	// update value
	sprintf(szTransparency, "%7.4f", m_pEditedObject->fn_fGetTransparencyLevel());
	m_cEditTransparency.SetWindowText(szTransparency);
	m_cSliderTransparency.SetPos((int) m_pEditedObject->fn_fGetTransparencyLevel());
//ENDANNECY Shaitan Transparency }
}

/*===========================================================================
*		Description:	Update object infos
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vUpdateObject (void)
{
	CPA_BaseObject *pLinkedObject;
	
	pLinkedObject = (m_pEditedObject) ? m_pEditedObject->GetObject() : NULL;

	// no selection => RAZ
	if (!pLinkedObject)
	{
		// update states
		m_cObjectName.EnableWindow(FALSE);
		// update text
		m_cObjectName.SetWindowText("");
		m_cObjectType.SetWindowText("");
		m_cObjectOwner.SetWindowText("");
		m_cObjectDesc.SetWindowText("");
		return;
	}

	// update text
	m_cObjectName.SetWindowText(pLinkedObject->GetName());
	m_cObjectType.SetWindowText(m_pEditedObject->GetTypeToDraw());
	m_cObjectDesc.SetWindowText(m_pEditedObject->GetModelName());
	m_cObjectOwner.SetWindowText(m_pEditedObject->GetOwnerToDraw());
	// update state
	m_cObjectName.EnableWindow(fn_bCanRenameObject());
}

/*===========================================================================
*		Description:	Update parent infos
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vUpdateParent (void)
{
	CPA_SuperObject		*pSupObj;
	EDT_SuperObject		*pParent;

	pSupObj = (m_pEditedObject) ? m_pEditedObject->GetSuperObjectFather() : NULL;
	pParent = (EDT_SuperObject *) pSupObj;

	// no selection => RAZ
	if (!pParent)
	{
		m_cParentName.SetWindowText("");
		m_cParentObject.SetWindowText("");
		m_cParentType.SetWindowText("");
		m_cParentOwner.SetWindowText("");
		m_cParentGo.EnableWindow(FALSE);
		return;
	}


	// update text & state
	m_cParentName.SetWindowText(pParent->GetName());
	m_cParentObject.SetWindowText((pParent->GetObject()) ? pParent->GetObject()->GetName() : "");
	m_cParentType.SetWindowText(pParent->GetTypeToDraw());
	m_cParentOwner.SetWindowText(pParent->GetOwnerName());
	m_cParentGo.EnableWindow(TRUE);
}

/*===========================================================================
*		Description:	Update positions infos
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vUpdatePosition (void)
{
	char szPosX[10];
	char szPosY[10];
	char szPosZ[10];

	// no selection => RAZ
	if (!m_pEditedObject)
	{
		m_cPosX.SetWindowText("");
		m_cPosY.SetWindowText("");
		m_cPosZ.SetWindowText("");
		MTH3D_M_vNullVector(&m_stTranslation);
		return;
	}
	
	// update position
	if (!m_bUpdatingPos)
	{
		m_bUpdatingPos = TRUE;
		if (POS_fn_vIsMatrixIdentityConst(HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct())))
		{
			MTH3D_M_vNullVector(&m_stTranslation);
		}
		else
		{
			POS_fn_vGetTranslationVector(HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct()),&m_stTranslation);
		}

		sprintf(szPosX, "%7.4f", MTH3D_M_xGetXofVector(&m_stTranslation));
		sprintf(szPosY, "%7.4f", MTH3D_M_xGetYofVector(&m_stTranslation));
		sprintf(szPosZ, "%7.4f", MTH3D_M_xGetZofVector(&m_stTranslation));
		m_cPosX.SetWindowText(szPosX);
		m_cPosY.SetWindowText(szPosY);
		m_cPosZ.SetWindowText(szPosZ);

		m_bUpdatingPos = FALSE;
	}
}


/*===========================================================================
*		Description:	Update rotations infos
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vUpdateRotation (void)
{
	char szRotX [10];
	char szRotY [10];
	char szRotZ [10];

	// no selection => RAZ
	if (!m_pEditedObject)
	{
		m_cRotX.SetWindowText("");
		m_cRotY.SetWindowText("");
		m_cRotZ.SetWindowText("");
		m_cSliderX.SetPos(0);
		m_cSliderY.SetPos(0);
		m_cSliderZ.SetPos(0);
		MTH3D_M_vNullVector(&m_stAngles);
		return;
	}

	// update rotation
	if (!m_bUpdatingRot)
	{
		m_bUpdatingRot = TRUE;
        fn_vConvertRotateMatrixToAngles (&m_stAngles,HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct()));
        
		m_cSliderX.SetPos((int) MTH3D_M_xGetXofVector(&m_stAngles));
  		m_cSliderY.SetPos((int) MTH3D_M_xGetYofVector(&m_stAngles));
		m_cSliderZ.SetPos((int) MTH3D_M_xGetZofVector(&m_stAngles));
		sprintf(szRotX, "%4.0f", MTH3D_M_xGetXofVector(&m_stAngles));
        sprintf(szRotY, "%4.0f", MTH3D_M_xGetYofVector(&m_stAngles));
	    sprintf(szRotZ, "%4.0f", MTH3D_M_xGetZofVector(&m_stAngles));
		m_cRotX.SetRedraw(TRUE);
		m_cRotX.SetWindowText(szRotX);
		m_cRotX.UpdateWindow();
		m_cRotY.SetWindowText(szRotY);
		m_cRotY.SetRedraw(TRUE);
		m_cRotY.UpdateWindow();
		m_cRotZ.SetRedraw(TRUE);
		m_cRotZ.SetWindowText(szRotZ);
		m_cRotZ.UpdateWindow();

        m_bUpdatingRot = FALSE;
	}
}

/*===========================================================================
*		Description:	Update scales infos
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vUpdateScale (void)
{
	MTH3D_tdstVector	stVectI,stVectJ,stVectK;
	char				szScaleX [10];
	char				szScaleY [10];
	char				szScaleZ [10];

	// no selection => RAZ
	if (!m_pEditedObject)
	{
		m_cScaleX.SetWindowText("");
		m_cScaleY.SetWindowText("");
		m_cScaleZ.SetWindowText("");
		MTH3D_M_vNullVector(&m_stScales);
		return;
	}
    
	// update scale
	if (!m_bUpdatingScale)
    {
		m_bUpdatingScale = TRUE;

		POS_fn_vGetScaleMatrix(HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct()),&stVectI,&stVectJ,&stVectK);

        MTH3D_M_vSetVectorElements (&m_stScales,MTH3D_M_xGetXofVector(&stVectI),
												MTH3D_M_xGetYofVector(&stVectJ),
												MTH3D_M_xGetZofVector(&stVectK));

        sprintf(szScaleX, "%7.4f", MTH3D_M_xGetXofVector(&m_stScales));
        sprintf(szScaleY, "%7.4f", MTH3D_M_xGetYofVector(&m_stScales));
        sprintf(szScaleZ, "%7.4f", MTH3D_M_xGetZofVector(&m_stScales));
        m_cScaleX.SetWindowText(szScaleX);
        m_cScaleY.SetWindowText(szScaleY);
        m_cScaleZ.SetWindowText(szScaleZ);

        m_bUpdatingScale = FALSE;
    }
}


/*===========================================================================
*		Description:	Change the position of the object according to
*						the dialog's data
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vSetNewPosition(char cAxe) 
{
	char				szPosX[15];
	char				szPosY[15];
	char				szPosZ[15];
	BOOL				bDone;
	MTH3D_tdstVector	stPosition;

	if (!m_bUpdatingPos)
	{
		m_bUpdatingPos = TRUE;

		// find new position
		m_cPosX.GetWindowText(szPosX, 15);
		m_cPosY.GetWindowText(szPosY, 15);
		m_cPosZ.GetWindowText(szPosZ, 15);
		MTH3D_M_vSetXofVector(&stPosition, (float) atof(szPosX));
		MTH3D_M_vSetYofVector(&stPosition, (float) atof(szPosY));
		MTH3D_M_vSetZofVector(&stPosition, (float) atof(szPosZ));
		// is there a difference ?
		if (!MTH3D_M_bEqualVector(&m_stTranslation, &stPosition))
		{
			// create modif
			m_pEditMove = new EDT_ModifMove(GetParentEditor(), M_GetWorld()->GetListOfListByDLL(), GetInterface()->GetSelectMode());
			// set the new position
			POS_fn_vSetTranslationVector(HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct()),&stPosition);
			GetInterface()->fn_vUpdatePositions();
			// do modif
			bDone = GetParentEditor()->fn_bDoOrCancelMove(m_pEditMove);
			if (bDone)
				MTH3D_M_vCopyVector(&m_stTranslation, &stPosition);

			m_pEditMove = NULL;
		}

		// update flags
		m_cPosX.SetModify(FALSE);
		m_cPosY.SetModify(FALSE);
		m_cPosZ.SetModify(FALSE);

		m_bUpdatingPos = FALSE;
	}
}


/*===========================================================================
*		Description:	Change the rotation of the object according to
*						the dialog's data
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vSetNewRotation(char cAxe) 
{
	MTH3D_tdstVector	stAngles;
	BOOL				bDone;
	char				szRotX [15];
	char				szRotY [15];
	char				szRotZ [15];

	if (!m_bUpdatingRot)
	{
		m_bUpdatingRot = TRUE;

		// get the new angles
        m_cRotX.GetWindowText(szRotX, 15);
        m_cRotY.GetWindowText(szRotY, 15);		
		m_cRotZ.GetWindowText(szRotZ, 15);
        MTH3D_M_vSetXofVector(&stAngles, (float) atof (szRotX));
        MTH3D_M_vSetYofVector(&stAngles, (float) atof (szRotY));
        MTH3D_M_vSetZofVector(&stAngles, (float) atof (szRotZ));
		// check angles validity
		if ((MTH3D_M_xGetXofVector(&m_stAngles) >  180) || 
			(MTH3D_M_xGetXofVector(&m_stAngles) < -180) ||
			(MTH3D_M_xGetYofVector(&m_stAngles) >  180) || 
			(MTH3D_M_xGetYofVector(&m_stAngles) < -180) ||
			(MTH3D_M_xGetZofVector(&m_stAngles) >  180) || 
			(MTH3D_M_xGetZofVector(&m_stAngles) < -180))
		{
			M_GetMainWnd()->UpdateStatus("ERROR : Invalid Rotation Value", C_STATUSPANE_INFOS, C_STATUS_ERROR);
			sprintf(szRotX, "%4.0f", MTH3D_M_xGetXofVector(&m_stAngles));
			sprintf(szRotY, "%4.0f", MTH3D_M_xGetYofVector(&m_stAngles));
			sprintf(szRotZ, "%4.0f", MTH3D_M_xGetZofVector(&m_stAngles));
			m_cRotX.SetWindowText(szRotX);
			m_cRotY.SetWindowText(szRotY);
			m_cRotZ.SetWindowText(szRotZ);
			m_bUpdatingRot = FALSE;
			return;
		}

		// is there a difference ?
		if (!MTH3D_M_bEqualVector(&m_stAngles, &stAngles))
		{
			// create modif
			m_pEditMove = new EDT_ModifMove(GetParentEditor(), M_GetWorld()->GetListOfListByDLL(), GetInterface()->GetSelectMode());
			// calculate the new rotation matrix
			fn_vConvertAnglesToRotateMatrix (HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct()),&stAngles);
			GetInterface()->fn_vUpdatePositions();
			// do modif
			bDone = GetParentEditor()->fn_bDoOrCancelMove(m_pEditMove);
			// update vector
			if (bDone)
			{
				MTH3D_M_vCopyVector(&m_stAngles, &stAngles);
				m_cSliderX.SetPos((int) MTH3D_M_xGetXofVector(&m_stAngles));
				m_cSliderY.SetPos((int) MTH3D_M_xGetYofVector(&m_stAngles));
				m_cSliderZ.SetPos((int) MTH3D_M_xGetZofVector(&m_stAngles));
			}
			m_pEditMove = NULL;
		}

		// update flags
		m_cRotX.SetModify(FALSE);
		m_cRotY.SetModify(FALSE);
		m_cRotZ.SetModify(FALSE);

		m_bUpdatingRot = FALSE;
	}
}

//ROMTEAM StickObjects (Nicolae Suparatu 10/02/98)
/*===========================================================================
*		Description:	Change the rotation and the translation of the object 
*		Creation date:	
*		Author:			Nicu - CPA2
*---------------------------------------------------------------------------
*		Revision date:                                                        
*=========================================================================*/
void EDT_DialogEdit::fn_vSetNewPositionAndRotation (EDT_SuperObject *pSupObj, POS_tdstCompletePosition stMatrix)
{
	CString c;
	BOOL				bDone;
	MTH3D_tdstVector	stVectI,stVectJ,stVectK;
  const GLI_tdxValue	ConvertToRadians = GLI_M_PI / 180;

	// create modif
	m_pEditMove = new EDT_ModifMove(GetParentEditor(), M_GetWorld()->GetListOfListByDLL(), GetInterface()->GetSelectMode());
	// calculate the new rotation matrix
	
	POS_fn_vGetRotationMatrix(&stMatrix, &stVectI, &stVectJ, &stVectK);
	POS_fn_vSetRotationMatrix(HIE_fn_hGetSuperObjectMatrix(pSupObj->GetStruct()), &stVectI, &stVectJ, &stVectK);

	fn_vConvertRotateMatrixToAngles (&stVectJ, &stMatrix);
	c.Format("%4.0f", stVectJ.xX);
	m_cRotX.SetWindowText(c);
	c.Format("%4.0f", stVectJ.xY);
	m_cRotY.SetWindowText(c);
	c.Format("%4.0f", stVectJ.xZ);
	m_cRotZ.SetWindowText(c);

	// set the new position
	POS_fn_vGetTranslationVector(&stMatrix, &stVectI);
	POS_fn_vSetTranslationVector(HIE_fn_hGetSuperObjectMatrix(pSupObj->GetStruct()), &stVectI);
	GetInterface()->fn_vUpdatePositions();

	c.Format("%.6f", stVectI.xX);							
	m_cPosX.SetWindowText(c);
	c.Format("%.6f", stVectI.xY);
	m_cPosY.SetWindowText(c);
	c.Format("%.6f", stVectI.xZ);
	m_cPosZ.SetWindowText(c);

	// do modif
	bDone = GetParentEditor()->fn_bDoOrCancelMove(m_pEditMove);
	// update vector
	if (bDone)
	{
		MTH3D_M_vCopyVector(&m_stTranslation, &stVectI);
		MTH3D_M_vCopyVector(&m_stAngles, &stVectJ);
		m_cSliderX.SetPos((int) MTH3D_M_xGetXofVector(&m_stAngles));
		m_cSliderY.SetPos((int) MTH3D_M_xGetYofVector(&m_stAngles));
		m_cSliderZ.SetPos((int) MTH3D_M_xGetZofVector(&m_stAngles));
	}

	m_pEditMove = NULL;

	// update flags
	m_cRotX.SetModify(FALSE);
	m_cRotY.SetModify(FALSE);
	m_cRotZ.SetModify(FALSE);

	m_cPosX.SetModify(FALSE);
	m_cPosY.SetModify(FALSE);
	m_cPosZ.SetModify(FALSE);

}
//ENDROMTEAM StickObjects (Nicolae Suparatu 10/02/98)

/*===========================================================================
*		Description:	Change the scale of the object according to
*						the dialog's data
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vSetNewScale (char cAxe) 
{
	MTH3D_tdstVector	stScale;
	BOOL				bDone;
	char				szScaleX [15];
	char				szScaleY [15];
	char				szScaleZ [15];

	if (!m_bUpdatingScale)
	{
		m_bUpdatingScale = TRUE;

		// get the new scale
		m_cScaleX.GetWindowText(szScaleX, 15);
//ANNECY Shaitan SPOFlags 17/02/98
		if (fn_bZoomForScale())
		{
			m_cScaleY.SetWindowText(szScaleX);
			m_cScaleZ.SetWindowText(szScaleX);
		}
//ENDANNECY Shaitan SPOFlags
		m_cScaleY.GetWindowText(szScaleY, 15);
		m_cScaleZ.GetWindowText(szScaleZ, 15);
		MTH3D_M_vSetXofVector(&stScale, (float) atof (szScaleX));
		MTH3D_M_vSetYofVector(&stScale, (float) atof (szScaleY));
		MTH3D_M_vSetZofVector(&stScale, (float) atof (szScaleZ));
		// is there a difference ?
		if (!MTH3D_M_bEqualVector(&m_stScales, &stScale))
		{
			MTH3D_tdstVector stVectI,stVectJ,stVectK;

			// create modif
			m_pEditMove = new EDT_ModifMove(GetParentEditor(), M_GetWorld()->GetListOfListByDLL(), GetInterface()->GetSelectMode());
			// modif scale
			POS_fn_vGetScaleMatrix(HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct()),&stVectI,&stVectJ,&stVectK);
			MTH3D_M_vSetXofVector(&stVectI, MTH3D_M_xGetXofVector(&stScale));
			MTH3D_M_vSetYofVector(&stVectJ, MTH3D_M_xGetYofVector(&stScale));
			MTH3D_M_vSetZofVector(&stVectK, MTH3D_M_xGetZofVector(&stScale));
			POS_fn_vSetScaleMatrix(HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct()),&stVectI,&stVectJ,&stVectK);

			GetInterface()->fn_vUpdatePositions();
			// do modif
			bDone = GetParentEditor()->fn_bDoOrCancelMove(m_pEditMove);
			// update vector
			if (bDone)
				MTH3D_M_vCopyVector(&m_stScales, &stScale);

			m_pEditMove = NULL;
		}

		// update flags
		m_cScaleX.SetModify(FALSE);
		m_cScaleY.SetModify(FALSE);
		m_cScaleZ.SetModify(FALSE);

        m_bUpdatingScale = FALSE;
	}
}


/*===========================================================================
*		Description:	Calculate the 3 angles of the 3 rotations (X axe then Y axe and Z axe)
*						from the rotation matrix
*		Creation date:	
*		Author:			Alexis Vaisse
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vConvertRotateMatrixToAngles (MTH3D_tdstVector * pAngles, POS_tdstCompletePosition * pMatrix)
{

#define M(a,b) (MTH3D_M_xGet##b##ofVector(&stVect##a))

	MTH3D_tdstVector	stVectI,stVectJ,stVectK;

	POS_fn_vGetRotationMatrix(pMatrix,&stVectI,&stVectJ,&stVectK);
    // Calculate the 3 angles
    GLI_tdxValue Divide = (float) sqrt(M(I,X)*M(I,X)+M(I,Y)*M(I,Y));

    pAngles->xX =   (float) asin (M(J,Z) / Divide);    // We get an angle between -90° and 90°
    pAngles->xZ =   (float) asin (M(I,Y) / Divide);    // We get an angle between -90° and 90°
    pAngles->xY =	(float) asin (M(I,Z));             // We get an angle between -90° and 90°


    if (M(K,Z) < 0)
    {
        if (pAngles->xX >= 0)  
			pAngles->xX =   GLI_M_PI - pAngles->xX;  // Angle between   90° and 180°
		else 
			pAngles->xX = - GLI_M_PI - pAngles->xX;  // Angle between -180° and -90°
    }

    if (M(I,X) < 0)
    {
        if (pAngles->xZ >= 0)  
			pAngles->xZ =   GLI_M_PI - pAngles->xZ;  // Angle between   90° and 180°
		else 
			pAngles->xZ = - GLI_M_PI - pAngles->xZ;  // Angle between -180° and -90°
    }

    if (M(I,X) < 0 && M(K,Z) < 0)
    {
		if (pAngles->xY >= 0)  
			pAngles->xY =   GLI_M_PI - pAngles->xY;  // Angle between   90° and 180°
		else 
			pAngles->xY = - GLI_M_PI - pAngles->xY;  // Angle bewteen -180° and -90°

        if (pAngles->xX >= 0)  
			pAngles->xX -= GLI_M_PI;
		else 
			pAngles->xX += GLI_M_PI;
 
		if (pAngles->xZ >= 0)  
			pAngles->xZ -= GLI_M_PI;
		else 
			pAngles->xZ += GLI_M_PI;
    }
   
	// Convert from radians to degrees
    const GLI_tdxValue ConvertToDegrees = 180 / GLI_M_PI;
    MTH3D_M_vMulScalarVector (pAngles,ConvertToDegrees, pAngles);
}

/*===========================================================================
*		Description:	Make a rotation around the X axe
*		Creation date:	
*		Author:			Alexis Vaisse
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vRotateX (POS_tdstCompletePosition *p_stMatrix, GLI_tdxValue xXAngle)
{
	POS_tdstCompletePosition stRotMatrix;
	MTH3D_tdstVector		stVectI,stVectJ,stVectK;

	POS_fn_vSetIdentityMatrix(&stRotMatrix);
	POS_fn_vGetRotationMatrix(&stRotMatrix,&stVectI,&stVectJ,&stVectK);
	MTH3D_M_vSetYofVector(&stVectJ,GLI_M_Cos(xXAngle)) ;
	MTH3D_M_vSetZofVector(&stVectJ,GLI_M_Sin(xXAngle)) ;
	MTH3D_M_vSetYofVector(&stVectK,GLI_M_Neg(GLI_M_Sin(xXAngle))) ;
	MTH3D_M_vSetZofVector(&stVectK,GLI_M_Cos(xXAngle)) ;
	POS_fn_vSetRotationMatrix(&stRotMatrix,&stVectI,&stVectJ,&stVectK);

	POS_fn_vMulMatrixMatrix(p_stMatrix,&stRotMatrix,p_stMatrix);
}


/*===========================================================================
*		Description:	Make a rotation around the Y axe
*		Creation date:	
*		Author:			Alexis Vaisse
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vRotateY (POS_tdstCompletePosition *p_stMatrix, GLI_tdxValue xYAngle)
{
	POS_tdstCompletePosition stRotMatrix;
	MTH3D_tdstVector		stVectI,stVectJ,stVectK;

	POS_fn_vSetIdentityMatrix(&stRotMatrix);
	POS_fn_vGetRotationMatrix(&stRotMatrix,&stVectI,&stVectJ,&stVectK);
	MTH3D_M_vSetXofVector(&stVectI,GLI_M_Cos(xYAngle)) ;
	MTH3D_M_vSetZofVector(&stVectI,GLI_M_Sin(xYAngle)) ;
	MTH3D_M_vSetXofVector(&stVectK,GLI_M_Neg(GLI_M_Sin(xYAngle))) ;
	MTH3D_M_vSetZofVector(&stVectK,GLI_M_Cos(xYAngle)) ;
	POS_fn_vSetRotationMatrix(&stRotMatrix,&stVectI,&stVectJ,&stVectK);

	POS_fn_vMulMatrixMatrix(p_stMatrix,&stRotMatrix,p_stMatrix);
}


/*===========================================================================
*		Description:	Make a rotation around the Z axe
*		Creation date:	
*		Author:			Alexis Vaisse
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vRotateZ (POS_tdstCompletePosition *p_stMatrix, GLI_tdxValue xZAngle)
{
	POS_tdstCompletePosition stRotMatrix;
	MTH3D_tdstVector		stVectI,stVectJ,stVectK;

	POS_fn_vSetIdentityMatrix(&stRotMatrix);
	POS_fn_vGetRotationMatrix(&stRotMatrix,&stVectI,&stVectJ,&stVectK);
	MTH3D_M_vSetXofVector(&stVectI,GLI_M_Cos(xZAngle));
	MTH3D_M_vSetYofVector(&stVectI,GLI_M_Sin(xZAngle));
	MTH3D_M_vSetXofVector(&stVectJ,GLI_M_Neg(GLI_M_Sin(xZAngle)));
	MTH3D_M_vSetYofVector(&stVectJ,GLI_M_Cos(xZAngle));
	POS_fn_vSetRotationMatrix(&stRotMatrix,&stVectI,&stVectJ,&stVectK);

	POS_fn_vMulMatrixMatrix(p_stMatrix,&stRotMatrix,p_stMatrix);
}


/*===========================================================================
*		Description:	Calculate the result rotation matrix when one makes 3 rotations
*                       (X axe then Y axe and Z axe)
*		Creation date:	
*		Author:			Alexis Vaisse
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
void EDT_DialogEdit::fn_vConvertAnglesToRotateMatrix (POS_tdstCompletePosition * pMatrix, MTH3D_tdstVector * pAngles)
{
    POS_tdstCompletePosition Matrix;
	MTH3D_tdstVector	stVectI,stVectJ,stVectK;
    const GLI_tdxValue	ConvertToRadians = GLI_M_PI / 180;

	POS_fn_vSetIdentityMatrix(&Matrix);
    fn_vRotateX (& Matrix, MTH3D_M_xGetXofVector(pAngles) * ConvertToRadians);
    fn_vRotateY (& Matrix, MTH3D_M_xGetYofVector(pAngles) * ConvertToRadians);
    fn_vRotateZ (& Matrix, MTH3D_M_xGetZofVector(pAngles) * ConvertToRadians);

	POS_fn_vGetRotationMatrix(&Matrix,&stVectI,&stVectJ,&stVectK);
	POS_fn_vSetRotationMatrix(pMatrix,&stVectI,&stVectJ,&stVectK);
}



//#################################################################################
// EDT_DialogEdit message handlers
//#################################################################################

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnObjectGo (void)
{
	m_pEditor->GetDialogList()->fn_vUpdateSelection(E_lrm_GoToChild);
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnChangeSupObjName() 
{
	CString		csFinalName;
	BOOL		bValid = FALSE;
	char		szFinalName[256], szInitialName[256];

	// no linked object => no change
	if (!m_pEditedObject)
		return;
	
	if (m_cSupObjName.GetModify())
	{
		// init names
		m_cSupObjName.GetWindowText(szFinalName, 255);
		strcpy(szInitialName, m_pEditedObject->GetName());
		// get prefixed name
		csFinalName = GetInterface()->GetPrefixedName(szFinalName);
		// check prefix
		if ((!GetInterface()->fn_bCanModifyObject(m_pEditedObject)) ||
			(m_pEditedObject->fn_eCheckValidity(csFinalName) != E_mc_None))
			m_cSupObjName.SetWindowText(szInitialName);
		// confirm the modif
		else
			M_GetEditManager()->AskFor(new EDT_ModifName(m_pEditor, m_pEditedObject, csFinalName, FALSE));
		// update editor
		GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
		// update flag
		m_cObjectName.SetModify(FALSE);
		m_cObjectName.SetFocus();
	}
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnChangeEditName() 
{
	tdeMissingCriteria	eValid;
	CPA_BaseObject		*pLinkedObject;
	CString				csFinalName;
	char				szFinalName[256], szInitialName[256];

	// no linked object => no change
	pLinkedObject = (m_pEditedObject) ? m_pEditedObject->GetObject() : NULL;
	if (!pLinkedObject)
		return;
	
	if (m_cObjectName.GetModify())
	{
		// init names
		m_cObjectName.GetWindowText(szFinalName, 255);
		strcpy(szInitialName, pLinkedObject->GetName());
		// get prefixed name
		csFinalName = GetInterface()->GetPrefixedName(szFinalName);
		// check validity of new name
		if (pLinkedObject->fn_bCanBeSaved())
			eValid = ((CPA_SaveObject *) pLinkedObject)->fn_eCheckValidity(csFinalName);
		else
			eValid = pLinkedObject->fn_eCheckUnicity(csFinalName);
		// if necessary, cancel the modif
		if ((!GetInterface()->fn_bCanModifyObject(pLinkedObject)) || (eValid != E_mc_None))
			m_cObjectName.SetWindowText(szInitialName);
		// confirm the modif
		else
			M_GetEditManager()->AskFor(new EDT_ModifName(m_pEditor, m_pEditedObject, csFinalName, TRUE));
		// update editor
		GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
		// update flag
		m_cObjectName.SetModify(FALSE);
		m_cParentGo.SetFocus();
	}
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnParentGo (void)
{
	m_pEditor->GetDialogList()->fn_vUpdateSelection(E_lrm_GoToParent);
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnChangePosx() 
{
	// global mode => change only on "Apply"
	if (m_bGlobalMove)
		return;
	
	// else change position
	if (m_cPosX.GetModify())
	{
		fn_vSetNewPosition(C_AxeX);	
		m_cPosY.SetFocus();
	}
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnChangePosy() 
{
	// global mode => change only on "Apply"
	if (m_bGlobalMove)
		return;
	
	// else change position
	if (m_cPosY.GetModify())
	{
		fn_vSetNewPosition(C_AxeY);	
		m_cPosZ.SetFocus();
	}
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnChangePosz() 
{
	// global mode => change only on "Apply"
	if (m_bGlobalMove)
		return;
	
	// else change position
	if (m_cPosZ.GetModify())
	{
		fn_vSetNewPosition(C_AxeZ);	
		m_cRotX.SetFocus();
	}
}


/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnChangeRotx() 
{
	// global mode => change only on "Apply"
	if (m_bGlobalMove)
		return;
	
	// else change position
	if (m_cRotX.GetModify())
	{
		char sz[15];
        m_cRotX.GetWindowText(sz, 15);
        float x = (float) atof (sz);
		if ((x > 180) || (x < -180))
		{
			M_GetMainWnd()->UpdateStatus("ERROR : Invalid Rotation Value (-180 to 180)", C_STATUSPANE_INFOS, C_STATUS_ERROR);
			m_cRotX.SetFocus();
		}
		else
		{
			fn_vSetNewRotation(C_AxeX);	
			m_cRotY.SetFocus();
		}
	}
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnChangeRoty() 
{
	// global mode => change only on "Apply"
	if (m_bGlobalMove)
		return;
	
	// else change position
	if (m_cRotY.GetModify())
	{
		char sz[15];
        m_cRotY.GetWindowText(sz, 15);
        float x = (float) atof (sz);
		if ((x > 180) || (x < -180))
		{
			M_GetMainWnd()->UpdateStatus("ERROR : Invalid Rotation Value (-180 to 180)", C_STATUSPANE_INFOS, C_STATUS_ERROR);
			m_cRotY.SetFocus();
		}
		else
		{
			fn_vSetNewRotation(C_AxeY);
			m_cRotZ.SetFocus();
		}
	}
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnChangeRotz() 
{
	// global mode => change only on "Apply"
	if (m_bGlobalMove)
		return;
	
	// else change position
	if (m_cRotZ.GetModify())
	{
		char sz[15];
        m_cRotZ.GetWindowText(sz, 15);
        float x = (float) atof (sz);
		if ((x > 180) || (x < -180))
		{
			M_GetMainWnd()->UpdateStatus("ERROR : Invalid Rotation Value (-180 to 180)", C_STATUSPANE_INFOS, C_STATUS_ERROR);
			m_cRotZ.SetFocus();
		}
		else
		{
			fn_vSetNewRotation(C_AxeZ);	
			m_cScaleX.SetFocus();
		}
	}
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnChangeScalex() 
{
	// global mode => change only on "Apply"
	if (m_bGlobalMove)
		return;
	
	// else change position
	if (m_cScaleX.GetModify())
	{
		fn_vSetNewScale(C_AxeX);
		m_cScaleY.SetFocus();
	}
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnChangeScaley() 
{
	// global mode => change only on "Apply"
	if (m_bGlobalMove)
		return;
	
	// else change position
	if (m_cScaleY.GetModify())
	{
		fn_vSetNewScale(C_AxeY);
		m_cScaleZ.SetFocus();
	}
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnChangeScalez() 
{
	// global mode => change only on "Apply"
	if (m_bGlobalMove)
		return;
	
	// else change position
	if (m_cScaleZ.GetModify())
	{
		fn_vSetNewScale(C_AxeZ);
		m_cSupObjGo.SetFocus();
	}
}

//ANNECY Shaitan Transparency 26/03/98 {
/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnChangeTransparency (void)
{
	float fTransparency;
	char  szTransparency[15];

	if (m_cEditTransparency.GetModify())
	{
		m_cEditTransparency.GetWindowText(szTransparency, 15);
		fTransparency = (float) atof (szTransparency);
		if (fTransparency > 255.0) 
			fTransparency = 255.0;
		if (fTransparency < 0.0)
			fTransparency = 0.0;
		// update transparency level
		m_pEditedObject->fn_vSetTransparencyLevel(fTransparency);
		m_cSliderTransparency.SetPos((int) fTransparency);
		
		m_cEditTransparency.SetModify(FALSE);
	}
}
//ENDANNECY Shaitan Transparency }

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnDefaultButton (void)
{
	// name changed ?
	if (m_cSupObjName.GetModify())
	{
		OnChangeSupObjName();
		m_cSupObjName.SetFocus();
	}
	
	// name changed ?
	else if (m_cObjectName.GetModify())
	{
		OnChangeEditName();
		m_cObjectName.SetFocus();
	}
	
//ANNECY Shaitan Transparency 26/03/98 {
	// name changed ?
	else if (m_cEditTransparency.GetModify())
	{
		OnChangeTransparency();
		m_cEditTransparency.SetFocus();
	}
//ENDANNECY Shaitan Transparency }

	// global mode => change only on "Apply"
	else if (m_bGlobalMove)
		return;
	
	// position changed ?
	else if (m_cPosX.GetModify())
	{
		fn_vSetNewPosition(C_AxeX);
		m_cPosX.SetFocus();
	}
	else if (m_cPosY.GetModify())
	{
		fn_vSetNewPosition(C_AxeY);
		m_cPosY.SetFocus();
	}
	else if (m_cPosZ.GetModify())
	{
		fn_vSetNewPosition(C_AxeZ);
		m_cPosZ.SetFocus();
	}

	// rotation changed ?
	else if (m_cRotX.GetModify())
	{
		char sz[15];
        m_cRotX.GetWindowText(sz, 15);
        float x = (float) atof (sz);
		if ((x > 180) || (x < -180))
		{
			M_GetMainWnd()->UpdateStatus("ERROR : Invalid Rotation Value (-180 to 180)", C_STATUSPANE_INFOS, C_STATUS_ERROR);
			m_cRotX.SetFocus();
		}
		else
		{
			fn_vSetNewRotation(C_AxeX);	
			m_cRotX.SetFocus();
		}
	}
	else if (m_cRotY.GetModify())
	{
	{
		char sz[15];
        m_cRotY.GetWindowText(sz, 15);
        float x = (float) atof (sz);
		if ((x > 180) || (x < -180))
		{
			M_GetMainWnd()->UpdateStatus("ERROR : Invalid Rotation Value (-180 to 180)", C_STATUSPANE_INFOS, C_STATUS_ERROR);
			m_cRotY.SetFocus();
		}
		else
		{
			fn_vSetNewRotation(C_AxeY);
			m_cRotY.SetFocus();
		}
	}
	}
	else if (m_cRotZ.GetModify())
	{
		char sz[15];
        m_cRotZ.GetWindowText(sz, 15);
        float x = (float) atof (sz);
		if ((x > 180) || (x < -180))
		{
			M_GetMainWnd()->UpdateStatus("ERROR : Invalid Rotation Value (-180 to 180)", C_STATUSPANE_INFOS, C_STATUS_ERROR);
			m_cRotZ.SetFocus();
		}
		else
		{
			fn_vSetNewRotation(C_AxeZ);	
			m_cRotZ.SetFocus();
		}
	}

	// scale changed ?
	else if (m_cScaleX.GetModify())
	{
		fn_vSetNewScale(C_AxeX);
		m_cScaleX.SetFocus();
	}
	else if (m_cScaleY.GetModify())
	{
		fn_vSetNewScale(C_AxeY);
		m_cScaleY.SetFocus();
	}
	else if (m_cScaleZ.GetModify())
	{
		fn_vSetNewScale(C_AxeZ);
		m_cScaleZ.SetFocus();
	}
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnGlobalMode (void)
{
	// global mode => update pos
	if (m_bGlobalMove)
		OnApply();
	// disable sliders
	else
	{
		m_cSliderX.EnableWindow(FALSE);
		m_cSliderY.EnableWindow(FALSE);
		m_cSliderZ.EnableWindow(FALSE);
	}
	// update mode
	m_bGlobalMove = m_cGlobalMode.GetCheck();
	// update apply button
	m_cApply.EnableWindow(m_bGlobalMove);
	// update sliders
	m_cSliderX.EnableWindow(!m_bGlobalMove && m_cRotX.IsWindowEnabled());
	m_cSliderY.EnableWindow(!m_bGlobalMove && m_cRotY.IsWindowEnabled());
	m_cSliderZ.EnableWindow(!m_bGlobalMove && m_cRotZ.IsWindowEnabled());
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnApply (void)
{
	char				szPosX[15], szPosY[15], szPosZ[15];
	char				szRotX[15], szRotY[15], szRotZ[15];
	char				szScaX[15], szScaY[15], szScaZ[15];
	BOOL				bChanged;
	MTH3D_tdstVector	stPosition;
	MTH3D_tdstVector	stAngles;
	MTH3D_tdstVector	stScale;
	MTH3D_tdstVector	stVectI,stVectJ,stVectK;

	// find new position
	m_cPosX.GetWindowText(szPosX, 15);
	m_cPosY.GetWindowText(szPosY, 15);
	m_cPosZ.GetWindowText(szPosZ, 15);
	MTH3D_M_vSetXofVector(&stPosition, (float) atof(szPosX));
	MTH3D_M_vSetYofVector(&stPosition, (float) atof(szPosY));
	MTH3D_M_vSetZofVector(&stPosition, (float) atof(szPosZ));
	// is there a difference ?
	bChanged = !MTH3D_M_bEqualVector(&m_stTranslation, &stPosition);

	// get the new angles
	m_cRotX.GetWindowText(szRotX, 15);
	m_cRotY.GetWindowText(szRotY, 15);		
	m_cRotZ.GetWindowText(szRotZ, 15);
	MTH3D_M_vSetXofVector(&stAngles, (float) atof(szRotX));
	MTH3D_M_vSetYofVector(&stAngles, (float) atof(szRotY));
	MTH3D_M_vSetZofVector(&stAngles, (float) atof(szRotZ));
	// is there a difference ?
	bChanged = (bChanged || (!MTH3D_M_bEqualVector(&m_stAngles, &stAngles)));

	// get the new scale
	m_cScaleX.GetWindowText(szScaX, 15);
//ANNECY Shaitan SPOFlags 17/02/98
	if (fn_bZoomForScale())
	{
		m_cScaleY.SetWindowText(szScaX);
		m_cScaleZ.SetWindowText(szScaX);
	}
//ENDANNECY Shaitan SPOFlags
	m_cScaleY.GetWindowText(szScaY, 15);
	m_cScaleZ.GetWindowText(szScaZ, 15);
	MTH3D_M_vSetXofVector(&stScale, (float) atof(szScaX));
	MTH3D_M_vSetYofVector(&stScale, (float) atof(szScaY));
	MTH3D_M_vSetZofVector(&stScale, (float) atof(szScaZ));
	// is there a difference ?
	bChanged = (bChanged || (!MTH3D_M_bEqualVector(&m_stScales, &stScale)));

	if (!bChanged)
		return;


	// create modif
	m_pEditMove = new EDT_ModifMove(GetParentEditor(), M_GetWorld()->GetListOfListByDLL(), GetInterface()->GetSelectMode());
	
	// set new translation
	POS_fn_vSetTranslationVector(HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct()),&stPosition);
	// set new rotation
	fn_vConvertAnglesToRotateMatrix (HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct()),&stAngles);
	// set new scale
	POS_fn_vGetScaleMatrix(HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct()),&stVectI,&stVectJ,&stVectK);
	MTH3D_M_vSetXofVector(&stVectI, MTH3D_M_xGetXofVector(&stScale));
	MTH3D_M_vSetYofVector(&stVectJ, MTH3D_M_xGetYofVector(&stScale));
	MTH3D_M_vSetZofVector(&stVectK, MTH3D_M_xGetZofVector(&stScale));
	POS_fn_vSetScaleMatrix(HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct()),&stVectI,&stVectJ,&stVectK);
	
	// update global matrix
	GetInterface()->fn_vUpdatePositions();
	// do modif
	GetParentEditor()->fn_bDoOrCancelMove(m_pEditMove);

	m_pEditMove = NULL;

	// update pos flags
	m_cPosX.SetModify(FALSE);
	m_cPosY.SetModify(FALSE);
	m_cPosZ.SetModify(FALSE);

	// update rot flags
	m_cRotX.SetModify(FALSE);
	m_cRotY.SetModify(FALSE);
	m_cRotZ.SetModify(FALSE);

	// update flags
	m_cScaleX.SetModify(FALSE);
	m_cScaleY.SetModify(FALSE);
	m_cScaleZ.SetModify(FALSE);
}

//#################################################################################
// EDT_DialogEdit permissions
//#################################################################################

/*----------------------------------------
----------------------------------------*/
BOOL EDT_DialogEdit::fn_bCanTranslate (void)
{
	CPA_List<CPA_SuperObject> stListModif;
	
	// no selection => no change
	if (!m_pEditedObject)
		return FALSE;

	// init list
	stListModif.RemoveAll();
	stListModif.AddTail(m_pEditedObject);
	
	// world must be valid
	if (!M_HasCurrentWorld())
		return FALSE;

	// ask World
	if (!M_GetWorld()->fn_bAcceptModifTranslate(m_pEditedObject->GetObjectDLL()))
		return FALSE;
	// ask current editor
	if (!M_IsCurrentEditor())
	{
		if (!M_GetCurrentEditor()->fn_bAcceptModifTranslate(&stListModif, C_AsCurrentEditor))
			return FALSE;
	}
	// ask concerned DLL
	if (m_pEditedObject->GetObjectDLL())
	{
		if (!m_pEditedObject->GetObjectDLL()->fn_bAcceptModifTranslate(&stListModif, C_AsConcernedDLL))
			return FALSE;
	}
	// ask owner
	if (m_pEditedObject->GetSuperObjectOwner())
	{
		if (!m_pEditedObject->GetSuperObjectOwner()->GetObjectDLL()->fn_bAcceptModifTranslate(&stListModif, C_AsChildOwner))
			return FALSE;
	}

	// no objection
	return TRUE;

}


/*----------------------------------------
----------------------------------------*/
BOOL EDT_DialogEdit::fn_bCanRotate (void)
{
	CPA_List<CPA_SuperObject> stListModif;
	
	// no selection => no change
	if (!m_pEditedObject)
		return FALSE;

	// init list
	stListModif.RemoveAll();
	stListModif.AddTail(m_pEditedObject);
	
	// world must be valid
	if (!M_HasCurrentWorld())
		return FALSE;

//ANNECY Shaitan SPOFlags 17/02/98
	// check super-objects flags
	if (HIE_fn_SO_bHasNoTransformationMatrix(m_pEditedObject->GetStruct()))
		return FALSE;
//ENDANNECY Shaitan SPOFlags
	
	// ask World
	if (!M_GetWorld()->fn_bAcceptModifRotate(m_pEditedObject->GetObjectDLL()))
		return FALSE;
	// ask current editor
	if (!M_IsCurrentEditor())
	{
		if (!M_GetCurrentEditor()->fn_bAcceptModifRotate(&stListModif, C_AsCurrentEditor))
			return FALSE;
	}
	// ask concerned DLL
	if (m_pEditedObject->GetObjectDLL())
	{
		if (!m_pEditedObject->GetObjectDLL()->fn_bAcceptModifRotate(&stListModif, C_AsConcernedDLL))
			return FALSE;
	}
	// ask owner
	if (m_pEditedObject->GetSuperObjectOwner())
	{
		if (!m_pEditedObject->GetSuperObjectOwner()->GetObjectDLL()->fn_bAcceptModifRotate(&stListModif, C_AsChildOwner))
			return FALSE;
	}

	// no objection
	return TRUE;
}


/*----------------------------------------
----------------------------------------*/
BOOL EDT_DialogEdit::fn_bCanScale (void)
{
	// world must be valid
	if (!M_HasCurrentWorld())
		return FALSE;
	// no selection => no change
	if (!m_pEditedObject)
		return FALSE;

//ANNECY Shaitan SPOFlags 17/02/98
	// check super-objects flags
	if (HIE_fn_SO_bHasNoTransformationMatrix(m_pEditedObject->GetStruct()))
		return FALSE;
//ENDANNECY Shaitan SPOFlags

	// ask world
	if (!M_GetWorld()->fn_bAcceptModifScale(m_pEditedObject->GetObjectDLL()))
		return FALSE;
	// ask current editor
	if (!M_IsCurrentEditor())
	{
		if (!M_GetCurrentEditor()->fn_bAcceptModifScale(m_pEditedObject, C_AsCurrentEditor))
			return FALSE;
	}
	// ask concerned DLL
	if (m_pEditedObject->GetObjectDLL())
	{
		if (!m_pEditedObject->GetObjectDLL()->fn_bAcceptModifScale(m_pEditedObject, C_AsConcernedDLL))
			return FALSE;
	}
	// ask owner
	if (m_pEditedObject->GetSuperObjectOwner())
	{
		if (!m_pEditedObject->GetSuperObjectOwner()->GetObjectDLL()->fn_bAcceptModifScale(m_pEditedObject, C_AsChildOwner))
			return FALSE;
	}

	// no objection
	return TRUE;

}

//ANNECY Shaitan SPOFlags 17/02/98
/*----------------------------------------
----------------------------------------*/
BOOL EDT_DialogEdit::fn_bZoomForScale (void)
{
	return HIE_fn_SO_bHasZoomInsteadOfScale(m_pEditedObject->GetStruct());
}
//ENDANNECY Shaitan SPOFlags 	

/*----------------------------------------
----------------------------------------*/
BOOL EDT_DialogEdit::fn_bCanRenameSuperObject (void)
{
	return TRUE;
}

/*----------------------------------------
----------------------------------------*/
BOOL EDT_DialogEdit::fn_bCanRenameObject (void)
{
	// world must be valid
	if (!M_HasCurrentWorld())
		return FALSE;

	// ask world
	if (!M_GetWorld()->fn_bAcceptModifName(m_pEditedObject->GetObjectDLL()))
		return FALSE;
	// ask current editor
	if (!M_IsCurrentEditor())
	{
		if (!M_GetCurrentEditor()->fn_bAcceptModifName(m_pEditedObject, C_AsCurrentEditor))
			return FALSE;
	}
	// ask concerned DLL
	if (m_pEditedObject->GetObjectDLL())
	{
		if (!m_pEditedObject->GetObjectDLL()->fn_bAcceptModifName(m_pEditedObject, C_AsConcernedDLL))
			return FALSE;
	}
	// ask owner
	if (m_pEditedObject->GetSuperObjectOwner())
	{
		if (!m_pEditedObject->GetSuperObjectOwner()->GetObjectDLL()->fn_bAcceptModifName(m_pEditedObject, C_AsChildOwner))
			return FALSE;
	}

	// no objection
	return TRUE;

}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{	
	float fTransparency;
	char  szTransparency[15];

	// test scrollbar
	if (pScrollBar != (void*) &m_cSliderTransparency)
	{
		CFormView::OnHScroll(nSBCode, nPos, pScrollBar);
		return;
	}

	// get the new level
    fTransparency = (float) m_cSliderTransparency.GetPos();

	// update level
	m_pEditedObject->fn_vSetTransparencyLevel(fTransparency);
	sprintf(szTransparency, "%7.4f", m_pEditedObject->fn_fGetTransparencyLevel());
	m_cEditTransparency.SetWindowText(szTransparency);

	CFormView::OnHScroll(nSBCode, nPos, pScrollBar);
}
//ENDANNECY Shaitan Transparency }

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	MTH3D_tdstVector	stAngles;
	BOOL				bDone;
	char				szRotX[15];
	char				szRotY[15];
	char				szRotZ[15];
	
	// test state
	if (m_bGlobalMove)
		return;
	
	// test scrollbar
	if ((pScrollBar != (void*) &m_cSliderX) &&
		(pScrollBar != (void*) &m_cSliderY) &&
		(pScrollBar != (void*) &m_cSliderZ))
	{
		CFormView::OnVScroll(nSBCode, nPos, pScrollBar);
		return;
	}

	if (!m_bUpdatingRot)
	{
		m_bUpdatingRot = TRUE;

		if (!m_pEditMove)
		{
			// tell Dlls
			GetParentEditor()->fn_vSendMessageBeginMove();
			// create modif
			m_pEditMove = new EDT_ModifMove(GetParentEditor(), M_GetWorld()->GetListOfListByDLL(), GetInterface()->GetSelectMode());
		}

		// get the new angles
        MTH3D_M_vSetXofVector(&stAngles, (float) m_cSliderX.GetPos());
        MTH3D_M_vSetYofVector(&stAngles, (float) m_cSliderY.GetPos());
        MTH3D_M_vSetZofVector(&stAngles, (float) m_cSliderZ.GetPos());
		// is there a difference ?
		if (!MTH3D_M_bEqualVector(&m_stAngles, &stAngles))
		{
			// create modif
//			m_pEditMove = new EDT_ModifMove(GetParentEditor(), M_GetWorld()->GetListOfListByDLL(), GetInterface()->GetSelectMode());
			// calculate the new rotation matrix
			fn_vConvertAnglesToRotateMatrix (HIE_fn_hGetSuperObjectMatrix(m_pEditedObject->GetStruct()),&stAngles);
			GetInterface()->fn_vUpdatePositions();
			GetInterface()->fn_vUpdateAll(E_mc_JustDraw);
			// do modif
//			bDone = GetParentEditor()->fn_bDoOrCancelMove(m_pEditMove);
			GetParentEditor()->fn_vSendMessageMoving();
			// update angles
//			if (bDone)
//			{
				MTH3D_M_vCopyVector(&m_stAngles, &stAngles);
				sprintf(szRotX, "%4.0f", MTH3D_M_xGetXofVector(&m_stAngles));
				sprintf(szRotY, "%4.0f", MTH3D_M_xGetYofVector(&m_stAngles));
				sprintf(szRotZ, "%4.0f", MTH3D_M_xGetZofVector(&m_stAngles));
				m_cRotX.SetRedraw(TRUE);
				m_cRotX.SetWindowText(szRotX);
				m_cRotX.UpdateWindow();
				m_cRotY.SetWindowText(szRotY);
				m_cRotY.SetRedraw(TRUE);
				m_cRotY.UpdateWindow();
				m_cRotZ.SetRedraw(TRUE);
				m_cRotZ.SetWindowText(szRotZ);
				m_cRotZ.UpdateWindow();
//			}
		}

		if (nSBCode == SB_ENDSCROLL)
		{
			BOOL bGlobalMove = m_bGlobalMove;
			m_bGlobalMove = TRUE;
			bDone = GetParentEditor()->fn_bDoOrCancelMove(m_pEditMove);
			m_pEditMove = NULL;
			m_bGlobalMove = bGlobalMove;
		}
	}
	
	CFormView::OnVScroll(nSBCode, nPos, pScrollBar);

	m_bUpdatingRot = FALSE;
}

/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnSize(UINT nType, int cx, int cy)
{
	RECT WindowPosition;
	RECT SupobjRect, ObjectRect, FatherRect, PositionRect;
	int cwx, cwy, csx, csy, cox, coy, cfx, cfy, cpx, cpy;
	int psy, poy, pfy, ppy;

	if (m_bInitialised)
	{
		GetWindowRect(&WindowPosition);
		cwx = WindowPosition.right - WindowPosition.left - 10;
		cwy = WindowPosition.bottom - WindowPosition.top - 10;

		// Super-Object controls
		GetDlgItem(EDT_IDC_SUPOBJRECT)->GetWindowRect(&SupobjRect);
		// relative position
		csx = (cwx < 60) ? 50 : cwx - 10;
		csy = 100;
		psy = 0;
		// Supobj box & go
		GetDlgItem(EDT_IDC_SUPOBJRECT)->MoveWindow(5, psy, cwx, csy);
		m_cSupObjGo.MoveWindow(cwx-15, psy+8, 18, 18);
		// name control
		m_cSupObjName.MoveWindow(10, psy+15, csx - 20 , 18);
		// parameters controls
		m_cSupObjOwner.MoveWindow(10, psy+35, csx - 50, 18);
//ANNECY CO SPOFLAG 03/02/98
		m_cSupObjFlags.MoveWindow(csx - 37, psy+35, 35, 18);
//ENDANNECY CO SPOFLAG 
		// level controls
		m_cSupObjLevel.MoveWindow(10, psy+55, csx - 60, 18);
		m_cTemp.MoveWindow(csx - 47, psy+57, 47, 15);
//ANNECY Shaitan Transparency (26/03/98) {
		m_cSliderTransparency.MoveWindow(10, psy+77, csx - 60, 15);
		m_cEditTransparency.MoveWindow(csx - 47, psy+75, 47, 18);
//ENDANNECY Shaitan Transparency }

		// Object controls
		GetDlgItem(EDT_IDC_OBJECTRECT)->GetWindowRect(&ObjectRect);
		// relative position
		cox = (cwx < 60) ? 50 : cwx - 10;
		coy = 80;
		poy = csy;
		// object box & go
		GetDlgItem(EDT_IDC_OBJECTRECT)->MoveWindow(5, poy, cwx, coy);
		// name controls
		m_cObjectName.MoveWindow(10, poy+15, cox - 20, 18);
		// type controls
		m_cObjectType.MoveWindow(10, poy+35, cox/2 - 5, 18);
		m_cObjectDesc.MoveWindow(cox/2 + 15, poy+35, cox/2 - 5, 18);
		// file controls
		m_cObjectOwner.MoveWindow(10, poy+55, cox - 20, 18);

		// ParentControls
		GetDlgItem(EDT_IDC_PARENTRECT)->GetWindowRect(&FatherRect);
		// relative position
		cfx = (cwx < 30) ? 0 : cwx - 30;
		cfy = 80;
		pfy = poy+coy;
		// object box
		GetDlgItem(EDT_IDC_PARENTRECT)->MoveWindow(5, pfy, cwx, cfy);
		m_cParentGo.MoveWindow(cwx-15, pfy+7, 18, 18);
		// name 
		m_cParentName.MoveWindow(10, pfy+15, cfx, 18);
		// object 
		m_cParentObject.MoveWindow(10, pfy+35, cfx, 18);
		// type controls
		m_cParentType.MoveWindow(10, pfy+55, cox/2 - 5, 18);
		m_cParentOwner.MoveWindow(cox/2 + 15, pfy+55, cox/2 - 5, 18);

		// Position Controls
		GetDlgItem(EDT_IDC_POSITIONRECT)->GetWindowRect(&PositionRect);
		// relative position
		ppy = pfy+cfy;
		cpy = cwy - ppy + 5;
		cpy = (cpy < 110) ? 110 : cpy;
		// object box
		GetDlgItem(EDT_IDC_POSITIONRECT)->MoveWindow(5, ppy, cwx, cpy);
		// Mode Controls
		cpx = (cwx < 100) ? 0 : cwx - 100;
		m_cGlobalMode.MoveWindow(cpx/2, ppy+20, 40, 18);
		m_cApply.MoveWindow(cpx/2+60, ppy+20, 40, 18);
		// static controls
		cpx = (cwx < 70) ? 0 : cwx - 50;
		GetDlgItem(EDT_IDC_TRANSL)->MoveWindow(10, ppy+45, 35, 18);
		GetDlgItem(EDT_IDC_SCALE)->MoveWindow(10, ppy+65, 35, 18);
		GetDlgItem(EDT_IDC_ROT)->MoveWindow(10, ppy+85, 35, 18);
		// Pos controls
		m_cPosX.MoveWindow(50,				ppy+45, cpx/3, 18);
		m_cPosY.MoveWindow(50 + cpx/3,		ppy+45, cpx/3, 18);
		m_cPosZ.MoveWindow(50 + 2*cpx/3,	ppy+45, cpx/3, 18);
		// Scale Controls
		m_cScaleX.MoveWindow(50,			ppy+65, cpx/3, 18);
		m_cScaleY.MoveWindow(50 + cpx/3,	ppy+65, cpx/3, 18);
		m_cScaleZ.MoveWindow(50 + 2*cpx/3,	ppy+65, cpx/3, 18);
		// Rot Controls
		m_cRotX.MoveWindow(50,				ppy+87, cpx/3 - 17, 18);
		m_cRotY.MoveWindow(50 + cpx/3,		ppy+87, cpx/3 - 17, 18);
		m_cRotZ.MoveWindow(50 + 2*cpx/3,	ppy+87, cpx/3 - 17, 18);
		// Sliders
		m_cSliderZ.MoveWindow(33 + cpx,		ppy+85, 16, cpy - 90);
		m_cSliderX.MoveWindow(33 + cpx/3,	ppy+85, 16, cpy - 90);
		m_cSliderY.MoveWindow(33 + 2*cpx/3, ppy+85, 16, cpy - 90);
	}
	return;
}


/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnDestroy ()
{
// FOR TUTORIAL
	TUT_M_vGetTutDll();
	// super-object
    TUT_M_vUnregisterControl(m_cSupObjName.m_hWnd);
    TUT_M_vUnregisterControl(m_cSupObjGo.m_hWnd);
    TUT_M_vUnregisterControl(m_cTemp.m_hWnd);
	// object
    TUT_M_vUnregisterControl(m_cObjectName.m_hWnd);
	// parent
    TUT_M_vUnregisterControl(m_cParentGo.m_hWnd);
	// position
    TUT_M_vUnregisterControl(m_cPosX.m_hWnd);
    TUT_M_vUnregisterControl(m_cPosY.m_hWnd);
    TUT_M_vUnregisterControl(m_cPosZ.m_hWnd);
    TUT_M_vUnregisterControl(m_cScaleX.m_hWnd);
    TUT_M_vUnregisterControl(m_cScaleY.m_hWnd);
    TUT_M_vUnregisterControl(m_cScaleZ.m_hWnd);
    TUT_M_vUnregisterControl(m_cRotX.m_hWnd);
    TUT_M_vUnregisterControl(m_cRotY.m_hWnd);
    TUT_M_vUnregisterControl(m_cRotZ.m_hWnd);
    TUT_M_vUnregisterControl(m_cSliderX.m_hWnd);
    TUT_M_vUnregisterControl(m_cSliderY.m_hWnd);
    TUT_M_vUnregisterControl(m_cSliderZ.m_hWnd);
    TUT_M_vUnregisterControl(m_cGlobalMode.m_hWnd);
    TUT_M_vUnregisterControl(m_cApply.m_hWnd);
	// default button
    TUT_M_vUnregisterControl(m_cDefault.m_hWnd);
// END TUTORIAL

	CFormView::OnDestroy();
}

//ANNECY CO SPOFLAG 03/02/98
/*----------------------------------------
----------------------------------------*/
void EDT_DialogEdit::OnFlags (void)
{
	m_pEditor->fn_vDoDialogFlags(m_pEditedObject);
}
//ENDANNECY CO SPOFLAG

#endif // ACTIVE_EDITOR
