/*
* $Id: tkcanvas.trm,v 1.7 1998/04/14 00:18:11 drd 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/Tcl canvas widgets
*
* AUTHORS - original dxy.trm
* Martin Yii, eln557h@monu3.OZ
* Further modified Jan 1990 by Russell Lang, rjl@monu1.cc.monash.oz
*
* Port to the Tk/Tcl canvas widget
* D. Jeff Dionne, July 1995 jeff@ryeham.ee.ryerson.ca
* Alex Woo, woo@playfair.stanford.edu
*
* send your comments or suggestions to (info-gnuplot@dartmouth.edu).
*
*/
/*
* adapted to the new terminal layout by Alex Woo (Sept. 1996)
*/
#include "driver.h"
#ifdef TERM_REGISTER
register_term(tkcanvas)
#endif
#ifdef TERM_PROTO
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));
#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
static int tk_angle = 0;
static int tk_lastx;
static int tk_lasty;
static int tk_color = 0;
static char *tk_colors[] = { "black", "gray", "red", "blue", "green", "brown", "magenta", "cyan" };
TERM_PUBLIC void TK_init()
{
fputs("\
proc gnuplot can {\n\
$can delete all\n\
set cmx [lindex [$can configure -width] 4]\n\
set cmy [lindex [$can configure -height] 4]\n",
gpoutfile);
tk_lastx = tk_lasty = tk_color = 0;
}
TERM_PUBLIC void TK_graphics()
{
}
TERM_PUBLIC void TK_reset()
{
}
TERM_PUBLIC void TK_linetype(linetype)
int linetype;
{
tk_color = (linetype + 2) & 7;
}
TERM_PUBLIC void TK_move(x, y)
unsigned int x, y;
{
tk_lastx = x;
tk_lasty = 1000 - y;
}
TERM_PUBLIC void TK_vector(x, y)
unsigned int x, y;
{
y = 1000 - y;
fprintf(gpoutfile,
"$can create line [expr $cmx * %d /1000] [expr $cmy * %d /1000] [expr $cmx * %d /1000] [expr $cmy * %d /1000] -fill %s\n",
tk_lastx, tk_lasty, x, y, tk_colors[tk_color]);
tk_lastx = x;
tk_lasty = y;
}
TERM_PUBLIC void TK_put_text(x, y, str)
unsigned int x, y;
char *str;
{
y = 1000 - y;
fprintf(gpoutfile,
"$can create text [expr $cmx * %d /1000] [expr $cmy * %d /1000] -text {%s} -fill %s -anchor w\n",
x, y, str, tk_colors[tk_color]);
}
TERM_PUBLIC void TK_text()
{
fputs("}\n", gpoutfile);
fflush(gpoutfile);
}
#endif /* TERM_BODY */
#ifdef TERM_TABLE
TERM_TABLE_START(tkcanvas)
"tkcanvas", "Tk/Tcl canvas widget",
TK_XMAX, TK_YMAX, TK_VCHAR, TK_HCHAR,
TK_VTIC, TK_HTIC, options_null, TK_init, TK_reset,
TK_text, null_scale, TK_graphics, TK_move, TK_vector,
TK_linetype, TK_put_text, null_text_angle,
null_justify_text, do_point, do_arrow, set_font_null
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. To use it, rebuild",
" `gnuplot` (after uncommenting or inserting the appropriate line in \"term.h\"),",
" then",
"",
" gnuplot> set term tkcanvas",
" gnuplot> set output 'plot.file'",
"",
" After invoking \"wish\", execute the following sequence of tcl commands:",
"",
" % source plot.file",
" % canvas .c",
" % pack .c",
" % gnuplot .c",
"",
" The code generated by `gnuplot` creates a tcl procedure called \"gnuplot\"",
" that takes the name of a canvas as its argument. When the procedure is,",
" called, it clears the canvas, finds the size of the canvas and draws the plot",
" in it, scaled to fit.",
"",
" The current version of `tkcanvas` supports neither `multiplot` nor `replot`."
END_HELP(tkcanvas)
#endif