CDMoveCopyCommands.mesa (part of ChipNDale)
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi, July 11, 1983 3:42 pm
last edited Christian Jacobi, January 28, 1985 10:58:38 am PST
DIRECTORY
CD,
CDSimpleOps,
CDOrient,
CDSequencer,
CDValue,
Rope,
TerminalIO;
CDMoveCopyCommands: CEDAR PROGRAM
IMPORTS CDSimpleOps, CDSequencer, CDValue, TerminalIO =
BEGIN
TransformS: PROC [comm: CDSequencer.Command] =
BEGIN
n: CARDINAL;
TerminalIO.WriteRope["Transform selected: "];
n ← TerminalIO.RequestSelection[
label: "transform selected",
choice: LIST["mirror x", "mirror y", "rot 90", "rot 180", "rot 270"]];
SELECT n FROM
1 => {TerminalIO.WriteRope["mirror x\n"];
CDSimpleOps.TransformSelected[comm.design, CDOrient.mirrorX]};
2 => {TerminalIO.WriteRope["mirror y\n"];
CDSimpleOps.TransformSelected[comm.design, CDOrient.rotate180];
CDSimpleOps.TransformSelected[comm.design, CDOrient.mirrorX];};
3 => {TerminalIO.WriteRope["rot 90\n"];
CDSimpleOps.TransformSelected[comm.design, CDOrient.rotate90]};
4 => {TerminalIO.WriteRope["rot 180\n"];
CDSimpleOps.TransformSelected[comm.design, CDOrient.rotate180]};
5 => {TerminalIO.WriteRope["rot 270\n"];
CDSimpleOps.TransformSelected[comm.design, CDOrient.rotate270]};
ENDCASE => TerminalIO.WriteRope["Skipped\n"];
END;
RotS: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Rotate selected\n"];
CDSimpleOps.TransformSelected[comm.design, CDOrient.rotate90]
END;
MirrorS: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Mirror selected\n"];
CDSimpleOps.TransformSelected[comm.design, CDOrient.mirrorX]
END;
MirrorYS: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Mirror selected y\n"];
CDSimpleOps.TransformSelected[comm.design, CDOrient.rotate180+CDOrient.mirrorX];
END;
StretchyMoveSCommand: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Move selected stretchy\n"];
CDSimpleOps.MoveSelected[design: comm.design, offset: CD.DesignPosition[comm.pos.x-comm.sPos.x, comm.pos.y-comm.sPos.y], stretchy: yes]
END;
SimpleMoveSCommand: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Move selected (no stretch)\n"];
CDSimpleOps.MoveSelected[design: comm.design, offset: CD.DesignPosition[comm.pos.x-comm.sPos.x, comm.pos.y-comm.sPos.y], stretchy: no]
END;
AutoMoveSCommand: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Move selected\n"];
CDSimpleOps.MoveSelected[design: comm.design, offset: CD.DesignPosition[comm.pos.x-comm.sPos.x, comm.pos.y-comm.sPos.y], stretchy: option]
END;
CopySCommand: PROC [comm: CDSequencer.Command] =
BEGIN
IF comm.pos.x#comm.sPos.x OR comm.pos.y#comm.sPos.y THEN {
TerminalIO.WriteRope["Copy selected\n"];
CDSimpleOps.CopySelected[comm.design,
CD.DesignPosition[comm.pos.x-comm.sPos.x, comm.pos.y-comm.sPos.y]]
}
ELSE TerminalIO.WriteRope["no copy in place\n"];
END;
StepValue: PROC[design: CD.Design] RETURNS [CD.DesignNumber] =
BEGIN
RETURN [CD.lambda*MAX[CDValue.FetchInt[boundTo: design, key: $CDxStepValue, propagation: global], 1]]
END;
LambdaUpS: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Move selected step up\n"];
CDSimpleOps.MoveSelected[comm.design, CD.DesignPosition[0, StepValue[comm.design]], no]
END;
LambdaDownS: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Move selected step down\n"];
CDSimpleOps.MoveSelected[comm.design, CD.DesignPosition[0, -StepValue[comm.design]], no]
END;
LambdaLeftS: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Move selected step left\n"];
CDSimpleOps.MoveSelected[comm.design, CD.DesignPosition[-StepValue[comm.design], 0], no]
END;
LambdaRightS: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Move selected step right\n"];
CDSimpleOps.MoveSelected[comm.design, CD.DesignPosition[StepValue[comm.design], 0], no]
END;
StretchyMoveStepUpS: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Stretchy move selected step up\n"];
CDSimpleOps.MoveSelected[comm.design, CD.DesignPosition[0, StepValue[comm.design]], yes]
END;
StretchyMoveStepDownS: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Stretchy move selected step down\n"];
CDSimpleOps.MoveSelected[comm.design, CD.DesignPosition[0, -StepValue[comm.design]], yes]
END;
StretchyMoveStepLeftS: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Stretchy move step left\n"];
CDSimpleOps.MoveSelected[comm.design, CD.DesignPosition[-StepValue[comm.design], 0], yes]
END;
StretchyMoveStepRightS: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Stretchy move step right\n"];
CDSimpleOps.MoveSelected[comm.design, CD.DesignPosition[StepValue[comm.design], 0], yes]
END;
RenameDesign: PROC [comm: CDSequencer.Command] =
BEGIN ENABLE TerminalIO.UserAbort => CONTINUE;
name: Rope.ROPE;
TerminalIO.WriteRope["Rename design "]; TerminalIO.WriteRope[comm.design.name]; TerminalIO.WriteLn;
name ← TerminalIO.RequestRope["enter name: "];
CDSimpleOps.RenameDesign[comm.design, name];
END;
Impl: PROC [] =
BEGIN
CDValue.StoreInt[boundTo: NIL, key: $CDxStepValue, value: 1];
CDSequencer.ImplementCommand[$StretchyMoveS, StretchyMoveSCommand];
CDSequencer.ImplementCommand[$MoveS, SimpleMoveSCommand];
CDSequencer.ImplementCommand[$AutMoveS, AutoMoveSCommand];
CDSequencer.ImplementCommand[$CopyS, CopySCommand];
CDSequencer.ImplementCommand[$LambdaUpS, LambdaUpS];
CDSequencer.ImplementCommand[$StretchyMoveStepUpS, StretchyMoveStepUpS];
CDSequencer.ImplementCommand[$LambdaDownS, LambdaDownS];
CDSequencer.ImplementCommand[$StretchyMoveStepDownS, StretchyMoveStepDownS];
CDSequencer.ImplementCommand[$LambdaLeftS, LambdaLeftS];
CDSequencer.ImplementCommand[$StretchyMoveStepLeftS, StretchyMoveStepLeftS];
CDSequencer.ImplementCommand[$LambdaRightS, LambdaRightS];
CDSequencer.ImplementCommand[$StretchyMoveStepRightS, StretchyMoveStepRightS];
CDSequencer.ImplementCommand[$RotS, RotS];
CDSequencer.ImplementCommand[$MirrorYS, MirrorYS];
CDSequencer.ImplementCommand[$MirrorS, MirrorS];
CDSequencer.ImplementCommand[$TransformS, TransformS];
CDSequencer.ImplementCommand[$RenameDesign, RenameDesign];
END;
Impl[];
END.