- Timestamp:
- 02/27/08 07:13:31 (17 years ago)
- Location:
- trunk/Jgraph
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Jgraph/draw.c
r419 r420 22 22 error_header(); 23 23 fprintf(stderr, 24 "Value of %f is at negative infinity with log rhythmic %c axis\n",24 "Value of %f is at negative infinity with logarithmic %c axis\n", 25 25 val, (axis->is_x) ? 'x' : 'y'); 26 26 exit(1); 27 27 } 28 28 return (log(val) / axis->logfactor - axis->logmin) * axis->factor; … … 51 51 #define MAXIMUM(a,b) ((a > b) ? a : b) 52 52 53 draw_axis(a, other) 54 Axis a, other; 53 void draw_label(Label l) 54 { 55 if (l->label == CNULL) return; 56 comment(l->label); 57 print_label(l); 58 } 59 60 void draw_axis(Axis a, Axis other) 55 61 { 56 62 char orientation; … … 117 123 118 124 119 draw_label(l) 120 Label l; 121 { 122 if (l->label == CNULL) return; 123 comment(l->label); 124 print_label(l); 125 } 126 127 set_clip(g) 128 Graph g; 125 void set_clip(Graph g) 129 126 { 130 127 comment("Setting Clip"); … … 136 133 } 137 134 138 draw_curves(g) 139 Graph g; 135 void draw_curve(Curve c, Graph g); 136 137 void draw_curves(Graph g) 140 138 { 141 139 Curve c; … … 151 149 } 152 150 153 draw_curve(c, g) 154 Curve c; 155 Graph g; 151 void draw_mark(float x, float y, Curve c, Graph g); 152 void draw_arrow(float x1, float y1, float x2, float y2, Curve c); 153 154 void draw_curve(Curve c, Graph g) 156 155 { 157 156 Point p, px, py; … … 270 269 } 271 270 272 draw_mark(x, y, c, g) 273 float x, y; 274 Curve c; 275 Graph g; 271 void draw_mark(float x, float y, Curve c, Graph g) 276 272 { 277 273 Point p; … … 317 313 } 318 314 for (i = 0; i < 4; i++) { 319 if (fscanf(f, "%d", &(bb[i])) == NULL) {315 if (fscanf(f, "%d", &(bb[i])) == 0) { 320 316 fprintf(stderr, "Error: Eps file '%s': eof in %s\n", 321 317 c->eps, "bounding box"); … … 502 498 } 503 499 504 draw_arrow(x1, y1, x2, y2, c) 505 float x1, y1, x2, y2; 506 Curve c; 500 void draw_arrow(float x1, float y1, float x2, float y2, Curve c) 507 501 { 508 502 float dx, dy; … … 542 536 } 543 537 544 draw_legend(g) 545 Graph g; 538 void draw_legend(Graph g) 546 539 { 547 540 Curve c; … … 606 599 } 607 600 608 draw_strings(g) 609 Graph g; 601 void draw_strings(Graph g) 610 602 { 611 603 String s; … … 616 608 } 617 609 618 draw_graph(g) 619 Graph g; 610 void draw_graph(Graph g) 620 611 { 621 612 comment("Drawing New Graph"); … … 637 628 } 638 629 639 draw_graphs(gs, pp, landscape) 640 Graphs gs;641 int pp; 642 int landscape; 630 void draw_header(Graphs gs, int pp, int landscape); 631 void draw_footer(Graphs gs, int pp); 632 633 void draw_graphs(Graphs gs, int pp, int landscape) 643 634 { 644 635 Graphs gs_p; … … 661 652 } 662 653 663 draw_header(gs, pp, landscape) 664 Graphs gs; 665 int pp; 666 int landscape; 654 void draw_header(Graphs gs, int pp, int landscape) 667 655 { 668 656 FILE *f; … … 774 762 } 775 763 } else if (landscape) { 776 printf("% f0 translate\n", -gs->bb[2] - gs->bb[0]);764 printf("%d 0 translate\n", -gs->bb[2] - gs->bb[0]); 777 765 } 778 766 printf("1 setlinecap 1 setlinejoin\n"); … … 835 823 } 836 824 837 draw_footer(gs, pp) 838 Graphs gs; 839 int pp; 825 void draw_footer(Graphs gs, int pp) 840 826 { 841 827 FILE *f; -
trunk/Jgraph/edit.c
r418 r420 8 8 9 9 #include <stdio.h> 10 #include <string.h> 10 11 11 12 #include "jgraph.h" … … 14 15 #define MIN(a,b) ((a < b) ? a : b) 15 16 16 edit_label(l) 17 Label l; 17 void edit_label(Label l) 18 18 { 19 19 char *txt, inp_str[80]; … … 73 73 } 74 74 75 copy_curve(c1, c2) /* Copies curve c2 to c1 */ 76 Curve c1, c2; 75 void copy_curve(Curve c1, Curve c2) /* Copies curve c2 to c1 */ 77 76 { 78 77 Flist f, newf; … … 139 138 } 140 139 141 copy_label(l1, l2) /* Copies label l2 to l1 */ 142 Label l1, l2; 140 void copy_label(Label l1, Label l2) /* Copies label l2 to l1 */ 143 141 { 144 142 l1->label = l2->label; … … 157 155 } 158 156 159 copy_axis(a1, a2) /* Copies axis a2 to a1 */ 160 Axis a1, a2; 157 void copy_axis(Axis a1, Axis a2) /* Copies axis a2 to a1 */ 161 158 { 162 159 copy_label(a1->label, a2->label); … … 202 199 } 203 200 204 Curve do_copy_curve(g, gs, all_gs) 205 Graph g; 206 Graphs gs; 207 Graphs all_gs; 201 Curve do_copy_curve(Graph g, Graphs gs, Graphs all_gs) 208 202 { 209 203 Curve lastc, newc; … … 255 249 } 256 250 257 Label do_copy_string(g, gs, all_gs) 258 Graph g; 259 Graphs gs; 260 Graphs all_gs; 251 Label do_copy_string(Graph g, Graphs gs, Graphs all_gs) 261 252 { 262 253 String lastl, newl; … … 308 299 } 309 300 310 Graph last_graph(g, gs, all_gs) 311 Graph g; 312 Graphs gs; 313 Graphs all_gs; 301 Graph last_graph(Graph g, Graphs gs, Graphs all_gs) 314 302 { 315 303 Graph lastg; … … 330 318 } 331 319 332 copy_legend(l1, l2) 333 Legend l1, l2; 320 void copy_legend(Legend l1, Legend l2) 334 321 { 335 322 l1->linelength = l2->linelength; … … 340 327 } 341 328 342 inherit_axes(g, lastg) 343 Graph g; 344 Graph lastg; 329 void inherit_axes(Graph g, Graph lastg) 345 330 { 346 331 char *s; … … 357 342 } 358 343 359 getpattern(inp_str, key, p, a) 360 char *inp_str, *key, *p; 361 float *a; 344 void getpattern(char *inp_str, char *key, char *p, float *a) 362 345 { 363 346 int i; … … 386 369 } 387 370 388 edit_curve(c, g) 389 Curve c; 390 Graph g; 371 void edit_curve(Curve c, Graph g) 391 372 { 392 373 char inp_str[256], *txt; … … 681 662 } 682 663 683 edit_hash_label(a) 684 Axis a; 664 void edit_hash_label(Axis a) 685 665 { 686 666 float at, f; … … 732 712 } 733 713 734 edit_axis(a) 735 Axis a; 714 void edit_axis(Axis a) 736 715 { 737 716 char inp_str[256]; … … 908 887 } 909 888 910 edit_legend(l) 911 Legend l; 889 void edit_legend(Legend l) 912 890 { 913 891 char inp_str[256]; … … 975 953 } 976 954 977 edit_graph(g, gs, all_gs) 978 Graph g; 979 Graphs gs; 980 Graphs all_gs; 955 void edit_graph(Graph g, Graphs gs, Graphs all_gs) 981 956 { 982 957 char inp_str[80]; … … 1050 1025 } 1051 1026 1052 edit_graphs(gs) 1053 Graphs gs; 1027 void edit_graphs(Graphs gs) 1054 1028 { 1055 1029 Graphs the_g; -
trunk/Jgraph/jgraph.c
r418 r420 7 7 8 8 #include <stdio.h> 9 #include <string.h> 9 10 10 11 #ifdef VMS … … 297 298 } 298 299 299 new_graphs(gs) 300 Graphs gs; 300 void new_graphs(Graphs gs) 301 301 { 302 302 Graphs newg; … … 316 316 } 317 317 318 main(argc, argv) 319 int argc; 320 char **argv; 318 int main(int argc, char **argv) 321 319 { 322 320 Graphs gs; -
trunk/Jgraph/jgraph.h
r418 r420 241 241 extern char PTYPES[]; 242 242 extern int NPATTERNS; 243 244 void new_graphs(Graphs gs); 245 246 /* Stuff defined in printline.c */ 247 248 void print_label(Label l); 249 void set_comment(int c); 250 void comment(char *s); 251 void gsave(void); 252 void grestore(void); 253 void setlinewidth(float size); 254 void setlinestyle(char style, Flist glist); 255 void print_ebar(float x1, float y1, float x2, float ms, char orientation); 256 void start_line(float x1, float y1, Curve c); 257 void bezier_control(float x1, float y1); 258 void bezier_end(float x1, float y1); 259 void end_line(void); 260 void setfill(float x, float y, char t, float f[], char p, float a); 261 void cont_line(float x1, float y1); 262 void setgray(char t, float f[]); 263 void printline(float x1, float y1, float x2, float y2, char orientation); 264 void start_poly(float x1, float y1); 265 void cont_poly(float x1, float y1); 266 void end_poly(float x, float y, char ftype, float fill[], 267 char pattern, float parg); 268 void printellipse(float x, float y, float radius1, float radius2, 269 char ftype, float fill[], char pattern, float parg); 270 void setfont(char *f, float s); 271 272 /* Stuff defined in edit.c */ 273 274 void copy_label(Label l1, Label l2); 275 void edit_graphs(Graphs gs); 276 277 /* Stuff defined in token.c */ 278 279 void set_input_file(char *s); 280 int getint(int *i); 281 int getstring(char *s); 282 int getfloat(float *f); 283 void rejecttoken(void); 284 285 /* Stuff defined in process.c */ 286 287 void process_graphs(Graphs gs); 288 289 /* Stuff defined in show.c */ 290 291 void show_graphs(Graphs gs); 292 293 /* Stuff defined in draw.c */ 294 295 void draw_graphs(Graphs gs, int pp, int landscape); -
trunk/Jgraph/list.c
r418 r420 7 7 8 8 #include <stdio.h> /* Basic includes and definitions */ 9 #include <stdlib.h> 9 10 #include "list.h" 10 11 … … 33 34 } *Int_list; 34 35 35 insert(item, list) /* Inserts to the end of a list */ 36 List item; 37 List list; 36 void insert(void *item, void *list) /* Inserts to the end of a list */ 38 37 { 39 38 List last_node; 40 39 41 last_node = list->blink;40 last_node = ((List)list)->blink; 42 41 43 list->blink = item;42 ((List)list)->blink = item; 44 43 last_node->flink = item; 45 item->blink = last_node;46 item->flink = list;44 ((List)item)->blink = last_node; 45 ((List)item)->flink = list; 47 46 } 48 47 49 delete_item(item) /* Deletes an arbitrary iterm */ 50 List item; 48 void delete_item(void *item) /* Deletes an arbitrary iterm */ 51 49 { 52 item->flink->blink = item->blink;53 item->blink->flink = item->flink;50 ((List)item)->flink->blink = ((List)item)->blink; 51 ((List)item)->blink->flink = ((List)item)->flink; 54 52 } 55 53 … … 68 66 } 69 67 70 List get_node(list) /* Allocates a node to be inserted into the list */ 71 List list; 68 List get_node(void *list) /* Allocates a node to be inserted into the list */ 72 69 { 73 70 Int_list l; … … 84 81 } 85 82 86 free_node(node, list) /* Deallocates a node from the list */ 87 List node; 88 List list; 83 void free_node(void *node, void *list) /* Deallocates a node from the list */ 89 84 { 90 85 Int_list l; 91 86 92 87 l = (Int_list) list; 93 node->flink = l->free_list;88 ((List)node)->flink = l->free_list; 94 89 l->free_list = node; 95 90 } -
trunk/Jgraph/list.h
r418 r420 24 24 #define prev(n) (n->blink) 25 25 26 /* These are the routines for manip luating lists */26 /* These are the routines for manipulating lists */ 27 27 28 /* void insert(node list);Inserts a node to the end of a list */29 /* void delete_item(node);Deletes an arbitrary node */30 /* List make_list(node_size);Creates a new list */31 /* List get_node(list);Allocates a node to be inserted into the list */32 /* void free_node(node, list);Deallocates a node from the list */28 void insert(void *, void *);/* Inserts a node to the end of a list */ 29 void delete_item(void *); /* Deletes an arbitrary node */ 30 List make_list(int size); /* Creates a new list */ 31 List get_node(void *); /* Allocates a node to be inserted into the list */ 32 void free_node(void *, void *); /* Deallocates a node from the list */ 33 33 34 void error_header(); -
trunk/Jgraph/makefile
r419 r420 7 7 # jgraph.1 to be the directory containing the example jgraphs. 8 8 9 CC = cc9 CC = gcc -DLCC -Wall 10 10 11 11 OBJS = draw.o \ … … 94 94 token.o: token.c list.h 95 95 clean: 96 rm -f *.o a.out *.jps jgraph96 rm -f *.o a.out *.jps *.eps jgraph sin -
trunk/Jgraph/printline.c
r419 r420 9 9 #include <stdio.h> 10 10 #include <assert.h> //by pzn@debian.org 11 #include <string.h> 11 12 12 13 #define LINEWIDTHFACTOR 0.700 … … 25 26 static int Jgraph_comment; 26 27 27 gsave()28 void gsave(void) 28 29 { 29 30 if (Jgraph_gsave_level == -100) { … … 35 36 } 36 37 37 grestore()38 void grestore(void) 38 39 { 39 40 Fontlist l; … … 50 51 } 51 52 52 setfont(f, s) 53 char *f; 54 float s; 53 void setfont(char *f, float s) 55 54 { 56 55 Fontlist l; … … 77 76 } 78 77 79 setfill( x, y, t, f, p, a) 80 char t, p ; 81 float x, y; 82 float f[], a ; 78 void setfill(float x, float y, char t, float f[], char p, float a) 83 79 { 84 80 /* fprintf(stderr, "Hello? %c %f %c %f\n", t, f[0], p, a); */ … … 102 98 } 103 99 104 setgray( t, f) 105 char t ; 106 float f[] ; 100 void setgray(char t, float f[]) 107 101 { 108 102 if ( t == 'g' ) { … … 113 107 } 114 108 115 printline(x1, y1,x2, y2, orientation) 116 float x1, y1, x2, y2; 117 char orientation; 109 void printline(float x1, float y1, float x2, float y2, char orientation) 118 110 { 119 111 if (orientation == 'x') … … 124 116 } 125 117 126 print_ebar(x1, y1, x2, ms, orientation) 127 float x1, y1, x2, ms; 128 char orientation; 118 void print_ebar(float x1, float y1, float x2, float ms, char orientation) 129 119 { 130 120 printline(x1, y1, x2, y1, orientation); … … 132 122 } 133 123 134 start_line(x1, y1, c) 135 float x1, y1; 136 Curve c; 124 void start_line(float x1, float y1, Curve c) 137 125 { 138 126 setlinewidth(c->linethick); … … 141 129 } 142 130 143 cont_line(x1, y1) 144 float x1, y1; 131 void cont_line(float x1, float y1) 145 132 { 146 133 printf(" %f %f lineto\n", x1, y1); 147 134 } 148 135 149 end_line()136 void end_line(void) 150 137 { 151 138 printf("stroke\n"); … … 156 143 } 157 144 158 bezier_control(x1, y1) 159 float x1, y1; 145 void bezier_control(float x1, float y1) 160 146 { 161 147 printf(" %f %f ", x1, y1); 162 148 } 163 149 164 bezier_end(x1, y1) 165 float x1, y1; 150 void bezier_end(float x1, float y1) 166 151 { 167 152 printf(" %f %f curveto\n", x1, y1); … … 169 154 170 155 171 start_poly(x1, y1) 172 float x1, y1; 156 void start_poly(float x1, float y1) 173 157 { 174 158 printf(" newpath %f %f moveto", x1, y1); 175 159 } 176 160 177 cont_poly(x1, y1) 178 float x1, y1; 161 void cont_poly(float x1, float y1) 179 162 { 180 163 printf(" %f %f lineto\n", x1, y1); 181 164 } 182 165 183 end_poly(x, y, ftype, fill, pattern, parg) 184 float x, y; 185 char ftype, pattern ; 186 float fill[], parg; 166 void end_poly(float x, float y, char ftype, float fill[], 167 char pattern, float parg) 187 168 { 188 169 printf("closepath "); … … 194 175 /* Ellipse at 0, 0 -- assumes that you've already translated to x, y */ 195 176 196 printellipse(x, y, radius1, radius2, ftype, fill, pattern, parg) 197 char ftype, pattern; 198 float x, y, radius1, radius2, fill[], parg; 177 void printellipse(float x, float y, float radius1, float radius2, 178 char ftype, float fill[], char pattern, float parg) 199 179 { 200 180 printf("newpath %f %f JDE\n", radius1, radius2); … … 204 184 } 205 185 206 set_comment(c) 207 int c; 186 void set_comment(int c) 208 187 { 209 188 Jgraph_comment = c; 210 189 } 211 190 212 comment(s) 213 char *s; 191 void comment(char *s) 214 192 { 215 193 if (Jgraph_comment) printf("%% %s\n", s); 216 194 } 217 195 218 printline_c(x1, y1, x2, y2, g) 219 float x1, y1, x2, y2; 220 Graph g; 196 void printline_c(float x1, float y1, float x2, float y2, Graph g) 221 197 { 222 198 printline(ctop(x1, g->x_axis), ctop(y1, g->y_axis), … … 224 200 } 225 201 226 print_label(l) 227 Label l; 202 void print_label(Label l) 228 203 { 229 204 int f, i, nlines; 230 205 float fnl; 231 206 char *s; 232 unsignedchar *s_7bit; // added by pzn@debian.org207 char *s_7bit; // added by pzn@debian.org 233 208 234 209 if (l->label == CNULL) return; … … 317 292 } 318 293 319 setlinewidth(size) 320 float size; 294 void setlinewidth(float size) 321 295 { 322 296 printf("%f setlinewidth ", size * LINEWIDTHFACTOR); 323 297 } 324 298 325 setlinestyle(style, glist) 326 char style; 327 Flist glist; 299 void setlinestyle(char style, Flist glist) 328 300 { 329 301 Flist fl; -
trunk/Jgraph/prio_list.c
r418 r420 10 10 #include <stdio.h> 11 11 12 typedef int Boolean;13 14 /* A prioirity list is any list with the first three fields being flink,15 * blink and prio. Use the routines of list.c to do everything except16 * insertion */17 18 typedef struct prio_list {19 struct prio_list *flink;20 struct prio_list *blink;21 int prio;22 } *Prio_list;23 12 24 13 /* Prio_insert inserts nodes into their proper places in priority lists. It first … … 26 15 * Thus, it is worst case linear, but for most cases constant time (right). */ 27 16 28 prio_insert(node, list, desc) 29 Prio_list node; 30 Prio_list list; 31 Boolean desc; 17 void prio_insert(void *n, void *l, Boolean desc) 32 18 { 33 Prio_list p ;19 Prio_list p, node = (Prio_list)n, list = (Prio_list)l; 34 20 35 21 /* Check nil and head of list */ -
trunk/Jgraph/prio_list.h
r418 r420 6 6 */ 7 7 8 /* Priority lists are just like normal lists of list.h and list.c, except 9 * that their third field is a (int) prioriy. The routines of list.c should all 10 * be used except for insert, because it will always put an item at the 11 * end of a list. Instead, use prio_insert, which will put the item 12 * into its proper place in the list. The last argument of prio_insert should 13 * be TRUE if the list is to be kept in descending order; it should be FALSE 14 * for ascending order. 8 /* Priority lists are just like normal lists of list.h and list.c, 9 * except that their third field is a (int) priority. The routines of 10 * list.c should all be used except for insert, because it will always 11 * put an item at the end of a list. Instead, use prio_insert, which 12 * will put the item into its proper place in the list. The last 13 * argument of prio_insert should be TRUE if the list is to be kept in 14 * descending order; it should be FALSE for ascending order. 15 */ 15 16 16 * Priority list should be: 17 18 struct prio_list { 17 /* A priority list is any list with the first three fields being flink, 18 * blink and prio. Use the routines of list.c to do everything except 19 * insertion */ 20 21 typedef struct prio_list { 19 22 struct prio_list *flink; 20 23 struct prio_list *blink; 21 24 int prio; 22 ...23 } 25 /* ... */ 26 } *Prio_list; 24 27 25 */ 28 typedef int Boolean; 26 29 27 /* void prio_insert(node, list, descending); */ 30 void prio_insert(void *node, void *list, Boolean descending); 28 31 -
trunk/Jgraph/process.c
r418 r420 8 8 #include <stdio.h> 9 9 #include <math.h> 10 #include <string.h> 10 11 11 12 #include "jgraph.h" … … 19 20 static double Pi; 20 21 21 process_title(g) 22 Graph g; 22 void process_label(Label l, Graph g, int adjust); 23 24 void process_title(Graph g) 23 25 { 24 26 … … 44 46 } 45 47 46 process_legend(g) 47 Graph g; 48 void process_label_max_n_mins(Label l, float len, float height) 49 { 50 float xlen, ylen, xheight, yheight; 51 float x, y; 52 53 xlen = len * cos(l->rotate * Pi / 180.00); 54 ylen = height * cos((l->rotate + 90.0) * Pi / 180.00); 55 xheight = len * sin(l->rotate * Pi / 180.00); 56 yheight = height * sin((l->rotate + 90.0) * Pi / 180.00); 57 58 x = l->x; 59 y = l->y; 60 61 if (l->hj == 'c') { 62 x -= xlen / 2.0; 63 y -= xheight / 2.0; 64 } else if (l->hj == 'r') { 65 x -= xlen; 66 y -= xheight; 67 } 68 if (l->vj == 'c') { 69 x -= ylen / 2.0; 70 y -= yheight / 2.0; 71 } else if (l->vj == 't') { 72 x -= ylen; 73 y -= yheight; 74 } 75 76 l->xmin = MIN(x, x + xlen); 77 l->xmin = MIN(l->xmin, x + xlen + ylen); 78 l->xmin = MIN(l->xmin, x + ylen); 79 80 l->ymin = MIN(y, y + xheight); 81 l->ymin = MIN(l->ymin, y + yheight); 82 l->ymin = MIN(l->ymin, y + xheight + yheight); 83 84 l->xmax = MAX(x, x + xlen); 85 l->xmax = MAX(l->xmax, x + xlen + ylen); 86 l->xmax = MAX(l->xmax, x + ylen); 87 88 l->ymax = MAX(y, y + xheight); 89 l->ymax = MAX(l->ymax, y + yheight); 90 l->ymax = MAX(l->ymax, y + xheight + yheight); 91 92 } 93 94 void process_legend(Graph g) 48 95 { 49 96 Legend l; … … 209 256 } 210 257 211 float find_reasonable_hash_interval(a) 212 Axis a; 258 float find_reasonable_hash_interval(Axis a) 213 259 { 214 260 float s, d; … … 238 284 } 239 285 240 float find_reasonable_hash_start(a) 241 Axis a; 286 float find_reasonable_hash_start(Axis a) 242 287 { 243 288 int i; … … 249 294 } 250 295 251 int find_reasonable_precision(a) 252 Axis a; 296 int find_reasonable_precision(Axis a) 253 297 { 254 298 int i, b, b2, done; … … 293 337 } 294 338 295 int find_reasonable_minor_hashes(a) 296 Axis a; 339 int find_reasonable_minor_hashes(Axis a) 297 340 { 298 341 float d; … … 316 359 } 317 360 318 process_axis1(a, g) 319 Axis a; 320 Graph g; 361 void process_axis1(Axis a, Graph g) 321 362 { 322 363 float tmp; … … 386 427 } 387 428 388 process_axis2(a, g) 389 Axis a; 390 Graph g; 429 void process_axis2(Axis a, Graph g) 391 430 { 392 431 float t1, t2, t3, minor_hashes, hloc, tmp; … … 576 615 } 577 616 578 process_label(l, g, adjust) 579 Label l; 580 Graph g; 581 int adjust; 617 void process_label(Label l, Graph g, int adjust) 582 618 { 583 619 float len, height; … … 618 654 } 619 655 620 process_label_max_n_mins(l, len, height) 621 Label l; 622 float len; 623 float height; 624 { 625 float xlen, ylen, xheight, yheight; 626 float x, y; 627 628 xlen = len * cos(l->rotate * Pi / 180.00); 629 ylen = height * cos((l->rotate + 90.0) * Pi / 180.00); 630 xheight = len * sin(l->rotate * Pi / 180.00); 631 yheight = height * sin((l->rotate + 90.0) * Pi / 180.00); 632 633 x = l->x; 634 y = l->y; 635 636 if (l->hj == 'c') { 637 x -= xlen / 2.0; 638 y -= xheight / 2.0; 639 } else if (l->hj == 'r') { 640 x -= xlen; 641 y -= xheight; 642 } 643 if (l->vj == 'c') { 644 x -= ylen / 2.0; 645 y -= yheight / 2.0; 646 } else if (l->vj == 't') { 647 x -= ylen; 648 y -= yheight; 649 } 650 651 l->xmin = MIN(x, x + xlen); 652 l->xmin = MIN(l->xmin, x + xlen + ylen); 653 l->xmin = MIN(l->xmin, x + ylen); 654 655 l->ymin = MIN(y, y + xheight); 656 l->ymin = MIN(l->ymin, y + yheight); 657 l->ymin = MIN(l->ymin, y + xheight + yheight); 658 659 l->xmax = MAX(x, x + xlen); 660 l->xmax = MAX(l->xmax, x + xlen + ylen); 661 l->xmax = MAX(l->xmax, x + ylen); 662 663 l->ymax = MAX(y, y + xheight); 664 l->ymax = MAX(l->ymax, y + yheight); 665 l->ymax = MAX(l->ymax, y + xheight + yheight); 666 667 } 668 669 process_strings(g) 670 Graph g; 656 void process_strings(Graph g) 671 657 { 672 658 String s; … … 677 663 } 678 664 679 process_curve(c, g) 680 Curve c; 681 Graph g; 665 void process_curve(Curve c, Graph g) 682 666 { 683 667 if (c->bezier && (c->npts < 4 || (c->npts % 3 != 1))) { … … 705 689 } 706 690 707 process_curves(g) 708 Graph g; 691 void process_curves(Graph g) 709 692 { 710 693 Curve c; … … 713 696 } 714 697 } 698 699 void process_label_extrema(Label l, Graph g) 700 { 701 if (l->label == CNULL) return; 702 g->yminval = MIN(g->yminval, l->ymin); 703 g->ymaxval = MAX(g->ymaxval, l->ymax); 704 g->xminval = MIN(g->xminval, l->xmin); 705 g->xmaxval = MAX(g->xmaxval, l->xmax); 706 } 715 707 716 process_extrema(g) /* This finds all the minval/maxvals for bbox calc */ 717 Graph g; 708 void process_extrema(Graph g) /* Finds all the minval/maxvals for bbox calc */ 718 709 { 719 710 Curve c; … … 764 755 } 765 756 766 process_label_extrema(l, g) 767 Label l; 768 Graph g; 769 { 770 if (l->label == CNULL) return; 771 g->yminval = MIN(g->yminval, l->ymin); 772 g->ymaxval = MAX(g->ymaxval, l->ymax); 773 g->xminval = MIN(g->xminval, l->xmin); 774 g->xmaxval = MAX(g->xmaxval, l->xmax); 775 } 776 777 process_graph(g) 778 Graph g; 757 void process_graph(Graph g) 779 758 { 780 759 g->x_translate = intop(g->x_translate); … … 791 770 } 792 771 793 process_graphs(gs) 794 Graphs gs; 772 void process_graphs(Graphs gs) 795 773 { 796 774 Graphs the_g; -
trunk/Jgraph/show.c
r418 r420 10 10 #include "jgraph.h" 11 11 12 static spaces(nsp) 13 int nsp; 12 static void spaces(int nsp) 14 13 { 15 14 while(nsp-- > 0) putchar(' '); … … 44 43 } 45 44 46 static show_mltiline(s) 47 char *s; 45 static void show_mltiline(char *s) 48 46 { 49 47 int i; … … 58 56 } 59 57 60 show_string(s) 61 char *s; 58 void show_string(char *s) 62 59 { 63 60 int i; … … 75 72 76 73 77 show_label(l, nsp, g) 78 Label l; 79 int nsp; 80 Graph g; 74 void show_label(Label l, int nsp, Graph g) 81 75 { 82 76 spaces(nsp); … … 96 90 printf("lcolor %f %f %f\n", l->gray[0], l->gray[1], l->gray[2]); 97 91 } 98 return; 99 } 100 101 show_lmark(l, nsp, g) 102 Label l; 103 int nsp; 104 Graph g; 92 } 93 94 void show_lmark(Label l, int nsp, Graph g) 105 95 { 106 96 spaces(nsp); show_string(l->label); … … 111 101 spaces(nsp); printf("font %s ", l->font); 112 102 printf("fontsize %f\n", l->fontsize); 113 return; 114 } 115 116 show_curve(c, nsp, g) 117 Curve c; 118 int nsp; 119 Graph g; 103 } 104 105 void show_curve(Curve c, int nsp, Graph g) 120 106 { 121 107 Point p; … … 252 238 } 253 239 254 show_axis(a, nsp, g) 255 Axis a; 256 int nsp; 257 Graph g; 240 void show_axis(Axis a, int nsp, Graph g) 258 241 { 259 242 Axis other; … … 343 326 } 344 327 345 show_legend(l, nsp, g) 346 Legend l; 347 int nsp; 348 Graph g; 328 void show_legend(Legend l, int nsp, Graph g) 349 329 { 350 330 if (l->type == 'c') { … … 363 343 } 364 344 365 show_graph(g, nsp) 366 Graph g; 367 int nsp; 345 void show_graph(Graph g, int nsp) 368 346 { 369 347 … … 395 373 } 396 374 397 show_graphs(gs) 398 Graphs gs; 375 void show_graphs(Graphs gs) 399 376 { 400 377 Graphs the_g; -
trunk/Jgraph/sin.c
r418 r420 1 #include <stdio.h> 1 2 #include <math.h> 2 main()3 int main(void) 3 4 { 4 5 double x; 5 6 for (x = -10.0; x < 10.0; x += .03) 6 7 printf("%f %f\n", x, sin(x)); 8 return 0; 7 9 } -
trunk/Jgraph/token.c
r418 r420 8 8 #include <math.h> 9 9 #include <stdio.h> 10 #include <string.h> 10 11 11 12 #ifdef LCC … … 36 37 static int getnew = 1; 37 38 static char oldchar = '\0'; 38 static oldcharvalid = 0;39 static int oldcharvalid = 0; 39 40 static char pipe = 0; 40 41 static int eof = 0; … … 61 62 #endif /*VMS*/ 62 63 63 set_input_file(s) 64 char *s; 65 { 66 FILE *f; 64 void set_input_file(char *s) 65 { 67 66 Iostack n; 68 67 … … 94 93 } 95 94 96 error_header()95 void error_header() 97 96 { 98 97 fprintf(stderr, "%s,%d: ", FILENAME, line); … … 107 106 } 108 107 109 ungettokenchar()108 void ungettokenchar() 110 109 { 111 110 oldcharvalid = 1; … … 132 131 } 133 132 134 get_comment()133 void get_comment() 135 134 { 136 135 if (eof) return; … … 149 148 } 150 149 151 static push_iostack(p) 152 int p; 150 static void push_iostack(int p) 153 151 { 154 152 Iostack n; … … 178 176 } 179 177 180 static pop_iostack()178 static void pop_iostack() 181 179 { 182 180 Iostack n; … … 196 194 n->stream = fopen(n->filename, "r"); 197 195 if (n->stream == NULL) { 198 fprintf(stderr, "Error: cannot open file \"%s\"\n", n-> stream);196 fprintf(stderr, "Error: cannot open file \"%s\"\n", n->filename); 199 197 exit(1); 200 198 } … … 211 209 } 212 210 213 static nexttoken() 211 int getsystemstring(void); 212 213 static void nexttoken() 214 214 { 215 215 if (eof) return; … … 256 256 } 257 257 getnew = 1; 258 return; 259 } 260 261 int getstring(s) 262 char *s; 258 } 259 260 int getstring(char *s) 263 261 { 264 262 nexttoken(); … … 268 266 } 269 267 270 int getint(i) 271 int *i; 268 int getint(int *i) 272 269 { 273 270 int j; … … 283 280 } 284 281 285 int getfloat(f) 286 float *f; 282 int getfloat(float *f) 287 283 { 288 284 int j; … … 335 331 { 336 332 char c; 337 int i, j,done, len, started;333 int i, done, len, started; 338 334 char *out_str; 339 335 … … 375 371 char *getlabel() 376 372 { 377 char c;378 373 char *txt, *new; 379 int i;380 374 381 375 txt = getmultiline(); … … 416 410 } 417 411 418 rejecttoken()412 void rejecttoken(void) 419 413 { 420 414 getnew = 0;
Note:
See TracChangeset
for help on using the changeset viewer.