#ifndef _dm_h
#define _dm_h
////////////// Lg 01-7-7从sym_dosf.h移来
#include <fstream.h>
/////////////////
//1: 点       2:  线    4:  圆    8:  弧      16:  尺寸  32:  TEXT
//64:polyline 128:块,   256:HATCH 
//512:零件标号1024:图框  2048:标题栏
//4096:明细表 
//8192:SOLID 
//16384:PATH
//32768:CELL
//65536:GROUP
//131072:COLUMN
//262144:TABLE

//-1:表示不进行过滤

#define CCOLOR		0
#define CLTYPE		1
#define CLAYER		2
#define CUCS		3

#define MAXLAYERNUM	    100
#define MAXLAYERNUMEXT	120
#define MAXLTYPENUM	    200
#define MAXCOLORNUM	    64

#define CBASE		0
#define CPOT		1
#define CLINE		2
#define CCIRCLE		3
#define CARC		4
#define CDIMENSION	5
#define CTEXT		6
#define CPOLYLINE	7
#define CBLOCK		8
#define CHATCH		9
#define CPART		10
#define CFRAME		11
#define CHEADER		12
#define CBOM		13
#define CSOLID		14
#define CELLIPSE	15
#define CSPLINE 	16
#define COFFSET		17
#define CGROUP		18
#define CBOMTABLE	19
#define CTABLECELL	20
#define CCELL		28
#define CCOLUMN		29
#define CTABLE		30
#define CCARDCELL	31
#define CCARD    	32
#define CSTYLEUNDO  127// Lg 2004-5-28 add 风格Undo类

#define PROCESS_CARD             128
#define WORKINGPROCEDURE_CARD    129

#define LAST_RECORD             -1

#define CAXA_EB_PRODUCT       0
#define CAXA_CAPP_PRODUCT     1

#define CAXA_CHAR                  0
#define CAXA_INT                   1
#define CAXA_DOUBLE                2
#define CAXA_DATETIME              3
#define CAXA_CURRENCY              4

#define NURBS 1    //曲线为NURBS
#define BSPLINE 0  //曲线为非有理B样条

#define NOPLANE 0   //曲线为非平面曲线;
#define ISPLANE 1   //曲线为平面曲线

#define NOBREAK 0       //没有断点
#define BREAK 1         //有断点


#include "afxtempl.h"
#include "varext.h"
#include "ebdef.h"

/*
//可供外部使用的全局指针变量
extern unsigned char DmCurLayer;
extern unsigned char DmCurLtype;
extern unsigned char DmCurColor;
extern unsigned char DmGndColor;
extern int	     DmPickColor;
extern BOOL	     DmSetXOR;
*/

//*******************************************************************
//系统基本数据结构定义***********************************************
//*******************************************************************




typedef struct xy {
			   double x;
			   double y;
		   } XY,*PXY,**PPXY;
#define SIZEXY  sizeof(XY)

typedef struct xyz {
			   double x;
			   double y;
			   double z;
			   } XYZ,*PXYZ,**PPXYZ;
#define SIZEXYZ  sizeof(XYZ)

typedef struct xyzw {
			   double x;
			   double y;
			   double z;
			   double w;
			   } XYZW,*PXYZW,**PPXYZW;
#define SIZEXYZW  sizeof(XYZW)

typedef struct box {
			   double xmin,ymin;
			   double xmax,ymax;
			   } BOX,*PBOX;
#define SIZEBOX  sizeof(BOX)


//*******************************************************************
//系统状态变量结构定义***********************************************
//*******************************************************************

typedef struct _dmparameter
{
	//pickMmask=1|2|4|8|16...
	//1: 点       2:  线    4:  圆    8:  弧      16:  尺寸  32:  TEXT
	//64:polyline 128:块,   256:HATCH 512:零件标号1024:图框  2048:标题栏
	//4096:明细表 8192:SOLID 65536:GROUP
	//-1:表不进行过滤
	double	pickValve;		//拾取判断的阀值
	double	winWidth,winHeight;
}DMPARAMETER;


//*******************************************************************
//系统属性节点的定义*************************************************
//*******************************************************************
class AFX_EXT_CLASS CSystemInfo : public CObject
{
	DECLARE_SERIAL(CSystemInfo)
public:
	CString		verInfo;
	LONG		version;
	int		open_or_edit;  //0==>open, 1==>edit, 2==>both
	char		openExbFilePwd[10];
	char		editExbFilePwd[10];
	CString 	attrib;
	int		attCount;
	int		entCount;
public:
	CSystemInfo();
	virtual void Serialize(CArchive& ar);
};



class AFX_EXT_CLASS CAttribute : public CObject
{
	DECLARE_SERIAL(CAttribute)
public:
	unsigned char attType;
public:
	CAttribute();
	virtual void Serialize(CArchive& ar);
};



class AFX_EXT_CLASS CUcs : public CAttribute
{
	DECLARE_SERIAL(CUcs)
public:
	XYZ		origin;
	double		angle;
	double		off_x;
	double		off_y;
public:
	CUcs();
	virtual ~CUcs();// Lg 2002-4-8 add for symapp error lnk2005
	CUcs(XYZ &p,double ang);
	virtual void Serialize(CArchive& ar);
};



class AFX_EXT_CLASS CColor : public CObject
{
	DECLARE_SERIAL(CColor)
public:
	unsigned char attType;
public:
	//调色板
	COLORREF		colorset[MAXCOLORNUM];
	unsigned char		mask[MAXCOLORNUM];		//拾取过滤,0:关,1:开
public:
	CColor();
	virtual void Serialize(CArchive& ar);
};

class AFX_EXT_CLASS CLtype : public CObject
{
	DECLARE_SERIAL(CLtype)
public:
	unsigned char attType;
public:
	int			count;			//线型数
	CString 		name[MAXLTYPENUM];		//线型名
	int			factor[MAXLTYPENUM];
	unsigned  short		pattern[MAXLTYPENUM];
	double			width[MAXLTYPENUM];
	unsigned char		mask[MAXLTYPENUM];		//拾取过滤,0:关,1:开
public:
	CLtype();
	void InitLtype();
	virtual void Serialize(CArchive& ar);
};

//层数目限定小于100
class AFX_EXT_CLASS CLayer : public CObject
{
	DECLARE_SERIAL(CLayer)
public:
	unsigned char attType;
public:
	int			count;			//层数
	CString			name[MAXLAYERNUMEXT];		//层名
	CString 		describe[MAXLAYERNUMEXT];		//描述
	unsigned char		status[MAXLAYERNUMEXT];		//层状态,0:关,1:开
	unsigned char		color[MAXLAYERNUMEXT];		//颜色索引值-1:BYLAYER,-2:BYBLOCK
	unsigned char		ltype[MAXLAYERNUMEXT];		//线型索引值,-1:BYLAYER,-2:BYBLOCK
	unsigned char		mask[MAXLAYERNUMEXT];		//拾取过滤,0:关,1:开
public:
	CLayer();
	void InitLayer();
	virtual void Serialize(CArchive& ar);
};



//Buffer
class CEbBuffer : public CObject
{
	DECLARE_SERIAL(CEbBuffer)
public:
	unsigned char bufType;
public:
	CEbBuffer();
	virtual void	Serialize(CArchive& ar);
	virtual void	SetValue(void *value);
	virtual void	GetValue(void *value);
	virtual CEbBuffer*	Copy();
	virtual void		Trans();
};


class CEbInt : public CEbBuffer
{
	DECLARE_SERIAL(CEbInt)
public:
	int bvalue;
public:
	CEbInt();
	virtual void	Serialize(CArchive& ar);
	virtual void	SetValue(void *value);
	virtual void	GetValue(void *value);
	virtual CEbBuffer*	Copy();
};


class CEbReal : public CEbBuffer
{
	DECLARE_SERIAL(CEbReal)
public:
	double bvalue;
public:
	CEbReal();
	virtual void	Serialize(CArchive& ar);
	virtual void	SetValue(void *value);
	virtual void	GetValue(void *value);
	virtual CEbBuffer*	Copy();
};

class CEbPoint : public CEbBuffer
{
	DECLARE_SERIAL(CEbPoint)
public:
	double bvalue_x;
	double bvalue_y;
public:
	CEbPoint();
	virtual void	Serialize(CArchive& ar);
	virtual void	SetValue(void *value);
	virtual void	GetValue(void *value);
	virtual CEbBuffer*	Copy();
	virtual void		Trans();
};


class CEbString : public CEbBuffer
{
	DECLARE_SERIAL(CEbString)
public:
	CString bvalue_str;
public:
	CEbString();
	virtual void	Serialize(CArchive& ar);
	virtual void	SetValue(void *value);
	virtual void	GetValue(void *value);
	virtual CEbBuffer*	Copy();
};


class CEbCString : public CEbBuffer
{
	DECLARE_SERIAL(CEbCString)
public:
	CString bvalue_str;
public:
	CEbCString();
	virtual void	Serialize(CArchive& ar);
	virtual void	SetValue(void *value);
	virtual void	GetValue(void *value);
	virtual CEbBuffer*	Copy();
};



class CEbChar : public CEbBuffer
{
	DECLARE_SERIAL(CEbChar)
public:
	unsigned char bvalue_chr;
public:
	CEbChar();
	virtual void	Serialize(CArchive& ar);
	virtual void	SetValue(void *value);
	virtual void	GetValue(void *value);
	virtual CEbBuffer*	Copy();
};

class CEbShort : public CEbBuffer
{
	DECLARE_SERIAL(CEbShort)
public:
	short bvalue;
public:
	CEbShort();
	virtual void	Serialize(CArchive& ar);
	virtual void	SetValue(void *value);
	virtual void	GetValue(void *value);
	virtual CEbBuffer*	Copy();
};

//*******************************************************************
//系统元素节点的3d名称定义*************************************************
//*******************************************************************
class CBase;
typedef CTypedPtrList<CPtrList,CBase*>	ENTLIST;
typedef CTypedPtrList<CPtrList,CBase*>*	PENTLIST;

//3d元素来源名称
#define _3DENT_SRCNAME_EDGE_NUM		25
#define _3DENT_SRCNAME_FACE_NUM		5
#define _3DENT_SRCNAME_3DDIM_NUM	2
#define _3DENT_SRCNAME_SAME			1
#define _3DENT_SRCNAME_NOTSAME		0
#define _3DENT_PATHID_SAME			1
#define _3DENT_PATHID_NOTSAME		0
#define _3DENT_FACE_SAME			1
#define _3DENT_FACE_NOTSAME			0
#define _3DENT_EDGE_SAME			1
#define _3DENT_EDGE_NOTSAME			0
#define _3DENT_3DDIM_SAME			1
#define _3DENT_3DDIM_NOTSAME		0

class AFX_EXT_CLASS C3dEntSrcName : public CObject
{
	DECLARE_SERIAL(C3dEntSrcName)
protected:
	char m_cSrcNameLength;	//来源名字长度
	int	 *m_piSrcName;		//来源名字  
	char m_cSrcPathIDLength;//来源的PATHID长度
	int	 *m_piSrcPathID;	//来源的PATHID名字
	int	 m_iCheck;			//用于两个3d元素名称的比较。有相同元素1，否则0
	int  IsPathIDSame(int iPathIDNum1, int *pPathID1, int iPathIDNum2, int *pPathID2);
	int  IsEdgeIndexesSame(int iNum1, int *pE1, int iNum2, int *pE2);
	int  IsFaceIndexesSame(int iNum1, int *pF1, int iNum2, int *pF2);
	int	 Is3dDimSame(int iNum1, int *pF1, int iNum2, int *pF2);
public:
	C3dEntSrcName();
	~C3dEntSrcName();
	virtual void Serialize(CArchive& ar);
	C3dEntSrcName* Copy();
	int	 GetCheckFlag();
	void SetCheckFlag(int iCheckFlag);
	void SetSrcName(char cSrcNameLength, int* piSrcName);
	void SetSrcPathID(char cSrcPathIDLength, int* piSrcPathID);
	void FreeContent();
	int	 GetSrcNameLength();
	int* GetSrcName();
	int  GetSrcPathIDLength();
	int* GetSrcPathID();
	void operator = (C3dEntSrcName&);
	int	 IsSame(C3dEntSrcName& compareSrcName);
};
//3d元素名称
#define ENTSTATE_UPDATA_EXIT		1
#define ENTSTATE_UPDATA_NORMAL		0

#define _3DENT_NAME_SAME			1
#define _3DENT_NAME_NOTSAME			0

#define _3DENT_NAME_SAME_CHECK		1
#define _3DENT_NAME_SAME_NOTCHECK	0

class C3dEntName;
typedef CTypedPtrList<CPtrList, C3dEntName*> ENTNAMELIST;
class AFX_EXT_CLASS C3dEntName : public CObject
{
	DECLARE_SERIAL(C3dEntName)
protected:
			char			m_cSrcNum;			//3d元素来源个数
			C3dEntSrcName	*m_p3DEntSrc;		//3d元素来源
			int				m_iFlag;			//在程序处理的时候做标记 (ENTSTATE_UPDATA_EXIT)1:表示更新视图中有该元素但，用户已经把它删掉了
			short			m_siViewSn;			//所属视图编号
//			short			m_siViewGroupSn;	//所属视图组编号, ebv4只有一个视图组，所以该处省略
public:
			C3dEntName();
			~C3dEntName();
			C3dEntName(C3dEntName& entName);
			C3dEntName* Copy();
			C3dEntSrcName* GetSrcName();
	virtual	void Serialize(CArchive& ar);
			void	operator = (C3dEntName& srcEntName);
			void	FreeContent();
			void	SetViewSn(short siViewSn);
			short	GetViewSn();
	 		void	SetSrcNames(char cSrcNum, C3dEntSrcName* m_p3DEntSrc);
			int		GetSrcNum();
			int		GetFlag();
			void    SetFlag(int iFlag);
			int		IsSame(C3dEntName &compareEntName);
		CString		GetViewExpression();
	static	void	FreeEntNameList(ENTNAMELIST &entNameList);
	static	void	SerializeEntNameList(ENTNAMELIST &entNameList, CArchive& ar);
	static	void	CopyEntNameList(ENTNAMELIST &srcList, ENTNAMELIST &targetList);
	static	void	AddEntNameToList(ENTNAMELIST *pEntNameList, C3dEntName entName);
	static	void	DeleteEntNameToList(ENTNAMELIST *pEntNameList, C3dEntName entName);
};

//*******************************************************************
//系统元素节点的定义*************************************************
//*******************************************************************
class AFX_EXT_CLASS CBase : public CObject
{
	DECLARE_SERIAL(CBase)
public:
	unsigned char entType;		//元素类型
	unsigned char layer;		//层索引值
	unsigned char ltype;		//线型索引
	unsigned char color;		//颜色索引
	char	      pickflag;
	BOX	      box;
	int			m_iDisplayListName;
	C3dEntName		m_3dEntName;	//对应3D元素名称

	CTypedPtrList<CPtrList,CEbBuffer *>  buffer;
public:
	CBase();
	CBase(const CBase& i_Base);// Lg 2004-3-10
	CBase(unsigned char InitLtype,
	    unsigned char InitColor,unsigned char InitLayer);
	virtual ~CBase();
	virtual CBase*	Copy();
	int SetAttrib(unsigned char InitLtype,
		unsigned char InitColor,unsigned char InitLayer);
	virtual void	Trans();
	virtual void	DrawByMatrix();
	virtual void	Serialize(CArchive& ar);
	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual BOX		CalBox();
	virtual double	Distance(XYZ *p);
	virtual BOOL	IsWanted(long mask);
	virtual BOOL	IsOutBox(BOX &pickbox);
	virtual void	SetColor(char color);
	virtual XYZ		GetEndPoint(XYZ &pt);
	virtual XYZ		GetMidPoint();
	virtual CTypedPtrList<CPtrList,CBase*> *GetChildlist() {return NULL;}
	virtual void Refresh();
	BOOL			IsIncludeBox(BOX &pickbox,BOX &box);
	BOOL			BeginDrawing(CDC *pDC);

//	void			SetDrawLtype();
//	void			SetDrawColor();
};


class AFX_EXT_CLASS CPot : public CBase
{
	DECLARE_SERIAL(CPot)
public:
	XYZ p;
public:
	CPot();
	CPot(XYZ &pp,unsigned char InitColor=DmCurColor,
		     unsigned char InitLayer=DmCurLayer);
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual void	DrawByMatrix();
	virtual void	Serialize(CArchive& ar);
	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual BOX	CalBox();
	virtual double	Distance(XYZ *p);
	virtual BOOL	IsWanted(long mask);
	virtual BOOL	IsOutBox(BOX &pickbox);
	
};

class AFX_EXT_CLASS CLine : public CBase
{
	DECLARE_SERIAL(CLine)
public:
	XYZ p0,p1;		//起点,终点
public:
	CLine();
	CLine(XYZ &pp0,XYZ &pp1,
	      unsigned char InitLtype=DmCurLtype,
	      unsigned char InitColor=DmCurColor,
	      unsigned char InitLayer=DmCurLayer);
	virtual ~CLine();// Lg 2002-4-8 add for symapp error lnk2005
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual void	DrawByMatrix();
	virtual void	Serialize(CArchive& ar);
	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual BOX	CalBox();
	virtual double	Distance(XYZ *p);
	virtual BOOL	IsWanted(long mask);
	virtual BOOL	IsOutBox(BOX &pickbox);
	virtual XYZ	GetEndPoint(XYZ &pt);
	virtual XYZ	GetMidPoint();
};				



class AFX_EXT_CLASS CPolyline : public CBase
{
	DECLARE_SERIAL(CPolyline)
public:
	int	   num_seg;
	PXYZ	   p;
public:
	CPolyline();
	CPolyline(int num,XYZ *pp,
	      unsigned char InitLtype=DmCurLtype,
	      unsigned char InitColor=DmCurColor,
	      unsigned char InitLayer=DmCurLayer);
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual void	DrawByMatrix();
	virtual ~CPolyline();
	virtual void	Serialize(CArchive& ar);
	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual BOX	CalBox();
	virtual double	Distance(XYZ *p);
	virtual BOOL	IsWanted(long mask);
	virtual BOOL	IsOutBox(BOX &pickbox);
	virtual XYZ	GetEndPoint(XYZ &pt);
	virtual XYZ	GetMidPoint();
	virtual double	CalLength();
};


class AFX_EXT_CLASS CSpline : public CPolyline
{
	DECLARE_SERIAL(CSpline)
public:
	unsigned char	nurbsflag; //NURBS,BSPLINE
	unsigned char	plnflag;   //NOPLANE,ISPLANE
	double a,b,c,d;
	int	n;
	int	degree;
	PXYZW  pw;
	double *t;
public:
	CSpline();
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual ~CSpline();
	virtual void	Serialize(CArchive& ar);
//	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	//virtual XYZ	GetMidPoint();
	virtual void    Refresh();
};



class AFX_EXT_CLASS CEllipse : public CSpline
{
	DECLARE_SERIAL(CEllipse)
public:
	XYZ		pc;	  //中心点
	double		length;		//长半轴长度
	double		width;		//短半轴长度
	double		ang;		//椭圆弧的旋转角
	double		angs,ange;		//椭圆弧的起始角度及终止角
public:
	CEllipse();
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual ~CEllipse();
	virtual void	Serialize(CArchive& ar);
//	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
};



class AFX_EXT_CLASS CArc : public CBase
{
	DECLARE_SERIAL(CArc)
public:
	XYZ	pc,px,py;	//圆弧坐标系的三个点
	double	r,a;
public:
	CArc();
	CArc(XYZ &ppc,XYZ &pps,XYZ &ppe,double *ang=NULL,double *radius=NULL,
	      unsigned char InitLtype=DmCurLtype,
	      unsigned char InitColor=DmCurColor,
	      unsigned char InitLayer=DmCurLayer);
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual void	DrawByMatrix();
	virtual void	Serialize(CArchive& ar);
	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual BOX		CalBox();
	virtual double	Distance(XYZ *p);
	virtual BOOL	IsWanted(long mask);
	virtual BOOL	IsOutBox(BOX &pickbox);
	virtual XYZ	GetEndPoint(XYZ &pt);
	virtual XYZ	GetMidPoint();
	virtual void Refresh();
	BOOL		IsCircle();
	XYZ		GetFirstPt();
	XYZ		GetSecondPt();
	void		CalPxPy(XYZ &start_pt);
};


class AFX_EXT_CLASS CCircle : public CArc
{
	DECLARE_SERIAL(CCircle)
public:
	CCircle();
	CCircle(XYZ &ppc,double radius,
	      unsigned char InitLtype=DmCurLtype,
	      unsigned char InitColor=DmCurColor,
	      unsigned char InitLayer=DmCurLayer);
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual void	DrawByMatrix();
//	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual BOX 	CalBox();
	virtual BOOL	IsWanted(long mask);
	virtual BOOL	IsOutBox(BOX &pickbox);
};


class AFX_EXT_CLASS COffset : public CBase
{
	DECLARE_SERIAL(COffset)
public:
	double	   dis;
	CSpline    *oldcur;
	CSpline    *newcur;
public:
	COffset();
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual ~COffset();
	virtual BOX	CalBox();
};



//#ifndef _TXT_H

class AFX_EXT_CLASS CGroup : public CBase
{
	DECLARE_SERIAL(CGroup)
public:
	CTypedPtrList<CPtrList,CBase*> childlist;
public:
	CGroup();
	CGroup(const CGroup& i_Group);// Lg 2004-3-10
	CGroup(unsigned char InitLtype,
	       unsigned char InitColor,
	       unsigned char InitLayer);
	virtual ~CGroup();
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual void	DrawByMatrix();
	virtual void	Serialize(CArchive& ar);
//	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual BOX		CalBox();
	virtual double	Distance(XYZ *p);
	virtual BOOL	IsWanted(long mask);
	virtual BOOL	IsOutBox(BOX &pickbox);
	virtual void	SetColor(char color);
	virtual CTypedPtrList<CPtrList,CBase*> *GetChildlist() {return &childlist;}

	virtual int Generate();// Lg 2004-3-29 add 生成childlist链
};
/*
#else

class _declspec(dllimport) CGroup : public CBase
{
	DECLARE_SERIAL(CGroup)
public:
	CTypedPtrList<CPtrList,CBase*> childlist;
public:
	CGroup();
	CGroup(unsigned char InitLtype,
	       unsigned char InitColor,
	       unsigned char InitLayer);
	virtual ~CGroup();
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual void	DrawByMatrix();
	virtual void	Serialize(CArchive& ar);
//	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual BOX		CalBox();
	virtual double	Distance(XYZ *p);
	virtual BOOL	IsWanted(long mask);
	virtual BOOL	IsOutBox(BOX &pickbox);
	virtual void	SetColor(char color);
	virtual CTypedPtrList<CPtrList,CBase*> *GetChildlist() {return &childlist;}
		
};

#endif
*/

class AFX_EXT_CLASS CSolid : public CGroup
{
	DECLARE_SERIAL(CSolid)
public:
	XYZ		p;	  //拾取点
	//sue Add. 2002-3-28
//	CTypedPtrList<CPtrList,CBase*> LoopList;	//记录拾取的环的链
	// sue 
public:
	CSolid();
	CSolid(unsigned char InitLtype,
	       unsigned char InitColor,
	       unsigned char InitLayer);
	virtual CBase*	Copy();
//  virtual BOX		CalBox();	//计算包围盒//sue Add. 2002-4-2
	virtual void	Trans();
	virtual void	Serialize(CArchive& ar);
	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual double	Distance(XYZ *p);
	virtual BOOL	IsWanted(long mask);
};


class AFX_EXT_CLASS CHatch : public CGroup
{
	DECLARE_SERIAL(CHatch)
public:
	CString  pattern;		//剖面图案类型
	double	 scale;
	double	 ang;
	XYZ	 p;	       //拾取点
	//Rongjun 2001.7.12
	CTypedPtrList<CPtrList,CBase*> loopchildlist;	//记录剖面线环的链
	//
public:
	CHatch();
	~CHatch();	//sue Add CHatch的析构函数. 2002-7-8
	CHatch(unsigned char InitLtype,
	       unsigned char InitColor,
	       unsigned char InitLayer);
	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual void	Serialize(CArchive& ar);
	virtual BOOL	IsWanted(long mask);
	//dbf 04.7.19 add
	virtual double  Distance(XYZ *pt);
	virtual BOOL	IsOutBox(BOX &pickbox);
	virtual BOX		CalBox();
	virtual void	DrawByMatrix();
	virtual int		Generate( void );
	//dbf end
};

class AFX_EXT_CLASS CBlock : public CGroup
{
	DECLARE_SERIAL(CBlock)
public:
	XYZ	p;		//定位点
	double	ang;		//旋转角
	CString name;		//块名
	CString	att;		//块属性
	CSolid	border;
	unsigned char	hide;	//块消隐标记
public:
	CBlock();
	CBlock(XYZ &pp,CString blk_name="",
	       unsigned char InitLtype=DmCurLtype,
	       unsigned char InitColor=DmCurColor,
	       unsigned char InitLayer=DmCurLayer);
	virtual ~CBlock();
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual void	Serialize(CArchive& ar);
//	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual BOX		CalBox();
	virtual BOOL	IsWanted(long mask);
};



class AFX_EXT_CLASS CPltLType
{
public:
	double dWidth;
	double *pdLLen;
	int iLNum;
	CPltLType();
	~CPltLType();
};
	
class  CColumn;
class AFX_EXT_CLASS CCell : public CBase //模板上的单元格，（被打包成列的形式得到体现）
{
	DECLARE_SERIAL(CCell)
public:
	double	      Left;			//
	double	      Top;			//
	double	      Width;			//
	double	      Height;			//
	short         Row;			//单元格对应的行号
	short         Record;		//单元格对应的记录号（同一道工序判别标志）
	short         Column;		//单元格所属的列ID
	CString       Content;		//单元格包含的文字
	CBase         *pText;		//对应的绘制文字
	
public:
	CCell();
	CCell(unsigned char InitLtype,
	       unsigned char InitColor,
	       unsigned char InitLayer);
	virtual ~CCell();
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual void	DrawByMatrix();
	virtual void	Serialize(CArchive& ar);
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual BOX	    CalBox();
	virtual double	Distance(XYZ *p);
	virtual BOOL	IsWanted(long mask);
	virtual BOOL	IsOutBox(BOX &pickbox);
	void HighLightCell();
	void NormalCell();
	void     HighLight(); //for cdc xor
	void     Normal();    //for cdc xor
	CColumn* GetColumn();
};
	

class AFX_EXT_CLASS CColumn : public CGroup//模板中的列（可以仅包含一个单元格）
{
	DECLARE_SERIAL(CColumn)
public:
	CTypedPtrList<CPtrList,CBase*> continuecolumn;
public:
	double	      Left;			//
	double	      Top;			//
	double	      Width;			//
	double	      Height;			//
	double		  TextHeight;
	CString		  CFontName;
	CString		  EFontName;
	CString       CellName;		//列名称
	CString       CollectName;	//被汇总的列名称
	CString       TableName;	//列引用的知识库表名称
	CString       FieldName;	//列引用的知识库表的字段名称
	CString       DomainName;	//列对应的域名称
	short         RowNum;		//列包含的行数
	short         HalignMode;	//水平对齐方式
	short         ValignMode;	//垂直对齐方式
	short         WrapMode;		//是否自动压缩
	short         Direction;	//自上向下还是自下向上填写
	short         Column;		//列ID
	//1=产品信息，2=零件信息，3=工艺信息，4=工序信息，5=工步信息，
	//6=表尾信息，7=附加栏信息，
	short         ColumnType;	//列对应的信息分类
	short         ColumnDir;	//列方向　0=纵向连续　1=横向连续　2=纵向不连续　3=横向不连续
public:
	CColumn();
	CColumn(unsigned char InitLtype,
	       unsigned char InitColor,
	       unsigned char InitLayer);
	virtual ~CColumn();
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual void	DrawByMatrix();
	virtual void	Serialize(CArchive& ar);
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual BOX	    CalBox();
	virtual double	Distance(XYZ *p);
	virtual BOOL	IsWanted(long mask);
	virtual BOOL	IsOutBox(BOX &pickbox);
	virtual void	SetColor(char color);
	//virtual BOOL	IsIncludeBox(BOX &pickbox,BOX &box);
	//virtual CTypedPtrList<CPtrList,CBase*> *GetChildlist() {return &childlist;}
	int     GetContinueColumnNum() {return continuecolumn.GetCount();}
	CCell*   GetCell(int row);
	int      GetCells(short record,CTypedPtrList<CPtrList,CBase*> &RecordCell,int row=-1);
	int      GetCellList(CTypedPtrList<CPtrList,CBase*> &CellList);
	short    GetRecordValue(double PosX,double PosY,int *row,int record_or_row=0);//0=record,1=row
	void     HighLight();
	void     Normal();
};


class AFX_EXT_CLASS CTable : public CGroup
{
	DECLARE_SERIAL(CTable)

public:
	double	      Left;			//
	double	      Top;			//
	double	      Width;			//
	double	      Height;			//
	short         PageNum;		//据查目前（2003.3.13)没用
	short         Table;		//表ID
	short         ContinueFlag;	//是否可以续页
	
public:
	CTable();
	CTable(unsigned char InitLtype,
	       unsigned char InitColor,
	       unsigned char InitLayer);
	virtual ~CTable();
	virtual CBase*	Copy();
	virtual void	Trans();
	virtual void	DrawByMatrix();
	virtual void	Serialize(CArchive& ar);
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual BOX	    CalBox();
	virtual double	Distance(XYZ *p);
	virtual BOOL	IsWanted(long mask);
	virtual BOOL	IsOutBox(BOX &pickbox);
	virtual void	SetColor(char color);
	//virtual BOOL	IsIncludeBox(BOX &pickbox,BOX &box);
	//virtual CTypedPtrList<CPtrList,CBase*> *GetChildlist() {return &childlist;}
	int     GetColumnNum() {return childlist.GetCount();}
	CColumn*  GetColumn(CString name);
	CColumn*  GetColumn(int index);
	short     GetRecordValue(double PosX,double PosY,int *row,int record_or_row=0);//0=record,1=row
	int      GetCell(int row);
	void     HighLight();
	void     Normal();
	//CStringArray  GetRowContent(int row);
	//int           SetRowContent(CStringArray content);
	//CStringArray  GetRecordContent(int record);
	//int           SetRecordContent(CStringArray content);
	//int           InsertRecord(int record,CStringArray content);
    //int           DeleteRecord(int record);
	//int           GetPageRange(int page,int &startrow,int &endrow);
};


class AFX_EXT_CLASS CCardCell : public CObject	//卡片内的单元格
{
	DECLARE_SERIAL(CCardCell)

public:
	short 	      Column;	//所属列ID
	short 	      Row;		//对应的行号
	short         Record;	//对应的记录号
	short         Table;	//对应的表ID
	//CString	      CommonAttribName;
	CString       CellName;	//单元格名称
	CString	      Content;	//单元格文字内容
	CString	      ItemId;		//单元格对应的知识库ID
	
public:
	CCardCell();
	virtual ~CCardCell();
	virtual void	Serialize(CArchive& ar);
	virtual CCardCell*	Copy();

};


class AFX_EXT_CLASS CCard : public CObject
{
	DECLARE_SERIAL(CCard)

public:
	unsigned char cardType;   //PROCESS_CARD     WORKINGPROCEDURE_CARD
	short 	      Record;		//对应的记录号（用于和过程卡中的工序匹配）
	short 	      Page;			//对应过程卡的第几页信息（同Record一起确定和过程卡工序的匹配），同时利用大基数区分工序卡和首页、附页、跟踪卡
	CString	      CardName;		//卡片名称，如 “工序卡10”
	CString	      TemplateName;	//卡片对应的模板名称
	BOOL          PrintMark;	//单页打印时，是否被选择打印
	long          LocCardID;	//标识ID号
public:	
	CTypedPtrList<CPtrList,CCardCell*> childlist;
	CTypedPtrList<CPtrList,CBase*> EntityChain;
	CTypedPtrList<CPtrList,CCard*> ContinuePage;
public:
	CCard();
	virtual ~CCard();
	virtual void	Serialize(CArchive& ar);
	virtual CCard*	Copy();
	int     GetPageNum() {return ContinuePage.GetCount();}
	
};



//ABOUT attType
// CAXA_CHAR                  
// CAXA_INT                   
// CAXA_DOUBLE                
// CAXA_DATETIME              
// CAXA_CURRENCY              
class AFX_EXT_CLASS  CCommonAttrib : public CObject
{
	DECLARE_SERIAL(CCommonAttrib)
public:
	unsigned char attType;
	CString       Name;
	CString       Value;
public:
	CCommonAttrib();
	virtual void	Serialize(CArchive& ar);
	virtual CCommonAttrib*	Copy();
	
};

typedef struct cellpos
{
	CCell *pCurrentCell;
	int pos1;
    int pos2;
} CELLPOS;
#define  SIZECELLPOS sizeof(CELLPOS)

//风格基类
class AFX_EXT_CLASS CStyle:public CObject
{
	DECLARE_SERIAL(CStyle)
protected:
	int m_iStyleID;
	CString m_sStyleName;//Style名

protected:
	int SetStyleID(int i_iID);
public:
	CStyle();
	CStyle(const CStyle& i_Style);
	virtual ~CStyle();

	CString GetStyleName()const;
	int SetStyleName(const CString& i_sName);
	
	int GetStyleID()const;

	virtual void Serialize(CArchive& ar);
};

// Lg 2004-5-27 add 风格Undo类
class AFX_EXT_CLASS CStyleUndo:public CBase
{
	DECLARE_SERIAL(CStyleUndo)
public:
	CStyle* m_pStyle;
	int m_iType;
	BOOL m_bUpdate;
public:
	CStyleUndo();
	CStyleUndo(const CStyle& i_Style,int i_iType,BOOL i_bUpdate = FALSE);
	virtual ~CStyleUndo();
	int GetType()const;	
	int ResumeToList();
	int RemoveFromList();
	int Undo();
	virtual BOX CalBox();
	virtual void Serialize(CArchive& ar);
};

// Lg 2004-3-8 从txt.h中移来文本风格定义并用类实现
class AFX_EXT_CLASS  CTxtStyle :public CStyle
{
	DECLARE_SERIAL(CTxtStyle)
protected:
//	int m_iStyleID;
	//TCHAR	aStyleName[32];				//Style名
	//TCHAR	aEFontName[LF_FACESIZE];	//西文字体名
	//TCHAR	aCFontName[LF_FACESIZE];	//中文字体名
//	CString m_sStyleName;//Style名
	CString m_sEFontName;//西文字体名
	CString m_sCFontName;//中文字体名
	double	m_dEWidFac;					//西文宽度系数
	double	m_dCWidFac;					//中文宽度系数
	double	m_dXIntFac;					//字符间距系数
	double	m_dYIntFac;					//行距系数
	double	m_dHeight;					//字高
	double	m_dObliqueAng;				//倾斜角(弧度)
	//double  m_dRotAng;					//旋转角(弧度)
	double  m_dIndent;					//缩进距离，预留，尚未实现!
//	BYTE	m_cJustification;			//对齐方式
//	BYTE	m_cEffect;					//特殊效果
	
	friend class CTxtStyleList;
public:
	CTxtStyle();
	CTxtStyle(const CTxtStyle& i_Style);
	virtual ~CTxtStyle();

//protected:
	
//	int SetStyleID(int i_iID);
public:
//	CString GetStyleName()const;
//	int SetStyleName(const CString& i_sName);
	
//	int GetStyleID();

	CString GetEFontName()const;
	int SetEFontName(const CString& i_sName);

	CString GetCFontName()const;
	int SetCFontName(const CString& i_sName);

	double GetEWidFac()const;
	int SetEWidFac(double i_dFac);

	double GetCWidFac()const;
	int SetCWidFac(double i_dFac);

	double GetXIntFac()const;
	int SetXIntFac(double i_dFac);

	double GetYIntFac()const;
	int SetYIntFac(double i_dFac);

	double GetHeight()const;
	int SetHeight(double i_dHeight);

	double GetObliqueAng()const;
	int SetObliqueAng(double i_dAng);

//	double GetRotAng()const;
//	int SetRotAng(double i_dAng);

	double GetIndent()const;
	int SetIndent(double i_dIndent);

//	BYTE GetJustification()const;
//	int SetJustification(BYTE i_cJust);

//	BYTE GetEffect()const;
//	int SetEffect(BYTE i_cEffect);

public:
	int Init();
	int operator = (const CTxtStyle& i_Style);
	virtual void Serialize(CArchive& ar);

};	
// Lg 2004-3-8 end


class AFX_EXT_CLASS CTxtStyleList : public CObject
{
	DECLARE_SERIAL(CTxtStyleList)
		
protected:
	//字型结构的链表
	CTypedPtrList< CPtrList, CTxtStyle * > m_StyleList;
	//当前字型的索引
	int m_iCurStyleID;
public:
	//dbf add 04.12.30
	//当读入的文字风格引用型文件时，型文件字体没有找到，而且被用户取消，
	//m_UnknownFontList记录该型文件名。为了下次不再弹出查找对话框
	CList < CString, CString& > m_UnknownFontList;
	//dbf end
public:
	CTxtStyleList();
	~CTxtStyleList();

	

	// Lg 2004-3-17 modified begin
	//设置当前字型
	//返回值：成功返回C_RT_SUCCESS，超出范围返回C_RT_NOTFOUND
/*	int SetCurStyle(int iIndex);
	//添加字型
	//返回值：成功返回C_RT_SUCCESS，如果存在相同名字字型，则
	//更新此同名字型，同时返回C_RT_FOUND,此时应注意释放掉pStyle
	int AddStyle( CTxtStyle* pStyle);
	//创建缺省字型
	//返回值：成功返回C_RT_SUCCESS，内存不足返回C_RT_OUTOFMEMORY
	int Init();
	
	//用pStyle中的参数创建名为sName的字型，加入字型链中，并设为当前字型
	//返回值：成功返回C_RT_SUCCESS，内存不足返回C_RT_OUTOFMEMORY
	int CreateStyle( const CString & sName, const CTxtStyle * pStyle );
	
	//删除名为sStyleName的字型，如果删除的是当前字型则下一个字型
	//成为当前字型，如果已经是最后一个字型则将新的最末字型设为当
	//前字型
	//返回值：成功返回C_RT_SUCCESS，未找到返回C_RT_NOTFOUND,要
	//		  删除缺省字型返回C_RT_NOTALLOWED
	int DelStyle( const CString & sStyleName );
	
	//用pStyle中的参数更新名为sName的字型。
	//返回值：成功返回C_RT_SUCCESS，未找到字型sName返回C_RT_NOTFOUND
	int UpdateStyle( const CString & sName, const CTxtStyle * pStyle );
	
	//将字型sOldName改名为sNewName
	//返回值：成功返回C_RT_SUCCESS，未找到字型sOldName返回
	//		  C_RT_NOTFOUND，sNewName太长(大于31字节)或者
	//		  要将缺省字型改名返回C_RT_NOTALLOWED
	int RenameStyle( const CString& sOldName, const CString& sNewName );
	
	//返回字型个数
	int GetStyleCount( void )
	{	return m_StyleList.GetCount();	}
	
	int GetCurStyleIndex( void ) { return m_iCurStyleIdx; }
	
	//通过修改m_iCurStyleIdx将名为sStyleName的字型设置为当前字型
	//返回值：成功返回C_RT_SUCCESS，未找到字型sStyleName返回
	//		  C_RT_NOTFOUND
	int SetCurStyle( const CString& sStyleName );
	
	//获得索引为iIndex的字型的名字，通过o_sName返回
	//返回值：成功返回C_RT_SUCCESS，未找到返回C_RT_INVALIDINDEX
	int GetStyleName( int iIndex, CString & o_sName );
	
	//在字型链中查找索引为iIndex的字型，将其参数复制到o_pStyle指
	//向的结构中，o_pStyle不能为NULL
	//返回值：成功返回C_RT_SUCCESS，未找到返回C_RT_INVALIDINDEX
	int GetStyle( int iIndex, CTxtStyle& o_Style );
	
	//根据风格ID在风格链中查找相应风格
	int GetStyle(int i_iStyleID,CTxtStyle& o_Style);// Lg 2004-3-17 add

	//在字型链中查找名为sStyleName的字型，将其参数复制到o_pStyle指
	//向的结构中
	//如果o_pStyle传入NULL，可用来判断是否存在名为sStyleName的字型
	//返回值：成功返回C_RT_SUCCESS，未找到返回C_RT_NOTFOUND
	int GetStyle( const CString& sStyleName, CTxtStyle& o_Style );
	
	//在字型链中查找当前字型，将其参数复制到pStyle指向的结构中
	//o_pStyle不能为NULL
	//返回值：成功返回C_RT_SUCCESS，否则返回C_RT_INVALIDINDEX
	int GetCurStyle( CTxtStyle& o_Style );
*/

	//添加风格(返回ID)
	int AddStyle(const CTxtStyle& i_Style);
	//传入风格和链中风格比较，如果风格数据不同（除风格名与风格id外)
	//把传入风格加入风格链  返回ID
	int AddStyleByData(const CTxtStyle& i_Style);
	//获得现有风格数目
	int GetCount();

	int GetCurStyleID();
	int SetCurStyleID(int i_iID);

	//删除链中的风格
	int DelStyle(const CString& i_sName);
	int DelStyleByID(int i_iID);
	//int DelStyle(int i_iIndex);
	
	//查找风格(返回风格在链中的索引)
	int Find(const CString& i_sName);
	int FindByID(int i_iID);
	
	//更新风格
	int UpdateStyle(const CString& i_sName,const CTxtStyle& i_Style);
	int UpdateStyleByID(int i_iID,const CTxtStyle& i_Style);
	//int UpdateStyle(int i_iIndex,const CTxtStyle& i_Style);
	
	//得到风格
	int GetStyle(const CString& i_sName,CTxtStyle& o_Style);
	int GetStyleByID(int i_iID,CTxtStyle& o_Style);
	//int GetStyle(int i_iIndex,CTxtStyle& o_Style);
	
	//风格改名
	int RenameStyle(const CString& i_sOldName,const CString& i_sNewName);
	int RenameStyleByID(int i_iID,const CString& i_sNewName);
	//int RenameStyle(int i_iIndex,const CString& i_sNewName);

	//初始化
	int Init();
	
	//设置当前默认风格
	int SetCurStyle(const CString& i_sName);
	int SetCurStyleByID(int i_iID);
	//int SetCurStyle(int i_iIndex);
	
	//得到当前默认风格
	int GetCurStyle(CTxtStyle& o_Style);
	//得到当前风格名
	int GetCurStyleName(CString& o_sName);

	// 得到系统缺省风格
	int GetDefaultStyle(CTxtStyle& o_Style);
	
	//得到索引对应的风格名
	int GetStyleName(int i_iIndex,CString& o_sName);
	//得到风格ID对应的风格名
	int GetStyleNameByID(int i_iID,CString& o_sName);
	
	//得到索引对应的风格ID
	int GetStyleID(int i_iIndex,int& o_iID);
	//得到风格名对应的风格ID
	int GetStyleID(const CString& i_sName,int& o_iID);
	
	virtual void Serialize( CArchive & ar );
};


// Lg 2004-3-8 begin 修改风格数据结构,定义风格类
// Lg 01-7-6从adm.h移来
/*typedef struct _dimstyle
{
    double   scale;	  //尺寸标注总比例
    short    textloc;	 //文本位置方式TEXTUP | TEXTCENTER | TEXTDOWN
    int      textdir;	   //文本书写方向TEXTHOR | TEXTPAR
    short    dotbit;	 //小数点位数
    double   height;	  //文字高度.
    double   widfac;	  //文字宽度因子
    double   colspace;	  //文字字间系数
    short    border1;	 //第一界线开关:ON-有界线,OFF-无界线.
    short    border2;	 //第二界线开关:ON-有界线,OFF-无界线.
    double   extlen;	  //尺寸线在界线外延伸长度.
    double   outlen;	  //尺寸界线超出尺寸线的长度.
    short    midline;	 //文字界外时中间尺寸线开关:ON-开,OFF-关.
    short    arrow1;	 //NOARROW | ARROW | ARROWDOT | ARROWLINE
    short    arrow2;	 //NOARROW | ARROW | ARROWDOT | ARROWLINE
    double   arrowlen;	  //箭头长度
    double   gap;	  //标注文字和尺寸线的间隙
    short    dotmove;	 //小数点自动圆整 1 = 圆整, 0 = 不圆整
    short    dotmark;	 //自动加圆点 1 = 加圆点, 0 = 不加圆点
    double   artdimgap;//界线与引出点的间距//add by wj 99.5.28
	TCHAR	 aEFontName[LF_FACESIZE];	//西文字体名
	TCHAR	 aCFontName[LF_FACESIZE];	//中文字体名
	TCHAR	 aStyleName[LF_FACESIZE];	//尺寸风格名称//CJL Add
}DIMSTYLE;
// Lg 01-7-7从sym_dosf.h移来
*/

class AFX_EXT_CLASS CDimStyle:public CStyle
{
	DECLARE_SERIAL(CDimStyle)
protected:
//    CString  m_sStyleName;//风格名          
//	int m_iStyleID;//风格ID;

	//尺寸线相关Dimension Line(DL)
	unsigned long  m_ulDLColor; //尺寸线颜色
	CString m_sDLClrDes;//尺寸线颜色描述
	//double m_dDLWeight;//尺寸线宽度
	double m_dDLExtLen;// 尺寸线超出边界线的长度
	//double m_dDLSpace;//基准标注时尺寸线的间距
	BOOL m_bLDLOn;//左尺寸线开关
	BOOL m_bRDLOn;//右尺寸线开关

	//边界线相关Border Line(BL)
	unsigned long  m_ulBLColor; //边界线颜色
	CString m_sBLClrDes;//边界线颜色描述
	//double m_dBLWeight;//边界线宽度
	double m_dBLOutLen;//边界线超出尺寸线的长度
	double m_dDistOffDeriv;//边界线离开标注点的距离
	BOOL m_bLBLOn;//左边界线开关
	BOOL m_bRBLOn;//右边界线开关
		
	//箭头相关（AutoCAD风格具有的引用箭头形式EB无法实现，因此风格中省去有关箭头ID的选项）
	double m_dArrowSize;//箭头大小
	
	short m_iLArrowMark;//左箭头形式NOARROW | ARROW | ARROWDOT | ARROWLINE
	short m_iRArrowMark;//右箭头形式NOARROW | ARROW | ARROWDOT | ARROWLINE
	short m_iLeadArrow;//引出箭头形式NOARROW | ARROW | ARROWDOT | ARROWLINE
	//其他
    short m_iDotMark;//引出点形式（1：加圆点，0：不加圆点）
	
	//文本相关
	int   m_iRefTxtStyID;//引用的文本风格ID（编辑时显示文本风格名，EB风格中关于文本的一些选项归入此项）
	unsigned long m_ulTxtColor;//文本颜色
	CString m_sTxtClrDes;//文本颜色描述
	unsigned long m_ulTxtFillColor;//文本填充颜色
	CString m_sTxtFillClrDes;//文本填充颜色描述
	double m_dDimTxtHeight;//标注字高
	
	BOOL  m_bDrawTxtFrm;//是否绘制文本包围盒
	short  m_iTxtHPos;//文本水平位置
	short  m_iTxtVPos;//文本垂直位置
	double m_dGapToDL;//文本和尺寸线之间的空隙
	short m_iTxtAlign;//文本书写方式（平行§水平）
	
	//调整选项(Fit)
	short  m_iFit;//尺寸线中间放不下文本和箭头时设定如何放置
	//1、文本或箭头优先
	//遵循如下规则：
	//  (1)如果有足够的空间，将文本和箭头放在边界线之间。否则
	//     移动文本或是箭头来满足配置。
	//  (2)如果空间只能放下文本，文本在边界线中间，
	//     箭头在外面。
	//  (3)如果空间只能放下箭头，则箭头在中间，文本在外面。
	//  (4)如果空间对两者都不够，两者都在外面。
	//2、箭头优先
	//遵循如下规则：
	//  (1)如果空间足以放下两者，则两者都在中间。
	//  (2)如果只能放下箭头，箭头在中间，文本在外面。
	//  (3)如果空间不够放箭头，两者都在外面。
	//3、文本优先
	//遵循如下规则：
	//  (1)如果空间足以放下两者，则两者都在中间。
	//  (2)如果只能放下文本，文本在中间，箭头在外面。
	//  (3)如果空间不够放文本，两者都在外面。
	//4、文本和箭头优先
	//如果空间不足以放下两者，则都放外面。
	//5、总是放文本在边界线中间
	BOOL  m_bOmitArrow;//尺寸线中间放不下箭头时，省略箭头绘制
	short  m_iTxtPlace;//当文本从默认位置移动时，控制文本的位置表现
	//1、始终在尺寸线上（包括延长线）
	//2、在尺寸线上方（或下方），带引出线
	//3、在尺寸线上方（或下方），不带引出线
	double m_dScale;//尺寸标注总比例（标注值和标注本身大小都受影响）
//	BOOL  m_bDragTxt;//标注时拖动确定文本位置
	//单位相关
	//可实现科学计数法、英制单位、十进制之间的转换（分数形式、建筑单位制与其他单位制的换算方法不明确，AutoCAD中的Windows Desktop单位制意义不明确）
	//short  m_iUnit;//单位制 
	short  m_iPrec;//精度位
	char   m_chDecimal;//小数点形式
	BOOL   m_bDecRnd;//小数是否圆整(EB独有，考虑到兼容性列入)
	double  m_dRndUnit;//圆整单位
	CString m_sPrefix;//尺寸前缀
	CString m_sSuffix;//尺寸后缀
	double m_dMScale;//尺寸值比例
	BOOL  m_bHeadZS;//是否压缩尺寸值头部的零
	BOOL  m_bTailZS;//是否压缩尺寸值尾部的零
	short  m_iAngUnit;//角度单位制
	short  m_iAngPrec;//角度单位精度
	BOOL  m_bAngHeadZS;//是否压缩角度尺寸值头部的零
	BOOL  m_bAngTailZS;//是否压缩角度尺寸值尾部的零
	//偏差精度
	short m_iTolPrec;

	friend class CDimStyleList ;
public:
	CDimStyle();
	CDimStyle(const CDimStyle& i_Style);
	virtual ~CDimStyle();

//protected:
//	int SetStyleID(int i_iID);
	

public:
	//CString GetStyleName()const;
	//int SetStyleName(const CString& i_sName);
	
//	int GetStyleID()const;
	
	unsigned long GetDLColor()const;
	int SetDLColor(unsigned long i_ulColor);
   
	CString GetDLColorDescrp()const;
	int SetDLColorDescrp(const CString& i_sDes);

	double GetDLExtLen()const;
	int SetDLExtLen(double i_dLen);

	double GetDLSpace()const;
	int SetDLSpace(double i_dDLSpace);

	BOOL IsLDLOn()const;
	int SetLDLOn(BOOL i_bOn);

	BOOL IsRDLOn()const;
	int SetRDLOn(BOOL i_bOn);

	unsigned long GetBLColor()const;
	int SetBLColor(unsigned long i_ulColor);

	CString GetBLColorDescrp()const;
	int SetBLColorDescrp(const CString& i_sDes);

	double GetBLOutLen()const;
	int SetBLOutLen(double i_dLen);

	double GetDistOffDeriv()const;
	int SetDistOffDeriv(double i_dDist);

	BOOL IsLBLOn()const;
	int SetLBLOn(BOOL i_bOn);

	BOOL IsRBLOn()const;
	int SetRBLOn(BOOL i_bOn);

	double GetArrowSize()const;
	int SetArrowSize(double i_dSize);

	short GetLArrowMark()const;
	int SetLArrowMark(short i_iMark);

	short GetRArrowMark()const;
	int SetRArrowMark(short i_iMark);
	
	short GetLeadArrow()const;
	int SetLeadArrow(short i_iMark);

	short GetDotMark()const;
	int SetDotMark(short i_iMark);

	int GetRefTxtStyID()const;
	int SetRefTxtStyID(int i_iID);

	unsigned long GetTxtColor()const;
	int SetTxtColor(unsigned long i_ulColor);

	CString GetTxtColorDescrp()const;
	int SetTxtColorDescrp(const CString& i_sDes);

	unsigned long GetTxtFillColor()const;
	int SetTxtFillColor(unsigned long i_ulColor);
	
	CString GetTxtFillColorDescrp()const;
	int SetTxtFillColorDescrp(const CString& i_sDes);

	double GetDimTxtHeight()const;
	int SetDimTxtHeight(double i_dHeight);

	BOOL IsDrawTxtFrm()const;
	int SetDrawTxtFrm(BOOL i_bDraw);

	short GetTxtHPos()const;
	int SetTxtHPos(short i_iPos);

	short GetTxtVPos()const;
	int SetTxtVPos(short i_iPos);

	double GetGapToDL()const;
	int SetGapToDL(double i_dGap);

	short GetTxtAlign()const;
	int SetTxtAlign(short i_iAlign);

	short GetFit()const;
	int SetFit(short i_iFit);

	BOOL IsOmitArrow()const;
	int SetOmitArrow(BOOL i_bOmit);

	short GetTxtPlace()const;
	int SetTxtPlace(short i_iPlace);

	double GetScale()const;
	int SetScale(double i_dScale);

//	BOOL IsDragTxt()const;
//	int SetDragTxt(BOOL i_bDrag);

	
	short GetPrec()const;
	int SetPrec(short i_iPrec);

	char GetDecimal()const;
	int SetDecimal(char i_chDec);

	BOOL IsDecRnd()const;
	int SetDecRnd(BOOL i_bRnd);

	double GetRndUnit()const;
	int SetRndUnit(double i_dUnit);

	CString GetPrefix()const;
	int SetPrefix(const CString& i_sPrefix);

	CString GetSuffix()const;
	int SetSuffix(const CString& i_sSuffix);

	double GetMScale()const;
	int SetMScale(double i_dMScale);

	BOOL IsHeadZS()const;
	int SetHeadZS(BOOL i_bZS);

	BOOL IsTailZS()const;
	int SetTailZS(BOOL i_bZS);

	short GetAngUnit()const;
	int SetAngUnit(short i_iUnit);

	short GetAngPrec()const;
	int SetAngPrec(short i_iAngPrec);

	BOOL IsAngHeadZS()const;
	int SetAngHeadZS(BOOL i_bZS);

	BOOL IsAngTailZS()const;
	int SetAngTailZS(BOOL i_bZS);

	short GetTolPrec()const;
	int SetTolPrec(short i_iPrec);

public:
	int Init();
	int Compare(const CDimStyle& i_Style)const;//lg 05-03-17 add 
	//得到文本风格
	CTxtStyle GetTxtStyle()const;
	//赋值
	int operator =(const CDimStyle& i_Style);
	//序列化
	virtual void Serialize( CArchive & ar );
};
// Lg 2004-3-8 end

//CJL Add, 2002/04 
class AFX_EXT_CLASS CDimStyleList : public CObject // Lg 2004-3-8 修改风格链类名CDimStyle为CDimStyleList
{
	DECLARE_SERIAL(CDimStyleList)

	protected:
		//尺寸风格结构的链表
		CTypedPtrList< CPtrList, CDimStyle* >	m_StyleList;
		//当前尺寸风格的索引
		//CString m_iCurStyleIdx;
		int m_iCurStyleID;

	public:
		CDimStyleList()	;
		~CDimStyleList();
	
		
// Lg 2004-3-17 modified begin
/*		//初始化尺寸风格链
		//返回值：成功返回C_RT_SUCCESS，内存不足返回C_RT_OUTOFMEMORY
		int Init();

		//添加尺寸风格
		int AddStyle(CDimStyle* pStyle);
		//获得现有尺寸风格的数目
		int GetCount();

		//根据名称获得相应尺寸风格的指针
		//成功返回TRUE，失败(该尺寸风格不存在)返回FALSE
	    int GetStyleByName(const CString& sName, CDimStyle*& pStyle);

		//根据索引获得相应尺寸风格的指针
		//如果Index小于0，返回当前尺寸风格的指针
		int GetStyleByIndex(int Index, CDimStyle*& pStyle);

		//根据名称删除相应的尺寸风格
		//成功返回TRUE，失败(该尺寸风格不存在)返回FALSE
		int DelStyleByName(const CString& sName);

		//释放尺寸风格链
		void FreeDimStyList();

		//获得默认风格(第一个尺寸风格)的指针
		CDimStyle*	GetDefaultStyle();
*/	
	
		int GetCurStyleID();
		int SetCurStyleID(int i_iID);

		//添加风格(返回ID)
		int AddStyle(const CDimStyle& i_Style);
		//传入风格和链中风格比较，如果风格数据不同（除风格名与风格id外)
		//把传入风格加入风格链  返回ID
		int AddStyleByData(const CDimStyle& i_Style);
		//获得现有风格数目
		int GetCount();

		//删除链中的风格
		int DelStyle(const CString& i_sName);
		int DelStyleByID(int i_iID);
	//	int DelStyle(int i_iIndex);

		//查找风格
		int Find(const CString& i_sName);
		int FindByID(int i_iID);
		
		//更新风格
		int UpdateStyle(const CString& i_sName,const CDimStyle& i_Style);
		int UpdateStyleByID(int i_iID,const CDimStyle& i_Style);
	//	int UpdateStyle(int i_iIndex,const CDimStyle& i_Style);

		//得到风格
		int GetStyle(const CString& i_sName,CDimStyle& o_Style);
		int GetStyleByID(int i_iID,CDimStyle& o_Style);
	//	int GetStyle(int i_iIndex,CDimStyle& o_Style);
		
		//风格改名
		int RenameStyle(const CString& i_sOldName,const CString& i_sNewName);
	//	int RenameStyle(int i_iIndex,const CString& i_sNewName);
		int RenameStyleByID(int i_iID,const CString& i_sNewName);

		//初始化
		int Init();

		//设置当前默认风格
		int SetCurStyle(const CString& i_sName);
		int SetCurStyleByID(int i_iID);
		//int SetCurStyle(int i_iIndex);

		//得到当前默认风格
		int GetCurStyle(CDimStyle& o_Style);
		//得到当前风格名
		int GetCurStyleName(CString& o_sName);

		// 得到系统缺省风格
		int GetDefaultStyle(CDimStyle& o_Style);

		//得到索引对应的风格名
		int GetStyleName(int i_iIndex,CString& o_sName);
		//得到风格ID对应的风格名
		int GetStyleNameByID(int i_iID,CString& o_sName);

		//得到索引对应的风格ID
		int GetStyleID(int i_iIndex,int& o_iID);
		//得到风格名对应的风格ID
		int GetStyleID(const CString& i_sName,int& o_iID);

		virtual void Serialize( CArchive & ar );
};

/////////////////////////////////////////////////////////////////////
//公差类型定义
////////////////////////////////////////////////////////////////////
//公差基类
class AFX_EXT_CLASS CTol : public CObject
{
	DECLARE_SERIAL(CTol)
protected:
	short m_iOutForm;//输出形式0:代号 1:偏差 2:(偏差) 3:代号(偏差)
public:
	CTol();
	CTol(const CTol& i_Tol);
	virtual ~CTol();
	short GetOutForm()const;
	int SetOutForm(short i_iOutForm);
	
	virtual CTol* Copy()const;
	virtual int GetType()const;
	virtual void Serialize(CArchive& ar);
	virtual int GenTolText(const CDimStyle& i_Style,CString& o_sText)const;
};


class AFX_EXT_CLASS CDevTol:public CTol
{
	DECLARE_SERIAL(CDevTol)
protected:
	double m_dBasVal;
	double m_dUp;//上下偏差
	double m_dDown;
	
protected:
	int AttachTolText(const CDimStyle& i_Style,CString& o_sText)const;

public:
	CDevTol();
	CDevTol(const CDevTol& i_Tol);
	CDevTol(double i_dBasVal,double i_dUp,double i_dDown,short i_iOutForm);
	virtual ~CDevTol();
	
	double GetBasVal()const;
	int SetBasVal(double i_dVal);

	double GetUpDev()const;
	int SetUpDev(double i_dUp);

	

	double GetDownDev()const;
	int SetDownDev(double i_dDown);

	virtual CTol* Copy()const;
	virtual int GetType()const;
	virtual void Serialize(CArchive& ar);
	virtual int GenTolText(const CDimStyle& i_Style,CString& o_sText)const;
};


class AFX_EXT_CLASS CSymTol:public CDevTol
{
	DECLARE_SERIAL(CSymTol)
protected:
	CString  m_sSymbol;


public:
	CSymTol();
	CSymTol(const CSymTol& i_Tol);
	CSymTol(double i_dBasVal,const CString& i_sSymbol,double i_dUp,double i_dDown,short i_iOutForm);
	virtual ~CSymTol();
	

	CString GetSymbol()const;
	int SetSymbol(const CString& i_sSymbol);

	virtual CTol* Copy()const;
	virtual int GetType()const;
	virtual void Serialize(CArchive& ar);
	virtual int GenTolText(const CDimStyle& i_Style,CString& o_sText)const;
};


class AFX_EXT_CLASS CAssemTol: public CTol
{
	DECLARE_SERIAL(CAssemTol)
protected:
	double m_dBasVal;
	short m_iNorm;//基准 0: 基孔制 1: 基轴制
	CString  m_sHoleSym;
	CString m_sAxisSym;
	short  m_iAssemType;//配合类型 0:间隙 1:过渡 2: 过盈
	
public:
	CAssemTol();
	CAssemTol(const CAssemTol& i_Tol);
	CAssemTol(double i_dBasVal,short i_iNorm,const CString& i_sHoleSym,const CString& i_sAxisSym,
				short i_iAssemType,short i_iOutForm);
	virtual ~CAssemTol();

	double GetBasVal()const;
	int SetBasVal(double i_dVal);

	short GetNorm()const;
	int SetNorm(short i_iNorm);

	CString GetHoleSym()const;
	int SetHoleSym(const CString& i_sSym);

	CString GetAxisSym()const;
	int SetAxisSym(const CString& i_sSym);

	short GetAssemType()const;
	int SetAssemType(short i_iAssem);

	virtual CTol* Copy()const;
	virtual int GetType()const;
	virtual void Serialize(CArchive& ar);
	virtual int GenTolText(const CDimStyle& i_Style,CString& o_sText)const;
};

class AFX_EXT_CLASS CAngTol:public CTol
{
	DECLARE_SERIAL(CAngTol)
protected:
	int m_iUpDeg;
	int m_iUpMin;
	int m_iUpSec;
	int m_iDownDeg;
	int m_iDownMin;
	int m_iDownSec;
public:
	CAngTol();
	CAngTol(const CAngTol& i_Tol);
	CAngTol(int i_iUpDeg,int i_iUpMin,int i_iUpSec,int i_iDownDeg,int i_iDownMin,int i_iDownSec);
	virtual ~CAngTol();
	
	int GetUpDeg()const;
	int SetUpDeg(int i_iDeg);

	int GetUpMin()const;
	int SetUpMin(int i_iMin);

	int GetUpSec()const;
	int SetUpSec(int i_iSec);

	int GetDownDeg()const;
	int SetDownDeg(int i_iDeg);
	
	int GetDownMin()const;
	int SetDownMin(int i_iMin);
	
	int GetDownSec()const;
	int SetDownSec(int i_iSec);

	virtual CTol* Copy()const;
	virtual int GetType()const;
	virtual void Serialize(CArchive& ar);
	virtual int GenTolText(const CDimStyle& i_Style,CString& o_sText)const;
};
//CJL
// Lg 2004-3-9 修改尺寸类定义
/*class AFX_EXT_CLASS CDimension : public CGroup
{
	DECLARE_SERIAL(CDimension)
public:
	unsigned      char type;		//尺寸类型
	CString       text;			//尺寸文本值
	XYZ	      p13,p14;			//引出点
	XYZ	      p15,p16;			//引出点
	XYZ	      p10;			//尺寸线定位点
	double	      value;			//尺寸值
	double	      ang50;			//尺寸线角度
	double	      ang52;			//尺寸界线角度
	CString		  sStyName;			//尺寸线风格//CJL Add
public:
	CDimension();
	~CDimension() {};
	CDimension(unsigned char InitLtype,
	       unsigned char InitColor,
	       unsigned char InitLayer);
	virtual CBase*	Copy();
	virtual void	GenDisplayList();
	virtual void	Draw();
	virtual void	Draw(CDC *pDC);
	virtual void	Redraw();
	virtual void	Trans();
	virtual void	Serialize(CArchive& ar);
	virtual BOOL	IsWanted(long mask);
};*/

//标注基类
class AFX_EXT_CLASS CAnnotate : public CGroup
{
	DECLARE_SERIAL(CAnnotate)
protected:
	int m_iRefStyID;//引用的标注风格ID

public:
	CAnnotate();
	CAnnotate(const CAnnotate& i_Annotate);
	virtual ~CAnnotate();

	int GetRefStyID()const;
	int SetRefStyID(int i_iRefID);
	
	virtual int GetType()const;
	/////
	virtual CBase*	Copy();
	virtual void Serialize(CArchive& ar);

	virtual int Generate();
	virtual int GetSelfStyle(CDimStyle& o_Style);
	virtual int SetSelfStyle(const CDimStyle& i_Style);
	virtual void Refresh();	
};

//尺寸基类
class AFX_EXT_CLASS CDimension : public CAnnotate
{
	DECLARE_SERIAL(CDimension)
protected:
	double m_dVal;//标注的计算值
	CString m_sText;//标注文本
	XYZ m_LocPt;//定位点
	CTol* m_pTol;//公差
	BOOL m_bUserText;
	BOOL m_bTxtLeadLn;//文字是否有引出线
	XYZ m_TxtLocPt;//文本定位点
public:
	
	CDimension();
	CDimension(const CDimension& i_Dim);
	virtual ~CDimension();
	
public:
	CString GetText()const;
	int SetText(const CString& i_sText);
	
	XYZ GetLocPt()const;
	virtual int SetLocPt(const XYZ& i_LocPt);

	XYZ GetTxtLocPt()const;
	int SetTxtLocPt(const XYZ& i_TxtLocPt);

	double GetVal()const;
	int SetVal(double i_dValue);

	BOOL HasTxtLeadLn()const;
	int  SetTxtLeadLn(BOOL i_bTxtLeadLn);

	int SetTol(CTol* i_pTol);
	CTol* GetTol()const;

	int SetUserText(BOOL i_bUsrText);
	BOOL IsUserText()const;
public:
	virtual void Serialize(CArchive& ar);
	virtual int GetType()const;
	/////
	virtual CBase*	Copy();
	virtual void Trans();
	virtual BOOL	IsWanted(long mask);
	virtual int Generate();
	virtual void RegenText();
	virtual int GetSelfStyle(CDimStyle& o_Style);
	virtual int SetSelfStyle(const CDimStyle& i_Style);
	
	/////
};

//引出标注
class AFX_EXT_CLASS CDimLeader:public CDimension
{
	DECLARE_SERIAL(CDimLeader)
protected:
	XYZ m_SPt;//引出线起点
	XYZ m_MidFstPt;//第一中间点
	XYZ m_MidSndPt;//第二中间点
	XYZ m_EPt;//引出线末点
	BOOL m_bLeadLine;//有无引线
public:
	CDimLeader();
	CDimLeader(const XYZ& i_SPt,const XYZ& i_EPt,const XYZ& i_LocPt,
				const CString& i_sText,const CDimStyle& i_Style,
				BOOL i_bLeadLine=TRUE,CTol* i_pTol = NULL);
	/*CDimLeader(const XYZ& i_SPt,const XYZ& i_MidFstPt,const XYZ& i_MidSndPt,
				const XYZ& i_EPt,const XYZ& i_LocPt,double i_dVal,
				const CString& i_sText,const CDimStyle& i_Style,
				BOOL i_bLeadLine=TRUE,CTol* i_pTol = NULL);
	*/
	CDimLeader(const CDimLeader& i_Leader);
	virtual ~CDimLeader();
	
	XYZ GetStaPt()const;
	virtual int SetStaPt(const XYZ& i_Pt);

	XYZ GetEndPt()const;
	virtual int SetEndPt(const XYZ& i_Pt);

	XYZ GetMidFstPt()const;
	virtual int SetMidFstPt(const XYZ& i_Pt);

	XYZ GetMidSndPt()const;
	virtual int SetMidSndPt(const XYZ& i_Pt);

	
	BOOL HasLeadLine()const;
	int SetLeadLine(BOOL i_bLine);

	virtual int GetType()const;
	/////
	virtual CBase*	Copy();
	virtual void Trans();
	virtual void Serialize(CArchive& ar);
	virtual int Generate();
	//virtual int GetSelfStyle(CDimStyle& o_Style);
	//virtual int SetSelfStyle(const CDimStyle& i_Style);
	virtual int SetLocPt(const XYZ& i_LocPt);
};                                                                                                                                                                                                                                         

//倒角标注
class AFX_EXT_CLASS CDimChamfer:public CDimLeader
{
	DECLARE_SERIAL(CDimChamfer)

public:
	CDimChamfer();
	CDimChamfer(const CDimChamfer& i_Chamfer);
	CDimChamfer(const XYZ& i_SPt,const XYZ& i_EPt,const XYZ& i_LocPt,
				double i_dVal,const CString& i_sText,const CDimStyle& i_Style,BOOL i_bLeadLine=TRUE);
	virtual ~CDimChamfer();
	virtual CBase*	Copy();
	virtual int GetType()const;
	virtual int Generate();
	virtual void RegenText();
	
};

//锥度标注
class AFX_EXT_CLASS CDimTaper:public CDimLeader
{
	DECLARE_SERIAL(CDimTaper)
protected:
	int m_iSymbolDir;//符号方向
	int m_iQuadrant;//锥度符号所在象限
public:
	CDimTaper();
	CDimTaper(const CDimTaper& i_Tapper);
	CDimTaper(const XYZ& i_SPt,const XYZ& i_EPt,double i_dTxtAng,
			int i_iSymbolDir,int i_iQuad,BOOL i_bLeadLine,double i_dVal,
				const CString& i_sText,const CDimStyle& i_Style);
	virtual ~CDimTaper();

	int GetSymbolDir()const;
	int SetSymbolDir(int i_iDir);


	
	int GetQuadrant()const;
	int SetQuadrant(int i_iQuad);
	virtual CBase*	Copy();
	virtual void Serialize(CArchive& ar);
	virtual int GetType()const;
	virtual int Generate();
	virtual int GetSelfStyle(CDimStyle& o_Style);
	virtual int SetSelfStyle(const CDimStyle& i_Style);
	virtual int SetLocPt(const XYZ& i_LocPt);
	virtual int SetEndPt(const XYZ& i_Pt);
};

//斜度标注
class AFX_EXT_CLASS CDimPitch:public CDimTaper
{
	DECLARE_SERIAL(CDimPitch)
public:
	CDimPitch();
	CDimPitch(const CDimPitch& i_Pitch);
	CDimPitch::CDimPitch(const XYZ& i_SPt,const XYZ& i_EPt,double i_dTxtAng,
		int i_iSymbolDir, int i_iQuad,BOOL i_bLeadLine,double i_dVal,
		const CString& i_sText,const CDimStyle& i_Style);
	virtual ~CDimPitch();
	virtual CBase*	Copy();
	virtual int GetType()const;
	virtual int Generate();
};

//坐标标注
class AFX_EXT_CLASS CDimCoord:public CDimension
{
	DECLARE_SERIAL(CDimCoord)
protected:
	XYZ m_StaPt;//引出线起点
	XYZ m_UCSOrign;//用户坐标系原点
	double m_dUCSAng;//用户坐标相对世界坐标的旋转角	
public:
	CDimCoord();
	CDimCoord(const XYZ& i_StaPt,const XYZ& i_LocPt,const XYZ& i_UCSOri,
				double i_dUCSAng,double i_dVal,const CString& i_sText,
				const CDimStyle& i_Style,CTol* i_pTol = NULL);
	CDimCoord(const CDimCoord& i_Annt);
	virtual ~CDimCoord();

	XYZ GetStaPt()const;
	int SetStaPt(const XYZ& i_StaPt);
	
	XYZ GetUCSOrign()const;
	int SetUCSOrigin(const XYZ& i_Pt);

	double GetUCSAng()const;
	int SetUCSAng(double i_dAng);

	virtual int GetType()const;
	/////
	virtual CBase*	Copy();
	virtual void Trans();
	virtual void Serialize(CArchive& ar);
	virtual int Generate();
	virtual int SetLocPt(const XYZ& i_LocPt);
	
};

//对齐标注
class AFX_EXT_CLASS CDimOriAlign:public CDimCoord
{
	DECLARE_SERIAL(CDimOriAlign)
protected:
	XYZ m_AlignPt;//对齐点
public:
	CDimOriAlign();
	CDimOriAlign(const CDimOriAlign& i_Align);
	CDimOriAlign(const XYZ& i_AlignPt,const XYZ& i_StaPt,const XYZ& i_LocPt,
		const XYZ& i_UCSOri,double i_dUCSAng,double i_dVal,const CString& i_sText,
		int i_iDimline,int i_iArrow,const CDimStyle& i_Style,CTol* i_pTol = NULL);
	virtual ~CDimOriAlign();

	XYZ GetAlignPt()const;
	int SetAlignPt(const XYZ& i_AlignPt);

	virtual int GetType()const;
	virtual CBase* Copy();
	virtual void Trans();
	virtual void Serialize(CArchive& ar);
	virtual int Generate();
};

//原点标注
class AFX_EXT_CLASS CDimOrigin:public CDimCoord
{
	DECLARE_SERIAL(CDimOrigin)
protected:
	BOOL m_bBiText;//文本单双向
	
public:
	CDimOrigin();
	CDimOrigin(const CDimOrigin& i_Annt);
	CDimOrigin(const XYZ& i_StaPt,const XYZ& i_LocPt,BOOL i_bBiText,
		const XYZ& i_UCSOri,double i_dUCSAng,double i_dVal,const CString& i_sText,
		const CDimStyle& i_Style,CTol* i_pTol=NULL);
	virtual ~CDimOrigin();

	BOOL IsBiText()const;
	int SetBiText(BOOL i_bBiText);
	

	virtual int GetType()const;
	/////
	virtual CBase*	Copy();
	
	virtual void Serialize(CArchive& ar);
	virtual int Generate();
	virtual int SetLocPt(const XYZ& i_LocPt);
};

//孔位标注
class AFX_EXT_CLASS CDimHolePos : public CDimCoord
{
	DECLARE_SERIAL(CDimHolePos)
public:
	CDimHolePos();
	CDimHolePos(const CDimHolePos& i_Annt);
	CDimHolePos(const XYZ& i_StaPt,const XYZ& i_LocPt,const XYZ& i_UCSOri,
		double i_dUCSAng,double i_dVal,const CString& i_sText,
		const CDimStyle& i_Style);
	
	virtual ~CDimHolePos();
	virtual CBase*	Copy();
	virtual int GetType();
	virtual int Generate();
	virtual int SetLocPt(const XYZ& i_LocPt);
};

//坐标引出标注
class AFX_EXT_CLASS CDimCrdLeader : public CDimLeader
{
	DECLARE_SERIAL(CDimCrdLeader)
public:
	CDimCrdLeader();
	CDimCrdLeader(const XYZ& i_SPt,const XYZ& i_MidFstPt,const XYZ& i_MidSndPt,
				const XYZ& i_EPt,const XYZ& i_LocPt,double i_dVal,
				const CString& i_sText,const CDimStyle& i_Style,
				BOOL i_bLeadLine=TRUE,CTol* i_pTol = NULL);
	CDimCrdLeader(const CDimCrdLeader& i_Dim);
	virtual ~CDimCrdLeader();
	virtual int GetType()const;
	//virtual int Generate();
	virtual CBase*	Copy();
	virtual int Generate();
	virtual int SetLocPt(const XYZ& i_LocPt);
};

//线性尺寸
class AFX_EXT_CLASS CDimLinear : public CDimension
{
	DECLARE_SERIAL(CDimLinear)
protected:
	XYZ  m_DerivLPt;//左引出点
	XYZ  m_DerivRPt;//右引出点
//	XYZ  m_IntLPt;//边界线与尺寸线的左交点
//	XYZ  m_IntRPt;//边界线与尺寸线的右交点
//	BOOL  m_bContinues;//是否连续标注
	double  m_dDLAng;//尺寸线角度
	double  m_dBLAng;//尺寸界线角度

	int m_iDragTxtLoc;//拖动确定文字位置(冗余数据,不存盘)
	BOOL m_bEditLeadLn;//是否在编辑文字引线(冗余数据,不存盘)
public:
	
	CDimLinear();
	CDimLinear(const CDimLinear& i_Dim);
	CDimLinear(const XYZ& i_LPt,const XYZ& i_RPt,const XYZ& i_LocPt,double i_dBLAng,
					   double i_dDLAng,int i_iDragTxtLoc,double i_dVal,const CString& i_sText,
					   const CDimStyle& i_Style,CTol* i_pTol=NULL);

	virtual ~CDimLinear();
	
public:
	int GetDragTxtLoc()const;
	int SetDragTxtLoc(int i_iDragLoc);
	
	BOOL IsEditLeadLn()const;
	int SetEditLeadLn(BOOL i_bEdit);

	XYZ GetDerivLPt()const;
	int SetDerivLPt(const XYZ& i_LPt);

	XYZ GetDerivRPt()const;
	int SetDerivRPt(const XYZ& i_RPt);

	XYZ GetIntLPt()const;
	int SetIntLPt(const XYZ& i_LPt);

	XYZ GetIntRPt()const;
	int SetIntRPt(const XYZ& i_RPt);

//	BOOL IsContinues()const;
//	int SetContinues(BOOL i_bContinue);



	double GetDLAng()const;
	int SetDLAng(double i_dAng);

	double GetBLAng()const;
	int SetBLAng(double i_dAng);

public:
	virtual int SetLocPt(const XYZ& i_LocPt);
	virtual void	Trans();
	virtual CBase*	Copy();
	virtual void Serialize(CArchive& ar);
	virtual int GetType()const;
	virtual int Generate();
	virtual int GetSelfStyle(CDimStyle& o_Style);
	virtual int SetSelfStyle(const CDimStyle& i_Style);
	virtual void RegenText();
};

//两线夹角尺寸
class AFX_EXT_CLASS CDim2LnsAng : public CDimension
{
	DECLARE_SERIAL(CDim2LnsAng)
protected:
	XYZ m_LSPt;//第一条线起点
	XYZ m_LEPt;//第一条线末点
	XYZ m_RSPt;//第二条线起点
	XYZ m_REPt;//第二条线末点
	
public:
	
	CDim2LnsAng();
	CDim2LnsAng(const CDim2LnsAng& i_Dim);
	CDim2LnsAng(const XYZ& i_LSPt,const XYZ& i_LEPt,const XYZ& i_RSPt,
				const XYZ& i_REPt,const XYZ& i_LocPt,double i_dVal,
				const CString& i_sText,const CDimStyle& i_Style,CTol* i_pTol=NULL);

	virtual ~CDim2LnsAng();
	

public:
	
	XYZ GetLSPt()const;
	int SetLSPt(const XYZ& i_Pt);
	
	XYZ GetLEPt()const;
	int SetLEPt(const XYZ& i_Pt);

	XYZ GetRSPt()const;
	int SetRSPt(const XYZ& i_Pt);

	XYZ GetREPt()const;
	int SetREPt(const XYZ& i_Pt);



public:
	virtual int SetLocPt(const XYZ& i_LocPt);
	virtual CBase*	Copy();
	virtual void Trans();
	virtual void Serialize(CArchive& ar);
	virtual int GetType()const;
	virtual int Generate();
	virtual int GetSelfStyle(CDimStyle& o_Style);
	virtual int SetSelfStyle(const CDimStyle& i_Style);
};

//三点角度尺寸
class AFX_EXT_CLASS CDim3PtsAng : public CDimension
{
	DECLARE_SERIAL(CDim3PtsAng)
protected:
	XYZ m_TopPt;//顶点
	XYZ m_SPt;//起点
	XYZ m_EPt;//末点
	BOOL m_bArcLen;//是否弧长标注
	
public:
	CDim3PtsAng();
	
	CDim3PtsAng(const CDim3PtsAng& i_Dim);
	CDim3PtsAng(const XYZ& i_TopPt,const XYZ& i_SPt,const XYZ& i_EPt,
				const XYZ& i_LocPt,double i_dVal,
				const CString& i_sText,const CDimStyle& i_Style,
				BOOL i_bArcLen = FALSE,CTol* i_pTol=NULL);
	virtual ~CDim3PtsAng();

	
public:
	
	XYZ GetTopPt()const;
	int SetTopPt(const XYZ& i_Pt);

	XYZ GetSPt()const;
	int SetSPt(const XYZ& i_Pt);

	XYZ GetEPt()const;
	int SetEPt(const XYZ& i_Pt);

	BOOL IsArcLen()const;


public:
	virtual int SetLocPt(const XYZ& i_LocPt);
	virtual CBase*	Copy();
	virtual void Trans();
	virtual void Serialize(CArchive& ar);
	virtual int GetType()const;
	virtual int Generate();
	virtual int GetSelfStyle(CDimStyle& o_Style);
	virtual int SetSelfStyle(const CDimStyle& i_Style);
	virtual void RegenText();
};

//半径尺寸
class AFX_EXT_CLASS CDimRad : public CDimension
{
	DECLARE_SERIAL(CDimRad)
protected:
	XYZ  m_DimLPt;//尺寸线左端点
	XYZ  m_DimRPt;//尺寸线右端点
	XYZ  m_CenPt;//圆心点
	int m_iDragTxtLoc;//拖动确定文字位置(冗余数据,不存盘)
public:
	CDimRad();
	CDimRad(const CDimRad& i_Dim);
	CDimRad(const XYZ& i_LPt,const XYZ& i_RPt,const XYZ& i_LocPt,
			const XYZ& i_Cen,int i_iDragTxtLoc,double i_dVal,
			const CString& i_sText,const CDimStyle& i_Style,CTol* i_pTol=NULL);
	virtual ~CDimRad();

public:
	int GetDragTxtLoc()const;
	int SetDragTxtLoc(int i_iDragLoc);
	XYZ GetDimLPt()const;
	int SetDimLPt(const XYZ& i_Pt);
	
	XYZ GetDimRPt()const;
	virtual int SetDimRPt(const XYZ& i_Pt);

	XYZ GetCenPt()const;
	int SetCenPt(const XYZ& i_Pt);
public:
	virtual CBase*	Copy();
	virtual void Trans();
	virtual void Serialize(CArchive& ar);
	virtual int GetType()const;
	virtual int Generate();
	virtual int GetSelfStyle(CDimStyle& o_Style);
	virtual int SetSelfStyle(const CDimStyle& i_Style);
	virtual int SetLocPt(const XYZ& i_LocPt);
};

//直径尺寸
class AFX_EXT_CLASS CDimDia : public CDimension
{
	DECLARE_SERIAL(CDimDia)
protected:
	XYZ  m_DimLPt;//尺寸线左端点
	XYZ  m_DimRPt;//尺寸线右端点
	
	int m_iDragTxtLoc;//拖动确定文字位置(冗余数据,不存盘)
public:
	CDimDia();
	CDimDia(const CDimDia& i_Dim);
	CDimDia(const XYZ& i_LPt,const XYZ& i_RPt,const XYZ& i_LocPt,
			int i_iDragTxtLoc,double i_dVal,const CString& i_sText,
			const CDimStyle& i_Style,CTol* i_pTol=NULL);

	virtual ~CDimDia();
	
public:
	int GetDragTxtLoc()const;
	int SetDragTxtLoc(int i_iDragLoc);
	XYZ GetDimLPt()const;
	int SetDimLPt(const XYZ& i_Pt);
	
	XYZ GetDimRPt()const;
	int SetDimRPt(const XYZ& i_Pt);

	

public:
	virtual CBase*	Copy();
	virtual void Trans();
	virtual void Serialize(CArchive& ar);
	virtual int GetType()const;
	virtual int Generate();
	virtual int GetSelfStyle(CDimStyle& o_Style);
	virtual int SetSelfStyle(const CDimStyle& i_Style);
	virtual int SetLocPt(const XYZ& i_LocPt);
};

//半标注尺寸
class AFX_EXT_CLASS CDimHalf : public CDimLinear
{
	DECLARE_SERIAL(CDimHalf)
protected:
	double m_dExtLen;//尺寸线左端点伸出边界线长度
public:
	CDimHalf();
	CDimHalf(const CDimHalf& i_Dim);
	CDimHalf(const XYZ& i_LPt,const XYZ& i_RPt,const XYZ& i_LocPt,
		    double i_dBLAng, double i_dDLAng,double i_dExtLen,
			double i_dVal,const CString& i_sText,
			 const CDimStyle& i_Style,CTol* i_pTol=NULL);
	virtual ~CDimHalf();

public:
	
	double GetExtLen()const;
	int SetExtLen(double i_dLen);
public:
	virtual CBase*	Copy();
	virtual void Trans();
	virtual void Serialize(CArchive& ar);
	virtual int GetType()const;
	virtual int Generate();
	virtual void RegenText();
};

//射线标注尺寸
class AFX_EXT_CLASS CDimRay : public CDimension
{
	DECLARE_SERIAL(CDimRay)
protected:
	XYZ  m_SPt;//尺寸线左端点
	XYZ  m_EPt;//尺寸线右端点
	int m_iDragTxtLoc;//拖动确定文字位置(冗余数据,不存盘)
public:
	CDimRay();
	CDimRay(const CDimRay& i_Dim);
	CDimRay(const XYZ& i_SPt,const XYZ& i_EPt,const XYZ& i_LocPt,
		 int i_iDragTxtLoc,double i_dVal,const CString& i_sText,
		 const CDimStyle& i_Style,CTol* i_pTol=NULL);
	virtual ~CDimRay();
	
public:
	int GetDragTxtLoc()const;
	int SetDragTxtLoc(int i_iDragLoc);
	XYZ GetStaPt()const;
	int SetStaPt(const XYZ& i_Pt);
	
	XYZ GetEndPt()const;
	int SetEndPt(const XYZ& i_Pt);
public:
	virtual CBase*	Copy();
	virtual void Trans();
	virtual void Serialize(CArchive& ar);
	virtual int GetType()const;
	virtual int Generate();
	virtual int GetSelfStyle(CDimStyle& o_Style);
	virtual int SetSelfStyle(const CDimStyle& i_Style);
	virtual int SetLocPt(const XYZ& i_LocPt);
};

//大圆弧尺寸
class AFX_EXT_CLASS CDimBigArc : public CDimRad
{
	DECLARE_SERIAL(CDimBigArc)
protected:
	
	XYZ  m_MidFstPt;//第一转折点
	XYZ  m_MidSndPt;//第二转折点

public:
	CDimBigArc();
	CDimBigArc(const CDimBigArc& i_Dim);
	CDimBigArc(const XYZ& i_LPt,const XYZ& i_MidFPt,const XYZ& i_MidSPt,
			const XYZ& i_RPt,const XYZ& i_Cen,double i_dVal,
			const CString& i_sText,const CDimStyle& i_Style,CTol* i_pTol=NULL);
	virtual ~CDimBigArc();

public:
	XYZ GetMidFstPt()const;
	int SetMidFstPt(const XYZ& i_Pt);

	XYZ GetMidSndPt()const;
	int SetMidSndPt(const XYZ& i_Pt);
public:
	virtual CBase*	Copy();
	virtual void Trans();
	virtual void Serialize(CArchive& ar);
	virtual int GetType()const;
	virtual int Generate();
	virtual int GetSelfStyle(CDimStyle& o_Style);
	virtual int SetSelfStyle(const CDimStyle& i_Style);
	virtual int SetLocPt(const XYZ& i_LocPt);
	virtual int SetDimRPt(const XYZ& i_Pt);
};

//曲率半径尺寸
/*class AFX_EXT_CLASS CDimCurvat : public CDimRad
{
	DECLARE_SERIAL(CDimCurvat)
public :
	CDimCurvat();
	CDimCurvat(const CDimCurvat& i_Dim);
	virtual ~CDimCurvat();
public:
	virtual CBase*	Copy();
	virtual void Serialize(CArchive& ar);
	virtual unsigned char GetType();
};*/
// Lg 2004-3-9 end

//以下结构和宏定义用于读取原DOS版图库文件
typedef struct _oldbox //系统对BOX盒的定义
{
    XY  p1,p2;
}oldBOX;
union _buffer_value  //对系统缓冲区结点中成员value的定义
{
  double     vreal;
  XY    * vpoint;
  oldBOX      * vbox;
  int      vint;
  char     * vstring;
  long     vlong;
  void     * node;
};
typedef struct _buffer //系统对缓冲区结点的定义
{
  struct _buffer * next;
  int type;
  union  _buffer_value value;
}* BUFFER;
typedef struct  _node	 //对系统通用结点的定义
{
  BUFFER buffer;
  struct _node *child;
  struct _node *next;
}* NODE;
/////////////////////////////////////
// Lg 01-7-20 move it from dlg_tole.h
// 形位公差数据结构
typedef	struct	_tole
{
	int		nSymbol; // 公差代号
	int		nSi; // 球形符号
	int		nFi; // 直径符号
	int     nQz; //全周符号// Lg 01-4-20
	int     nKn; //可逆要求// Lg 01-4-20
//	char    szToleDimText[128];// Lg 2001-5-11
	char	szMainText[16]; // 公差数值
	int		nMainList1; // 公差数值相关原则
	int		nMainList2; // 被测要素形状限定
	char	szBaseText1[7]; // 基准一
	int		nBaseList1; // 基准一相关原则
	char	szBaseText2[7]; // 基准二
	int		nBaseList2; // 基准二相关原则
	char	szBaseText3[7]; // 基准三
	int		nBaseList3; // 基准三相关原则
} TOLE;
// Lg 01-7-20 move it from dlg_weld.h
// 焊接符号数据结构
typedef	struct	_weld
{
	int		nUpBasic; // 上基本符号
	int		nDnBasic; // 下基本符号
	int		nUpAuxiliary; // 上辅助符号
	int		nDnAuxiliary; // 下辅助符号
	int		nSupplement; // 补充符号
	int		nSpecial; // 特殊符号
	int		nDotLine; // 虚线位置
	char	szUpLText[17]; // 上左尺寸
	char	szDnLText[17]; // 下左尺寸
	char	szUpMText[17]; // 上中尺寸
	char	szDnMText[17]; // 下中尺寸
	char	szUpRText1[17]; // 上右尺寸一
	char	szDnRText1[17]; // 下右尺寸一
	char	szUpRText2[17]; // 上右尺寸二
	char	szDnRText2[17]; // 下右尺寸二
	char	szCaption[33]; // 焊接说明
	char	szUpSpace[9]; // 上交错焊缝间距
	char	szDnSpace[9]; // 下交错焊缝间距
} WELD;
// Lg 01-7-20 move it from dsn_weld.cpp
typedef	struct	_weldtxtlen
{
	double	dUpLText;	// 上左尺寸字串长度
	double	dDnLText;	// 下左尺寸字串长度
	double	dUpMText;	// 上中尺寸字串长度
	double	dDnMText;	// 上中尺寸字串长度
	double	dUpRText1;	// 上右尺寸一字串长度
	double	dDnRText1;	// 下右尺寸一字串长度
	double	dUpRText2;	// 上右尺寸二字串长度
	double	dDnRText2;	// 下右尺寸二字串长度
	double	dUpSpace;	// 上交错焊缝间距字串长度
	double	dDnSpace;	// 下交错焊缝间距字串长度
	double	dCaption;	// 焊接说明字串长度
	double	dX;			// "X"字串长度
}	WELDTXTLEN;
// Lg 01-7-20 move if from dlg_roug.h
// 粗糙度数据结构
typedef	struct	_rough
{
	int		nType; // 基本符号
	int		nVein; // 纹理方向
	BOOL	bSame; // 相同要求
	char	szUpValue[11]; // 上限值
	char	szDnValue[11]; // 下限值
	char	szUpCaption[31]; // 上说明
	char	szDnCaption[31]; // 下说明
} ROUGH;
// Lg 01-7-20 move it from dsn_roug.cpp
// 粗糙度文字长度数据结构
typedef	struct	_roughtxtlen
{
	double	dUpValue;	// 上限值字串长度
	double	dDnValue;	// 下限值字串长度
	double	dUpCaption;	// 上说明字串长度
	double	dDnCaption;	// 下说明字串长度
	double	dM;			// 纹理方向"X"、"M"、"C"、"R"、"P"字串长度
}	ROUGHTXTLEN;

//Zwz add/modify begin 2003-6-25
//颜色——线宽 映射信息
static unsigned char AutoCADColorMap[255]=
{ 8,9,18,12,28,15,47,43,45,8,0,8,0,24,16,24,
16,32,38,8,17,24,0,24,16,24,16,32,32,25,0,25,
0,33,42,33,16,32,16,25,1,25,1,41,42,33,42,33,
16,9,1,9,1,41,42,41,42,33,42,10,1,10,42,41,
42,41,42,34,34,10,2,10,42,41,42,26,42,34,34,18,
2,26,2,26,42,26,42,34,34,18,2,18,2,26,38,26,
38,34,34,11,2,11,2,26,44,26,44,34,35,3,3,3,
44,27,44,63,44,34,35,3,4,3,44,0,44,27,44,35,
35,12,4,12,4,19,44,19,44,35,35,5,4,13,4,19,
44,20,44,35,35,5,21,13,14,20,44,20,44,35,35,28,
21,29,14,20,14,36,44,37,37,28,21,29,21,29,14,36,
37,37,37,28,21,29,14,29,14,36,39,37,37,31,21,31,
14,39,14,39,38,37,37,31,7,31,14,30,14,39,38,38,
38,15,7,15,7,30,30,30,38,38,38,23,6,23,6,30,
16,22,16,38,38,23,6,23,6,22,16,22,16,32,16,8,
0,22,0,24,16,24,16,32,16,40,43,43,45,45,47 };

typedef struct AFX_EXT_CLASS tagColorLWPair
{
	enum MAPMETHOD
	{
		SYSLW = 0,
			DEFLW = 1
	};
	int			m_iAdColor;
	int			m_iEbColor;
	MAPMETHOD	m_enumMapMethod;
	int			m_iSysLW;	
	double		m_dDefLW;
	tagColorLWPair();
} COLORLWPAIR;

typedef struct AFX_EXT_CLASS tagColorLWMap
{
	COLORLWPAIR	 m_zColorLW[255];
	tagColorLWMap();
	void Serialize(CArchive &ar);
} COLORLWMAP;
//Zwz end 2003-6-25

////////////////////////////////////////////////////////////////////////////////////////

//从par_db.h中转移至此，ebbase中调用
//在def_par.cpp中实现-->base.cpp
class AFX_EXT_CLASS Tab_HeaderCell : public CObject
{
	DECLARE_SERIAL(Tab_HeaderCell)
public:
	Tab_HeaderCell(CString caption="",CString name="",CString tablename="",int width=0,int height=0,int datastyle=0,int datalength=0,short layer=0)
	{
		Caption=caption;
		Name=name;
		Width=width;
		Height=height;
		DataStyle=datastyle;
		DataLength=datalength;
		Layer=layer;
		TableName=tablename;
		ForeignName="";
		ForeignTable="";
		IDFlag=0;
		PCPFlag=0;
	};
	
public:
	CString Caption,Name,TableName,ForeignName,ForeignTable;
	int		Width,Height,DataStyle,DataLength,IDFlag,PCPFlag;
	CRect	CellRect,DlgRect;
	short Layer;
	virtual void Serialize(CArchive& ar);        // for native data
	Tab_HeaderCell *Copy();
};	
//在base.cpp中实现


typedef enum RelateTypeEnum {
	NULLFRAME	= 0,
	TOPLEFT		= 1,
	TOPRIGHT	= 2,
	BOTTOMLEFT	= 3,
	BOTTOMRIGHT	= 4
} RelTypeEnum;

class AFX_EXT_CLASS CTableCell : public CBlock
{
	DECLARE_SERIAL(CTableCell)
public:
	CTableCell(const CTableCell& i_TableCell);

	CTableCell( CString	i_sCaption = "",
				CString	i_sKey = "",
				CString	i_sTableName = "",
				double	i_dWidth = 0,
				double	i_dHeight = 0,
				int		i_iDatastyle = 0,
				int		i_iDatalength = 0,
				short	i_iLayer = 0,
				int		i_TxtStyle = 10000,
				BYTE	i_iTxtAlign = 5,//MIDDLE_CENTER
				double	i_dTxtHeight = 3.5*SysPaperScale,
				double	i_dTxtToLeftGap = 1.66
				);

	virtual ~CTableCell();

protected:
	CString		m_sCaption;			//在表头中的标题
	CString		m_sKey;				//数据库关联字段名(表格单元的名称)
	CString		m_sTableName;
	int			m_iDataStyle;		//表格单元的数据类型
	int			m_iDataLength;		//表格单元的数据长度

	double		m_dWidth;			//单元格的宽度
	double		m_dHeight;			//单元格的高度(仅对表头起作用)

	int			m_iRefTxtStyID;		//引用的文本风格ID
	double		m_dTxtHeight;		//文字字高
	BYTE		m_iTxtAlign;		//文字对齐方式
	double		m_dTxtToLeftGap;	//左对齐时表项文字与直线间隙
	short		m_iLayer;			//在表头中的层(仅对表头起作用)
	XYZ			m_Pt;				//左下角定位点，考虑作为中间数据不存储

	//颜色由风格控制，此处仅为生成表头时使用
	BYTE		m_ucTxtColor;			//文本颜色
	BYTE		m_ucLnColor;			//表头线颜色
	//unsigned long m_ulTxtColor;
	//unsigned long m_ulHeaderLnColor;

//////////////////////////////////////////////////////////////////////////
	double	m_dTxtToBothSideGap;		//文字与两侧竖线的间隙

//////////用途不清楚的，还没有加到存储中
public:
	CString		m_sForeignName;
	CString		m_sForeignTable;
	short		m_IDFlag;
	short		m_PCPFlag;
	//如果是中间计算数据，不存储
	CRect		CellRect,DlgRect;
	
public:

	CString	GetCellCaption();
	void	SetCellCaption(CString &i_sCaption);

	CString	GetCellKey();
	void	SetCellKey(CString &i_sKey);

	int		GetDataStyle();
	void	SetDataStyle(int i_iStyle);
	
	int		GetDataLength();
	void	SetDataLength(int i_iLength);

	double	GetCellWidth();
	void	SetCellWidth(double i_dWidth);

	double	GetCellHeight();
	void	SetCellHeight(double i_dHeight);

	//得到表头单元的文本风格ID
	int		GetRefTxtStyID()const;
	//设置表头单元的文本风格ID
	int		SetRefTxtStyID(int i_iStyleID);

	BYTE	GetTxtAlign();
	void	SetTxtAlign(BYTE i_Align);

	double	GetTxtHeight();
	void	SetTxtHeight(double i_dHeight);

	double	GetTxtToLeftGap();
	void	SetTxtToLeftGap(double i_dGap);

	short	GetCellLayer();
	void	SetCellLayer(short i_iLayer);

	CString	GetTableName();
	void	SetTableName(CString &i_sTableName);

	int		GetCellLocatePt(XYZ &o_Pt);
	void	SetCellLocatePt(XYZ* i_pPt);
	void	SetCellLocatePt(double i_dX, double i_dY, double i_dZ);

	short	GetCellIDFlag();
	int		SetCellIDFlag(short i_iFlag);

	short	GetCellPCPFlag();
	int		SetCellPCPFlag(short i_iFlag);

	//设置文本颜色BYTE
	int		SetTxtColorUC(BYTE i_ucColor);
	//设置线框颜色BYTE
	int		SetLnColorUC(BYTE i_ucColor);

	//得到文字与两侧竖线的间隙
	double	GetTxtToBothSideGap() const;
	
public:
	//生成单元格中的文字
	int GenCellTextByBox(CString Caption,BOX box);
	//生成显示链
	virtual int	Generate();
	//得到表头单元的文本风格
	CTxtStyle GetTxtStyle()const;
	//拷贝
	virtual CBase* Copy();
	//序列化
	virtual void Serialize(CArchive& ar);
};
	
class AFX_EXT_CLASS CBomStyle : public CStyle
{
	DECLARE_SERIAL(CBomStyle)
public:
	CBomStyle();
	CBomStyle(const CBomStyle& i_Style);
	virtual ~CBomStyle();
	
protected:
	CTypedPtrList <CPtrList, CTableCell*>	m_CellList;			//表头链
	CTypedPtrList <CPtrList, BYTE*>			m_TxtAlignList;		//对应明细栏文字对齐方式链

	double	m_dItemHeight;				//明细栏每行高度
	short	m_iIDColumn;				//序号列的位置，小于0表示不存在序号列
	
	int		m_iRefTxtStyID;				//引用的文本风格ID
	double	m_dTxtHeight;				//文字字高
	double	m_dTxtToLeftGap;			//左对齐时表项文字与直线间隙
	
	unsigned long m_ulTxtColor;			//文本颜色
	CString m_sTxtClrDes;				//文本颜色描述
	unsigned long m_ulVerLnColor;		//明细栏竖线颜色
	CString m_sVerLnClrDes;				//明细栏竖线颜色描述
	unsigned long m_ulHorLnColor;		//明细栏横线颜色
	CString m_sHorLnClrDes;				//明细栏横线颜色描述
	unsigned long m_ulHeaderLnColor;	//表头线颜色
	CString m_sHeaderLnClrDes;			//表头线颜色描述
	
	friend class CBomStyleList ;

//////////////////////////////////////////////////////////////////////////
	double	m_dTxtToBothSideGap;		//文字与两侧竖线的间隙
	BYTE	m_iTxtAlign;				//文字对齐方式

public:
	//初始化表头链
	int	InitCellList();
	//清空表头单元链
	int EmptyCellList();
	//清空表头文字对齐方式链
	int	EmptyTxtAlignList();
	//增加表头单元
	int AddCell(CTableCell *i_pCell, BYTE *i_pTxtAlign);
	
	//计算表头(明细表)的总宽度
	double	CalTotalWidth();
	//计算明细表的高度
	double	CalTotalHeight();
	
	//获得表头单元
	CTableCell* GetHeaderCellAt(const int i_iPos)const;
	//获得明细表单元
	CTableCell*	GetTableCellAt(const int i_iCurPos, BYTE **o_pTxtAlign)const;

	//获得表头单元的总数
	int GetHeaderCellNum()const;
	//获得明细表单元的总数
	int GetTableCellNum();

	//由表头链获得明细表项链(差别在于不含重量这一栏)
	int GetTableCellList(CTypedPtrList<CPtrList, CTableCell*> &o_TableCellList);
	//获得明细表表头链
	int GetHeaderCellList(CTypedPtrList<CPtrList, CTableCell*> &o_TableHeaderCellList);
	//设置明细表表头链
	int SetHeaderCellList(CTypedPtrList<CPtrList, CTableCell*> &i_TableHeaderCellList);
	//获得明细表表头文字对齐方式链
	int GetTxtAlignList(CTypedPtrList<CPtrList, BYTE*> &o_TxtAlignList);
	//设置明细表表头文字对齐方式链
	int SetTxtAlignList(CTypedPtrList<CPtrList, BYTE*> &i_TxtAlignList);
	
	
	void	CalCellLocatePt();
	CTableCell*	GetPreSiblingCell(CTableCell *Cur_Cell, POSITION i_Pos);
	
	//明细栏每行高度
	double	GetItemHeight()const;
	int		SetItemHeight(double i_dHeight);
	
	//得到表头的文本风格ID
	int		GetHeadRefTxtStyID()const;
	//设置表头的文本风格ID
	int		SetHeadRefTxtStyID(int i_iStyleID);
	
	//得到明细栏的文本风格ID
	int		GetRefTxtStyID()const;
	//设置明细栏的文本风格ID
	int		SetRefTxtStyID(int i_iStyleID);
	//得到明细栏文字字高
	double	GetTxtHeight()const;
	//设置明细栏文字字高
	int		SetTxtHeight(double i_dHeight);
	
	BYTE	GetTxtAlign()const;
	int		SetTxtAlign(BYTE i_Align);
	
	double	GetTxtToLeftGap()const;
	int		SetTxtToLeftGap(double i_dGap);
	//////////
	short	GetIDColumn()const;
	int		SetIDColumn(int i_iIdColumn);		//序号列的位置

	//文本颜色
	unsigned long GetTxtColor()const;
	int		SetTxtColor(unsigned long i_ulColor);
	//文本颜色描述
	CString	GetTxtColorDescrp()const;
	int		SetTxtColorDescrp(const CString& i_sDes);
	//明细栏竖线颜色
	unsigned long GetVerLnColor()const;
	int		SetVerLnColor(unsigned long i_ulColor);
	//明细栏竖线颜色描述
	CString	GetVerLnColorDescrp()const;
	int		SetVerLnColorDescrp(const CString& i_sDes);
	//明细栏横线颜色
	unsigned long GetHorLnColor()const;
	int		SetHorLnColor(unsigned long i_ulColor);
	//明细栏横线颜色描述
	CString	GetHorLnColorDescrp()const;
	int		SetHorLnColorDescrp(const CString& i_sDes);
	//表头线颜色
	unsigned long GetHeaderLnColor()const;
	int		SetHeaderLnColor(unsigned long i_ulColor);
	//表头线颜色描述
	CString	GetHeaderLnColorDescrp()const;
	int		SetHeaderLnColorDescrp(const CString& i_sDes);

	//得到文字与两侧竖线的间隙
	double	GetTxtToBothSideGap() const;
	
public:
	//初始化为默认值
	int Init();
	//得到明细栏的文本风格
	CTxtStyle GetTxtStyle()const;
	//赋值重载
	int operator =(const CBomStyle& i_Style);
	//拷贝
	CBomStyle* Copy();
	//序列化
	virtual void Serialize(CArchive& ar);
};

class AFX_EXT_CLASS CBomStyleList : public CStyle
{
	DECLARE_SERIAL(CBomStyleList)

	protected:
		//尺寸风格结构的链表
		CTypedPtrList< CPtrList, CBomStyle* >	m_StyleList;
		//当前尺寸风格的索引
		int m_iCurStyleID;

	public:
		CBomStyleList()	;
		~CBomStyleList();
	
	
		int GetCurStyleID();
		int SetCurStyleID(int i_iID);

		//添加风格(返回ID)
		int AddStyle(const CBomStyle& i_Style);
		//传入风格和链中风格比较，如果风格数据不同（除风格名与风格id外)
		//把传入风格加入风格链  返回ID
		int AddStyleByData(const CBomStyle& i_Style);
		//获得现有风格数目
		int GetCount();

		//删除链中的风格
		int DelStyle(const CString& i_sName);
		int DelStyleByID(int i_iID);
	//	int DelStyle(int i_iIndex);

		//查找风格
		int Find(const CString& i_sName);
		int FindByID(int i_iID);
		
		//更新风格
		int UpdateStyle(const CString& i_sName,const CBomStyle& i_Style);
		int UpdateStyleByID(int i_iID,const CBomStyle& i_Style);
	//	int UpdateStyle(int i_iIndex,const CBomStyle& i_Style);

		//得到风格
		int GetStyle(const CString& i_sName,CBomStyle& o_Style);
		int GetStyleByID(int i_iID,CBomStyle& o_Style);
	//	int GetStyle(int i_iIndex,CBomStyle& o_Style);
		
		//风格改名
		int RenameStyle(const CString& i_sOldName,const CString& i_sNewName);
	//	int RenameStyle(int i_iIndex,const CString& i_sNewName);
		int RenameStyleByID(int i_iID,const CString& i_sNewName);

		//初始化
		int Init();

		//设置当前默认风格
		int SetCurStyle(const CString& i_sName);
		int SetCurStyleByID(int i_iID);
		//int SetCurStyle(int i_iIndex);

		//得到当前默认风格
		int GetCurStyle(CBomStyle& o_Style);
		//得到当前风格名
		int GetCurStyleName(CString& o_sName);

		// 得到系统缺省风格
		int GetDefaultStyle(CBomStyle& o_Style);

		//得到索引对应的风格名
		int GetStyleName(int i_iIndex,CString& o_sName);
		//得到风格ID对应的风格名
		int GetStyleNameByID(int i_iID,CString& o_sName);

		//得到索引对应的风格ID
		int GetStyleID(int i_iIndex,int& o_iID);
		//得到风格名对应的风格ID
		int GetStyleID(const CString& i_sName,int& o_iID);

		virtual void Serialize( CArchive & ar );
};

class AFX_EXT_CLASS CPartnoStyle : public CStyle
{
	DECLARE_SERIAL(CPartnoStyle)
public:
	CPartnoStyle();
	CPartnoStyle(const CPartnoStyle& i_Style);
	virtual ~CPartnoStyle();
	
protected:
	short	m_iPartnoStyle;				//零件序号的样式
	int		m_iRefDimStyID;				//引用尺寸风格ID
	double	m_dTxtHeight;				//文字字高
	
	double	m_dHorLnMdlus;				//水平线宽度系数	3个字宽
	double	m_dXGapMdlus;				//水平排列间隙系数	1.5个字宽
	double	m_dYGapMdlus;				//垂直排列间隙系数	2个字高
	double	m_dTxtToLineMdlus;			//文字与零件序号水平线之间的间距系数
	double	m_dPartCirRMdlus;			//零件序号圈结点半径系数(与字体大小有关)
	double	m_dDotScale;				//圆点比例
	short	m_iRefPointOrArrow;			//圆点|箭头
///////////	
	int		m_iRefTxtStyID;				//引用的文本风格ID
	unsigned long m_ulTxtColor;			//文本颜色
	CString m_sTxtClrDes;				//文本颜色描述
	unsigned long m_ulRefLnColor;		//引线颜色
	CString m_sRefLnClrDes;				//引线颜色描述
	double	m_dArrowSize;				//零件序号的箭头大小	//比例
	
public:
	//得到零件序号的样式
	short	GetPartnoStyle()const;
	//设置零件序号的样式
	int		SetPartnoStyle(int i_iPartnoStyle);
	
	//得到相关尺寸风格ID
	int		GetRefDimStyID()const;
	//设置相关尺寸风格ID
	int		SetRefDimStyID(int i_iStyleID);

	//得到零件序号文字字高
	double	GetTxtHeight()const;
	//零件序号文字字高
	int		SetTxtHeight(double i_dHeight);

	//得到圆点比例
	double	GetDotScale()const;
	//设置圆点比例
	int		SetDotScale(double i_dScale);
	
	//得到引出位置的 圆点|箭头
	short	GetRefPointOrArrow()const;
	//设置引出位置的 圆点|箭头
	int		SetRefPointOrArrow(int i_iRefPtOrAr);

	//得到水平线的长度
	double	GetHorLnLength()const;
	//得到水平排列间隙
	double	GetXGap()const;
	//得到垂直排列间隙
	double	GetYGap()const;
	//得到文字与零件序号水平线之间的间距
	double	GetTxtToLineGap()const;
	//得到零件序号圈结点半径
	double	GetPartCirRadius()const;

//////////	
	//得到零件序号文本颜色
	unsigned long GetTxtColor()const;
	//得到零件序号文本颜色描述
	CString	GetTxtColorDescrp()const;
	//得到零件序号引线颜色
	unsigned long GetRefLnColor()const;
	//得到零件序号引线颜色描述
	CString	GetRefLnColorDescrp()const;

	//得到相关尺寸风格的箭头大小
	double	GetScaledArrowSize()const;
	//得到相关尺寸风格的文本风格ID
	int		GetRefTxtStyID()const;
	
public:
	//初始化为默认值
	int Init();
	//得到明细栏的文本风格
	CTxtStyle GetTxtStyle()const;
	//赋值重载
	int operator =(const CPartnoStyle& i_Style);
	//拷贝
	CPartnoStyle* Copy();
	//序列化
	virtual void Serialize(CArchive& ar);
};

class AFX_EXT_CLASS CTableItem : public CObject
{
	DECLARE_SERIAL(CTableItem)
protected:
	CStringArray	m_ItemArray;		//明细栏内容
	short			m_iIsDisplayed;		//是否在明细表中显示
	short			m_iPartOrCom;		//零件或部件信息；零件为0，部件为1
	
	friend class CBomTable;
	
public:
	CTableItem();
	CTableItem(const CTableItem& i_Item);
	virtual void Serialize(CArchive& ar);
	
	//获得部件信息
	short	GetComponentInfo() const;
	//设置部件信息
	int		SetComponentInfo(int i_iPartOrCom);
	//获得显示信息
	short	GetDisplayInfo() const;
	//设置显示信息
	int		SetDisplayInfo(int i_iDisplayed);
	//获得明细栏内容
	int		GetItemArray(CStringArray& o_ItemString);	//bExcelFlag不为零时，挖掉表头中sKey为空的对应项
	//设置明细栏内容
	int		SetItemArray(CStringArray& i_ItemString);
	//获得内容字符串数组的大小
	int		GetItemArraySize();
};

class AFX_EXT_CLASS CBomTable : public CGroup 
{
	DECLARE_SERIAL(CBomTable)
public:
	CBomTable();
	CBomTable(int i_iStyleID);
	CBomTable(const CBomTable& i_BomTable);
	virtual ~CBomTable();

protected:
	int		m_iRefStyID;			//引用的明细表风格ID

	RelTypeEnum	m_enRelType;		//表的定位方式
	XYZ		m_BrkPt;				//折行起点
	XYZ		m_LocPt;				//定位点；输出时表的位置不依赖于图框，需要设置一系列的位置信息

	CArray <int, int> m_BreakLns;	//折行
	short	m_iBreakDir;			//折行方向：左折 1；右折 -1

	CTypedPtrArray <CPtrArray, CTableItem*>	m_aContent;		//明细栏的内容

	//中间计算数据
	double	m_dTabHeadHeight;		//明细表表头高度
	double	m_dTabHeadWidth;		//明细表表头宽度
	double	m_dTabItemHeight;		//明细栏每行高度
	short	m_iIDColumn;			//序号列的位置，小于0表示不存在序号列
	short	m_iTabCellNum;			//明细表单元格数

//	double	m_dRecHeight;			//明细栏每行高度
//	int		m_TxtStyle;				//文字风格
//	BYTE	m_iTxtAlign;			//文字对齐方式
//	double	m_dTxtHeight;			//文字字高
//	double	m_dTxtToLeftGap;		//左对齐时表项文字与直线间隙(系数)
//	int		m_iDirect;				//表的生成方向------------??
//	CTableHeader	*m_pHeader;		//明细表表头
	
public:
	virtual CBase* Copy();
	virtual BOOL IsWanted(long mask);
	virtual void Trans();
	virtual int	Generate();			//生成显示链
	virtual void Serialize(CArchive& ar);

	//计算中间数据
	int CalCacheData();

	void	AddPartToBom(CTableItem* i_pContent);
	int		DelPartFromBom(int i_iRow);
	int		AddItemIntoTable(const CString i_sPart,const CString i_sBlkstring,int i_iPosition,
							short i_iDisplayed = TRUE, short i_iPartOrCom = FALSE);

	//在指定位置插入空行
	int		InsertEmptyLn(int i_iPosition);
	
	//得到明细表的行数
	int		GetTableNumber();
	//根据位置得到明细表的内容
	int		GetTableContent(int i_iPos, CTableItem& o_Item);
	//根据位置设置明细表的内容
	int		SetTableContent(int i_iPos, CTableItem& i_Item);

	//根据风格生成表头
	int		GenTableHeader(const CBomStyle& i_Style);
	//改变左右边界线的线形
	int		ChangeCellLineType(CTableCell **i_ppCell,BOX box);
	//翻转标题栏
	int		ReverseTableHeader(CGroup *i_pHeader);
	//翻转表头单元格
	void	ReverseTableHeaderCell(CTableCell **i_ppCell,BOX BlkBox);
	
	//计算从原点到定位点的的距离
	XYZ		CalDeltLocation(CGroup *i_pHeader, BOOL i_Trans = FALSE);
	//XYZ	MoveTableHeader(XYZ *i_pDeltPt,BOOL	i_Trans = FALSE);

	//得到自身的风格
	int		GetSelfStyle(CBomStyle& o_Style);
	//更新自身的风格
	int		SetSelfStyle(CBomStyle& i_Style);
	//获得明细表依赖于图框的位置关系
	int		GetRelateType();
	//设置明细表依赖于图框的位置关系
	void	SetRelateType(RelTypeEnum i_enRelType);	//表的定位方式
	//得到明细表的水平生成方向:1为向左，-1为向右
	short	GetTabHDirect();
	//得到明细表的垂直生成方向:1为向上，-1为向下
	short	GetTabVDirect();

	//得到折行方向
	short	GetBreakDir();
	//设置折行方向
	void	SetBreakDir(const int i_iShort);
	//设置折行点（同方向增加，反方向修改或删除）
	void	SetBreakLines(int i_iBrkPos, const short i_iBrkDir);
	//清除所有折行
	void	EmptyBreakLines();

	//生成明细栏
	int		GenTableItem(CTableItem* i_pArray, int i_iPosition, CBomStyle& i_Style);
	//获得新零件的插入位置
	int		GetInsertPosOfNewPart(CString i_sPart);//int GetItemPosition(CString i_sPart);
	//根据明细栏在表中的位置得到它的行和列
	int		GetItemRowAndColByPos(const int i_iPosition, int& o_iRow, int& o_iColumn);

	//根据指针得到在表中的位置，位置从1开始计算，拾取到表头返回0
	int		GetPosOfTableLn(CGroup* i_pTabgroup);
	//根据位置得到所在的列，从0开始计算
	int		GetTabColumn(int i_iPosition);
	//根据位置得到所在的行，从0开始计算
	int		GetTabRow(int i_iPosition);
	//计算从起始位置到结束位置之间的不被显示的行数
	int		CalcuHideRowNumber(int i_iStartPos, int i_iEndPos);
		
	int		DrawItemLine(int i_iRow, CBomStyle& i_Style, CGroup* o_pGroup);

	int		AddGroupText(CString i_sPart, int i_iCell, const CBomStyle& i_Style, CGroup* o_pGroup);
	int		GenTableText(XYZ& i_Pt, double i_dWidth, CString i_sPart,  const CBomStyle& i_Style,
						BYTE* i_pTxtAlign, CGroup* o_pGroup);

	//设置定位点与折行点等位置信息
	void	SetLocationInfo(XYZ& i_LocPt, XYZ& i_BrkPt, RelTypeEnum i_eRelType);
	//获得定位点与折行点等位置信息
	void	GetLocationInfo(XYZ* o_pLocPt, XYZ* o_pBrkPt, RelTypeEnum* o_eRelType);

	//获得中间计算的数据
	double	GetTabHeadHeight() const;
	double	GetTabHeadWidth() const;
	double	GetTabItemHeight() const;
	short	GetTabCellNum() const;
	short	GetIDColumn() const;	//序号列的位置
	//void	SetIDColumn(int i_iIdColumn);	
	//////////
	//不再需要的函数,统一修改
	XYZ		CalLocationPt(CTypedPtrList<CPtrList,CBase*>& i_Select);
	//int		SetCellValue(CString i_sPart, CGroup * o_pGroup, int i_iCell=0);
	//void	DrawTableHeader();
	//CTableHeader* GetTabHeader();
	//int		GetHeaderCellNum();
	
	//short	GetHeaderDir();
	//void	SetHeaderDir(int i_iHeaderDir);		//表头的生成方向
};

//PQ Add 2004,8,19 背景图片信息
typedef struct AFX_EXT_CLASS BkgData{
	XYZ LeftTopPt;
	XYZ RightBottomPt;
	CString  bkgpath;
}BKGDATA;
//PQ
#endif



//End Dm.h Define
