#!/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 perform any layer merging that
# is required.
# It is called by the "Check Merging" 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_in_progress genform1 mrg

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

# Put window on screen asking user to select merge option.
o_tooling
o FONT $NORM_FNT
o BG $NORM_COL
o BW 0
o LABEL Layer Merge Select
o RADIO merge Options: V 1 990000
o No merging required
o Merging required
o END

do_gui

if ($merge != 1) then
   # Merging is required. Open editor, action merges, then get user to re-run matrix set-up.
   COM open_entity,job=$JOB,type=step,name=pcb
   set group=$COMANS
   AUX set_group,group=$group

   # Pause script and ask user to complete data merging.
   PAUSE Press continue when merging is done

   # Close editor.
   COM editor_page_close

   # Put window on screen asking user to re-run matrix setup.
   o_tooling
   o FONT $NORM_FNT
   o BG $WARN_COL
   o BW 0
   o LABEL Layer Merge Complete
   o LABEL Ensure that matrix setup is run again.
   o BG $NORM_COL
   o END

   do_gui
endif

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

set_complete genform1 mrg

if ($merge != 1) then
   # Merging done. Reset form to show matrix needs to be set-up again.
   # Change color of action button to show action needs running again.

   set_complete genform1 mrg

   COM edit_form,job=$JOB,form=genform1,elem=mrg,color=$RERUN_COLOR

   # Change color of matrix button to show action needs running again.
   COM edit_form,job=$JOB,form=genform1,elem=smx,color=$RERUN_COLOR
endif

save_job

exit 0
