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