Jspice3
ftegraph.h
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: 1988 Jeffery M. Hsu
5  1992 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 /*
9  * This file contains the graph structure.
10  */
11 
12 #ifndef _GRAPH_H_
13 #define _GRAPH_H_
14 
15 #include "fteconst.h"
16 #include "ftedata.h" /* for struct dvec */
17 
18 #define NUMCOLORS 32
19 
20 #define GR_PLOT 0
21 #define GR_GRAF 1
22 #define GR_MPLT 2
23 #define GR_SCED 3
24 
25 /* generic pointer to type specific data structure */
26 typedef char * GRDATA;
27 
28 /* Device-independent data structure for plots. */
29 typedef struct graph {
30  int graphid;
31  int graphtype; /* type of graph: GR_? */
32 
33  GRDATA plotdata; /* normalized data */
34 
35  char *plotname; /* name of plot this graph is in */
36  int onevalue; /* boolean variable,
37  true if plotting one value
38  against itself (real vs imaginary) */
39  int degree; /* degree of polynomial interpretation */
40 
42  int linestyle;
43 
44  struct {
45  int height, width;
46  } viewport;
47  int viewportxoff; /* x offset of viewport w/in graph */
48  int viewportyoff; /* y offset of viewport w/in graph */
49 
50  struct {
51  int xpos; /* x position of graph in screen coord */
52  int ypos; /* y position of graph in screen coord */
53  int width; /* width of window on screen */
54  int height; /* height of window on screen */
55  } absolute;
56 
57  struct {
58  double xmin, ymin, xmax, ymax;
59  /* cache: width = xmax - xmin height = ymax - ymin */
60  double width, height;
61  } datawindow;
62 
63  /* callbacks:
64  */
65 #ifdef __STDC__
66  void (*redraw)(struct graph*); /* redraw procedure */
67  void (*destroy)(GRDATA); /* free data procedure */
68  GRDATA (*copydata)(GRDATA); /* copy data procedure */
69 #else
70  void (*redraw)();
71  void (*destroy)();
73 #endif
74 
75  /* note: this int is device dependent */
77 
78  /* cache (datawindow size) / (viewport size) */
80 
81  int ticmarks; /* mark every ticmark'th point */
82  int fontwidth, fontheight; /* for use in grid */
83 
84  PLOTTYPE plottype; /* defined in FTEconstant.h */
85  struct {
86  GRIDTYPE gridtype; /* defined in FTEconstant.h */
87  int circular; /* TRUE if circular plot area */
88  union {
89  struct {
90  char units[16]; /* unit labels */
92  int onedec; /* a boolean */
93  int hacked; /* true if hi - lo already hacked up */
94  } lin;
95  struct {
96  int hmt, lmt, decsp, subs, pp;
97  } log;
98  struct {
99  int radius, center;
100  double mrad;
101  int lmt;
102  } circular; /* bogus, rework when write polar grids, etc */
103  } xaxis, yaxis;
105  double xdelta, ydelta; /* if non-zero, user-specified deltas */
106  char *xlabel, *ylabel;
107  } grid;
108 
109  int numbuttons; /* number of buttons */
110  struct {
111  int id;
112  char *message;
113  } *buttons;
114  int buttonsxoff; /* viewportxoff + x size of viewport */
116 
117  struct {
118  int width, height;
119  char message[161]; /* two lines of text */
120  } messagebox;
123 
124  /* characters the user typed on graph */
125  struct _keyed {
126  char *text;
127  int x, y;
128  int colorindex; /* index into colors array */
129  struct _keyed *next;
130  } *keyed;
131 
132  /* for zoomin */
133  char *commandline;
134 
135  /* Need to have device dependent info here because
136  * otherwise every device implementation would need to handle
137  * its own device dependent analog of GRAPH. I want a
138  * language with generics.
139  * Use pointer so we don't have to include device dependent
140  * header files here.
141  * Space here is allocated by NewViewport
142  * and de-allocated by DestroyGraph.
143  */
144  char *devdep;
145 
146 } GRAPH;
147 
148 extern GRAPH *currentgraph;
149 extern int numgraphcxsw;
150 
151 #define NEWGRAPH (GRAPH *) calloc(1, sizeof(GRAPH))
152 
153 
154 
155 /***************************************************************************
156 Defs for the Input routine.
157 
158 char_option: Used by the lexer and elsewhere. response.reply.ch contains the
159  character, obtained from the graphics package if request.fp is 0,
160  otherwise from the standard input.
161 
162 button_option: Used by the menu system and the help package,
163  response.reply.button contains the button number.
164 
165 click_option: Used in the X10 version for the hardcopy command,
166  response.reply.graph is the associated graph structure.
167 
168 point_option: Used in the SCED schematic capture editor. Returns the window
169  coords of the pointer in response.x,response.y. If there was a button
170  press, thr reply option is button_option and response.reply.button
171  contains the button number. If the keyboard was used, the character
172  is returned in response.reply.ch, and the response option is char_option.
173 
174 checkup_option: For handling pending asynchonous events.
175 ****************************************************************************/
176 
177 typedef enum {
178  error_option, /* a reply option only */
179  button_option, /* get a button press */
180  char_option, /* get a char */
181  click_option, /* point at a widget */
182  point_option, /* get a char or button, return coords */
183  checkup_option /* see if events in queue */
184 } OPTION;
185 
186 typedef struct request {
188  FILE *fp;
189 } REQUEST;
190 
191 typedef struct response {
193  int x;
194  int y;
195  union {
196  int ch;
198  int button;
199  } reply;
200 } RESPONSE;
201 
202 
203 #define rnd(x) (int) ((x)+0.5)
204 
205 /* graphdb.c */
206 #ifdef __STDC__
207 extern GRAPH *NewGraph(void);
208 extern GRAPH *FindGraph(int);
209 extern GRAPH *CopyGraph(GRAPH*);
210 extern int DestroyGraph(int);
211 extern void FreeGraphs(void);
212 extern void SetGraphContext(int);
213 extern void PushGraphContext(GRAPH*);
214 extern void PopGraphContext(void);
215 #else
216 extern GRAPH *NewGraph();
217 extern GRAPH *FindGraph();
218 extern GRAPH *CopyGraph();
219 extern int DestroyGraph();
220 extern void FreeGraphs();
221 extern void SetGraphContext();
222 extern void PushGraphContext();
223 extern void PopGraphContext();
224 #endif
225 
226 
227 #endif /* notdef _GRAPH_H_ */
GRIDTYPE
Definition: fteconst.h:60
int messageyoff
Definition: ftegraph.h:122
int spacing
Definition: ftegraph.h:91
double width
Definition: ftegraph.h:60
int decsp
Definition: ftegraph.h:96
int xdatatype
Definition: ftegraph.h:104
char * GRDATA
Definition: ftegraph.h:26
struct graph::@2 absolute
#define NUMCOLORS
Definition: ftegraph.h:18
int numbuttons
Definition: ftegraph.h:109
OPTION
Definition: ftegraph.h:177
FILE * fp
Definition: ftegraph.h:188
int hacked
Definition: ftegraph.h:93
OPTION option
Definition: ftegraph.h:187
int center
Definition: ftegraph.h:99
GRAPH * graph
Definition: ftegraph.h:197
double aspectratiox
Definition: ftegraph.h:79
void FreeGraphs()
Definition: graphdb.c:208
int distance
Definition: ftegraph.h:91
char units[16]
Definition: ftegraph.h:90
double ymin
Definition: ftegraph.h:58
union graph::@4::@7 yaxis
struct _keyed * next
Definition: ftegraph.h:129
struct request REQUEST
int height
Definition: ftegraph.h:45
int degree
Definition: ftegraph.h:39
struct graph::@3 datawindow
GRDATA(* copydata)()
Definition: ftegraph.h:72
char * message
Definition: ftegraph.h:112
PLOTTYPE
Definition: fteconst.h:73
int viewportyoff
Definition: ftegraph.h:48
int buttonsyoff
Definition: ftegraph.h:115
int ch
Definition: ftegraph.h:196
double xdelta
Definition: ftegraph.h:105
int id
Definition: ftegraph.h:111
struct graph::@6 messagebox
int xpos
Definition: ftegraph.h:51
int lmt
Definition: ftegraph.h:96
int fontwidth
Definition: ftegraph.h:82
double mrad
Definition: ftegraph.h:100
void PushGraphContext()
int graphtype
Definition: ftegraph.h:31
int graphid
Definition: ftegraph.h:30
int highlimit
Definition: ftegraph.h:91
double aspectratioy
Definition: ftegraph.h:79
GRDATA plotdata
Definition: ftegraph.h:33
int currentcolor
Definition: ftegraph.h:41
int viewportxoff
Definition: ftegraph.h:47
Definition: ftegraph.h:29
GRAPH * CopyGraph()
int fontheight
Definition: ftegraph.h:82
int onedec
Definition: ftegraph.h:92
int colors[NUMCOLORS]
Definition: ftegraph.h:76
GRAPH * FindGraph()
struct graph::@4::@7::@9 log
int buttonsxoff
Definition: ftegraph.h:114
int ydatatype
Definition: ftegraph.h:104
GRIDTYPE gridtype
Definition: ftegraph.h:86
union graph::@4::@7 xaxis
struct graph::_keyed * keyed
char * xlabel
Definition: ftegraph.h:106
char * plotname
Definition: ftegraph.h:35
void(* destroy)()
Definition: ftegraph.h:71
char * devdep
Definition: ftegraph.h:144
int onevalue
Definition: ftegraph.h:36
int circular
Definition: ftegraph.h:87
int ypos
Definition: ftegraph.h:52
int button
Definition: ftegraph.h:198
void PopGraphContext()
Definition: graphdb.c:270
int DestroyGraph()
int colorindex
Definition: ftegraph.h:128
int y
Definition: ftegraph.h:194
int x
Definition: ftegraph.h:193
int subs
Definition: ftegraph.h:96
OPTION option
Definition: ftegraph.h:192
char * text
Definition: ftegraph.h:126
int ticmarks
Definition: ftegraph.h:81
int linestyle
Definition: ftegraph.h:42
char * commandline
Definition: ftegraph.h:133
PLOTTYPE plottype
Definition: ftegraph.h:84
int hmt
Definition: ftegraph.h:96
struct graph::@4::@7::@8 lin
int pp
Definition: ftegraph.h:96
int numspace
Definition: ftegraph.h:91
GRAPH * currentgraph
Definition: graphdb.c:21
struct graph::@5 * buttons
int width
Definition: ftegraph.h:45
void(* redraw)()
Definition: ftegraph.h:70
double ydelta
Definition: ftegraph.h:105
double xmax
Definition: ftegraph.h:58
char * ylabel
Definition: ftegraph.h:106
struct graph::@4 grid
struct response RESPONSE
struct graph GRAPH
int numgraphcxsw
Definition: graphdb.c:24
int lowlimit
Definition: ftegraph.h:91
struct graph::@1 viewport
int radius
Definition: ftegraph.h:99
double ymax
Definition: ftegraph.h:58
void SetGraphContext()
int mult
Definition: ftegraph.h:91
double xmin
Definition: ftegraph.h:58
GRAPH * NewGraph()
Definition: graphdb.c:59
int messagexoff
Definition: ftegraph.h:121