#! @TCL@ -f
#
# file: dec_plot_2.tcl
#

# procedure to draw the best phone paths for the n-best hypotheses
#
proc draw_phones_proc {} {

    # declare globals
    #
    global p

    global phone_list

    global black_color
    global red_color

    global num_frames
    global num_n_best

    global x_off
    global y_off

    global row_space
    global col_space
    global dec_factor

    global font_0
    global font_1
    global font_2
    global font_3

    # set column separation
    #
    set col_sep [expr $dec_factor * $col_space]
    set row_sep [expr $row_space / 3]

    # remove everything if there is already some path
    #
    catch {$p.phones delete all}

    # loop over all the hypotheses
    #
    set i 0
    foreach ph_seq $phone_list {
	
	# set the start coordinates
	#
	set xx $y_off
	set yy [expr $i * $row_sep + 5]

	# set the color
	#
	if {$i == 0} {
	    set txtcol $red_color
	} else {
	    set txtcol $black_color
	}

	# increment index
	#
	incr i

	# set the path name
	#
	$p.phones create text $xx $yy -text "Path $i :: " -font $font_2 \
		-anchor w -fill $txtcol -tags path
	set xx [expr $xx + 60]

	# loop over all the phones
	#
	foreach phone $ph_seq {

	    # read the values
	    #
	    foreach {st en sc phstr} $phone {
		
		# print the phone and the frame
		#
		$p.phones create text $xx $yy  \
			-text "($st->$en): $phstr" \
			-font $font_1 -anchor w -fill $txtcol -tags path

		# offset the x coord
		#
		set xx [expr $xx + $col_sep]
	    }
	}
    }

    # reconfigure the scroll region
    #
    set size  [$p.phones bbox all]
    set x0 [expr [lindex $size 0] - $y_off]
    set y0 [expr [lindex $size 1] - 5]
    set x1 [expr [lindex $size 2] + $y_off]
    set y1 [expr [lindex $size 3] + 2]
    
    set size {}
    set size [linsert $size 0 $x0 $y0 $x1 $y1]
    
    $p.phones configure -scrollregion $size
}
    
# end of file
#
