QBaseObj.h
资源名称:QGIS.rar [点击查看]
上传用户:oybseng
上传日期:2015-04-27
资源大小:7831k
文件大小:7k
源码类别:
GDI/图象编程
开发平台:
Visual C++
- // QBaseObj.h: interface for the CQBaseObj class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_QBASEOBJ_H__85C41B71_9C1A_4072_9688_328E9CA6E462__INCLUDED_)
- #define AFX_QBASEOBJ_H__85C41B71_9C1A_4072_9688_328E9CA6E462__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- class CQCoordSys;
- enum enumQObjType
- {
- QGIS_UNKNOW = 0,
- QGIS_POINT, //点
- QGIS_LINE, //线
- QGIS_AREA, //区
- QGIS_LABEL, //文本
- QGIS_CIRCLE //圆
- };
- //自定义点坐标类
- //用于存放一个点位坐标值
- //////////////////////////////////////////
- ///***************CQGIS****************///
- ///类 名:CQPoint
- ///基 型:无
- ///说 明:点位坐标类
- ///***************CQGIS****************///
- //////////////////////////////////////////
- class AFX_EXT_CLASS CQPoint : public CObject
- {
- public:
- CQPoint();
- CQPoint(const CQPoint & pt); //拷贝构造
- CQPoint(double dx,double dy);
- void Copy(const CQPoint & pt); //点对象坐标值拷贝
- virtual ~CQPoint(){}; // 析构函数
- inline double GetX() const;
- inline double GetY() const;
- void SetPoint(double dx,double dy);
- CQPoint & operator = (CQPoint & pt); //对点进行赋值
- BOOL operator == (CQPoint & pt ); //判断两个点是否相等
- //BOOL operator == (CQPoint & pt1,CQPoint & pt2); // 属于类的而不是对象
- BOOL operator !=(CQPoint & pt);
- double Distance(CQPoint & pt); //计算两点之间的距离
- double Distance(double dx,double dy);
- double Distance(CQPoint & pt1,CQPoint & pt2); //点到直线的距离
- double YAxisDistance(CQPoint & pt);
- double XAxisDistance(CQPoint & pt);
- static double Distance(CQPoint & pt,CQPoint & pt1,CQPoint & pt2); // 点到直线的距离计算
- static double Distance(CQPoint & pt,double xx,double yy); // 两点之间的距离
- static double Distance(double x1,double y1,double x2,double y2); // 两点之间的距离
- static double DistanceHasFlag(CQPoint & pt1,CQPoint & pt2);
- BOOL PtInLine(CQPoint & pt1,CQPoint & pt2); //判断点是否在直线上
- static BOOL PtInLine(CQPoint & pt,CQPoint & pt1,CQPoint & pt2);
- short OrientationPtToPt(CQPoint & pt);
- static short OrientationPtToPt(CQPoint & pt1,CQPoint & pt2);
- DECLARE_SERIAL(CQPoint);
- virtual void Serialize(CArchive& ar);
- virtual void WriteToFile(CFile * pfile);
- virtual void ReadFromFile(CFile * pfile);
- void Move(double dx,double dy);
- void SetX(double dx);
- void SetY(double dy);
- protected:
- double m_fx;
- double m_fy;
- };
- //外接矩形类,用于表示几何对象的边界矩形
- //////////////////////////////////////////
- ///***************CQGIS****************///
- ///类 名:CBoundaryRect
- ///基 型:无
- ///说 明:图元的边界矩形类
- ///***************CQGIS****************///
- //////////////////////////////////////////
- class AFX_EXT_CLASS CBoundaryRect :public CObject // 对象的边界矩形对象
- {
- public:
- CBoundaryRect();
- CBoundaryRect(CBoundaryRect & Box);
- virtual ~CBoundaryRect(); //析构函数
- void Copy(CBoundaryRect & Box);
- BOOL PtInRect(CQPoint & pt);
- void SetRect(double fMinx,double fMinY,double fMaxX,double fMaxY);
- CQPoint CenterPoint(); //计算矩形的中心点
- BOOL IsValid(); // 判断边界矩形是否有效
- inline void Offset(CQPoint & pt); //矩形沿点偏移
- inline void Offset(double dx,double dy);
- CBoundaryRect & operator = (CBoundaryRect & Box);
- CBoundaryRect * UnionBoundary(CBoundaryRect * pBox); // 求两个矩形的最小边界矩形
- void Union(CBoundaryRect * pRect);
- CBoundaryRect * Cutout(CBoundaryRect * pBox); // 矩形的裁剪
- BOOL IsCross(CBoundaryRect * pBox); // 判断矩形是否相交
- inline double GetLeftBottomX();
- void SetLeftBottomX(double lx);
- inline double GetLeftBottomY();
- void SetLeftBottomY(double ly);
- inline double GetRightTopX();
- void SetRightTopY(double ry);
- inline double GetRightTopY();
- void SetRightTopX(double rx);
- double Width();
- double Height();
- DECLARE_SERIAL(CBoundaryRect);
- virtual void Serialize(CArchive & ar);
- CString VarToStr();
- virtual void WriteToFile(CFile * pFile);
- virtual void ReadFromFile(CFile * pFile);
- void Lager(double dStep);
- void Smaller(double dStep);
- public:
- double m_fMinX;
- double m_fMinY;
- double m_fMaxX;
- double m_fMaxY;
- };
- //////////////////////////////////////////
- ///***************CQGIS****************///
- ///类 名:CQBaseObj
- ///基 型:CObject
- ///说 明:所有图元对象的基类
- ///***************CQGIS****************///
- //////////////////////////////////////////
- class AFX_EXT_CLASS CQBaseObj : public CObject
- {
- public:
- CQBaseObj(); // 默认构造函数
- CQBaseObj(const CQBaseObj & tmObj); //拷贝构造
- virtual void Copy(const CQBaseObj & tmObj); // 对象的复制 虚函数
- virtual ~CQBaseObj();
- // 基本图元操作
- inline void SetObjID(long &);
- inline long GetObjID() const;
- void SetObjName(CString & szName);
- inline CString GetObjName() const;
- void SetObjLayerID(const long & lLayerID);
- inline long GetObjLayerID() const;
- void SetObjMapID(const long & lMapID);
- inline long GetObjMapID() const;
- void SetobjLineType(short & nLineType);
- inline short GetObjLineType() const;
- void SetObjPenColor(COLORREF & crPen);
- inline COLORREF GetObjPenColor() const;
- void SetObjBrushColor(COLORREF & brcolor);
- inline COLORREF GetObjBrushColor() const;
- void SetObjLineWidth(double & fLineWidth);
- inline double GetObjLineWidth() const;
- inline void SetObjType(short &);
- inline short GetObjType() const;
- void SetObjDeleted(BOOL bDeleted);
- inline BOOL GetObjDeleted() const;
- void SetObjHided(BOOL bHided);
- inline BOOL GetObjHided() const;
- void SetObjSelected(BOOL bSelected);
- inline BOOL GetObjSeleted() const;
- //其他操作
- virtual void Serialize(CArchive& ar);
- static void Rotate(CQPoint * ptR,CQPoint & ptO,double & fAngleDegree);
- virtual void Move(double dx,double dy) = 0;
- virtual void Rotate(CQPoint & pt,double & fAngleDegree) = 0;
- virtual void GetBoundingRect(CBoundaryRect * pRect) = 0;
- virtual void CalculateBoundary(CBoundaryRect * pRect = 0) = 0;//计算图元的边界矩形
- virtual BOOL Select(CQCoordSys * pSys,CQPoint & pt, double fEffectDistance) = 0; //点选
- virtual BOOL Select(CQCoordSys * pSys,CBoundaryRect & rect) = 0; //框选
- virtual void Display(CQCoordSys * pSys,CDC * pDC,int nDrawMode,int nSpecialMode,COLORREF * pColor) = 0;
- // 所有图元x坐标的按照中心点x坐标和缩放倍数缩放,dFlex>1会放大,dFlex<1会缩小
- virtual void XFlex(double dcp_x,double dFlex)=0;
- // 所有图元y坐标的按照中心点y坐标和缩放倍数缩放,dFlex>1会放大,dFlex<1会缩小
- virtual void YFlex(double dcp_x,double dFlex)=0;
- virtual void WriteToFile(CFile * pFile);
- virtual void ReadFromFile(CFile * pFile);
- virtual CString VarToStr(); //将图元的值转换为字符串格式
- private:
- long SetObjIndex();
- long SetObjIDByRand();
- protected:
- //图元基类属性
- long m_lObjID; //图元对象的唯一标识号
- long m_lLayerID; //图元所在图层的唯一识别号
- long m_lMapID; //图元所在的图幅的唯一识别号
- CString m_szObjName; //图元名称
- COLORREF m_crPenColor; //边框颜色 线条颜色
- COLORREF m_crBrushColor; //填充颜色 实体颜色
- double m_fLineWidth; //图元的线条宽度,单位为毫米
- short m_nLineType; //图元线型
- short m_nObjType; //图元对象的类型1- 点 2 - 线 3 - 面
- BOOL m_bDeleted; //图元的删除状态
- BOOL m_bHided; //图元的显示状态
- BOOL m_bSelected; //图元的选择状态
- };
- #endif // !defined(AFX_QBASEOBJ_H__85C41B71_9C1A_4072_9688_328E9CA6E462__INCLUDED_)