home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / graph / curve.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  4.1 KB  |  109 lines

  1. /**********************************************************************
  2. *                                                                     *
  3. *  IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3.5           *
  4. *                                                                     *
  5. *  PID: 5622-880                                                      *
  6. *  - Licensed Material - Program-Property of IBM                      *
  7. *  (C) Copyright IBM Corp. 1991, 1995 - All Right Reserved.           *
  8. *                                                                     *
  9. *  US Government Users Restricted Rights - Use, duplication or        *
  10. *  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.  *
  11. *                                                                     *
  12. *  VisualAge, and IBM are trademarks or registered trademarks of      *
  13. *  International Business Machines Corporation.                       *
  14. *  Windows is a registered trademark of Microsoft Corporation.        *
  15. *                                                                     *
  16. **********************************************************************/
  17.  
  18. #include <istring.hpp>
  19.  
  20.  
  21. class Curve : public Graphics
  22. {
  23. public:
  24.  
  25.   float ivXStart;
  26.   float ivYStart;
  27.   float ivXFix1;
  28.   float ivYFix1;
  29.   float ivXFix2;
  30.   float ivYFix2;
  31.   float ivXFix3;
  32.   float ivYFix3;
  33.   float ivXEnd;
  34.   float ivYEnd;
  35.  
  36.  
  37.   Curve(int graphicsKey, IString id,
  38.         float xstart, float ystart,
  39.         float xfix1, float yfix1,
  40.         float xfix2, float yfix2,
  41.         float xfix3, float yfix3,
  42.         float xend, float yend)
  43.                                   :  Graphics(graphicsKey, id),
  44.                                      ivXStart(xstart),
  45.                                      ivYStart(ystart),
  46.                                      ivXFix1(xfix1),
  47.                                      ivYFix1(yfix1),
  48.                                      ivXFix2(xfix2),
  49.                                      ivYFix2(yfix2),
  50.                                      ivXFix3(xfix3),
  51.                                      ivYFix3(yfix3),
  52.                                      ivXEnd(xend),
  53.                                      ivYEnd(yend)
  54.                                      { }
  55.  
  56.  
  57.  
  58.   IBoolean operator== (Curve const& curve) const
  59.     {
  60.      return (this->ivXStart == curve.ivXStart &&
  61.              this->ivYStart == curve.ivYStart &&
  62.              this->ivXFix1  == curve.ivXFix1  &&
  63.              this->ivYFix1  == curve.ivYFix1  &&
  64.              this->ivXFix2  == curve.ivXFix2  &&
  65.              this->ivYFix2  == curve.ivYFix2  &&
  66.              this->ivXFix3  == curve.ivXFix3  &&
  67.              this->ivYFix3  == curve.ivYFix3  &&
  68.              this->ivXEnd   == curve.ivXEnd   &&
  69.              this->ivYEnd   == curve.ivYEnd);
  70.     }
  71.  
  72.  
  73.   void           draw() const
  74.     {
  75.      cout << "drawing "
  76.           << Graphics::id()
  77.           << endl
  78.           << "with starting point: "
  79.           << "(" << this->ivXStart << "|"
  80.           << this->ivYStart << ")"
  81.           << endl
  82.           << "and with fix points: "
  83.           << "(" << this->ivXFix1 << "|" << this->ivYFix1 << ")"
  84.           << "(" << this->ivXFix2 << "|" << this->ivYFix2 << ")"
  85.           << "(" << this->ivXFix3 << "|" << this->ivYFix3 << ")"
  86.           << endl
  87.           << "and with ending point: "
  88.           << "(" << this->ivXEnd << "|" << this->ivYEnd << ")"
  89.           << endl;
  90.     }
  91.  
  92.  
  93.   void           lengthOfCurve() const
  94.     {
  95.      cout << "Length of "
  96.           << Graphics::id()
  97.           << " is: "
  98.           << (sqrt(pow(((this->ivXFix1) - (this->ivXStart)),2)
  99.                  + pow(((this->ivYFix1) - (this->ivYStart)),2))
  100.             + sqrt(pow(((this->ivXFix2) - (this->ivXFix1)),2)
  101.                  + pow(((this->ivYFix2) - (this->ivYFix1)),2))
  102.             + sqrt(pow(((this->ivXFix3) - (this->ivXFix2)),2)
  103.                  + pow(((this->ivYFix3) - (this->ivYFix2)),2))
  104.             + sqrt(pow(((this->ivXEnd) -  (this->ivXFix3)),2)
  105.                  + pow(((this->ivYEnd) - (this->ivYFix3)),2)))
  106.           << endl;
  107.     }
  108. };
  109.