// CamInfoTab.cpp : implementation file
//

#include "stdafx.h"
#include "TCTb.h"
#include "CamInfoTab.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCamInfoTab property page

IMPLEMENT_DYNCREATE(CCamInfoTab, CPropertyPage)

CCamInfoTab::CCamInfoTab() : CCamInfoPage(CCamInfoTab::IDD)
{
	//{{AFX_DATA_INIT(CCamInfoTab)
	m_CamLocX = 0.0f;
	m_CamLocY = 0.0f;
	m_CamLocZ = 0.0f;
	m_CamTrkAlt = 0.0f;
	//}}AFX_DATA_INIT
}

CCamInfoTab::~CCamInfoTab()
{
}

void CCamInfoTab::DoDataExchange(CDataExchange* pDX)
{
	CCamInfoPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCamInfoTab)
	DDX_Control(pDX, IDC_CAMTALT, m_CTAlt);
	DDX_Text(pDX, IDC_CAMLOCX, m_CamLocX);
	DDX_Text(pDX, IDC_CAMLOCY, m_CamLocY);
	DDX_Text(pDX, IDC_CAMLOCZ, m_CamLocZ);
	DDX_Text(pDX, IDC_CAMTALT, m_CamTrkAlt);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CCamInfoTab, CCamInfoPage)
	//{{AFX_MSG_MAP(CCamInfoTab)
	ON_EN_CHANGE(IDC_CAMLOCX, OnChangeCamlocx)
	ON_EN_CHANGE(IDC_CAMLOCY, OnChangeCamlocy)
	ON_EN_CHANGE(IDC_CAMLOCZ, OnChangeCamlocz)
	ON_BN_CLICKED(IDC_CLOCTT, OnCloctt)
	ON_BN_CLICKED(IDC_FREE, OnFree)
	ON_BN_CLICKED(IDC_TRACK, OnTrack)
	ON_EN_CHANGE(IDC_CAMTALT, OnChangeCamtalt)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCamInfoTab message handlers

void CCamInfoTab::DataIn()
{
m_CamLocX=CamInfo->Loc.x;
m_CamLocY=CamInfo->Loc.y;
m_CamLocZ=CamInfo->Loc.z;
m_CamTrkAlt=CamInfo->CamTrackAlt;
CheckDlgButton(IDC_CLOCTT,CamInfo->CamATrkFlg);
}

void CCamInfoTab::DataOut()
{
CamInfo->Loc.x=m_CamLocX;
CamInfo->Loc.y=m_CamLocY;
CamInfo->Loc.z=m_CamLocZ;
CamInfo->CamTrackAlt=m_CamTrkAlt;
}

void CCamInfoTab::UpdateControlStates()
{
m_CTAlt.EnableWindow(IsDlgButtonChecked(IDC_CLOCTT));
CheckRadioButton(IDC_FREE,IDC_TRACK,CamInfo->GetMode()==CameraInfo::CM_TRACK?IDC_TRACK:IDC_FREE);
}

void CCamInfoTab::OnChangeCamlocx() 
{
DelayedValidate();
CamInfo->SetMode(CameraInfo::CM_FREE);
}

void CCamInfoTab::OnChangeCamlocy() 
{
DelayedValidate();
CamInfo->CamATrkFlg=false;
CheckDlgButton(IDC_CLOCTT,FALSE);
UpdateControlStates();
}

void CCamInfoTab::OnChangeCamlocz() 
{
DelayedValidate();
CamInfo->SetMode(CameraInfo::CM_FREE);
}

void CCamInfoTab::OnCloctt() 
{
UpdateControlStates();
CamInfo->CamATrkFlg=IsDlgButtonChecked(IDC_CLOCTT)?true:false;
}

void CCamInfoTab::OnFree() 
{
CamInfo->SetMode(CameraInfo::CM_FREE);
}

void CCamInfoTab::OnTrack() 
{
CamInfo->SetMode(CameraInfo::CM_TRACK);
}

void CCamInfoTab::OnChangeCamtalt() 
{
DelayedValidate();
}
