// Camera.cpp: implementation of the CCamera class.
//
//////////////////////////////////////////////////////////////////////



/** \file Camera.cpp
	\brief implementace třídy CCamera
*/

#include "stdafx.h"
#include "Camera.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

IMPLEMENT_DYNAMIC(CCamera, CObject)

//defaultni konstruktor
CCamera::CCamera()
{
	TRACE("Entering CCamera default constructor\n");

	//m_focus = 0;
	//m_distanceToO = 0;
	Rotation[0]=Rotation[1]=Rotation[2]=0;
	ProjectionCenter[0]=ProjectionCenter[1]=ProjectionCenter[2]=0;
	CameraConstant = 0;
	m_xSize = 0;
	m_ySize = 0;
	m_imageCenter.X = 0;
	m_imageCenter.Y = 0;
	m_isReady = false;
	pixel_xmm = pixel_ymm = 1;
}

CCamera::CCamera(int xSize, int ySize, double m_distanceToO )
{
	TRACE("Entering CCamera parameter constructor\n");

	//m_focus = focus;
	//m_distanceToO = m_distanceToO;
	Rotation[0]=Rotation[1]=Rotation[2]=0;
	ProjectionCenter[0]=ProjectionCenter[1]=ProjectionCenter[2]=0;
	CameraConstant = m_distanceToO;
	m_xSize = xSize;
	m_ySize = ySize;
	m_imageCenter.X = (float)xSize / 2;
	m_imageCenter.Y = (float)ySize / 2;
	m_isReady = true;
	pixel_xmm = pixel_ymm = 1;
}

//defaultni destruktor
CCamera::~CCamera()
{
	
	#ifdef _DEBUG
		Dump(afxDump);
	#endif // _DEBUG

	TRACE("-- leaving  CCamera destructor --\n");
}

//////////////////////////////////////////////////////////////
//Funkce SET

void CCamera::SetSize(int xSize, int ySize)
{
	m_xSize = xSize;
	m_ySize = ySize;
	m_imageCenter.X = (float)xSize / 2;
	m_imageCenter.Y = (float)ySize / 2;
}


//////////////////////////////////////////////////////////////
//Funkce GET

CStructures::iPoint CCamera::GetSize()
{
	CStructures::iPoint size;

	size.X = m_xSize;
	size.Y = m_ySize;

	return size;
}

CStructures::fPoint CCamera::GetCenter()
{
	return m_imageCenter;
}


CCamera& CCamera:: operator = (CCamera const & cam)
{
	CameraConstant = cam.CameraConstant;
	m_imageCenter = cam.m_imageCenter;
	m_isReady = cam.m_isReady;
	m_xSize  = cam.m_xSize;
	m_ySize = cam.m_ySize;
	ProjectionCenter[0] = cam.ProjectionCenter[0];
	ProjectionCenter[1] = cam.ProjectionCenter[1];ProjectionCenter[2] = cam.ProjectionCenter[2];
	Rotation[0]=cam.Rotation [0];Rotation[1]=cam.Rotation [1];Rotation[2]=cam.Rotation [2];
	pixel_xmm = cam.pixel_xmm; pixel_ymm = cam.pixel_ymm;
	CameraConstant = cam.CameraConstant;
	return * this;
}


#ifdef _DEBUG
void CCamera::Dump(CDumpContext& dc) const
	{
		CObject::Dump(dc);

		dc << "CC" << CameraConstant <<"X = " << ProjectionCenter[0]<< "Y = " << ProjectionCenter[1]<< "Z = " << ProjectionCenter[2]  << "  m_xSize =" << m_xSize << "  m_ySize = " << m_ySize << "\n";
	}
#endif // _DEBUG
