home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / libg++-2.7.1-base.tgz / libg++-2.7.1-src.tar / fsf / libg++ / libio / PlotFile.cc < prev    next >
C/C++ Source or Header  |  1995-06-15  |  4KB  |  158 lines

  1. /* 
  2. Copyright (C) 1993 Free Software Foundation
  3.  
  4. This file is part of the GNU IO Library.  This library is free
  5. software; you can redistribute it and/or modify it under the
  6. terms of the GNU General Public License as published by the
  7. Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this library; see the file COPYING.  If not, write to the Free
  17. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. As a special exception, if you link this library with files
  20. compiled with a GNU compiler to produce an executable, this does not cause
  21. the resulting executable to be covered by the GNU General Public License.
  22. This exception does not however invalidate any other reasons why
  23. the executable file might be covered by the GNU General Public License. */
  24.  
  25. // This may look like C code, but it is really -*- C++ -*-
  26. /* 
  27. Copyright (C) 1988, 1992, 1993 Free Software Foundation
  28.     written by Doug Lea (dl@rocky.oswego.edu)
  29.     converted to use iostream library by Per Bothner (bothner@cygnus.com)
  30.  
  31. This file is part of the GNU IO Library.  This library is free
  32. software; you can redistribute it and/or modify it under the
  33. terms of the GNU General Public License as published by the
  34. Free Software Foundation; either version 2, or (at your option)
  35. any later version.
  36.  
  37. This library is distributed in the hope that it will be useful,
  38. but WITHOUT ANY WARRANTY; without even the implied warranty of
  39. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  40. GNU General Public License for more details.
  41.  
  42. You should have received a copy of the GNU General Public License
  43. along with this library; see the file COPYING.  If not, write to the Free
  44. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  45.  
  46. As a special exception, if you link this library with files
  47. compiled with GCC to produce an executable, this does not cause
  48. the resulting executable to be covered by the GNU General Public License.
  49. This exception does not however invalidate any other reasons why
  50. the executable file might be covered by the GNU General Public License.  */
  51.  
  52. #ifdef __GNUG__
  53. #pragma implementation
  54. #endif
  55. #include <PlotFile.h>
  56.  
  57. /*
  58.  PlotFile implementation module
  59. */
  60.  
  61.  
  62. PlotFile& PlotFile:: cmd(char c)
  63.   ofstream::put(c); 
  64.   return *this; 
  65. }
  66.  
  67. PlotFile& PlotFile:: operator<<(const int x)
  68. #if defined(convex)
  69.   ofstream::put((char)(x>>8)); 
  70.   ofstream::put((char)(x&0377)); 
  71. #else
  72.   ofstream::put((char)(x&0377)); 
  73.   ofstream::put((char)(x>>8)); 
  74. #endif
  75.   return *this; 
  76. }
  77.  
  78. PlotFile& PlotFile:: operator<<(const char *s)
  79.   *(ofstream*)this << s;
  80.   return *this;
  81. }
  82.  
  83.  
  84. PlotFile& PlotFile:: arc(const int xi, const int yi,
  85.              const int x0, const int y0,
  86.              const int x1, const int y1)
  87.   return cmd('a') << xi << yi << x0 << y0 << x1 << y1; 
  88. }
  89.  
  90.  
  91. PlotFile& PlotFile:: box(const int x0, const int y0,
  92.              const int x1, const int y1)
  93.   line(x0, y0, x0, y1);
  94.   line(x0, y1, x1, y1);
  95.   line(x1, y1, x1, y0);
  96.   return line(x1, y0, x0, y0);
  97. }
  98.  
  99. PlotFile& PlotFile:: circle(const int x, const int y, const int r)
  100.   return cmd('c') << x << y << r; 
  101. }
  102.  
  103. PlotFile& PlotFile:: cont(const int xi, const int yi)
  104.   return cmd('n') << xi << yi;
  105. }
  106.  
  107. PlotFile& PlotFile:: dot(const int xi, const int yi, const int dx,
  108.              int n, const int* pat)
  109.   cmd('d') << xi << yi << dx << n;
  110.   while (n-- > 0) *this << *pat++;
  111.   return *this; 
  112. }
  113.  
  114. PlotFile& PlotFile:: erase()
  115.   return cmd('e'); 
  116. }
  117.  
  118. PlotFile& PlotFile:: label(const char* s)
  119.   return cmd('t') << s << "\n"; 
  120. }
  121.  
  122. PlotFile& PlotFile:: line(const int x0, const int y0,
  123.               const int x1, const int y1)
  124.   return cmd('l') << x0 << y0 << x1 << y1; 
  125. }
  126.  
  127. PlotFile& PlotFile:: linemod(const char* s)
  128.   return cmd('f') << s << "\n"; 
  129. }
  130.  
  131. PlotFile& PlotFile:: move(const int xi, const int yi)
  132.   return cmd('m') << xi << yi;
  133. }
  134.  
  135. PlotFile& PlotFile:: point(const int xi, const int yi)
  136.   return cmd('p') << xi << yi; 
  137. }
  138.  
  139. PlotFile& PlotFile:: space(const int x0, const int y0,
  140.                const int x1, const int y1)
  141.   return cmd('s') << x0 << y0 << x1 << y1; 
  142. }
  143.