Domain.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #pragma once
  2. #include "XMLSerialization.h"
  3. namespace OTSDATA {
  4. // domain shape
  5. typedef enum class __declspec(dllexport) DOMAIN_SHAPE
  6. {
  7. INVALID = -1,
  8. MIN = 0,
  9. ROUND = 0,
  10. POLYGON = 15,
  11. RECTANGLE = 1,
  12. MAX = 1
  13. } DOMAIN_SHAPE;
  14. __declspec(dllexport) const int DOMAIN_ITEM_NUMBER = 5;
  15. // CDomain command target
  16. class __declspec(dllexport) CDomain : public xmls::ISlo
  17. {
  18. /*protected:
  19. DECLARE_SERIAL(CDomain)*/
  20. public:
  21. // constructor
  22. CDomain(); // constructor
  23. CDomain(DOMAIN_SHAPE a_nShape, CRect a_rectRegion); // constructor
  24. CDomain(const CDomain&); // copy constructor
  25. CDomain(CDomain*); // copy constructor
  26. CDomain& operator=(const CDomain&); // =operator
  27. BOOL operator==(const CDomain&); // ==operator
  28. virtual ~CDomain(); // destructor
  29. // serialization
  30. //void Serialize(CArchive& ar);
  31. // validation check
  32. virtual BOOL IsInvalid() const;
  33. // check if it is empty
  34. BOOL IsEmpty() { return m_rectDomain.IsRectEmpty(); }
  35. // check if this is a round domain
  36. BOOL IsRound() const { return m_nShape == DOMAIN_SHAPE::ROUND; }
  37. // check if this is a rectangle domain
  38. BOOL IsRect() const { return m_nShape == DOMAIN_SHAPE::RECTANGLE; }
  39. // domain center
  40. CPoint GetDomainCenter() const { return m_rectDomain.CenterPoint(); }
  41. void OffsetDomain(CPoint a_poiMove) { m_rectDomain += a_poiMove; }
  42. // diameter
  43. long GetDiameter() const { return m_rectDomain.Width(); }
  44. // rectangle
  45. CRect GetDomainRect() const { return m_rectDomain; }
  46. void SetDomainRect(const CRect& a_rect) { m_rectDomain = a_rect; }
  47. // sharp
  48. DOMAIN_SHAPE GetShape() const { return m_nShape; }
  49. void SetShape(const DOMAIN_SHAPE a_nShape) { m_nShape = a_nShape; }
  50. // PolygonPoint
  51. std::vector<CPoint> GetPolygonPoint() const { return m_PolygonPoint; }
  52. void SetPolygonPoint(const std::vector<CPoint>& a_PolygonPoint) { m_PolygonPoint = a_PolygonPoint; }
  53. // check if have common area with the given domain
  54. BOOL IntersectDomain(const CDomain& a_oDomain);
  55. // check if the point in the domain
  56. BOOL PtInDomain(const CPoint& a_poiCheck) const;
  57. // check if the given domain is in the domain
  58. BOOL DomainInDomain(const CDomain& a_oDomain);
  59. virtual void Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode);
  60. //virtual void Deserialize(Slo * classItem, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode);
  61. protected:
  62. // cleanup
  63. void Cleanup();
  64. // initialization
  65. void Init();
  66. // duplication
  67. void Duplicate(const CDomain& a_oSource);
  68. // sharp
  69. DOMAIN_SHAPE m_nShape;
  70. // area
  71. CRect m_rectDomain;
  72. std::vector<CPoint> m_PolygonPoint;
  73. };
  74. typedef std::shared_ptr<CDomain> __declspec(dllexport) CDomainPtr;
  75. typedef std::vector<CDomainPtr> __declspec(dllexport) CDomainsList;
  76. }