00001 00008 #ifndef BOUNDINGBOX_H 00009 #define BOUNDINGBOX_H 00010 00011 #include<ostream> 00012 #include<istream> 00013 00024 class BoundingBox 00025 { 00026 public : 00030 BoundingBox(); 00031 00040 BoundingBox(int x, int y, int w, int h); 00041 00045 ~BoundingBox(); 00046 00047 protected : 00051 int m_x1; 00055 int m_y1; 00059 int m_x2; 00063 int m_y2; 00064 00065 public : 00070 int GetOriginX() const; 00075 int GetOriginY() const; 00080 int GetEndX() const; 00085 int GetEndY() const; 00086 00091 int GetWidth() const; 00092 00097 int GetHeight() const; 00098 00102 void SetOriginX(int pos); 00106 void SetOriginY(int pos); 00110 void SetEndX(int pos); 00114 void SetEndY(int pos); 00115 00119 void MakeSquare(); 00120 00124 void Display() const; 00125 00131 void SetCoord(int x1, int y1, int x2, int y2); 00132 00140 void SetBoundingBox(int x1, int y1, int w, int h); 00141 00148 bool IsInside(int x, int y, bool border=true) const; 00149 00155 bool IsInside(const BoundingBox& bb) const; 00156 00162 void Move(int dx, int dy); 00163 00168 bool IsEmpty() const; 00169 00173 void Validate(); 00174 00180 BoundingBox operator|(const BoundingBox &bb) const; 00181 00188 BoundingBox& operator|=(const BoundingBox &bb); 00189 00195 bool operator==(const BoundingBox& bb); 00196 00202 BoundingBox& operator=(const BoundingBox& bb); 00203 }; 00204 00205 #endif