// MiscCamProp.cpp : implementation file
//

#include "stdafx.h"
#include "TCTb.h"
#include "MiscCamProp.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMiscCamProp property page

IMPLEMENT_DYNCREATE(CMiscCamProp, CPropertyPage)

CMiscCamProp::CMiscCamProp() : CCamInfoPage(CMiscCamProp::IDD)
{
	//{{AFX_DATA_INIT(CMiscCamProp)
	m_FOVSli = 0;
	m_FarClip = 0.0f;
	m_NearClip = 0.0f;
	m_FOV = 0;
	//}}AFX_DATA_INIT
}

CMiscCamProp::~CMiscCamProp()
{
}

void CMiscCamProp::DoDataExchange(CDataExchange* pDX)
{
	CCamInfoPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMiscCamProp)
	DDX_Control(pDX, IDC_FOVTEXT, m_FOVText);
	DDX_Control(pDX, IDC_FOVSLI, m_FOVSliCtrl);
	DDX_Slider(pDX, IDC_FOVSLI, m_FOVSli);
	DDX_Text(pDX, IDC_FARCLIP, m_FarClip);
	DDX_Text(pDX, IDC_NEARCLIP, m_NearClip);
	DDX_Text(pDX, IDC_FOVTEXT, m_FOV);
	DDV_MinMaxInt(pDX, m_FOV, 1, 180);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMiscCamProp, CCamInfoPage)
	//{{AFX_MSG_MAP(CMiscCamProp)
	ON_WM_HSCROLL()
	ON_EN_CHANGE(IDC_FARCLIP, OnChangeFarclip)
	ON_EN_CHANGE(IDC_NEARCLIP, OnChangeNearclip)
	ON_EN_CHANGE(IDC_FOVTEXT, OnChangeFovtext)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMiscCamProp message handlers
void CMiscCamProp::DataIn()
{
m_FOVSliCtrl.SetRange(1,180);
m_NearClip=CamInfo->NearClip;
m_FarClip=CamInfo->FarClip;
m_FOV=(int)(CamInfo->FOV*Degrees_Per_Radian);
m_FOVSli=(int)(CamInfo->FOV*Degrees_Per_Radian);

}

void CMiscCamProp::DataOut()
{
if(m_FarClip<m_NearClip)  m_FarClip=m_NearClip;

CamInfo->FOV=m_FOV*Radians_Per_Degree;
CamInfo->NearClip=m_NearClip;
CamInfo->FarClip=m_FarClip;
}

void CMiscCamProp::UpdateControlStates()
{
}

void CMiscCamProp::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
CString tstr;

	if(pScrollBar==(CScrollBar* )&m_FOVSliCtrl)
	{
	tstr.Format("%i",m_FOVSliCtrl.GetPos(),0xF8);
	m_FOVText.SetWindowText(tstr);
	CamInfo->FOV=m_FOVSliCtrl.GetPos()*Radians_Per_Degree;
	m_FOV=m_FOVSliCtrl.GetPos();
	}

	CCamInfoPage::OnHScroll(nSBCode, nPos, pScrollBar);
}

void CMiscCamProp::OnChangeFarclip() 
{
DelayedValidate();
}

void CMiscCamProp::OnChangeNearclip() 
{
DelayedValidate();
}

void CMiscCamProp::OnChangeFovtext() 
{
DelayedValidate();
}
