00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __RECTANGLE_INCLUDED
00019 #define __RECTANGLE_INCLUDED
00020
00021 #include <iostream>
00022
00023 using namespace std;
00024
00025 class TLine;
00026 class TPoint;
00027 class TRectangle;
00028
00029
00030
00031
00032
00033
00034
00042 ostream& operator<<( ostream& Stream, const TRectangle& Rect );
00043
00044
00045
00046
00047
00048
00049
00062 class TRectangle
00063 {
00064 public:
00073 TRectangle( double x=0, double y=0, double w=0, double h=0 );
00080 TRectangle( const TPoint& TopLeft, const TPoint& Size );
00081
00082
00083
00095 bool Contains( double x, double y, bool proper=false ) const;
00106 bool Contains( const TPoint& Point, bool proper=false ) const;
00111 double GetBottom() const;
00116 TPoint GetCenter() const;
00122 double GetHeight() const;
00127 int GetIntersectionPoints( const TLine& line, TPoint* one, TPoint* two ) const;
00132 double GetLeft() const;
00137 double GetRight() const;
00142 TPoint GetSize() const;
00147 double GetTop() const;
00153 double GetWidth() const;
00157 double GetX() const;
00161 double GetY() const;
00167 bool Intersects( const TRectangle& r ) const;
00172 bool IsValid() const;
00181 void MoveBy( double dx, double dy );
00188 void MoveByX( double dx );
00195 void MoveByY( double dy );
00203 void MoveTo( double x, double y );
00210 void MoveToX( double x );
00217 void MoveToY( double y );
00224 TRectangle Normalize() const;
00231 void SetBottom( double b );
00237 void SetHeight( double h );
00244 void SetLeft( double l );
00249 void SetRect( double x, double y, double w, double h );
00255 void SetRight( double r );
00262 void SetSize( double w, double h );
00269 void SetSize( const TPoint& Size );
00275 void SetTop( double t );
00281 void SetWidth( double w );
00288 void SetX( double x );
00295 void SetY( double y );
00302 ostream& Write( ostream& Stream ) const;
00303
00304 protected:
00305 double x1;
00306 double y1;
00307 double x2;
00308 double y2;
00309 };
00310
00311
00312
00313
00314
00315 #endif // __RECTANGLE_INCLUDED