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 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783
|
#!nviz -f
# Please log changes in the ChangeLog file in this directory
# (Use "C-x 4 a" from emacs to add an entry)
# These two lines necessary to allow auto-loading
# If you move nviz then be sure to change these two lines
# to reflect the location of the libraries
# Also, don't forget to change the invocation of nvwish above.
# auto_mkindex /data/stimpy/terry/tcl/nviz *.tcl
# exec chmod ugo+rw tclIndex
global src_boot
global env
global BGColor
#If set to 1 output debug statements
global DEBUG
set DEBUG 0
#Initialize ProcessName variable
set env(NV_processname) NVIZ
set BGColor #FFFFFF
source $src_boot/etc/nviz2.2/scripts/config.tcl
global Nv_ ScriptState ScriptFile ScriptPlaying NvizLoadState
set ScriptPlaying 0
##########################################################################
# Constants
##########################################################################
set Nv_(TOP) ".top"
set Nv_(APP) ".top2"
set Nv_(P_AREA) ".top2.panelarea.panels"
set Nv_(AREA) ".top2.panelarea"
set Nv_(CALLED_SET_FOCUS) no
set Nv_(CurrSurf) 0
set Nv_(CurrVect) 0
set Nv_(CurrSite) 0
set Nv_(CurrSdiff) 0
set Nv_(CurrVol) 0
# Some quick code to initialize the CurrSurf, CurrVect and CurrSite variables
set temp [Nget_surf_list]
if {[llength $temp] == 0} then {
set Nv_(CurrSurf) 0
} else {
set Nv_(CurrSurf) [lindex $temp 0]
}
set temp [Nget_vect_list]
if {[llength $temp] == 0} then {
set Nv_(CurrVect) 0
} else {
set Nv_(CurrVect) [lindex $temp 0]
}
set temp [Nget_site_list]
if {[llength $temp] == 0} then {
set Nv_(CurrSite) 0
} else {
set Nv_(CurrSite) [lindex $temp 0]
}
set temp [Nget_vol_list]
if {[llength $temp] == 0} then {
set Nv_(CurrVol) 0
} else {
set Nv_(CurrVol) [lindex $temp 0]
}
##########################################################################
#*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
##########################################################################
# Load this array with the names of the panels that are to be used
#
# 11/1/95 - This array loaded by searching through all the directories
# in $user_path. For each directory in this path, the contents of
# the file panelIndex is added to this array
# note we need a TRACE proc for whenever this list is changed dynamically
#DEBUG
if {$DEBUG} {puts "Adding panels from $user_path"}
set Nv_(panels) [list]
foreach i $user_path {
set index $i/panelIndex
if {[file exists $index]} then {
set panels [exec cat $index]
set panels [split $panels]
foreach j $panels {
if {[lsearch -exact $Nv_(panels) $j] == -1} then {
lappend Nv_(panels) $j
}
}
}
}
# DEBUG
if {$DEBUG} {puts Nv_(panels)}
##########################################################################
#*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
##########################################################################
#########################################################################
# Make sure panel has been loaded
#########################################################################
proc Nv_force_panel { name } {
global Nv_
set P $Nv_(P_AREA)
# create panel if it doesn't already exist
set path $P.$name
if [catch {set Nv_($path)}] {
set file panel_$name.tcl
set Nv_($path) [mk$name\Panel $path]
}
}
###########################################################################
# add key bindings so that menu shortcut keys can be used
###########################################################################
###########################################################################
# make toplevel
###########################################################################
proc Nv_makeGUI {{BASE .top}} {
global Nv_ ScriptState src_boot env
global DEBUG
set width [exec $src_boot/bin/g.gisenv X3D_WIDTH]
if {$width == ""} {set width 585}
set width [expr round($width/.98)]
set height [exec $src_boot/bin/g.gisenv X3D_HEIGHT]
if {$height == ""} {set height 720}
set height [expr round($height /.97)]
#set position variable for placing .top2
set posx [expr $width + 17]
set posy 10
set Nv_(First) 1
wm geometry . $width\x$height\+10+10
wm minsize . 300 200
pack [frame $BASE] -side top -fill both -expand y
toplevel .top2
wm resizable .top2 false false
wm title .top2 "Controls"
set Nv_(height) 720
# DEBUG
if {$DEBUG} {puts "toplevel made"}
###########################################################################
# make informational text widget
###########################################################################
set Nv_(text) "Start"
entry $BASE.entry -relief sunken -borderwidth 3 -state disabled \
-textvariable Nv_(text)
place $BASE.entry -relx 0 -relwidth .70 -rely 0
## glxwin $BASE.canvas -rgb true -db true -zbuffersize -1
togl $BASE.canvas -rgba true -double true -depth true
place $BASE.canvas -relx .01 -rely .03 -relwidth .98 -relheight .97
bind $BASE.canvas <Expose> {Nv_expose %W}
bind $BASE.canvas <Configure> {set Nv_(height) %h}
update
#With widget made reset ProcessName variable
set env(NV_processname) [winfo name .]
# DEBUG
if {$DEBUG} {puts "info widget made"}
###########################################################################
# make panel area
###########################################################################
frame $Nv_(AREA) -relief raised -borderwidth 3
pack $Nv_(AREA) -side top -fill both -expand yes
frame $Nv_(P_AREA) -relief raised -borderwidth 3
# DEBUG
if {$DEBUG} {puts "panel area made"}
###########################################################################
# make menubar
###########################################################################
frame $Nv_(AREA).menu -relief raised -borderwidth 1
pack $Nv_(AREA).menu -side top -fill x -anchor nw
# Make label with invisible text to hold "Please wait..." message
label $Nv_(AREA).menu.wait_pls -text "Please Wait..." \
-fg gray90
pack $Nv_(P_AREA) -side top -fill both -expand yes
pack [Nv_mkMenu $Nv_(AREA).menu.file File \
{"Load State..." "Save State..." "Load 3d Settings..." \
"Save 3d Settings..." "Image Dump..." "Reset" "Quit" } \
{0 0 0 0 0 0 0} \
{ "load_state" "save_state" "load_3dview" "save_3dview" \
"Cascade img menu2" "reset_Nviz" "Nv_close_scripting ; exit ; puts"}]\
-side left -fill both -expand yes
# DEBUG
if {$DEBUG} {puts "file menu made"}
pack [Nv_mkMenu $Nv_(AREA).menu.help Help \
{"NVIZ Help" "About NVIZ" "NVIZ - Bugs / ToDo"} \
{0 0 0} \
{"nviz_browse nviz_toc.html" "nviz_browse nviz_desc.html" "nviz_browse bugs_todo.html"} ] \
-side right -fill both -expand yes
# DEBUG
if {$DEBUG} {puts "Help menu made"}
# Take these out later when these features are more reliable
# $Nv_(AREA).menu.file.m entryconfigure 3 -state disabled
# $Nv_(AREA).menu.file.m entryconfigure 4 -state disabled
# DEBUG
if {$DEBUG} {puts "disabled made"}
pack [Nv_mkPanelMenu $Nv_(AREA).menu.panel] -side left -fill both -expand yes
# DEBUG
if {$DEBUG} {puts "scripting menu 0 made"}
# Make a menu entry for scripting
menubutton $Nv_(AREA).menu.scripting -text Scripting \
-menu $Nv_(AREA).menu.scripting.m -underline 0
menu $Nv_(AREA).menu.scripting.m
# DEBUG
if {$DEBUG} {puts "scripting menu 1 made"}
$Nv_(AREA).menu.scripting.m add checkbutton -label "On" \
-onvalue 1 -offvalue 0 -variable ScriptState \
-command "script_handle_on"
# DEBUG
if {$DEBUG} {puts "scripting menu 2 made"}
$Nv_(AREA).menu.scripting.m add command -label "Scriptfile" \
-underline 0 -command SetScriptFile
# DEBUG
if {$DEBUG} {puts "scripting menu 3 made"}
$Nv_(AREA).menu.scripting.m add command -label "Script Tools" \
-underline 1 -command {exec nviz -f $default_panel_path/script_tools -q &}
# DEBUG
if {$DEBUG} {puts "scripting menu 4 made"}
$Nv_(AREA).menu.scripting.m add command -label "Add Script Line" \
-underline 0 -command AddScriptLine
# DEBUG
if {$DEBUG} {puts "scripting menu 5 made"}
$Nv_(AREA).menu.scripting.m add command -label "Add Script Cmd" \
-underline 1 -command AddScriptCmd
# DEBUG
if {$DEBUG} {puts "scripting menu 6 made"}
$Nv_(AREA).menu.scripting.m add command -label "Play Script" \
-underline 0 -command {set ScriptPlaying 1 ; exec nviz -f $default_panel_path/script_play &}
# DEBUG
if {$DEBUG} {puts "scripting menu 7 made"}
$Nv_(AREA).menu.scripting.m add command -label "Close Script" \
-underline 1 -command Nv_close_scripting
pack $Nv_(AREA).menu.scripting -side left -fill both -expand yes
# DEBUG
if {$DEBUG} {puts "scripting menu made"}
tk_menuBar $Nv_(AREA).menu $Nv_(AREA).menu.file $Nv_(AREA).menu.panel \
$Nv_(AREA).menu.scripting
set Nv_(Q) [Q_init 2]
pack $Nv_(AREA).menu.wait_pls -side left -fill x -expand yes
# initialize Main panel
Nv_force_panel main
Nv_openPanel main 0
update
# DEBUG
if {$DEBUG} {puts "menubar made"}
focus $Nv_(AREA).menu
wm geometry .top2 "+$posx\+$posy"
return $BASE
}
proc menu2 { menu } {
menu $menu \
-tearoff 0
$menu add command \
-command dump_rgb -underline 0 -label "IRIS RGB Image"
$menu add command \
-command dump_ppm -underline 0 -label "PPM Image"
$menu add command \
-command dump_tif -underline 0 -label "TIFF Image"
$menu add command \
-command {set fname [create_file_browser .file_browser 1]
if {$fname != -1} then {
appBusy
Nstart_zoom $fname [winfo screenwidth .] [winfo screenheight .]
appNotBusy
}
} -underline 0 -label "Save Max. Resolution PPM(s)"
}
proc dump_rgb { } {
# This routine should use: Nwrite_rgb $fname
set fname [create_file_browser .file_browser 1]
# show we are busy
appBusy
if {$fname != -1} then {
Ndraw_all
Nwrite_rgb $fname
}
# show user can proceed
appNotBusy
}
proc dump_ppm { } {
# This routine should use: Nwrite_ppm $fname
set fname [create_file_browser .file_browser 1]
# show we are busy
appBusy
if {$fname != -1} then {
Ndraw_all
Nwrite_ppm $fname
}
# show user can proceed
appNotBusy
}
proc dump_tif { } {
# This routine should use: Nwrite_tif $fname
set fname [create_file_browser .file_browser 1]
# show we are busy
appBusy
if {$fname != -1} then {
Ndraw_all
Nwrite_tif $fname
}
# show user can proceed
appNotBusy
}
###########################################################################
# null proc
###########################################################################
proc null {args} {}
#########################################################################
# open panel P.name with routine mkP and place in appropriate spot
#########################################################################
proc Nv_openPanel { name {pos -1}} {
global Nv_
set P $Nv_(P_AREA)
# create panel if it doesn't already exist
set path $P.$name
# if panel has not yet been created ...
# or panel is one that needs updating ...
if {[catch {set panel $Nv_($path)}]} then {
set panel [mk$name\Panel $path]
set Nv_($path) $panel
} elseif {"site" == "$name"} then {
set panel [mk$name\Panel $path]
set Nv_($path) $panel
} elseif {"vect" == "$name"} then {
set panel [mk$name\Panel $path]
set Nv_($path) $panel
} elseif {"sdiff" == "$name"} then {
set panel [mk$name\Panel $path]
set Nv_($path) $panel
}
# if panel is not already mapped ...
if { [lsearch [place slaves $P] $P.$name] < 0 } {
if {$pos < 0} {
Q_add $Nv_(Q) $panel
} else {
Nv_mapPanel $path $panel $pos
}
}
}
proc Nv_mapPanel {name panel pos } {
#insert update to fix KDE wm problem
update
set size [St_get $panel size]
if [catch {set height [expr $size * .33]}] { set height 1}
if [catch {set y [expr $pos * .33]}] { set y 0}
pack $name -side top -fill x -expand no -anchor n
set x [winfo x .top2]
set y [winfo y .top2]
if {$x && $y} {
wm geometry .top2 "+$x+$y"
}
}
proc Nv_closePanel { name } {
pack forget $name
}
# Simple routine to uniformly close any opened panels
proc Nv_closeAllPanels { } {
global Nv_
set children [pack slaves $Nv_(P_AREA)]
foreach i $children {
if {[regexp main "$i"] != 1} then {
pack forget $i
}
}
}
############################################################################
# procedure to make PANEL pulldown menu
###########################################################################
proc Nv_mkPanelMenu { P { name Panel } } {
global Nv_ DEBUG
menubutton $P -text $name -menu $P.m -underline 0
menu $P.m
# DEBUG
if {$DEBUG} {puts "Nv_mkPanelMenu 1"}
set j 0
foreach i $Nv_(panels) {
Nv_force_panel $i
set panel $Nv_($Nv_(P_AREA).$i)
$P.m add command -label [St_get $panel name] \
-command "Nv_openPanel $i"
# DEBUG
if {$DEBUG} {puts "Nv_mkPanelMenu 2 $j"}
incr j
}
return $P
}
proc inform {args} {
global Nv_
set Nv_(text) ""
foreach S $args {
set Nv_(text) [concat $Nv_(text) $S]
}
}
proc Nv_expose { W } {
global Nv_
global BGColor
# if [$W islinked] then {
if {$Nv_(First)} then {
init_graphics
set Nv_(First) 0
} else {
Nbackground $BGColor
Nquick_draw
}
# }
}
proc save_3dview { dummy } {
# Ask the user for a file name to save in
set file_name [create_map_browser .browse_3dview_file "3d.view" 1]
if {$file_name == -1} then return
Nsave_3dview $file_name
}
proc load_3dview { dummy } {
global Nv_
# Ask the user for a file name to load from
set file_name [create_map_browser .browse_3dview_file "3d.view" 1]
if {$file_name == -1} then return
#do a quick draw to make sure display initialized
Nquick_draw
Nload_3dview $file_name
#Reset position GUI
set ht [lindex [Nget_real_position 1] 2]
#reset height
Nv_setEntry $Nv_(main_BASE).midf.height.f.entry $ht
Nv_floatscaleCallback $Nv_(main_BASE).midf.height e 2 null $ht
change_display 2
change_display 1
Nquick_draw
}
# Procedure to load the state of the system, calls a special
# load procedure for each panel in the system.
proc load_state { dummy } {
global Nv_
# First open a file for reading in the state
set new_file [create_file_browser .state_file 1 0]
if {$new_file == -1} then return
# show that we are busy
appBusy
load_state_aux $new_file
# show that we aren't busy anymore
appNotBusy
}
#Procedure to load NVIZ HTML pages
proc nviz_browse { URL dummy } {
global env
exec $env(GISBASE)/docs/nviz/help_frame.tcl $env(GISBASE)/docs/nviz/$URL &
}
proc load_state_aux { new_file} {
global Nv_
if {[catch {set file_hook [open $new_file r]} error_code] != 0} then {
display_error "While opening file: $error_code"
return
}
# Close all panels fist
Nv_closeAllPanels
# First line before panel data contains the name of the panel which
# saved the data. Use this name to build the command which will
# read in the data and call the appropriate routine.
while {[gets $file_hook i] != -1} {
set cmd_name "Nviz_$i"
append cmd_name "_load"
if {[catch {$cmd_name $file_hook} error_code] != 0} then {
puts "Diagnostic: $error_code -- Load procedure for panel $i may not be defined"
}
}
# Finally, close the file and exit
close $file_hook
# Go through each of the panels one at a time and force them to open
# This should update them all so they display correctly
foreach i $Nv_(panels) {
Nv_openPanel $i
update
}
Nv_closeAllPanels
return 1
}
# Procedure to completely reset nviz, calls a special reset procedure
# in each panel in the system
proc reset_Nviz { dummy } {
global Nv_
# Query user to verify this choice
if {[tk_dialog .reset_all "Reset" \
"Really reset Nviz?" {} 1 "Ok" "Cancel"] == 1} then return
# Show that we are busy
appBusy
# Now call each of the panels one at a time and pass the
# file hook so that each panel can write out its state
set tmp_list $Nv_(panels)
lappend tmp_list main
foreach i $tmp_list {
set cmd_name "Nviz_$i"
append cmd_name "_reset"
if {[catch {$cmd_name} error_code] != 0} then {
puts "Diagnostic: $error_code -- Reset procedure for panel $i may not be defined"
}
}
# Go through each of the panels one at a time and force them to open
# This should update them all so they display correctly
foreach i $Nv_(panels) {
Nv_openPanel $i
update
}
Nv_closeAllPanels
# Show that user may proceed
appNotBusy
}
# This routine is equivalent to the one above except it skips alot of
# the user interface BS
proc reset_nviz_aux { } {
global Nv_
# Now call each of the panels one at a time and pass the
# file hook so that each panel can write out its state
set tmp_list $Nv_(panels)
lappend tmp_list main
foreach i $tmp_list {
set cmd_name "Nviz_$i"
append cmd_name "_reset"
if {[catch {$cmd_name} error_code] != 0} then {
puts "Diagnostic: $error_code -- Reset procedure for panel $i may not be defined"
}
}
# Go through each of the panels one at a time and force them to open
# This should update them all so they display correctly
foreach i $Nv_(panels) {
Nv_openPanel $i
update
}
Nv_closeAllPanels
}
# Procedure to save the state of the system, calls a special
# save procedure for each panel in the system.
proc save_state { dummy } {
global Nv_
# First open a file for writing out the state
set new_file [create_file_browser .state_file 1 0]
if {$new_file == -1} then return
if {[catch {set file_hook [open $new_file w]} error_code] != 0} then {
display_error "While opening file: $error_code"
return
}
# Show that we are busy
appBusy
# Now call each of the panels one at a time and pass the
# file hook so that each panel can write out its state
set tmp_list $Nv_(panels)
lappend tmp_list main
foreach i $tmp_list {
puts $file_hook "$i"
set cmd_name "Nviz_$i"
append cmd_name "_save"
if {[catch {$cmd_name $file_hook} error_code] != 0} then {
puts "Diagnostic: $error_code -- Save procedure for panel $i may not be defined"
}
}
# Finally, close the file and exit
close $file_hook
# Show that user may proceed
appNotBusy
}
###################################################
# Routine to display error
###################################################
proc display_error { err_string } {
tk_dialog .file_error "File Error" "$err_string" \
error 0 "Dismiss"
}
# Set the cancel function for drawing
Nset_cancel_func update
# and start the ball rolling...
Nv_makeGUI .top
# Center the view on initialization
look_center
# *********************************************************************
# ************* Additional Keyframe Animator Channels *****************
# *********************************************************************
# Add cutplane 0 to the keyframe animator
# Create the cutplane entry list
global Nv_
set Nv_(CutPlaneFence) OFF
set entry_list [list [list pos_x dynamic] [list pos_y dynamic] [list pos_z dynamic]]
lappend entry_list [list blend_type static]
lappend entry_list [list rot dynamic] [list tilt dynamic]
keyanimAddChannel $Nv_(P_AREA).kanimator "cplane-0" $entry_list \
cutplane0_get_entries cutplane0_set_entries
# Undo the "Please wait..." message
update
catch {destroy .wait_ok}
# *********************************************************************
# Automatically load state file from command line
# *********************************************************************
if {[catch {set NvizLoadState}] == 0} then {
global Nv_
appBusy
load_state_aux $NvizLoadState
appNotBusy
}
# *********************************************************************
# Automatics command line script playing functions
# *********************************************************************
# If the -script option was used then we need to immediately start a script
# We kill Nviz after the script has finished playing
if {[catch {set NvizPlayScript}] == 0} then {
global NvizPlayScript NvizPlayScriptProcess ScriptPlaying
global NvizScriptKill
set ScriptPlaying 1
set NvizPlayScriptProcess [exec nviz -f $default_panel_path/script_play $NvizPlayScript &]
if {[catch {set NvizScriptKill}] == 0} then {
after 5000 CheckScriptDone
}
}
proc CheckScriptDone {} {
global NvizPlayScriptProcess
set answer [catch {exec ps -p $NvizPlayScriptProcess | grep $NvizPlayScriptProcess}]
puts "Done check = $answer"
if {$answer == 1} then {
exit
}
after 5000 CheckScriptDone
}
|