source: trunk/Jgraph/jgraph.c@ 418

Last change on this file since 418 was 418, checked in by Nicholas Riley, 16 years ago

Jgraph 8.3 from http://www.cs.utk.edu/~plank/plank/jgraph/jgraph.tar.gz

File size: 7.7 KB
Line 
1/*
2 * $Source: /tmp_mnt/n/fs/grad1/jsp/src/jgraph/RCS/jgraph.c,v $
3 * $Revision: 8.3 $
4 * $Date: 92/11/30 11:42:21 $
5 * $Author: jsp $
6 */
7
8#include <stdio.h>
9
10#ifdef VMS
11#include <redexp.VMS>
12#endif
13
14#include "jgraph.h"
15
16int NMARKTYPES = 17;
17int NORMALMARKTYPES = 6;
18
19char *MARKTYPESTRS[] = { "circle", "box", "diamond", "triangle", "x", "cross",
20 "ellipse", "general", "general_nf", "general_bez",
21 "general_bez_nf", "postscript", "eps",
22 "xbar", "ybar", "none", "text"};
23char MARKTYPES[] = { 'o', 'b', 'd', 't', 'x', 'c',
24 'e', 'g', 'G', 'Z',
25 'B', 'p', 'E',
26 'X', 'Y', 'n', 'l' };
27
28int NPATTERNS = 3;
29char *PATTERNS[] = { "solid", "stripe", "estripe" };
30char PTYPES[] = { 's', '/', 'e' };
31
32Label new_label()
33{
34 Label l;
35 int i;
36
37 l = (Label) malloc (sizeof(struct label));
38 l->label = CNULL;
39 l->hj = 'c';
40 l->vj = 'b';
41 l->font = "Times-Roman";
42 l->fontsize = 9.0;
43 l->rotate = 0;
44 l->graytype = 'n';
45 for (i = 0; i < 3; i++) l->gray[i] = 0.0;
46 l->linesep = FSIG;
47
48 return l;
49}
50
51
52Curve new_curve(c, num)
53Curve c;
54int num;
55{
56 Curve new_c;
57 int i;
58
59 new_c = (Curve) get_node(c);
60 new_c->num = num;
61 new_c->l = new_label();
62 new_c->l->vj = 't';
63 new_c->lmark = new_label();
64 new_c->lmark->hj = 'c';
65 new_c->lmark->vj = 'c';
66 new_c->clip = 0;
67 new_c->pattern = 's';
68 new_c->parg = FSIG;
69 new_c->apattern = 's';
70 new_c->aparg = FSIG;
71 new_c->ppattern = 's';
72 new_c->pparg = FSIG;
73 new_c->graytype = 'n';
74 for (i = 0; i < 3; i++) new_c->gray[i] = 0.0;
75 new_c->afilltype = 'g';
76 for (i = 0; i < 3; i++) new_c->afill[i] = 0.0;
77 new_c->pts = (Point) make_list(sizeof(struct point));
78 new_c->yepts = (Point) make_list(sizeof(struct point));
79 new_c->xepts = (Point) make_list(sizeof(struct point));
80 new_c->npts = 0;
81 new_c->gen_linetype = (Flist) make_list(sizeof(struct flist));
82 new_c->marktype = MARKTYPES[num % NORMALMARKTYPES];
83 new_c->linetype = '0';
84 new_c->linethick = 1.0;
85 new_c->marksize[0] = FSIG;
86 new_c->marksize[1] = FSIG;
87 new_c->mrotate = 0.0;
88 new_c->general_marks = (Point) make_list(sizeof(struct point));
89 new_c->filltype = 'n';
90 for (i = 0; i < 3; i++) new_c->fill[i] = 0.0;
91 new_c->pfilltype = 'n';
92 for (i = 0; i < 3; i++) new_c->pfill[i] = 0.0;
93 new_c->poly = 0;
94 new_c->rarrow = 0;
95 new_c->larrow = 0;
96 new_c->rarrows = 0;
97 new_c->larrows = 0;
98 new_c->asize[0] = FSIG;
99 new_c->asize[1] = FSIG;
100 new_c->bezier = 0;
101 new_c->postscript = CNULL;
102 new_c->postfile = 0;
103 new_c->eps = CNULL;
104 prio_insert(new_c, c, 0);
105 return new_c;
106}
107
108Curve new_line(c, num)
109Curve c;
110int num;
111{
112 Curve new_c;
113 new_c = new_curve(c, num);
114 new_c->linetype = 's';
115 new_c->marktype = 'n';
116 return new_c;
117}
118
119
120Curve get_curve(c, num)
121Curve c;
122int num;
123{
124 Curve new_c;
125 for(new_c = last(c); new_c != nil(c) && new_c->num > num; new_c = prev(new_c));
126 if (new_c == nil(c) || new_c->num < num) return new_curve(c, num);
127 return new_c;
128}
129
130Axis new_axis(is_x)
131int is_x;
132{
133 int i;
134 Axis a;
135
136 a = (Axis) malloc (sizeof(struct axis));
137 a->label = new_label();
138 a->label->x = FSIG;
139 a->label->y = FSIG;
140 a->label->font = "Times-Bold";
141 a->label->fontsize = 10.0;
142 a->label->rotate = FSIG;
143 a->label->hj = '0';
144 a->label->vj = '0';
145 a->size = 3.0;
146 a->max = FSIG;
147 a->min = FSIG;
148 a->pmax = FSIG;
149 a->pmin = FSIG;
150 a->hash_interval = -1.0;
151 a->log_base = 10.0;
152 a->minor_hashes = -1;
153 a->precision = -1;
154 a->hl = new_label();
155 a->hl->label = "";
156 a->hl->font = "Times-Roman";
157 a->hl->fontsize = 9.0;
158 a->hl->rotate = 0.0;
159 a->hl->hj = '0';
160 a->hl->vj = '0';
161 a->hash_format = 'f';
162 a->draw_at = FSIG;
163 a->draw_hash_marks_at = FSIG;
164 a->draw_hash_labels_at = FSIG;
165 a->draw_hash_labels = 1;
166 a->draw_axis_line = 1;
167 a->draw_hash_marks = 1;
168 a->draw_axis_label = 1;
169 a->auto_hash_labels = 1;
170 a->auto_hash_marks = 1;
171 a->start_given = 0;
172 a->hash_scale = -1.0;
173 a->grid_lines = 0;
174 a->mgrid_lines = 0;
175 a->graytype = 'n';
176 for (i = 0; i < 3; i++) a->gray[i] = 0.0;
177 a->gr_graytype = '0';
178 for (i = 0; i < 3; i++) a->gr_gray[i] = 0.0;
179 a->mgr_graytype = '0';
180 for (i = 0; i < 3; i++) a->mgr_gray[i] = 0.0;
181 a->is_x = is_x;
182 a->is_lg = 0;
183 a->hash_labels = (String) make_list (sizeof(struct string));
184 a->hash_lines = (Hash) make_list (sizeof(struct hash));
185 return a;
186}
187
188Legend new_legend()
189{
190 Legend l;
191 l = (Legend) malloc (sizeof(struct legend));
192 l->linelength = FSIG;
193 l->linebreak = FSIG;
194 l->midspace = FSIG;
195 l->type = 'u';
196 l->l = new_label();
197 l->l->label = "";
198 l->l->hj = 'l';
199 l->l->vj = 'c';
200 l->l->x = FSIG;
201 l->l->y = FSIG;
202 return l;
203}
204
205Label new_title()
206{
207 Label t;
208
209 t = new_label();
210 t->x = FSIG;
211 t->y = FSIG;
212 t->rotate = 0.0;
213 t->hj = 'c';
214 t->vj = 't';
215 t->fontsize = 12.0;
216 return t;
217}
218
219String new_string(s, num)
220String s;
221int num;
222{
223 String new_s;
224
225 new_s = (String) get_node(s);
226 new_s->num = num;
227 new_s->s = new_label();
228 prio_insert(new_s, s, 0);
229 return new_s;
230}
231
232String get_string(s, num)
233String s;
234int num;
235{
236 String new_s;
237 for(new_s = last(s); new_s != nil(s) && new_s->num > num; new_s = prev(new_s));
238 if (new_s == nil(s) || new_s->num < num) return new_string(s, num);
239 return new_s;
240}
241
242/*
243Default new_default()
244{
245 Default new_d;
246 new_d = (Default) malloc (sizeof(default));
247 new_d->rotate = FSIG;
248 new_d->fontsize = FSIG;
249 new_d->general_marks = GMNULL;
250 new_d->fill = FSIG;
251 new_d->linethick = FSIG;
252 new_d->font = CNULL;
253 new_d->hj = '!';
254 new_d->vj = '!';
255 new_d->marktype = '!';
256 new_d->linetype = '!';
257 new_d->marksize[0] = FSIG;
258 new_d->marksize[1] = FSIG;
259}
260*/
261
262Graph new_graph(gs, num)
263Graph gs;
264int num;
265{
266 Graph g;
267
268 g = (Graph) get_node(gs);
269 g->num = num;
270 g->xminval = 0.0;
271 g->yminval = 0.0;
272 g->xmaxval = 0.0;
273 g->ymaxval = 0.0;
274 g->x_axis = new_axis(1);
275 g->y_axis = new_axis(0);
276 g->x_translate = 0.0;
277 g->y_translate = 0.0;
278 g->curves = (Curve) make_list(sizeof(struct curve));
279 g->strings = (String) make_list(sizeof(struct string));
280 g->title = new_title();
281 g->clip = 0;
282 g->border = 0;
283 g->legend = new_legend();
284/* g->def = new_default(); */
285 prio_insert(g, gs, 0);
286 return g;
287}
288
289Graph get_graph(g, num)
290Graph g;
291int num;
292{
293 Graph new_g;
294 for(new_g = last(g); new_g != nil(g) && new_g->num > num; new_g = prev(new_g));
295 if (new_g == nil(g) || new_g->num < num) return new_graph(g, num);
296 return new_g;
297}
298
299new_graphs(gs)
300Graphs gs;
301{
302 Graphs newg;
303
304 newg = (Graphs) get_node(gs);
305 newg->g = (Graph) make_list(sizeof(struct graph));
306 newg->height = 0.0;
307 newg->width = 0.0;
308 newg->bb[0] = ISIG; newg->bb[1] = ISIG;
309 newg->bb[2] = ISIG; newg->bb[3] = ISIG;
310 newg->preamble = CNULL;
311 newg->epilogue = CNULL;
312 newg->prefile = 0;
313 newg->epifile = 0;
314 if (first(gs) == nil(gs)) newg->page = 1; else newg->page = last(gs)->page+1;
315 insert(newg, gs);
316}
317
318main(argc, argv)
319int argc;
320char **argv;
321{
322 Graphs gs;
323 int i;
324 int show, pp;
325 int landscape;
326 int comments;
327 int nfiles;
328
329#ifdef VMS
330 IOSTREAM = stdin; /* for token.c -hdd */
331#endif
332 show = 0;
333 pp = 0;
334 comments = 0;
335 landscape = 0;
336 nfiles = 0;
337
338 for (i = 1; i < argc; i++) {
339 if (strcmp(argv[i], "-p") == 0) show = 1;
340 else if (strcmp(argv[i], "-comments") == 0) comments = 1;
341 else if (strcmp(argv[i], "-P") == 0) pp = 1;
342 else if (strcmp(argv[i], "-L") == 0) landscape = 1;
343 else {
344 nfiles++;
345 set_input_file(argv[i]);
346 }
347 }
348 if (nfiles == 0) set_input_file(CNULL);
349 gs = (Graphs) make_list(sizeof(struct graphs));
350 set_comment(comments);
351 new_graphs(gs);
352 edit_graphs(gs);
353 process_graphs(gs);
354 if (show) show_graphs(gs); else draw_graphs(gs, pp, landscape);
355 exit(0);
356 return 0;
357}
358
359
Note: See TracBrowser for help on using the repository browser.