blob: 309b5b79277ebd1a6a85d9d28e88f9cf2c563f0c (
plain)
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
|
#!../src/bltwish
package require BLT
# --------------------------------------------------------------------------
# Starting with Tcl 8.x, the BLT commands are stored in their own
# namespace called "blt". The idea is to prevent name clashes with
# Tcl commands and variables from other packages, such as a "table"
# command in two different packages.
#
# You can access the BLT commands in a couple of ways. You can prefix
# all the BLT commands with the namespace qualifier "blt::"
#
# blt::graph .g
# blt::table . .g -resize both
#
# or you can import all the command into the global namespace.
#
# namespace import blt::*
# graph .g
# table . .g -resize both
#
# --------------------------------------------------------------------------
if { $tcl_version >= 8.0 } {
namespace import blt::*
namespace import -force blt::tile::*
}
source scripts/demo.tcl
source scripts/stipples.tcl
if { ![string match "*gray*" [winfo screenvisual .]] } {
option add *Button.Background red
option add *TextMarker.Foreground black
option add *TextMarker.Background yellow
option add *LineMarker.Foreground black
option add *LineMarker.Background yellow
option add *PolyMarker.Fill yellow2
option add *PolyMarker.Outline ""
option add *PolyMarker.Stipple bdiagonal1
option add *activeLine.Color red4
option add *activeLine.Fill red2
option add *Element.Color purple
}
set data {
R0lGODlhEAANAMIAAAAAAH9/f///////AL+/vwAA/wAAAAAAACH5BAEAAAUALAAAAAAQAA0A
AAM8WBrM+rAEQWmIb5KxiWjNInCkV32AJHRlGQBgDA7vdN4vUa8tC78qlrCWmvRKsJTquHkp
ZTKAsiCtWq0JADs=
}
set image [image create photo -format gif -data $data]
set graph [graph .g]
table . \
0,0 $graph -fill both
source scripts/graph2.tcl
$graph postscript configure \
-maxpect yes \
-landscape yes
$graph configure \
-width 5i \
-height 5i
$graph axis configure x \
-title "X Axis"
if 1 {
$graph element configure line3 \
-areatile $image
$graph element configure line1 \
-areapattern @bitmaps/sharky.xbm \
-areaforeground red \
-areabackground ""
}
set fileName testImg.jpg
if { [file exists $fileName] } {
set image [image create photo]
winop readjpeg $fileName $image
if 1 {
puts stderr [time {
$graph marker create image -image $image \
-coords "-360.0 -1.0 360.0 1.0" \
-under yes \
-mapx degrees \
-name $fileName
}]
}
}
bind $graph <Control-ButtonPress-3> { MakeSnapshot }
bind $graph <Shift-ButtonPress-3> {
%W postscript output demo2.ps
%W snap -format emf demo2.emf
}
set unique 0
proc MakeSnapshot {} {
update idletasks
global unique
set top ".snapshot[incr unique]"
set im [image create photo]
$graph snap $im 210 150
toplevel $top
wm title $top "Snapshot \#$unique of \"[$graph cget -title]\""
label $top.lab -image $im
button $top.but -text "Dismiss" -command "DestroySnapshot $top"
table $top $top.lab
table $top $top.but -pady 4
focus $top.but
}
proc DestroySnapshot { win } {
set im [$win.lab cget -image]
$im write test.ppm
image delete $im
destroy $win
exit
}
if { $tcl_platform(platform) == "windows" } {
if 0 {
set printer [printer open [lindex [printer names] 0]]
printer getattrs $printer attrs
puts $attrs(Orientation)
set attrs(Orientation) Landscape
set attrs(DocumentName) "This is my print job"
printer setattrs $printer attrs
printer getattrs $printer attrs
puts $attrs(Orientation)
after 5000 {
$graph print2 $printer
printer close $printer
}
}
if 0 {
after 2000 {$graph snap -format emf CLIPBOARD}
}
}
|