CDSatellitesCommands.mesa
Copyright © 1985, 1986 by Xerox Corporation. All rights reserved.
Written by: Christian Jacobi, August 29, 1986 9:55:02 pm PDT
This module is descended from the early implementation of satellites by Monier. It has been
rewritten a number of times since then by Sindhu and Serlet to find an implementation that
is comfortable to use both from programs and interactively. This last version is a complete
rewrite by Jacobi, one hopes for the last time!
Old version by: Pradeep Sindhu December 20, 1985 1:25:44 pm PST
Old version by: Pradeep Sindhu March 26, 1986 3:21:40 pm PST
Old version by: Bertrand Serlet August 17, 1986 0:49:00 am PDT
Old version by: Christian Jacobi, July 15, 1986 1:59:30 pm PDT
Old version by: Jean-Marc Frailong July 28, 1986 6:45:49 pm PDT
Last edited by: Christian Jacobi, October 30, 1986 11:56:04 am PST
DIRECTORY
CD, CDInstances, CDOps, CDPanelFonts, CDSatellites, CDSequencer, CDTexts, IO, Rope, TerminalIO;
CDSatellitesCommands: CEDAR PROGRAM
IMPORTS CDInstances, CDOps, CDPanelFonts, CDSatellites, CDSequencer, CDTexts, IO, TerminalIO =
BEGIN
SelectWithMaster: PROC [design: CD.Design, master: REF, deselectOthers: BOOLTRUE] RETURNS [n: INT𡤀] = {
FOR w: CD.InstanceList ← CDOps.InstList[design], w.rest WHILE w#NIL DO
IF CDTexts.IsText[w.first.ob] AND CDSatellites.IsAssociated[master, w.first] THEN {
n ← n+1; SelectInst[design, w.first]
}
ELSE IF master=w.first THEN SelectInst[design, w.first]
ELSE DeSelectInst[design, w.first]
ENDLOOP;
};
SelectObjectSatellitesComm: PROC [comm: CDSequencer.Command] = {
n: INT;
ob: CD.Object ← CDOps.PushedTopCell[comm.design];
[] ← CDSatellites.GetSatellites[ob]; --reinstalls invariants
n ← SelectWithMaster[comm.design, ob];
TerminalIO.PutF[" %g satellites(s) in group.\n", IO.int[n]];
};
SelectInstanceSatellitesComm: PROC [comm: CDSequencer.Command] = {
n: INT; selOrMaster: REF←NIL;
selected: CD.Instance ← CDOps.TheInstance[comm.design, "select satelites for "];
IF selected#NIL THEN {
ob: CD.Object ← CDOps.PushedTopCell[comm.design];
[] ← CDSatellites.GetSatellites[ob]; --reinstalls invariants
IF CDTexts.IsText[selected.ob] THEN {
WITH CDSatellites.GetMaster[ob, selected] SELECT FROM
i: CD.Instance => {selOrMaster ← i; TerminalIO.PutRope["instance satellites"]};
o: CD.Object => {selOrMaster ← o; TerminalIO.PutRope["object satellites"]};
ENDCASE => {selOrMaster ← NIL; TerminalIO.PutRope["non satellite texts"]};
}
ELSE {selOrMaster ← selected; TerminalIO.PutRope["instance satellites"]};
}
ELSE {selOrMaster ← NIL; TerminalIO.PutRope[" select non satellite texts"]};
n ← SelectWithMaster[comm.design, selOrMaster];
TerminalIO.PutF[" %g satellite(s) in group.\n", IO.int[n]];
};
SetInstanceSatellites: PROC [design: CD.Design, exclusive: BOOL] RETURNS [n: INT𡤀] = {
satellites: CD.InstanceList ← NIL; master: CD.Instance ← NIL;
ob: CD.Object ← CDOps.PushedTopCell[design];
[] ← CDSatellites.GetSatellites[ob]; --reinstalls invariants
FOR w: CD.InstanceList ← CDOps.InstList[design], w.rest WHILE w#NIL DO
IF w.first.selected THEN {
IF CDTexts.IsText[w.first.ob] THEN satellites ← CONS[w.first, satellites]
ELSE {
IF master#NIL THEN CDSequencer.Quit["failed: more than one master selected"];
master ← w.first
}
}
ENDLOOP;
IF master=NIL THEN CDSequencer.Quit["failed: no master selected"];
IF exclusive THEN CDSatellites.Associate[master, NIL];
FOR w: CD.InstanceList ← satellites, w.rest WHILE w#NIL DO
n ← n+1;
CDSatellites.Associate[master, w.first];
ENDLOOP;
};
SetObjectSatellites: PROC [design: CD.Design, exclusive: BOOL] RETURNS [n: INT𡤀] = {
ob: CD.Object ← CDOps.PushedTopCell[design];
[] ← CDSatellites.GetSatellites[ob]; --reinstalls invariants
IF exclusive THEN CDSatellites.Associate[ob, NIL];
FOR w: CD.InstanceList ← CDOps.InstList[design], w.rest WHILE w#NIL DO
IF w.first.selected AND CDTexts.IsText[w.first.ob] THEN {
CDSatellites.Associate[ob, w.first];
n ← n+1;
};
ENDLOOP;
};
InclusiveInstanceSatellitesComm: PROC [comm: CDSequencer.Command] = {
TerminalIO.PutRope["set instance satellites inclusive\n"];
[] ← SetInstanceSatellites[comm.design, FALSE];
};
ExclusiveInstanceSatellitesComm: PROC [comm: CDSequencer.Command] = {
n: INT;
TerminalIO.PutRope["set object satellites exclusive\n"];
n ← SetInstanceSatellites[comm.design, TRUE];
TerminalIO.PutF[" %g satellite(s) in group.\n", IO.int[n]];
};
InclusiveObjectSatellitesComm: PROC [comm: CDSequencer.Command] = {
TerminalIO.PutRope["set object satellites inclusive\n"];
[] ← SetObjectSatellites[comm.design, FALSE];
};
ExclusiveObjectSatellitesComm: PROC [comm: CDSequencer.Command] = {
n: INT;
TerminalIO.PutRope["set object satellites exclusive\n"];
n ← SetObjectSatellites[comm.design, TRUE];
TerminalIO.PutF[" %g satellite(s) in group.\n", IO.int[n]];
};
GetTextPart: PROC [comm: CDSequencer.Command, r: Rope.ROPE] RETURNS [i: CD.Instance] = {
--quits command if no success
ob: CD.Object; f: CDTexts.CDFont;
name: Rope.ROPE ← TerminalIO.RequestRope[r];
f ← CDPanelFonts.CurrentFont[comm.design];
IF f=NIL THEN CDSequencer.Quit["failed: no current font"];
IF name=NIL THEN CDSequencer.Quit["failed: empty text"];
ob ← CDTexts.Create[name, f, CD.commentLayer, TRUE];
IF ob=NIL THEN CDSequencer.Quit["failed: text not created"];
i ← CDInstances.NewInst[ob, [comm.pos]];
CDOps.IncludeInstance[comm.design, i];
};
DrawInstanceSatelliteComm: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance ← CDOps.TheInstance[comm.design, "draw satellite to master\n"];
IF selected#NIL THEN {
inst: CD.Instance;
ob: CD.Object ← CDOps.PushedTopCell[comm.design];
[] ← CDSatellites.GetSatellites[ob]; --reinstalls invariants
IF CDTexts.IsText[selected.ob] THEN
CDSequencer.Quit["failed: selected instance is text, can't put a satellite on texts\n"];
inst ← GetTextPart[comm, "type instance satellite: "];
CDSatellites.Associate[selected, inst];
};
};
DrawObjectSatelliteComm: PROC [comm: CDSequencer.Command] = {
ob: CD.Object ← CDOps.PushedTopCell[comm.design];
text: CD.Instance ← GetTextPart[comm, "type object satellite: "];
[] ← CDSatellites.GetSatellites[ob]; --reinstalls invariants
CDSatellites.Associate[ob, text];
};
UnSatelliteComm: PROC [comm: CDSequencer.Command] = {
TerminalIO.PutRope["remove satellite association for selected\n"];
FOR w: CD.InstanceList ← CDOps.InstList[comm.design], w.rest WHILE w#NIL DO
IF w.first.selected THEN CDSatellites.Associate[w.first, NIL];
ENDLOOP;
};
--general utilities
SelectInst: PROC [design: CD.Design, inst: CD.Instance] = {
IF ~inst.selected THEN {
inst.selected←TRUE;
CDOps.RedrawInstance[design, inst];
}
};
DeSelectInst: PROC [design: CD.Design, inst: CD.Instance] = {
IF inst.selected THEN {
inst.selected←FALSE;
CDOps.RedrawInstance[design, inst, TRUE];
}
};
CDSequencer.ImplementCommand[$SelectInstanceGroup, SelectInstanceSatellitesComm,, doQueue];
CDSequencer.ImplementCommand[$SelectObjectGroup, SelectObjectSatellitesComm,, doQueue];
CDSequencer.ImplementCommand[$AddInstanceSatellite, DrawInstanceSatelliteComm,, doQueueAndMark];
CDSequencer.ImplementCommand[$AddObjectSatellite, DrawObjectSatelliteComm,, doQueueAndMark];
CDSequencer.ImplementCommand[$SetInstanceSatellites, InclusiveInstanceSatellitesComm,, doQueueAndMark];
CDSequencer.ImplementCommand[$SetInstanceSatellitesExclusive, ExclusiveInstanceSatellitesComm,, doQueueAndMark];
CDSequencer.ImplementCommand[$SetObjectSatellites, InclusiveObjectSatellitesComm,, doQueueAndMark];
CDSequencer.ImplementCommand[$SetObjectSatellitesExclusive, ExclusiveObjectSatellitesComm,, doQueueAndMark];
CDSequencer.ImplementCommand[$UnSatellite, UnSatelliteComm,, doQueueAndMark];
[] ← CDPopUpMenus.MakeMenu[$SatellitesMenu, "Satellites Menu", "Satellites Menu"];
CDCommandOps.RegisterWithMenu[menu: $SatellitesMenu,
entry: "select instance satellites",
doc: "<I-Left>",
proc: SelectInstanceSatellitesComm,
key: $SelectInstanceGroup,
queue: doQueue
];
CDCommandOps.RegisterWithMenu[menu: $SatellitesMenu,
entry: "select object satellites",
proc: SelectObjectSatellitesComm,
doc: "<O-Left>",
key: $SelectObjectGroup,
queue: doQueue
];
CDCommandOps.RegisterWithMenu[menu: $SatellitesMenu,
entry: "draw instance satellite",
proc: DrawInstanceSatelliteComm,
doc: "<I-Middle>",
key: $AddInstanceSatellite,
queue: doQueueAndMark
];
CDCommandOps.RegisterWithMenu[menu: $SatellitesMenu,
entry: "draw object satellite",
proc: DrawObjectSatelliteComm,
doc: "<O-Middle>",
key: $AddObjectSatellite,
queue: doQueueAndMark
];
CDCommandOps.RegisterWithMenu[menu: $SatellitesMenu,
entry: "set instance satellites inclusive",
proc: InclusiveInstanceSatellitesComm,
doc: "<I-Right>; adds instance satellites",
key: $SetInstanceSatellites,
queue: doQueueAndMark
];
CDCommandOps.RegisterWithMenu[menu: $SatellitesMenu,
entry: "set instance satellites exclusive",
proc: ExclusiveInstanceSatellitesComm,
doc: "removes other instance satellites of master",
key: $SetInstanceSatellitesExclusive,
queue: doQueueAndMark
];
CDCommandOps.RegisterWithMenu[menu: $SatellitesMenu,
entry: "set object satellites inclusive",
doc: "<O-Right> add other object satellites",
proc: InclusiveObjectSatellitesComm,
key: $SetObjectSatellites,
queue: doQueueAndMark
];
CDCommandOps.RegisterWithMenu[menu: $SatellitesMenu,
entry: "set object satellites exclusive",
doc: "removes other object satellites",
proc: ExclusiveObjectSatellitesComm,
key: $SetObjectSatellitesExclusive,
queue: doQueueAndMark
];
CDCommandOps.RegisterWithMenu[menu: $SatellitesMenu,
entry: "remove satellite association",
proc: UnSatelliteComm,
key: $UnSatellite,
queue: doQueueAndMark
];
END.