|
From: Joachim W. <wu...@we...> - 2002-11-04 16:20:13
|
Dear maintainers, developers, users:
I have extended the gnuplot tk terminal, adding two other script
languages (Python and Ruby) to those already supported (Tcl and Perl).
Users: just replace term/tkcanvas.trm in the gnuplot source distribution,
make, make install, restart gnuplot, and type 'help set term tkcanvas'.
Gnuplot maintainers: This enhancement should close request #483294.
Gnuplot.py specialists: could you tell me how to bind an action to a line
segment within a canvas ?
Gnuplot developers: could you tell me how the set_font mechanism within
term/tkcanvas.trm is intended to be used ?
Greetings to all - Joachim Wuttke
---------------------------------------- 709 lines of code to follow ---------------------------------------------------
/*
* MODIFIED VERSION of :
* $Id: tkcanvas.trm,v 1.6.2.4 2001/10/01 14:07:57 lhecking Exp $
*/
/* GNUPLOT - tkcanvas.trm */
/*[
* Copyright 1990 - 1993, 1998
*
* Permission to use, copy, and distribute this software and its
* documentation for any purpose with or without fee is hereby granted,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
*
* Permission to modify the software is granted, but not the right to
* distribute the complete modified source code. Modifications are to
* be distributed as patches to the released version. Permission to
* distribute binaries produced by compiling modified sources is granted,
* provided you
* 1. distribute the corresponding source modifications from the
* released version in the form of a patch file along with the binaries,
* 2. add special version identification to distinguish your version
* in addition to the base release version number,
* 3. provide your name and address as the primary contact for the
* support of your modified version, and
* 4. retain our contact information in regard to use of the base
* software.
* Permission to distribute the released version of the source code along
* with corresponding source modifications in the form of a patch file is
* granted with same provisions 2 through 4 for binary distributions.
*
* This software is provided "as is" without express or implied warranty
* to the extent permitted by applicable law.
]*/
/*
* This file is included by ../term.c.
*
* This terminal driver supports:
* Tk canvas widgets under several scripting languages
* (currently Tcl, Perl, Python, Ruby)
*
* AUTHORS and HISTORY:
* original dxy.trm by Martin Yii, el...@mo...
* Further modified Jan 1990 by Russell Lang, rj...@mo...
*
* Port to the Tk/Tcl canvas widget
* D. Jeff Dionne, July 1995 je...@ry...
* Alex Woo, wo...@pl...
*
* adapted to the new terminal layout by Alex Woo (Sept. 1996)
*
* extended interactive Tk/Tcl capabilities
* Thomas Sefzick, March 1999, t.s...@fz...
* added the perltk.trm code written by Slaven Rezic <es...@cs...>,
* used a variable to switche between tcl/tk and perltk code.
* 'linewidth' and 'justify text' added, ends of plotted lines are now rounded.
* Thomas Sefzick, May 1999, t.s...@fz...
*
* scale plot to fit into the actual size of the canvas as reported by
* the window manager (the canvas itself doesn't report its real size).
* Matt Willis, October 1999, mat...@my...
*
* cleaned up and generalized in order to accomodate an increasing
* number of scripting languages
* added support for Python
* Joachim Wuttke, October 2002, jw...@us...
*
* BUGS and MISSING FEATURES:
* - Python/Tk: interactive mode not implemented
* (don't know how to bind an event to a line segment within a canvas).
* - Ruby/Tk: interactive mode does not support user_gnuplot_coordinates().
* - font selection missing for Python and Ruby.
* - gnuplot_xy:
* the definition (with 12 input and 4 output coordinates) is clumsy,
* and the implementation is unelegant.
* - we don't take advantage of object orientation; our Ruby code looks
* like an almost literal translation from Tcl (because that's what it is).
*/
#include "driver.h"
#ifdef TERM_REGISTER
register_term(tkcanvas)
#endif
#ifdef TERM_PROTO
TERM_PUBLIC void TK_options __PROTO((void));
TERM_PUBLIC void TK_init __PROTO((void));
TERM_PUBLIC void TK_graphics __PROTO((void));
TERM_PUBLIC void TK_text __PROTO((void));
TERM_PUBLIC void TK_linetype __PROTO((int linetype));
TERM_PUBLIC void TK_move __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void TK_vector __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void TK_put_text __PROTO((unsigned int x,unsigned int y,char *str));
TERM_PUBLIC void TK_reset __PROTO((void));
TERM_PUBLIC int TK_justify_text __PROTO((enum JUSTIFY));
TERM_PUBLIC int TK_set_font __PROTO((char *font));
TERM_PUBLIC void TK_linewidth __PROTO((double linewidth));
#define TK_XMAX 1000
#define TK_YMAX 1000
#define TK_XLAST (TK_XMAX - 1)
#define TK_YLAST (TK_XMAX - 1)
#define TK_VCHAR (25) /* double actual height of characters */
#define TK_HCHAR (16) /* actual width including spacing */
#define TK_VTIC (18)
#define TK_HTIC (18)
#endif /* TERM_PROTO */
#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY
/* plot2d.c */
extern double min_array[], max_array[], base_array[], log_base_array[];
extern TBOOLEAN log_array[];
/* graphics.c */
extern int xleft, xright, ybot, ytop;
extern TBOOLEAN is_3d_plot;
/* static int tk_angle = 0; unused, for now */
static int tk_lastx;
static int tk_lasty;
static int tk_color = 0;
static char tk_anchor[7] = "w";
static double tk_linewidth = 1.0;
static char *tk_colors[] = {
"black", "gray", "red", "blue", "green", "brown", "magenta", "cyan"
};
#define TK_TCL 0
#define TK_PERL 1
#define TK_PYTHON 2
#define TK_RUBY 3
static int tk_script_language = TK_TCL;
static char *tk_script_languages[] = {
"tcl", "perl", "python", "ruby"
};
static int tk_interactive = 0;
TERM_PUBLIC void TK_options()
{
/* tk_script_language = TK_TCL; */ /* not sure we want this - JWu */
tk_interactive = 0;
if (!END_OF_COMMAND) {
if (almost_equals(c_token, "t$cl")) {
tk_script_language = TK_TCL;
c_token++;
}
if (almost_equals(c_token, "pe$rl")) {
tk_script_language = TK_PERL;
c_token++;
}
if (almost_equals(c_token, "pe$rltk")) {
/* for backward compatibility */
tk_script_language = TK_PERL;
c_token++;
}
if (almost_equals(c_token, "py$thon")) {
tk_script_language = TK_PYTHON;
c_token++;
}
if (almost_equals(c_token, "r$uby")) {
tk_script_language = TK_RUBY;
c_token++;
}
if (almost_equals(c_token, "i$nteractive")) {
tk_interactive = 1;
c_token++;
}
}
sprintf(term_options, "script_language=%s %s",
tk_script_languages[tk_script_language],
tk_interactive ? "interactive" : "");
}
TERM_PUBLIC void TK_init()
{
}
/** TK_graphics **/
/*
* Here we start the definition of the `gnuplot` procedure.
* Our scripts take the actual width and height of the canvas and
* scale the plot to fit.
* => this makes 'set size' useless, unless the original width and
* height is taken into account by some script code, that's why the
* 'gnuplot_plotarea' and 'gnuplot_axisranges' procedures are supplied.
*/
static char *tk_init_gnuplot[] = {
/*Tcl */
"proc gnuplot cv {\n"
" $cv delete all\n"
" set cmx [expr\\\n"
" [winfo width $cv]-2*[$cv cget -border]"
"-2*[$cv cget -highlightthickness]]\n"
" if {$cmx <= 1} {set cmx [$cv cget -width]}\n"
" set cmy [expr\\\n"
" [winfo height $cv]-2*[$cv cget -border]"
"-2*[$cv cget -highlightthickness]]\n"
" if {$cmy <= 1} {set cmy [$cv cget -height]}\n",
/* Perl */
"sub {\n"
" my($cv) = @_;\n"
" $cv->delete('all');\n"
" my $cmx = $cv->width - 2 * $cv->cget(-border)\n"
" - 2 * $cv->cget(-highlightthickness);\n"
" if ($cmx <= 1) {$cmx = ($cv->cget(-width));}\n"
" my $cmy = $cv->height - 2 * $cv->cget(-border)\n"
" - 2 * $cv->cget(-highlightthickness);\n"
" if ($cmy <= 1) {$cmy = ($cv->cget(-height));}\n",
/* Python */
"def gnuplot (cv):\n"
"\tcv.delete('all')\n"
"\tcmdelta = 2*(int(cv.cget('border'))+"
"int(cv.cget('highlightthickness')))\n"
"\tcmx = int(cv.cget('width'))-cmdelta\n"
"\tif (cmx<=1):\t\tcmx = int(cv.cget('width'))\n"
"\tcmy = int(cv.cget('height'))-cmdelta\n"
"\tif (cmy<=1):\t\tcmy = int(cv.cget('height'))\n"
"",
/* below, we NEED the blank in "- 2", definitely a weak point of Ruby: */
"def gnuplot(cv)\n"
" cv.delete('all')\n"
" cmx = cv.width - 2*cv.cget('border')- 2*cv.cget('highlightthickness')\n"
" cmx = cvcget.width if (cmx <= 1)\n"
" cmy = cv.height- 2*cv.cget('border')- 2*cv.cget('highlightthickness')\n"
" cmy = cvcget.height if (cmy <= 1)\n"
"",
};
TERM_PUBLIC void TK_graphics()
{
fputs(tk_init_gnuplot[tk_script_language], gpoutfile);
tk_lastx = tk_lasty = tk_color = 0;
}
TERM_PUBLIC void TK_reset()
{
}
TERM_PUBLIC void TK_linetype(linetype)
int linetype;
{
tk_color = (linetype + 2) & 7;
}
TERM_PUBLIC void TK_linewidth(linewidth)
double linewidth;
{
tk_linewidth = linewidth;
}
TERM_PUBLIC void TK_move(x, y)
unsigned int x, y;
{
tk_lastx = x;
tk_lasty = 1000 - y;
}
#define TK_REAL_VALUE(value,axis) \
(log_array[axis])\
?pow(base_array[axis],min_array[axis]+value*(max_array[axis]-min_array[axis]))\
:min_array[axis]+value*(max_array[axis]-min_array[axis])
#define TK_X_VALUE(value) \
(double)(value-xleft)/(double)(xright-xleft)
#define TK_Y_VALUE(value) \
(double)((TK_YMAX-value)-ybot)/(double)(ytop-ybot)
/** TK_Vector **/
/*
* wrapper around the 'create line' command
*/
static char *tk_bind_init[] = {
" $cv bind [\n ", " $cv->bind(\n ", "", ""
};
static char *tk_line_segment[] = {
/* Tcl */
" $cv create line\\\n"
" [expr $cmx*%d/1000] [expr $cmy*%d/1000]\\\n"
" [expr $cmx*%d/1000] [expr $cmy*%d/1000]\\\n"
" -fill %s -width %f -capstyle round\n",
/* Perl */
" $cv->createLine("
"$cmx*%d/1000, $cmy*%d/1000, $cmx*%d/1000, $cmy*%d/1000,\n"
" -fill => q{%s}, -width => %f, -capstyle => q{round})",
/* Python */
"\tcv.create_line(cmx*%d/1000, cmy*%d/1000, cmx*%d/1000, cmy*%d/1000,\\\n"
"\t\tfill='%s', width=%f, capstyle='round')\n",
/* Ruby */
" cl=TkcLine.new("
"cv, cmx*%d/1000, cmy*%d/1000, cmx*%d/1000, cmy*%d/1000,\\\n"
" 'fill'=>'%s', 'width'=>%f, 'capstyle'=>'round')\n"
};
static char *tk_bind_main[] = {
/* Tcl */
" ] <Button> \"gnuplot_xy %%W %f %f %f %f\\\n"
" %f %f %f %f",
/* Perl */
",\n '<Button>' => "
"[\\&gnuplot_xy, %f, %f, %f, %f,\n"
" %f, %f, %f, %f",
/* Python */
/* how can one bind an event to a line segment in Python/TkCanvas ? */
"",
/* Ruby */
" cl.bind('Button', proc{ gnuplot_xy(%f, %f, %f, %f,\\\n"
" %f, %f, %f, %f"
};
static char *tk_bind_f[] = {
" %f", ", %f", "", ", %f"
};
static char *tk_bind_nil[] = {
" {}", ", \"\"", "", ", ''"
};
static char *tk_bind_end[] = {
"\"\n", "]);\n", "", ") })\n"
};
static char *tk_nobind[] = {
"", ";\n", "", ""
};
TERM_PUBLIC void TK_vector(x, y)
unsigned int x, y;
{
/* prepare the binding mechanism */
if (tk_interactive && !is_3d_plot)
fprintf(gpoutfile, tk_bind_init[tk_script_language]);
/* draw a line segment */
y = 1000 - y;
fprintf(gpoutfile,tk_line_segment[tk_script_language],
tk_lastx, tk_lasty, x, y,
tk_colors[tk_color], tk_linewidth);
/* finish the binding mechanism
* (which calls 'gnuplot_xy' for the line segment pointed to by
* the mouse cursor when a mouse button is pressed)
*/
if (tk_interactive && !is_3d_plot) {
fprintf(gpoutfile, tk_bind_main[tk_script_language],
TK_REAL_VALUE(TK_X_VALUE(tk_lastx), FIRST_X_AXIS),
TK_REAL_VALUE(TK_Y_VALUE(tk_lasty), FIRST_Y_AXIS),
TK_REAL_VALUE(TK_X_VALUE(tk_lastx), SECOND_X_AXIS),
TK_REAL_VALUE(TK_Y_VALUE(tk_lasty), SECOND_Y_AXIS),
TK_REAL_VALUE(TK_X_VALUE(x), FIRST_X_AXIS),
TK_REAL_VALUE(TK_Y_VALUE(y), FIRST_Y_AXIS),
TK_REAL_VALUE(TK_X_VALUE(x), SECOND_X_AXIS),
TK_REAL_VALUE(TK_Y_VALUE(y), SECOND_Y_AXIS));
if (log_array[FIRST_X_AXIS])
fprintf(gpoutfile, tk_bind_f[tk_script_language],
TK_REAL_VALUE(TK_X_VALUE(0.5 * (x + tk_lastx)),
FIRST_X_AXIS));
else
fprintf(gpoutfile, tk_bind_nil[tk_script_language]);
if (log_array[FIRST_Y_AXIS])
fprintf(gpoutfile, tk_bind_f[tk_script_language],
TK_REAL_VALUE(TK_Y_VALUE(0.5 * (y + tk_lasty)),
FIRST_Y_AXIS));
else
fprintf(gpoutfile, tk_bind_nil[tk_script_language]);
if (log_array[SECOND_X_AXIS])
fprintf(gpoutfile, tk_bind_f[tk_script_language],
TK_REAL_VALUE(TK_X_VALUE(0.5 * (x + tk_lastx)),
SECOND_X_AXIS));
else
fprintf(gpoutfile, tk_bind_nil[tk_script_language]);
if (log_array[SECOND_Y_AXIS])
fprintf(gpoutfile, tk_bind_f[tk_script_language],
TK_REAL_VALUE(TK_Y_VALUE(0.5 * (y + tk_lasty)),
SECOND_Y_AXIS));
else
fprintf(gpoutfile, tk_bind_nil[tk_script_language]);
fprintf(gpoutfile, tk_bind_end[tk_script_language]);
} else {
fprintf(gpoutfile, tk_nobind[tk_script_language]);
}
tk_lastx = x;
tk_lasty = y;
}
#undef TK_REAL_VALUE
#undef TK_X_VALUE
#undef TK_Y_VALUE
/** TK_put_text **/
static char *tk_create_text[] = {
/* Tcl */
" eval $cv create text "
"[expr $cmx*%d/1000] [expr $cmy*%d/1000]\\\n "
"-text \\{%s\\} -fill %s\\\n -anchor %s "
"[expr [info exists font]?\"-font \\$font\":{}]\n",
/* Perl */
" $cv->createText($cmx*%d/1000, $cmy*%d/1000,\n"
" -text => q{%s}, -fill => q{%s}, -anchor => '%s',\n"
" (defined $font ? (-font => $font) : ()));\n",
/* Python */
"\tcv.create_text(cmx*%d/1000, cmy*%d/1000,\\\n"
"\t\ttext='%s', fill='%s', anchor='%s')\n"
"",
/* Ruby */
" ct=TkcText.new(cv, cmx*%d/1000, cmy*%d/1000,\\\n"
" 'text'=>'%s', 'fill'=>'%s', 'anchor'=>'%s'"
")\n"
};
TERM_PUBLIC void TK_put_text(x, y, str)
unsigned int x, y;
char *str;
{
y = 1000 - y;
fprintf(gpoutfile, tk_create_text[tk_script_language],
x, y, str, tk_colors[tk_color], tk_anchor);
}
TERM_PUBLIC int TK_justify_text(anchor)
enum JUSTIFY anchor;
{
int return_value;
switch (anchor) {
case RIGHT:
strcpy(tk_anchor, "e");
return_value = TRUE;
break;
case CENTRE:
strcpy(tk_anchor, "center");
return_value = TRUE;
break;
case LEFT:
strcpy(tk_anchor, "w");
return_value = TRUE;
break;
default:
strcpy(tk_anchor, "w");
return_value = FALSE;
}
return return_value;
}
/** TK_set_font **/
static char *tk_undef_font[] = {
"catch {unset $font}\n", "undef $font;\n", "", ""
};
static char *tk_set_font[] = {
/* Tcl */
"set font [font create -family %s",
/* Perl */
" if ($cv->cv('fontCreate')) {\n"
" $font = $cv->fontCreate(-family => q{%s}",
/* Python */
"",
/* Ruby */
""
};
static char *tk_set_fsize[] = {
" -size %d", ", -size => %d", "", ""
};
static char *tk_font_end[] = {
"]\n", ");\n}\n", "", ""
};
TERM_PUBLIC int TK_set_font(font)
char *font;
{
if (!font || *font == NUL) {
fputs(tk_undef_font[tk_script_language], gpoutfile);
} else {
char *name;
int size = 0;
size_t sep = strcspn(font, ",");
name = malloc(sep + 1);
if (!name) return FALSE;
strncpy(name, font, sep);
name[sep] = NUL;
if (sep < strlen(font)) sscanf(&(font[sep + 1]), "%d", &size);
fprintf(gpoutfile, tk_set_font[tk_script_language], name);
if (size) fprintf(gpoutfile, tk_set_fsize[tk_script_language], size);
fputs(tk_font_end[tk_script_language], gpoutfile);
free(name);
}
return TRUE;
}
/** TK_text **/
/*
* is called when switching back to text mode;
* generates some procedures which return information about the plot:
* - gnuplot_plotarea
* returns the plotarea size in tkcanvas units
* - gnuplot_axisranges
* returns the min. and max. values of the axis
* (these are needed to set the size of the canvas when the
* axis scaling is important)
* - gnuplot_xy
* contains the actions bound to line segments the mouse is pointing to
* (see 'TK_vector' above):
* either it calls a procedure 'user_gnuplot_coordinates',
* or it writes the coordinates of the line segment to standard output.
*/
static char *tk_endblock[] = { "}\n", "};\n", "", "end\n" };
static char *tk_info_procs[] = {
/* Tcl */
"proc gnuplot_plotarea {} {\n"
" return {%d %d %d %d}\n"
"}\n"
"proc gnuplot_axisranges {} {\n"
" return {%f %f %f %f\n"
" %f %f %f %f}\n"
"}\n",
/* Perl */
"sub gnuplot_plotarea {\n"
" return (%d, %d, %d, %d);\n"
"};\n"
"sub gnuplot_axisranges {\n"
" return (%f, %f, %f, %f,\n"
" %f, %f, %f, %f);\n"
"};\n",
/* Python */
"def gnuplot_plotarea():\n"
"\treturn (%d, %d, %d, %d)\n"
"def gnuplot_axisranges():\n"
"\treturn (%f, %f, %f, %f,\\\n"
"\t %f, %f, %f, %f)\n",
/* Ruby */
"def gnuplot_plotarea()\n"
" return [%d, %d, %d, %d]\n"
"end\n"
"def gnuplot_axisranges()\n"
" return [%f, %f, %f, %f,\\\n"
" %f, %f, %f, %f]\n"
"end\n"
};
static char *tk_gnuplot_xy[] = {
/* Tcl */
"proc gnuplot_xy {win x1s y1s x2s y2s x1e y1e x2e y2e x1m y1m x2m y2m} {\n"
" if {([llength [info commands user_gnuplot_coordinates]])} {\n"
" set id [$win find withtag current]\n"
" user_gnuplot_coordinates $win $id \\\n"
" $x1s $y1s $x2s $y2s $x1e $y1e $x2e $y2e $x1m $y1m $x2m $y2m\n"
" } else {\n"
" if {[string length $x1m]>0} {puts -nonewline \" $x1m\"\n"
" } else {puts -nonewline \" [expr 0.5*($x1s+$x1e)]\"}\n"
" if {[string length $y1m]>0} {puts -nonewline \" $y1m\"\n"
" } else {puts -nonewline \" [expr 0.5*($y1s+$y1e)]\"}\n"
" if {[string length $x2m]>0} {puts -nonewline \" $x2m\"\n"
" } else {puts -nonewline \" [expr 0.5*($x2s+$x2e)]\"}\n"
" if {[string length $y2m]>0} {puts \" $y2m\"\n"
" } else {puts \" [expr 0.5*($y2s+$y2e)]\"}\n"
" }\n"
"}\n",
/* Perl */
"sub gnuplot_xy {\n"
" my ($win, $x1s, $y1s, $x2s, $y2s, $x1e, $y1e, $x2e, $y2e,\n"
" $x1m, $y1m, $x2m, $y2m) = @_;\n"
" if (defined &user_gnuplot_coordinates) {\n"
" my $id = $win->find('withtag', 'current');\n"
" user_gnuplot_coordinates $win, $id, $x1s, $y1s, $x2s, $y2s,\n"
" $x1e, $y1e, $x2e, $y2e, $x1m, $y1m, $x2m, $y2m\n"
" } else {\n"
" print \" \", (length($x1m)>0 ? \"$x1m\": 0.5*($x1s+$x1e));\n"
" print \" \", (length($y1m)>0 ? \"$y1m\": 0.5*($y1s+$y1e));\n"
" print \" \", (length($x2m)>0 ? \"$x2m\": 0.5*($x2s+$x2e));\n"
" print \" \", (length($y2m)>0 ? \"$y2m\": 0.5*($y2s+$y2e));\n"
" print \"\\n\"\n"
" }\n"
"};\n",
/* Python */
/* how can one bind an event to a line segment in Python/TkCanvas ? */
"",
/* Ruby */
"def gnuplot_xy(x1s, y1s, x2s, y2s, x1e, y1e, x2e, y2e,\n"
" x1m, y1m, x2m, y2m)\n"
// " if (defined &user_gnuplot_coordinates)\n"
// " id = win->find('withtag', 'current')\n"
// " user_gnuplot_coordinates (win, id, x1s, y1s, x2s, y2s,\\\n"
// " x1e, y1e, x2e, y2e, x1m, y1m, x2m, y2m)\n"
// " else\n"
" print \" \", x1m!='' ? x1m : 0.5*(x1s+x1e)\n"
" print \" \", y1m!='' ? y1m : 0.5*(y1s+y1e)\n"
" print \" \", x2m!='' ? x2m : 0.5*(x2s+x2e)\n"
" print \" \", y2m!='' ? y2m : 0.5*(y2s+y2e)\n"
" print \"\\n\""
// " end\n"
"end\n",
};
TERM_PUBLIC void TK_text()
{
fprintf(gpoutfile, tk_endblock[tk_script_language]);
if (!is_3d_plot)
fprintf(gpoutfile, tk_info_procs[tk_script_language],
xleft, xright, 1000 - ytop, 1000 - ybot,
min_array[FIRST_X_AXIS], max_array[FIRST_X_AXIS],
min_array[FIRST_Y_AXIS], max_array[FIRST_Y_AXIS],
min_array[SECOND_X_AXIS], max_array[SECOND_X_AXIS],
min_array[SECOND_Y_AXIS], max_array[SECOND_Y_AXIS]);
if (tk_interactive)
fputs(tk_gnuplot_xy[tk_script_language], gpoutfile);
fflush(gpoutfile);
}
#endif /* TERM_BODY */
#ifdef TERM_TABLE
TERM_TABLE_START(tkcanvas)
"tkcanvas", "Tk canvas widget [tcl|perl|python|ruby] [interactive]",
TK_XMAX, TK_YMAX, TK_VCHAR, TK_HCHAR,
TK_VTIC, TK_HTIC, TK_options, TK_init, TK_reset,
TK_text, null_scale, TK_graphics, TK_move, TK_vector,
TK_linetype, TK_put_text, null_text_angle,
TK_justify_text, do_point, do_arrow, TK_set_font,
NULL, 0, NULL, NULL, NULL, TK_linewidth
TERM_TABLE_END(tkcanvas)
#undef LAST_TERM
#define LAST_TERM tkcanvas
#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */
#ifdef TERM_HELP
START_HELP(tkcanvas)
"1 tkcanvas",
"?commands set terminal tkcanvas",
"?set terminal tkcanvas",
"?set term tkcanvas",
"?terminal tkcanvas",
"?term tkcanvas",
"?tkcanvas",
" This terminal driver generates Tk canvas widget commands in one of the",
" following scripting languages: Tcl(default), Perl, Python, Ruby.",
"",
" Usage:",
" gnuplot> set term tkcanvas {tcl|perl|python|ruby} {interactive}",
" gnuplot> set output 'plot.<ext>'",
"",
" (If \"set term tkcanvas\" fails, uncomment or insert the appropriate line",
" in \"term.h\" and rebuild `gnuplot`.)",
"",
" After invoking \"wish\", execute the following sequence of Tcl/Tk commands:",
" % source plot.tcl",
" % canvas .c",
" % pack .c",
" % gnuplot .c",
"",
" Or, for Perl/Tk use a program like this:",
" use Tk;",
" my $top = MainWindow->new;",
" my $c = $top->Canvas->pack;",
" my $gnuplot = do \"plot.pl\";",
" $gnuplot->($c);",
" MainLoop;",
"",
" Or, for Python/Tkinter use a program like this:",
" from Tkinter import *",
" root = Tk()",
" c = Canvas(root)",
" c.pack()",
" fhandle = open('plot.py')",
" exec fhandle",
" gnuplot(c)",
" root.mainloop()",
"",
" Or, for Ruby/Tk use a program like this:",
" require 'tk'",
" root = TkRoot.new { title 'Ruby/Tk' }",
" c = TkCanvas.new(root) { pack { } }",
" load('plot.rb')",
" gnuplot(c)",
" Tk.mainloop",
"",
" The code generated by `gnuplot` (in the above examples, this code is",
" written to \"plot.<ext>\") contains the following procedures:",
"",
" gnuplot(canvas)",
" takes the name of a canvas as its argument.",
" When called, it clears the canvas, finds the size of the canvas and",
" draws the plot in it, scaled to fit.",
"",
" gnuplot_plotarea()",
" returns a list containing the borders of the plotting area",
" (xleft, xright, ytop, ybot) in canvas screen coordinates."
" It works only for 2-dimensional plotting (`plot`).",
"",
" gnuplot_axisranges()",
" returns the ranges of the two axes in plot coordinates",
" (x1min, x1max, y1min, y1max, x2min, x2max, y2min, y2max).",
" It works only for 2-dimensional plotting (`plot`).",
"",
" If the \"interactive\" option is specified, mouse clicking on a line segment",
" will print the coordinates of its midpoint to stdout.",
" The user can supersede this behavior by supplying a procedure",
" user_gnuplot_coordinates which takes the following arguments:",
" win id x1s y1s x2s y2s x1e y1e x2e y2e x1m y1m x2m y2m,",
" i.e. the name of the canvas and the id of the line segment followed by the",
" coordinates of its start and end point in the two possible axis ranges; the",
" coordinates of the midpoint are only filled for logarithmic axes.",
"",
" The current version of `tkcanvas` supports neither `multiplot` nor `replot`.",
" Interactive mode is not implemented for Python/Tk."
" Interactive mode for Ruby/Tk does not yet support user_gnuplot_coordinates."
END_HELP(tkcanvas)
#endif
________________________________________________________________
Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr!
Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=13
|