Jspice3
wp.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1992 Stephen R. Whiteley
5 ****************************************************************************/
6 
7 /*
8  * WordPerfect driver
9  */
10 
11 #include "spice.h"
12 #include "plotdefs.h"
13 
14 static FILE *plotfile;
15 
16 #define putshort(s,fp) putc(((unsigned char)s),fp); putc(((s)>>8),fp)
17 
18 /* these scale, make them user adjustable some day */
19 #define WP_fontwidth 100
20 #define WP_fontheight 180
21 
22 
23 int
25 {
26  double w, h;
27  extern char *kw_wpboxw, *kw_wpboxh;
28 
30  dispdev->numcolors = 2;
31 
32  if (!cp_getvar(kw_wpboxw,VT_REAL,(char*)&w))
33  w = 4.0;
34  if (!cp_getvar(kw_wpboxh,VT_REAL,(char*)&h))
35  h = 4.0;
36 
37  /* 1200 units per inch */
38  dispdev->width = w*1200;
39  dispdev->height = h*1200;
40 
41  return (0);
42 }
43 
44 
45 int
47 
48 /* devdep initially contains name of output file */
49 GRAPH *graph;
50 {
51  plotfile = fopen((char*)graph->devdep, "wb");
52  if (!plotfile) {
53  perror(graph->devdep);
54  graph->devdep = (char *) NULL;
55  return (1);
56  }
57 
58  graph->absolute.width = dispdev->width;
59  graph->absolute.height = dispdev->height;
60 
61  /* Header */
62 
63  putc(0xff,plotfile);
64  putc('W',plotfile);
65  putc('P',plotfile);
66  putc('C',plotfile);
67 
68  putc(0x10,plotfile);
69  putc(0,plotfile);
70  putc(0,plotfile);
71  putc(0,plotfile);
72 
73  putc(1,plotfile);
74  putc(0x16,plotfile);
75  putc(1,plotfile);
76  putc(0,plotfile);
77 
78  putc(0,plotfile);
79  putc(0,plotfile);
80  putc(0,plotfile);
81  putc(0,plotfile);
82 
83  /* Start WPG record */
84 
85  putc(15,plotfile);
86  putc(6,plotfile);
87  putc(1,plotfile);
88  putc(0,plotfile);
91 
92  /* Text attributes record */
93 
94  putc(13,plotfile);
95  putc(22,plotfile);
98  putshort(0,plotfile);
99  putshort(0,plotfile);
100  putshort(0,plotfile);
101  putshort(0,plotfile);
102  putshort(0,plotfile);
103  putshort(0x1950,plotfile);
104  putc(0,plotfile);
105  putc(0,plotfile);
106  putc(0,plotfile);
107  putc(0,plotfile);
108  putshort(0,plotfile);
109 
110  /* Line attributes record */
111 
112  putc(2,plotfile);
113  putc(4,plotfile);
114  putc(1,plotfile);
115  putc(0,plotfile);
116  putshort(8,plotfile);
117 
118  /* reasonable values, used in gr_ for placement */
119  graph->fontwidth = WP_fontwidth;
120  graph->fontheight = WP_fontheight;
121 
122  return (0);
123 }
124 
125 
126 int
128 
129 {
130  return (0);
131 }
132 
133 
134 int
136 {
137  putc(16,plotfile);
138  putc(0,plotfile);
139  fclose(plotfile);
140  return (0);
141 }
142 
143 
144 /* ARGSUSED */
145 int
146 WP_Pixel(x, y)
147 
148 int x, y;
149 {
150 
151 }
152 
153 
154 int
155 WP_Line(x1, y1, x2, y2)
156 
157 int x1, y1, x2, y2;
158 {
159  /* Line record */
160 
161  putc(5,plotfile);
162  putc(8,plotfile);
163  putshort(x1,plotfile);
164  putshort(y1,plotfile);
165  putshort(x2,plotfile);
166  putshort(y2,plotfile);
167 
168  return (0);
169 }
170 
171 
172 int
173 WP_Box(x1, y1, x2, y2)
174 int x1, y1, x2, y2;
175 {
176  /* poly line record */
177 
178  putc(6,plotfile);
179  putc(22,plotfile);
180  putshort(5,plotfile);
181  putshort(x1,plotfile);
182  putshort(y1,plotfile);
183  putshort(x1,plotfile);
184  putshort(y2,plotfile);
185  putshort(x2,plotfile);
186  putshort(y2,plotfile);
187  putshort(x2,plotfile);
188  putshort(y1,plotfile);
189  putshort(x1,plotfile);
190  putshort(y1,plotfile);
191 
192  /*
193  WP_Line(x1,y1,x1,y2);
194  WP_Line(x1,y2,x2,y2);
195  WP_Line(x2,y2,x2,y1);
196  WP_Line(x2,y1,x1,y1);
197  */
198  return (0);
199 }
200 
201 
202 /* ARGSUSED */
203 int
204 WP_Arc(x0, y0, radius, theta1, theta2)
205 
206 int x0, y0, radius;
207 double theta1, theta2;
208 {
209  return (0);
210 }
211 
212 
213 /* ARGSUSED */
214 int
216 POLYGON *p;
217 {
218  int i = p->nvertices;
219  int *v = (int*)p->xy;
220 
221  /* poly line record */
222 
223  putc(6,plotfile);
224  putc(0xff,plotfile);
225  putshort(4*i + 2,plotfile);
226  putshort(i,plotfile);
227  while (i) {
228  putshort(*v,plotfile);
229  v++;
230  putshort(*v,plotfile);
231  v++;
232  i--;
233  }
234 }
235 
236 
237 int
238 WP_Text(text, x, y)
239 
240 char *text;
241 int x, y;
242 {
243  int j;
244 
245  j = strlen(text);
246 
247  /* Text record */
248  putc(12,plotfile);
249  putc(j+6,plotfile);
250  putshort(j,plotfile);
251  putshort(x,plotfile);
252  putshort(y,plotfile);
253  while (*text) {
254  putc(*text,plotfile);
255  text++;
256  }
257  return (0);
258 }
259 
260 
261 int
262 WP_SetLinestyle(linestyleid)
263 
264 int linestyleid;
265 {
266  return (0);
267 }
268 
269 
270 /* ARGSUSED */
271 int
272 WP_SetColor(colorid)
273 {
274  return (0);
275 }
276 
277 
278 int
280 
281 {
282  fflush(plotfile);
283  return (0);
284 }
285 
#define WP_fontheight
Definition: wp.c:20
bool cp_getvar(char *n, int t, char *r)
Definition: help.c:184
int WP_Close()
Definition: wp.c:127
int WP_Update()
Definition: wp.c:279
int numlinestyles
Definition: plotdev.h:67
int WP_Pixel(int x, int y)
Definition: wp.c:146
DISPDEVICE * dispdev
Definition: display.c:112
int WP_Polygon(POLYGON *p)
Definition: wp.c:215
Definition: cddefs.h:169
int WP_NewViewport(GRAPH *graph)
Definition: wp.c:46
Definition: cddefs.h:215
Definition: plotdev.h:14
#define WP_fontwidth
Definition: wp.c:19
int WP_Text(char *text, int x, int y)
Definition: wp.c:238
#define putshort(s, fp)
Definition: wp.c:16
#define NULL
Definition: spdefs.h:121
Definition: ftegraph.h:29
void perror()
static FILE * plotfile
Definition: wp.c:14
int WP_SetColor(colorid)
Definition: wp.c:272
int WP_Box(int x1, int y1, int x2, int y2)
Definition: wp.c:173
int WP_Init()
Definition: wp.c:24
char * kw_wpboxw
Definition: options.c:432
int height
Definition: plotdev.h:66
int numcolors
Definition: plotdev.h:67
#define VT_REAL
Definition: cpstd.h:62
int WP_Halt()
Definition: wp.c:135
int width
Definition: plotdev.h:66
char * kw_wpboxh
Definition: options.c:431
int WP_Line(int x1, int y1, int x2, int y2)
Definition: wp.c:155
int WP_SetLinestyle(int linestyleid)
Definition: wp.c:262
int WP_Arc(int x0, int y0, int radius, double theta1, double theta2)
Definition: wp.c:204