(FILECREATED " 7-Feb-85 18:33:53" {PHYLUM}<BLUEBONNET>BBTR>BBTRINTERFACE.;22 15404  

      changes to:  (FNS BbTr.UpdateJobDescriptionPanel)

      previous date: "10-Jan-85 17:19:25" {PHYLUM}<BLUEBONNET>BBTR>BBTRINTERFACE.;21)


(* Copyright (c)  by NIL. All rights reserved.)

(PRETTYCOMPRINT BbTrInterfaceCOMS)

(RPAQQ BbTrInterfaceCOMS ((FNS * BbTrInterfacefns)))

(RPAQQ BbTrInterfacefns (BbTr.ChangeTask BbTr.DeleteButton BbTr.FillFrame BbTr.GetTrilliumItem 
					 BbTr.NewOrNextDigit BbTr.ProceedFromPanel 
					 BbTr.ResolveNewJobValue BbTr.Trillium.Initialize 
					 BbTr.UpdateJobDescriptionPanel BbTr.UpdateJobField Del.Item 
					 DISPLAY.MESSAGE Get.Item Restore.Item Save.Trillium.Items 
					 TestForChange))
(DEFINEQ

(BbTr.ChangeTask
  [LAMBDA NIL                                                (* JG "12-Oct-84 21:03")

          (* * Action performed when "Change Task" is selected in frame BbRun)


    (if HelpWindow
	then (CLOSEW HelpWindow)
	     (DELETEMENU (WINDOWPROP 'HelpWindow 'HelpMenu)
			 T))
    (FRAME.GOTO DescriptionPanel T)
    (DO.FRAME.CHANGE)
    (BbTr.UpdateJobDescriptionPanel CURRENT.FRAME CopyJob])

(BbTr.DeleteButton
  [LAMBDA (name frame)                                       (* JG "12-Oct-84 22:02")

          (* * Delete a button from a frame)


    (PROG ((DISPLAY.CHANGED.ITEM.ONLY T))
          (for item in (GET.FIELDQ frame ITEMS)
	     do (PUTPROP name 'Trillium.Item item)
		(Del.Item item frame)
		(UPDATE&DISPLAY.FRAME frame 'IGNORE (BOUNDING.BOX item))
	     when (AND (EQ (ITEM.TYPE item)
			   'GENERAL.BUTTON)
		       (STREQUAL (MKSTRING name)
				 (CAR (GET.FIELDQ item TEXT])

(BbTr.FillFrame
  [LAMBDA (frame)                                            (* JG "12-Oct-84 20:50")

          (* * Makes sure that a frame contains all the questions and answers)


    (PROG (newItems)
          [SETQ newItems (for cellname in CopyJobFields bind [fields.currently.in.frame
							       ←
							       (for item in (GET.FIELDQ frame ITEMS)
								  collect (GET.FIELDQ item BbName)
								  when (EQ (ITEM.TYPE item)
									   'Q.&.A]
			    collect (Restore.Item item frame) when (AND (SETQ item (Get.Item cellname)
									  )
									(NOT (FMEMB cellname 
									fields.currently.in.frame]
          (UPDATE&DISPLAY.FRAME frame newItems NIL T])

(BbTr.GetTrilliumItem
  [LAMBDA (BbName frame)                                     (* JG " 4-Oct-84 16:31")

          (* * Return the Trillium item with name BbName in frame)


    (for item in (GET.FIELDQ frame ITEMS) thereis (EQ (GET.FIELDQ item BbName)
						      BbName])

(BbTr.NewOrNextDigit
  [LAMBDA (cell digit)                                       (* JG "14-Sep-84 22:33")

          (* * If the number pad has not been touched in the last 30 seconds, consider the digit to be the new value;
	  otherwise compound it with the previous value)


    (CHANGE.CURRENT.VALUE cell (if (GREATERP (FQUOTIENT [ABS (IDIFFERENCE (CLOCK 0)
									  (GETPROP cell 'LastTime]
							1000.0)
					     30)
				   then digit
				 else (IPLUS (ITIMES (GET.CURRENT.VALUE cell)
						     10)
					     digit))
			  (PUTPROP cell 'LastTime (CLOCK 0])

(BbTr.ProceedFromPanel
  [LAMBDA NIL                                                (* JG " 7-Jan-85 13:34")

          (* * Function executed when the user presses the PROCEED button in the frame: DescriptionPanel)


    (PROG (plan planGenerator unvaluedFields)
          (SETQ unvaluedFields (for f in (fetch relevantFields of CopyJob) unless (JobFieldValue
										    f CopyJob)
				  collect f))

          (* * Intercept the unvalued fields before proceeding further)


          (if unvaluedFields
	      then (CHANGE.CELL MessageArea.Cell "Answer the flashing questions")
		   (for f in unvaluedFields
		      do (for i to 5 bind ((region ← (GET.FIELDQ (for item
								    in (GET.FIELDQ (
BbTr.GetTrilliumItem f CURRENT.FRAME)
										   SUBITEMS)
								    thereis (EQ (ITEM.TYPE item)
										'DOUBLE.ACTION.SENSOR)
								      )
								 PLACEMENT)))
			    do (FLASH.REGION region CURRENT.DSP)
			       (DISMISS 400)))
	    else [SETQ planGenerator (OR (fetch planGenerator of CopyJob)
					 (ResolveNewJobValue CopyJob 'NumberOfCopies
							     (fetch (CopyJob NumberOfCopies)
								of CopyJob]
		 (COND
		   [(AND planGenerator (fetch generator of planGenerator))
		     (\TraceIt BluebonnetTrace "Create Procedure for Job.")
		     (SETQ plan (APPLY* (fetch generator of planGenerator)
					CopyJob))
		     (COND
		       ((type? Plan plan)
			 (\TraceIt BluebonnetTrace "Perform the procedure.")
			 (replace (CopyJob plan) of CopyJob with plan)
			 (if Simulate8200
			     then (FRAME.GOTO BbRunSimulator T)
			   else (FRAME.GOTO BbRun T))
			 (DO.FRAME.CHANGE)
			 (DoPlan plan CopyJob)
			 (AND Simulate8200 (WINDOWP SimulationStatusWindow)
			      (CLOSEW SimulationStatusWindow))
                                                             (* HelpWindow is NIL if the Help System is not 
							     loaded...)
			 (COND
			   (HelpWindow (CLOSEW HelpWindow)))
			 (COND
			   (HelpWindow (DELETEMENU (WINDOWPROP HelpWindow 'HelpMenu)
						   T)
				       (DELETEMENU (CAR (WINDOWPROP Simulate8200Menu 'MENU))
						   T)))
			 (CARET T)
			 (CHANGE.CELL StatusWindow.Cell "")
			 (CHANGE.CELL UserInstructionWindow.Cell "")
			 (StartBluebonnet T]
		   (T (CHANGE.CELL MessageArea.Cell 
"Bluebonnet does not have a procedure for doing the job
you described. Please check the job description and try again."])

(BbTr.ResolveNewJobValue
  [LAMBDA (job field value)                                  (* JG "13-Sep-84 21:32")

          (* A new value has been assigned to a field of a copy job via the job description panel. Make values of all fields 
	  that were relevant before assignment of the new value be assertions, and remove any underived values of irrelevant 
	  fields. Check on enabled plan generators and attempt to derive values for the fields relevant to that check and for 
	  those fields that are parameters to any enabled generators. Assign those fields as relevant and any that supported 
	  the attempted derivations. If all the relevant fields have values, and no generator is enabled, then apply any 
	  applicable help units. Before returning, assign previous values or default values to unvalued fields that became 
	  relevant after the assignment of the new value. Return a list of the currently enabled generators.)


    (PROG (dList consistent? gens unprocessedFields (newValue? T)
		 relevantFields)
          (for f in CopyJobFields do (if (RelevantField? f job)
					 then (AddAssertion job f (JobFieldValue f job))
				       elseif (NOT (DerivedResult? f job))
					 then (if (JobFieldValue f job)
						  then (LISTPUT (fetch removedAssertions
								   of job)
								f
								(JobFieldValue f job)))
					      (RemoveValue f job)))
          (AddAssertion job field value)
          (SETQ gens (DeriveValuesForGenerators job))        (* (for gen in (CAR gens) do 
							     (\TraceIt BluebonnetTrace "Procedure " 
							     (fetch generator of gen) " enabled.")))
          (replace relevantFields of job with (CDR gens))    (* (CLEARW CommentWindow))
          [SETQ generator (replace planGenerator of job with (SelectPlanGenerator (CAR gens]

          (* (if generator then (ShowTimeEstimate generator job) (if (fetch advisor of generator) then 
	  (APPLY* (fetch advisor of generator) job)) elseif (for f in (CDR gens) always (JobFieldValue f job)) then 
	  (ApplyHelpUnits job)))


          (RETURN (fetch planGenerator of job])

(BbTr.Trillium.Initialize
  [LAMBDA NIL                                                (* JG "21-Dec-84 20:37")

          (* * Action form of the Trillium Frame DescriptionPanel)


    (SETQ Simulate8200Menu NIL)                              (* Used by old Bluebonnet)
    (Save.Trillium.Items CURRENT.FRAME)
    [for cellname in '(OriginalsBound.Cell TwoSidedOriginals.Cell TwoSidedCopies.Cell 
					   OriginalsStandardSize.Cell OriginalsOnStandardPaper.Cell 
					   CopyBrightness.Cell Collate.Cell 
					   CopiesOnStandardPaper.Cell Staple.Cell Reduction.Cell)
       do (SET.CURRENT.VALUE cellname (GETPROP (SUBATOM cellname 1 -6)
					       'defaultValue]
    (SET.CURRENT.VALUE 'MessageArea.Cell 
" Select, using the left mouse button, the answers
 corresponding to your job. The choices on a black
 background correspond to the current selection. When you
 are ready to make copies press the %"Proceed%" button.")
    (BbTr.UpdateJobDescriptionPanel CURRENT.FRAME CopyJob])

(BbTr.UpdateJobDescriptionPanel
  [LAMBDA (frame job)                                        (* JG " 7-Feb-85 18:30")

          (* * Delete all the fields currently in the frame that are not relevant and add those that should be there.)


    (DECLARE (GLOBALVARS DISPLAY.CHANGED.ITEM.ONLY))
    (PROG (oldItems newItems (oldvalue DISPLAY.CHANGED.ITEM.ONLY))
          [for f in CopyJobFields bind [fields.currently.in.frame ← (for item
								       in (GET.FIELDQ frame ITEMS)
								       collect (GET.FIELDQ item 
											   BbName)
								       when (EQ (ITEM.TYPE item)
										'Q.&.A]
	     do (if (RelevantField? f job)
		    then [if (NOT (FMEMB f fields.currently.in.frame))
			     then (if (Get.Item f)
				      then (SETQ newItems (CONS (Restore.Item (Get.Item f)
									      frame)
								newItems]
		  elseif (FMEMB f fields.currently.in.frame)
		    then (SETQ oldItems (CONS (Del.Item (Get.Item f)
							frame)
					      oldItems]
          (if (OR oldItems newItems)
	      then (UPDATE&DISPLAY.FRAME frame newItems NIL T)
		   (BUILD.6LISTS frame])

(BbTr.UpdateJobField
  [LAMBDA (job field value)                                  (* JG "13-Sep-84 21:44")

          (* * Ask Bb to make inferences and update the Trillium frame)


    (BbTr.ResolveNewJobValue job field value)
    (BbTr.UpdateJobDescriptionPanel (FIND.FRAME (FIND.INTERFACE 'BbTr)
						'DescriptionPanel)
				    job])

(Del.Item
  [LAMBDA (item frame)                                       (* JG " 4-Oct-84 12:05")

          (* * Delete an item from a Trillium frame)


    (DELETE.OLD.ITEM frame item)
    item])

(DISPLAY.MESSAGE
  [LAMBDA (ITEM)                                             (* JG "10-Jan-85 16:24")
                                                             (* DAHJr " 7-OCT-83 11:25")
    (DECLARE (GLOBALVARS ANALYZE.LOT.DSP CURRENT.DSP))
    (PROG ((CELL (GET.PARAMQ ITEM CELL PRINT.REGION))
	   (REGION (GET.PARAMQ ITEM PLACEMENT PRINT.REGION))
	   (SOURCE (GET.PARAMQ ITEM SOURCE PRINT.REGION))
	   (OPERATION (GET.PARAMQ ITEM OPERATION PRINT.REGION))
	   (TEXTURE (GET.PARAMQ ITEM TEXTURE PRINT.REGION))
	   (BACKGROUND (GET.PARAMQ ITEM BACKGROUND PRINT.REGION))
	   (FONT (GET.PARAMQ ITEM FONT PRINT.REGION))
	   (MARGIN (GET.PARAMQ ITEM MARGIN PRINT.REGION))
	   DSP OLD.CLIPPING.REGION CBOX LEFT BOTTOM WIDTH HEIGHT BOX LIST.OF.LINES XCOORD YCOORD 
	   TEXT.WIDTH FONT.HEIGHT FONT.DESCENT OLD.SOURCE OLD.OPERATION OLD.FONT TX TY CHAR.WIDTH)
          (SETQ DSP CURRENT.DSP)
          (SETQ OLD.CLIPPING.REGION (DSPCLIPPINGREGION NIL DSP))
          (SETQ CBOX (INTERSECTREGIONS REGION OLD.CLIPPING.REGION))
          (COND
	    (CBOX (DSPFILL CBOX BACKGROUND 'REPLACE DSP)
		  (SETQ LEFT (IPLUS MARGIN (fetch (REGION LEFT) of REGION)))
		  (SETQ BOTTOM (IPLUS MARGIN (fetch (REGION BOTTOM) of REGION)))
		  (SETQ WIDTH (IDIFFERENCE (fetch (REGION WIDTH) of REGION)
					   (LSH MARGIN 1)))
		  (SETQ HEIGHT (IDIFFERENCE (fetch (REGION HEIGHT) of REGION)
					    (LSH MARGIN 1)))
		  (SETQ BOX (create REGION
				    LEFT ← LEFT
				    BOTTOM ← BOTTOM
				    WIDTH ← WIDTH
				    HEIGHT ← HEIGHT))
		  (SETQ LIST.OF.LINES (MKLIST (GET.CURRENT.VALUE CELL)))
		  (OR FONT (SETQ FONT (DSPFONT NIL DSP)))
		  (DSPCLIPPINGREGION BOX DSP)
		  (SETQ OLD.FONT (DSPFONT FONT DSP))
		  (SETQ OLD.SOURCE (DSPSOURCETYPE SOURCE DSP))
		  (SETQ OLD.OPERATION (DSPOPERATION OPERATION DSP))
		  (MOVETOUPPERLEFT DSP BOX)
		  (SETQ CHAR.WIDTH (CHARWIDTH (CHARCODE a)
					      FONT))
		  (if (LISTP (CAR LIST.OF.LINES))
		      then (for msg in LIST.OF.LINES
			      do (PRINTPARA (IQUOTIENT (IPLUS LEFT CHAR.WIDTH)
						       CHAR.WIDTH)
					    (IQUOTIENT (IPLUS LEFT WIDTH)
						       CHAR.WIDTH)
					    msg NIL NIL DSP)
				 (TERPRI DSP)
				 (DSPXPOSITION (IPLUS LEFT CHAR.WIDTH)
					       DSP))
		    else (PRINTPARA (IQUOTIENT (IPLUS LEFT CHAR.WIDTH)
					       CHAR.WIDTH)
				    (IQUOTIENT (IPLUS LEFT WIDTH)
					       CHAR.WIDTH)
				    LIST.OF.LINES NIL NIL DSP))
		  (DSPCLIPPINGREGION OLD.CLIPPING.REGION DSP)
		  (DSPFONT OLD.FONT DSP)
		  (DSPSOURCETYPE OLD.SOURCE DSP)
		  (DSPOPERATION OLD.OPERATION DSP])

(Get.Item
  [LAMBDA (field)                                            (* JG "11-Sep-84 12:09")

          (* * comment)


    (GETPROP field 'Trillium.Item])

(Restore.Item
  [LAMBDA (item frame)                                       (* JG "15-Sep-84 16:54")

          (* * Put the item back into the Trillium frame)


    (ADD.NEW.ITEM frame item)
    item])

(Save.Trillium.Items
  [LAMBDA (frame)                                            (* JG "11-Sep-84 11:25")

          (* * Caches the Trillium items of type Question-and-Answer (Q.&.A) on the property list of Bluebonnet%'s CopyJob 
	  fields so that they can be added or deleted by Bluebonnet)



          (* * Assumes that all the fields that are going to be referred to are in the frame)


    (for item in (GET.FIELDQ frame ITEMS) do (PUTPROP (GET.FIELDQ item BbName)
						      'Trillium.Item item)
       when (EQ (ITEM.TYPE item)
		'Q.&.A])

(TestForChange
  [LAMBDA (fieldname cellvalue)                              (* JG "13-Sep-84 17:42")
    (if (NEQ cellvalue (JobFieldValue fieldname CopyJob))
	then (BbTr.UpdateJobField CopyJob fieldname cellvalue])
)
(DECLARE: DONTCOPY
  (FILEMAP (NIL (739 15382 (BbTr.ChangeTask 749 . 1201) (BbTr.DeleteButton 1203 . 1769) (BbTr.FillFrame 
1771 . 2535) (BbTr.GetTrilliumItem 2537 . 2842) (BbTr.NewOrNextDigit 2844 . 3483) (
BbTr.ProceedFromPanel 3485 . 6153) (BbTr.ResolveNewJobValue 6155 . 8435) (BbTr.Trillium.Initialize 
8437 . 9478) (BbTr.UpdateJobDescriptionPanel 9480 . 10729) (BbTr.UpdateJobField 10731 . 11096) (
Del.Item 11098 . 11309) (DISPLAY.MESSAGE 11311 . 14146) (Get.Item 14148 . 14322) (Restore.Item 14324
 . 14541) (Save.Trillium.Items 14543 . 15135) (TestForChange 15137 . 15380)))))
STOP