📄 coverage.tcl
字号:
for {set i 1} {$i < 5} {incr i} { set DIV$i [random_color] set DEC$i [random_color] } coverage(update_colors)}proc coverage(restore_colors) {} { coverage(init_colors) coverage(update_colors)}proc coverage(run_of_colors) {} { global DIV1 DIV4 DEC1 DEC4 set DIV1 [random_color] set DIV4 [random_color] set DEC1 [random_color] set DEC4 [random_color] coverage(blend_colors)}proc coverage(blend_colors) {} { global DIV1 DIV2 DIV3 DIV4 DEC1 DEC2 DEC3 DEC4 set DIV1B [expr $DIV1 % 256] set DIV1G [expr ($DIV1 - $DIV1B)/256 % 256] set DIV1R [expr ($DIV1 - $DIV1B - $DIV1G * 256) / 65536] set DIV4B [expr $DIV4 % 256] set DIV4G [expr ($DIV4 - $DIV4B)/256 % 256] set DIV4R [expr ($DIV4 - $DIV4B - $DIV4G * 256) / 65536] set DEC1B [expr $DEC1 % 256] set DEC1G [expr ($DEC1 - $DEC1B)/256 % 256] set DEC1R [expr ($DEC1 - $DEC1B - $DEC1G * 256) / 65536] set DEC4B [expr $DEC4 % 256] set DEC4G [expr ($DEC4 - $DEC4B)/256 % 256] set DEC4R [expr ($DEC4 - $DEC4B - $DEC4G * 256) / 65536] set DIVRinc [expr ($DIV4R - $DIV1R) / 3 * 65536] set DIVGinc [expr ($DIV4G - $DIV1G) / 3 * 256] set DIVBinc [expr ($DIV4B - $DIV1B) / 3] set DECRinc [expr ($DEC4R - $DEC1R) / 3 * 65536] set DECGinc [expr ($DEC4G - $DEC1G) / 3 * 256] set DECBinc [expr ($DEC4B - $DEC1B) / 3] set DIV2 [expr $DIV1 + $DIVRinc + $DIVGinc + $DIVBinc] set DIV3 [expr $DIV2 + $DIVRinc + $DIVGinc + $DIVBinc] set DEC2 [expr $DEC1 + $DECRinc + $DECGinc + $DECBinc] set DEC3 [expr $DEC2 + $DECRinc + $DECGinc + $DECBinc] coverage(update_colors)}proc coverage(save_colors) {} { global Save DIV1 DIV2 DIV3 DIV4 DEC1 DEC2 DEC3 DEC4 set types { {"SaVi coverage color shades" {.shades} } } set filename [tk_getSaveFile -filetypes $types \ -title "SaVi: save coverage color shades" ] if {"$filename" == ""} return if {![string_ends "$filename" ".shades"]} { set filename "$filename.shades" } # open file set f [open "$filename" w] if {$f == ""} { puts stderr "SaVi: couldn't save coverage color shades to $filename" return } # write colors puts $f "\# SaVi saved coverage color shades" puts $f "\# http://savi.sourceforge.net/" for {set i 1} {$i < 5} {incr i} { set name DIV$i set name [expr $$name] puts $f "set DIV$i $name" set name DEC$i set name [expr $$name] puts $f "set DEC$i $name" } close $f puts stderr "SaVi: saved coverage color shades to $filename"}proc coverage(load_colors) {} { set types { {"SaVi coverage color shades" {.shades} } } set filename [tk_getOpenFile -filetypes $types \ -parent .main -title "SaVi: load coverage color shades" ] if {"$filename" == ""} return coverage(source_colors) "$filename" coverage(update_colors)}proc coverage(source_colors) {filename} { global DIV1 DIV2 DIV3 DIV4 DEC1 DEC2 DEC3 DEC4 source "$filename" }proc coverage(diversitycolor) {n} { global COLDIV DIV1 DIV2 DIV3 DIV4 if {$n == "1"} { set s "" } else { set s "s" } set color [tk_chooseColor -initialcolor $COLDIV($n) -parent .coverage \ -title "SaVi: diversity color for $n satellite$s visible"] if {($color != "") && ($color != $COLDIV($n))} { set COLDIV($n) $color .coverage.cmd.a.ce.cf.$n configure -bg $COLDIV($n) \ -activebackground $COLDIV($n) set value [string range $COLDIV($n) 1 6] set DIV$n [expr 0x$value] } satellites COLOR_UPDATE coverage(update)}proc coverage(decaycolor) {n} { global COLDEC DEC1 DEC2 DEC3 DEC4 if {$n == "1"} { set s "" } else { set s "s" } set color [tk_chooseColor -initialcolor $COLDEC($n) -parent .coverage \ -title "SaVi: decay color for $n interval$s since covered"] if {($color != "") && ($color != $COLDEC($n))} { set COLDEC($n) $color .coverage.cmd.a.ce.cg.$n configure -bg $COLDEC($n) \ -activebackground $COLDEC($n) set value [string range $COLDEC($n) 1 6] set DEC$n [expr 0x$value] } satellites COLOR_UPDATE coverage(update)}proc coverage(save_map) {} { global Save last_map_filename set types { {"SaVi coverage map (gzipped)" {.ppm.gz} } } set filename [tk_getSaveFile -filetypes $types \ -parent .coverage -title "SaVi: save coverage map" ] if {"$filename" == ""} return set last_map_filename "$filename" if {[string_ends "$filename" ".gz"]} { set filename [string range "$filename" 0 [expr $length - 4]] } if {![string_ends $filename ".ppm"]} { set filename "$filename.ppm" } satellites COVERAGE_SAVE_MAP "$filename" puts stderr "SaVi: saved map as raw ppm to $filename" exec gzip -9 "$filename" puts stderr "SaVi: gzip-compressed map to $filename.gz"}proc coverage(dismiss) {} { global coverage_flag tracks_flag \ coverage_flag_dismissed tracks_flag_dismissed set coverage_flag_dismissed $coverage_flag set tracks_flag_dismissed $tracks_flag # turn off flags to avoid computing drawing when window not shown set coverage_flag 0 set tracks_flag 0 destroy .coverage}proc coverage(update_decay) {} { global no_access_flag if {$no_access_flag == 0} return # Removing satellites leaves gaps in decay, so we reset this before # coverage flags are reset in coverage(update) set flag $no_access_flag set no_access_flag 1 if {$flag == 0} { set no_access_flag 0 }}proc coverage(update) {} { global coverage_flag tracks_flag if {![winfo exists .coverage]} return set flag $coverage_flag set coverage_flag 1 if {$flag == 0} { set coverage_flag 0 } set flag $tracks_flag set tracks_flag 1 if {$flag == 0} { set tracks_flag 0 } update}proc coverage(lat_long) {x y} { global Fisheye coverage_projection IM_W IM_H im_x_offset im_y_offset \ Longitude_Center_Line PI coverage_display_center_longitude set x [expr $x-$im_x_offset] set y [expr $y-$im_y_offset] set HALF_X [expr $IM_W/2] set HALF_Y [expr $IM_H/2] set off_map 0 if {$coverage_projection == 0} { # cylindrical set long [expr (($x%$IM_W)-$HALF_X)/double($IM_W)*360.0+$Longitude_Center_Line] set y [expr 1-$y/double($IM_H)*2] if {$y < -1} { set y -1 } elseif {$y > 1} { set y 1 } set lat [expr asin($y)/$PI*180.0] } elseif {$coverage_projection == 1} { # unprojected set long [expr (($x%$IM_W)-$HALF_X)/double($IM_W)*360.0+$Longitude_Center_Line] set y [expr 1-$y/double($IM_H)*2] if {$y < -1} { set y -1 } elseif {$y > 1} { set y 1 } set lat [expr $y*90] } elseif {$coverage_projection == 2} { # sinusoidal set lat [expr ($HALF_Y-$y)/double($HALF_Y)*90.0] if {abs($lat) == 90} { set long 0 } else { set long [expr \ (($x%$IM_W)-$HALF_X)/double($HALF_X)/cos($lat/180.0*$PI)*180 + $Longitude_Center_Line] } # below presumes that LCR is -90; it depends on the ppm map anyway. if {$long > ($Longitude_Center_Line+180)} { set long [expr $Longitude_Center_Line+180] set off_map 1 } elseif {$long < ($Longitude_Center_Line-180)} { set long [expr $Longitude_Center_Line+180] set off_map 1 } } elseif {$coverage_projection == 3} { # spherical set y [expr 1-$y/double($IM_H)*2] if {$y < -1} { set y -1 } elseif {$y > 1} { set y 1 } set lat [expr asin($y)/$PI*180.0] set long [expr 0] # longitude equation to be worked out. } if {$off_map == 0} { if {$long <= -180} { set long [expr $long+360] } elseif {$long > 180} { set long [expr $long-360] } } set Fisheye(lat_degrees) [expr {$lat<0 ? -int(-$lat) : int($lat)} ] set Fisheye(lat_minutes) [expr abs($lat-$Fisheye(lat_degrees))*60.0] set Fisheye(long_degrees) [expr {$long<0 ? -int(-$long) : int($long)} ] set Fisheye(long_minutes) [expr abs($long-$Fisheye(long_degrees))*60.0] if {![winfo exists .fisheye]} { puts stderr "SaVi: you selected (latitude,longitude) of ($Fisheye(lat_degrees),$Fisheye(long_degrees))" } # We could call fisheye(apply) here to set the coordinates directly, # but it's more useful to just know where you've clicked without also # changing the fisheye location.}proc coverage(foot) {} { coverage(update_decay) coverage(update)}proc coverage(title) {} { global coverage_name coverage_projection if {$coverage_projection == 0} { build_Title $coverage_name "view of coverage on cylindrical Earth map" } elseif {$coverage_projection == 1} { build_Title $coverage_name "view of coverage on unprojected (equirectangular) Earth map" } elseif {$coverage_projection == 2} { build_Title $coverage_name "view of coverage on sinusoidal Earth map (centred on 90W for Americas)" } elseif {$coverage_projection == 3} { build_Title $coverage_name "view of coverage on east/west hemispheres (equatorial orthographic maps), sans Earth outline" }}proc coverage(map) {} { global coverage_proj_flag coverage_projection last_coverage_projection \ geomview_module geomview_dynamic_texture_flag texture_flag \ earth_flag fancy_earth_flag if {$coverage_projection == $last_coverage_projection} return coverage(title) set coverage_proj_flag [expr 1 - $coverage_proj_flag] # this is a hack to reset Earth while dynamic texturemapping if changed # from cylindrical projection. if {$geomview_module && $geomview_dynamic_texture_flag && $texture_flag && \ $earth_flag && $fancy_earth_flag && ($last_coverage_projection == 0) && \ ($coverage_projection != 0)} { set texture_flag 0 set texture_flag 1 } set last_coverage_projection $coverage_projection coverage(update)}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -