/*=========================================================================
* 
* EDTdEdit.h :  class EDT_DialogEdit
* 
*
* Version			1.0
* Creation date		
* Revision date
*
* Shaitan
*=======================================================================*/
#ifdef ACTIVE_EDITOR

#ifndef __DIALOGEDIT_HPP__
#define __DIALOGEDIT_HPP__

#include "EDTRes.h"
#include "EDTModif.hpp"


#define C_AxeX 0
#define C_AxeY 1
#define C_AxeZ 2

//**************************************
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
//**************************************

class EDT_HierarchyEditor;
class EDT_SuperObject;
class CPA_Interface;

/*===========================================================================
*		Description:	EDT_DialogEdit dialog
*		Creation date:
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                        Author:
*=========================================================================*/

class EDT_DialogEdit : public CFormView
{
protected:
	EDT_HierarchyEditor *m_pEditor;

	// super object
	EDT_SuperObject	*m_pEditedObject;

	// move
	EDT_ModifMove	*m_pEditMove;

	// position
	MTH3D_tdstVector  m_stTranslation;
	MTH3D_tdstVector  m_stAngles;
	MTH3D_tdstVector  m_stScales;

	// flags for update
	BOOL	m_bUpdatingPos;
	BOOL	m_bUpdatingRot;
    BOOL	m_bUpdatingScale;

	// flag for move
	BOOL	m_bGlobalMove; 

	BOOL	m_bInitialised;

private:
	// moves
	void fn_vSetNewPosition (char cAxe);
	void fn_vSetNewRotation (char cAxe);
	void fn_vSetNewScale	(char cAxe);
	void fn_vRotateX                     (POS_tdstCompletePosition * pMatrix, GLI_tdxValue Angle);
	void fn_vRotateY                     (POS_tdstCompletePosition * pMatrix, GLI_tdxValue Angle);
	void fn_vRotateZ                     (POS_tdstCompletePosition * pMatrix, GLI_tdxValue Angle);
    void fn_vConvertAnglesToRotateMatrix (POS_tdstCompletePosition * pMatrix, MTH3D_tdstVector * pAngles);
    void fn_vConvertRotateMatrixToAngles (MTH3D_tdstVector * pAngles, POS_tdstCompletePosition * pMatrix);

public:
// parent editor
	EDT_HierarchyEditor * GetParentEditor (void) { return m_pEditor; }
	EDT_SuperObject		* GetEditedSupObj (void) { return m_pEditedObject; }

	CPA_Interface * GetInterface (void);
	
// standard constructor
	EDT_DialogEdit (CWnd* pParent = NULL);

// dialog
	void fn_vInitDialog     (EDT_HierarchyEditor *pEditor, FRMBase *pFrame);
	void fn_vUpdateDialog   (void);
	
	void fn_vUpdatePosition (void);
	void fn_vUpdateRotation (void);
	void fn_vUpdateScale	(void);
	
	void fn_vUpdateSuperObject	(void);
	void fn_vUpdateObject		(void);
	void fn_vUpdateParent		(void);

	void fn_vSendMessageMove (void);

	BOOL fn_bCanTranslate			(void);
	BOOL fn_bCanRotate				(void);
	BOOL fn_bCanScale				(void);
//ANNECY Shaitan SPOFlags 17/02/98
	BOOL fn_bZoomForScale			(void);
//ENDANNECY Shaitan SPOFlags 	
	BOOL fn_bCanRenameObject		(void);
	BOOL fn_bCanRenameSuperObject	(void);


//ROMTEAM StickObjects (Nicolae Suparatu 10/02/98)
	void fn_vSetNewPositionAndRotation (EDT_SuperObject *obj, POS_tdstCompletePosition matrix);
//ENDROMTEAM StickObjects (Nicolae Suparatu)


// Dialog Data
	//{{AFX_DATA(EDT_DialogEdit)
	enum { IDD = EDT_IDD_DIALOGEDIT };
// super-object
	CEdit			m_cSupObjName;
	CButton			m_cSupObjGo;
	CStatic			m_cSupObjOwner;
	CStatic			m_cSupObjLevel;
//ANNECY CO SPOFLAG 03/02/98
	CButton			m_cSupObjFlags;
//ENDANNECY CO SPOFLAG
//ANNECY Shaitan Transparency 26/03/98 {
	CEdit			m_cEditTransparency;
	CSliderCtrl		m_cSliderTransparency;
//ENDANNECY Shaitan Transparency }
	CButton			m_cTemp;
// object
	CEdit			m_cObjectName;
	CStatic			m_cObjectType, m_cObjectOwner;
	CStatic			m_cObjectDesc;
// parent
	CStatic			m_cParentName;
	CStatic			m_cParentObject;
	CStatic			m_cParentType, m_cParentOwner;
	CButton			m_cParentGo;
// position
	CEdit			m_cPosX, m_cPosY, m_cPosZ;
	CEdit			m_cScaleX, m_cScaleY, m_cScaleZ;
	CEdit			m_cRotX, m_cRotY, m_cRotZ;
	CSliderCtrl		m_cSliderX, m_cSliderY, m_cSliderZ;
	CButton			m_cGlobalMode, m_cApply;
// default button
	CButton			m_cDefault;
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(EDT_DialogEdit)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(EDT_DialogEdit)
	afx_msg void OnChangeSupObjName();
	afx_msg void OnObjectGo();
//ANNECY CO SPOFLAG 03/02/98
	afx_msg void OnFlags();
//ENDANNECY CO SPOFLAG
//ANNECY Shaitan Transparency 26/03/98 {
	afx_msg void OnChangeTransparency();
	afx_msg void OnHScroll (UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
//ENDANNECY Shaitan Transparency }

	afx_msg void OnChangeEditName();
	afx_msg void OnLink();

	afx_msg void OnParentGo();

	afx_msg void OnChangePosx();
	afx_msg void OnChangePosy();
	afx_msg void OnChangePosz();
	afx_msg void OnChangeScalex();
	afx_msg void OnChangeScaley();
	afx_msg void OnChangeScalez();
	afx_msg void OnChangeRotx();
	afx_msg void OnChangeRoty();
	afx_msg void OnChangeRotz();
	afx_msg void OnVScroll (UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);

	afx_msg void OnGlobalMode();
	afx_msg void OnApply();

	afx_msg void OnDefaultButton();
	afx_msg void OnSize(UINT, int, int);
	afx_msg void OnDestroy();	
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#endif //__DIALOGEDIT_HPP__
#endif // ACTIVE_EDITOR
