Annotation of OpenXM_contrib2/asir2000/lib/glib, Revision 1.17
1.17 ! takayama 1: /* $OpenXM: OpenXM_contrib2/asir2000/lib/glib,v 1.16 2004/03/14 12:56:47 takayama Exp $ */
1.1 takayama 2:
1.9 takayama 3: /* BUG: this library has not yet been adapted to the new automatic launcher
4: of ox_plot. 2002, Aug, 4. Do not load glib more than twice.
5: */
1.1 takayama 6:
1.17 ! takayama 7: extern Cfep_loaded$
! 8:
1.12 takayama 9: #define DO_NOT_START_SERVER_EXPLICITLY
10:
1.1 takayama 11: /* #define CLIP 1 */
12: /* #define DEBUG 1 */
13: #define LIST 4
14:
1.5 takayama 15: def glib_floor(N) {
1.1 takayama 16: return(pari(floor,N));
17: }
18:
1.5 takayama 19: /*
1.1 takayama 20: def join(A,B) {
21: if (type(B) == 0) return(A);
22: return(append(A,B));
23: }
24: def eigenvalues(M) {
25: return(pari(eigen,M));
26: }
27: def roots(F) {
28: return(pari(roots,F));
29: }
1.5 takayama 30: */
1.1 takayama 31:
32: /* ---------------------------------------------- */
1.8 takayama 33: def glib_ox_get_errors(P) {
1.1 takayama 34: ox_push_cmd(P,276);
35: return(ox_pop_cmo(P));
36: }
37:
38: def reset_plot() {
39: extern Glib_process;
1.17 ! takayama 40: if (!Cfep_loaded) {
! 41: print(" Sending signal to ox_plot",0);
! 42: ox_reset(Glib_process);
! 43: print(" Done.");
! 44: }
1.1 takayama 45: }
1.5 takayama 46: Glib_ps = 0$
47: Glib_h = []$
1.1 takayama 48: Glib_canvas_x = 400$
49: Glib_canvas_y = 400$
50: Glib_xmin=0$ Glib_xmax=Glib_canvas_x$
51: Glib_ymin=0$ Glib_ymax=Glib_canvas_y$
1.11 takayama 52: Glib_math_coordinate=0$
1.12 takayama 53:
1.1 takayama 54:
55: Glib_canvas = -1$
56: Glib_xmag = 1$ Glib_ymag=1$ Glib_xoffset=0$ Glib_yoffset=0$
57: Glib_safe_mode = 2 $
58: Glib_counter = 100$
59:
1.16 takayama 60: extern Glib_ps_sx$
61: extern Glib_ps_sy$
62: Glib_ps_sx=2$ /* mag=1/2 for PS picture. cf. glib_ps_form, glib_tops */
63: Glib_ps_sy=2$ /* mag=1/2 for PS picture */
64:
1.1 takayama 65: def open_Canvas(P,S) {
1.12 takayama 66: extern Glib_process;
1.17 ! takayama 67: /* print("open_Canvas: ",0);print(S); */
! 68: if (!Cfep_loaded) {
! 69: if (P < 0) P=open_canvas(S); /* BUG, get process No. */
! 70: else open_canvas(P,S);
! 71: Glib_process = P;
1.1 takayama 72: R = ox_pop_cmo(P);
1.17 ! takayama 73: /*
! 74: if (glib_ox_get_errors(P) == []) {
! 75: R = ox_pop_cmo(P);
! 76: }else{
! 77: debug;
! 78: }
! 79: */
1.1 takayama 80: }else{
1.17 ! takayama 81: R=cfep.open_canvas(S);
1.1 takayama 82: }
83: return(R);
84: }
85:
1.8 takayama 86: /*&usage begin: glib_open()
87: It starts the ox_plot server and opens a canvas.
88: The canvas size is set to {Glib_canvas_x} X {Glib_canvas_y}
89: (the default value is 400).
90: This function is automatically called when the user calls glib
91: functions.
92: end: */
93:
1.1 takayama 94: def glib_open() {
95: extern Glib_canvas_x, Glib_canvas_y,
1.12 takayama 96: Glib_process, Glib_canvas,
97: Glib_server_started, Glib_process$
1.17 ! takayama 98: if (!Cfep_loaded) return glib_openx11();
! 99: else {
! 100: Glib_canvas = open_Canvas(-1,[Glib_canvas_x,Glib_canvas_y])$
! 101: Glib_server_started = 1$
! 102: return(Glib_canvas);
! 103: }
! 104: }
! 105: def glib_openx11() {
! 106: extern Glib_canvas_x, Glib_canvas_y,
! 107: Glib_process, Glib_canvas,
! 108: Glib_server_started, Glib_process$
1.12 takayama 109: #ifndef DO_NOT_START_SERVER_EXPLICITLY
1.17 ! takayama 110: if (type(Glib_server_started) == 0) {
1.12 takayama 111: Glib_process = ox_launch_nox(0,"ox_plot")$
112: register_handler(reset_plot);
113: Glib_server_started = 1$
114: }$
1.1 takayama 115: Glib_canvas = open_Canvas(Glib_process,[Glib_canvas_x,Glib_canvas_y])$
1.12 takayama 116: #else
117: Glib_canvas = open_Canvas(-1,[Glib_canvas_x,Glib_canvas_y])$
118: register_handler(reset_plot);
119: Glib_server_started = 1$
120: #endif
1.1 takayama 121: glib_check_strict();
122: return(Glib_canvas);
123: }
124:
125: def glib_check() {
126: extern Glib_process, Glib_canvas, Glib_safe_mode,
127: Glib_canvas_x, Glib_canvas_y, Glib_counter;
128: if (Glib_safe_mode == 0) {
129: return(0);
130: }
131: if (Glib_safe_mode == 2) {
132: if (Glib_counter > 0) {
133: Glib_counter--;
134: return(0);
135: }else{
136: Glib_counter=100;
137: }
138: }
139: glib_check_strict();
140: }
141: def glib_check_strict() {
142: extern Glib_process, Glib_canvas, Glib_safe_mode,
143: Glib_canvas_x, Glib_canvas_y, Glib_counter;
144: if (Glib_canvas < 0) {
145: glib_open();
146: }
1.17 ! takayama 147: if (Cfep_loaded) return ;
1.8 takayama 148: E = glib_ox_get_errors(Glib_process);
1.1 takayama 149: if (E != []) {
150: ox_pops(Glib_process,200);
151: print(E);
152: print("Warning: ",0);
153: print("Drawing canvas seems to be closed.");
154: print("Opening a new canvas.");
155: Glib_canvas = open_Canvas(Glib_process,[Glib_canvas_x,Glib_canvas_y])$
156: error("Drawing aborted");
157: }
158: }
159:
160: def glib_clear() {
161: extern Glib_process, Glib_canvas;
162: if (Glib_canvas < 0) glib_open();
1.17 ! takayama 163: if (!Cfep_loaded) clear_canvas(Glib_process,Glib_canvas);
1.1 takayama 164: }
165:
1.5 takayama 166: /*&usage begin: glib_window(Xmin,Ymin,Xmax,Ymax)
167: It generates a window with the left top corner [{Xmin},{Ymin}] and
168: the right bottom corner [{Xmax},{Ymax}].
1.11 takayama 169: If the global variable {Glib_math_coordinate} is set to 1, mathematical
170: coordinate system will be employed, i.e., the left top
171: corner will have the coordinate [{Xmin},{Ymax}].
1.5 takayama 172: example: glib_window(-1,-1,10,10);
173: end: */
1.1 takayama 174: def glib_window(Xmin,Ymin,Xmax,Ymax) {
175: extern Glib_xmin, Glib_xmax, Glib_ymin, Glib_ymax,
176: Glib_canvas_x, Glib_canvas_y, Glib_process, Glib_canvas,
177: Glib_xoffset, Glib_yoffset, Glib_xmag, Glib_ymag;
178: if (Xmax <= Xmin) error("glib window: Invalid size");
179: if (Ymax <= Ymin) error("glib window: Invalid size");
1.2 takayama 180: glib_check_arg(Xmin,Ymin); glib_check_arg(Xmax,Ymax);
1.1 takayama 181: Glib_xmin = Xmin; Glib_xmax = Xmax;
182: Glib_ymin = Ymin; Glib_ymax = Ymax;
183: Glib_xoffset = -Xmin;
184: Glib_yoffset = -Ymin;
185: Glib_xmag = Glib_canvas_x/(Xmax-Xmin);
186: Glib_ymag = Glib_canvas_y/(Ymax-Ymin);
187: if (Glib_canvas < 0) glib_open();
188: }
189:
1.2 takayama 190: def glib_check_arg(X,Y) {
191: if (type(X) <= 1 && type(Y) <= 1) return 1;
192: else {
193: print("Error in glib: arguments ",0);
194: print([X,Y],0);
195: print(" are not numbers.");
196: error("Invalid argument for glib_window, glib_putpixel, glib_line.");
197: }
198: }
199:
1.6 takayama 200: /*&usage begin: glib_putpixel(X,Y|color)
1.5 takayama 201: It puts a pixel at [{X},{Y}] with {color}
202: example: glib_putpixel(1,2 | color=0xffff00);
203: end: */
1.1 takayama 204: def glib_putpixel(X,Y) {
205: extern Glib_process, Glib_canvas,
1.11 takayama 206: Glib_xoffset, Glib_yoffset, Glib_xmag, Glib_ymag, Glib_ps,
207: Glib_math_coordinate, Glib_canvas_y;
1.1 takayama 208: if (Glib_canvas < 0) glib_open();
209: glib_check();
1.2 takayama 210: glib_check_arg(X,Y);
1.3 noro 211: C = getopt(color);
1.11 takayama 212: if (Glib_math_coordinate) {
213: Pos = [glib_floor(Glib_xmag*(X+Glib_xoffset)),
214: Glib_canvas_y-glib_floor(Glib_ymag*(Y+Glib_yoffset))];
215: Pos2= [glib_floor(Glib_xmag*(X+Glib_xoffset)),
216: glib_floor(Glib_ymag*(Y+Glib_yoffset))];
217: }else{
218: Pos = [glib_floor(Glib_xmag*(X+Glib_xoffset)),
219: glib_floor(Glib_ymag*(Y+Glib_yoffset))];
220: Pos2= [glib_floor(Glib_xmag*(X+Glib_xoffset)),
221: Glib_canvas_y-glib_floor(Glib_ymag*(Y+Glib_yoffset))];
222: }
1.5 takayama 223: if ( type(C) != -1 ) {
1.17 ! takayama 224: if (!Cfep_loaded) draw_obj(Glib_process,Glib_canvas,Pos,C);
! 225: else cfep.draw_obj2(Glib_process,Glib_canvas,Pos,C);
1.11 takayama 226: if (Glib_ps) glib_history(["putpixel",Pos2,C]);
1.5 takayama 227: }else{
1.17 ! takayama 228: if (!Cfep_loaded) draw_obj(Glib_process,Glib_canvas,Pos);
! 229: else cfep.draw_obj(Glib_process,Glib_canvas,Pos);
1.11 takayama 230: if (Glib_ps) glib_history(["putpixel",Pos2,0]);
1.5 takayama 231: }
1.1 takayama 232: }
233:
1.6 takayama 234: /*&usage begin: glib_line(X0,Y0,X1,Y1|color)
1.8 takayama 235: It draws the line [{X0},{Y0}]-- [{X1},{Y1}] with {color}
1.5 takayama 236: example: glib_line(0,0,5,3/2 | color=0xff00ff);
237: end: */
1.1 takayama 238: def glib_line(X0,Y0,X1,Y1) {
239: extern Glib_xmag, Glib_ymag, Glib_xoffset, Glib_yoffset;
1.3 noro 240: C = getopt(color);
1.2 takayama 241: glib_check_arg(X0,Y0);
242: glib_check_arg(X1,Y1);
1.5 takayama 243: glib_clip_line(glib_floor(Glib_xmag*(X0+Glib_xoffset)),
244: glib_floor(Glib_ymag*(Y0+Glib_yoffset)),
245: glib_floor(Glib_xmag*(X1+Glib_xoffset)),
246: glib_floor(Glib_ymag*(Y1+Glib_yoffset)),C);
1.1 takayama 247: }
248:
1.3 noro 249: def glib_clip_line(X0,Y0,X1,Y1,Color) {
1.1 takayama 250: /* X0, Y0, X1, Y1 should be integers.
251: Coordinates are already translated. */
1.5 takayama 252: extern Glib_process, Glib_canvas, Glib_canvas_x, Glib_canvas_y,
1.11 takayama 253: Glib_ps, Glib_math_coordinate;
1.1 takayama 254: if (Glib_canvas < 0) glib_open();
255:
1.5 takayama 256: if (Glib_ps) {
1.1 takayama 257: #ifdef DEBUG
258: print(["clip_line",[X0,Y0,X1,Y1]]);
259: #endif
260: /* clip by x = 0 */
261: S = glib_clip0_x(X0,Y0,X1,Y1,0);
262: #ifdef DEBUG
263: print(["clip0_x",S]);
264: #endif
265: if (type(S) == 0) return;
266: X0 = S[0]; Y0 = S[1]; X1 = S[2]; Y1 = S[3];
267:
268: S = glib_clip1_x(X0,Y0,X1,Y1,Glib_canvas_x-1);
269: #ifdef DEBUG
270: print(["clip1_x",S]);
271: #endif
272: if (type(S) == 0) return;
273: X0 = S[0]; Y0 = S[1]; X1 = S[2]; Y1 = S[3];
274:
275: S = glib_clip0_y(X0,Y0,X1,Y1,0);
276: #ifdef DEBUG
277: print(["clip0_y",S]);
278: #endif
279: if (type(S) == 0) return;
280: X0 = S[0]; Y0 = S[1]; X1 = S[2]; Y1 = S[3];
281:
282: S = glib_clip1_y(X0,Y0,X1,Y1,Glib_canvas_y-1);
283: #ifdef DEBUG
284: print(["clip1_y",S]);
285: #endif
286: if (type(S) == 0) return;
287: X0 = S[0]; Y0 = S[1]; X1 = S[2]; Y1 = S[3];
288:
289: #ifdef DEBUG
290: print([X0,Y0,X1,Y1]);
291: #endif
1.5 takayama 292: }
293:
1.1 takayama 294: glib_check();
1.11 takayama 295: if (Glib_math_coordinate) {
296: Pos = [glib_floor(X0),Glib_canvas_y-glib_floor(Y0),
297: glib_floor(X1),Glib_canvas_y-glib_floor(Y1)];
298: Pos2= [glib_floor(X0),glib_floor(Y0),glib_floor(X1),glib_floor(Y1)];
299: }else{
300: Pos = [glib_floor(X0),glib_floor(Y0),glib_floor(X1),glib_floor(Y1)];
301: Pos2 = [glib_floor(X0),Glib_canvas_y-glib_floor(Y0),
302: glib_floor(X1),Glib_canvas_y-glib_floor(Y1)];
303: }
1.5 takayama 304: if ( type(Color) != -1 ) {
1.17 ! takayama 305: if (!Cfep_loaded) draw_obj(Glib_process,Glib_canvas,Pos,Color);
! 306: else cfep.draw_obj2(Glib_process,Glib_canvas,Pos,Color);
1.11 takayama 307: if (Glib_ps) glib_history(["line",Pos2,Color]);
1.5 takayama 308: }else{
1.17 ! takayama 309: if (!Cfep_loaded) draw_obj(Glib_process,Glib_canvas,Pos);
! 310: else cfep.draw_obj(Glib_process,Glib_canvas,Pos);
1.11 takayama 311: if (Glib_ps) glib_history(["line",Pos2,0]);
1.5 takayama 312: }
1.1 takayama 313: }
314:
315: def glib_clip0_x(X0,Y0,X1,Y1,Clip) {
316: if (X0 < Clip && X1 < Clip) return(0);
317: if (X0 < Clip && X1 > Clip) {
318: return([Clip, Y0+(Clip-X0)*(Y1-Y0)/(X1-X0),X1,Y1]);
319: }
320: if (X1 > Clip && X1 < Clip) {
321: return([X0,Y0,Clip, Y1+(Clip-X1)*(Y0-Y1)/(X0-X1)]);
322: }
323: return([X0,Y0,X1,Y1]);
324: }
325: def glib_clip0_y(X0,Y0,X1,Y1,Clip) {
326: if (Y0 < Clip && Y1 < Clip) return(0);
327: if (Y0 < Clip && Y1 > Clip) {
328: return([X0+(Clip-Y0)*(X1-X0)/(Y1-Y0),Clip,X1,Y1]);
329: }
330: if (Y1 > Clip && Y1 < Clip) {
331: return([X0,Y0,X1+(Clip-Y1)*(X0-X1)/(Y0-Y1),Clip]);
332: }
333: return([X0,Y0,X1,Y1]);
334: }
335: def glib_clip1_x(X0,Y0,X1,Y1,Clip) {
336: if (X0 > Clip && X1 > Clip) return(0);
337: if (X0 > Clip && X1 < Clip) {
338: return([Clip, Y0+(Clip-X0)*(Y1-Y0)/(X1-X0),X1,Y1]);
339: }
340: if (X1 < Clip && X1 > Clip) {
341: return([X0,Y0,Clip, Y1+(Clip-X1)*(Y0-Y1)/(X0-X1)]);
342: }
343: return([X0,Y0,X1,Y1]);
344: }
345: def glib_clip1_y(X0,Y0,X1,Y1,Clip) {
346: if (Y0 > Clip && Y1 > Clip) return(0);
347: if (Y0 > Clip && Y1 < Clip) {
348: return([X0+(Clip-Y0)*(X1-X0)/(Y1-Y0),Clip,X1,Y1]);
349: }
350: if (Y0 < Clip && Y1 > Clip) {
351: return([X0,Y0,X1+(Clip-Y1)*(X0-X1)/(Y0-Y1),Clip]);
352: }
353: return([X0,Y0,X1,Y1]);
1.4 takayama 354: }
355:
1.6 takayama 356: /*&usage begin: glib_print(X,Y,Text|color)
1.4 takayama 357: It put a string {Text} at [{X},{Y}] on the glib canvas.
358: example: glib_print(100,100,"Hello Worlds" | color=0xff0000);
359: end: */
360: def glib_print(X,Y,Text) {
361: extern Glib_process, Glib_canvas,
1.11 takayama 362: Glib_xoffset, Glib_yoffset, Glib_xmag, Glib_ymag, Glib_ps,
363: Glib_math_coordinate, Glib_canvas_y;
1.4 takayama 364: if (Glib_canvas < 0) glib_open();
365: glib_check();
366: glib_check_arg(X,Y);
367: if (type(Text) != 7) error("glib_print(X,Y,Text): Text must be a string.");
368: C = getopt(color);
1.11 takayama 369: if (Glib_math_coordinate) {
370: Pos = [glib_floor(Glib_xmag*(X+Glib_xoffset)),
371: Glib_canvas_y-glib_floor(Glib_ymag*(Y+Glib_yoffset))];
372: Pos2= [glib_floor(Glib_xmag*(X+Glib_xoffset)),
373: glib_floor(Glib_ymag*(Y+Glib_yoffset))];
374: }else{
375: Pos = [glib_floor(Glib_xmag*(X+Glib_xoffset)),
376: glib_floor(Glib_ymag*(Y+Glib_yoffset))];
377: Pos2= [glib_floor(Glib_xmag*(X+Glib_xoffset)),
378: Glib_canvas_y-glib_floor(Glib_ymag*(Y+Glib_yoffset))];
379: }
1.5 takayama 380: if ( type(C) != -1 ) {
1.17 ! takayama 381: if (!Cfep_loaded) draw_string(Glib_process,Glib_canvas,Pos,Text,C);
! 382: else cfep.draw_string2(Glib_process,Glib_canvas,Pos,Text,C);
1.11 takayama 383: if (Glib_ps) glib_history(["print",Pos2,Text,C]);
1.5 takayama 384: }else{
1.17 ! takayama 385: if (!Cfep_loaded) draw_string(Glib_process,Glib_canvas,Pos,Text);
! 386: else cfep.draw_string(Glib_process,Glib_canvas,Pos,Text);
1.11 takayama 387: if (Glib_ps) glib_history(["print",Pos2,Text,0]);
1.5 takayama 388: }
389: }
390:
391: def glib_history(L) {
1.11 takayama 392: extern Glib_h, Glib_canvas_x, Glib_canvas_y,
393: Glib_math_coodinate;
1.5 takayama 394: if (L[0] == "putpixel" || L[0] == "print") {
395: if (L[1][0] <= Glib_canvas_x && L[1][0] >= 0) {
396: if (L[1][1] <= Glib_canvas_x && L[1][1] >= 0)
397: Glib_h = cons(L,Glib_h);
398: }
399: }else {
400: Glib_h = cons(L,Glib_h);
401: }
402: return 0;
403: }
404:
1.16 takayama 405: #define xxx(x) idiv(x,Glib_ps_sx)
406: #define yyy(y) idiv(y,Glib_ps_sy)
407:
1.6 takayama 408: /*&usage begin: glib_tops()
1.5 takayama 409: If Glib_ps is set to 1,
410: it returns a postscript program to draw the picture on the canvas.
1.8 takayama 411: ref: print_output
1.5 takayama 412: end: */
413: def glib_tops() {
414: extern Glib_h;
415: return glib_ps(Glib_h);
416: }
417: def glib_ps(L) {
1.16 takayama 418: extern Glib_ps_sx;
419: extern Glib_ps_sy;
1.13 takayama 420: PS = string_to_tb("");
1.5 takayama 421: Prev_color = 0;
422: /* Prolog */
1.13 takayama 423: write_to_tb("%%!PS-Adobe-1.0\n",PS);
424: write_to_tb("%%BoundingBox: 0 0 " +
1.16 takayama 425: rtostr(xxx(Glib_canvas_x)) + " " + rtostr(yyy(Glib_canvas_y)) + "\n",PS);
1.13 takayama 426: write_to_tb("%%Creator: This is generated by ifplot\n",PS);
427: write_to_tb("%%Title: ifplot\n",PS);
428: write_to_tb("%%EndComments: \n",PS);
429: write_to_tb("0.1 setlinewidth \n",PS);
430: write_to_tb("2 setlinecap \n",PS);
431: write_to_tb("2 setlinejoin \n",PS);
432: write_to_tb("/ifplot_putpixel { \n",PS);
433: write_to_tb(" /yyy 2 1 roll def /xxx 2 1 roll def \n",PS);
434: write_to_tb(" gsave newpath xxx yyy .5 0 360 arc \n",PS);
435: write_to_tb(" fill grestore \n",PS);
436: write_to_tb("} def \n",PS);
1.5 takayama 437:
438: L = reverse(L);
439: N = length(L);
440: for (I=0; I<N; I++) {
441: C = L[I];
442: if (C[length(C)-1] != Prev_color) {
443: Prev_color = C[length(C)-1];
1.13 takayama 444: write_to_tb(rtostr(deval(ishift(Prev_color,16)/256)) + " " +
1.5 takayama 445: rtostr(deval(iand(ishift(Prev_color,8),0xff)/256)) + " " +
1.13 takayama 446: rtostr(deval(iand(Prev_color,0xff)/256)) + " setrgbcolor \n",PS);
1.5 takayama 447: }
448: if (C[0] == "putpixel") {
1.16 takayama 449: write_to_tb(rtostr(xxx(C[1][0])) + " " + rtostr(yyy(C[1][1])) + " ifplot_putpixel \n",PS);
1.5 takayama 450: }
451: if (C[0] == "line") {
1.13 takayama 452: write_to_tb(" newpath ",PS);
1.16 takayama 453: write_to_tb(rtostr(xxx(C[1][0])) + " " + rtostr(yyy(C[1][1])) + " moveto " +
454: rtostr(xxx(C[1][2])) + " " + rtostr(yyy(C[1][3])) + " lineto stroke \n",PS);
1.5 takayama 455: }
456: if (C[0] == "print") {
1.13 takayama 457: write_to_tb("/Times-Roman findfont 10 scalefont setfont \n",PS);
1.16 takayama 458: write_to_tb(rtostr(xxx(C[1][0])) + " " + rtostr(yyy(C[1][1])) + " moveto ",PS);
1.13 takayama 459: write_to_tb("(" + C[2] + ") show \n",PS);
1.5 takayama 460: }
461: }
462:
463: /* Epilog */
1.13 takayama 464: write_to_tb("0 0 0 setrgbcolor \n",PS);
465: write_to_tb("showpage \n",PS);
1.5 takayama 466:
1.13 takayama 467: return tb_to_string(PS);
1.14 takayama 468: }
469:
470: /*&usage begin: glib_ps_form(S)
471: It returns the PS code generated by executing {S}
472: (experimental).
473: example: glib_ps_form(quote( glib_line(0,0,100,100) ));
1.15 takayama 474: example: glib_ps_form(quote([glib_line(0,0,100,100),glib_line(100,0,0,100)]));
1.14 takayama 475: ref: glib_tops
476: end: */
1.15 takayama 477: /* Todo. Change the canvas size. */
1.14 takayama 478: def glib_ps_form(F) {
479: extern Glib_h;
480: extern Glib_ps;
481: H = Glib_h; /* push Glib_h */
482: P = Glib_ps; /* push Glib_ps */
483:
484: Glib_ps=1; Glib_h = [];
1.16 takayama 485: if (type(F) != 17) {
486: return "Error: argument should be quote(...).";
487: }
1.14 takayama 488: eval_quote(F);
489: /* bug. eval_str causes seg fault for ccurve.rr main(8) */
490: R = glib_tops();
491: Glib_h = H; /* pop Glib_h */
492: Glib_ps = P; /* pop Glib_ps */
493: return R;
1.1 takayama 494: }
1.10 takayama 495:
496: /*&usage begin: glib_plot(F)
497: It plots an object {F} on the glib canvas.
498: example: glib_plot([[0,1],[0.1,0.9],[0.2,0.7],[0.3,0.5],[0.4,0.8]]);
499: example: glib_plot(tan(x));
500: end: */
501: /* bug, xmin, xmax, color should be optional variables. */
502: def glib_plot(F) {
503: Opt = getopt();
504: taka_glib_plot(F,Opt);
505: }
506:
1.17 ! takayama 507: def glib_flush() {
! 508: extern Glib_canvas;
! 509: if (Cfep_loaded) cfep.draw_flush(Glib_canvas);
! 510: }
1.1 takayama 511: end$
512:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>