1 /*****************************************************************************
2 ** Copyright (C) 1998-2001 Ljubomir Milanovic & Horst Wagner
3 ** This file is part of the g2 library
5 ** This library is free software; you can redistribute it and/or
6 ** modify it under the terms of the GNU Lesser General Public
7 ** License as published by the Free Software Foundation; either
8 ** version 2.1 of the License, or (at your option) any later version.
10 ** This library is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ** Lesser General Public License for more details.
15 ** You should have received a copy of the GNU Lesser General Public
16 ** License along with this library; if not, write to the Free Software
17 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ******************************************************************************/
26 * g2 Fortran Interface
30 #define FIF(funame) funame ## __
32 #define FIF(funame) funame ## _
35 #define F_REAL float /* everything is float (real) !!!!!!!!!!!!!! */
36 #define F_CHAR char /* only char is char */
37 #define F_CHAR_LENGTH int /* and char length is integer (it is automatically supplied */
40 /**********************************************************/
50 F_REAL FIF(g2_open_ps)(F_CHAR *text, F_REAL *paper, F_REAL *orientation,
56 str=g2_malloc((length+1)*sizeof(char));
57 strncpy(str, text, length);
59 rv=g2_open_PS(str, dtoi(*paper), dtoi(*orientation));
67 /**********************************************************/
71 #include "X11/g2_X11.h"
73 F_REAL FIF(g2_open_x11)(F_REAL *width, F_REAL *height)
75 return (F_REAL)g2_open_X11(*width, *height);
78 /* g2_open_x11x is missing */
82 /**********************************************************/
88 F_REAL FIF(g2_open_gd)(F_CHAR *text, F_REAL *width, F_REAL *height, F_REAL *gd_type,
94 str=g2_malloc((length+1)*sizeof(char));
95 strncpy(str, text, length);
98 rv=g2_open_gd(str, *width, *height, *gd_type);
107 /**********************************************************/
110 F_REAL FIF(g2_open_vd)(void)
112 return (F_REAL)g2_open_vd();
116 void FIF(g2_attach)(F_REAL *vd_dev, F_REAL *dev)
118 g2_attach(dtoi(*vd_dev), dtoi(*dev));
122 void FIF(g2_detach)(F_REAL *vd_dev, F_REAL *dev)
124 g2_detach(dtoi(*vd_dev), dtoi(*dev));
129 void FIF(g2_close)(F_REAL *dev)
131 g2_close(dtoi(*dev));
135 void FIF(g2_set_auto_flush)(F_REAL *dev, F_REAL *on_off)
137 g2_set_auto_flush(dtoi(*dev), dtoi(*on_off));
141 void FIF(g2_set_coordinate_system)(F_REAL *dev,
142 F_REAL *x_origin, F_REAL *y_origin,
143 F_REAL *x_mul, F_REAL *y_mul)
145 g2_set_coordinate_system(dtoi(*dev),
146 *x_origin, *y_origin,
151 F_REAL FIF(g2_ld)(void)
153 return (F_REAL)g2_ld();
157 void FIF(g2_set_ld)(F_REAL *dev)
159 g2_set_ld(dtoi(*dev));
164 void FIF(g2_flush)(F_REAL *dev)
166 g2_flush(dtoi(*dev));
170 void FIF(g2_save)(F_REAL *dev)
178 void FIF(g2_arc)(F_REAL *dev, F_REAL *x, F_REAL *y,
179 F_REAL *r1, F_REAL *r2, F_REAL *a1, F_REAL *a2)
181 g2_arc(dtoi(*dev), *x, *y, *r1, *r2, *a1, *a2);
185 void FIF(g2_circle)(F_REAL *dev, F_REAL *x, F_REAL *y, F_REAL *r)
187 g2_circle(dtoi(*dev), *x, *y, *r);
191 void FIF(g2_clear)(F_REAL *dev)
193 g2_clear(dtoi(*dev));
197 void FIF(g2_clear_palette)(F_REAL *dev)
199 g2_clear_palette(dtoi(*dev));
203 void FIF(g2_string)(F_REAL *dev, F_REAL *x, F_REAL *y, F_CHAR *text,
204 F_CHAR_LENGTH length)
207 str=g2_malloc((length+1)*sizeof(char));
208 strncpy(str, text, length);
210 g2_string(dtoi(*dev), *x, *y, str);
215 void FIF(g2_ellipse)(F_REAL *dev, F_REAL *x, F_REAL *y, F_REAL *r1, F_REAL *r2)
217 g2_ellipse(dtoi(*dev), *x, *y, *r1, *r2);
221 void FIF(g2_filled_arc)(F_REAL *dev, F_REAL *x, F_REAL *y,
222 F_REAL *r1, F_REAL *r2,
223 F_REAL *a1, F_REAL *a2)
225 g2_filled_arc(dtoi(*dev), *x, *y, *r1, *r2, *a1, *a2);
229 void FIF(g2_filled_circle)(F_REAL *dev, F_REAL *x, F_REAL *y, F_REAL *r)
231 g2_filled_circle(dtoi(*dev), *x, *y, *r);
235 void FIF(g2_filled_ellipse)(F_REAL *dev, F_REAL *x, F_REAL *y, F_REAL *r1, F_REAL *r2)
237 g2_filled_ellipse(dtoi(*dev), *x, *y, *r1, *r2);
241 void FIF(g2_filled_triangle)(F_REAL *dev, F_REAL *x1, F_REAL *y1,
242 F_REAL *x2, F_REAL *y2,
243 F_REAL *x3, F_REAL *y3)
245 g2_filled_triangle(dtoi(*dev), *x1, *y1, *x2, *y2, *x3, *y3);
249 F_REAL FIF(g2_ink)(F_REAL *dev, F_REAL *red, F_REAL *green, F_REAL *blue)
251 return (F_REAL)g2_ink(dtoi(*dev), *red, *green, *blue);
255 void FIF(g2_line)(F_REAL *dev, F_REAL *x1, F_REAL *y1, F_REAL *x2, F_REAL *y2)
257 g2_line(dtoi(*dev), *x1, *y1, *x2, *y2);
261 void FIF(g2_poly_line)(F_REAL *dev, F_REAL *N_pt, F_REAL *points)
264 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
265 g2_poly_line(dtoi(*dev), dtoi(*N_pt), d);
270 void FIF(g2_polygon)(F_REAL *dev, F_REAL *N_pt, F_REAL *points)
273 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
274 g2_polygon(dtoi(*dev), dtoi(*N_pt), d);
279 void FIF(g2_filled_polygon)(F_REAL *dev, F_REAL *N_pt, F_REAL *points)
282 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
283 g2_filled_polygon(dtoi(*dev), dtoi(*N_pt), d);
288 void FIF(g2_line_r)(F_REAL *dev, F_REAL *dx, F_REAL *dy)
290 g2_line_r(dtoi(*dev), *dx, *dy);
294 void FIF(g2_line_to)(F_REAL *dev, F_REAL *x, F_REAL *y)
296 g2_line_to(dtoi(*dev), *x, *y);
300 void FIF(g2_move)(F_REAL *dev, F_REAL *x, F_REAL *y)
302 g2_move(dtoi(*dev), *x, *y);
306 void FIF(g2_move_r)(F_REAL *dev, F_REAL *dx, F_REAL *dy)
308 g2_move_r(dtoi(*dev), *dx, *dy);
312 void FIF(g2_pen)(F_REAL *dev, F_REAL *color)
314 g2_pen(dtoi(*dev), dtoi(*color));
318 void FIF(g2_plot)(F_REAL *dev, F_REAL *x, F_REAL *y)
320 g2_plot(dtoi(*dev), *x, *y);
324 void FIF(g2_plot_r)(F_REAL *dev, F_REAL *dx, F_REAL *dy)
326 g2_plot_r(dtoi(*dev), *dx, *dy);
330 void FIF(g2_rectangle)(F_REAL *dev,
331 F_REAL *x1, F_REAL *y1,
332 F_REAL *x2, F_REAL *y2)
334 g2_rectangle(dtoi(*dev), *x1, *y1, *x2, *y2);
338 void FIF(g2_filled_rectangle)(F_REAL *dev,
339 F_REAL *x1, F_REAL *y1,
340 F_REAL *x2, F_REAL *y2)
342 g2_filled_rectangle(dtoi(*dev), *x1, *y1, *x2, *y2);
346 void FIF(g2_reset_palette)(F_REAL *dev)
348 g2_reset_palette(dtoi(*dev));
352 void FIF(g2_set_background)(F_REAL *dev, F_REAL *color)
354 g2_set_background(dtoi(*dev), dtoi(*color));
358 void FIF(g2_set_dash)(F_REAL *dev, F_REAL *N, F_REAL *dashes)
361 d=g2_floatp2doublep(dashes, dtoi(*N));
362 g2_set_dash(dtoi(*dev), dtoi(*N), d);
367 void FIF(g2_set_font_size)(F_REAL *dev, F_REAL *size)
369 g2_set_font_size(dtoi(*dev), *size);
373 void FIF(g2_set_line_width)(F_REAL *dev, F_REAL *w)
375 g2_set_line_width(dtoi(*dev), *w);
379 void FIF(g2_triangle)(F_REAL *dev, F_REAL *x1, F_REAL *y1,
380 F_REAL *x2, F_REAL *y2,
381 F_REAL *x3, F_REAL *y3)
383 g2_triangle(dtoi(*dev), *x1, *y1, *x2, *y2, *x3, *y3);
387 void FIF(g2_set_qp)(F_REAL *dev, F_REAL *d, F_REAL *shape)
389 g2_set_QP(dtoi(*dev), *d, dtoi(*shape));
393 void FIF(g2_plot_qp)(F_REAL *dev, F_REAL *x, F_REAL *y)
395 g2_plot_QP(dtoi(*dev), *x, *y);
399 /* thanks to Yuri Sbitnev for contributing the g2_image code for FORTRAN */
400 void FIF(g2_image)(F_REAL *dev, F_REAL *x, F_REAL *y, F_REAL *x_size, F_REAL *y_size,
407 mypens=(int *) g2_malloc(xs*ys*sizeof(int));
410 mypens[j*xs+i]=dtoi(pens[j*xs+i]); /* pens[dtoi(*y_size)][dtoi(*x_size)] */
411 g2_image(dtoi(*dev), *x, *y, xs, ys, mypens);
420 void FIF(g2_spline)(F_REAL *dev, F_REAL *N_pt, F_REAL *points, F_REAL *o)
423 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
424 g2_spline(dtoi(*dev), dtoi(*N_pt), d, dtoi(*o));
428 void FIF(g2_b_spline)(F_REAL *dev, F_REAL *N_pt, F_REAL *points, F_REAL *o)
431 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
432 g2_b_spline(dtoi(*dev), dtoi(*N_pt), d, dtoi(*o));
436 void FIF(g2_raspln)(F_REAL *dev, F_REAL *N_pt, F_REAL *points, F_REAL *tn)
439 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
440 g2_raspln(dtoi(*dev), dtoi(*N_pt), d, *tn);
444 void FIF(g2_para_3)(F_REAL *dev, F_REAL *N_pt, F_REAL *points)
447 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
448 g2_para_3(dtoi(*dev), dtoi(*N_pt), d);
452 void FIF(g2_para_5)(F_REAL *dev, F_REAL *N_pt, F_REAL *points)
455 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
456 g2_para_5(dtoi(*dev), dtoi(*N_pt), d);
460 void FIF(g2_filled_spline)(F_REAL *dev, F_REAL *N_pt, F_REAL *points, F_REAL *o)
463 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
464 g2_filled_spline(dtoi(*dev), dtoi(*N_pt), d, dtoi(*o));
468 void FIF(g2_filled_b_spline)(F_REAL *dev, F_REAL *N_pt, F_REAL *points, F_REAL *o)
471 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
472 g2_filled_b_spline(dtoi(*dev), dtoi(*N_pt), d, dtoi(*o));
476 void FIF(g2_filled_raspln)(F_REAL *dev, F_REAL *N_pt, F_REAL *points, F_REAL *tn)
479 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
480 g2_filled_raspln(dtoi(*dev), dtoi(*N_pt), d, *tn);
484 void FIF(g2_filled_para_3)(F_REAL *dev, F_REAL *N_pt, F_REAL *points)
487 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
488 g2_filled_para_3(dtoi(*dev), dtoi(*N_pt), d);
492 void FIF(g2_filled_para_5)(F_REAL *dev, F_REAL *N_pt, F_REAL *points)
495 d=g2_floatp2doublep(points, dtoi(*N_pt)*2);
496 g2_filled_para_5(dtoi(*dev), dtoi(*N_pt), d);