[GRASS-SVN] r29598 - grass/branches/releasebranch_6_3/gui/tcltk/gis.m

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jan 8 06:22:52 EST 2008


Author: neteler
Date: 2008-01-08 06:22:52 -0500 (Tue, 08 Jan 2008)
New Revision: 29598

Modified:
   grass/branches/releasebranch_6_3/gui/tcltk/gis.m/mapcanvas.tcl
   grass/branches/releasebranch_6_3/gui/tcltk/gis.m/mapprint.tcl
   grass/branches/releasebranch_6_3/gui/tcltk/gis.m/runandoutput.tcl
Log:
various backports

Modified: grass/branches/releasebranch_6_3/gui/tcltk/gis.m/mapcanvas.tcl
===================================================================
--- grass/branches/releasebranch_6_3/gui/tcltk/gis.m/mapcanvas.tcl	2008-01-08 11:02:54 UTC (rev 29597)
+++ grass/branches/releasebranch_6_3/gui/tcltk/gis.m/mapcanvas.tcl	2008-01-08 11:22:52 UTC (rev 29598)
@@ -593,8 +593,7 @@
 			Gm::errmsg $error [G_msg "Error setting region"]
 		}
 		# Finally put this into wind file format to use with GRASS_REGION
-		regexp -nocase {^.* (\(.*\))} $parts(projection) trash end
-		set parts(projection) [string trim $parts(projection) $end]
+		regexp -nocase {^([0-9]+)} $parts(projection) trash parts(projection)
 
 		set gregion "projection:$parts(projection); zone:$parts(zone); north:$parts(north); south:$parts(south); east:$parts(east); west:$parts(west); e-w resol:$parts(ewres);	 n-s resol:$parts(nsres)"
 	} 

Modified: grass/branches/releasebranch_6_3/gui/tcltk/gis.m/mapprint.tcl
===================================================================
--- grass/branches/releasebranch_6_3/gui/tcltk/gis.m/mapprint.tcl	2008-01-08 11:02:54 UTC (rev 29597)
+++ grass/branches/releasebranch_6_3/gui/tcltk/gis.m/mapprint.tcl	2008-01-08 11:22:52 UTC (rev 29598)
@@ -38,10 +38,10 @@
 	variable tmpppmfile
 	variable tmppsfile 
 	variable tmpscript 
-    variable PPap 
-    variable PVar 
-    variable PView
-    variable PWid 
+	variable PPap 
+	variable PVar 
+	variable PView
+	variable PWid 
 	global array can # mon
 }
 
@@ -69,23 +69,25 @@
 	global mon
 	global mingw
 
-    set psprint::pgwd 8.5
-    set psprint::pght 11
-    set psprint::docwd 7.5
-    set psprint::docht 10
-    set psprint::paper "preset"
-    set psprint::paper_preset "letter"
-    set psprint::printer ""
-    set psprint::gsexists 1
-    set psprint::orient "landscape"
-    set psprint::res 300
+	set psprint::pgwd 8.5
+	set psprint::pght 11
+	set psprint::docwd 7.5
+	set psprint::docht 10
+	set psprint::paper "preset"
+	set psprint::paper_preset "letter"
+	set psprint::printer ""
+	set psprint::gsexists 1
+	set psprint::orient "landscape"
+	set psprint::res 300
 	set psprint::mleft 1
 	set psprint::mright 1
 	set psprint::mtop 1
 	set psprint::mbottom 1
 	
-	# check for ghostscript
-	
+	# default is lpr printing
+	set printmode "lpr"
+
+	# check for ghostscript	
 	# switch to native windows version of ghostscript if runing wingrass
 	if { $mingw == 1 } {
 		set cmd "gswin32c"
@@ -93,17 +95,17 @@
 		set cmd "gs"
 	}
 
+	#enable additional printing options if Ghostscript available
 	if {![catch {set input [exec $cmd -help]} error]} {
 		regexp ".*Available devices:(.*)Search path:" $input string gsdevices 
 		set gsstate "normal"
-		set printmode "lpr"
 		regsub -all {   } $gsdevices { } gsdevices
 		regsub -all { } $gsdevices \n gsdevices
 		regsub -all \n\n $gsdevices \n gsdevices
 	} else {
 		set gsdevices "none available"
 		set gsstate "disabled"
-		set printmode "eps"
+		#set printmode "eps"
 		tk_messageBox -type ok -icon error -message [G_msg "Ghostscript not available"]
 	}
 }	
@@ -123,7 +125,7 @@
 	variable docht
 	variable orient
     
-    # set paper dimensions
+	# set paper dimensions
 	if { $paper == "preset" } {
 		switch $paper_preset {
 			"11x17" {
@@ -186,19 +188,19 @@
 	variable tmppsfile
 	variable tmppngfile
 
-    # get temporary file for postscript printing
-    set pid [ pid ]
+	# get temporary file for postscript printing
+	set pid [ pid ]
 	if {[catch {set tmppsfile [ exec g.tempfile pid=$pid ]} error]} {
 		Gm::errmsg $error [G_msg "Error creating tempfile"]
 	}
 
-    append tmppsfile ".ps"
-    set pid [ pid ]
+	append tmppsfile ".ps"
+	set pid [ pid ]
     
 	if {[catch {set tmppngfile [ exec g.tempfile pid=$pid ]} error]} {
 		Gm::errmsg $error [G_msg "Error creating tempfile"]
 	}
-    append tmppngfile ".png"
+	    append tmppngfile ".png"
 }
 
 # show gs printer devices in output window
@@ -235,135 +237,135 @@
 	variable gsstate
 	global mon
 	
-    set mon $cm
+	set mon $cm
+	    
+	# check if opened
+	if { [winfo exists .printwin] } {
+		wm deiconify .printwin
+		raise .printwin
+		return
+	}
 	
-    # check if opened
-    if { [winfo exists .printwin] } {
-        wm deiconify .printwin
-        raise .printwin
-        return
-    }
-    
-    set PW [toplevel .printwin]
-    wm title $PW [G_msg "Postscript and LPR printing of map display"]
-
-    # Left part paper + output
-    set PWid(left) [ frame $PW.left -padx 5 -pady 5]  
-    pack $PWid(left) -side left -anchor w
-
-    # paper size, scale
-    set PWid(paper) [ frame $PWid(left).paper]  
-    pack $PWid(paper) -side top -anchor w
-
-	# preset paper sizes (from ghostscript)
-    set row [ frame $PWid(paper).row1 ]
-    radiobutton $row.a -variable psprint::paper -value "preset" \
+	set PW [toplevel .printwin]
+	wm title $PW [G_msg "Postscript and LPR printing of map display"]
+	
+	# Left part paper + output
+	set PWid(left) [ frame $PW.left -padx 5 -pady 5]  
+	pack $PWid(left) -side left -anchor w
+	
+	# paper size, scale
+	set PWid(paper) [ frame $PWid(left).paper]  
+	pack $PWid(paper) -side top -anchor w
+	
+	    # preset paper sizes (from ghostscript)
+	set row [ frame $PWid(paper).row1 ]
+	radiobutton $row.a -variable psprint::paper -value "preset" \
 		-highlightthickness 0 
-    Label $row.b -anchor w -text [G_msg "Preset paper type"]
-    ComboBox $row.c -label "" -width 20  -textvariable psprint::paper_preset \
+	Label $row.b -anchor w -text [G_msg "Preset paper type"]
+	ComboBox $row.c -label "" -width 20  -textvariable psprint::paper_preset \
 		-values {"letter" "a4" "legal" "11x17" "a3" "ledger" "a0" "a1" "a2" } \
 		-modifycmd psprint::paper
-    pack $row.a $row.b $row.c -side left;
-    pack $row -side top -fill x -expand no -anchor n
-
+	pack $row.a $row.b $row.c -side left;
+	pack $row -side top -fill x -expand no -anchor n
+	
 	# custom paper sizes
-    set row [ frame $PWid(paper).row2 ]
-    radiobutton $row.a -variable psprint::paper -value "custom" \
+	set row [ frame $PWid(paper).row2 ]
+	radiobutton $row.a -variable psprint::paper -value "custom" \
 		-highlightthickness 0
-    Label $row.b -anchor w -text [G_msg "Custom paper size"]
-    Label $row.c -anchor w -text [G_msg "width:"]
-    Entry $row.d -width 10 -textvariable psprint::pgwd
-    Label $row.e -anchor w -text [G_msg "  height:"]
-    Entry $row.f -width 10 -textvariable psprint::pght 
-    pack $row.a $row.b $row.c $row.d $row.e $row.f -side left;
-    pack $row -side top -fill x -expand no -anchor n
-    
+	Label $row.b -anchor w -text [G_msg "Custom paper size"]
+	Label $row.c -anchor w -text [G_msg "width:"]
+	Entry $row.d -width 10 -textvariable psprint::pgwd
+	Label $row.e -anchor w -text [G_msg "  height:"]
+	Entry $row.f -width 10 -textvariable psprint::pght 
+	pack $row.a $row.b $row.c $row.d $row.e $row.f -side left;
+	pack $row -side top -fill x -expand no -anchor n
+	
 	#margins
-    set row [ frame $PWid(paper).row3]
-    Label $row.a -anchor w -text [G_msg "Margins  left:"]
-    Entry $row.b -width 10 -textvariable psprint::mleft 
-    Label $row.c -anchor w -text [G_msg " right:"] 
-    Entry $row.d -width 10 -textvariable psprint::mright 
-    Label $row.e -anchor w -text [G_msg " top:"]
-    Entry $row.f -width 10 -textvariable psprint::mtop 
-    Label $row.g -anchor w -text [G_msg " bottom:"]
-    Entry $row.h -width 10 -textvariable psprint::mbottom 
-
-    pack $row.a $row.b $row.c $row.d $row.e $row.f $row.g $row.h -side left;
+	set row [ frame $PWid(paper).row3]
+	Label $row.a -anchor w -text [G_msg "Margins  left:"]
+	Entry $row.b -width 10 -textvariable psprint::mleft 
+	Label $row.c -anchor w -text [G_msg " right:"] 
+	Entry $row.d -width 10 -textvariable psprint::mright 
+	Label $row.e -anchor w -text [G_msg " top:"]
+	Entry $row.f -width 10 -textvariable psprint::mtop 
+	Label $row.g -anchor w -text [G_msg " bottom:"]
+	Entry $row.h -width 10 -textvariable psprint::mbottom 
+	
+	pack $row.a $row.b $row.c $row.d $row.e $row.f $row.g $row.h -side left;
 	pack $row -side top -fill x -expand no -anchor n
-
-    # portrait or landscape
-    set row [ frame $PWid(paper).row4 ]
-	LabelEntry $row.a -label [G_msg "Resolution (dpi) for printing and PDF "] \
+	
+	# portrait or landscape
+	set row [ frame $PWid(paper).row4 ]
+		LabelEntry $row.a -label [G_msg "Resolution (dpi) for printing and PDF "] \
 		-textvariable psprint::res -width 4
-    Label $row.b -anchor w -text "  "
-    radiobutton $row.c -variable psprint::orient -value "landscape" \
+	Label $row.b -anchor w -text "  "
+	radiobutton $row.c -variable psprint::orient -value "landscape" \
 		-text "landscape mode" -highlightthickness 0
-    radiobutton $row.d -variable psprint::orient -value "portrait" \
+	radiobutton $row.d -variable psprint::orient -value "portrait" \
 		-text "portrait mode  " -highlightthickness 0
-    pack $row.a $row.b $row.c $row.d -side left;
-    pack $row -side top -fill x -expand no -anchor n
-
-    # output options
-    set PWid(output) [ frame $PWid(left).output ]  
-    pack $PWid(output) -side top -anchor w
-
-    # LPR printer
-    set row [ frame $PWid(output).lpr ]
-    radiobutton $row.a -variable psprint::printmode -value "lpr" \
-    	-highlightthickness 0
-    Label $row.b -anchor w -text [G_msg "Print on LPR printer"]
-    pack $row.a $row.b -side left;
-    pack $row -side top -fill x -expand no -anchor n
-
-    # Postscript printer
-    set row [ frame $PWid(output).psprinter ]
-    radiobutton $row.a -variable psprint::printmode -value "psprint" \
-    	-state $psprint::gsstate -highlightthickness 0
-    Label $row.b -anchor w -text [G_msg "Print on postscript device* "] \
-    	-state $psprint::gsstate
-    ComboBox $row.c -width 20 -textvariable psprint::printer  \
-    	-values $psprint::gsdevices -editable 0 -entrybg white
-    pack $row.a $row.b $row.c -side left;
-    pack $row -side top -fill x -expand no -anchor n
-
-    # PDF file
-    set row [ frame $PWid(output).pdffile]
-    radiobutton $row.a -variable psprint::printmode -value "pdf" \
-    	-state $psprint::gsstate -highlightthickness 0 
-    Label $row.b -anchor w -text [G_msg "Save to PDF file*              "]  \
-    	-state $psprint::gsstate 
-    Entry $row.c -width 30 -textvariable psprint::pdffile  -state $gsstate
-    Button $row.d -text [G_msg "Browse"]  -command { set psprint::pdffile \
+	pack $row.a $row.b $row.c $row.d -side left;
+	pack $row -side top -fill x -expand no -anchor n
+	
+	# output options
+	set PWid(output) [ frame $PWid(left).output ]  
+	pack $PWid(output) -side top -anchor w
+	
+	# LPR printer
+	set row [ frame $PWid(output).lpr ]
+	radiobutton $row.a -variable psprint::printmode -value "lpr" \
+		-highlightthickness 0
+	Label $row.b -anchor w -text [G_msg "Print on LPR printer"]
+	pack $row.a $row.b -side left;
+	pack $row -side top -fill x -expand no -anchor n
+	
+	# Postscript printer
+	set row [ frame $PWid(output).psprinter ]
+	radiobutton $row.a -variable psprint::printmode -value "psprint" \
+		-state $psprint::gsstate -highlightthickness 0
+	Label $row.b -anchor w -text [G_msg "Print on postscript device* "] \
+		-state $psprint::gsstate
+	ComboBox $row.c -width 20 -textvariable psprint::printer  \
+		-values $psprint::gsdevices -editable 0 -entrybg white
+	pack $row.a $row.b $row.c -side left;
+	pack $row -side top -fill x -expand no -anchor n
+	
+	# PDF file
+	set row [ frame $PWid(output).pdffile]
+	radiobutton $row.a -variable psprint::printmode -value "pdf" \
+		-state $psprint::gsstate -highlightthickness 0 
+	Label $row.b -anchor w -text [G_msg "Save to PDF file*              "]  \
+		-state $psprint::gsstate 
+	Entry $row.c -width 30 -textvariable psprint::pdffile  -state $gsstate
+	Button $row.d -text [G_msg "Browse"]  -command { set psprint::pdffile \
 		[tk_getSaveFile -title "Output PDF file" -defaultextension ".pdf"]} \
-    	-state $psprint::gsstate
-    pack $row.a $row.b $row.c $row.d -side left;
-    pack $row -side top -fill x -expand no -anchor n
-
-    # EPS file
-    set row [ frame $PWid(output).epsfile ]
-    radiobutton $row.a -variable psprint::printmode -value "eps" \
-     	-highlightthickness 0 
-    Label $row.b -anchor w -text [G_msg "Save to EPS file               "] 
-    Entry $row.c -width 30 -textvariable psprint::epsfile 
-    Button $row.d -text [G_msg "Browse"] -command { set psprint::epsfile \
-           [ tk_getSaveFile -title "Output EPS file" -defaultextension ".eps"] }
-    pack $row.a $row.b $row.c $row.d -side left;
-    pack $row -side top -fill x -expand no -anchor n
-
+		-state $psprint::gsstate
+	pack $row.a $row.b $row.c $row.d -side left;
+	pack $row -side top -fill x -expand no -anchor n
+	
+	# EPS file
+	set row [ frame $PWid(output).epsfile ]
+	radiobutton $row.a -variable psprint::printmode -value "eps" \
+		-highlightthickness 0 
+	Label $row.b -anchor w -text [G_msg "Save to EPS file               "] 
+	Entry $row.c -width 30 -textvariable psprint::epsfile 
+	Button $row.d -text [G_msg "Browse"] -command { set psprint::epsfile \
+	       [ tk_getSaveFile -title "Output EPS file" -defaultextension ".eps"] }
+	pack $row.a $row.b $row.c $row.d -side left;
+	pack $row -side top -fill x -expand no -anchor n
+	
 	set row [ frame $PWid(output).gsmessage ]
-    Label $row.a -anchor w -text [G_msg "*requires ghostscript to be installed and in path"]
-    pack $row.a -side bottom;
-    pack $row -side top -fill x -expand yes -anchor center
+	Label $row.a -anchor w -text [G_msg "*requires ghostscript to be installed and in path"]
+	pack $row.a -side bottom;
+	pack $row -side top -fill x -expand yes -anchor center
+	
+	# Buttons 
+	set but [ frame $PWid(left).buttons ]  
+	pack $but -side top
+	
+	Button $but.print -text [G_msg "Print"] -command "update; psprint::print $cv"
+	Button $but.close -text [G_msg "Close"] -command { destroy .printwin }
+	pack $but.print $but.close -side left 
 
-#    Buttons 
-    set but [ frame $PWid(left).buttons ]  
-    pack $but -side top
-
-    Button $but.print -text [G_msg "Print"] -command "update; psprint::print $cv"
-    Button $but.close -text [G_msg "Close"] -command { destroy .printwin }
-    pack $but.print $but.close -side left 
-
 }
 
 proc psprint::print { cv } {
@@ -391,14 +393,14 @@
 	global mon
 	global mingw
     
-    psprint::init_tmpfiles
+	psprint::init_tmpfiles
    	psprint::paper
    	update
-    set landscape $gmpath/landscap.ps
+	set landscape $gmpath/landscap.ps
     
-    #change doc size to points
-    set cdocwd [expr $docwd * 72]
-    set cdocht [expr $docht * 72]
+	#change doc size to points
+	set cdocwd [expr $docwd * 72]
+	set cdocht [expr $docht * 72]
     
  	# set paper size for postscript printer and pdf files
 	set w [expr round($pgwd * $res)]
@@ -431,10 +433,10 @@
  		if {[catch {exec lpr -o position=center $tmppsfile } error]} {
 			Gm::errmsg $error
 		}
-    }
+	}
 
 	# postsript printing via ghostsript
-    if { $printmode == "psprint" && $printer != "" } {
+	if { $printmode == "psprint" && $printer != "" } {
 		if {[catch {exec $cmd  $format -sDEVICE#$printer -r$res -sNOPAUSE -dBATCH -- $tmppsfile} error]} {
 			Gm::errmsg $error
 		}
@@ -463,22 +465,22 @@
 
 
 proc psprint::set_option { key value } {
-    variable PWid 
-    variable PVar 
-    variable PPap 
-    variable PView
+	variable PWid 
+	variable PVar 
+	variable PPap 
+	variable PView
+    
+	set PVar($key) $value
 
-    set PVar($key) $value
-
 }
 
 # Delete temporary files
 proc psprint::clean {  } {
-    variable tmppsfile
-    variable tmppngfile
+	variable tmppsfile
+	variable tmppngfile
+    
+	catch {file delete $tmppsfile}
+	catch {file delete $tmppngfile}
 
-    catch {file delete $tmppsfile}
-    catch {file delete $tmppngfile}
-
 }
 

Modified: grass/branches/releasebranch_6_3/gui/tcltk/gis.m/runandoutput.tcl
===================================================================
--- grass/branches/releasebranch_6_3/gui/tcltk/gis.m/runandoutput.tcl	2008-01-08 11:02:54 UTC (rev 29597)
+++ grass/branches/releasebranch_6_3/gui/tcltk/gis.m/runandoutput.tcl	2008-01-08 11:22:52 UTC (rev 29598)
@@ -113,19 +113,19 @@
 	set gronsole [Gronsole $where.gronsole -clickcmd "gronsole_history $cmdwin.text"]
 	set cmdtext [text $cmdwin.text -height 2 -width 80] 
 	$cmdwin setwidget $cmdtext
-	set runbutton [button $cmdpane.run -text [G_msg "Run"] -width 14 -default active -bd 1 \
+	set runbutton [button $cmdpane.run -text [G_msg "Run"] -width 14 -wraplength 90 -default active -bd 1 \
 		-command "run_disabled $gronsole $cmdpane.run \[string trim \[$cmdtext get 1.0 end\]\]"]
-	set run2button [button $cmdpane.run2 -text [G_msg "Run (background)"] -width 14 -bd 1 \
+	set run2button [button $cmdpane.run2 -text [G_msg "Run (background)"] -width 14 -wraplength 90 -bd 1 \
 		-command "$gronsole run \[string trim \[$cmdtext get 1.0 end\]\] {} {}"]
-	set runuibutton [button $cmdpane.runui -text [G_msg "Run (GUI)"] -width 14 -bd 1 \
+	set runuibutton [button $cmdpane.runui -text [G_msg "Run (GUI)"] -width 14 -wraplength 90 -bd 1 \
 		-command "run_ui \[string trim \[$cmdtext get 1.0 end\]\]"]
-	set runxterm [button $cmdpane.xterm -text [G_msg "Run (in Xterm)"] -width 14 -bd 1 \
+	set runxterm [button $cmdpane.xterm -text [G_msg "Run (in Xterm)"] -width 14 -wraplength 90 -bd 1 \
 		-command "$gronsole run_xterm \[string trim \[$cmdtext get 1.0 end\]\] {}"]
 	set outpane [frame $where.output -bg $bgcolor]
 	set savebutton [button $outpane.save -text [G_msg "Save"] -command "$gronsole save" \
-		-bd 1 -width 5]
+		-bd 1 -padx 10]
 	set clearbutton [button $outpane.clear -text [G_msg "Clear"] -command "$gronsole clear" \
-		-bd 1 -width 5]
+		-bd 1 -padx 10]
 
 	pack $runbutton $run2button $runuibutton $runxterm \
 		-side left -expand yes -padx 5 -pady 5



More information about the grass-commit mailing list