DIRECTORY Graph USING [Entity, EntityList, Text, Texts], GraphCleanUp USING [CleanUpSDL], GraphPrivate USING [GraphAtomProc, GraphHandle, PaintEntity, PaintText], GraphUtil USING [ControllerNotNil, PanelIndexedEntity, PanelIndexedText, RaiseError]; GraphRemove: CEDAR PROGRAM IMPORTS GraphCleanUp, GraphPrivate, GraphUtil EXPORTS GraphPrivate = { OPEN Graph, GraphPrivate, GraphUtil; PanelRemove: PUBLIC GraphAtomProc = { -- invoked by buttons on panel. IF ControllerNotNil[handle.controller] THEN { OPEN handle; SELECT atom FROM $Text => RemoveText[handle, PanelIndexedText[controller, graph.texts]]; $Entity => RemoveEntity[handle, PanelIndexedEntity[controller, graph.entityList]]; ENDCASE => RaiseError[$UnknownAtom, "in PanelRemove"]; }; }; -- PanelRemove RemoveText: PUBLIC PROC[handle: GraphHandle _ NIL, text: Text _ NIL] = { OPEN handle; IF text # NIL THEN { painted: BOOL _ FALSE; FOR ts: Texts _ graph.texts, ts.rest UNTIL ts = NIL DO IF ts.first = text THEN painted _ TRUE; ENDLOOP; IF painted THEN { graph.texts _ RemoveTextFromList[text, graph.texts]; IF chart.viewer # NIL THEN PaintText[handle, erase, text]; }; }; }; -- RemoveText RemoveEntity: PUBLIC PROC[handle: GraphHandle _ NIL, entity: Entity _ NIL] = { OPEN handle; IF entity # NIL THEN { painted: BOOL _ FALSE; FOR el: EntityList _ graph.entityList, el.rest UNTIL el = NIL DO IF el.first = entity THEN painted _ TRUE; ENDLOOP; IF painted THEN { graph.entityList _ RemoveEntityFromList[entity, graph.entityList]; IF chart.viewer # NIL THEN PaintEntity[handle, erase, entity]; entity.segments _ GraphCleanUp.CleanUpSDL[entity.segments]; }; }; }; -- RemoveEntity RemoveTextFromList: PROC [text: Text _ NIL, old: Texts _ NIL] RETURNS [new: Texts _ NIL] = { ts: Texts _ new _ old; IF ts # NIL THEN { IF ts.first = text THEN new _ ts.rest ELSE UNTIL ts.rest = NIL DO IF ts.rest.first = text THEN {ts.rest _ ts.rest.rest; EXIT}; ts _ ts.rest; ENDLOOP; }; }; -- RemoveTextFromList RemoveEntityFromList: PROC [entity: Entity _ NIL, old: EntityList _ NIL] RETURNS [new: EntityList _ NIL]= { el: EntityList _ new _ old; IF el # NIL THEN { IF el.first = entity THEN new _ el.rest ELSE UNTIL el = NIL DO IF el.rest.first = entity THEN {el.rest _ el.rest.rest; EXIT}; el _ el.rest; ENDLOOP; }; }; -- RemoveEntityFromList }. LOG. SChen, created at October 9, 1985 6:51:03 pm PDT. šGraphRemove.mesa, Copyright c 1985 by Xerox Corporation. All rights reserved. Last Edited by: Sweetsun Chen, October 16, 1985 4:12:38 pm PDT If handle = nil or controller = nil then error; otherwise: removes text or entity from graph data, and, if chart.viewer # nil, erase it from display. IF controller # NIL THEN { ViewerTools.SetContents[controller.textId, Convert.RopeFromInt[text.id]]; Resume[handle, $Text]; }; IF controller # NIL THEN { ViewerTools.SetContents[controller.entityId, Convert.RopeFromInt[entity.id]]; Resume[handle, $Entity]; }; noop if either entity or entityList is nil; or if entity is not on old. RemoveEntityFromHash[entity, hash] Κ¨˜JšœΟmœ1™Nšœ™Icode™.—J˜šΟk ˜ Jšœžœ#˜.Jšœ žœ˜ Jšœ žœ6˜HJšœ žœF˜U—J˜šœ žœž˜Jšžœ%˜-Jšžœžœ ˜=—J˜šœ žœΟc˜E™:Jšœ'™'Jšœ2™2—šžœ%žœžœ˜:šžœž˜JšœG˜GJšœR˜RJšžœ/˜6—J˜—JšœŸ˜—J˜š Οn œžœžœžœžœžœ˜Ušžœžœžœ˜Jšœ žœžœ˜šžœ"žœžœž˜6Jšžœžœ žœ˜'Jšžœ˜—šžœ žœ˜Jšœ4˜4Jšžœžœžœ ˜:J˜šžœžœžœ™J™IJšœ™J™——J˜—JšœŸ ˜—J˜š   œžœžœžœžœžœ˜[šžœ žœžœ˜Jšœ žœžœ˜šžœ,žœžœž˜@Jšžœžœ žœ˜)Jšžœ˜—šžœ žœ˜JšœB˜BJšžœžœžœ$˜>Jšœ;˜;J˜šžœžœžœ™J™MJšœ™J™——J˜—JšœŸ˜—˜š  œžœžœžœžœžœ˜\J˜šžœžœžœ˜š žœžœžœžœ žœž˜AJšžœžœžœ˜Jšžœžœžœ˜>Jšœ ˜ Jšžœ˜—J˜—JšœŸ˜—J˜J™"—J˜J˜šžœ˜J˜1——…— .p