#include "stdafx.h"
#include "2DObject.h"


/************************************************************************
 ¶þÎ¬µãÀà 
************************************************************************/
C2DPoint::C2DPoint(CPoint& pt)
{
	//m_fRadius = 0.5f;
    m_Position = pt;
	m_byR = g_2DObj.m_byR[5];
	m_byG = g_2DObj.m_byG[5];
	m_byB = g_2DObj.m_byB[5];
}

C2DPoint::C2DPoint()
{
	m_Position = CPoint(0, 0);
}

C2DPoint::~C2DPoint()
{

}

void C2DPoint::Serialize( CFile* pFile, BOOL bSave /*= TRUE*/ )
{
	if (bSave)
	{
		C2DAtom::Serialize(pFile,bSave);
		//pFile->Write(&m_fRadius,sizeof(float));
		pFile->Write(&m_byR,sizeof(BYTE));
		pFile->Write(&m_byG,sizeof(BYTE));
		pFile->Write(&m_byB,sizeof(BYTE));
		pFile->Write(&m_Position,sizeof(CPoint));
// 		UINT wEnd = 0;
// 		pFile->Write(&wEnd,sizeof(UINT));
	}
	else
	{
		C2DAtom::Serialize(pFile,bSave);
		//pFile->Read(&m_fRadius,sizeof(float));
		pFile->Read(&m_byR,sizeof(BYTE));
		pFile->Read(&m_byG,sizeof(BYTE));
		pFile->Read(&m_byB,sizeof(BYTE));
		pFile->Read(&m_Position,sizeof(CPoint));
// 		UINT wEnd = 0;
// 		pFile->Read(&wEnd,sizeof(UINT));
	}
}

void C2DPoint::Draw(CDC* pDC)
{
	//pDC->SetPixel(m_Position.x, m_Position.y,(COLORREF)GetClrRefFromByte(m_byR,m_byG,m_byB));
    COLORREF clr = GetClrRefFromByte(m_byR,m_byG,m_byB);
	CPen pen(PS_SOLID, 0, clr);
	CBrush br(clr);
	CPen* pOldPen  = pDC->SelectObject(&pen);
	CBrush* pOldBs = pDC->SelectObject(&br);
	pDC->Ellipse(m_Position.x-2,m_Position.y-2,m_Position.x+2,m_Position.y+2);
	pDC->SelectObject(pOldPen);
	pDC->SelectObject(pOldBs);
}

UINT C2DPoint::GetClass()
{
	return CLASS_DRAW_POINT;
}

void C2DPoint::GetPoint(int& x,int& y)
{
	x = m_Position.x;
	y = m_Position.y;
}