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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
|
#
# oneD.tk
#
proc oneD(build) {n wname} {
global Model Defaults Snap rbox highlight Browser COLOR
upvar \#0 oneD$n nm
# remove if not a 1-d mapping
if { ($Model(Mapping_Flag) == 0) || ($Model(Varb_Dim) > 2)} {
window(dismiss) oneD$n
return
}
build_Title $wname "1-D View \#$n"
wm minsize $wname 100 160
set nm(hormin) $Defaults(Varb_Min,0)
set nm(hormax) $Defaults(Varb_Max,0)
set nm(vermin) $Defaults(Varb_Min,0)
set nm(vermax) $Defaults(Varb_Max,0)
set nm(pick) 0
set nm(hormouse) ""
set nm(vermouse) ""
build_DismissButtonbar $wname dbbar "window(dismiss) oneD$n" \
[list "Refresh" "oneD(refresh) $n"] \
[list "Toggle diagonal" "oneD(toggle_diagonal) $n"] \
[list "Toggle function" "oneD(toggle_function) $n"] \
[list "Use default ranges" "oneD(default) $n"] \
[list "Clear" "oneD(clear) $n"]
set cmd [build_CmdFrame $wname cmd]
set cmdl [build_StdFrame $cmd l]
set cmdr [build_StdFrame $cmd r]
build_LabelEntryColumns $cmdr le0 \
{text {} {"Horizontal:" "Vertical:"}} \
[list dentry {} [list oneD$n\(hormin\) oneD$n\(vermin\)]] \
[list dlabel {} [list oneD$n\(hormouse\) oneD$n\(vermouse\)]] \
[list dentry {} [list oneD$n\(hormax\) oneD$n\(vermax\)]]
pack $cmdl $cmdr -side left -anchor w
pack $cmd -fill x
if { [winfo exists $wname.c] == 0 } {
plot $wname.c -bg $COLOR(views) -width 600 -height 600
pack $wname.c -expand 1 -fill both
bind $wname.c <Motion> [list oneD(c_motion) $n %x %y]
bind $wname.c <Leave> [list oneD(c_leave) $n]
bind $wname.c <Enter> [list oneD(leave) $n]
bind $wname <Configure> [list oneD(resize) $n]
bind $wname.c <Button-1> [list oneD(button1) $n %x %y]
bind $wname.c <Button-2> [list oneD(button2) $n %x %y]
bind $wname.c <Button-3> [list oneD(button3) $n %x %y]
bind $wname.c <Shift-Button-1> [list oneD(shift_button1) $n %x %y]
bind $wname.c <ButtonRelease-1> \
[list oneD(button1_release) $n %x %y]
bind $wname.c <Shift-B1-Motion> \
[list oneD(shift_button1_motion) $n %x %y]
window_register ONED $n ACTIVATE
}
set rbox(drawn) 0
set nm(diagonal) 0
set nm(function) 0
set nm(iterate) 1
oneD(register) $n
# draw highlight right away if it's called for
set highlight(drawn_one$n) 0
if {$Browser(Highlight) == 1} {
oneD(set_highlight) $n
oneD(draw_highlight) $n
}
set highlight(drawn_one$n) $Browser(Highlight)
oneD(refresh) $n
}
proc oneD(pickcolor) {n} {
global Defaults
upvar #0 oneD$n nm
#puts "pick color mode for window #$n : $nm(pick)"
window_register ONED $n COLORMODE $nm(pick)
if {$Defaults(Auto_Refresh) == 1} {
oneD(refresh) $n
}
}
proc oneD(snap) {} {
global Snap
global Print
set n $Snap(Wid)
#set Snap(Wid) $n
set Snap(Xwidth) [lindex [.oneD$n.c configure -width] 4]
set Snap(Ywidth) [lindex [.oneD$n.c configure -height] 4]
set Snap(Xoff) 0
set Snap(Yoff) 0
set Snap(Directory) $Print(Directory)
set Snap(Filename) "oned.snap"
set Snap(Findex) 0
window(open) snap
}
proc oneD(print) {} {
global Print Model Snap
set n $Snap(Wid)
upvar #0 oneD$n nm
set Print(Hor_Label) $Model(Varb_Names,0)
set Print(Ver_Label) $Model(Varb_Names,0)
set Print(HorMin) $nm(hormin)
set Print(HorMax) $nm(hormax)
set Print(VerMin) $nm(vermin)
set Print(VerMax) $nm(vermax)
window(open) print
}
proc oneD(enter) {n} {
}
proc oneD(leave) {n} {
upvar #0 oneD$n nm
eval [concat window_register ONED $n RANGE \
$nm(hormin) $nm(hormax) \
$nm(vermin) $nm(vermax) \
$nm(iterate)]
}
proc oneD(c_motion) {n x y} {
upvar #0 oneD$n nm
set xy [oneD(convert) $n $x $y]
set nm(hormouse) [lindex $xy 0]
set nm(vermouse) [lindex $xy 1]
}
proc oneD(c_leave) n {
upvar #0 oneD$n nm
set nm(hormouse) ""
set nm(vermouse) ""
}
proc oneD(convert) {n x y} {
upvar #0 oneD$n nm
set h [lindex [.oneD$n.c configure -height] 4]
set w [lindex [.oneD$n.c configure -width] 4]
# set dx [expr double($x)/($w-1)*($nm(hormax)-$nm(hormin))+$nm(hormin)]
# set dy [expr double($y)/($h-1)*($nm(vermin)-$nm(vermax))+$nm(vermax)]
# BAM 8/19/97 -- error checking in case a min/max field is not a number
set xokay [catch {set dx [expr double($x)/($w-1)*($nm(hormax)-$nm(hormin))+$nm(hormin)]}]
set yokay [catch {set dy [expr double($y)/($h-1)*($nm(vermin)-$nm(vermax))+$nm(vermax)]}]
if {$xokay != 0} { set dx "check bounds" }
if {$yokay != 0} { set dy "check bounds" }
list $dx $dy
}
proc oneD(convert_to_pix) {n x y} {
upvar #0 oneD$n nm
set h [lindex [.oneD$n.c configure -height] 4]
set w [lindex [.oneD$n.c configure -width] 4]
set dx [expr (double($x)-$nm(hormin))/($nm(hormax)-$nm(hormin))*($w-1)]
set dy [expr (double($y)-$nm(vermax))/($nm(vermin)-$nm(vermax))*($h-1)]
list [expr int($dx)] [expr int($dy)]
}
proc oneD(button1) {n x y} {
global Flow
oneD(to_selected) $n $x $y
set Flow(Direction) 1
tcl_to_pm Flow
}
proc oneD(button2) {n x y} {
begin_wait
pm EXEC Flow.Continue
pm_to_tcl Memory Selected
end_wait
}
proc oneD(button3) {n x y} {
global Flow
oneD(to_selected) $n $x $y
set Flow(Direction) 2
tcl_to_pm Flow
}
proc oneD(to_selected) {n x y} {
global Selected
upvar #0 oneD$n nm
set xy [oneD(convert) $n $x $y]
set Selected(Varb_Ic,0) [lindex $xy 0]
tcl_to_pm Selected
selected(enter)
}
proc oneD(dismiss) n {
upvar #0 oneD$n nm
window_register ONED $n DISMISS
if {[info exists nm]} {
unset nm
}
}
proc oneD(refresh) n {
global View
upvar #0 oneD$n nm
begin_wait "Refreshing 1-D View \#$n"
oneD(plot_clear) $n
if {$nm(diagonal)} {
oneD(draw_diagonal) $n
}
if {$nm(function)} {
oneD(draw_function) $n
}
browser(highlight)
set View(Refresh_Num) $n
set View(Refresh_Type) ONED
tcl_to_pm View
pm EXEC View.Refresh
end_wait
}
proc oneD(refresh_all) {} {
global View window
begin_wait {}
foreach ttt $window(names) {
if {[regexp {^oneD([0-9]+)$} $ttt tn n] == 1 } {
oneD(refresh) $n
}
}
end_wait
}
proc oneD(dismiss) n {
upvar #0 oneD$n nm
window_register ONED $n DISMISS
unset nm
}
proc oneD(clear) n {
Flow(Clear_All)
pm_to_tcl Memory
oneD(refresh) $n
}
proc oneD(resize) n {
#puts "Caught Configure event!"
eval [concat window_register ONED $n CONFIG \
[lindex [.oneD$n.c configure -width] 4] \
[lindex [.oneD$n.c configure -height] 4] ]
#oneD(refresh) $n
}
proc oneD(default) n {
global Defaults
upvar #0 oneD$n nm
set nm(hormin) $Defaults(Varb_Min,0)
set nm(hormax) $Defaults(Varb_Max,0)
set nm(vermin) $Defaults(Varb_Min,0)
set nm(vermax) $Defaults(Varb_Max,0)
oneD(leave) $n
if {$Defaults(Auto_Refresh) == 1} {
oneD(refresh) $n
}
}
proc oneD(register) n {
upvar #0 oneD$n nm
eval [concat window_register ONED $n CONFIG \
[lindex [.oneD$n.c configure -width] 4] \
[lindex [.oneD$n.c configure -height] 4] ]
eval [concat window_register ONED $n RANGE \
$nm(hormin) $nm(hormax) \
$nm(vermin) $nm(vermax) \
$nm(iterate)]
}
proc oneD(plot_clear) n {
.oneD$n.c clear
#update
}
proc oneD(shift_button1) {n x y} {
global rbox
set rbox(x) $x
set rbox(y) $y
set rbox(drawn) 0
}
proc oneD(button1_release) {n x y} {
global rbox
upvar #0 oneD$n nm
# erase box if drawn
if {$rbox(drawn) > 0} {
.oneD$n.c rbox $rbox(x) $rbox(y) $rbox(width) $rbox(height)
# take appropriate action!
if {($rbox(width) < 5) || ($rbox(height) < 5)} {
set ans 2
} else {
set ans [build_Dialog dialog "Zoom" "Zoom options:" \
0 "Zoom in" "Zoom out" "Cancel"]
}
if {$ans == 0} {
# Zooming in
set mins [oneD(convert) $n $rbox(x) $rbox(y)]
set maxs [oneD(convert) $n [expr $rbox(x)+$rbox(width)] \
[expr $rbox(y)+$rbox(height)] ]
set nm(hormin) [lindex $mins 0]
set nm(vermin) [lindex $maxs 1]
set nm(hormax) [lindex $maxs 0]
set nm(vermax) [lindex $mins 1]
oneD(register) $n
oneD(refresh) $n
} elseif {$ans == 1} {
# Zooming out
set h [lindex [.oneD$n.c configure -height] 4]
set w [lindex [.oneD$n.c configure -width] 4]
set hmin [expr $nm(hormin) - $rbox(x) * \
($nm(hormax)-$nm(hormin)) / $rbox(width) ]
set nm(hormax) [expr $nm(hormin) + ($w-$rbox(x)) * \
($nm(hormax)-$nm(hormin)) / $rbox(width) ]
set nm(hormin) $hmin
set vmax [expr $nm(vermax) + $rbox(y) * \
($nm(vermax)-$nm(vermin)) / $rbox(height) ]
set nm(vermin) [expr $nm(vermax) - ($h-$rbox(y)) * \
($nm(vermax)-$nm(vermin)) / $rbox(height) ]
set nm(vermax) $vmax
oneD(register) $n
oneD(refresh) $n
}
}
set rbox(drawn) 0
}
proc oneD(shift_button1_motion) {n x y} {
global rbox
# erase box if drawn
if {$rbox(drawn) > 0} {
.oneD$n.c rbox $rbox(x) $rbox(y) $rbox(width) $rbox(height)
} else {
set rbox(x) $x
set rbox(y) $y
}
# compute new width height
set rbox(width) [expr $x - $rbox(x)]
set rbox(height) [expr $y - $rbox(y)]
if {$rbox(width) < 0} {
set rbox(x) $x
set rbox(width) [expr -$rbox(width)]
}
if {$rbox(height) < 0} {
set rbox(y) $y
set rbox(height) [expr -$rbox(height)]
}
# draw new box
.oneD$n.c rbox $rbox(x) $rbox(y) $rbox(width) $rbox(height)
set rbox(drawn) 1
}
proc oneD(toggle_diagonal) n {
upvar #0 oneD$n nm
if {$nm(diagonal) == 0} {
# turn diagonal on
set nm(diagonal) 1
oneD(draw_diagonal) $n
} {
# turn diagonal off
set nm(diagonal) 0
oneD(refresh) $n
}
}
proc oneD(draw_diagonal) n {
upvar #0 oneD$n nm
if {$nm(hormin) > $nm(vermin)} {
set min $nm(hormin)
} {
set min $nm(vermin)
}
if {$nm(hormax) < $nm(vermax)} {
set max $nm(hormax)
} {
set max $nm(vermax)
}
if { $min < $max } {
# draw the line
set xy_min [oneD(convert_to_pix) $n $min $min]
set xy_max [oneD(convert_to_pix) $n $max $max]
eval [concat .oneD$n.c line $xy_min $xy_max {-color red}]
}
}
proc oneD(toggle_function) n {
upvar #0 oneD$n nm
if {$nm(function) == 0} {
# turn diagonal on
set nm(function) 1
oneD(draw_function) $n
} {
# turn diagonal off
set nm(function) 0
oneD(refresh) $n
}
}
proc oneD(draw_function) n {
eval [concat window_register ONED $n CONFIG \
[lindex [.oneD$n.c configure -width] 4] \
[lindex [.oneD$n.c configure -height] 4] ]
set View(Refresh_Num) $n
set View(Refresh_Type) ONED
tcl_to_pm View
pm EXEC View.OneD_Function
}
proc oneD(set_highlight) n {
global highlight Browser
}
proc oneD(draw_highlight) n {
global highlight Browser
}
proc oneD(erase_highlight) n {
global highlight Browser
}
|