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

  1.  
  2.  
  3. #ifndef _chord_h_ /* Thu Jan  5 09:36:32 1995 */
  4. #define _chord_h_
  5.  
  6.  
  7.  
  8. /*
  9.  *
  10.  *          Copyright (C) 1994, M. A. Sridhar
  11.  *  
  12.  *
  13.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  14.  *     to copy, modify or distribute this software  as you see fit,
  15.  *     and to use  it  for  any  purpose, provided   this copyright
  16.  *     notice and the following   disclaimer are included  with all
  17.  *     copies.
  18.  *
  19.  *                        DISCLAIMER
  20.  *
  21.  *     The author makes no warranties, either expressed or implied,
  22.  *     with respect  to  this  software, its  quality, performance,
  23.  *     merchantability, or fitness for any particular purpose. This
  24.  *     software is distributed  AS IS.  The  user of this  software
  25.  *     assumes all risks  as to its quality  and performance. In no
  26.  *     event shall the author be liable for any direct, indirect or
  27.  *     consequential damages, even if the  author has been  advised
  28.  *     as to the possibility of such damages.
  29.  *
  30.  */
  31.  
  32.  
  33.  
  34. // This is a GraphicObject representing a chord of an ellipse. This is a
  35. // closed figure.
  36.  
  37.  
  38. #if defined(__GNUC__)
  39. #pragma interface
  40. #endif
  41.  
  42. #include "ui/graphic.h"
  43.  
  44. class CL_EXPORT UI_Arc;
  45. class CL_EXPORT UI_Ellipse;
  46. class CL_EXPORT UI_LineSegment;
  47.  
  48. class CL_EXPORT UI_Chord: public UI_GraphicObject {
  49.  
  50. public:
  51.     UI_Chord (const UI_Rectangle& boundingRect, long startAngleDeg64,
  52.               long subtendedDeg64);
  53.     // Construct a chord of an ellipse. The Chord is part of the
  54.     // ellipse whose
  55.     // bounding rectangle is {\tt boundingRect}. Its starting point is at an
  56.     // angle {$d$} degrees from the 3-o'clock position of {\tt boundingRect}
  57.     // where $d = {\tt startAngleDeg64} * 64$, and it subtends an angle $s$
  58.     // at the center of the ellipse, where $s = {\tt subtendedDeg64} * 64$.
  59.     // Angles are reckoned counter-clockwise.
  60.  
  61.     UI_Chord (const UI_Point &p1, const UI_Point &p2, const UI_Point& origin);
  62.     // Construct a chord of an ellipse with the points p1, p2 being the
  63.     // start point and the end point and the origin being the center of
  64.     // the ellipse.    
  65.  
  66.     UI_Chord ();
  67.     // Construct a chord with zero radii at the origin.
  68.     
  69.     bool DrawOn (UI_DrawingSurface& sfc,
  70.                  const UI_Point& p = UI_Point (0,0)) const;
  71.     // Draw the chord on the surface {\tt sfc} (overrides inherited
  72.     // method).
  73.  
  74.     bool Fill (UI_DrawingSurface& sfc) const;
  75.     
  76.     bool ReshapeTo (const UI_Point& p1, const UI_Point& p2);
  77.     // Override method inherited from GraphicObject. The implementation
  78.     // reshapes the ellipse so that its bounding rectangle is the rectangle
  79.     // whose diagonally opposite points are p1 and p2.
  80.  
  81.  
  82.     UI_Point Center () const {return UI_Point (_xOrigin, _yOrigin);};
  83.     // Return the center of the ellipse of this chord.
  84.     
  85.     UI_Rectangle BoundingRectangle() const;
  86.     // Returns the bounding rectangle of the ellipse of which this chord is
  87.     // part.
  88.  
  89.     UI_PointPair EndPoints () const;
  90.  
  91.     UI_HitTest HitTest (const UI_Point& p) const;
  92.     // Hit testing: overrides method inherited from Graphic.
  93.     
  94.     bool IntersectsBoundary (const UI_Rectangle& r) const;
  95.  
  96.     long StartAngle() const;
  97.  
  98.     long SubtendedAngle() const;
  99.  
  100.     UI_Ellipse Ellipse() const;
  101.     // Return the ellipse of which this chord is part.
  102.  
  103.     UI_LineSegment Line () const;
  104.     // Return the line segment joining the two end points.
  105.  
  106.     UI_Arc Arc () const;
  107.     // Return the arc of this chord.
  108.     
  109.     void StartAngle (long startAngle64);
  110.  
  111.     void SubtendedAngle (long subtAngle64);
  112.  
  113.     void Origin (const UI_Point &origin);
  114.  
  115.  
  116.     UI_Chord& operator= (const UI_Chord&);
  117.  
  118.     void operator= (const CL_Object& o)
  119.         {if (o.IsA (*this)) *this = (const UI_Chord&) o;};
  120.     
  121.     const char* ClassName() const {return "UI_Chord";};
  122.  
  123. protected:
  124.     long   _startAngle; 
  125.     long   _subtAngle;  
  126.     long   _xOrigin;    
  127.     long   _yOrigin;    
  128.     long   _major;      
  129.     long   _minor;
  130. };                            
  131.                               
  132.                               
  133.                               
  134.                               
  135. inline long UI_Chord::StartAngle() const
  136. {
  137.     return _startAngle;
  138. }
  139.  
  140.  
  141. inline long UI_Chord::SubtendedAngle() const
  142. {
  143.     return _subtAngle;
  144. }
  145.  
  146.  
  147. #endif /* _chord_h_ */
  148.