#!/bin/csh
# This is a program for the example Genesis Tooling Forms.
# This file will exist in form 1.
# The purpose of this program is to prompt the user to create a rout path and outline for the
# circuit.
# It is called by the "Define Rout Outline" button.
# 
# Written by Ian Ticehurst (Autom8 Ltd.)
# Version 1A. Date: 11.09.00 - Initial design and development.
# Version 1B. Date: 11.12.00 - Add source of info. file to support gui creation.
# Version 1C. Date: 12.12.00 - Re-write the gui windows to use the sourced font and colours.
# Version 1D. Date: 05.02.01 - Modify to only check job path if job moved from original location.
#                            - Add save time update to forms.
# Version 1E. Date: 09.02.01 - Modify the setting and useage of $TMP.
# Version 1F. Date: 14.03.01 - Check how "$GENESIS_EDIR" is set to ensure paths are set correctly.
######################################################################### 

source $_genesis_root/sys/scripts/include_me
set TMP_DAT = $TMP/otl.$$

set_in_progress genform1 otl

# Close Form
COM close_form,job=$JOB,form=genform1

# Open editor on step "pcb".
COM open_entity,job=$JOB,type=step,name=pcb
set group=$COMANS
AUX set_group,group=$group

# Put window on screen asking user to define profile.
o_tooling
o FONT $NORM_FNT
o BG $NORM_COL
o BW 0
o LABEL Profile Definition Pop-up
o LABEL Graphic editor is open.
o LABEL Program will pause.
o LABEL Complete rout profile and outline definition.
o LABEL Close pause box when profile defined
o END

do_gui

# Set cct. x size as default ("0") to check that profile has been defined.
set CCTX = 0
while ($CCTX == 0)
   # Pause script and ask user to define profile.
   PAUSE Press continue when profile is defined

   # Collect board size and update forms.
   DO_INFO -t step -e $JOB/pcb
   set CCTX = `echo $gPROF_LIMITSxmin $gPROF_LIMITSxmax | awk -F' ' '{print ($2 - $1)}'`
   set CCTY = `echo $gPROF_LIMITSymin $gPROF_LIMITSymax | awk -F' ' '{print ($2 - $1)}'`
   echo "elem=cct_x,value=$CCTX" >  $TMP_DAT
   echo "elem=cct_y,value=$CCTY" >> $TMP_DAT
   COM edit_form_list,job=$JOB,form=genform1,in_file=$TMP_DAT
   COM edit_form_list,job=$JOB,form=genform2,in_file=$TMP_DAT
   \rm $TMP_DAT
end

# Close editor.
COM editor_page_close

# Open Form
COM show_form,job=$JOB,form=genform1

set_complete genform1 otl

save_job

exit 0
