
proc va_display_set_view {} {
    global movie va_win saved_views options
    global tdv_center tdv_rot tdv_scale tdv_pos tdv_current_viewer
    
    # close control if opened
	if ![info exists va_win(w_movie)] set_screen_init
    set_screen_done
	if ![info exists movie(frames)] {
		set movie(frames) 15
		for {set i 0} {$i < 15} {incr i} {set movie($i) ""}
	}
	for {set i 0} {$i < $movie(frames)} {incr i} {
		if {$movie($i) == ""} break
	}
	if {$movie($i) != ""} {
		incr movie(frames)
		set i $movie(frames)
	}
	set w $tdv_current_viewer
	foreach v {rot scale center pos} {
		set $v [set tdv_${v}($w)]
	}
	set movie($i) "$rot $scale $center $pos"
	ic_mess "Current view $i\n" 
#	if !$i {
#		ic_mess "In order to save view in file use \"Edit/Save View\" or Replay menu\n"
#	}
    # For "replay" record only:
	ic_current_view -rot $rot -scale $scale -center $center -pos $pos
    
    if !$options(auto_save_views) return
    for {set i} {$i < $movie(frames)} {incr i} {
        if {$movie($i) == ""} break
        lappend saved_views(views) "\{$i\} \{$movie($i)\}"
    }
}

proc va_display_get_view {} {
    global movie saved_views options
    
    if !$options(auto_save_views) return
    set n 0
    foreach v [array names saved_views views] {
        foreach cv $saved_views($v) {
            if {$cv == ""} break
            set i [lindex $cv 0]
            set m [lindex $cv 1]
            set movie($i) $m
            incr n
        }
    }
    if $n {
        mess "Loaded $n view frames from project file\n" blue
    }
}
 
