Jspice3
plot5.c File Reference
#include "spice.h"
#include "plotdev.h"
Include dependency graph for plot5.c:

Go to the source code of this file.

Macros

#define putsi(a)
 
#define SOLID   0
 

Functions

int Plt5_Init ()
 
int Plt5_NewViewport (GRAPH *graph)
 
int Plt5_Close ()
 
int Plt5_Halt ()
 
int Plt5_Pixel (int x, int y)
 
int Plt5_Line (int x1, int y1, int x2, int y2)
 
int Plt5_Box (int x1, int y1, int x2, int y2)
 
int Plt5_Arc (int x0, int y0, int radius, double theta1, double theta2)
 
int Plt5_Polygon (POLYGON *p)
 
int Plt5_Text (char *text, int x, int y)
 
int Plt5_SetLinestyle (int linestyleid)
 
int Plt5_SetColor (int colorid)
 
int Plt5_Update ()
 

Variables

static FILE * plotfile
 
static char * linestyle []
 
static int currentlinestyle = SOLID
 

Macro Definition Documentation

#define putsi (   a)
Value:
putc((char) (a), plotfile); \
putc((char) ((a) >> 8), plotfile)
Definition: sced.h:120
static FILE * plotfile
Definition: plot5.c:11

Definition at line 13 of file plot5.c.

#define SOLID   0

Definition at line 16 of file plot5.c.

Function Documentation

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

Definition at line 141 of file plot5.c.

145 {
146  int xs, ys, xf, yf;
147 
148  xs = radius*sin(theta1);
149  ys = radius*cos(theta1);
150  xf = radius*sin(theta2);
151  yf = radius*cos(theta2);
152  putc('a', plotfile);
153  putsi(x0);
154  putsi(y0);
155  putsi(xs);
156  putsi(ys);
157  putsi(xf);
158  putsi(yf);
159  return (0);
160 }
static FILE * plotfile
Definition: plot5.c:11
#define putsi(a)
Definition: plot5.c:13
double cos()
double sin()
int Plt5_Box ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 127 of file plot5.c.

130 {
131  Plt5_Line(x1,y1,x1,y2);
132  Plt5_Line(x1,y2,x2,y2);
133  Plt5_Line(x2,y2,x2,y1);
134  Plt5_Line(x2,y1,x1,y1);
135  return (0);
136 }
int Plt5_Line(int x1, int y1, int x2, int y2)
Definition: plot5.c:112
int Plt5_Close ( )

Definition at line 82 of file plot5.c.

84 {
85  return (0);
86 }
int Plt5_Halt ( )

Definition at line 90 of file plot5.c.

91 {
92  if (plotfile)
93  fclose(plotfile);
94  return (0);
95 }
static FILE * plotfile
Definition: plot5.c:11
int Plt5_Init ( )

Definition at line 23 of file plot5.c.

24 {
26  dispdev->numcolors = 2;
27 
28  /* arbitrary drawable area */
29  dispdev->width = 800;
30  dispdev->height = 1050;
31 
32  return(0);
33 }
int numlinestyles
Definition: plotdev.h:67
DISPDEVICE * dispdev
Definition: display.c:112
int height
Definition: plotdev.h:66
int numcolors
Definition: plotdev.h:67
int width
Definition: plotdev.h:66
int Plt5_Line ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 112 of file plot5.c.

115 {
116  putc('l', plotfile);
117  putsi(x1);
118  putsi(y1);
119  putsi(x2);
120  putsi(y2);
121  return (0);
122 }
static FILE * plotfile
Definition: plot5.c:11
#define putsi(a)
Definition: plot5.c:13
int Plt5_NewViewport ( GRAPH graph)

Definition at line 37 of file plot5.c.

40 {
41  plotfile = fopen((char*)graph->devdep, "wb");
42  if (!plotfile) {
43  graph->devdep = (char *) NULL;
44  perror(graph->devdep);
45  return (1);
46  }
47 
48  switch (graph->graphtype) {
49  default:
50  case GR_PLOT:
51  case GR_GRAF:
52  case GR_MPLT:
53  /* square plotting area */
54  graph->absolute.width = dispdev->width;
55  graph->absolute.height = dispdev->width;
56  break;
57  case GR_SCED:
58  /* full page plot */
59  graph->absolute.width = dispdev->width;
60  graph->absolute.height = dispdev->height;
61  break;
62  }
63 
64  putc('s', plotfile);
65  putsi(0);
66  putsi(0);
67  putsi(graph->absolute.width);
68  putsi(graph->absolute.height);
69 
70  /* reasonable values, used in gr_ for placement */
71  graph->fontwidth = 12;
72  graph->fontheight = 24;
73 
74  /* set to NULL so graphdb doesn't incorrectly de-allocate it */
75  graph->devdep = (char *) NULL;
76 
77  return(0);
78 }
struct graph::@2 absolute
DISPDEVICE * dispdev
Definition: display.c:112
int height
Definition: ftegraph.h:45
#define GR_SCED
Definition: ftegraph.h:23
int fontwidth
Definition: ftegraph.h:82
#define NULL
Definition: spdefs.h:121
int graphtype
Definition: ftegraph.h:31
static FILE * plotfile
Definition: plot5.c:11
#define putsi(a)
Definition: plot5.c:13
int fontheight
Definition: ftegraph.h:82
void perror()
char * devdep
Definition: ftegraph.h:144
int height
Definition: plotdev.h:66
#define GR_PLOT
Definition: ftegraph.h:20
#define GR_MPLT
Definition: ftegraph.h:22
int width
Definition: plotdev.h:66
int width
Definition: ftegraph.h:45
#define GR_GRAF
Definition: ftegraph.h:21
int Plt5_Pixel ( int  x,
int  y 
)

Definition at line 100 of file plot5.c.

103 {
104  putc('p', plotfile);
105  putsi(x);
106  putsi(y);
107  return (0);
108 }
static FILE * plotfile
Definition: plot5.c:11
#define putsi(a)
Definition: plot5.c:13
int Plt5_Polygon ( POLYGON p)

Definition at line 165 of file plot5.c.

168 {
169  return (0);
170 }
int Plt5_SetColor ( int  colorid)

Definition at line 221 of file plot5.c.

224 {
225  return (0);
226 }
int Plt5_SetLinestyle ( int  linestyleid)

Definition at line 201 of file plot5.c.

204 {
205  if (linestyleid < 0) {
206  internalerror("bad linestyleid");
207  return (1);
208  }
209  if (linestyleid > dispdev->numlinestyles)
210  linestyleid = (linestyleid % dispdev->numlinestyles) + 1;
211 
212  putc('f', plotfile);
213  fprintf(plotfile, "%s\n", linestyle[linestyleid]);
214  currentlinestyle = linestyleid;
215  return (0);
216 }
static char * linestyle[]
Definition: plot5.c:17
int numlinestyles
Definition: plotdev.h:67
internalerror(char *message)
Definition: error.c:91
DISPDEVICE * dispdev
Definition: display.c:112
static int currentlinestyle
Definition: plot5.c:19
static FILE * plotfile
Definition: plot5.c:11
int Plt5_Text ( char *  text,
int  x,
int  y 
)

Definition at line 174 of file plot5.c.

177 {
178  int savedlstyle;
179 
180  /* set linestyle to solid
181  * or may get funny color text on some plotters
182  */
183  savedlstyle = currentlinestyle;
185 
186  /* move to (x, y) */
187  putc('m', plotfile);
188  putsi(x);
189  putsi(y);
190 
191  /* use the label option */
192  fprintf(plotfile, "t%s\n", text);
193 
194  /* restore old linestyle */
195  Plt5_SetLinestyle(savedlstyle);
196  return (0);
197 }
static int currentlinestyle
Definition: plot5.c:19
static FILE * plotfile
Definition: plot5.c:11
#define putsi(a)
Definition: plot5.c:13
#define SOLID
Definition: plot5.c:16
int Plt5_SetLinestyle(int linestyleid)
Definition: plot5.c:201
int Plt5_Update ( )

Definition at line 230 of file plot5.c.

232 {
233  fflush(plotfile);
234  return (0);
235 }
static FILE * plotfile
Definition: plot5.c:11

Variable Documentation

int currentlinestyle = SOLID
static

Definition at line 19 of file plot5.c.

char* linestyle[]
static
Initial value:
= { "solid", "dotted", "longdashed", "shortdashed",
"dotdashed" }

Definition at line 17 of file plot5.c.

FILE* plotfile
static

Definition at line 11 of file plot5.c.