//**************************************
// This is the base class of your DLL interface
// All methods of CPA_BaseObjectDLLBase are
// present in that class.
//**************************************

#ifndef __MYINTERF_HPP__
#define __MYINTERF_HPP__

#include "itf.h"
#include "camera.hpp"


// if you want only one instance of your DLL
// activate the next line
#define DLL_ONLY_ONE_INSTANCE





class Geometry3D;

//----------------------------------------------------------
// Object DLL interface class
//----------------------------------------------------------
class Camera_Interface : public CPA_CameraDLLBase
{
private:
	// CPA_Ed_1 MP BEGIN
	// mouse handler 
	BOOL m_bRotateOn;
	BOOL m_bIsMoving;
	tdstMousePos m_stMousePos;
	HCURSOR hcursorM, hcursorR;
	// CPA_Ed_1 MP END

	// keyboard handler
    CPA_KeyActionConfiguration *m_p_oKeyConfiguration;
	Geometry3D					*m_p_oInertCameraGeomObject;

	float						m_fTranslationStep;
	float						m_fRotationStep;

	GLI_tdxHandleToCamera		m_hLastEngineCamera;

	BOOL						m_bFirstTime;
	long						m_lSlotForEngineCamera;
	long						m_lSlotForLastEditorCamera;
// ANNECY MT NewInterface 26/03/98 {
	tdeDisplayReferential		m_eReferentialDisplayMode;
// ENDANNECY MT NewInterface }
	BOOL						m_bCameraTargetMode;

public:

    Camera_Interface(void);

	Geometry3D		*GetInertCameraGeomObject() { return m_p_oInertCameraGeomObject;};
	void			SetTranslationStep(float fStep) { m_fTranslationStep = fStep;};
	void			SetRotationStep(float fStep) { m_fRotationStep = fStep;};
	float			GetTranslationStep() { return m_fTranslationStep;};
	float			GetRotationStep() { return m_fRotationStep;};

	void		fn_vInitListByType		(CPA_World *pWorld);
	CPA_SuperObject *AssociateSuperObject(Camera *p_oCamera);
	
	BOOL fn_bAcceptModifCopy (CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus) { return (eStatus != C_AsConcernedDLL); }
	
	// ACP MEssages Functions overload
	//    BOOL    fn_bPreTranslateMessage(MSG *);
	void fn_vJustAfterRegistered(void);
	void fn_vConstruct(void);
	//    void    fn_vRefreshDatas(void);
	void fn_vAddObjectsToDraw(GLD_tdstViewportAttributes *, GLI_tdstLight *, DEV_ViewPort* p3);
	//    void    fn_vAddObjectsToDraw2(GLD_tdstViewportAttributes *, GLI_tdstLight *);
	//    BOOL    fn_bAcceptToRunEngine(void);
	void    fn_vBeforeEngine(void);
	void    fn_vBeforeEditor(void);
	//    void    fn_vHasLostFocus(void);
	//    BOOL    fn_bHasGainedFocus(void);
	//    BOOL    fn_bAcceptToExit(void);
	//    void    fn_vJustBeforeClosing(void);
	//	  long	  OnQueryAction(CPA_DLLBase*, WPARAM, LPARAM);
	//    long	  OnQueryInfos(CPA_DLLBase*, WPARAM, LPARAM);
	//    long    OnQueryOpen(CPA_DLLBase*, WPARAM, LPARAM);
	//    long    OnQueryClose(CPA_DLLBase*, WPARAM, LPARAM);
	
	// Windows MEssages Functions overload
	//    BOOL    _OnKeyUp           (UINT, UINT, UINT, void *);
	//    BOOL    _OnKeyDown         (UINT, UINT, UINT, void *);
	//    BOOL    _OnUpdateCommandUI (unsigned int, CCmdUI *, void *);
	//    BOOL    _OnMouseMove       (UINT, tdstMousePos *, void *);
	//    BOOL    _OnLButtonDblClk	 (UINT, tdstMousePos *, ACP_tdxIndex, void *);
	//    BOOL    _OnLButtonDown     (UINT, tdstMousePos *, ACP_tdxIndex, void *);
	//    BOOL    _OnLButtonUp		 (UINT, tdstMousePos *, void *);
	//    BOOL    _OnRButtonDblClk	 (UINT, tdstMousePos *, ACP_tdxIndex, void *);
	//    BOOL    _OnRButtonDown     (UINT, tdstMousePos *, ACP_tdxIndex, void *);
	//    BOOL    _OnRButtonUp		 (UINT, tdstMousePos *, void *);
	//    BOOL	  _OnDragDropEnd	 (WPARAM, LPARAM);
	//	  BOOL	  _OnDragDropMove(WPARAM, LPARAM);
	//    BOOL	  _OnDragDropLooseFocus(WPARAM, LPARAM);
	//    BOOL    _OnDragDropGainFocus(WPARAM, LPARAM);
	
	// SHAITAN -> Editor Messages Functions overload
	//	BOOL fn_bAcceptAsParent (CPA_BaseObject *pChild, CPA_BaseObject *pParent) { return TRUE; }
	//	BOOL fn_bAcceptAsChild (CPA_BaseObject *pParent, CPA_BaseObject *pChild) { return TRUE; }
	BOOL fn_bAcceptModifDelete		(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
	//	BOOL fn_bAcceptModifParent	(CPA_List<CPA_SuperObject> *pListObjects)  { return TRUE; }
	//	BOOL fn_bAcceptModifCopy	(CPA_List<CPA_SuperObject> *pListObjects)  { return TRUE; }
	//	BOOL fn_bAcceptModifMove	(CPA_List<CPA_SuperObject> *pListObjects)  { return TRUE; }
	//	BOOL fn_bAcceptModifInsert	(CPA_SuperObject *pEdObj, CPA_SuperObject *pParent) { return TRUE; }
	//	BOOL fn_bAcceptModifName	(CPA_SuperObject *pEdObj) { return TRUE; }
	//  BOOL fn_bAcceptSelect       (CPA_SuperObject *pEdObj) { return TRUE; }
	//	void fn_vOnModifDelete	(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType) { }
	//	void fn_vOnModifParent	(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType) { }
	//	void fn_vOnModifCopy	(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType) { }
	//	void fn_vOnModifMove	(CPA_List<EDT_SavePos> *pListObjects, tdeTypeModif eType)	 { }
	//	void fn_vOnModifInsert	(CPA_SuperObject *pEdObj, CPA_SuperObject *pParent, tdeTypeModif eType) { }
	//	void fn_vOnModifName	(CPA_SuperObject *pEdObj, char *szInitalName, char *szFinalName, tdeTypeModif eType) { }
//	void fn_vOnSelect (CPA_SuperObject *pEdObj, tdeTypeModif eType, tdeStatus eStatus); 
	
	// ObjectDLL special functions overload
	//	CPA_BaseObject *GetNewObject (char *p_cObjectFile, char*p_cObjectName, FILE *p_fFile);
	BOOL fn_bDefinePopupMenu(EDT_PopUpMenu *pPopup, CPA_List<CPA_SuperObject> *pSelection, BOOL bIsAlone);
	void _OnPopUpMenuCommand(UINT m_IDCmdMsg);
	
	ACP_tdxHandleOfObject fn_hGetBoundingVolume(CPA_BaseObject *pObject);
	void fn_vComputeBoundingVolume(CPA_BaseObject *pObject);


	void SendDialogBarCommandToCamera(CPA_BaseObject *p_oCamera,UINT nID);
	//=========================================================================================
	//=========================================================================================
	//=========================================================================================
	//=========================================================================================
	//=========================================================================================
	void Activate(CPA_BaseObject *_p_oCamera, DEV_ViewPort3D *p_oViewPort, CPA_DialogBar *p_oPopUpParent, CPoint oPos);
	void Disactivate(CPA_BaseObject *_p_oCamera);
	
	void SetRotationAxisSystem(CPA_BaseObject *p_oCamera, tdeAxisSystem eSystem);
	void SetTranslationAxisSystem(CPA_BaseObject *p_oCamera, tdeAxisSystem eSystem);
	
	tdeAxisSystem GetRotationAxisSystem(CPA_BaseObject *p_oCamera);
	tdeAxisSystem GetTranslationAxisSystem(CPA_BaseObject *p_oCamera);
	
	BOOL SetRotationCenterType(CPA_BaseObject *p_oCamera, tdeRotationCenterType eRotCenterType);
	tdeRotationCenterType GetRotationCenterType(CPA_BaseObject *p_oCamera);
	tdeRotationCenterType GetEffectiveRotationCenterType(CPA_BaseObject *p_oCamera);
	
	BOOL SetTargetType(CPA_BaseObject *p_oCamera, tdeTargetType eTargetType);
	tdeTargetType GetTargetType(CPA_BaseObject *p_oCamera);
	
	BOOL ZoomOnTarget (CPA_BaseObject *p_oCamera, CPA_SuperObject *pTarget);

	void SetRotationCenterPoint(CPA_BaseObject *p_oCamera, CPA_CameraCoords *p_oRotationCenter, tdeCoordsType eType = Absolute);
	BOOL SetRotationCenterSuperObject(CPA_BaseObject *p_oCamera, CPA_SuperObject *p_oSuperObject);
	BOOL GetRotationCenter(CPA_BaseObject *p_oCamera, MTH3D_tdstVector &r_stCenter);
	
	void SetTargetPoint(CPA_BaseObject *p_oCamera, CPA_CameraCoords *p_oRotationCenter);
	BOOL SetTargetSuperObject(CPA_BaseObject *p_oCamera, CPA_SuperObject *p_oSuperObject);
	BOOL GetTarget(CPA_BaseObject *p_oCamera, MTH3D_tdstVector &r_stTarget);
	
	
	void Translate(CPA_BaseObject *p_oCamera, CPA_CameraCoords *p_oOffset, BOOL bUserDefinedAxis = FALSE);
	void SetPosition(CPA_BaseObject *p_oCamera, CPA_CameraCoords *p_oPos = NULL);
	
	void Rotate(CPA_BaseObject *p_oCamera, tdeAxis eAxis, double dAngle);
	void SetRotation(CPA_BaseObject *p_oCamera, double dAngleX = 0, double dAngleY = 0, double dAngleZ = 0);
	
	void Update(CPA_BaseObject *p_oCamera);
	CPA_SuperObject *CreateDefaultCamera();
	void InsertCameraInHierarchy(CPA_SuperObject *p_oCameraSO);
	void ShowDialogBar(CPA_BaseObject *p_oCamera);
	void HideDialogBar(CPA_BaseObject *p_oCamera);

	CPA_BaseObject	*CopySlotCamera(CPA_BaseObject* p_oCamera);		
	void		PutCameraInViewPort(CPA_BaseObject *_p_oCamera,DEV_ViewPort3D *p_oViewPort, BOOL bWithPrevCam = TRUE);

	void GetMatrix(CPA_BaseObject *_p_oCamera, POS_tdstCompletePosition *p_oMatrix);
	void SetMatrix(CPA_BaseObject *_p_oCamera, POS_tdstCompletePosition *p_oMatrix);


// camera - viewport communication specific functions
	
	BOOL SendKeyDownToCamera		(CPA_BaseObject *p_oCamera, UINT nChar, UINT nRepCnt, UINT nFlags);
//	BOOL SendKeyUpToCamera			(CPA_BaseObject *p_oCamera, UINT nChar, UINT nRepCnt, UINT nFlags);
//	BOOL SendMouseMoveToCamera		(CPA_BaseObject *p_oCamera, UINT nFlags, tdstMousePos *p_stPos, MTH3D_tdstVector *p_stVect);
//	BOOL SendLButtonDblClkToCamera	(CPA_BaseObject *p_oCamera, UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo);
//	BOOL SendRButtonDblClkToCamera	(CPA_BaseObject *p_oCamera, UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo);
// CPA_Ed_1 MP BEGIN - enabled mouse functions
	BOOL SendMouseMoveToCamera		(CPA_BaseObject *p_oCamera, UINT nFlags, tdstMousePos *p_stPos, MTH3D_tdstVector *p_stVect);
	BOOL SendLButtonDownToCamera	(CPA_BaseObject *p_oCamera, UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo);
	BOOL SendRButtonDownToCamera	(CPA_BaseObject *p_oCamera, UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo);
	BOOL SendLButtonUpToCamera		(CPA_BaseObject *p_oCamera, UINT nFlags, tdstMousePos *p_stPos);
	BOOL SendRButtonUpToCamera		(CPA_BaseObject *p_oCamera, UINT nFlags, tdstMousePos *p_stPos);
// CPA_Ed_1 MP END
	void DestroyCamera				(CPA_SuperObject *p_oCameraSO);
	BOOL OnToolTipNotify			(CPA_BaseObject *_p_oCamera, TOOLTIPTEXT *p_TTT, UINT nID);
	
	void CameraToWorldCoordinates_Point(CPA_BaseObject *_p_oCamera, MTH3D_tdstVector &r_stVector);
	void CameraToWorldCoordinates_Vector(CPA_BaseObject *_p_oCamera, MTH3D_tdstVector &r_stVector);
	void WorldToCameraCoordinates_Point(CPA_BaseObject *_p_oCamera, MTH3D_tdstVector &r_stVector);
	void WorldToCameraCoordinates_Vector(CPA_BaseObject *_p_oCamera, MTH3D_tdstVector &r_stVector);

// ANNECY MT NewInterface 26/03/98 {
	void SetReferentialDisplayMode	(tdeDisplayReferential eDisplayMode);
	tdeDisplayReferential GetReferentialDisplayMode	();
// ENDANNECY MT NewInterface }

//CPA2 Corneliu Babiuc 04-05-98
//functions to store and restore camera positions from slots
	void        SaveSlotsPositions();
	void        LoadSlotsPositions(CPA_BaseObject * p_oCamera);
//CPA2 Corneliu Babiuc 04-05-98

private:
	BOOL KeyOtherActions(Camera *p_oCamera, UINT nChar);
	BOOL KeyMoveCamera(Camera *p_oCamera, UINT nChar, BOOL bRepeat = FALSE);
	BOOL KeyRotateCamera(Camera *p_oCamera, UINT nChar, BOOL bRepeat = FALSE);
	BOOL KeyViewCamera(Camera *p_oCamera, UINT nChar);
	void InitKeyboard();
	CPA_SuperObject *CreateInertCamera(GLI_tdxHandleToCamera hObj = NULL,CString csName = "",
										CString csFileName = "",CString csSectionName = "");

// CPA_Ed_1 MP BEGIN
	void UpdatePosition( Camera *p_oCamera,tdstMousePos *p_stPos );
	BOOL MouseRotateCamera( Camera *p_oCamera, tdstMousePos *p_stPos ); // MIRCEA
	BOOL MouseMoveCamera( Camera *p_oCamera, tdstMousePos *p_stPos );  // MIRCEA
// CPA_Ed_1 MP END

	BOOL fn_bAddEntriesToTreePopup	(CPA_DialogList *pDialog, CString csListName, CMenu *pMenu, UINT uiCustomEntriesStart);
	BOOL fn_bAddEntriesToListPopup	(CPA_DialogList *pDialog, CString csListName, CMenu *pMenu, UINT uiCustomEntriesStart);
	void fn_vOnCommandInTreePopup	(CPA_DialogList *pDialog, CString csListName, UINT uiCustomEntry);
	void fn_vOnCommandInListPopup	(CPA_DialogList *pDialog, CString csListName, UINT uiCustomEntry);

	void	ChangeCameraTarget		(void);
};

extern tdstDLLIdentity g_stCameraIdentity;


#endif // __MYINTERF_HPP__