#if !defined(AFX_JOINTEDITDIALOG_H__8D9FD983_FEC9_11D1_854E_00A0C9B4E907__INCLUDED_)
#define AFX_JOINTEDITDIALOG_H__8D9FD983_FEC9_11D1_854E_00A0C9B4E907__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// JointEditDialog.h : header file
//

class JointEditDialog;

#include "AnimationSuite.h"

#define TIME_TO_FRAME(time, frame) \
		if (GetTicksPerFrame() != 0 || time != 0) \
		{ \
			frame = (int)((float)time / (float)GetTicksPerFrame()); \
		} \
			else \
		{ \
			frame = 0; \
		} 


/////////////////////////////////////////////////////////////////////////////
// JointEditDialog dialog

#define  JOINTPREFS_SAVE_CLASS_ID Class_ID(0xe835e35, 0x7e1e3fd1)
#define	 JOINT_SAVE_SUPER_CLASS_ID    UTILITY_CLASS_ID
#define	 TEMP_DATA_ID 1
#define  PERM_DATA_ID 0

struct JointPreference
{

public:

	bool m_forceExclude;
	int m_excludeJoint;
	
	enum {
		ExcludeJoint = 0,
		IncludeJoint,
		AutoJoint
	};

	bool m_decodeWithVelocity;
	
	enum {
		LinearKeyframeType,EulerXYZKeyframeType,PositionXYZKeyframeType
	};

	
	bool m_forceConvertRotation;
	bool m_convertRotationJoint;
	int m_rotationConvertType;

	
	bool m_forceConvertTranslation;
	bool m_convertTranslationJoint;
	int m_translationConvertType;

	bool m_optimizeRotation;
	Stuff::Radian m_rotationThreshold;

	bool m_rotationRange;
	int m_rotationSampleStartFrame;
	int m_rotationSampleEndFrame;

	bool m_optimizeTranslation;
	Stuff::Scalar m_translationThreshold;
	bool m_translationRange;
	int m_translationSampleStartFrame;
	int m_translationSampleEndFrame;
};



class JointEditDialog : public CDialog
{
// Construction
public:
	JointEditDialog(INode *root_node, Interface *ip, CWnd* pParent = NULL);   // standard constructor

    static void DeleteAllJointPrefrence(INode* node);
	static int CountChildren(INode *node);
	static JointPreference * GetJointPrefrence(INode* node);
	static void CopyJointPrefrence(INode* source_node, INode* target_node);

	void AddJointPreference(INode* node);
	void CountNodes(INode* node, int& node_count);
	bool NodeAnimated(INode* node);

// Dialog Data
	//{{AFX_DATA(JointEditDialog)
	enum { IDD = IDD_JOINT_EDIT };
	CComboBox	m_tranConvertCombo;
	CComboBox	m_rotConvertCombo;
	CComboBox	m_includeCombo;
	BOOL	m_rotOptCheck;
	BOOL	m_tranOptCheck;
	BOOL	m_rotRangeCheck;
	BOOL	m_tranRangeCheck;
	BOOL	m_encodeVelocityCheck;
	float	m_rotThresholdEdit;
	float	m_tranThresholdEdit;
	int		m_rotMaxRange;
	int		m_rotMinRange;
	int		m_tranMaxRange;
	int		m_tranMinRange;
	BOOL	m_rotConvertCheck;
	BOOL	m_tranConvertCheck;
	//}}AFX_DATA
	
protected:
	bool m_forceExclude;
	bool m_forceConvertRotation;
	bool m_forceConvertTranslation;

	Interface *m_max_interface;
	INode *m_rootNode;
	bool m_firstDataSave;

private:
	HTREEITEM AddToTree(CTreeCtrl *tree, INode *node, HTREEITEM parent);
	void LoadPrefs(INode* node, JointPreference *prefs);
	bool NodeIsRoot(INode* node);
	bool KnownNode(INode* node);
	bool HasKnownControler(INode *node);
	bool IsKnownControlerType(Control *c);

	void ClearControls();
	void SaveControls(JointPreference *j_pref);
	void InitControls(JointPreference *j_pref);


	void AcceptTempData(INode *node);
	void CancelTempData(INode *node);



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

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(JointEditDialog)
	virtual BOOL OnInitDialog();
	virtual void OnOK();
	virtual void OnCancel();
	afx_msg void OnRevertJoint();
	afx_msg void OnSelchangedNodeTree(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnCheckRotOpt();
	afx_msg void OnConvertRotCheck();
	afx_msg void OnCheckRotRange();
	afx_msg void OnConvertTranCheck();
	afx_msg void OnCheckTranOpt();
	afx_msg void OnCheckTranRange();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_JOINTEDITDIALOG_H__8D9FD983_FEC9_11D1_854E_00A0C9B4E907__INCLUDED_)
