////////////////////////////////////////////////////////////////////////////// //文件 Rect8.h ///////////////////////////////////////////////////////////////////////////// #pragma once #ifndef AFX_EXT_CLASS #define AFX_EXT_CLASS Q_DECL_IMPORT #endif #include "Point2D.h" namespace GBase { class AFX_EXT_CLASS CRect8 { public: CRect8(void); // (left, top, right, bottom)格式字符串 explicit CRect8(CString strVal); CRect8(double left, double top, double right, double bottom); //#ifdef _QT_VERSION // CRect8( DF_Rect& rect); //#endif ~CRect8(void); virtual void Serialize(CArchive& ar, const short &ver); void SetRect(double left, double top, double right, double bottom); void SetRect(const CPoint2D& TopLeft, const CPoint2D& RightBottom); double Width(void); double Height(void); CSize8 GetSize(void); void SetOne(void); void ToInt(CRect& rect); bool operator==(const CRect8& rt); void operator= (const CRect8& rt); void operator= (CRect& rt); void operator*=(double sv); bool PtInRect(const CPoint2D& point); bool PtInRect(double x, double y); virtual bool RtInRect(CRect8& rect); //判断由指定坐标点组成的曲线是否在Rect范围内 bool IsInRange(double* x, double* y, int num); bool ContainRect(CRect8& rect); CPoint2D TopLeft(void); CPoint2D BottomRight(void); CPoint2D CenterPoint(void); void CombinRect(const CRect8& rect); void CombinRect(double xmin, double ymin, double xmax, double ymax); void CombinPoint(double x, double y); void CombinPoint(const CPoint2D& point); void Empty(void); bool IsEmpty(void); void InflateRect(double x, double y); void DeflateRect(double x, double y); void InflateRect(double l, double t, double r, double b); void DeflateRect(double l, double t, double r, double b); void IntersectRect(CRect8& rect); void RotateRect(double x0, double y0, double angle); void OffsetRect(double dx, double dy); void NormalizeRect(void); virtual void ScaleCoor(double xs,double ys,double dx,double dy); virtual void ExchangeXY(void); //交换XY坐标 virtual void Serialize(CArchive& ar); // void Write(CDFile& fw); // int Read(CDFile& fr); //判断两个矩形是否相交 bool IsIntersected(CRect8& other); public: double left,right,top,bottom; }; }; using namespace GBase;