home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / i / iv26_w_3.zip / EXAMPLES / IDRAW / SLELLIPS.C < prev    next >
C/C++ Source or Header  |  1992-01-17  |  4KB  |  131 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. // $Header: slellipses.c,v 1.7 89/10/09 14:49:27 linton Exp $
  24. // implements classes EllipseSelection and CircleSelection.
  25.  
  26. #include "iellipses.h"
  27. #include "slellipses.h"
  28. #include <iostream.h>
  29.  
  30. // EllipseSelection creates the ellipse's filled interior and outline.
  31.  
  32. EllipseSelection::EllipseSelection (Coord x0, Coord y0, int rx, int ry,
  33. Graphic* gs) : (gs) {
  34.     Append(new IFillEllipse(x0, y0, rx, ry));
  35.     Append(new GEllipse(x0, y0, rx, ry));
  36. }
  37.  
  38. // EllipseSelection reads data to initialize its graphic state and
  39. // create its filled interior and outline.
  40.  
  41. EllipseSelection::EllipseSelection (istream& from, State* state) : (nil) {
  42.     ReadGS(from, state);
  43.     Skip(from);
  44.     Coord x0, y0;
  45.     int rx, ry;
  46.     from >> x0 >> y0 >> rx >> ry;
  47.     Append(new IFillEllipse(x0, y0, rx, ry));
  48.     Append(new GEllipse(x0, y0, rx, ry));
  49. }
  50.  
  51. // Copy returns a copy of the EllipseSelection.
  52.  
  53. Graphic* EllipseSelection::Copy () {
  54.     Coord x0, y0;
  55.     int rx, ry;
  56.     GetOriginal(x0, y0, rx, ry);
  57.     return new EllipseSelection(x0, y0, rx, ry, this);
  58. }
  59.  
  60. // GetOriginal returns the center point and the x and y radii lengths
  61. // that were passed to the EllipseSelection's constructor.
  62.  
  63. void EllipseSelection::GetOriginal (Coord& x0, Coord& y0, int& rx, int& ry) {
  64.     ((GEllipse*) Last())->GetOriginal(x0, y0, rx, ry);
  65. }
  66.  
  67. // WriteData writes the EllipseSelection's data and Postscript code to
  68. // draw it.
  69.  
  70. void EllipseSelection::WriteData (ostream& to) {
  71.     Coord x0, y0;
  72.     int rx, ry;
  73.     GetOriginal(x0, y0, rx, ry);
  74.     to << "Begin " << startdata << " Elli\n";
  75.     WriteGS(to);
  76.     to << startdata << "\n";
  77.     to << x0 << " " << y0 << " " << rx << " " << ry << " Elli\n";
  78.     to << "End\n\n";
  79. }
  80.  
  81. // CircleSelection creates the circle's filled interior and outline.
  82.  
  83. CircleSelection::CircleSelection (Coord x0, Coord y0, int r, Graphic* gs)
  84. : (gs) {
  85.     Append(new IFillCircle(x0, y0, r));
  86.     Append(new Circle(x0, y0, r));
  87. }
  88.  
  89. // CircleSelection reads data to initialize its graphic state and
  90. // create its filled interior and outline.
  91.  
  92. CircleSelection::CircleSelection (istream& from, State* state) : (nil) {
  93.     ReadGS(from, state);
  94.     Skip(from);
  95.     Coord x0, y0;
  96.     int r;
  97.     from >> x0 >> y0 >> r;
  98.     Append(new IFillCircle(x0, y0, r));
  99.     Append(new Circle(x0, y0, r));
  100. }
  101.  
  102. // Copy returns a copy of the CircleSelection.
  103.  
  104. Graphic* CircleSelection::Copy () {
  105.     Coord x0, y0;
  106.     int r;
  107.     GetOriginal(x0, y0, r);
  108.     return new CircleSelection(x0, y0, r, this);
  109. }
  110.  
  111. // GetOriginal returns the center point and radius length that were
  112. // passed to the CircleSelection's constructor.
  113.  
  114. void CircleSelection::GetOriginal (Coord& x0, Coord& y0, int& r) {
  115.     ((Circle*) Last())->GetOriginal(x0, y0, r, r);
  116. }
  117.  
  118. // WriteData writes the CircleSelection's data and Postscript code to
  119. // draw it.
  120.  
  121. void CircleSelection::WriteData (ostream& to) {
  122.     Coord x0, y0;
  123.     int r;
  124.     GetOriginal(x0, y0, r);
  125.     to << "Begin " << startdata << " Circ\n";
  126.     WriteGS(to);
  127.     to << startdata << "\n";
  128.     to << x0 << " " << y0 << " " << r << " Circ\n";
  129.     to << "End\n\n";
  130. }
  131.