File: tkcanvas.trm

package info (click to toggle)
gnuplot 3.5beta6.340-5
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 4,792 kB
  • ctags: 4,205
  • sloc: ansic: 41,878; asm: 539; makefile: 498; objc: 379; csh: 297; sh: 277; pascal: 194; perl: 138; lisp: 88
file content (187 lines) | stat: -rw-r--r-- 4,943 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
 * $Id: tkcanvas.trm,v 1.5 1997/04/10 02:34:35 drd Exp $
 *
 */

/* GNUPLOT - tkcanvas.trm */
/*
 * Copyright (C) 1990 - 1993, 1997
 *
 * 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 modified code.  Modifications are to be distributed 
 * as patches to released version.
 *  
 * This software  is provided "as is" without express or implied warranty.
 * 
 * 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)
 */

#ifndef GOT_DRIVER_H
#include "driver.h"
#endif

#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()
{
	fprintf(outfile,"proc gnuplot can {\n");
	fprintf(outfile,"$can delete all\n");
	fprintf(outfile,"set cmx [lindex [$can configure -width] 4]\n");
	fprintf(outfile,"set cmy [lindex [$can configure -height] 4]\n");
	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(outfile,"$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(outfile,"$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()
{
	fprintf(outfile,"}\n");
	fflush(outfile);
}


#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",
"?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