<> <> <> 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, text, erase]; }; <> <> <> <<};>> }; }; -- 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, entity, TRUE, erase]; PaintLegend[handle, next, paint, FALSE]; -- packing them }; entity.segments _ GraphCleanUp.CleanUpSDL[entity.segments]; entity.lastSegment _ NIL; <> }; <> <> <> <<};>> }; }; -- 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]; el.first.lastSegment _ NIL; ENDLOOP; graph.entityList _ GraphCleanUp.CleanUpEL[graph.entityList, FALSE]; PaintAll[handle, TRUE, FALSE, TRUE]; }; -- RemoveAllCurves <<>> <> }. LOG. SChen, created at October 9, 1985 6:51:03 pm PDT.