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

# Procs that work directly on the main canvas (.c)
# See also plot.tk and bindings in bindings.tk

# Set the scrollregion for the map being loaded
# (called from images/*_js.tcl)
proc canvas_set_scrollregion {x1 y1 x2 y2} {
   .c configure -scrollregion "$x1 $y1 $x2 $y2"
}


# Load the map onto the canvas (called from images/*_js.tcl)
proc canvas_loadmap {img1 img2 {jsmap ""} {satimg ""}} {
   global loadsat

   catch { .c delete all }
   image_message "Mapping bitmap image #1 to canvas"
   .c create image 0 0 -image $img1 -anchor nw

   if {$loadsat} {
      image_message "Downloading/plotting GOES East imagery"
      set retval [getsatmap $jsmap $satimg]
      if {$retval == -1} {
         image_message "Failed to download GOES East imagery"
         after 2000 ;
      }
   }

   image_message "Mapping bitmap image #2 to canvas"
   .c create image 0 0 -image $img2 -anchor nw
   image_message ""
}


# delete items with tag(s) specified
proc canvas_delete_wtags {tag args} {
   .c delete $tag
   foreach tag $args {
      catch { .c delete $tag }
   }
}


# File menu:  "PostScript output" (moved over from menuprok.tk)
proc create_ps {} {
   set filename [tk_getSaveFile]
   if {$filename != ""} {
      puts "Writing PostScript data to $filename ... "
      .c postscript -x 0 -y 0 -colormode gray -file $filename
      puts "Done."
   }
}


proc addtags {item args} {
   foreach tag $args { .c addtag $tag withtag $item }
}



