(FILECREATED "20-Feb-86 16:47:35" {QV}<NOTECARDS>1.3K>RHTPATCH026.;18 85199  

      changes to:  (VARS RHTPATCH026COMS)
		   (FNS NC.GraphLinkIconUpdateCheck NC.PutBrowserSubstance NC.GetBrowserSubstance 
			NC.ReadBrowserRootsInfo NC.ReadBrowserLinkLabels NC.ReadBrowserFormat 
			NC.ReadSpecialBrowserSpecs NC.ReadBrowserDepth NC.ReadBrowserSavedLinkingInfo 
			NC.ReadBrowserSavedLinkingInfoForNode NC.ReadBrowserLinksLegend 
			NC.WriteBrowserLinksLegend NC.RelayoutBrowserCard 
			NC.DelReferencesToCardFromBrowser NC.BringUpBrowserCard 
			NC.SetBrowserSavedLinkingInfo NC.PutGraphSubstance)

      previous date: "14-Feb-86 17:35:00" {QV}<NOTECARDS>1.3K>RHTPATCH026.;12)


(* Copyright (c) 1986 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT RHTPATCH026COMS)

(RPAQQ RHTPATCH026COMS ((* * Changes to the browser. These involve, among other things, writing new 
			     info down to notefile at PutSubstance time.)
			  (* * These are changed from NCGRAPHCARD)
			  (FNS NC.PutGraphSubstance NC.GetGraphSubstance NC.UpdateLinkImagesInGraph)
			  (* * These are changed fns from NCBROWSERCARD)
			  (FNS NC.PutBrowserSubstance NC.BringUpBrowserCard NC.AddBrowserCard 
			       NC.MakeBrowserCard NC.UpdateBrowserCard NC.RelayoutBrowserCard 
			       NC.ConnectNodesInBrowser NC.UnconnectNodesInBrowser 
			       NC.ExpandBrowserNode NC.ChangeBrowserSpecs NC.GraphLinkIconUpdateCheck)
			  (FNS NC.SetBrowserRoots NC.FetchBrowserRoots)
			  (FNS NC.BrowserAddLink NC.BrowserDeleteCard NC.BrowserRemoveNode)
			  (* * The function NC.QuitBrowserCard needs to be DELETED from NCBROWSERCARD)
			  (* * New functions for NCBROWSERCARD)
			  (FNS NC.DelReferencesToCardFromBrowser NC.NewBrowserNodeUIDFromOldUID 
			       NC.GetBrowserSubstance NC.ComputeBrowserSavedLinkingInfo 
			       NC.ComputeBrowserSavedLinkingInfoForNode)
			  (FNS NC.FetchBrowserRootsInfo NC.FetchBrowserLinkLabels 
			       NC.FetchBrowserFormat NC.FetchSpecialBrowserSpecs NC.FetchBrowserDepth 
			       NC.FetchBrowserSavedLinkingInfo NC.FetchBrowserLinksLegend)
			  (FNS NC.SetBrowserRootsInfo NC.SetBrowserLinkLabels NC.SetBrowserFormat 
			       NC.SetSpecialBrowserSpecs NC.SetBrowserDepth 
			       NC.SetBrowserSavedLinkingInfo NC.SetBrowserLinksLegend)
			  (FNS NC.ReadBrowserRootsInfo NC.ReadBrowserLinkLabels NC.ReadBrowserFormat 
			       NC.ReadSpecialBrowserSpecs NC.ReadBrowserDepth 
			       NC.ReadBrowserSavedLinkingInfo NC.ReadBrowserSavedLinkingInfoForNode 
			       NC.ReadBrowserLinksLegend)
			  (FNS NC.WriteBrowserRootsInfo NC.WriteBrowserLinkLabels 
			       NC.WriteBrowserFormat NC.WriteSpecialBrowserSpecs NC.WriteBrowserDepth 
			       NC.WriteBrowserSavedLinkingInfo NC.WriteBrowserSavedLinkingInfoForNode 
			       NC.WriteBrowserLinksLegend)))
(* * Changes to the browser. These involve, among other things, writing new info down to 
notefile at PutSubstance time.)

(* * These are changed from NCGRAPHCARD)

(DEFINEQ

(NC.PutGraphSubstance
  (LAMBDA (Card Stream)                                      (* rht: "14-Feb-86 18:09")
                                                             (* Put Graph in card ID onto DatabaseStream)

          (* * fgh 11/14/85 Updated to handle Card object.)



          (* * fgh 11/20/85 NoteCards now takes care of setting the start and end pointers for the substance.)



          (* * rht 1/23/86: Now takes Stream as arg instead of computing from Card.)



          (* * fgh 2/6/86 Now returns a version number)



          (* * rht 2/7/86: Now uses DUMPGRAPH rather than HPRINT)


    (LET ((Graph (NC.FetchSubstance Card)))                (* Clean up BITMAPS in Graph data structure)
         (for GraphNode in (fetch GRAPHNODES of Graph) do (replace (GRAPHNODE 
										  NODELABELBITMAP)
								       of GraphNode with NIL))
                                                             (* Write data stucture)
         (DUMPGRAPH Graph Stream)
     0)))

(NC.GetGraphSubstance
  (LAMBDA (Card Length Stream)                               (* rht: " 7-Feb-86 16:48")

          (* * Read the Graph)



          (* * fgh 11/14/85 Updated to handle Card object.)



          (* * fgh 11/20/85 NoteCards now passes start and end ptrs down.)



          (* * fgh 11/21/85 Now passes length instead of start and end ptrs.)



          (* * rht 1/23/86: Now takes Stream as arg instead of computing from Card.)



          (* * rht 2/7/86: Now uses READGRAPH instead of HREAD)


    (READGRAPH Stream)))

(NC.UpdateLinkImagesInGraph
  (LAMBDA (SourceCard DestinationCard)                       (* rht: "20-Feb-86 16:44")
                                                             (* Update all the NoteCard links that point to 
							     DestinationID from the graph card specified by 
							     SourceCardID)

          (* * rht 2/15/85: Added hack to redraw links into and out of the affected node. This is in case it has changed 
	  size. Note the calls to internal grapher functions!)



          (* * rht 10/3/85: Threw away above mentioned code. It was screwing up the link-params info for the affected nodes.)



          (* * fgh 11/17/85 Updated to handle card object.)


    (LET (Window Graph GraphNodes LinkIcon OldAddLinkFn OldDeleteLinkFn)
         (SETQ Window (NC.FetchWindow SourceCard))
         (SETQ Graph (NC.FetchSubstance SourceCard))
         (for GraphNode in (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of Graph))
	    when (AND (NC.LinkIconImageObjP (SETQ LinkIcon (fetch (GRAPHNODE NODELABEL)
								      of GraphNode)))
			  (NC.SameCardP DestinationCard (fetch (Link DestinationCard)
							     of (NC.FetchLinkFromLinkIcon 
											 LinkIcon))))
	    do                                             (* Update the size of the graph node if doesn't agree 
							     with image box.)
		 (NC.GraphNodeLinkIconUpdate Window GraphNode))
         (REDISPLAYW Window))))
)
(* * These are changed fns from NCBROWSERCARD)

(DEFINEQ

(NC.PutBrowserSubstance
  (LAMBDA (Card Stream)                                      (* rht: "20-Feb-86 14:32")

          (* * For each BrowserUID, clear its UID prop list. Otherwise HPRINT will die in PutGraphSubstance.)



          (* * rht 1/23/86: Now takes Stream as arg)



          (* * rht 2/1/86: Now saves old UID information on card's proplist for restoring when card is brought up again.
	  Note that this info will only exist for nodes connected to some other node with multiple links.)



          (* * fgh 2/5/86 Added call to NC.ApplySupersFn)



          (* * rht 2/6/86: Now writes down all browser info to substance rather than letting it live on prop list.)



          (* * rht 2/20/86: Now checks to see if saved linking info is cached before recomputing it.)


    (NC.WriteBrowserRootsInfo Stream (NC.FetchBrowserRootsInfo Card))
    (NC.WriteBrowserLinkLabels Stream (NC.FetchBrowserLinkLabels Card))
    (NC.WriteBrowserFormat Stream (NC.FetchBrowserFormat Card))
    (NC.WriteSpecialBrowserSpecs Stream (NC.FetchSpecialBrowserSpecs Card))
    (NC.WriteBrowserDepth Stream (NC.FetchBrowserDepth Card))
    (NC.WriteBrowserLinksLegend Stream (NC.FetchBrowserLinksLegend Card))
    (NC.WriteBrowserSavedLinkingInfo Stream (OR (NC.FetchBrowserSavedLinkingInfo Card)
						    (NC.SetBrowserSavedLinkingInfo Card
										     (
								NC.ComputeBrowserSavedLinkingInfo
										       Card))))
    (NC.ApplySupersFn PutFn Card Stream)))

(NC.BringUpBrowserCard
  (LAMBDA (Card Substance Region/Position)                   (* rht: "20-Feb-86 11:53")

          (* * Given a browser Substance, open a browser window and set it up to be a NoteCard with ID.)



          (* * rht 11/17/84: Now returns window.)



          (* * rht 9/11/85: Now checks for changed link icon display global params.)



          (* * rht 11/17/85: Now handles new card and Notefile objects.)



          (* * rht 2/1/86: Now restores any saved UID user data info stashed on card's prop list.)



          (* * fgh 2/5/86 Added call to NC.ApplySupersFn)



          (* * rht 2/14/86: Now rebuilds browser hash array.)


    (LET ((GraphNodes (fetch (GRAPH GRAPHNODES) of Substance))
	  Window OldUIDToNewUIDHashArray BrowserSavedLinkingInfo)

          (* * Restore any saved UID user data info stashed on card UID's prop list.)


         (if (SETQ BrowserSavedLinkingInfo (NC.FetchBrowserSavedLinkingInfo Card))
	     then (SETQ OldUIDToNewUIDHashArray (HASHARRAY 100 NIL (FUNCTION NC.MakeHashKey)
								 (FUNCTION NC.SameUIDP)))
		    (for BrowserSavedLinkingInfoForNode in BrowserSavedLinkingInfo
		       eachtime (BLOCK) do (for SavedLinkingInfo on (CDR 
								   BrowserSavedLinkingInfoForNode)
						    by (CDDR SavedLinkingInfo)
						    bind (SourceUID ←(
								   NC.NewBrowserNodeUIDFromOldUID
									(CAR 
								   BrowserSavedLinkingInfoForNode)
									GraphNodes 
									OldUIDToNewUIDHashArray))
						    eachtime (BLOCK)
						    do (NC.UIDPutProp SourceUID
									  (
								   NC.NewBrowserNodeUIDFromOldUID
									    (CAR SavedLinkingInfo)
									    GraphNodes 
									  OldUIDToNewUIDHashArray)
									  (CADR SavedLinkingInfo))))
	       )
         (NC.SetBrowserSavedLinkingInfo Card NIL)

          (* * For each graph node corresponding to a notecard, hang the card object off the node id's prop list.)


         (SETQ HashArray (NC.HashArrayFromBrowserCard Card))
         (for GraphNode in GraphNodes bind LinkIcon DestCard eachtime (BLOCK)
	    when (NC.LinkIconImageObjP (SETQ LinkIcon (fetch (GRAPHNODE NODELABEL)
							       of GraphNode)))
	    do (NC.UIDPutProp (NC.CoerceToGraphNodeID GraphNode)
				  (QUOTE CardObject)
				  (SETQ DestCard (fetch (Link DestinationCard)
						      of (NC.FetchLinkFromLinkIcon LinkIcon)))))

          (* * Make a new browser hash array with the new graph node UIDs.)


         (NC.SetUserDataProp Card (QUOTE BrowserHashArray)
			       NIL)
         (NC.GetBrowserHashArray Card Substance)

          (* * For each graph node, fix the NODEID and DESTNODEID fields of each of its TONODES LinkParameters.)


         (for GraphNode in GraphNodes eachtime (BLOCK)
	    do (for ToNode in (fetch (GRAPHNODE TONODES) of GraphNode)
		    bind (ThisNodeID ←(NC.CoerceToGraphNodeID GraphNode)) eachtime (BLOCK)
		    when (EQ (CAR ToNode)
				 LINKPARAMS)
		    do (LISTPUT ToNode (QUOTE NODEID)
				    ThisNodeID)
			 (LISTPUT ToNode (QUOTE DESTNODEID)
				    (NC.CoerceToGraphNodeID (CADR ToNode)))))

          (* * Bring up card and mess with its window.)


         (SETQ Window (NC.ApplySupersFn EditFn Card Substance Region/Position))
         (NC.SetupTitleBarMenu Window Card (QUOTE Browser))
         (NC.MakeLinksLegendMenu Window (NC.FetchBrowserLinksLegend Card))
                                                             (* Disable the old-style right button grapher editor 
							     menu.)
         (WINDOWPROP Window (QUOTE RIGHTBUTTONFN)
		       (FUNCTION NC.BrowserRightButtonFn))
         (WINDOWADDPROP Window (QUOTE SHRINKFN)
			  (FUNCTION NC.GraphCardShrinkFn))
         (WINDOWADDPROP Window (QUOTE REPAINTFN)
			  (FUNCTION NC.BrowserRepaintFn)
			  T)

          (* * I have to hang notecard's Card on window now in case REDISPLAYW runs and tries to get Card from window.)


         (WINDOWPROP Window (QUOTE NoteCardObject)
		       Card)                                 (* Check if link icon display global params have 
							     changed since last time card was up.
							     If so, fix graph nodes and redisplay.)
         (if (NC.GraphLinkIconUpdateCheck Card Window Substance T)
	     then (REDISPLAYW Window))
     Window)))

(NC.AddBrowserCard
  (LAMBDA NIL                                                (* rht: " 6-Feb-86 22:21")

          (* * fgh 11/14/85 Updated to handle merge of card and substance types.)


    (NC.AddCardType (QUOTE Browser)
		      (QUOTE Graph)
		      (BQUOTE ((MakeFn , (FUNCTION NC.MakeBrowserCard))
				 (EditFn , (FUNCTION NC.BringUpBrowserCard))
				 (PutFn , (FUNCTION NC.PutBrowserSubstance))
				 (GetFn , (FUNCTION NC.GetBrowserSubstance))
				 (DeleteLinksFn , (FUNCTION NC.DelReferencesToCardFromBrowser))))
		      (BQUOTE ((LinkDisplayMode Title)
				 (DefaultHeight 350)
				 (DefaultWidth 500)
				 (DisplayedInMenuFlg , T))))))

(NC.MakeBrowserCard
  (LAMBDA (Card Title NoDisplayFlg ParamList)                (* rht: " 7-Feb-86 12:19")

          (* Make a browser card with id Card using root at RootID and the link following predictae specified by Predicate.
	  IF Root and/or ListOfLinkLabels not specified, ask the user.)



          (* * rht 8/3/84: Changed to call NC.AskLinkLabel with its ReverseLinkLabel parameter set to T.)



          (* * fgh 10/2/84 Changed Link Icons to be image objects in NodeLabel of Graph Npodes rather than annotations on 
	  graph nodes.)



          (* * rht 10/19/84: Fixed setting up of browser card's prop list in case NoDisplayFlg is T so we have no Window.
	  Now NC.MakeLinksLegend returns the label pairs.)



          (* * rht 11/27/84: Removed the WINDOWADDPROP call to put NC.GraphCardCloseFn on the CLOSEFN of the window.
	  This causes trouble. NC.QuitCard will get put on by NC.MakeNoteCard and that's enough.)



          (* * rht 1/3/85: Now puts a dummy region of the right size if the NoDisplayFlg is on.)



          (* * rht 1/15/85: Put hooks for AddNode, AddLink, etc. so editing graph edits underlying structure.)



          (* * rht 2/14/85: Added VerticalFlg and made BrowserSpecs get put on browser's proplist in all cases.)



          (* * rht 4/1/85: Now calls NC.AskBrowserSpecs with additional Don'tAskFlg in case of call from Programmer's 
	  interface.)



          (* * rht 11/17/85: Updated to handle new card and notefile objects.)



          (* * rht 2/7/86: Now gets browser format, etc. via fetch/set fns.)


    (PROG ((RootCards (MKLIST (LISTGET ParamList (QUOTE ROOTCARDS))))
	     (ListOfLinkLabels (LISTGET ParamList (QUOTE LINKTYPES)))
	     (BrowserFormat (LISTGET ParamList (QUOTE FORMAT)))
	     (Depth (LISTGET ParamList (QUOTE DEPTH)))
	     Lattice RootNodes Window Graph SpecialBrowserSpecs BrowserSpecs DropVirtualNodesFlg)
	    (NC.ActivateCard Card)
	    (COND
	      ((NULL NoDisplayFlg)
		(SETQ Window (CREATEW (NC.DetermineDisplayRegion Card NIL)
					  (NC.RetrieveTitle Card)
					  NIL))
		(WINDOWADDPROP Window (QUOTE SHRINKFN)
				 (FUNCTION NC.GraphCardShrinkFn))
		(WINDOWPROP Window (QUOTE NoteCardObject)
			      Card)))
	    (if (NULL RootCards)
		then (SETQ RootCards (if NoDisplayFlg
					     then (LIST NIL)
					   else (NC.SelectNoteCards NIL NIL 
								    NC.SelectingBrowserSourceMenu 
									Window NIL 
			    "Please select the Cards and/or Boxes the browser should start from."
									T))))
	    (COND
	      ((EQ RootCards (QUOTE CANCELLED))
		(NC.DeactivateCard Card)
		(CLOSEW Window)
		(RETURN)))
	    (NC.HoldTTYProcess)
	    (SETQ BrowserSpecs (NC.AskBrowserSpecs Window Card NIL Depth BrowserFormat T
						       (if (OR ParamList NoDisplayFlg)
							   then (QUOTE DONTASK))))
	    (COND
	      ((NULL BrowserSpecs)
		(NC.DeactivateCard Card)
		(CLOSEW Window)
		(RETURN)))
	    (SETQ ListOfLinkLabels (CAR BrowserSpecs))
	    (SETQ Depth (CADR BrowserSpecs))
	    (SETQ BrowserFormat (CADDR BrowserSpecs))    (* If user wants *GRAPH* format, i.e. virtual nodes 
							     eliminated, then set the flag)
	    (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
		then (SETQ DropVirtualNodesFlg T))
	    (SETQ SpecialBrowserSpecs (COND
		(NC.SpecialBrowserSpecsFlg (NC.AskSpecialBrowserSpecs Window))
		(T (create SPECIALBROWSERSPECS))))
	    (OR NoDisplayFlg (NC.PrintMsg Window T (CHARACTER 13)
					      "Computing browser graph. Please wait. ..."))
                                                             (* Create new browser hash array)
	    (NC.GetBrowserHashArray Card)                  (* Compute lattice breakdth-first starting from 
							     roots.)
	    (SETQ Lattice (NC.GrowLinkLattice RootCards NIL ListOfLinkLabels Card Depth))
	    (SETQ RootNodes (for RootCard in RootCards collect (NC.GetBrowserNodeID Card 
											 RootCard)))
	    (OR NoDisplayFlg (WINDOWPROP Window (QUOTE NoteCardObject)
					     Card))

          (* * Link destination id information stored in NodeLabel field into a LinkIcon for display)


	    (for Node in Lattice bind NodeID eachtime (BLOCK)
	       do (replace (GRAPHNODE NODELABEL) of Node
		       with (NC.MakeLinkIcon (NC.MakeLink Window NC.BrowserContentsLinkLabel
								(fetch (GRAPHNODE NODELABEL)
								   of Node)
								Card NIL)))
                                                             (* Untouch each graph node so that next Recompute will
							     put fresh values on proplist.)
		    (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node))
		    (NC.UIDRemProp (NC.CoerceToGraphNodeID NodeID)
				     (QUOTE TouchedFlg))
		    (NC.UIDRemProp (NC.CoerceToGraphNodeID NodeID)
				     (QUOTE VisitedFlg)))
	    (SETQ Graph (if (AND Lattice RootNodes)
			      then (LAYOUTGRAPH Lattice RootNodes (SUBST (QUOTE LATTICE)
									       
									  NC.*Graph*BrowserFormat 
									       BrowserFormat)
						    (fetch (SPECIALBROWSERSPECS Font) of 
									      SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS MotherD)
						       of SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS PersonalD)
						       of SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS FamilyD)
						       of SpecialBrowserSpecs))
			    else (create GRAPH)))
	    (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window DropVirtualNodesFlg))
	    (OR NoDisplayFlg (NC.PrintMsg Window NIL "Done!"))
	    (NC.SetSubstance Card Graph)
	    (NC.SetBrowserLinkLabels Card (OR ListOfLinkLabels (LIST NC.SubBoxLinkLabel)))
	    (NC.SetBrowserRoots Card RootCards)
	    (NC.SetBrowserFormat Card BrowserFormat)
	    (NC.SetBrowserDepth Card Depth)
	    (NC.SetSpecialBrowserSpecs Card SpecialBrowserSpecs)
	    (COND
	      (NoDisplayFlg (RETURN Card)))
	    (WINDOWPROP Window (QUOTE GRAPH)
			  Graph)
	    (NC.SetupTitleBarMenu Window Card (QUOTE Browser))
	    (NC.RelayoutBrowserCard Window)
	    (RETURN Window))))

(NC.UpdateBrowserCard
  (LAMBDA (Window)                                           (* rht: "14-Feb-86 15:08")

          (* * rht 10/14/84: Added call to DETACHALLWINDOWS to close any existing links legend window and prompt window.
	  Also added call to NC.MakeLinksLegend to make a new attached legend menu.)



          (* * rht 1/15/85: Put hooks for AddNode, AddLink, etc. so editing graph edits underlying structure.)



          (* * rht 2/14/85: Added ability to respecify roots and link labels before recomputing graph.)



          (* * rht 3/8/85: Modified to use new browser props stored on card's proplist as of release 1.2.)



          (* * rht 3/17/85: Now takes OnlyLayoutFlg argument. If set, then don't recompute lattice or ask about root nodes.)



          (* * rht 11/17/85: updated to handle new card and notefile objects.)



          (* * kirk 23Jan86 Changed to use NC.AskYesOrNo)



          (* * rht 2/7/86: Now gets and sets browser format, etc. via fetch/set fns.)


    (PROG (Card LinkLabels RootCards RootNodes Lattice LinkIcon Graph GraphNodes NodeLabel 
		  BrowserSpecs BrowserFormat DropVirtualNodesFlg Depth SpecialBrowserSpecs 
		  OldLabelNodes OldRootCards)                (* Get rid of all attached windows except the graph 
							     editor menu if any.)
	    (for Win in (ATTACHEDWINDOWS Window) unless (WINDOWPROP Win (QUOTE 
										 GRAPHEDITMENUFLG))
	       do (DETACHWINDOW Win)
		    (CLOSEW Win))
	    (SETQ Card (NC.CoerceToCard Window))
	    (SETQ RootCards (NC.FetchBrowserRoots Card))
	    (SETQ LinkLabels (NC.FetchBrowserLinkLabels Card))
	    (SETQ BrowserFormat (OR (NC.FetchBrowserFormat Card)
					(QUOTE (LATTICE))))
                                                             (* If user wants *GRAPH* format, i.e. virtual nodes 
							     eliminated, then set the flag)
	    (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
		then (SETQ DropVirtualNodesFlg T))
	    (SETQ Depth (OR (NC.FetchBrowserDepth Card)
				999999))
	    (SETQ SpecialBrowserSpecs (OR (NC.FetchSpecialBrowserSpecs Card)
					      (create SPECIALBROWSERSPECS)))
	    (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of (SETQ Graph (WINDOWPROP
								    Window
								    (QUOTE GRAPH)))))
                                                             (* Smash the current hash array, putting a fresh one 
							     in its place.)
	    (NC.GetBrowserHashArray Card)                  (* Get new roots.)
	    (if (OR (NULL RootCards)
			(NC.AskYesOrNo "Want to respecify roots? " "--" "No" T Window T NIL))
		then (NC.BrowserFlipRoots Window Card GraphNodes (SETQ OldRootCards RootCards))
		       (SETQ RootCards (NC.SelectNoteCards NIL NIL NC.SelectingBrowserSourceMenu 
							       Window NIL (CONCAT 
			    "Please select the Cards and/or Boxes the browser should start from."
										    (CHARACTER
										      13)
										    
							       "(Current roots are highlighted.)")
							       T))
		       (NC.BrowserFlipRoots Window Card GraphNodes OldRootCards)
		       (COND
			 ((EQ RootCards (QUOTE CANCELLED))
			   (RETURN))))
	    (NC.PrintMsg Window T (CHARACTER 13)
			   "Computing browser graph. Please wait. ...")
                                                             (* Compute lattice breadth-first from the roots.)
	    (SETQ Lattice (NC.GrowLinkLattice RootCards NIL LinkLabels Card Depth))
	    (SETQ RootNodes (for RootCard in RootCards collect (NC.GetBrowserNodeID Card 
											 RootCard)))
	    (NC.SetPropListDirtyFlg Card T)                (* Remove all links that are in the old browser graph 
							     but not in the new one)
	    (for Node in GraphNodes bind NodeID Link
	       eachtime (BLOCK)
			  (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node))
	       unless (FASSOC (OR (CAR NodeID)
					NodeID)
				  Lattice)
	       do (if (NC.LinkIconImageObjP (SETQ LinkIcon (fetch (GRAPHNODE NODELABEL)
								      of Node)))
			then (NC.DeleteLink (NC.FetchLinkFromLinkIcon LinkIcon)
						T T)
		      else                                 (* Collect the label nodes from the old browser.)
			     (SETQ OldLabelNodes (CONS Node OldLabelNodes))))
                                                             (* Create Links for all nodes in the new browser graph
							     but not in the old one.)
	    (for Node in Lattice bind NodeID OldNode eachtime (BLOCK)
	       do (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node))
		    (COND
		      ((SETQ OldNode (FASSOC NodeID GraphNodes))
			(replace (GRAPHNODE NODELABEL) of Node with (fetch (GRAPHNODE 
											NODELABEL)
									     of OldNode)))
		      (T (replace (GRAPHNODE NODELABEL) of Node
			    with (NC.MakeLinkIcon (NC.MakeLink Window 
								     NC.BrowserContentsLinkLabel
								     (fetch (GRAPHNODE NODELABEL)
									of Node)
								     Card)))))
                                                             (* Untouch each graph node so that next Recompute will
							     put fresh values on proplist.)
		    (NC.UIDRemProp NodeID (QUOTE TouchedFlg))
		    (NC.UIDRemProp NodeID (QUOTE VisitedFlg)))
                                                             (* Throw in the label nodes from the old browser.)
	    (SETQ Lattice (NCONC Lattice OldLabelNodes))
                                                             (* For each old label node, take away nonexistent 
							     fromnodes and save the label nodes that no longer have
							     any from nodes.)
	    (for OldLabelNode in OldLabelNodes eachtime (BLOCK)
	       do (replace (GRAPHNODE FROMNODES) of OldLabelNode
		       with (for FromNodeID in (fetch (GRAPHNODE FROMNODES) of OldLabelNode)
				 bind FromNode eachtime (BLOCK) when (SETQ FromNode
									       (FASSOC FromNodeID 
											 Lattice))
				 collect                   (* If the From node isn't a label node, then add to 
							     its Tonode list.)
					   (if (NC.LinkIconImageObjP (fetch (GRAPHNODE 
											NODELABEL)
									    of FromNode))
					       then (replace (GRAPHNODE TONODES) of FromNode
							 with (CONS (fetch (GRAPHNODE NODEID)
									   of OldLabelNode)
									(fetch (GRAPHNODE TONODES)
									   of FromNode))))
					   FromNodeID))      (* For the old label node's ToNodes, just need to 
							     remove any for ToNodes that no longer exist.)
		    (replace (GRAPHNODE TONODES) of OldLabelNode
		       with (for ToNodeID in (fetch (GRAPHNODE TONODES) of OldLabelNode)
				 bind ToNode eachtime (BLOCK) when (SETQ ToNode
									     (FASSOC ToNodeID 
										       Lattice))
				 collect                   (* If the To node isn't a label node, then add to its 
							     FromNode list.)
					   (if (NC.LinkIconImageObjP (fetch (GRAPHNODE 
											NODELABEL)
									    of ToNode))
					       then (replace (GRAPHNODE FROMNODES) of ToNode
							 with (CONS (fetch (GRAPHNODE NODEID)
									   of OldLabelNode)
									(fetch (GRAPHNODE FROMNODES)
									   of ToNode))))
					   ToNodeID)))       (* Layout graph, including as roots any non-virtual 
							     nodes with no from nodes to avoid disconnected 
							     graphs.)
	    (SETQ Graph (if (AND Lattice RootNodes)
			      then (LAYOUTGRAPH Lattice (for Node in Lattice bind NodeID
							       eachtime
								(BLOCK)
								(SETQ NodeID
								  (OR (NC.CoerceToGraphNodeID
									  Node)
									(fetch (GRAPHNODE NODEID)
									   of Node)))
							       when
								(OR (FMEMB NodeID RootNodes)
								      (NULL (fetch (GRAPHNODE
											 FROMNODES)
										 of Node)))
							       collect NodeID)
						    (SUBST (QUOTE LATTICE)
							     NC.*Graph*BrowserFormat BrowserFormat)
						    (fetch (SPECIALBROWSERSPECS Font) of 
									      SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS MotherD)
						       of SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS PersonalD)
						       of SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS FamilyD)
						       of SpecialBrowserSpecs))
			    else (create GRAPH)))        (* Build links legend and fix up TONODES in the 
							     graph.)
	    (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window DropVirtualNodesFlg))
	    (NC.SetBrowserRoots Card RootCards)
	    (NC.SetBrowserDepth Card Depth)
	    (WINDOWPROP Window (QUOTE GRAPH)
			  Graph)
	    (NC.RelayoutBrowserCard Window))))

(NC.RelayoutBrowserCard
  (LAMBDA (Window)                                           (* rht: "20-Feb-86 14:55")

          (* * Called from the middle button of a browser or structeditbrowser card. This lays out and displays the browser, 
	  but does not recompute the nodes.)



          (* * rht 11/17/85: updated to handle new notefile and card objects.)



          (* * rht 2/7/86: Now gets browser format, etc. via fetch/set fns.)


    (PROG (Card RootCards RootNodeIDs OldToNodePairs Graph GraphNodes BrowserFormat 
		  DropVirtualNodesFlg SpecialBrowserSpecs)
	    (NC.PrintMsg Window T "Laying out graph ...")
	    (SETQ Card (NC.CoerceToCard Window))
	    (SETQ RootCards (NC.FetchBrowserRoots Card))
	    (SETQ BrowserFormat (OR (NC.FetchBrowserFormat Card)
					(QUOTE (LATTICE))))
                                                             (* If user wants *GRAPH* format, i.e. virtual nodes 
							     eliminated, then set the flag)
	    (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
		then (SETQ DropVirtualNodesFlg T))
	    (SETQ SpecialBrowserSpecs (OR (CAR (NC.FetchSpecialBrowserSpecs Card))
					      (create SPECIALBROWSERSPECS)))
	    (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of (SETQ Graph (WINDOWPROP
								    Window
								    (QUOTE GRAPH)))))
                                                             (* Create hash array if haven't already.)
	    (NC.GetBrowserHashArray Card Graph)            (* check graph node size against image box size.)
	    (NC.GraphLinkIconUpdateCheck Card Window Graph NIL)

          (* Save the TONODES values of the nodes so can replace later after LAYOUTGRAPH call. At the same time, throw away 
	  all the link params info in TONODES field.)


	    (SETQ OldToNodePairs (for Node in GraphNodes bind ToNodes eachtime (BLOCK)
				      collect (PROG1 (CONS (fetch (GRAPHNODE NODEID)
								    of Node)
								 (APPEND (SETQ ToNodes
									     (fetch (GRAPHNODE
											TONODES)
										of Node))))
							 (replace (GRAPHNODE TONODES) of Node
							    with (for ToNode in ToNodes
								      collect
								       (if (EQ (CAR ToNode)
										   LINKPARAMS)
									   then (CADR ToNode)
									 else ToNode))))))
	    (SETQ RootNodeIDs (for RootCard in RootCards collect (NC.GetBrowserNodeID
									   Card RootCard)))
	    (NC.SetPropListDirtyFlg Card T)                (* Layout graph, including as roots any non-virtual 
							     nodes with no from nodes to avoid disconnected 
							     graphs.)
	    (SETQ Graph (if GraphNodes
			      then (LAYOUTGRAPH GraphNodes
						    (for Node in GraphNodes bind NodeID
						       eachtime (BLOCK)
								  (SETQ NodeID (fetch
								      (GRAPHNODE NODEID)
										    of Node))
						       when
							(OR (AND (NULL (fetch (GRAPHNODE
											FROMNODES)
										of Node))
								     (NOT (LISTP NodeID)))
							      (FMEMB NodeID RootNodeIDs))
						       collect NodeID)
						    (SUBST (QUOTE LATTICE)
							     NC.*Graph*BrowserFormat BrowserFormat)
						    (fetch (SPECIALBROWSERSPECS Font) of 
									      SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS MotherD)
						       of SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS PersonalD)
						       of SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS FamilyD)
						       of SpecialBrowserSpecs))
			    else (create GRAPH)))

          (* Replace the TONODES fields of the Graph nodes by their pre-LAYOUTGRAPH values. Also throw away any nodes that 
	  didn't appear in the old graph.)


	    (if Graph
		then (replace (GRAPH GRAPHNODES) of Graph
			  with (for Node in (fetch (GRAPH GRAPHNODES) of Graph)
				    bind AssocPair eachtime (BLOCK)
				    when (SETQ AssocPair (FASSOC (fetch (GRAPHNODE NODEID)
									  of Node)
								       OldToNodePairs))
				    collect (replace (GRAPHNODE TONODES) of Node
						 with (CDR AssocPair))
					      (if DropVirtualNodesFlg
						  then (replace (GRAPHNODE NODEBORDER)
							    of Node with NIL))
                                                             (* Throw away LINKPARAMS junk from the FromNodes that 
							     LAYOUTGRAPH stuck in.)
					      (replace (GRAPHNODE FROMNODES) of Node
						 with (for FromNode in (fetch (GRAPHNODE
											FROMNODES)
										of Node)
							   eachtime (BLOCK)
							   collect (if (EQ (CAR FromNode)
										 LINKPARAMS)
									 then (CADR FromNode)
								       else FromNode)))
					      Node)))
	    (SHOWGRAPH Graph Window (FUNCTION NC.GraphCardLeftButtonFn)
			 (FUNCTION NC.GraphCardMiddleButtonFn)
			 NIL T)

          (* * Have to reset windowprops since SHOWGRAPH messes with them.)

                                                             (* Disable the old-style right button grapher editor 
							     menu.)
	    (WINDOWPROP Window (QUOTE RIGHTBUTTONFN)
			  (FUNCTION NC.BrowserRightButtonFn))
	    (WINDOWADDPROP Window (QUOTE REPAINTFN)
			     (FUNCTION NC.BrowserRepaintFn)
			     T)
	    (NC.SetSubstance Card (WINDOWPROP Window (QUOTE GRAPH)))
	    (NC.MarkCardDirty Card)
	    (OR (EQ (WINDOWPROP Window (QUOTE BUTTONEVENTFN))
			(FUNCTION NC.TitleBarButtonEventFn))
		  (WINDOWPROP Window (QUOTE OLDBUTTONEVENTFN)
				(WINDOWPROP Window (QUOTE BUTTONEVENTFN)
					      (FUNCTION NC.TitleBarButtonEventFn))))
	    (NC.ClearMsg Window T))))

(NC.ConnectNodesInBrowser
  (LAMBDA (Window)                                           (* rht: "14-Feb-86 17:20")

          (* * Draw any links, from the current link set, between any pairs of nodes currently being shown in the browser.)



          (* * rht 2/7/86: Now gets and sets browser format, etc. via fetch/set fns. Also fixed one last old call to 
	  GETPROPLIST on a NodeID.)


    (PROG (Card LinkLabels Graph GraphNodes BrowserFormat DropVirtualNodesFlg NodeIDs)
	    (SETQ Card (NC.CoerceToCard Window))
	    (SETQ LinkLabels (NC.FetchBrowserLinkLabels Card))
	    (SETQ BrowserFormat (NC.FetchBrowserFormat Card))
                                                             (* If user wants *GRAPH* format, i.e. virtual nodes 
							     eliminated, then set the flag)
	    (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
		then (SETQ DropVirtualNodesFlg T))
	    (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of (SETQ Graph (WINDOWPROP
								    Window
								    (QUOTE GRAPH)))))
                                                             (* Create hash array if haven't already.)
	    (NC.GetBrowserHashArray Card Graph)            (* check graph node size against image box size.)
	    (NC.GraphLinkIconUpdateCheck Card Window Graph NIL)
                                                             (* These are the workhorse loops that rebuild the 
							     TONODES of each nonvirtual node.)
                                                             (* First smash all the nodeID's proplists and 
							     accumulate nodeIDs.)
	    (SETQ NodeIDs (for Node in GraphNodes bind NodeID eachtime (BLOCK)
			       when (NC.LinkIconImageObjP (fetch (GRAPHNODE NODELABEL)
								 of Node))
			       collect (NC.SmashGraphNodeIDProps (SETQ NodeID (
									 NC.CoerceToGraphNodeID
									 Node)))
					 NodeID))            (* Throw away duplicates obtained from virtual nodes.)
	    (SETQ NodeIDs (INTERSECTION NodeIDs NodeIDs))

          (* Next accumulate all linktypes on the from node's proplist using the To node's graphnodeID as prop name.
	  We do the analogous thing for backward links, but notice that we ignore backward linktypes that also appear in the 
	  list in their forward version.)


	    (for NodeID in NodeIDs bind RealCard
	       do (for Link in (NC.RetrieveToLinks (SETQ RealCard (
							       NC.CardFromBrowserNodeID NodeID)))
		       bind DestNodeID eachtime (BLOCK) when (NC.LinkLabelP Link LinkLabels)
		       when (FMEMB (SETQ DestNodeID (NC.GetBrowserNodeID Card
										 (fetch
										   (Link 
										  DestinationCard)
										    of Link)))
				       NodeIDs)
		       do (NC.UIDAddProp NodeID DestNodeID (fetch (Link Label) of Link)
					     T))
		    (for Link in (NC.RetrieveFromLinks RealCard) bind SourceNodeID
		       eachtime (BLOCK) when (AND (NC.ReverseLinkLabelP Link LinkLabels)
							  (NOT (NC.LinkLabelP Link LinkLabels)))
		       when (FMEMB (SETQ SourceNodeID (NC.GetBrowserNodeID
					   Card
					   (fetch (Link SourceCard) of Link)))
				       NodeIDs)
		       do (NC.UIDAddProp SourceNodeID NodeID (fetch (Link Label) of Link)
					     T)))
	    (for Node in GraphNodes bind NodeID OldToNodeIDs eachtime (BLOCK)
	       unless (LISTP (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node)))
	       when (NC.LinkIconImageObjP (fetch (GRAPHNODE NODELABEL) of Node))
	       do                                          (* Accumulate the old NodeIDs, possibly virtual, from 
							     the TONODES list.)
		    (SETQ OldToNodeIDs (for ToNode in (fetch (GRAPHNODE TONODES)
							       of Node)
					    collect (if (EQ (CAR ToNode)
								  LINKPARAMS)
							  then (CADR ToNode)
							else ToNode)))

          (* The trick here is to use a virtual node for this ToNode if one was used before, otherwise just the ToNodeID.
	  Also throw in the label nodes that were in the TONODES list before.)


		    (replace (GRAPHNODE TONODES) of Node
		       with (NCONC (for ToNodeID on (
							 NC.ComputeBrowserSavedLinkingInfoForNode
							      NodeID)
					  by (CDDR ToNodeID) eachtime (BLOCK)
					  collect (OR (for OldToNodeID in OldToNodeIDs
							     thereis (AND (LISTP OldToNodeID)
									      (EQ (CAR ToNodeID)
										    (CAR 
										      OldToNodeID))
									      OldToNodeID))
							  (CAR ToNodeID)))
				       (for ToNodeID in OldToNodeIDs eachtime (BLOCK)
					  unless (NC.SameCardP Card (NC.CardFromBrowserNodeID
								     (NC.CoerceToGraphNodeID 
											 ToNodeID)))
					  collect ToNodeID))))
	    (NC.RebuildFromNodesInGraph GraphNodes)
	    (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window DropVirtualNodesFlg))
	    (SHOWGRAPH Graph Window (FUNCTION NC.GraphCardLeftButtonFn)
			 (FUNCTION NC.GraphCardMiddleButtonFn)
			 NIL T)

          (* * Have to reset windowprops since SHOWGRAPH messes with them.)

                                                             (* Disable the old-style right button grapher editor 
							     menu.)
	    (WINDOWPROP Window (QUOTE RIGHTBUTTONFN)
			  (FUNCTION NC.BrowserRightButtonFn))
	    (WINDOWADDPROP Window (QUOTE REPAINTFN)
			     (FUNCTION NC.BrowserRepaintFn)
			     T)
	    (NC.SetSubstance Card (WINDOWPROP Window (QUOTE GRAPH)))
	    (NC.MarkCardDirty Card)
	    (OR (EQ (WINDOWPROP Window (QUOTE BUTTONEVENTFN))
			(FUNCTION NC.TitleBarButtonEventFn))
		  (WINDOWPROP Window (QUOTE OLDBUTTONEVENTFN)
				(WINDOWPROP Window (QUOTE BUTTONEVENTFN)
					      (FUNCTION NC.TitleBarButtonEventFn))))
	    (NC.ClearMsg Window T))))

(NC.UnconnectNodesInBrowser
  (LAMBDA (Window)                                           (* rht: " 7-Feb-86 12:23")

          (* * Remove all the links in the browser.)



          (* * rht 11/17/85: Now handles new card and notefile objects.)



          (* * rht 2/7/86: Now gets and sets browser format, etc. via fetch/set fns.)


    (PROG (Card Graph GraphNodes BrowserFormat DropVirtualNodesFlg)
	    (SETQ Card (NC.CoerceToCard Window))
	    (SETQ BrowserFormat (NC.FetchBrowserFormat Card))
                                                             (* If user wants *GRAPH* format, i.e. virtual nodes 
							     eliminated, then set the flag)
	    (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
		then (SETQ DropVirtualNodesFlg T))
	    (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of (SETQ Graph (WINDOWPROP
								    Window
								    (QUOTE GRAPH)))))
                                                             (* smash all the nodeID's proplists and TONODES 
							     fields.)
	    (for Node in GraphNodes bind NodeID unless (PROGN (BLOCK)
									(LISTP
									  (SETQ NodeID
									    (fetch (GRAPHNODE
										       NODEID)
									       of Node))))
	       do (NC.SmashGraphNodeIDProps NodeID)
		    (replace (GRAPHNODE TONODES) of Node with NIL)
		    (replace (GRAPHNODE FROMNODES) of Node with NIL))
	    (NC.MakeLinksLegend Graph Window DropVirtualNodesFlg)
	    (SHOWGRAPH Graph Window (FUNCTION NC.GraphCardLeftButtonFn)
			 (FUNCTION NC.GraphCardMiddleButtonFn)
			 NIL T)

          (* * Have to reset windowprops since SHOWGRAPH messes with them.)

                                                             (* Disable the old-style right button grapher editor 
							     menu.)
	    (WINDOWPROP Window (QUOTE RIGHTBUTTONFN)
			  (FUNCTION NC.BrowserRightButtonFn))
	    (WINDOWADDPROP Window (QUOTE REPAINTFN)
			     (FUNCTION NC.BrowserRepaintFn)
			     T)
	    (NC.SetSubstance Card (WINDOWPROP Window (QUOTE GRAPH)))
	    (NC.MarkCardDirty Card)
	    (NC.SetBrowserLinksLegend Card NIL)
	    (OR (EQ (WINDOWPROP Window (QUOTE BUTTONEVENTFN))
			(FUNCTION NC.TitleBarButtonEventFn))
		  (WINDOWPROP Window (QUOTE OLDBUTTONEVENTFN)
				(WINDOWPROP Window (QUOTE BUTTONEVENTFN)
					      (FUNCTION NC.TitleBarButtonEventFn))))
	    (NC.ClearMsg Window T))))

(NC.ExpandBrowserNode
  (LAMBDA (Window)                                           (* rht: " 7-Feb-86 12:26")

          (* * Ask user to choose a node in the browser and recompute the part of the lattice under that node to the given 
	  depth. And relayout the graph. The code is just a modification of the NC.UpdateBrowserCard code.)



          (* * rht 2/7/86: Now gets and sets browser format, etc. via fetch/set fns.)


    (PROG (NodeToExpand Card LinkLabels RootCards RootNodes Lattice LinkIcon OldToNodePairs Graph 
			  GraphNodes NodeLabel OldNode Link BrowserSpecs BrowserFormat 
			  DropVirtualNodesFlg Depth SpecialBrowserSpecs SavedLabelNodes)
	    (SETQ Card (NC.CoerceToCard Window))
	    (SETQ RootCards (NC.FetchBrowserRoots Card))
	    (SETQ LinkLabels (NC.FetchBrowserLinkLabels Card))
	    (SETQ BrowserFormat (NC.FetchBrowserFormat Card))
                                                             (* If user wants *GRAPH* format, i.e. virtual nodes 
							     eliminated, then set the flag)
	    (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
		then (SETQ DropVirtualNodesFlg T))
	    (SETQ SpecialBrowserSpecs (OR (NC.FetchSpecialBrowserSpecs Card)
					      (create SPECIALBROWSERSPECS)))
	    (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of (SETQ Graph (WINDOWPROP
								    Window
								    (QUOTE GRAPH)))))
                                                             (* If there aren't any nodes in graph, then get out 
							     pronto.)
	    (if (NULL GraphNodes)
		then (NC.PrintMsg Window T "No nodes to expand.")
		       (DISMISS 1000)
		       (NC.ClearMsg Window T)
		       (RETURN NIL))                       (* Create hash array if haven't already.)
	    (NC.GetBrowserHashArray Card Graph)
	    (NC.PrintMsg Window T "Pick node to expand." (CHARACTER 13))
                                                             (* Note call to the grapher function READ/NODE to 
							     select a graph node.)
	    (SETQ NodeToExpand (READ/NODE GraphNodes Window))
                                                             (* Can't expand a label node.)
	    (if (NOT (NC.LinkIconImageObjP (fetch (GRAPHNODE NODELABEL) of NodeToExpand)))
		then (NC.PrintMsg NIL T "Sorry, can't expand a label node.")
		       (FLASHW PROMPTWINDOW)
		       (NC.ClearMsg Window T)
		       (RETURN))
	    (SETQ Depth (MKATOM (NC.AskUser "Depth to expand (type integer or INF): " "--" 1 T 
						  Window NIL NIL T)))
	    (COND
	      ((EQ Depth (QUOTE INF))
		(SETQ Depth MAX.FIXP))
	      ((NOT (AND (FIXP Depth)
			     (GREATERP Depth 0)))
		(NC.PrintMsg Window T "Depth must be an integer greater than 0 or INF.")
		(RETURN)))
	    (NC.PrintMsg Window T (CHARACTER 13)
			   "Augmenting browser graph. Please wait. ...")
                                                             (* Save the nodes pointed to by the chosen node that 
							     are label nodes. GrowLinkLattice will trash those, so 
							     we restore afterwards.)
	    (SETQ SavedLabelNodes (for ToNode in (fetch (GRAPHNODE TONODES) of NodeToExpand)
				       eachtime (BLOCK) when (AND (NOT (EQ (CAR ToNode)
										       LINKPARAMS))
									  (NOT (
									     NC.LinkIconImageObjP
										   ToNode)))
				       collect ToNode))    (* Increase link lattice from chosen node to given 
							     depth.)
	    (SETQ Lattice (NC.GrowLinkLattice (LIST (NC.CardFromBrowserNodeID
							    (fetch (GRAPHNODE NODEID) of 
										     NodeToExpand)))
						  (APPEND GraphNodes)
						  LinkLabels Card Depth))
	    (AND SavedLabelNodes (replace (GRAPHNODE TONODES) of NodeToExpand
				      with (APPEND SavedLabelNodes (fetch (GRAPHNODE TONODES)
									  of NodeToExpand))))
	    (SETQ RootNodes (for RootCard in RootCards collect (NC.GetBrowserNodeID Card 
											 RootCard)))
	    (NC.SetPropListDirtyFlg Card T)                (* Create Links for all nodes in the new browser graph
							     but not in the old one.)
	    (for Node in Lattice bind NodeID
	       do (COND
		      ((SETQ OldNode (FASSOC (SETQ NodeID (OR (NC.CoerceToGraphNodeID
									Node)
								      (fetch (GRAPHNODE NODEID)
									 of Node)))
						 GraphNodes))
			(replace (GRAPHNODE NODELABEL) of Node with (fetch (GRAPHNODE 
											NODELABEL)
									     of OldNode)))
		      (T (replace (GRAPHNODE NODELABEL) of Node
			    with (NC.MakeLinkIcon (NC.MakeLink Window 
								     NC.BrowserContentsLinkLabel
								     (fetch (GRAPHNODE NODELABEL)
									of Node)
								     Card)))))
                                                             (* Throw away virtual node info.)
		    (AND NodeID (replace (GRAPHNODE NODEID) of Node with NodeID)) 
                                                             (* Untouch each graph node so that next Recompute will
							     put fresh values on proplist.)
		    (NC.UIDRemProp NodeID (QUOTE TouchedFlg))
		    (NC.UIDRemProp NodeID (QUOTE VisitedFlg)) 
                                                             (* Smash all the unnecessary junk off existing nodes, 
							     letting LAYOUTGRAPH and NC.MakeLinksLegend recompute.)
		    (replace (GRAPHNODE TONODES) of Node
		       with (for ToNode in (fetch (GRAPHNODE TONODES) of Node)
				 bind ToNodeID eachtime (BLOCK)
				 collect (if (SETQ ToNodeID (NC.CoerceToGraphNodeID ToNode))
					       then        (* Throw away link parameterlist info.)
                                                             (* Throw away link dashing info.)
						      (NC.UIDPutProp NodeID ToNodeID
								       (for LabelPair
									  in (NC.UIDGetProp
										 NodeID ToNodeID)
									  collect
									   (OR (CAR LabelPair)
										 LabelPair)))
						      (NC.UIDPutProp ToNodeID NodeID
								       (for LabelPair
									  in (NC.UIDGetProp
										 ToNodeID NodeID)
									  collect
									   (OR (CAR LabelPair)
										 LabelPair)))
						      ToNodeID
					     else ToNode))))
                                                             (* LAYOUTGRAPH doesn't like duplicate nodes.
							     These get created when virtual nodes are turned into 
							     regular nodes.)
	    (SETQ Lattice (NC.RemoveDuplicateNodesFromGraph Lattice))
	    (NC.RebuildFromNodesInGraph Lattice)
	    (SETQ Graph (LAYOUTGRAPH Lattice (for Node in Lattice bind NodeID
						    eachtime (BLOCK)
						    when (OR (FMEMB (SETQ NodeID
									    (
								    NC.CoerceToGraphNodeIDOrLabel
									      Node))
									  RootNodes)
								 (NULL (fetch (GRAPHNODE 
											FROMNODES)
									    of Node)))
						    collect NodeID)
					 (SUBST (QUOTE LATTICE)
						  NC.*Graph*BrowserFormat BrowserFormat)
					 (fetch (SPECIALBROWSERSPECS Font) of SpecialBrowserSpecs)
					 (fetch (SPECIALBROWSERSPECS MotherD) of 
									      SpecialBrowserSpecs)
					 (fetch (SPECIALBROWSERSPECS PersonalD) of 
									      SpecialBrowserSpecs)
					 (fetch (SPECIALBROWSERSPECS FamilyD) of 
									      SpecialBrowserSpecs)))
                                                             (* Build links legend and fix up TONODES in the 
							     graph.)
	    (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window DropVirtualNodesFlg))
	    (WINDOWPROP Window (QUOTE GRAPH)
			  Graph)
	    (NC.RelayoutBrowserCard Window))))

(NC.ChangeBrowserSpecs
  (LAMBDA (Window)                                           (* rht: " 7-Feb-86 12:55")

          (* * Change the values of the various browser specs including link types, browser format, search depth, etc.)



          (* * rht 11/17/85: Updated for new card and notefile objects.)



          (* * rht 2/7/86: Now sets and gets browser link labels, etc. via fetch/set fns.)


    (PROG (Card LinkLabels RootNodes BrowserSpecs BrowserFormat Depth)
	    (SETQ Card (NC.CoerceToCard Window))
	    (SETQ LinkLabels (NC.FetchBrowserLinkLabels Card))
	    (SETQ BrowserFormat (NC.FetchBrowserFormat Card))
	    (SETQ Depth (NC.FetchBrowserDepth Card))
	    (SETQ BrowserSpecs (NC.AskBrowserSpecs Window Card LinkLabels Depth BrowserFormat))
	    (SETQ LinkLabels (CAR BrowserSpecs))
	    (SETQ Depth (CADR BrowserSpecs))
	    (SETQ BrowserFormat (CADDR BrowserSpecs))
	    (NC.SetPropListDirtyFlg Card T)
	    (NC.SetBrowserLinkLabels Card LinkLabels)
	    (NC.SetBrowserFormat Card BrowserFormat)
	    (NC.SetBrowserDepth Card Depth)
	    (NC.ClearMsg Window T))))

(NC.GraphLinkIconUpdateCheck
  (LAMBDA (GraphCard Window Graph UpdateIfNullCacheFlg)      (* rht: "20-Feb-86 16:38")

          (* * Check current values of link icon default display global params against values cached on Window.
	  If changed, then fix link icon sizes in graph. Return non-nil if we had to fix graph nodes.)



          (* * rht 2/20/86: Changed to use card's user data area instead of props.)


    (LET ((OldGlobalParams (NC.FetchUserDataProp GraphCard (QUOTE CachedGlobalParams)))
	  (CurGlobalParams (LIST NC.LinkIconShowTitleFlg NC.LinkIconShowLinkTypeFlg 
				   NC.LinkIconAttachBitmapFlg))
	  DidWorkFlg)
         (if (NOT (EQUAL OldGlobalParams CurGlobalParams))
	     then (if (OR OldGlobalParams UpdateIfNullCacheFlg)
			then (for Node in (fetch (GRAPH GRAPHNODES) of Graph)
				  do (NC.GraphNodeLinkIconUpdate Window Node))
			       (SETQ DidWorkFlg T))
		    (NC.SetUserDataProp GraphCard (QUOTE CachedGlobalParams)
					  CurGlobalParams))
     DidWorkFlg)))
)
(DEFINEQ

(NC.SetBrowserRoots
  (LAMBDA (Card BrowserRoots)                                (* rht: " 7-Feb-86 12:28")

          (* * Put the roots on the Card's UID property list in the CardUID/NoteFileUID pair format.)


    (NC.SetBrowserRootsInfo Card (for BrowserRoot in BrowserRoots eachtime (BLOCK)
				      collect (CONS (fetch (Card UID) of BrowserRoot)
							(fetch (NoteFile UID)
							   of (fetch (Card NoteFile)
								   of BrowserRoot)))))))

(NC.FetchBrowserRoots
  (LAMBDA (Card)                                             (* rht: " 7-Feb-86 12:29")

          (* * Get roots off Card's UID list and convert them from UID pairs to Card objects.)


    (for BrowserRootUIDPair in (NC.FetchBrowserRootsInfo Card) eachtime (BLOCK)
       collect (NC.CardFromUID (CAR BrowserRootUIDPair)
				   (NC.NoteFileFromNoteFileUID (CDR BrowserRootUIDPair))))))
)
(DEFINEQ

(NC.BrowserAddLink
  (LAMBDA (FromNode ToNode Win Graph GlobalLinkFlg)          (* rht: " 7-Feb-86 12:44")

          (* * Like grapher's ADD/AND/DISPLAY/LINK except has different checks and builds a real NC Link.)



          (* * rht 9/20/85: Added GlobalLinkFlg arg to force the link created to be global. Currently, it's global anyway if 
	  from node is a sketch card, for example.)



          (* * rht 11/17/85: updated for new card and notefile object format.)



          (* * rht 2/7/86: Now sets and gets browser link labels, etc. via fetch/set fns.)


    (PROG ((MaxDashingStylesNum (LENGTH NC.DashingStyles))
	     Link Card LabelPairs LabelPair LinkLabel LabelNum ToNodeID FromNodeID OldDestNode 
	     LinkParams ReverseLinkParams SavedDeleteLinkFn NumberOfLinks)
	    (COND
	      ((NOT (AND (NC.LinkIconImageObjP (fetch (GRAPHNODE NODELABEL) of FromNode))
			     (NC.LinkIconImageObjP (fetch (GRAPHNODE NODELABEL) of ToNode))))
		(NC.PrintMsg NIL T 
			    "Can't create link from or to a label node.  Try 'Add Edge' instead.")
		(FLASHW PROMPTWINDOW)
		(RETURN NIL))
	      ((SETQ Link (NC.BrowserCreateLink FromNode ToNode Graph Win GlobalLinkFlg))
                                                             (* We successfully created a link.
							     Now undraw existing link and redraw with new one 
							     added.)
                                                             (* First, check whether label for new link is already 
							     in graph.)
		(SETQ Card (NC.CoerceToCard Win))
		(SETQ LabelPairs (NC.FetchBrowserLinksLegend Card))
		(SETQ LinkLabel (fetch (Link Label) of Link))
                                                             (* If link label hasn't appeared in the graph, make a 
							     new dashing number for it and update links legend.)
		(if (NULL (SETQ LabelPair (FASSOC LinkLabel LabelPairs)))
		    then (SETQ LabelPairs (APPEND LabelPairs
							(LIST (SETQ LabelPair
								  (CONS LinkLabel
									  (COND
									    ((ILESSP
										(SETQ LabelNum
										  (LENGTH 
										       LabelPairs))
										MaxDashingStylesNum)
									      (SETQ LabelNum
										(ADD1 LabelNum)))
									    (T LabelNum)))))))
			   (NC.SetBrowserLinksLegen Card LabelPairs)
			   (NC.MakeLinksLegendMenu Win LabelPairs))
		(SETQ FromNodeID (NC.CoerceToGraphNodeID FromNode))
		(SETQ ToNodeID (NC.CoerceToGraphNodeID ToNode))
		(SETQ NumberOfLinks (PLUS (LENGTH (NC.UIDGetProp FromNodeID ToNodeID))
					      (LENGTH (NC.UIDGetProp ToNodeID FromNodeID))))
		(SETQ LinkParams (LINKPARAMETERS FromNode ToNode))
		(SETQ ReverseLinkParams (LINKPARAMETERS ToNode FromNode))
		(COND
		  ((OR (ZEROP NumberOfLinks)
			 (AND (NULL LinkParams)
				(NULL ReverseLinkParams)))
		    (if (OR (FMEMB (fetch (GRAPHNODE NODEID) of FromNode)
					 (fetch (GRAPHNODE TONODES) of ToNode))
				(FMEMB (fetch (GRAPHNODE NODEID) of ToNode)
					 (fetch (GRAPHNODE TONODES) of FromNode)))
			then                               (* There are no links, but there is an edge.
							     Delete it and redisplay.)
			       (SETQ SavedDeleteLinkFn (fetch (GRAPH GRAPH.DELETELINKFN)
							    of Graph))
			       (replace (GRAPH GRAPH.DELETELINKFN) of Graph with NIL)
			       (DELETE/AND/DISPLAY/LINK FromNode ToNode Win Graph)
			       (NC.PrintMsg NIL T "Replacing existing edge with new link edge.")
			       (FLASHW PROMPTWINDOW))      (* This is first link between these two nodes so 
							     compute dashing here.)
		    (replace (GRAPHNODE TONODES) of FromNode
		       with (CONS (LIST LINKPARAMS (fetch (GRAPHNODE NODEID) of ToNode)
					      (QUOTE DRAWLINKFN)
					      (FUNCTION NC.BrowserDrawLinkFn)
					      (QUOTE DASHING)
					      (CAR (FNTH NC.DashingStyles (CDR LabelPair))))
				      (fetch (GRAPHNODE TONODES) of FromNode)))
		    (replace (GRAPHNODE FROMNODES) of ToNode with (CONS (fetch
										  (GRAPHNODE NODEID)
										   of FromNode)
										(fetch
										  (GRAPHNODE 
											FROMNODES)
										   of ToNode))))
		  (LinkParams                                (* There are multiple links.
							     And the link params is on the FromNode.)
			      (DISPLAYLINK FromNode ToNode
					     (CONSTANT (create POSITION
								   XCOORD ← 0
								   YCOORD ← 0))
					     Win Graph 1 LinkParams)
                                                             (* If there was only one link, then change so 
							     multi-link indicator.)
			      (if (EQP NumberOfLinks 1)
				  then (RPLACD (CDR LinkParams)
						   (LIST (QUOTE NODEID)
							   FromNodeID
							   (QUOTE DESTNODEID)
							   ToNodeID))))
		  (T                                         (* There are multiple links.
							     The Link params is on the ToNode.)
		     (DISPLAYLINK ToNode FromNode (CONSTANT (create POSITION
									  XCOORD ← 0
									  YCOORD ← 0))
				    Win Graph 1 ReverseLinkParams)
                                                             (* If there was only one link, then change so 
							     multi-link indicator.)
		     (if (EQP NumberOfLinks 1)
			 then (RPLACD (CDR ReverseLinkParams)
					  (LIST (QUOTE NODEID)
						  ToNodeID
						  (QUOTE DESTNODEID)
						  FromNodeID)))))
		(NC.UIDAddProp FromNodeID ToNodeID LabelPair)
		(COND
		  (LinkParams (DISPLAYLINK FromNode ToNode
					     (CONSTANT (create POSITION
								   XCOORD ← 0
								   YCOORD ← 0))
					     Win Graph 1 LinkParams))
		  (ReverseLinkParams (DISPLAYLINK ToNode FromNode
						    (CONSTANT (create POSITION
									  XCOORD ← 0
									  YCOORD ← 0))
						    Win Graph 1 ReverseLinkParams))
		  (T (DISPLAYLINK FromNode ToNode (CONSTANT (create POSITION
									  XCOORD ← 0
									  YCOORD ← 0))
				    Win Graph 1 (LINKPARAMETERS FromNode ToNode))))
		(RETURN NIL))))))

(NC.BrowserDeleteCard
  (LAMBDA (Node Graph Window)                                (* rht: " 7-Feb-86 12:48")

          (* * Called by grapher when user deletes a node. Will try to delete the card behind the node as well.)



          (* * rht 11/17/85: updated to handle card and notefile object styles.)



          (* * rht 2/7/86: Changed to use NC.SetBrowserRoots instead of NC.PutProp.)


    (PROG ((GraphCard (NC.CoerceToCard Window))
	     Card GraphNodeID RootCards)
	    (SETQ Card (NC.CardFromBrowserNodeID (fetch (GRAPHNODE NODEID) of Node)))
	    (NC.MarkCardDirty GraphCard)                   (* Delete all record of links to and from this node on
							     prop lists.)
	    (NC.SmashGraphNodeIDProps (SETQ GraphNodeID (NC.CoerceToGraphNodeID Node)))
	    (for OtherNode in (fetch (GRAPH GRAPHNODES) of Graph) do (NC.UIDRemProp
										 (
									   NC.CoerceToGraphNodeID
										   OtherNode)
										 GraphNodeID))
                                                             (* Does user really want to delete the card behind 
							     this node?)
	    (COND
	      ((AND (NC.ValidCardP Card)
		      (NC.AskYesOrNo (CONCAT "Want to delete the " (NC.RetrieveTitle Card)
						 " card? ")
				       "--"
				       (QUOTE Yes)
				       T Window NIL NIL))
		(NC.DeleteNoteCards Card T)                (* Redisplay so that the deletedLinkIcon goes away.)
		(DISPLAYNODE Node (CONSTANT (create POSITION
							  XCOORD ← 0
							  YCOORD ← 0))
			       Window Graph)                 (* Remove from the root ids list.)
		(SETQ RootCards (NC.FetchBrowserRoots GraphCard))
		(if (for RootCard in RootCards eachtime (BLOCK) thereis (NC.SameCardP
										      Card RootCard))
		    then (NC.SetBrowserRoots GraphCard (for RootCard in RootCards
							      eachtime (BLOCK)
							      unless (NC.SameCardP Card RootCard)
							      collect RootCard))))
	      (T (NC.PrintMsg Window NIL "Card not deleted."))))))

(NC.BrowserRemoveNode
  (LAMBDA (Graph Window DeleteCardFlg)                       (* rht: " 7-Feb-86 12:51")

          (* * Called by grapher when user removes a node.)



          (* * rht 11/17/85: Updated to handle new card and notefile formats.)



          (* * rht 2/7/86: Changed to use NC.SetBrowserRoots instead of NC.PutProp)


    (PROG ((GraphCard (NC.CoerceToCard Window))
	     Card NodeToRemoveID RootCards NodesToRemove NumVirtuals NodeToRemove)
	    (SETQ NodeToRemove (NC.SelectGraphNode Window Graph (if DeleteCardFlg
									then 
								 "Choose node of card to delete."
								      else "Choose node to remove.")
						       ))
	    (SETQ NodeToRemoveID (NC.CoerceToGraphNodeIDOrLabel NodeToRemove))
	    (SETQ Card (NC.CardFromBrowserNodeID NodeToRemoveID))
                                                             (* If we're supposed to be deleting a card, then check
							     that node represents a card and that user confirms.)
	    (if DeleteCardFlg
		then (if (NC.ValidCardP Card)
			   then (if (NOT (NC.AskYesOrNo (CONCAT "Want to delete the "
									  (NC.RetrieveTitle Card)
									  " card? ")
								"--"
								(QUOTE Yes)
								T Window NIL NIL))
				      then (FLIPNODE NodeToRemove Window)
					     (RETURN (NC.PrintMsg NIL T 
								    "Card & Node delete aborted.")))
			 else (NC.PrintMsg NIL T "No card for that node.")
				(FLASHW PROMPTWINDOW)
				(FLIPNODE NodeToRemove Window)
				(RETURN NIL)))
	    (NC.MarkCardDirty GraphCard)

          (* We require that all virtual nodes for this node must be removed at once if this one has any link edges to or 
	  from it.)


	    (SETQ NodesToRemove (for Node in (fetch (GRAPH GRAPHNODES) of Graph)
				     when (EQ NodeToRemoveID (NC.CoerceToGraphNodeIDOrLabel
						    Node))
				     collect Node))        (* If there are no edges into or out of this node, 
							     then just delete from graph.)
	    (if (AND (NOT DeleteCardFlg)
			 (NULL (fetch (GRAPHNODE FROMNODES) of NodeToRemove))
			 (NULL (fetch (GRAPHNODE TONODES) of NodeToRemove)))
		then (FLIPNODE NodeToRemove Window)      (* Delete the browsercontents link from the browser.)
		       (AND (NC.ValidCardP Card)
			      (NC.DelBrowserContentsLink GraphCard Card))
                                                             (* Remove entry for this node from browser hash 
							     array.)
		       (NC.RemoveBrowserNodeHashArrayEntry GraphCard Card)
		       (RETURN (NC.GraphRemoveNode NodeToRemove Graph Window)))
                                                             (* If there are companion virtual nodes, ask for user 
							     confirmation.)
	    (if (AND (NOT DeleteCardFlg)
			 (GREATERP (SETQ NumVirtuals (LENGTH NodesToRemove))
				     1)
			 (NOT (PROGN (NC.PrintMsg Window T NumVirtuals 
						      " virtual companion nodes will be removed."
							(CHARACTER 13))
					 (NC.YesP (NC.AskUser "Still want to remove? " "--"
								  (QUOTE Yes)
								  NIL Window NIL NIL T)))))
		then (FLIPNODE NodeToRemove Window)
		       (RETURN NIL))                       (* Delete the browsercontents link from the browser.)
	    (AND (NC.ValidCardP Card)
		   (NC.DelBrowserContentsLink GraphCard Card))
                                                             (* Delete all record of links to and from this node on
							     prop lists.)
	    (NC.SmashGraphNodeIDProps NodeToRemoveID)
	    (for Node in (fetch (GRAPH GRAPHNODES) of Graph) do (NC.UIDRemProp
									    (NC.CoerceToGraphNodeID
									      Node)
									    NodeToRemoveID))
                                                             (* Remove from the root ids list.)
	    (SETQ RootCards (NC.FetchBrowserRoots GraphCard))
	    (if (for RootCard in RootCards eachtime (BLOCK) thereis (NC.SameCardP
										  Card RootCard))
		then (NC.SetBrowserRoots GraphCard (for RootCard in RootCards
							  eachtime (BLOCK)
							  unless (NC.SameCardP Card RootCard)
							  collect RootCard)))
                                                             (* Remove entry for this node from browser hash 
							     array.)
	    (NC.RemoveBrowserNodeHashArrayEntry GraphCard Card)
                                                             (* Get rid of node and its virtual buddies from 
							     graph.)
	    (FLIPNODE NodeToRemove Window)
	    (for Node in NodesToRemove do (NC.GraphRemoveNode Node Graph Window))
                                                             (* Delete card if we're supposed to.)
	    (if DeleteCardFlg
		then (NC.PrintMsg NIL T "Deleting " Card " ... ")
		       (NC.DeleteNoteCards Card T)
		       (NC.PrintMsg NIL T "Done." (CHARACTER 13)))
	    (REDISPLAYW Window)
	    (NC.PrintMsg NIL T "Nodes: " (CONCATLIST (for Node in NodesToRemove
							    collect (PACK* (fetch (GRAPHNODE
											  NODEID)
										  of Node)
									       (QUOTE % ))))
			   "removed."))))
)
(* * The function NC.QuitBrowserCard needs to be DELETED from NCBROWSERCARD)

(* * New functions for NCBROWSERCARD)

(DEFINEQ

(NC.DelReferencesToCardFromBrowser
  (LAMBDA (SourceCard LinkOrDestinationCard)                 (* rht: "20-Feb-86 11:28")

          (* * Delete from the browser specified by SourceCard all link icon nodes whose DESTINATIONID is eq to 
	  DestinationID. This just checks the case of the SourceCard being a browser root and then passes off to GRAPHCARD's 
	  DelReferencesFn.)


    (LET ((LinkFlg (type? Link LinkOrDestinationCard))
	  DestinationCard BrowserRoots)
         (if LinkFlg
	     then (OR (NC.CardP SourceCard)
			  (SETQ SourceCard (fetch (Link SourceCard) of LinkOrDestinationCard)))
		    (SETQ DestinationCard (fetch (Link DestinationCard) of 
									    LinkOrDestinationCard))
	   else (SETQ DestinationCard LinkOrDestinationCard))
         (if (SETQ RootCardToDelete (for RootCard in (SETQ BrowserRoots (
								 NC.FetchBrowserRoots SourceCard))
					   eachtime (BLOCK) do (if (NC.SameCardP 
										  DestinationCard 
											 RootCard)
									 then (RETURN RootCard))))
	     then (NC.SetBrowserRoots SourceCard (DREMOVE RootCardToDelete BrowserRoots)))
         (NC.ApplySupersFn DeleteLinksFn SourceCard LinkOrDestinationCard))))

(NC.NewBrowserNodeUIDFromOldUID
  (LAMBDA (OldUID GraphNodes HashArray)                      (* rht: " 1-Feb-86 15:59")

          (* * Find and return the NodeID UID in GraphNodes that is SameUIDP to OldUID. Use hash table for caching.)


    (OR (GETHASH OldUID HashArray)
	  (for GraphNode in GraphNodes bind NewUID eachtime (BLOCK)
	     when (NC.SameUIDP OldUID (SETQ NewUID (fetch (GRAPHNODE NODEID) of GraphNode)))
	     do (RETURN (PUTHASH OldUID NewUID HashArray))))))

(NC.GetBrowserSubstance
  (LAMBDA (Card Length Stream)                               (* rht: "20-Feb-86 14:32")

          (* * Go get all the browser-specific info and then get the graph that is the browser's substance.)



          (* * rht 2/14/86: Added call to NC.ApplySupersFn)


    (NC.SetBrowserRootsInfo Card (NC.ReadBrowserRootsInfo Stream))
    (NC.SetBrowserLinkLabels Card (NC.ReadBrowserLinkLabels Stream))
    (NC.SetBrowserFormat Card (NC.ReadBrowserFormat Stream))
    (NC.SetSpecialBrowserSpecs Card (NC.ReadSpecialBrowserSpecs Stream))
    (NC.SetBrowserDepth Card (NC.ReadBrowserDepth Stream))
    (NC.SetBrowserLinksLegend Card (NC.ReadBrowserLinksLegend Stream))
    (NC.SetBrowserSavedLinkingInfo Card (NC.ReadBrowserSavedLinkingInfo Stream))
    (NC.ApplySupersFn GetFn Card Length Stream)))

(NC.ComputeBrowserSavedLinkingInfo
  (LAMBDA (Card)                                             (* rht: " 7-Feb-86 00:44")

          (* * Search the graph nodeIDs of Card's substance for special linking info for multiple links between same pair of 
	  nodes.)


    (for GraphNode in (fetch (GRAPH GRAPHNODES) of (NC.FetchSubstance Card))
       bind SavedLinkingInfoForNode UID eachtime (BLOCK) when (SETQ SavedLinkingInfoForNode
									(
							 NC.ComputeBrowserSavedLinkingInfoForNode
									  (SETQ UID
									    (fetch (GRAPHNODE
										       NODEID)
									       of GraphNode))))
       collect (CONS UID SavedLinkingInfoForNode))))

(NC.ComputeBrowserSavedLinkingInfoForNode
  (LAMBDA (UID)                                              (* rht: " 7-Feb-86 00:43")

          (* * Return list of DestUIDs and link dashing info.)


    (for UserData on (NC.UIDGetPropList UID) by (CDDR UserData) when (type?
										   UID
										   (CAR UserData))
       join (LIST (CAR UserData)
		      (CADR UserData)))))
)
(DEFINEQ

(NC.FetchBrowserRootsInfo
  (LAMBDA (Card)                                             (* rht: "11-Feb-86 23:28")

          (* * Return the browser roots UID pairs for this browser card.)


    (NC.FetchUserDataProp Card (QUOTE BrowserRootsInfo))))

(NC.FetchBrowserLinkLabels
  (LAMBDA (Card)                                             (* rht: "11-Feb-86 23:28")

          (* * Return the browser link labels for this browser card.)


    (NC.FetchUserDataProp Card (QUOTE BrowserLinkLabels))))

(NC.FetchBrowserFormat
  (LAMBDA (Card)                                             (* rht: "11-Feb-86 23:28")

          (* * Return the browser format for this browser card.)


    (NC.FetchUserDataProp Card (QUOTE BrowserFormat))))

(NC.FetchSpecialBrowserSpecs
  (LAMBDA (Card)                                             (* rht: "11-Feb-86 23:28")

          (* * Return the special browser specs for this browser card.)


    (NC.FetchUserDataProp Card (QUOTE SpecialBrowserSpecs))))

(NC.FetchBrowserDepth
  (LAMBDA (Card)                                             (* rht: "11-Feb-86 23:27")

          (* * Return the browser depth for this browser card.)


    (NC.FetchUserDataProp Card (QUOTE BrowserDepth))))

(NC.FetchBrowserSavedLinkingInfo
  (LAMBDA (Card)                                             (* rht: "11-Feb-86 23:27")

          (* * Return the special linking info for this browser card.)


    (NC.FetchUserDataProp Card (QUOTE BrowserSavedLinkingInfo))))

(NC.FetchBrowserLinksLegend
  (LAMBDA (Card)                                             (* rht: "11-Feb-86 23:27")

          (* * Return the links legend label pairs for this browser card.)


    (NC.FetchUserDataProp Card (QUOTE BrowserLinksLegend))))
)
(DEFINEQ

(NC.SetBrowserRootsInfo
  (LAMBDA (Card BrowserRootsInfo)                            (* rht: "11-Feb-86 23:30")

          (* * Set the browser card's browser roots pairs.)


    (NC.SetUserDataProp Card (QUOTE BrowserRootsInfo)
			  BrowserRootsInfo)))

(NC.SetBrowserLinkLabels
  (LAMBDA (Card BrowserLinkLabels)                           (* rht: "11-Feb-86 23:30")

          (* * Set the browser card's link labels.)


    (NC.SetUserDataProp Card (QUOTE BrowserLinkLabels)
			  BrowserLinkLabels)))

(NC.SetBrowserFormat
  (LAMBDA (Card BrowserFormat)                               (* rht: "11-Feb-86 23:30")

          (* * Set the browser card's format.)


    (NC.SetUserDataProp Card (QUOTE BrowserFormat)
			  BrowserFormat)))

(NC.SetSpecialBrowserSpecs
  (LAMBDA (Card SpecialBrowserSpecs)                         (* rht: "11-Feb-86 23:30")

          (* * Set the browser card's special browser specs.)


    (NC.SetUserDataProp Card (QUOTE SpecialBrowserSpecs)
			  SpecialBrowserSpecs)))

(NC.SetBrowserDepth
  (LAMBDA (Card BrowserDepth)                                (* rht: "11-Feb-86 23:29")

          (* * Set the browser card's depth.)


    (NC.SetUserDataProp Card (QUOTE BrowserDepth)
			  BrowserDepth)))

(NC.SetBrowserSavedLinkingInfo
  (LAMBDA (Card BrowserSavedLinkingInfo)                     (* rht: "20-Feb-86 11:44")

          (* * Set the browser special linking info.)



          (* * rht 2/20/86: Now returns the value we set to.)


    (NC.SetUserDataProp Card (QUOTE BrowserSavedLinkingInfo)
			  BrowserSavedLinkingInfo)
    BrowserSavedLinkingInfo))

(NC.SetBrowserLinksLegend
  (LAMBDA (Card BrowserLinksLegend)                          (* rht: "11-Feb-86 23:29")

          (* * Set the browser card's links legend label pairs.)


    (NC.SetUserDataProp Card (QUOTE BrowserLinksLegend)
			  BrowserLinksLegend)))
)
(DEFINEQ

(NC.ReadBrowserRootsInfo
  (LAMBDA (Stream)                                           (* rht: "20-Feb-86 14:34")

          (* * Read pairs of UIDs corresponding to card and notefile UIDs for each browser root. These pairs are bounded by 
	  left and right parens.)


    (LET (CharRead)
         (if (NEQ (SETQ CharRead (CHARACTER (BIN Stream)))
		      (QUOTE %())
	     then (NC.ReportError "NC.ReadBrowserRootsInfo" (CONCAT 
						       "Expected to read left paranthesis. Saw: "
									  CharRead)))
         (PROG1 (while (NEQ (CHARACTER (\PEEKBIN Stream))
				  (QUOTE %)))
		     eachtime (BLOCK) collect (CONS (NC.ReadUID Stream)
							    (NC.ReadUID Stream)))
		  (BIN Stream)))))

(NC.ReadBrowserLinkLabels
  (LAMBDA (Stream)                                           (* rht: "20-Feb-86 14:27")

          (* * Read list of link labels from notefile.)


    (PROG1 (READ Stream)
	     (BIN Stream))))

(NC.ReadBrowserFormat
  (LAMBDA (Stream)                                           (* rht: "20-Feb-86 14:27")

          (* * Read browser format from notefile.)


    (PROG1 (READ Stream)
	     (BIN Stream))))

(NC.ReadSpecialBrowserSpecs
  (LAMBDA (Stream)                                           (* rht: "20-Feb-86 14:27")

          (* * Read special browser specs from notefile.)


    (PROG1 (READ Stream)
	     (BIN Stream))))

(NC.ReadBrowserDepth
  (LAMBDA (Stream)                                           (* rht: "20-Feb-86 14:25")

          (* * Read depth from notefile.)


    (LET ((ThingRead (READ Stream)))
         (if (NOT (FIXP ThingRead))
	     then (NC.ReportError "NC.ReadBrowserFormat" (CONCAT 
							      "Expected to read a number.  Saw: "
								       ThingRead)))
                                                             (* Skip CR)
         (BIN Stream)
     ThingRead)))

(NC.ReadBrowserSavedLinkingInfo
  (LAMBDA (Stream)                                           (* rht: "20-Feb-86 14:36")

          (* * Read lists of info on multiple links between nodes. Each list consists of a UID cons'ed to a prop list of 
	  destination UIDs and link dashing info.)


    (LET (CharRead)
         (if (NEQ (SETQ CharRead (CHARACTER (BIN Stream)))
		      (QUOTE %())
	     then (NC.ReportError "NC.ReadBrowserSavedLinkingInfo" (CONCAT 
						       "Expected to read left paranthesis. Saw: "
										 CharRead)))
         (PROG1 (while (NEQ (CHARACTER (\PEEKBIN Stream))
				  (QUOTE %)))
		     eachtime (BLOCK) collect (NC.ReadBrowserSavedLinkingInfoForNode Stream))
                                                             (* Skip RightParen)
		  (BIN Stream)))))

(NC.ReadBrowserSavedLinkingInfoForNode
  (LAMBDA (Stream)                                           (* rht: "20-Feb-86 14:37")

          (* * Read list of info on multiple links for a particular node. In form of a source UID cons'ed to a prop list of 
	  destination UIDs and link dashing info.)


    (LET (CharRead SourceUID)
         (if (NEQ (SETQ CharRead (CHARACTER (BIN Stream)))
		      (QUOTE %())
	     then (NC.ReportError "NC.ReadBrowserSavedLinkingInfoForNode" (CONCAT 
						       "Expected to read left paranthesis. Saw: "
											CharRead)))
         (PROG1 (CONS (NC.ReadUID Stream)
			  (while (NEQ (CHARACTER (\PEEKBIN Stream))
					  (QUOTE %)))
			     eachtime (BLOCK) join (PROG1 (LIST (NC.ReadUID Stream)
									  (READ Stream))
                                                             (* Skip CR)
								  (BIN Stream))))
                                                             (* Skip RightParen)
		  (BIN Stream)))))

(NC.ReadBrowserLinksLegend
  (LAMBDA (Stream)                                           (* rht: "20-Feb-86 14:25")

          (* * Read links legend from notefile.)


    (PROG1 (READ Stream)
	     (BIN Stream))))
)
(DEFINEQ

(NC.WriteBrowserRootsInfo
  (LAMBDA (Stream BrowserRootUIDPairs)                       (* rht: " 6-Feb-86 23:30")

          (* * Write pairs of UIDs corresponding to card and notefile UIDs for each browser root. These pairs are bounded by 
	  left and right parens.)


    (PRIN1 (QUOTE %()
	     Stream)
    (for BrowserRootUIDPair in BrowserRootUIDPairs eachtime (BLOCK)
       do (NC.WriteUID Stream (CAR BrowserRootUIDPair))
	    (NC.WriteUID Stream (CDR BrowserRootUIDPair)))
    (PRIN1 (QUOTE %))
	     Stream)))

(NC.WriteBrowserLinkLabels
  (LAMBDA (Stream LinkLabels)                                (* rht: " 6-Feb-86 22:59")

          (* * Write list of link labels from notefile.)


    (PRINT LinkLabels Stream)))

(NC.WriteBrowserFormat
  (LAMBDA (Stream Format)                                    (* rht: " 6-Feb-86 23:03")

          (* * Write browser format to notefile.)


    (PRINT Format Stream)))

(NC.WriteSpecialBrowserSpecs
  (LAMBDA (Stream LinkLabels)                                (* rht: " 6-Feb-86 23:04")

          (* * Write special browser specs to notefile.)


    (PRINT LinkLabels Stream)))

(NC.WriteBrowserDepth
  (LAMBDA (Stream Depth)                                     (* rht: " 6-Feb-86 23:06")

          (* * Write depth to notefile.)


    (PRINT Depth Stream)))

(NC.WriteBrowserSavedLinkingInfo
  (LAMBDA (Stream BrowserSavedLinkingInfo)                   (* rht: " 7-Feb-86 00:29")

          (* * Write lists of info on multiple links between nodes. Each list consists of a UID cons'ed to a prop list of 
	  destination UIDs and link dashing info.)


    (PRIN1 (QUOTE %()
	     Stream)
    (for BrowserSavedLinkingInfoForNode in BrowserSavedLinkingInfo eachtime (BLOCK)
       do (NC.WriteBrowserSavedLinkingInfoForNode Stream BrowserSavedLinkingInfoForNode))
    (PRIN1 (QUOTE %))
	     Stream)))

(NC.WriteBrowserSavedLinkingInfoForNode
  (LAMBDA (Stream BrowserSavedLinkingInfoForNode)            (* rht: " 7-Feb-86 00:28")

          (* * Write list of info on multiple links for a particular node. In form of a source UID cons'ed to a prop list of 
	  destination UIDs and link dashing info.)


    (PRIN1 (QUOTE %()
	     Stream)
    (NC.WriteUID Stream (CAR BrowserSavedLinkingInfoForNode))
    (for SavedLinkInfo on (CDR BrowserSavedLinkingInfoForNode) by (CDDR SavedLinkInfo)
       eachtime (BLOCK)
       do (NC.WriteUID Stream (CAR SavedLinkInfo))
	    (PRINT (CADR SavedLinkInfo)
		     Stream))
    (PRIN1 (QUOTE %))
	     Stream)))

(NC.WriteBrowserLinksLegend
  (LAMBDA (Stream LinksLegend)                               (* rht: "20-Feb-86 14:30")

          (* * Write links legend to notefile.)


    (PRINT LinksLegend Stream)))
)
(PUTPROPS RHTPATCH026 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2971 6170 (NC.PutGraphSubstance 2981 . 4049) (NC.GetGraphSubstance 4051 . 4632) (
NC.UpdateLinkImagesInGraph 4634 . 6168)) (6224 54688 (NC.PutBrowserSubstance 6234 . 7810) (
NC.BringUpBrowserCard 7812 . 12501) (NC.AddBrowserCard 12503 . 13204) (NC.MakeBrowserCard 13206 . 
19784) (NC.UpdateBrowserCard 19786 . 29178) (NC.RelayoutBrowserCard 29180 . 35271) (
NC.ConnectNodesInBrowser 35273 . 41593) (NC.UnconnectNodesInBrowser 41595 . 44197) (
NC.ExpandBrowserNode 44199 . 52398) (NC.ChangeBrowserSpecs 52400 . 53595) (NC.GraphLinkIconUpdateCheck
 53597 . 54686)) (54689 55678 (NC.SetBrowserRoots 54699 . 55214) (NC.FetchBrowserRoots 55216 . 55676))
 (55679 69841 (NC.BrowserAddLink 55689 . 62145) (NC.BrowserDeleteCard 62147 . 64333) (
NC.BrowserRemoveNode 64335 . 69839)) (69969 73909 (NC.DelReferencesToCardFromBrowser 69979 . 71285) (
NC.NewBrowserNodeUIDFromOldUID 71287 . 71836) (NC.GetBrowserSubstance 71838 . 72727) (
NC.ComputeBrowserSavedLinkingInfo 72729 . 73467) (NC.ComputeBrowserSavedLinkingInfoForNode 73469 . 
73907)) (73910 75802 (NC.FetchBrowserRootsInfo 73920 . 74189) (NC.FetchBrowserLinkLabels 74191 . 74458
) (NC.FetchBrowserFormat 74460 . 74714) (NC.FetchSpecialBrowserSpecs 74716 . 74989) (
NC.FetchBrowserDepth 74991 . 75242) (NC.FetchBrowserSavedLinkingInfo 75244 . 75524) (
NC.FetchBrowserLinksLegend 75526 . 75800)) (75803 77819 (NC.SetBrowserRootsInfo 75813 . 76086) (
NC.SetBrowserLinkLabels 76088 . 76356) (NC.SetBrowserFormat 76358 . 76609) (NC.SetSpecialBrowserSpecs 
76611 . 76895) (NC.SetBrowserDepth 76897 . 77144) (NC.SetBrowserSavedLinkingInfo 77146 . 77531) (
NC.SetBrowserLinksLegend 77533 . 77817)) (77820 82110 (NC.ReadBrowserRootsInfo 77830 . 78629) (
NC.ReadBrowserLinkLabels 78631 . 78874) (NC.ReadBrowserFormat 78876 . 79110) (
NC.ReadSpecialBrowserSpecs 79112 . 79359) (NC.ReadBrowserDepth 79361 . 79884) (
NC.ReadBrowserSavedLinkingInfo 79886 . 80779) (NC.ReadBrowserSavedLinkingInfoForNode 80781 . 81869) (
NC.ReadBrowserLinksLegend 81871 . 82108)) (82111 85117 (NC.WriteBrowserRootsInfo 82121 . 82708) (
NC.WriteBrowserLinkLabels 82710 . 82932) (NC.WriteBrowserFormat 82934 . 83141) (
NC.WriteSpecialBrowserSpecs 83143 . 83367) (NC.WriteBrowserDepth 83369 . 83565) (
NC.WriteBrowserSavedLinkingInfo 83567 . 84161) (NC.WriteBrowserSavedLinkingInfoForNode 84163 . 84898) 
(NC.WriteBrowserLinksLegend 84900 . 85115)))))
STOP