Jspice3
wp.c File Reference
#include "spice.h"
#include "plotdefs.h"
Include dependency graph for wp.c:

Go to the source code of this file.

Macros

#define putshort(s, fp)   putc(((unsigned char)s),fp); putc(((s)>>8),fp)
 
#define WP_fontwidth   100
 
#define WP_fontheight   180
 

Functions

int WP_Init ()
 
int WP_NewViewport (GRAPH *graph)
 
int WP_Close ()
 
int WP_Halt ()
 
int WP_Pixel (int x, int y)
 
int WP_Line (int x1, int y1, int x2, int y2)
 
int WP_Box (int x1, int y1, int x2, int y2)
 
int WP_Arc (int x0, int y0, int radius, double theta1, double theta2)
 
int WP_Polygon (POLYGON *p)
 
int WP_Text (char *text, int x, int y)
 
int WP_SetLinestyle (int linestyleid)
 
int WP_SetColor (colorid)
 
int WP_Update ()
 

Variables

static FILE * plotfile
 

Macro Definition Documentation

#define putshort (   s,
  fp 
)    putc(((unsigned char)s),fp); putc(((s)>>8),fp)

Definition at line 16 of file wp.c.

#define WP_fontheight   180

Definition at line 20 of file wp.c.

#define WP_fontwidth   100

Definition at line 19 of file wp.c.

Function Documentation

int WP_Arc ( int  x0,
int  y0,
int  radius,
double  theta1,
double  theta2 
)

Definition at line 204 of file wp.c.

208 {
209  return (0);
210 }
int WP_Box ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 173 of file wp.c.

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 }
#define putshort(s, fp)
Definition: wp.c:16
static FILE * plotfile
Definition: wp.c:14
int WP_Close ( )

Definition at line 127 of file wp.c.

129 {
130  return (0);
131 }
int WP_Halt ( )

Definition at line 135 of file wp.c.

136 {
137  putc(16,plotfile);
138  putc(0,plotfile);
139  fclose(plotfile);
140  return (0);
141 }
static FILE * plotfile
Definition: wp.c:14
int WP_Init ( )

Definition at line 24 of file wp.c.

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 }
bool cp_getvar(char *n, int t, char *r)
Definition: help.c:184
int numlinestyles
Definition: plotdev.h:67
DISPDEVICE * dispdev
Definition: display.c:112
Definition: cddefs.h:169
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 width
Definition: plotdev.h:66
char * kw_wpboxh
Definition: options.c:431
int WP_Line ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 155 of file wp.c.

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 }
#define putshort(s, fp)
Definition: wp.c:16
static FILE * plotfile
Definition: wp.c:14
int WP_NewViewport ( GRAPH graph)

Definition at line 46 of file wp.c.

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 }
#define WP_fontheight
Definition: wp.c:20
struct graph::@2 absolute
DISPDEVICE * dispdev
Definition: display.c:112
int height
Definition: ftegraph.h:45
int fontwidth
Definition: ftegraph.h:82
#define WP_fontwidth
Definition: wp.c:19
#define putshort(s, fp)
Definition: wp.c:16
#define NULL
Definition: spdefs.h:121
int fontheight
Definition: ftegraph.h:82
void perror()
static FILE * plotfile
Definition: wp.c:14
char * devdep
Definition: ftegraph.h:144
int height
Definition: plotdev.h:66
int width
Definition: plotdev.h:66
int width
Definition: ftegraph.h:45
int WP_Pixel ( int  x,
int  y 
)

Definition at line 146 of file wp.c.

149 {
150 
151 }
int WP_Polygon ( POLYGON p)

Definition at line 215 of file wp.c.

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 }
long * xy
Definition: plotdev.h:16
int nvertices
Definition: plotdev.h:15
#define putshort(s, fp)
Definition: wp.c:16
static FILE * plotfile
Definition: wp.c:14
int WP_SetColor ( colorid  )

Definition at line 272 of file wp.c.

273 {
274  return (0);
275 }
int WP_SetLinestyle ( int  linestyleid)

Definition at line 262 of file wp.c.

265 {
266  return (0);
267 }
int WP_Text ( char *  text,
int  x,
int  y 
)

Definition at line 238 of file wp.c.

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 }
#define putshort(s, fp)
Definition: wp.c:16
static FILE * plotfile
Definition: wp.c:14
int WP_Update ( )

Definition at line 279 of file wp.c.

281 {
282  fflush(plotfile);
283  return (0);
284 }
static FILE * plotfile
Definition: wp.c:14

Variable Documentation

FILE* plotfile
static

Definition at line 14 of file wp.c.