Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | // This may look like C code, but it is really -*- C++ -*- |
2 | /* | |
3 | Copyright (C) 1988 Free Software Foundation | |
4 | written by Doug Lea (dl@rocky.oswego.edu) | |
5 | ||
6 | This file is part of GNU CC. | |
7 | ||
8 | GNU CC is distributed in the hope that it will be useful, | |
9 | but WITHOUT ANY WARRANTY. No author or distributor | |
10 | accepts responsibility to anyone for the consequences of using it | |
11 | or for whether it serves any particular purpose or works at all, | |
12 | unless he says so in writing. Refer to the GNU CC General Public | |
13 | License for full details. | |
14 | ||
15 | Everyone is granted permission to copy, modify and redistribute | |
16 | GNU CC, but only under the conditions described in the | |
17 | GNU CC General Public License. A copy of this license is | |
18 | supposed to have been given to you along with GNU CC so you | |
19 | can know your rights and responsibilities. It should be in a | |
20 | file named COPYING. Among other things, the copyright notice | |
21 | and this notice must be preserved on all copies. | |
22 | */ | |
23 | ||
24 | #ifdef __GNUG__ | |
25 | #pragma implementation | |
26 | #endif | |
27 | #include <PlotFile.h> | |
28 | ||
29 | /* | |
30 | PlotFile implementation module | |
31 | */ | |
32 | ||
33 | ||
34 | PlotFile:: PlotFile() {} | |
35 | PlotFile::~PlotFile() {} | |
36 | ||
37 | ||
38 | PlotFile::PlotFile(const char* filename, io_mode m, access_mode a) | |
39 | :(filename, m, a) {} | |
40 | ||
41 | PlotFile::PlotFile(const char* filename, const char* m) | |
42 | :(filename, m) {} | |
43 | ||
44 | PlotFile::PlotFile(int filedesc, const io_mode m) | |
45 | :(filedesc, m) {} | |
46 | ||
47 | PlotFile::PlotFile(FILE* fileptr) | |
48 | :(fileptr) {} | |
49 | ||
50 | PlotFile::operator void*() | |
51 | { | |
52 | return (state & (_bad|_fail))? 0 : this ; | |
53 | } | |
54 | ||
55 | ||
56 | PlotFile& PlotFile::open(const char* filename, | |
57 | io_mode m, access_mode a) | |
58 | { | |
59 | File::open(filename, m, a); return *this; | |
60 | } | |
61 | ||
62 | PlotFile& PlotFile::open(const char* filename, const char* m) | |
63 | { | |
64 | File::open(filename, m); return *this; | |
65 | } | |
66 | ||
67 | PlotFile& PlotFile::open(int filedesc, io_mode m) | |
68 | { | |
69 | File::open(filedesc, m); return *this; | |
70 | } | |
71 | ||
72 | PlotFile& PlotFile::open(FILE* fileptr) | |
73 | { | |
74 | File::open(fileptr); return *this; | |
75 | } | |
76 | ||
77 | PlotFile& PlotFile::setbuf(const int buffer_kind) | |
78 | { | |
79 | File::setbuf(buffer_kind); return *this; | |
80 | } | |
81 | ||
82 | PlotFile& PlotFile::setbuf(const int size, char* buf) | |
83 | { | |
84 | File::setbuf(size, buf); return *this; | |
85 | } | |
86 | ||
87 | ||
88 | PlotFile& PlotFile:: cmd(char c) | |
89 | { | |
90 | File::put(c); | |
91 | return *this; | |
92 | } | |
93 | ||
94 | PlotFile& PlotFile:: operator<<(const int x) | |
95 | { | |
96 | #if defined(convex) | |
97 | File::put((char)(x>>8)); | |
98 | File::put((char)(x&0377)); | |
99 | #else | |
100 | File::put((char)(x&0377)); | |
101 | File::put((char)(x>>8)); | |
102 | #endif | |
103 | return *this; | |
104 | } | |
105 | ||
106 | PlotFile& PlotFile:: operator<<(const char *s) | |
107 | { | |
108 | File::put(s); | |
109 | return *this; | |
110 | } | |
111 | ||
112 | ||
113 | PlotFile& PlotFile:: arc(const int xi, const int yi, | |
114 | const int x0, const int y0, | |
115 | const int x1, const int y1) | |
116 | { | |
117 | return cmd('a') << xi << yi << x0 << y0 << x1 << y1; | |
118 | } | |
119 | ||
120 | ||
121 | PlotFile& PlotFile:: box(const int x0, const int y0, | |
122 | const int x1, const int y1) | |
123 | { | |
124 | line(x0, y0, x0, y1); | |
125 | line(x0, y1, x1, y1); | |
126 | line(x1, y1, x1, y0); | |
127 | return line(x1, y0, x0, y0); | |
128 | } | |
129 | ||
130 | PlotFile& PlotFile:: circle(const int x, const int y, const int r) | |
131 | { | |
132 | return cmd('c') << x << y << r; | |
133 | } | |
134 | ||
135 | PlotFile& PlotFile:: cont(const int xi, const int yi) | |
136 | { | |
137 | return cmd('n') << xi << yi; | |
138 | } | |
139 | ||
140 | PlotFile& PlotFile:: dot(const int xi, const int yi, const int dx, | |
141 | int n, const int* pat) | |
142 | { | |
143 | cmd('d') << xi << yi << dx << n; | |
144 | while (n-- > 0) *this << *pat++; | |
145 | return *this; | |
146 | } | |
147 | ||
148 | PlotFile& PlotFile:: erase() | |
149 | { | |
150 | return cmd('e'); | |
151 | } | |
152 | ||
153 | PlotFile& PlotFile:: label(const char* s) | |
154 | { | |
155 | return cmd('t') << s << "\n"; | |
156 | } | |
157 | ||
158 | PlotFile& PlotFile:: line(const int x0, const int y0, | |
159 | const int x1, const int y1) | |
160 | { | |
161 | return cmd('l') << x0 << y0 << x1 << y1; | |
162 | } | |
163 | ||
164 | PlotFile& PlotFile:: linemod(const char* s) | |
165 | { | |
166 | return cmd('f') << s << "\n"; | |
167 | } | |
168 | ||
169 | PlotFile& PlotFile:: move(const int xi, const int yi) | |
170 | { | |
171 | return cmd('m') << xi << yi; | |
172 | } | |
173 | ||
174 | PlotFile& PlotFile:: point(const int xi, const int yi) | |
175 | { | |
176 | return cmd('p') << xi << yi; | |
177 | } | |
178 | ||
179 | PlotFile& PlotFile:: space(const int x0, const int y0, | |
180 | const int x1, const int y1) | |
181 | { | |
182 | return cmd('s') << x0 << y0 << x1 << y1; | |
183 | } |