+
+select_contour_gui()
+{
+ local roi_list=$@
+ roi=`zenity --list --title="Available Contours" --column="Please choose a contour:" $roi_list`
+ case $? in
+ 0)
+ if [ -z $roi ]
+ then
+ zenity --warning --text="You must choose one contour."
+ select_contour $roi_list
+ else
+ rtstruct_roi_name=$roi
+ fi;;
+ 1)
+ if zenity --question --text="Do you really wish to quit?"
+ then
+ exit
+ else
+ select_contour $roi_list
+ fi;;
+ -1)
+ zenity --error --text="Unexpected error. Please relaunch the application."
+ exit;;
+ esac
+}
+
+select_contour()
+{
+ local roi_list=$@
+ echo "Available Contours:"
+ for r in $roi_list; do
+ echo $r
+ done
+
+ echo "Please choose a contour number:"
+ read rtstruct_roi_index
+ let i=0
+ for r in $roi_list; do
+ if [ $rtstruct_roi_index = `echo $r | cut -d ':' -f 1` ]; then
+ rtstruct_roi_index=$i
+ break;
+ fi
+ let i=i+1
+ done
+
+}
+
+select_roi()
+{
+ rtstruct_roi_name_list=( `clitkDicomInfo ${rtstruct_file} | grep "3006|0026" | cut -d '[' -f 4 | sed 's/| V 3006|0026[LO] [ROI Name] \|]//'` )
+ rtstruct_roi_number_list=( `clitkDicomInfo ${rtstruct_file} | grep "3006|0022" | cut -d '[' -f 4 | sed 's/| V 3006|0026[LO] [ROI Number] \|]//'` )
+ rtstruct_roi_list=( )
+ for i in $(seq 0 1 $(( ${#rtstruct_roi_name_list[@]} - 1 ))); do
+ rtstruct_roi_list[$i]=${rtstruct_roi_number_list[$i]}:${rtstruct_roi_name_list[$i]}
+ done
+
+ if [ $gui_mode = 1 ]; then
+ select_contour_gui ${rtstruct_roi_list[@]}
+ rtstruct_roi=`echo ${rtstruct_roi_name} | cut -d ':' -f 1`
+ rtstruct_roi_name=`echo ${rtstruct_roi_name} | cut -d ':' -f 2`
+ else
+ select_contour ${rtstruct_roi_list[@]}
+ rtstruct_roi=${rtstruct_roi_number_list[$(( $rtstruct_roi_index ))]}
+ rtstruct_roi_name=${rtstruct_roi_name_list[$(( $rtstruct_roi_index ))]}
+ fi
+}
\ No newline at end of file