subr view_redraw, win
 ;use tvplane because it handles the offsets and zoom for us
 !tvplanezoom = $view_zoom_fac(win)
 ;need to check if we are coupled with other windows
 ;alignment of multiple movies is done differently and further below
 if $view_connect(win) then { slave_align, win 		return }
 sw = string(win)
 ;need to check if this is a movie window
 if win lt #play_window or win ge 20 then {
   if defined(eval('$viewrangewidget'+sw)) eq 1 then view_range_update, win
   tvplane, eval('$view_data'+sw), 0 , $view_ix(win), $view_iy(win), win
   return
 }
 ;some sort of movie, gets complicated
 j = $now+$j1
 ix = $view_ix(win)
 iy = $view_iy(win)
 ;and there are now 2 types of movies, the old single one and the multi's
 if win eq #play_window then {
   sw = '$data'+sw
   it = $play_index(j)
   ;don't do both the track and the drift
   zeroifnotdefined, $mv_track_flag, $movie_drift_flag
   ;8/18/2000 - modified to handle set of differently sized images, this means
   ;we always use $mv_track_dx and $mv_track_dy but they are loaded with
   ;different values depending on $mv_track_flag
   ix = ix + $mv_track_dx(it)
   iy = iy + $mv_track_dy(it)
   ;don't do both the track and the drift; i.e., the drift can be used only
   ;when solar tracking is off
   if $movie_drift_flag eq 1 and $mv_track_flag eq 0 then {
	  ix = ix + rfix(it * $movie_drift_x)
	  }
   tvplane, eval(sw), it, ix, iy, win
 } else {
   ;this is for the multi's, we have to find what we need in the set, assumes
   ;that the windows are contiguous
   ;slave alignment is done here for movies sets
   if $multi_link_flags(win - $play_window(1)) then {
     for i=0, $num_movies-1 do {
       if $multi_link_flags(i) then {
	  iq = i + 1 + $play_window(0)
	  if iq ne win then {
	    ;adjust this window (iq) to match win
	    $view_zoom_fac(iq) = !tvplanezoom
	    $view_xsize(iq) = $view_xsize(win)
	    $view_ysize(iq) = $view_ysize(win)
	    $view_ix(iq) = ix
	    $view_iy(iq) = iy
	    draw_x = $view_width(win)
	    $view_width(iq) = draw_x
	    draw_y = $view_height(win)
	    $view_height(iq) = draw_y
	    ;because the xmsize will generally call view_resize_cb, we must get
	    ;the centers done here
	    $view_ixc(iq) = $view_ixc(win)
	    $view_iyc(iq) = $view_iyc(win)
	    xmscrollbarsetvalues, $view_sch(iq), ix, $view_nx(iq), draw_x, .5*draw_x
	    xmscrollbarsetvalues, $view_scv(iq), iy, $view_ny(iq), draw_y, .5*draw_y
	    xmsize, $view_draw(iq), $view_xsize(iq), $view_ysize(iq)
	  }
	 sw = '$movie'+string(i+1)
	 it = $play_multi(j, i)
	 tvplane, eval(sw), it, ix + $multi_track_dx(j, i), iy + $multi_track_dy(j, i), iq
       }
     }
   } else {
     ;this covers case of an unlinked movie
     iq = win - $play_window(1)
     it = $play_multi(j, iq)
     sw = '$movie'+string(iq+1)
     ix = ix + $multi_track_dx(j, iq)
     iy = iy + $multi_track_dy(j, iq)
     tvplane, eval(sw), it, ix, iy, win
   }
 }
 endsubr
 ;==============================================================