home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / ui / lineseg.h < prev    next >
C/C++ Source or Header  |  1995-04-09  |  3KB  |  101 lines

  1.  
  2.  
  3.  
  4.  
  5. #ifndef _lineseg_h_ /* Sat Oct 29 09:53:51 1994 */
  6. #define _lineseg_h_
  7.  
  8.  
  9.  
  10.  
  11. /*
  12.  *
  13.  *          Copyright (C) 1994, M. A. Sridhar
  14.  *  
  15.  *
  16.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  17.  *     to copy, modify or distribute this software  as you see fit,
  18.  *     and to use  it  for  any  purpose, provided   this copyright
  19.  *     notice and the following   disclaimer are included  with all
  20.  *     copies.
  21.  *
  22.  *                        DISCLAIMER
  23.  *
  24.  *     The author makes no warranties, either expressed or implied,
  25.  *     with respect  to  this  software, its  quality, performance,
  26.  *     merchantability, or fitness for any particular purpose. This
  27.  *     software is distributed  AS IS.  The  user of this  software
  28.  *     assumes all risks  as to its quality  and performance. In no
  29.  *     event shall the author be liable for any direct, indirect or
  30.  *     consequential damages, even if the  author has been  advised
  31.  *     as to the possibility of such damages.
  32.  *
  33.  */
  34.  
  35. #if defined(__GNUC__)
  36. #pragma interface
  37. #endif
  38.  
  39.  
  40. #include "ui/graphic.h"
  41.  
  42. class CL_EXPORT UI_LineSegment: public  UI_GraphicObject {
  43.  
  44. public:
  45.     UI_LineSegment (const UI_Point& p1, const UI_Point& p2);
  46.  
  47.     UI_LineSegment (const UI_Point& start, double slope, long length);
  48.  
  49.     UI_LineSegment ();
  50.  
  51.     UI_LineSegment& operator= (const UI_LineSegment& o);
  52.  
  53.     bool Intersects (const UI_LineSegment& l) const;
  54.     // Tell whether the given line segment intersects this one.
  55.  
  56.     void operator= (const CL_Object& o);
  57.     
  58.     bool DrawOn (UI_DrawingSurface& sfc,
  59.                  const UI_Point& p = UI_Point(0,0)) const;
  60.     // Draw the line segment on the surface {\tt sfc}, translated so that
  61.     // {\tt p} is treated as the origin of the co-ordinate system.
  62.  
  63.     bool ReshapeTo (const UI_Point& p1, const UI_Point& p2);
  64.  
  65.     bool OnBoundary (const UI_Point& p) const;
  66.  
  67.     UI_HitTest HitTest (const UI_Point& p) const;
  68.     // Hit testing: overrides method inherited from Graphic. This method
  69.     // always returns either Outside or Boundary, never Inside, because
  70.     // there is no ``inside'' of a line segment.
  71.     
  72.     UI_PointPair EndPoints () const;
  73.  
  74.     UI_PointPair PointsAtDistance (const UI_Point &, long);
  75.  
  76.     UI_Point Center () const;
  77.  
  78.     double Slope () const;
  79.     
  80.     bool Includes (const UI_Point& p) const {return OnBoundary (p);}
  81.     // Includes is the same as OnBoundary, because this is a line.
  82.  
  83.     bool IntersectsBoundary (const UI_Rectangle& r) const;
  84.     
  85.     bool IsContainedIn (const UI_Rectangle& r) const;
  86.  
  87.     UI_Rectangle BoundingRectangle() const;
  88.  
  89.  
  90.     const char* ClassName () const {return "UI_LineSegment";};
  91.  
  92.     
  93. protected:
  94.     UI_Point _p1, _p2;
  95.  
  96. };
  97.  
  98.  
  99.  
  100. #endif /* _lineseg_h_ */
  101.