Domain.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. public:
  19. // constructor
  20. CDomain(); // constructor
  21. CDomain(DOMAIN_SHAPE a_nShape, CRect a_rectRegion); // constructor
  22. CDomain(const CDomain&); // copy constructor
  23. CDomain(CDomain*); // copy constructor
  24. CDomain& operator=(const CDomain&); // =operator
  25. BOOL operator==(const CDomain&); // ==operator
  26. virtual ~CDomain(); // destructor
  27. // serialization
  28. //void Serialize(CArchive& ar);
  29. // validation check
  30. BOOL IsInvalid() const;
  31. // check if it is empty
  32. BOOL IsEmpty() { return m_rectDomain.IsRectEmpty(); }
  33. // check if this is a round domain
  34. BOOL IsRound() const { return m_nShape == DOMAIN_SHAPE::ROUND; }
  35. // check if this is a rectangle domain
  36. BOOL IsRect() const { return m_nShape == DOMAIN_SHAPE::RECTANGLE; }
  37. // domain center
  38. CPoint GetDomainCenter() const { return m_rectDomain.CenterPoint(); }
  39. void OffsetDomain(CPoint a_poiMove) { m_rectDomain += a_poiMove; }
  40. // diameter
  41. long GetDiameter() const { return m_rectDomain.Width(); }
  42. // rectangle
  43. CRect GetDomainRect() const { return m_rectDomain; }
  44. void SetDomainRect(const CRect& a_rect) { m_rectDomain = a_rect; }
  45. // sharp
  46. DOMAIN_SHAPE GetShape() const { return m_nShape; }
  47. void SetShape(const DOMAIN_SHAPE a_nShape) { m_nShape = a_nShape; }
  48. // PolygonPoint
  49. std::vector<CPoint> GetPolygonPoint() const { return m_PolygonPoint; }
  50. void SetPolygonPoint(const std::vector<CPoint> a_PolygonPoint);
  51. //void AddPolygonPoint(CPoint p) { m_PolygonPoint.push_back(p); }
  52. // check if have common area with the given domain
  53. BOOL IntersectDomain(const CDomain& a_oDomain);
  54. // check if the point in the domain
  55. BOOL PtInDomain(const CPoint& a_poiCheck) const;
  56. // check if the given domain is in the domain
  57. BOOL DomainInDomain(const CDomain& a_oDomain);
  58. virtual void Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode);
  59. //virtual void Deserialize(Slo * classItem, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode);
  60. protected:
  61. // cleanup
  62. void Cleanup();
  63. // initialization
  64. void Init();
  65. // duplication
  66. void Duplicate(const CDomain& a_oSource);
  67. // sharp
  68. DOMAIN_SHAPE m_nShape;
  69. // area
  70. CRect m_rectDomain;
  71. std::vector<CPoint> m_PolygonPoint;
  72. };
  73. typedef std::shared_ptr<CDomain> __declspec(dllexport) CDomainPtr;
  74. typedef std::vector<CDomainPtr> __declspec(dllexport) CDomainsList;
  75. }