
# JStrack:  copyright 1997/2012 by Jim Graham, N5IAL, all rights reserved.

set jstversion "JStrack version 3.3.3b (24June2012)"

# More configuring JStrack for easier transition to providing an
# executable for the Windows version....

# For Tcl/Tk 8.4 (if nothing else, for MacOS X)
set mt [split $tcl_version .]
set maj [lindex $mt 0] ; set min [lindex $mt 1]
if {$maj == 8 && $min >= 4} {
   tk::unsupported::ExposePrivateCommand *
} elseif {$maj > 8} {
   tk::unsupported::ExposePrivateCommand *
}

set winexe 0

# Windows-EXE-specific stuff
if {[string compare -nocase [file tail [info nameofexecutable]] "jstrack.exe"] == 0} {
   lappend auto_path jstrack.exe/lib
   set topdir $starkit::topdir
   regsub {/tracker.*$} $topdir {} t
   cd $t/tracker
   set winexe 1
}

lappend auto_path ../extlib

if {[catch { package require Tcl 8.4 } errmsg ]} {
   set info $errorInfo
   error $errmsg $info
}

package require textutil 0.7.1
package require fileutil 1.13
package require autoscroll

if {$winexe} {
   source ../paths.tcl.winexe
} else {
   source ../paths.tcl
}
source $libdir/miscb.tcl ;# one proc needed in defaults.tcl

set shell Tcl/Tk

# Start with default configuration variables....

set map large_js
source $libdir/defaults.tcl

# Now find out what the user really wants (if there are any overrides).

catch { source sysconfig.tcl }
catch { source options.tcl }

# Now setting DEFAULT map in config files
if {[info exists defmap]} { set map $defmap }

if {[file exists jstrackrc] && [string compare $jstrackrc jstrackrc]} {
   source jstrackrc
}
if {[file exists $jstrackrc]} { source $jstrackrc }


source $libdir/misc.tk
read_cmdline

# Create the frame for the menus

frame .mf -relief raised -borderwidth 2
pack .mf -side top -anchor w -fill x

# Source the scripts for  our input sources....

# First, the filter itself
#
source $rfcdir/filtlib.tcl

package require Tcl 8.2
package require textutil
source $httpfilt_path/httplib.tcl


# These must be done AFTER the frame above is created!
source $libdir/capture_window.tk
source $libdir/imagery.tk
source $libdir/menu.tk
source $libdir/menuproc.tk

# Create the canvas and scrollbars

pack [frame .can] -side top -fill both -expand yes
pack [scrollbar .hscroll -orient horiz -command ".c xview"] -in .can -side bottom -fill x
pack [scrollbar .yscroll -command ".c yview"] -in .can -side right -fill y

canvas .c -xscrollcommand ".hscroll set" -yscrollcommand ".yscroll set" -width $c_w -height $c_h
pack .c -in .can -expand yes -fill both
wm protocol . WM_DELETE_WINDOW { exit }
wm geometry . +0+0

# Nice idea ... but it would break scripts that do xwd (etc.) based on
# window name!
#
# wm title . "JStrack Version $version"

update

source $libdir/canvas.tk ;# load procs for accessing the canvas (.c)
source $libdir/loadsatmap.tk
source $imgdir/$map.tcl

update

set ptrstormid ""

pack [frame .jsver] -side top -expand y -fill x
set ftmp  {Helvetica 12 bold}
label .jsver.jsver -text "   $jstversion by Jim Graham" -font $ftmp
label .jsver.fill -text ""
label .jsver.webpage -text "http://www.jstrack.org/jstrack/      " -font $ftmp
pack .jsver.jsver -side left -anchor w -expand n
pack .jsver.fill -side left -anchor w -expand y
pack .jsver.webpage -side left -anchor w -expand n

if {$show_ptrloc == 0} { set ptrlocstr "(not active)" }
pack [frame .ptrloc] -side top -expand y -fill x
label .ptrloc.l1 -text "   Pointer location:  "
label .ptrloc.l2 -textvariable ptrlocstr
label .ptrloc.l3 -textvariable ptrstormid -font {Helvetica 12 bold}
pack .ptrloc.l1 .ptrloc.l2 .ptrloc.l3 -side left -anchor w -expand n

pack [frame .can2] -side top

set offset 0
if {[regexp {^8} $tcl_version]} { set offset 20 }

canvas .c2 -width $c_w -height 20
pack .c2 -in .can2

set x 10 ; set y 10
set x1 [expr {$x - 4}] ; set y1 [expr {$y - 4}]
set x2 [expr {$x + 4}] ; set y2 [expr {$y + 4}]
.c2 create polygon $x $y1 $x1 $y2 $x2 $y2 -width 1 -outline black \
   -fill $color(tddot)
.c2 create text [expr {$x + 6}] 10 -text "Tropical Depression" -anchor w

set x [expr {150 + $offset}] ; set y 10
set x1 [expr {$x - 4}] ; set y1 [expr {$y - 4}]
set x2 [expr {$x + 4}] ; set y2 [expr {$y + 4}]
.c2 create rectangle $x1 $y1 $x2 $y2 -width 1 -outline black -fill $color(tsdot)
.c2 create text [expr {$x + 6}] 10 -text "Tropical Storm" -anchor w

set x [expr {270 + $offset}] ; set y 10
set x1 [expr {$x - 4}] ; set y1 [expr {$y - 4}]
set x2 [expr {$x + 4}] ; set y2 [expr {$y + 4}]
.c2 create oval $x1 $y1 $x2 $y2 -width 1 -outline black -fill $color(hrdot)
.c2 create text [expr {$x + 6}] 10 -text "Hurricane" -anchor w

set x1 [expr {350 + $offset}]
.c2 create text $x1 10 -text "X  Extratrop. Storm    S  Subtrop. Storm    (LOW)  Remnant Low" -anchor w

set x1 [expr {$c_w - 450}]
set y 10

if {$x1 < 545} {
   .c2 configure -height 40
   set x1 10
   set y 30
}
# .c2 create text $x1 $y -anchor w -text $info_text -tag c2_info_text
update

# This must be used with caution...lots of events can cause <Configure>.
# If there were a <Window-Resize> type event, that would be the one to
# use.  Sadly, there does not appear to be one...so we improvise.

# There's just one problem...it doesn't work.  This appears to be what's
# causing the window to resize itself when a storm is loaded, etc....
#
# bind . <Configure> { handle_resize }

source $libdir/global.tcl
source $libdir/save_config.tcl ;# only called from Tk version
source $libdir/plot.tk
source $libdir/plotmenu.tk
source $libdir/bindings.tk
source $libdir/stlib.tcl
source $libdir/storm.tcl
source $libdir/misc.tcl
source $libdir/user.tcl
source $libdir/userdata.tcl
source $libdir/userdata.tk
source $libdir/menu.tcl
source $libdir/help.tcl
source $libdir/read_any.tcl
source $libdir/ss_global.tcl
source $libdir/saffsimp.tcl
source $libdir/saffsimp.tk
source $libdir/update.tcl
source $libdir/tkcon_wrap.tcl
# Load our procs for handling watch/warning breakpoints (YEAH!!!)
# source bplist.tcl
# source $libdir/read_vtec.tcl

set watchwarn() [list]

# Initialize auto_update mode
if {$auto_update} { test_st_files 1 }

# Plot the 'X' for home coordinates
plot_home_x

# New for beta 1.9---auto-load of storms from command line

if {[llength $loadlist] > 0} { eval mreload $loadlist }

# Load city names for the first drawing of the map...let folks know
# that they can be added (even if it is still a work in progress).

source $libdir/plotcity.tk
plot_user_cities







