Annotation of OpenXM_contrib/pari-2.2/src/graph/Gnuplot.h, Revision 1.1
1.1 ! noro 1: /* $Id: Gnuplot.h,v 1.5 2001/03/13 17:56:52 karim Exp $
! 2:
! 3: Copyright (C) 2000 The PARI group.
! 4:
! 5: This file is part of the PARI/GP package.
! 6:
! 7: PARI/GP is free software; you can redistribute it and/or modify it under the
! 8: terms of the GNU General Public License as published by the Free Software
! 9: Foundation. It is distributed in the hope that it will be useful, but WITHOUT
! 10: ANY WARRANTY WHATSOEVER.
! 11:
! 12: Check the License for details. You should have received a copy of it, along
! 13: with the package; see the file 'COPYING'. If not, write to the Free Software
! 14: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
! 15:
! 16: /* This header should be included in one C file only! */
! 17:
! 18: #include <stdio.h>
! 19: #include <stdlib.h>
! 20: #include <setjmp.h>
! 21:
! 22: #ifdef __cplusplus
! 23: extern "C" {
! 24: #endif
! 25:
! 26: /* CAT2:
! 27: * This macro catenates 2 tokens together.
! 28: */
! 29: /* STRINGIFY:
! 30: * This macro surrounds its token with double quotes.
! 31: */
! 32: #ifndef CAT2
! 33: # if 42 == 1
! 34: # define CAT2(a,b)a/**/b
! 35: # define CAT3(a,b,c)a/**/b/**/c
! 36: # define CAT4(a,b,c,d)a/**/b/**/c/**/d
! 37: # define CAT5(a,b,c,d,e)a/**/b/**/c/**/d/**/e
! 38: # define STRINGIFY(a)"a"
! 39: /* If you can get stringification with catify, tell me how! */
! 40: # endif
! 41: # if 42 == 42
! 42: # define CAT2(a,b)a ## b
! 43: # define CAT3(a,b,c)a ## b ## c
! 44: # define CAT4(a,b,c,d)a ## b ## c ## d
! 45: # define CAT5(a,b,c,d,e)a ## b ## c ## d ## e
! 46: # define StGiFy(a)# a
! 47: # define STRINGIFY(a)StGiFy(a)
! 48: # define SCAT2(a,b)StGiFy(a) StGiFy(b)
! 49: # define SCAT3(a,b,c)StGiFy(a) StGiFy(b) StGiFy(c)
! 50: # define SCAT4(a,b,c,d)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d)
! 51: # define SCAT5(a,b,c,d,e)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d) StGiFy(e)
! 52: # endif
! 53: # ifndef CAT2
! 54: # include "Bletch: How does this C preprocessor catenate tokens?"
! 55: # endif
! 56: #endif /* CAT2 */
! 57:
! 58:
! 59: #define TERM_CAN_MULTIPLOT 1 /* tested if stdout not redirected */
! 60: #define TERM_CANNOT_MULTIPLOT 2 /* tested if stdout is redirected */
! 61: #define TERM_BINARY 4 /* open output file with "b" */
! 62:
! 63: #ifndef NO_JUNK_SMALL
! 64:
! 65: /* Compatibility with the old gnuplot: */
! 66: extern FILE *outfile;
! 67: FILE *outfile = NULL;
! 68:
! 69: extern FILE *gpoutfile;
! 70: FILE *gpoutfile = NULL;
! 71:
! 72: static outfile_set;
! 73: static void
! 74: set_gpoutfile(void)
! 75: {
! 76: outfile = stdout;
! 77: gpoutfile = stdout;
! 78: }
! 79:
! 80: #define SET_OUTFILE (outfile_set++ ? 1 : (set_gpoutfile(), 1))
! 81:
! 82: extern int encoding;
! 83: int encoding = 0;
! 84: extern float xoffset; /* x origin */
! 85: extern float yoffset; /* y origin */
! 86: float xoffset = 0.0; /* x origin */
! 87: float yoffset = 0.0; /* y origin */
! 88: extern int multiplot;
! 89: int multiplot = 0;
! 90:
! 91: extern char *outstr;
! 92: #define MAX_ID_LEN 50
! 93: /* char outstr[MAX_ID_LEN+1] = "STDOUT"; */
! 94: char *outstr = NULL;
! 95: extern double ticscale; /* scale factor for tic marks (was (0..1])*/
! 96: double ticscale = 1.0; /* scale factor for tic mark */
! 97:
! 98: char *input_line = NULL;
! 99: int inline_num; /* from command.c */
! 100:
! 101: float xsize=1.0, ysize=1.0;
! 102: double pointsize=1.0; /* During test! */
! 103:
! 104: int interactive; /* from plot.c */
! 105: char *infile_name; /* from plot.c */
! 106: extern char default_font[];
! 107: char default_font[MAX_ID_LEN+1] = "\0"; /* Entry added by DJL */
! 108:
! 109: typedef int TBOOLEAN;
! 110:
! 111: enum DATA_TYPES {
! 112: INTGR, CMPLX
! 113: };
! 114:
! 115: #if !(defined(ATARI)&&defined(__GNUC__)&&defined(_MATH_H)) && !(defined(MTOS)&&defined(__GNUC__)&&defined(_MATH_H)) /* FF's math.h has the type already */
! 116: struct cmplx {
! 117: double real, imag;
! 118: };
! 119: #endif
! 120:
! 121: struct value {
! 122: enum DATA_TYPES type;
! 123: union {
! 124: int int_val;
! 125: struct cmplx cmplx_val;
! 126: } v;
! 127: };
! 128:
! 129: struct lexical_unit { /* produced by scanner */
! 130: TBOOLEAN is_token; /* true if token, false if a value */
! 131: struct value l_val;
! 132: int start_index; /* index of first char in token */
! 133: int length; /* length of token in chars */
! 134: };
! 135:
! 136: /* char *token; */
! 137: #define MAX_TOKENS 20
! 138: extern struct lexical_unit *token;
! 139: struct lexical_unit tokens[MAX_TOKENS]; /* We only process options,
! 140: there should not be many */
! 141: struct lexical_unit *token = tokens;
! 142: long c_token = 0, num_tokens = 0;
! 143: char term_options[200] = "";
! 144:
! 145: /* New with 3.7.1: */
! 146:
! 147: #define FIRST_Z_AXIS 0
! 148: #define FIRST_Y_AXIS 1
! 149: #define FIRST_X_AXIS 2
! 150: #define SECOND_Z_AXIS 4 /* for future expansion ;-) */
! 151: #define SECOND_Y_AXIS 5
! 152: #define SECOND_X_AXIS 6
! 153: /* extend list for datatype[] for t,u,v,r though IMHO
! 154: * they are not relevant to time data [being parametric dummies]
! 155: */
! 156: #define T_AXIS 3 /* fill gap */
! 157: #define R_AXIS 7 /* never used ? */
! 158: #define U_AXIS 8
! 159: #define V_AXIS 9
! 160:
! 161: #define AXIS_ARRAY_SIZE 10
! 162: #define DATATYPE_ARRAY_SIZE 10
! 163:
! 164: extern double base_array[], log_base_array[];
! 165: extern TBOOLEAN log_array[];
! 166: /* graphics.c */
! 167: extern TBOOLEAN is_3d_plot;
! 168:
! 169: double min_array[AXIS_ARRAY_SIZE], max_array[AXIS_ARRAY_SIZE], base_array[AXIS_ARRAY_SIZE], log_base_array[AXIS_ARRAY_SIZE];
! 170: TBOOLEAN log_array[AXIS_ARRAY_SIZE];
! 171: int xleft, xright, ybot, ytop;
! 172: TBOOLEAN is_3d_plot;
! 173:
! 174: /* End of 3.7.1 additions */
! 175:
! 176: /* 3.7.0-devel additions */
! 177:
! 178: extern float surface_rot_z;
! 179: extern TBOOLEAN polar;
! 180: extern double base_log_x, base_log_y, base_log_z;
! 181: extern TBOOLEAN is_log_x, is_log_y, is_log_z;
! 182: extern double log_base_log_x2, log_base_log_y2;
! 183: extern double base_z;
! 184: extern TBOOLEAN screen_ok;
! 185:
! 186: float surface_rot_z = 30.0;
! 187: TBOOLEAN polar = 0;
! 188: TBOOLEAN is_log_x = 0;
! 189: TBOOLEAN is_log_y = 0;
! 190: TBOOLEAN is_log_z = 0;
! 191: double base_log_x = 0.0;
! 192: double base_log_y = 0.0;
! 193: double base_log_z = 0.0;
! 194: double log_base_log_x = 0.0;
! 195: double log_base_log_y = 0.0;
! 196: double log_base_log_z = 0.0;
! 197: double base_z = 0.0;
! 198: TBOOLEAN screen_ok;
! 199:
! 200: void map3d_xy (double x, double y, double z, unsigned int *xt, unsigned int *yt)
! 201: {
! 202: croak("Unsupported function map3d_xy called");
! 203: }
! 204:
! 205: /* End of 3.7.0-devel additions */
! 206:
! 207: /* Here are the only missing functions: */
! 208:
! 209: struct value*
! 210: const_express(struct value*v)
! 211: {
! 212: if (token[c_token].is_token)
! 213: croak("Expect a number, got a string");
! 214: *v = token[c_token++].l_val;
! 215: return v;
! 216: }
! 217:
! 218: void*
! 219: gp_alloc(unsigned long size, char *usage)
! 220: {
! 221: (void)usage;
! 222: return malloc(size);
! 223: }
! 224:
! 225: void*
! 226: gp_realloc(void *old, unsigned long size, char *usage)
! 227: {
! 228: (void)usage;
! 229: return realloc(old,size);
! 230: }
! 231:
! 232: void
! 233: bail_to_command_line()
! 234: {
! 235: croak("panic: gnuplot");
! 236: }
! 237:
! 238: #endif /* NO_JUNK_SMALL */
! 239:
! 240: /* Cannot pull the whole plot.h, too many contradictions. */
! 241:
! 242: #ifdef __ZTC__
! 243: typedef int (*FUNC_PTR)(...);
! 244: #else
! 245: typedef int (*FUNC_PTR)();
! 246: #endif
! 247:
! 248: struct TERMENTRY {
! 249: char *name;
! 250: #if defined(_Windows) && !defined(WIN32)
! 251: char GPFAR description[80]; /* to make text go in FAR segment */
! 252: #else
! 253: char *description;
! 254: #endif
! 255: unsigned int xmax,ymax,v_char,h_char,v_tic,h_tic;
! 256: FUNC_PTR options,init,reset,text,scale,graphics,move,vector,linetype,
! 257: put_text,text_angle,justify_text,point,arrow,set_font,
! 258: pointsize;
! 259: int flags;
! 260: FUNC_PTR suspend,resume,fillbox,linewidth;
! 261: };
! 262:
! 263: #ifdef _Windows
! 264: # define termentry TERMENTRY far
! 265: #else
! 266: # define termentry TERMENTRY
! 267: #endif
! 268:
! 269: extern struct termentry *term;
! 270: struct termentry *term;
! 271:
! 272: #define RETVOID
! 273: #define RETINT , 1
! 274:
! 275: #define F_0 void(*)()
! 276: #define F_1 void(*)(int)
! 277: #define F_1I int(*)(int)
! 278: #define F_1D void(*)(double)
! 279: #define F_1IP int(*)(char*)
! 280: #define F_2 void(*)(unsigned int,unsigned int)
! 281: #define F_2D int(*)(double,double)
! 282: #define F_3 void(*)(unsigned int,unsigned int,int)
! 283: #define F_3T void(*)(int,int,char*)
! 284: #define F_4 void(*)(int,int,int,int)
! 285: #define F_5 void(*)(int,int,int,int,int)
! 286:
! 287: #define CALL_G_METH0(method) CALL_G_METH(method,0,(),RETVOID)
! 288: #define CALL_G_METH1(method,arg1) CALL_G_METH(method,1,(arg1),RETVOID)
! 289: #define CALL_G_METH1I(method,arg1) CALL_G_METH(method,1I,(arg1),RETINT)
! 290: #define CALL_G_METH1D(method,arg1) CALL_G_METH(method,1D,(arg1),RETVOID)
! 291: #define CALL_G_METH1IP(method,arg1) CALL_G_METH(method,1IP,(arg1),RETINT)
! 292: #define CALL_G_METH2(method,arg1,arg2) \
! 293: CALL_G_METH(method,2,((arg1),(arg2)),RETVOID)
! 294: #define CALL_G_METH2D(method,arg1,arg2) \
! 295: CALL_G_METH(method,2D,((arg1),(arg2)),RETINT)
! 296: #define CALL_G_METH3(method,arg1,arg2,arg3) \
! 297: CALL_G_METH(method,3,((arg1),(arg2),(arg3)),RETVOID)
! 298: #define CALL_G_METH3T(method,arg1,arg2,arg3) \
! 299: CALL_G_METH(method,3T,((arg1),(arg2),(arg3)),RETVOID)
! 300: #define CALL_G_METH4(method,arg1,arg2,arg3,arg4) \
! 301: CALL_G_METH(method,4,((arg1),(arg2),(arg3),(arg4)),RETVOID)
! 302: #define CALL_G_METH5(method,arg1,arg2,arg3,arg4,arg5) \
! 303: CALL_G_METH(method,5,((arg1),(arg2),(arg3),(arg4),(arg5)),RETVOID)
! 304:
! 305: #define CALL_G_METH(method,mult,args,returnval) ( \
! 306: (term==0) ? ( \
! 307: croak("No terminal specified") returnval \
! 308: ) : \
! 309: (*(CAT2(F_,mult))term->method)args \
! 310: )
! 311:
! 312: #define GET_G_FLAG(mask) ( \
! 313: (term==0) ? ( \
! 314: croak("No terminal specified") RETINT \
! 315: ) : \
! 316: (term->flags & (mask)))
! 317:
! 318: #ifdef DONT_POLLUTE_INIT
! 319: # define gptable_init() CALL_G_METH0(init)
! 320: #else
! 321: # define init() CALL_G_METH0(init)
! 322: # define gptable_init init
! 323: #endif
! 324: #define reset() CALL_G_METH0(reset)
! 325: #define text() CALL_G_METH0(text)
! 326: #define options() CALL_G_METH0(options)
! 327: #define graphics() CALL_G_METH0(graphics)
! 328: #define linetype(lt) CALL_G_METH1(linetype,lt)
! 329: #define justify_text(mode) CALL_G_METH1I(justify_text,mode)
! 330: #define text_angle(ang) CALL_G_METH1I(text_angle,ang)
! 331: #define scale(xs,ys) CALL_G_METH2D(scale,xs,ys)
! 332: #define move(x,y) CALL_G_METH2(move,x,y)
! 333: #define vector(x,y) CALL_G_METH2(vector,x,y)
! 334: #define put_text(x,y,str) CALL_G_METH3T(put_text,x,y,str)
! 335: #define point(x,y,p) CALL_G_METH3(point,x,y,p)
! 336: #define arrow(sx,sy,ex,ey,head) CALL_G_METH5(arrow,sx,sy,ex,ey,head)
! 337: #define set_font(font) CALL_G_METH1IP(set_font,font)
! 338: #define setpointsize(size) CALL_G_METH1D(pointsize,size)
! 339: #define suspend() CALL_G_METH0(suspend)
! 340: #define resume() CALL_G_METH0(resume)
! 341: #define fillbox(sx,sy,ex,ey,head) CALL_G_METH5(fillbox,sx,sy,ex,ey,head)
! 342: #define linewidth(size) CALL_G_METH1D(linewidth,size)
! 343: #define can_multiplot() GET_G_FLAG(TERM_CAN_MULTIPLOT)
! 344: #define cannot_multiplot() GET_G_FLAG(TERM_CANNOT_MULTIPLOT)
! 345: #define is_binary() GET_G_FLAG(TERM_BINARY)
! 346:
! 347: #define termprop(prop) (term->prop)
! 348: #define termset(term) my_change_term(term,strlen(term))
! 349:
! 350: struct termentry * change_term(char*,int);
! 351:
! 352: #define TTABLE_STARTPLOT 0
! 353: #define TTABLE_ENDPLOT 1
! 354: #define TTABLE_STARTMPLOT 2
! 355: #define TTABLE_ENDMPLOT 3
! 356: #define TTABLE_INIT 4
! 357: #define TTABLE_LIST 5
! 358: #define TTABLE_COUNT 6
! 359:
! 360: typedef void (*TSET_FP)(char *s);
! 361: typedef void (*TST_END_FP)(void);
! 362: typedef void (*SET_SIZES_t)(double x, double y);
! 363: typedef double (*GET_SIZES_t)(int flag);
! 364: typedef void (*SET_MOUSE_FEEDBACK_RECTAGLE_t)(int term_xmin, int term_xmax,
! 365: int term_ymin, int term_ymax,
! 366: double plot_xmin, double plot_xmax,
! 367: double plot_ymin, double plot_ymax);
! 368:
! 369: struct t_ftable {
! 370: int loaded;
! 371: FUNC_PTR change_term_p;
! 372: TSET_FP term_set_outputp;
! 373: SET_SIZES_t set_sizesp;
! 374: GET_SIZES_t get_sizesp;
! 375: TST_END_FP term_funcs[TTABLE_COUNT];
! 376: SET_MOUSE_FEEDBACK_RECTAGLE_t mouse_feedback_func;
! 377: };
! 378:
! 379: #ifdef DYNAMIC_PLOTTING /* Can load plotting DLL later */
! 380:
! 381: int
! 382: UNKNOWN_null()
! 383: {
! 384: croak("gnuplot-like plotting environment not loaded yet");
! 385: return 0;
! 386: }
! 387:
! 388: static void myterm_table_not_loaded_v(void);
! 389: static void myterm_table_not_loaded(char*);
! 390: static int myterm_table_not_loaded_u();
! 391: static void myterm_table_not_loaded_vdd(double x, double y);
! 392: static double myterm_table_not_loaded_di(int flag);
! 393: static void myterm_table_not_loaded_v4i4d(int term_xmin, int term_xmax,
! 394: int term_ymin, int term_ymax,
! 395: double plot_xmin, double plot_xmax,
! 396: double plot_ymin, double plot_ymax);
! 397: #if 0
! 398: static int ftable_warned;
! 399: static void
! 400: tmp_my_term_init
! 401: {
! 402: if (!warned++)
! 403: warn("This runtime link with gnuplot-shim does not implement midlevel start/end functions");
! 404: shim_myinit();
! 405: }
! 406: #endif
! 407:
! 408: static struct t_ftable my_term_ftable =
! 409: {
! 410: 0, &myterm_table_not_loaded_u, &myterm_table_not_loaded,
! 411: &myterm_table_not_loaded_vdd,
! 412: &myterm_table_not_loaded_di,
! 413: {&myterm_table_not_loaded_v, &myterm_table_not_loaded_v,
! 414: &myterm_table_not_loaded_v, &myterm_table_not_loaded_v,
! 415: &myterm_table_not_loaded_v, &myterm_table_not_loaded_v},
! 416: myterm_table_not_loaded_v4i4d
! 417: };
! 418:
! 419: static struct t_ftable *my_term_ftablep = &my_term_ftable;
! 420:
! 421: static void
! 422: myterm_table_not_loaded_v(void)
! 423: {
! 424: if (!my_term_ftablep->loaded) {
! 425: UNKNOWN_null();
! 426: return;
! 427: }
! 428: croak("This runtime link with gnuplot-shim does not implement midlevel start/end functions");
! 429: }
! 430:
! 431: static void
! 432: myterm_table_not_loaded(char *s)
! 433: {
! 434: myterm_table_not_loaded_v();
! 435: }
! 436:
! 437: static void
! 438: myterm_table_not_loaded_vdd(double x, double y)
! 439: {
! 440: myterm_table_not_loaded_v();
! 441: }
! 442:
! 443: static double
! 444: myterm_table_not_loaded_di(int flag)
! 445: {
! 446: myterm_table_not_loaded_v();
! 447: return 0; /* NOT REACHED */
! 448: }
! 449:
! 450: static int
! 451: myterm_table_not_loaded_u()
! 452: {
! 453: myterm_table_not_loaded_v();
! 454: return 0;
! 455: }
! 456:
! 457: void myterm_table_not_loaded_v4i4d(int term_xmin, int term_xmax,
! 458: int term_ymin, int term_ymax,
! 459: double plot_xmin, double plot_xmax,
! 460: double plot_ymin, double plot_ymax)
! 461: {
! 462: myterm_table_not_loaded_v();
! 463: }
! 464:
! 465: # define change_term (*my_term_ftablep->change_term_p)
! 466: # define term_set_output (*my_term_ftablep->term_set_outputp)
! 467: # define term_start_plot (*my_term_ftablep->term_funcs[TTABLE_STARTPLOT])
! 468: # define term_end_plot (*my_term_ftablep->term_funcs[TTABLE_ENDPLOT])
! 469: # define term_start_multiplot (*my_term_ftablep->term_funcs[TTABLE_STARTMPLOT])
! 470: # define term_end_multiplot (*my_term_ftablep->term_funcs[TTABLE_ENDMPLOT])
! 471: # define term_init (*my_term_ftablep->term_funcs[TTABLE_INIT])
! 472: # define list_terms (*my_term_ftablep->term_funcs[TTABLE_LIST])
! 473: # define plotsizes_scale (*my_term_ftablep->set_sizesp)
! 474: # define plotsizes_scale_get (*my_term_ftablep->get_sizesp)
! 475: # define set_mouse_feedback_rectangle (*my_term_ftablep->mouse_feedback_func)
! 476:
! 477: # define scaled_xmax() ((int)termprop(xmax)*plotsizes_scale_get(0))
! 478: # define scaled_ymax() ((int)termprop(ymax)*plotsizes_scale_get(1))
! 479:
! 480: #define USE_FUNCTION_FROM_TABLE
! 481:
! 482: static struct termentry *
! 483: my_change_term(char*s,int l)
! 484: {
! 485: SET_OUTFILE;
! 486: if (!my_term_ftablep->change_term_p)
! 487: UNKNOWN_null();
! 488: return term = (struct termentry *)(*my_term_ftablep->change_term_p)(s,l);
! 489: }
! 490:
! 491: #if 0
! 492: static struct termentry dummy_term_tbl[] = {
! 493: {"unknown", "Unknown terminal type - not a plotting device",
! 494: 100, 100, 1, 1,
! 495: 1, 1, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null,
! 496: UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null,
! 497: UNKNOWN_null, UNKNOWN_null, UNKNOWN_null,
! 498: UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, 0,
! 499: UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null},
! 500: };
! 501: #endif
! 502:
! 503: #define set_term_funcp(change_p, term_p) set_term_funcp2((change_p), 0)
! 504: /* #define set_term_funcp3(change_p, term_p, tchange) \
! 505: set_term_funcp2((change_p), (tchange)) */
! 506:
! 507: /* This function should be called before any graphic code can be used... */
! 508: void
! 509: set_term_funcp2(FUNC_PTR change_p, TSET_FP tchange)
! 510: {
! 511: SET_OUTFILE;
! 512: my_term_ftable.change_term_p = change_p;
! 513: my_term_ftable.loaded = 1;
! 514: if (tchange) {
! 515: my_term_ftable.term_set_outputp = tchange;
! 516: }
! 517: }
! 518:
! 519: /* Used from Math::Pari */
! 520: void
! 521: set_term_funcp3(FUNC_PTR change_p, void *term_p, TSET_FP tchange)
! 522: {
! 523: set_term_funcp2(change_p, tchange);
! 524: }
! 525:
! 526: void
! 527: set_term_ftable(struct t_ftable *p)
! 528: {
! 529: SET_OUTFILE;
! 530: my_term_ftablep = p;
! 531: }
! 532:
! 533: extern struct t_ftable *get_term_ftable();
! 534:
! 535: #else /* !DYNAMIC_PLOTTING */
! 536:
! 537: extern struct termentry term_tbl[];
! 538: extern double min_array[], max_array[];
! 539: extern int xleft, xright, ybot, ytop;
! 540:
! 541: void
! 542: mys_mouse_feedback_rectangle(int term_xmin, int term_xmax,
! 543: int term_ymin, int term_ymax,
! 544: double plot_xmin, double plot_xmax,
! 545: double plot_ymin, double plot_ymax)
! 546: {
! 547: xleft = term_xmin, xright = term_xmax;
! 548: ybot = term_ymin, ytop = term_ymax;
! 549: min_array[FIRST_X_AXIS] = min_array[SECOND_X_AXIS] = plot_xmin;
! 550: max_array[FIRST_X_AXIS] = max_array[SECOND_X_AXIS] = plot_xmax;
! 551: min_array[FIRST_Y_AXIS] = min_array[SECOND_Y_AXIS] = plot_ymin;
! 552: max_array[FIRST_Y_AXIS] = max_array[SECOND_Y_AXIS] = plot_ymax;
! 553: }
! 554:
! 555: # define my_change_term change_term
! 556: # define my_term_tbl term_tbl
! 557:
! 558: extern void term_set_output(char *s);
! 559: extern void term_start_plot(void);
! 560: extern void term_end_plot(void);
! 561: extern void term_start_multiplot(void);
! 562: extern void term_end_multiplot(void);
! 563: extern void term_init(void);
! 564: extern void list_terms(void);
! 565:
! 566: static void
! 567: plotsizes_scale(double x, double y) { xsize=x; ysize=y; }
! 568:
! 569: static double
! 570: plotsizes_get(int flag) { return (flag ? ysize : xsize); }
! 571:
! 572: struct t_ftable my_term_ftable =
! 573: {
! 574: 1, (FUNC_PTR)&change_term, &term_set_output,
! 575: &plotsizes_scale, &plotsizes_get,
! 576: {&term_start_plot, &term_end_plot,
! 577: &term_start_multiplot, &term_end_multiplot, &term_init, &list_terms},
! 578: &mys_mouse_feedback_rectangle
! 579: };
! 580:
! 581: struct t_ftable *get_term_ftable() { SET_OUTFILE; return &my_term_ftable; }
! 582: void set_term_ftable() { SET_OUTFILE; }
! 583:
! 584: void
! 585: set_term_funcp3(FUNC_PTR change_p, void *term_p, TSET_FP tchange)
! 586: {
! 587: SET_OUTFILE;
! 588: (void)term_p;
! 589: my_term_ftable.change_term_p = change_p;
! 590: my_term_ftable.loaded = 1;
! 591: if (tchange) {
! 592: my_term_ftable.term_set_outputp = tchange;
! 593: }
! 594: }
! 595:
! 596: #define scaled_xmax() ((int)termprop(xmax)*xsize)
! 597: #define scaled_ymax() ((int)termprop(ymax)*ysize)
! 598:
! 599: #endif /* !DYNAMIC_PLOTTING */
! 600:
! 601: #define int_get_term_ftable() ((IV)get_term_ftable())
! 602: #define int_set_term_ftable(a) (v_set_term_ftable((void*)a))
! 603:
! 604: void
! 605: v_set_term_ftable(void *a) { set_term_ftable((struct t_ftable*)a); }
! 606:
! 607: typedef void (*set_term_ftable_t)(struct t_ftable *p);
! 608: typedef struct t_ftable *(get_term_ftable_t)(void);
! 609:
! 610: extern get_term_ftable_t *get_term_ftable_get(void);
! 611:
! 612: static int shim_set;
! 613:
! 614: void
! 615: setup_gpshim(void) {
! 616: #if 0
! 617: if (shim_set++)
! 618: return;
! 619: #endif
! 620:
! 621: if (!shim_set++) {
! 622: #ifdef DYNAMIC_PLOTTING_RUNTIME_LINK
! 623: get_term_ftable_t *f = get_term_ftable_get(); /* Resolve the getter */
! 624:
! 625: if (f)
! 626: v_set_term_ftable(f()); /* Get the external table */
! 627: #endif
! 628:
! 629: #ifdef DYNAMIC_PLOTTING_STATIC_LINK
! 630: void *a = get_term_ftable(); /* Get the external one */
! 631: v_set_term_ftable(get_term_ftable());
! 632: #endif
! 633: }
! 634: SET_OUTFILE;
! 635: }
! 636:
! 637: #ifdef SET_OPTIONS_FROM_STRING
! 638: /* This sets the tokens for the options */
! 639: void
! 640: set_tokens_string(char *start)
! 641: {
! 642: char *s = start;
! 643: char *tstart;
! 644: int is_real, is_integer, has_exp;
! 645:
! 646: num_tokens = 0;
! 647: while (num_tokens < MAX_TOKENS) {
! 648: while (*s == ' ' || *s == '\t' || *s == '\n')
! 649: s++;
! 650: if (!*s)
! 651: return;
! 652: tstart = s;
! 653: if (*s == ',') {
! 654: s++;
! 655: is_integer = is_real = 0;
! 656: goto process;
! 657: }
! 658: is_integer = is_real = ((*s) != 0);
! 659: if (*s == '+' || *s == '-')
! 660: s++;
! 661: has_exp = 0;
! 662: while (*s && !(*s == ' ' || *s == '\t' || *s == '\n')) {
! 663: if (!(*s <= '9' && *s >= '0')) {
! 664: if (*s == '.') {
! 665: if (!is_integer)
! 666: is_real = 0;
! 667: else if (is_integer == 1 && !(s[1] <= '9' && s[1] >= '0'))
! 668: is_real = 0;
! 669: } else if (*s == 'e' || *s == 'E') {
! 670: if (has_exp)
! 671: is_real = 0;
! 672: has_exp = 1;
! 673: if (s[1] == '+' || s[1] == '-')
! 674: s++;
! 675: } else if (*s == ',' && (is_integer || is_real))
! 676: break;
! 677: else
! 678: is_real = 0;
! 679: is_integer = 0;
! 680: } else if (is_integer)
! 681: is_integer++;
! 682: s++;
! 683: }
! 684: process:
! 685: token[num_tokens].start_index = tstart - input_line;
! 686: token[num_tokens].length = s - tstart;
! 687: if (is_integer) {
! 688: token[num_tokens].is_token = 0;
! 689: token[num_tokens].l_val.type = INTGR;
! 690: token[num_tokens].l_val.v.int_val = atoi(tstart);
! 691: } else if (is_real) {
! 692: token[num_tokens].is_token = 0;
! 693: token[num_tokens].l_val.type = CMPLX;
! 694: token[num_tokens].l_val.v.cmplx_val.real = atof(tstart);
! 695: token[num_tokens].l_val.v.cmplx_val.imag = 0;
! 696: } else {
! 697: token[num_tokens].is_token = 1;
! 698: }
! 699: num_tokens++;
! 700: }
! 701: if (num_tokens >= MAX_TOKENS) {
! 702: char buf[80];
! 703: sprintf(buf, "panic: more than %d tokens for options", MAX_TOKENS);
! 704: croak(buf);
! 705: }
! 706: }
! 707:
! 708: void
! 709: set_options_from(char *s)
! 710: {
! 711: char *o = input_line;
! 712:
! 713: input_line = s; /* for error reports */
! 714: set_tokens_string(s);
! 715: options();
! 716: input_line = o;
! 717: c_token = num_tokens = 0;
! 718: }
! 719: #endif
! 720:
! 721: #ifdef GNUPLOT_OUTLINE_STDOUT
! 722: int
! 723: StartOutput() { return 0; }
! 724:
! 725: int
! 726: EndOutput() { return 0; }
! 727:
! 728: int
! 729: OutLine(char *s)
! 730: {
! 731: return fprintf(stdout, "%s", s);
! 732: }
! 733: #endif
! 734:
! 735: #ifdef __cplusplus
! 736: }
! 737: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>