gamma.tk
changeset 3 2bdd3f8b7864
parent 2 9aa865195c24
child 4 f8ce867298a9
equal deleted inserted replaced
2:9aa865195c24 3:2bdd3f8b7864
     1 #!/bin/wish
     1 #!/usr/bin/wish
     2 
     2 
     3 set wheight 400
     3 set wheight 400
     4 set wwidth 800
     4 set wwidth 800
     5 set wwidthsingle [expr $wwidth / 3 ]
     5 set wwidthsingle [expr $wwidth / 3 ]
     6 set gradient 10
     6 set gradient 10
    56 menu .mb
    56 menu .mb
    57 . config -menu .mb
    57 . config -menu .mb
    58 set mFile [menu .mb.mFile]
    58 set mFile [menu .mb.mFile]
    59 .mb add cascade -label File -menu .mb.mFile
    59 .mb add cascade -label File -menu .mb.mFile
    60 
    60 
       
    61 $mFile add command -label New -command new_points
    61 $mFile add command -label Load -command load_file
    62 $mFile add command -label Load -command load_file
    62 $mFile add command -label Save -command save_file
    63 $mFile add command -label Save -command save_file
    63 $mFile add separator
    64 $mFile add separator
    64 $mFile add cascade -label Export -menu ${mFile}.mExport
    65 $mFile add cascade -label Export -menu ${mFile}.mExport
    65 $mFile add command -label Quit -command exit
    66 $mFile add command -label Quit -command exit
   223 	set file [tk_getSaveFile]
   224 	set file [tk_getSaveFile]
   224 	if { $file == "" } {
   225 	if { $file == "" } {
   225 		return
   226 		return
   226 	}
   227 	}
   227 	set fd [open $file w]
   228 	set fd [open $file w]
   228 	puts "# plot for gnuplot"
   229 	puts $fd "# plot for gnuplot"
   229 	puts "# plot 'data' index 0 title 'vermell', 'data' index 1 title 'verd', 'data' index 2 title 'blau'"
   230 	puts $fd "# plot 'data' index 0 title 'vermell', 'data' index 1 title 'verd', 'data' index 2 title 'blau'"
   230 
   231 
   231 	foreach t { rpoints gpoints bpoints } {
   232 	foreach t { rpoints gpoints bpoints } {
       
   233 		puts $fd "# $t"
   232 		foreach i [set $t] {
   234 		foreach i [set $t] {
   233 			puts -nonewline $fd [join $i " "]
   235 			puts -nonewline $fd [join $i " "]
   234 			puts $fd ""
   236 			puts $fd ""
   235 		}
   237 		}
   236 		if { $t != "bpoints"} {
   238 		if { $t != "bpoints"} {
       
   239 			puts $fd ""
   237 			puts $fd ""
   240 			puts $fd ""
   238 		}
   241 		}
   239 	}
   242 	}
   240 
   243 
   241 	close $fd
   244 	close $fd
   265 					r { set type g }
   268 					r { set type g }
   266 					g { set type b }
   269 					g { set type b }
   267 				}
   270 				}
   268 			}
   271 			}
   269 		} else {
   272 		} else {
   270 			if { [string index $line] != "#" } {
   273 			if { [string index $line 0] != "#" } {
   271 				lappend ${type}points [split $line " "]
   274 				lappend ${type}points [split $line " "]
   272 			}
   275 			}
   273 		}
   276 		}
   274 	}
   277 	}
   275 
   278 
   281 	puts "Read nrp: $nrp, ngp: $ngp, nbp: $nbp"
   284 	puts "Read nrp: $nrp, ngp: $ngp, nbp: $nbp"
   282 
   285 
   283 	prepare_colors_newpoint
   286 	prepare_colors_newpoint
   284 }
   287 }
   285 
   288 
       
   289 proc new_points { } {
       
   290         global rpoints gpoints bpoints
       
   291 
       
   292         set rpoints {{0 0.} {65535 1.}}
       
   293         set gpoints {{0 0.} {65535 1.}}
       
   294         set bpoints {{0 0.} {65535 1.}}
       
   295 
       
   296         prepare_colors_newpoint
       
   297 }
       
   298 
       
   299 
   286 # Prepare the colors for the user, for the first time!
   300 # Prepare the colors for the user, for the first time!
   287 prepare_colors_newpoint
   301 prepare_colors_newpoint