OTSRect.h 867 B

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. namespace OTSDATA
  3. {
  4. class __declspec(dllexport) COTSRect
  5. {
  6. public:
  7. COTSRect();
  8. COTSRect(int left, int top, int right, int bottom);
  9. COTSRect(CPoint leftTop, CPoint bottomRight);
  10. BOOL operator==(const COTSRect&); // ==operator
  11. void SetRectData(int left, int top, int right, int bottom);
  12. bool PointInRect(CPoint p);
  13. bool IntersectOtherRect(COTSRect r);
  14. CPoint GetTopLeft() { return CPoint(m_left, m_top); }
  15. CPoint GetBottomRight() { return CPoint(m_right, m_bottom); }
  16. int GetWidth() { return (m_right - m_left); }
  17. int GetHeight() { return (m_top - m_bottom); }
  18. CPoint GetCenterPoint() { double w = GetWidth(); double h = GetHeight(); CPoint lt = GetTopLeft(); return CPoint(lt.x + w / 2, lt.y - h / 2); }
  19. virtual ~COTSRect(); // detractor
  20. private :
  21. int m_left;
  22. int m_top;
  23. int m_right;
  24. int m_bottom;
  25. };
  26. }