[GRASS-SVN] r35072 - grass/branches/releasebranch_6_4/visualization/nviz/scripts

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Dec 28 02:39:42 EST 2008


Author: cmbarton
Date: 2008-12-28 02:39:42 -0500 (Sun, 28 Dec 2008)
New Revision: 35072

Modified:
   grass/branches/releasebranch_6_4/visualization/nviz/scripts/nviz2.2_script
Log:
backport from develbranch_6 r 35070. Fix nviz opening, and hide/show panels. Some cosmetics.

Modified: grass/branches/releasebranch_6_4/visualization/nviz/scripts/nviz2.2_script
===================================================================
--- grass/branches/releasebranch_6_4/visualization/nviz/scripts/nviz2.2_script	2008-12-28 07:38:28 UTC (rev 35071)
+++ grass/branches/releasebranch_6_4/visualization/nviz/scripts/nviz2.2_script	2008-12-28 07:39:42 UTC (rev 35072)
@@ -63,7 +63,7 @@
 set Nv_(TOP)	".middle.draw"
 set Nv_(APP)	"."
 set Nv_(P_AREA) ".middle.panelarea.panels"
-set Nv_(PAREA)	 ".middle.panelarea"
+set Nv_(PAREA)	".middle.panelarea"
 set Nv_(AREA)	".top"
 set Nv_(CALLED_SET_FOCUS) no
 set Nv_(CurrSurf) 0
@@ -71,6 +71,7 @@
 set Nv_(CurrSite) 0
 set Nv_(CurrSdiff) 0
 set Nv_(CurrVol) 0
+set Nv_(hidemenus) 1
 
 # Some quick code to initialize the CurrSurf, CurrVect and CurrSite variables
 set temp [Nget_surf_list]
@@ -185,37 +186,32 @@
 
 
 ###################################
-# Procedure to hide menus
+# Procedure to hide or reveal panels
 ###################################
-proc hide_menus {} {
-	global Nv_ bit_map_path
+proc hide_menus { } {
+	global Nv_
+	global bit_map_path
+	
+	if {$Nv_(hidemenus) == "1" } {
+		set Nv_(hidemenus) 0
+		$Nv_(PAREA).canvas configure -width 0		
+		$Nv_(PAREA).f1.b1 configure -bitmap @$bit_map_path/right \
+			-width 12 -height 18 -command "hide_menus"
+		help $Nv_(PAREA).f1.b1 balloon "Show Panels"
+		#$Nv_(AREA).menu.config.m entryconfigure 1 -label "Show Panels" -command "show_menus"
+	} else {
+		set Nv_(hidemenus) 1
+		$Nv_(PAREA).canvas configure -width [winfo width $Nv_(P_AREA)]
+		$Nv_(PAREA).f1.b1 configure -bitmap @$bit_map_path/left \
+			-width 12 -height 18 -command "hide_menus"
+		help $Nv_(PAREA).f1.b1 balloon "Hide Panels"
+		#$Nv_(AREA).menu.config.m entryconfigure 1 -label "Hide Panels" -command "hide_menus"
+	}
+	update
 
-	$Nv_(PAREA).canvas	configure -width 0
-	$Nv_(PAREA).f1.b1 configure -bitmap @$bit_map_path/right \
-			-width 8 -height 12 -command "show_menus"
-
-	help $Nv_(PAREA).f1.b1 balloon "Show Panels"
-
-	$Nv_(AREA).menu.config.m entryconfigure 1 -label "Show Panels" -command "show_menus"
-
 }
 
-###################################
-# Procedure to reveal menus
-###################################
-proc show_menus {} {
-	global Nv_ bit_map_path
 
-	$Nv_(PAREA).canvas	configure -width [winfo width $Nv_(P_AREA)]
-	$Nv_(PAREA).f1.b1 configure -bitmap @$bit_map_path/left \
-			-width 8 -height 12 -command "hide_menus"
-
-	help $Nv_(PAREA).f1.b1 balloon "Hide Panels"
-
-	$Nv_(AREA).menu.config.m entryconfigure 1 -label "Hide Panels" -command "hide_menus"
-}
-
-
 ###########################################################################
 # add key bindings so that menu shortcut keys can be used
 ###########################################################################
@@ -238,7 +234,7 @@
 	wm sizefrom . user
 
 	#Use three base frames
-	frame .top -relief flat -bd 0
+	frame $Nv_(AREA) -relief flat -bd 0
 	frame .middle -relief flat -bd 0
 	frame .bottom -relief flat -bd 0
 
@@ -258,8 +254,8 @@
 	pack $Nv_(PAREA) -side left -fill y -expand no
 
 	#togl canvas
-	frame .middle.draw -relief groove -bd 2
-	pack .middle.draw -side left -fill both -expand yes
+	frame $Nv_(TOP) -relief groove -bd 2
+	pack $Nv_(TOP) -side left -fill both -expand yes
 
 	entry .bottom.entry -relief sunken -state disabled \
 		-background #FFFFFF -textvariable Nv_(text)
@@ -267,29 +263,29 @@
 
 	set cwidth [exec $src_boot/bin/g.gisenv X3D_WIDTH]
 	set cheight [exec $src_boot/bin/g.gisenv X3D_HEIGHT]
-
+	
 	if {$cwidth > 0 && $cheight > 0} {
-		togl .middle.draw.canvas -rgba true -double true -depth true \
+		togl $Nv_(TOP).canvas -rgba true -double true -depth true \
 				-width $cwidth -height $cheight
-		pack .middle.draw.canvas -side top -expand no
+		pack $Nv_(TOP).canvas -side top -expand no
 	} elseif {$cwidth == "" && $cheight > 0} {
-		togl .middle.draw.canvas -rgba true -double true -depth true \
+		togl $Nv_(TOP).canvas -rgba true -double true -depth true \
 				-height $cheight
-		pack .middle.draw.canvas -side top -fill x -expand yes
+		pack $Nv_(TOP).canvas -side top -fill x -expand yes
 	} elseif {$cheight == "" && $cwidth > 0} {
-		togl .middle.draw.canvas -rgba true -double true -depth true \
+		togl $Nv_(TOP).canvas -rgba true -double true -depth true \
 				-width $cwidth
-		pack .middle.draw.canvas -side top -fill y -expand yes
+		pack $Nv_(TOP).canvas -side top -fill y -expand yes
 	} else {
 	#nothing set
 	set constrained 1
-		togl .middle.draw.canvas -rgba true -double true -depth true
-		pack .middle.draw.canvas -side top -fill both -expand yes
+		togl $Nv_(TOP).canvas -rgba true -double true -depth true
+		pack $Nv_(TOP).canvas -side top -fill both -expand yes
 	}
 
-	bind .middle.draw.canvas <Expose> {Nv_expose %W}
-	bind .middle.draw.canvas <Configure> {set Nv_(height) %h}
-	set tags [bindtags .middle.draw.canvas]
+	bind $Nv_(TOP).canvas <Expose> {Nv_expose %W}
+	bind $Nv_(TOP).canvas <Configure> {set Nv_(height) %h}
+	set tags [bindtags $Nv_(TOP).canvas]
 
 	# the Togl widget can't be redrawn until the main panel has been created
 	#	 update
@@ -300,7 +296,7 @@
 	#Moved the following packing here to satisfy some TCL versions
 	#Prevents minimized GUI
 	#top frame for menubar
-	pack .top -side top -fill x -expand no
+	pack $Nv_(AREA) -side top -fill x -expand no
 	#middle frame for menus and togl canvas
 	pack .middle  -side top -fill both -expand yes
 	#botom frame for statusbar
@@ -318,8 +314,9 @@
 	scrollbar $Nv_(PAREA).f1.scrolly -command "$Nv_(PAREA).canvas yview"        
         bind all <MouseWheel> {$Nv_(PAREA).canvas yview scroll [expr -1 * %D] units}
 	button $Nv_(PAREA).f1.b1 -bitmap @$bit_map_path/left \
-		-width 8 -height 12 -command "hide_menus"
+		-width 12 -height 18 -command "hide_menus"
 	help $Nv_(PAREA).f1.b1 balloon "Hide Panels"
+	
 
 	frame $Nv_(P_AREA) -relief flat
 
@@ -460,8 +457,12 @@
 # DEBUG
 if {$DEBUG} {puts "menubar made"}
 
-	focus $Nv_(AREA).menu
+	raise .bottom
+	raise .middle
+	raise $Nv_(AREA)
 
+	focus -force $Nv_(AREA).menu
+
 	return $BASE
 }
 
@@ -673,7 +674,7 @@
 	if {$DEBUG} {puts "Nv_mkConfigMenu 1"}
 
 	set j 0
-	$P.m add command -label "Hide Panels" -command hide_menus
+	$P.m add command -label "Hide Panels" -command "hide_menus"
 	$P.m add separator
 
 	foreach i $Nv_(config) {
@@ -706,15 +707,13 @@
 	global Nv_
 	global BGColor
 
-#	 if [$W islinked] then {
 	if {$Nv_(First)} then {
 		init_graphics
 		set Nv_(First) 0
 	} else {
-			Nbackground $BGColor
+		Nbackground $BGColor
 		Nquick_draw
 	}
-#	 }
 }
 
 proc save_3dview { dummy } {
@@ -811,10 +810,10 @@
 	button .canvas_size.f2.b1 -text "Close" \
 		-command {
 			if {$constrained} {
-					pack $Nv_(TOP).canvas -side top -fill both -expand yes
+				pack $Nv_(TOP).canvas -side top -fill both -expand yes
 			} else {
-					$Nv_(TOP).canvas configure -width $cwidth -height $cheight
-					pack $Nv_(TOP).canvas -side top -expand no -fill none
+				$Nv_(TOP).canvas configure -width $cwidth -height $cheight
+				pack $Nv_(TOP).canvas -side top -expand no -fill none
 				#Need Nset_viewport to make sure reshape is called
 				Nset_viewport $cwidth $cheight
 			}
@@ -892,13 +891,13 @@
 	# 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_(config) {
-        Nv_openPanel $i
-        update
+		Nv_openPanel $i
+		update
 	}
 
 	foreach i $Nv_(panels) {
-        Nv_openPanel $i
-        update
+		Nv_openPanel $i
+		update
 	}
 
 	Nv_closeAllPanels
@@ -923,32 +922,32 @@
 	set tmp_list $Nv_(panels)
 	lappend tmp_list main
 	foreach i $Nv_(panels) {
-        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"
-        }
+		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"
+		}
 	}
 
 	foreach i $Nv_(config) {
-        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"
-        }
+		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_openPanel $i
+		update
 	}
 
 	foreach i $Nv_(config) {
-        Nv_openPanel $i
-        update
+		Nv_openPanel $i
+		update
 	}
 
 	Nv_closeAllPanels
@@ -968,31 +967,31 @@
 	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"
-        }
+		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"
+		}
 	}
 
 	foreach i $Nv_(config) {
-        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"
-        }
+		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_openPanel $i
+		update
 	}
 
 	foreach i $Nv_(config) {
-        Nv_openPanel $i
-        update
+		Nv_openPanel $i
+		update
 	}
 
 	Nv_closeAllPanels
@@ -1010,12 +1009,12 @@
 
 	# append ".nviz" extension to the filename if it doesn't already have one
 	if { [string compare [file extension $new_file] ".nviz"] != 0 } then {
-        append new_file ".nviz"
+		append new_file ".nviz"
 	}
 
 	if {[catch {set file_hook [open $new_file w]} error_code] != 0} then {
-        display_error "While opening file: $error_code"
-        return
+		display_error "While opening file: $error_code"
+		return
 	}
 
 	# Show that we are busy
@@ -1024,11 +1023,11 @@
 	# Now call each of the panels one at a time and pass the
 	# file hook so that each panel can write out its state
 	foreach i $Nv_(panelstate) {
-        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"
-        }
+		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
@@ -1050,7 +1049,7 @@
 Nset_cancel_func update
 
 # and start the ball rolling...
-Nv_makeGUI .top
+Nv_makeGUI $Nv_(AREA)
 
 # Center the view on initialization
 look_center
@@ -1078,13 +1077,12 @@
 # Automatically load state file from command line
 # *********************************************************************
 if {[catch {set NvizLoadState}] == 0} then {
+	global Nv_
 
-global Nv_
+	appBusy
+	load_state_aux $NvizLoadState
 
-appBusy
-load_state_aux $NvizLoadState
-
-appNotBusy
+	appNotBusy
 }
 
 if {$DEBUG} {puts "Finished loading, call draw all"}



More information about the grass-commit mailing list