DIRECTORY Graph USING [Entity, EntityList, GraphHandle, GraphProc, Text, Texts], GraphCleanUp USING [CleanUpEL, CleanUpSDL], GraphPrivate USING [GraphAtomProc, PaintAll, PaintEntity, PaintLegend, PaintText], GraphUtil USING [ControllerNotNil, SpecIndexedEntity, SpecIndexedText, RaiseError]; GraphRemove: CEDAR PROGRAM IMPORTS GraphCleanUp, GraphPrivate, GraphUtil EXPORTS GraphPrivate = { OPEN Graph, GraphPrivate, GraphUtil; SpecRemove: PUBLIC GraphAtomProc = { -- invoked by buttons on panel. IF ControllerNotNil[handle.controller] THEN { OPEN handle; SELECT atom FROM $Text => RemoveText[handle, SpecIndexedText[controller, graph.texts]]; $Entity => RemoveEntity[handle, SpecIndexedEntity[controller, graph.entityList]]; ENDCASE => RaiseError[$UnknownAtom, "in SpecRemove"]; }; }; -- SpecRemove 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 { next: Entity; [graph.entityList, next] _ RemoveEntityFromList[entity, graph.entityList]; IF chart.viewer # NIL THEN { PaintEntity[handle, erase, entity, TRUE]; PaintLegend[handle, paint, next, FALSE]; -- packing them }; 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, next: Entity _ NIL]= { el: EntityList _ new _ old; IF el # NIL THEN { IF el.first = entity THEN { new _ el.rest; next _ IF new = NIL THEN NIL ELSE new.first; } ELSE UNTIL el = NIL DO IF el.rest.first = entity THEN { el.rest _ el.rest.rest; next _ IF el.rest = NIL THEN NIL ELSE el.rest.first; EXIT; }; el _ el.rest; ENDLOOP; }; }; -- RemoveEntityFromList RemoveAllCurves: PUBLIC GraphProc = { OPEN handle; FOR el: EntityList _ graph.entityList, el.rest UNTIL el = NIL DO el.first.segments _ GraphCleanUp.CleanUpSDL[el.first.segments]; ENDLOOP; graph.entityList _ GraphCleanUp.CleanUpEL[graph.entityList, FALSE]; PaintAll[handle, TRUE]; }; -- RemoveAllCurves }. LOG. SChen, created at October 9, 1985 6:51:03 pm PDT. hGraphRemove.mesa, Copyright c 1985 by Xerox Corporation. All rights reserved. Last Edited by: Sweetsun Chen, November 20, 1985 2:49:51 pm PST 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]; }; Check if it is indeed plotted. If plotted then {Remove it from graph.entityList. If plot exits, erase it, and pack lengend.}. lets leave the x's segments there. 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. clean up plotted curves from graph viewer. RemoveEntityFromHash[entity, hash] Κ†˜JšœΟmœ1™Nšœ™Icode™/—J˜šΟk ˜ Jšœžœ;˜FJšœ žœ˜+Jšœ žœ@˜RJšœ žœD˜S—J˜šœ žœž˜Jšžœ%˜-Jšžœžœ ˜=—J˜šœ žœΟc˜D™:Jšœ'™'Jšœ2™2—šžœ%žœžœ˜:šžœž˜JšœF˜FJšœQ˜QJšžœ.˜5—J˜—JšœŸ ˜—J˜š Οn œžœžœžœžœžœ˜Ušžœžœžœ˜Jšœ žœžœ˜šžœ"žœžœž˜6Jšžœžœ žœ˜'Jšžœ˜—šžœ žœ˜Jšœ4˜4Jšžœžœžœ ˜:J˜šžœžœžœ™J™IJšœ™J™——J˜—JšœŸ ˜—J˜š   œžœžœžœžœžœ˜[J™}šžœ žœžœ˜Jšœ žœžœ˜šžœ,žœžœž˜@Jšžœžœ žœ˜)Jšžœ˜—šžœ žœ˜J˜ JšœJ˜Jšžœžœžœ˜Jšœ#žœ˜)Jšœ!žœŸ˜8J˜—šœ;˜;J™"—J˜šžœžœžœ™J™MJšœ™J™——J˜—JšœŸ˜—˜š  œžœžœžœžœžœ˜\J˜šžœžœžœ˜š žœžœžœžœ žœž˜AJšžœžœžœ˜