#pragma once

#include "DxfLib\dl_attributes.h"
#include "DxfLib\dl_entities.h"

class DL_WriterA;
class DL_Dxf;
class MxReadFilter;

class MxReadContext;
class MxWriteContext;


class MxOptEntity
{
public:
	MxOptEntity(MxWriteContext* pWriteContext);
	MxOptEntity(MxReadContext* pReadContext);

	virtual ~MxOptEntity(void);

	bool Mx2Dxf(McDbObjectId entId,DL_WriterA* dw);

	McDbObjectId ReadLine(const DL_LineData& data);

	McDbObjectId ReadPoint(const DL_PointData& data);

	McDbObjectId ReadArc(const DL_ArcData& data);

	McDbObjectId ReadEllipse(const DL_EllipseData& data);

	McDbObjectId ReadPolyline(const DL_PolylineData& data);

	void ReadVertex(const DL_VertexData& data);

	McDbObjectId ReadText(const DL_TextData& data);

	McDbObjectId ReadInsert(const DL_InsertData& data);

	McDbObjectId ReadCircle(const DL_CircleData& data);
protected:
	DL_Attributes GetEntityAttributes(McDbEntity* pEntity);


	McDbObjectId  SetEntityAttributes(McDbEntity* pEntity,
		const DL_Attributes& attrib,
		McDbBlockTableRecord* pBlkRecord
		) ;

	void WriteLine(DL_WriterA& dw, 
		McDbLine* pLine,
		const DL_Attributes& attrib);

	void WritePoint(DL_WriterA& dw, 
		McDbPoint* pPoint,
		const DL_Attributes& attrib
		);

	void WriteArc(DL_WriterA& dw, 
		McDbArc* pArc, 
		const DL_Attributes& attrib);

	void WriteEllipse(DL_WriterA& dw, 
		McDbEllipse* pEllipse, 
		const DL_Attributes& attrib);

	void WritePolyline(DL_WriterA& dw, 
		McDbPolyline* pPolyline, 
		const DL_Attributes& attrib);

	
	void WriteText(DL_WriterA& dw, 
		McDbText* pText, 
		const DL_Attributes& attrib
		);

	void WriteInsert(DL_WriterA& dw, 
		McDbBlockReference* pRef,
		const DL_Attributes& attrib
		);

	void WriteCircle(DL_WriterA& dw, McDbCircle* pCircle,
		const DL_Attributes& attrib);


	void WriteHatch(DL_WriterA& dw, 
		McDbHatch* pHatch,
		const DL_Attributes& attrib);
private:
	MxWriteContext* m_pWriteContext;
	DL_Dxf*         m_pDxf;
	MxReadContext*  m_pReadContext;

	McDbObjectId    m_curPolyline;
};
