Annotation of OpenXM_contrib/gnuplot/term/tkcanvas.trm, Revision 1.1.1.1
1.1 maekawa 1: /*
2: * $Id: tkcanvas.trm,v 1.7 1998/04/14 00:18:11 drd Exp $
3: *
4: */
5:
6: /* GNUPLOT - tkcanvas.trm */
7:
8: /*[
9: * Copyright 1990 - 1993, 1998
10: *
11: * Permission to use, copy, and distribute this software and its
12: * documentation for any purpose with or without fee is hereby granted,
13: * provided that the above copyright notice appear in all copies and
14: * that both that copyright notice and this permission notice appear
15: * in supporting documentation.
16: *
17: * Permission to modify the software is granted, but not the right to
18: * distribute the complete modified source code. Modifications are to
19: * be distributed as patches to the released version. Permission to
20: * distribute binaries produced by compiling modified sources is granted,
21: * provided you
22: * 1. distribute the corresponding source modifications from the
23: * released version in the form of a patch file along with the binaries,
24: * 2. add special version identification to distinguish your version
25: * in addition to the base release version number,
26: * 3. provide your name and address as the primary contact for the
27: * support of your modified version, and
28: * 4. retain our contact information in regard to use of the base
29: * software.
30: * Permission to distribute the released version of the source code along
31: * with corresponding source modifications in the form of a patch file is
32: * granted with same provisions 2 through 4 for binary distributions.
33: *
34: * This software is provided "as is" without express or implied warranty
35: * to the extent permitted by applicable law.
36: ]*/
37:
38: /*
39: * This file is included by ../term.c.
40: *
41: * This terminal driver supports:
42: * Tk/Tcl canvas widgets
43: *
44: * AUTHORS - original dxy.trm
45: * Martin Yii, eln557h@monu3.OZ
46: * Further modified Jan 1990 by Russell Lang, rjl@monu1.cc.monash.oz
47: *
48: * Port to the Tk/Tcl canvas widget
49: * D. Jeff Dionne, July 1995 jeff@ryeham.ee.ryerson.ca
50: * Alex Woo, woo@playfair.stanford.edu
51: *
52: * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
53: *
54: */
55:
56: /*
57: * adapted to the new terminal layout by Alex Woo (Sept. 1996)
58: */
59:
60: #include "driver.h"
61:
62: #ifdef TERM_REGISTER
63: register_term(tkcanvas)
64: #endif
65:
66: #ifdef TERM_PROTO
67: TERM_PUBLIC void TK_init __PROTO((void));
68: TERM_PUBLIC void TK_graphics __PROTO((void));
69: TERM_PUBLIC void TK_text __PROTO((void));
70: TERM_PUBLIC void TK_linetype __PROTO((int linetype));
71: TERM_PUBLIC void TK_move __PROTO((unsigned int x, unsigned int y));
72: TERM_PUBLIC void TK_vector __PROTO((unsigned int x, unsigned int y));
73: TERM_PUBLIC void TK_put_text __PROTO((unsigned int x, unsigned int y, char *str));
74: TERM_PUBLIC void TK_reset __PROTO((void));
75:
76: #define TK_XMAX 1000
77: #define TK_YMAX 1000
78:
79: #define TK_XLAST (TK_XMAX - 1)
80: #define TK_YLAST (TK_XMAX - 1)
81:
82: #define TK_VCHAR (25) /* double actual height of characters */
83: #define TK_HCHAR (16) /* actual width including spacing */
84: #define TK_VTIC (18)
85: #define TK_HTIC (18)
86: #endif /* TERM_PROTO */
87:
88: #ifndef TERM_PROTO_ONLY
89: #ifdef TERM_BODY
90:
91: static int tk_angle = 0;
92: static int tk_lastx;
93: static int tk_lasty;
94: static int tk_color = 0;
95: static char *tk_colors[] = { "black", "gray", "red", "blue", "green", "brown", "magenta", "cyan" };
96:
97: TERM_PUBLIC void TK_init()
98: {
99: fputs("\
100: proc gnuplot can {\n\
101: $can delete all\n\
102: set cmx [lindex [$can configure -width] 4]\n\
103: set cmy [lindex [$can configure -height] 4]\n",
104: gpoutfile);
105:
106: tk_lastx = tk_lasty = tk_color = 0;
107: }
108:
109:
110: TERM_PUBLIC void TK_graphics()
111: {
112: }
113:
114:
115: TERM_PUBLIC void TK_reset()
116: {
117: }
118:
119: TERM_PUBLIC void TK_linetype(linetype)
120: int linetype;
121: {
122: tk_color = (linetype + 2) & 7;
123: }
124:
125: TERM_PUBLIC void TK_move(x, y)
126: unsigned int x, y;
127: {
128: tk_lastx = x;
129: tk_lasty = 1000 - y;
130: }
131:
132:
133: TERM_PUBLIC void TK_vector(x, y)
134: unsigned int x, y;
135: {
136: y = 1000 - y;
137: fprintf(gpoutfile,
138: "$can create line [expr $cmx * %d /1000] [expr $cmy * %d /1000] [expr $cmx * %d /1000] [expr $cmy * %d /1000] -fill %s\n",
139: tk_lastx, tk_lasty, x, y, tk_colors[tk_color]);
140: tk_lastx = x;
141: tk_lasty = y;
142: }
143:
144:
145: TERM_PUBLIC void TK_put_text(x, y, str)
146: unsigned int x, y;
147: char *str;
148: {
149: y = 1000 - y;
150: fprintf(gpoutfile,
151: "$can create text [expr $cmx * %d /1000] [expr $cmy * %d /1000] -text {%s} -fill %s -anchor w\n",
152: x, y, str, tk_colors[tk_color]);
153: }
154:
155: TERM_PUBLIC void TK_text()
156: {
157: fputs("}\n", gpoutfile);
158: fflush(gpoutfile);
159: }
160:
161:
162: #endif /* TERM_BODY */
163:
164: #ifdef TERM_TABLE
165: TERM_TABLE_START(tkcanvas)
166: "tkcanvas", "Tk/Tcl canvas widget",
167: TK_XMAX, TK_YMAX, TK_VCHAR, TK_HCHAR,
168: TK_VTIC, TK_HTIC, options_null, TK_init, TK_reset,
169: TK_text, null_scale, TK_graphics, TK_move, TK_vector,
170: TK_linetype, TK_put_text, null_text_angle,
171: null_justify_text, do_point, do_arrow, set_font_null
172: TERM_TABLE_END(tkcanvas)
173:
174: #undef LAST_TERM
175: #define LAST_TERM tkcanvas
176:
177: #endif /* TERM_TABLE */
178: #endif /* TERM_PROTO_ONLY */
179:
180: #ifdef TERM_HELP
181: START_HELP(tkcanvas)
182: "1 tkcanvas",
183: "?commands set terminal tkcanvas",
184: "?set terminal tkcanvas",
185: "?set term tkcanvas",
186: "?terminal tkcanvas",
187: "?term tkcanvas",
188: "?tkcanvas",
189: " This terminal driver generates tk canvas widget commands. To use it, rebuild",
190: " `gnuplot` (after uncommenting or inserting the appropriate line in \"term.h\"),",
191: " then",
192: "",
193: " gnuplot> set term tkcanvas",
194: " gnuplot> set output 'plot.file'",
195: "",
196: " After invoking \"wish\", execute the following sequence of tcl commands:",
197: "",
198: " % source plot.file",
199: " % canvas .c",
200: " % pack .c",
201: " % gnuplot .c",
202: "",
203: " The code generated by `gnuplot` creates a tcl procedure called \"gnuplot\"",
204: " that takes the name of a canvas as its argument. When the procedure is,",
205: " called, it clears the canvas, finds the size of the canvas and draws the plot",
206: " in it, scaled to fit.",
207: "",
208: " The current version of `tkcanvas` supports neither `multiplot` nor `replot`."
209: END_HELP(tkcanvas)
210: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>