<> <> <> <> DIRECTORY CD, CDInstances, CDCallSpecific, CDCells, CDCommandOps, CDDirectory, CDOps, CDOrient, CDProperties, CDRepetitions, CDSequencer, Rope, TerminalIO; CDRepetitionCommands: CEDAR PROGRAM IMPORTS CDInstances, CDCallSpecific, CDCells, CDCommandOps, CDDirectory, CDOps, CDOrient, CDProperties, CDRepetitions, CDSequencer, TerminalIO = BEGIN MakeRepetition: PROC [comm: CDSequencer.Command] = BEGIN sel: CD.InstanceList; ob: CD.Object; offset, location: CD.Position; count: INT; first: CD.Instance; multiple: BOOL; TerminalIO.WriteRope["make a repetition "]; [first, multiple] _ CDOps.SelectedInstance[comm.design]; IF first=NIL THEN {TerminalIO.WriteRope["no selected object\n"]; RETURN}; count _ TerminalIO.RequestInt["number: "]; IF count<1 OR count>=LAST[NAT] THEN {TerminalIO.WriteRope["bad number\n"]; RETURN}; IF count>=257 THEN {TerminalIO.WriteRope["don't exagerate\n"]; RETURN}; IF multiple THEN { [done: multiple, cellOb: ob] _ CDCells.CreateCellSelected[comm.design, "-dummy"]; IF NOT multiple THEN {TerminalIO.WriteRope["not done\n"]; RETURN}; }; [selected: sel, others: comm.design.actual.first.specific.contents] _ CDInstances.SplitSelected[comm.design.actual.first.specific.contents]; IF sel.first=NIL OR sel.rest#NIL THEN ERROR; -- therefore sel#NIL ! offset _ [comm.pos.x-comm.sPos.x, comm.pos.y-comm.sPos.y]; ob _ CDRepetitions.CreateRepetition[comm.design, sel.first.ob, count, offset, sel.first.orientation]; location _ sel.first.location; IF offset.x<0 THEN location.x _ location.x+(count-1)*offset.x; IF offset.y<0 THEN location.y _ location.y+(count-1)*offset.y; CDOps.AddAnObject[comm.design, ob, location, CDOrient.original]; END; ChangeRepetition: PROC [comm: CDSequencer.Command] = BEGIN inst: CD.Instance = CDCommandOps.TheInstance[comm, "change a repetition "]; IF inst#NIL THEN IF ~ISTYPE[inst.ob.specificRef, CDRepetitions.RepPtr] THEN TerminalIO.WriteRope["selected ob not a repetition"] ELSE { offset: CD.Position = [comm.pos.x-comm.sPos.x, comm.pos.y-comm.sPos.y]; rp: CDRepetitions.RepPtr = NARROW[inst.ob.specificRef]; CDCommandOps.RedrawInstance[comm.design, inst]; inst.ob _ CDRepetitions.CreateRepetition[comm.design, rp.ob, rp.count, offset, CDOrient.ComposeOrient[rp.orientation, inst.orientation]]; inst.orientation _ CDOrient.original; CDCommandOps.RedrawInstance[comm.design, inst, FALSE]; TerminalIO.WriteRope[" done\n"] }; END; TransformToCellS: PROC [comm: CDSequencer.Command] = BEGIN n: NAT; TerminalIO.WriteRope["transform to cell\n"]; n _ CDCallSpecific.CallForSelected[design: comm.design, objectSpecific: $TransformToCell, whatElse: TransformOthers]; TerminalIO.WriteInt[n]; TerminalIO.WriteRope[" objects transformed\n"]; END; TransformOthers: PROC [design: CD.Design, inst: CD.Instance, x: REF] RETURNS [done: BOOL_TRUE, removeMe: BOOL_FALSE, include: CD.InstanceList_NIL, repaintMe: BOOL_FALSE, repaintInclude: BOOL_FALSE] = BEGIN IF inst.ob.class.inDirectory AND ~CDCells.IsCell[inst.ob] THEN { cob: CD.Object _ CDDirectory.Expand[inst.ob, design, design]; done _ cob#NIL; IF done THEN { removeMe _ TRUE; repaintMe _ TRUE; include _ LIST[NEW[CD.InstanceRep _ [ ob: cob, location: inst.location, orientation: inst.orientation, selected: inst.selected, properties: CDProperties.CopyProps[inst.properties] ]]]; repaintInclude _ TRUE; } }; END; <> <> <> <> <<--we make a list first, otherwise: directory changes while the enumeration>> <<>> <> <<-- PROC [name: Rope.ROPE, ob: CD.Object] RETURNS [quit: BOOL_FALSE]>> <> <> < repList _ CONS[ob, repList];>> < NULL>> <> <<>> <> <<[] _ CDDirectory.Enumerate[design: comm.design, action: FindRepetitions];>> <> <> <> <> <> <> <<[] _ CDDirectory.Remove[design: comm.design, name: name, expectObject: list.first];>> <<[] _ CDDirectory.Rename[design: comm.design, object: rCell, newName: name];>> <> <> <> <<};>> <> <> <> <<>> <<>> CDSequencer.ImplementCommand[$DrawRepetition, MakeRepetition]; CDSequencer.ImplementCommand[$ChangeRepetition, ChangeRepetition]; CDSequencer.ImplementCommand[$TransformToCellS, TransformToCellS]; END.