4 # --------------------------------------------------------------------------
5 # Starting with Tcl 8.x, the BLT commands are stored in their own
6 # namespace called "blt". The idea is to prevent name clashes with
7 # Tcl commands and variables from other packages, such as a "table"
8 # command in two different packages.
10 # You can access the BLT commands in a couple of ways. You can prefix
11 # all the BLT commands with the namespace qualifier "blt::"
14 # blt::table . .g -resize both
16 # or you can import all the command into the global namespace.
18 # namespace import blt::*
20 # table . .g -resize both
22 # --------------------------------------------------------------------------
24 if { $tcl_version >= 8.0 } {
25 namespace import blt::*
26 namespace import -force blt::tile::*
29 source scripts/demo.tcl
31 proc FormatXTicks { w value } {
33 # Determine the element name from the value
35 set index [expr round($value)]
36 if { $index != $value } {
41 set name [lindex { A1 B1 A2 B2 C1 D1 C2 A3 E1 } $index]
45 source scripts/stipples.tcl
47 #image create photo bgTexture -file ./images/chalk.gif
48 image create photo bgTexture -file ./images/rain.gif
50 option add *Button.padX 5
52 option add *tile bgTexture
54 option add *Radiobutton.font -*-courier*-medium-r-*-*-14-*-*
55 option add *Radiobutton.relief flat
56 option add *Radiobutton.borderWidth 2
57 option add *Radiobutton.highlightThickness 0
59 option add *Htext.font -*-times*-bold-r-*-*-14-*-*
60 option add *Htext.tileOffset no
61 option add *header.font -*-times*-medium-r-*-*-14-*-*
63 option add *Barchart.font -*-helvetica-bold-r-*-*-14-*-*
64 option add *Barchart.title "Comparison of Simulators"
65 option add *Axis.tickFont -*-helvetica-medium-r-*-*-12-*-*
66 option add *Axis.titleFont -*-helvetica-bold-r-*-*-12-*-*
67 option add *x.Command FormatXTicks
68 option add *x.Title "Simulator"
69 option add *y.Title "Time (hrs)"
71 option add *activeBar.Foreground pink
72 option add *activeBar.stipple dot3
73 option add *Element.Background red
74 option add *Element.Relief solid
76 option add *Grid.dashes { 2 4 }
77 option add *Grid.hide no
78 option add *Grid.mapX ""
80 option add *Legend.Font "-*-helvetica*-bold-r-*-*-12-*-*"
81 option add *Legend.activeBorderWidth 2
82 option add *Legend.activeRelief raised
83 option add *Legend.anchor ne
84 option add *Legend.borderWidth 0
85 option add *Legend.position right
87 option add *TextMarker.Font *Helvetica-Bold-R*14*
89 set visual [winfo screenvisual .]
90 if { $visual != "staticgray" && $visual != "grayscale" } {
91 option add *print.background yellow
92 option add *quit.background red
93 option add *quit.activeBackground red2
97 Data points with like x-coordinates, can have their bar segments displayed
98 in one of the following modes (using the -barmode option):
100 htext .header -text {
102 radiobutton .header.stacked -text stacked -variable barMode \
103 -anchor w -value "stacked" -selectcolor red -command {
104 .graph configure -barmode $barMode
106 .header append .header.stacked -width 1.5i -anchor w
107 %% Bars are stacked on top of each other. The overall height is the
108 sum of the y-coordinates.
110 radiobutton .header.aligned -text aligned -variable barMode \
111 -anchor w -value "aligned" -selectcolor yellow -command {
112 .graph configure -barmode $barMode
114 .header append .header.aligned -width 1.5i -fill x
115 %% Bars are drawn side-by-side at a fraction of their normal width.
117 radiobutton .header.overlap -text "overlap" -variable barMode \
118 -anchor w -value "overlap" -selectcolor green -command {
119 .graph configure -barmode $barMode
121 .header append .header.overlap -width 1.5i -fill x
122 %% Bars overlap slightly.
124 radiobutton .header.normal -text "normal" -variable barMode \
125 -anchor w -value "normal" -selectcolor blue -command {
126 .graph configure -barmode $barMode
128 .header append .header.normal -width 1.5i -fill x
129 %% Bars are overlayed one on top of the next.
132 htext .footer -text { Hit the %%
133 set im [image create photo -file ./images/stopsign.gif]
134 button $htext(widget).quit -image $im -command { exit }
135 $htext(widget) append $htext(widget).quit -pady 2
136 %% button when you've seen enough. %%
137 label $htext(widget).logo -bitmap BLT
138 $htext(widget) append $htext(widget).logo
141 barchart .graph -tile bgTexture
143 vector X Y0 Y1 Y2 Y3 Y4
145 X set { 1 2 3 4 5 6 7 8 9 }
147 0.729111111 0.002250000 0.09108333 0.006416667 0.026509167
148 0.007027778 0.1628611 0.06405278 0.08786667
151 0.003120278 0.004638889 0.01113889 0.048888889 0.001814722
152 0.291388889 0.0503500 0.13876389 0.04513333
155 11.534444444 3.879722222 4.54444444 4.460277778 2.334055556
156 1.262194444 1.8009444 4.12194444 3.24527778
159 1.015750000 0.462888889 0.49394444 0.429166667 1.053694444
160 0.466111111 1.4152500 2.17538889 2.55294444
163 0.022018611 0.516333333 0.54772222 0.177638889 0.021703889
164 0.134305556 0.5189278 0.07957222 0.41155556
169 # Element attributes:
171 # Label yData Foreground Background Stipple Borderwidth
173 "Setup" Y1 lightyellow3 lightyellow1 fdiagonal1 1
174 "Read In" Y0 lightgoldenrod3 lightgoldenrod1 bdiagonal1 1
175 "Other" Y4 lightpink3 lightpink1 fdiagonal1 1
176 "Solve" Y3 cyan3 cyan1 bdiagonal1 1
177 "Load" Y2 lightblue3 "" fdiagonal1 1
180 foreach {label yData fg bg stipple bd} $attributes {
181 .graph element create $yData -label $label -bd $bd \
182 -y $yData -x X -fg "" -bg $bg -stipple $stipple
184 .header.stacked invoke
188 1,0 .header -fill x \
189 2,0 .graph -fill both \
192 table configure . r0 r1 r3 -resize none
195 Blt_Crosshairs .graph
196 Blt_ActiveLegend .graph
197 Blt_ClosestPoint .graph
199 .graph marker bind all <B2-Motion> {
200 set coords [%W invtransform %x %y]
201 catch { %W marker configure [%W marker get current] -coords $coords }
204 .graph marker bind all <Enter> {
205 set marker [%W marker get current]
206 catch { %W marker configure $marker -bg green}
209 .graph marker bind all <Leave> {
210 set marker [%W marker get current]
211 catch { %W marker configure $marker -bg ""}
214 .graph element bind all <Enter> {
215 .graph element closest %x %y info
216 puts stderr "$info(x) $info(y)"