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