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

/************************************************************************
 ¶þÎ¬Ö±ÏßÀà
************************************************************************/
C2DBeeLine::C2DBeeLine( CPoint& ptS, CPoint& ptE )
{
	m_ptStart = ptS;
	m_ptEnd   = ptE;
 	m_byR = g_2DObj.m_byR[0];
 	m_byG = g_2DObj.m_byG[0];
 	m_byB = g_2DObj.m_byB[0];
	m_byLineStyle = g_2DObj.m_byLineStyle[0];
	m_wLineWidth  = g_2DObj.m_wLineWidth[0];
}

C2DBeeLine::C2DBeeLine()
{
	m_ptStart = CPoint(0, 0); 
	m_ptEnd   = CPoint(0, 0);
	m_byR = g_2DObj.m_byR[0];
	m_byG = g_2DObj.m_byG[0];
	m_byB = g_2DObj.m_byB[0];
	m_byLineStyle = g_2DObj.m_byLineStyle[0];
	m_wLineWidth  = g_2DObj.m_wLineWidth[0];
}

C2DBeeLine::~C2DBeeLine()
{

}

void C2DBeeLine::Serialize( CFile* pFile, BOOL bSave /*= TRUE*/ )
{
	if (bSave)
	{
		C2DLine::Serialize(pFile,bSave);
		pFile->Write(&m_ptStart,sizeof(CPoint));
		pFile->Write(&m_ptEnd,sizeof(CPoint));
	} 
	else
	{
		C2DLine::Serialize(pFile,bSave);
		pFile->Read(&m_ptStart,sizeof(CPoint));
		pFile->Read(&m_ptEnd,sizeof(CPoint));
	}
}

void C2DBeeLine::Draw( CDC* pDC )
{
	CPen pen(m_byLineStyle,m_wLineWidth,GetClrRefFromByte(m_byR,m_byG,m_byB));
	CPen* pOldPen = pDC->SelectObject(&pen);
	pDC->MoveTo(m_ptStart);
	pDC->LineTo(m_ptEnd);
	pDC->SelectObject(pOldPen);
}

UINT C2DBeeLine::GetClass()
{
	return CLASS_DRAW_BEELINE;
}

void C2DBeeLine::GetPoint( int& x1,int& y1,int& x2,int& y2 )
{
	x1 = m_ptStart.x;
	y1 = m_ptStart.y;
	x2 = m_ptEnd.x;
	y2 = m_ptEnd.y;
}