#!/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 verify that the cleanup cycle
# is complete.
# It is called by the "Verify Cleanup" 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.
#                            - Text changes to remove abbreviations.
#                            - Add save time update to forms.
# Version 1E. Date: 09.02.01 - Modify step deletion to take account of default settings and user confirm.
#                            - 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 vcu

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

# Put window on screen asking user to review cleanup checklist.
o_tooling
o FONT $NORM_FNT
o BG $NORM_COL
o BW 0
o LABEL Verify Cleanup Pop-up
o LABEL Editor will be opened
o LABEL Program will pause.
o LABEL Review all data cleanup procedures.
o LABEL Close pause box when review complete.
o FONT $HINT_FNT
o BG $HINT_COL
o LABEL Hint - The following actions should be carried out now:
o LABEL 1. Review auto-cleanup checklist results
o LABEL 2. Ensure that pad construction is complete on all layers
o LABEL 3. Ensure .smd attribute has been set correctly
o LABEL 4. Perform any final cleanup required
o BG $NORM_COL
o END

do_gui

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

# Source info.source file and open cleanup checklist defined.
source $JOB_PATH/user/info.source
# Open analysis checklist.
COM chklist_open,chklist=$CL_CHK
COM chklist_show,chklist=$CL_CHK

# Pause script and ask user to complete cleanup verification.
PAUSE Press continue when verification is done

# Check to see if tmp. step was created.
DO_INFO -t job -e $JOB
set TMP_ST_TST = 0
foreach STP ($gSTEPS_LIST)
   if ($STP == "tmp_step") then
      set TMP_ST_TST = 1
   endif
end

# If tmp. step is found advise user to run graphic compare.
if ($TMP_ST_TST == 1) then
   o_tooling
   o FONT $NORM_FNT
   o BG $NORM_COL
   o BW 0
   o LABEL Graphic Check Pop-up
   o LABEL Copy step has been detected
   o LABEL You are advised to run a graphic compare between the two steps
   o LABEL This will help detect any errors made during cleanup
   o LABEL Program will pause.
   o LABEL Close pause box when checks complete.
   o FONT $HINT_FNT
   o BG $HINT_COL
   o LABEL Hint - Remember to use the graphic compare function.
   o LABEL Use the right hand mouse button on the layer list in the graphic editor
   o BG $NORM_COL
   o END

   do_gui

# Pause script and ask user to complete graphic checks.
   PAUSE Press continue when graphic checks are done

   if (! $?KEEP_ORG) then
      # Get user to confirm tmp step deletion.
      o_tooling
      o FONT $NORM_FNT
      o BG $WARN_COL
      o BW 0
      o LABEL Copy Step Deletion Pop-up.
      o LABEL Confirm that copy step can be deleted
      o RADIO DEL_CF Options: V 1 222299
      o Delete copy step
      o Keep copy step
      o END
      o BG $NORM_COL
      o END
	
      do_gui

      if ($DEL_CF == 1) then
         COM open_entity,job=$JOB,type=matrix
         COM delete_entity,job=$JOB,type=step,name=tmp_step
         COM matrix_refresh,job=$JOB,matrix=matrix
         COM matrix_page_close,job=$JOB,matrix=matrix
      else
         COM rename_entity,job=$JOB,type=step,name=tmp_step,new_name=pre_eng
      endif
   else
      COM rename_entity,job=$JOB,type=step,name=tmp_step,new_name=pre_eng
   endif
endif

# Close editor.
COM editor_page_close

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

set_complete genform1 vcu

save_job

exit 0
