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, September 2, 1986 12:01:57 pm PDT
DIRECTORY
CD, CDCommandOps, CDInstances, CDCommandOpsExtras2, CDOps, CDOpsExtras, CDPanelFonts, CDPopUpMenus, CDSatellites, CDSequencer, CDTexts, CDTextsExtras, IO, Rope, TerminalIO;
CDSatellitesCommands:
CEDAR
PROGRAM
IMPORTS CDCommandOps, CDInstances, CDCommandOpsExtras2, CDOps, CDOpsExtras, CDPanelFonts, CDPopUpMenus, CDSatellites, CDSequencer, CDTextsExtras, IO, TerminalIO
SHARES CDPopUpMenus =
BEGIN
SelectWithMaster:
PROC [design:
CD.Design, master:
REF, deselectOthers:
BOOL←
TRUE]
RETURNS [n:
INT𡤀] = {
FOR w:
CD.InstanceList ← CDOps.InstList[design], w.rest
WHILE w#
NIL
DO
IF CDTextsExtras.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 ← CDOpsExtras.PushedTopCell[comm.design];
[] ← CDSatellites.GetSatellites[ob]; --reinstalls invariants
n ← SelectWithMaster[comm.design, ob];
TerminalIO.WriteF[" %g satellites(s) in group.\n", IO.int[n]];
};
SelectInstanceSatellitesComm:
PROC [comm: CDSequencer.Command] = {
n: INT; selOrMaster: REF←NIL;
selected: CD.Instance ← CDCommandOps.TheInstance[comm, "select satelites for"];
IF selected#
NIL
THEN {
ob: CD.Object ← CDOpsExtras.PushedTopCell[comm.design];
[] ← CDSatellites.GetSatellites[ob]; --reinstalls invariants
IF CDTextsExtras.IsText[selected.ob]
THEN {
WITH CDSatellites.GetMaster[ob, selected]
SELECT
FROM
i: CD.Instance => {selOrMaster ← i; TerminalIO.WriteRope["instance satellites"]};
o: CD.Object => {selOrMaster ← o; TerminalIO.WriteRope["object satellites"]};
ENDCASE => {selOrMaster ← NIL; TerminalIO.WriteRope["non satellite texts"]};
}
ELSE {selOrMaster ← selected; TerminalIO.WriteRope["instance satellites"]};
}
ELSE {selOrMaster ← NIL; TerminalIO.WriteRope[" select non satellite texts"]};
n ← SelectWithMaster[comm.design, selOrMaster];
TerminalIO.WriteF[" %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 ← CDOpsExtras.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 CDTextsExtras.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 ← CDOpsExtras.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 CDTextsExtras.IsText[w.first.ob]
THEN {
CDSatellites.Associate[ob, w.first];
n ← n+1;
};
ENDLOOP;
};
InclusiveInstanceSatellitesComm:
PROC [comm: CDSequencer.Command] = {
TerminalIO.WriteRope["set instance satellites inclusive\n"];
[] ← SetInstanceSatellites[comm.design, FALSE];
};
ExclusiveInstanceSatellitesComm:
PROC [comm: CDSequencer.Command] = {
n: INT;
TerminalIO.WriteRope["set object satellites exclusive\n"];
n ← SetInstanceSatellites[comm.design, TRUE];
TerminalIO.WriteF[" %g satellite(s) in group.\n", IO.int[n]];
};
InclusiveObjectSatellitesComm:
PROC [comm: CDSequencer.Command] = {
TerminalIO.WriteRope["set object satellites inclusive\n"];
[] ← SetObjectSatellites[comm.design, FALSE];
};
ExclusiveObjectSatellitesComm:
PROC [comm: CDSequencer.Command] = {
n: INT;
TerminalIO.WriteRope["set object satellites exclusive\n"];
n ← SetObjectSatellites[comm.design, TRUE];
TerminalIO.WriteF[" %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 ← CDTextsExtras.Create[name, f, CD.commentLayer, TRUE];
IF ob=NIL THEN CDSequencer.Quit["failed: text not created"];
i ← CDInstances.NewInstI[ob, comm.pos];
CDOps.IncludeInstance[comm.design, i];
};
DrawInstanceSatelliteComm:
PROC [comm: CDSequencer.Command] = {
selected: CD.Instance ← CDCommandOps.TheInstance[comm, "draw satellite to master"];
IF selected#
NIL
THEN {
inst: CD.Instance;
ob: CD.Object ← CDOpsExtras.PushedTopCell[comm.design];
[] ← CDSatellites.GetSatellites[ob]; --reinstalls invariants
IF CDTextsExtras.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 ← CDOpsExtras.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.WriteRope["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];
}
};
[] ← CDPopUpMenus.MakeMenu[$SatellitesMenu, "Satellites Menu", "Satellites Menu"];
CDCommandOpsExtras2.RegisterWithMenu[menu: $SatellitesMenu,
entry: "select instance satellites",
doc: "<I-Left>",
proc: SelectInstanceSatellitesComm,
key: $SelectInstanceGroup,
queue: doQueue
];
CDCommandOpsExtras2.RegisterWithMenu[menu: $SatellitesMenu,
entry: "select object satellites",
proc: SelectObjectSatellitesComm,
doc: "<O-Left>",
key: $SelectObjectGroup,
queue: doQueue
];
CDCommandOpsExtras2.RegisterWithMenu[menu: $SatellitesMenu,
entry: "draw instance satellite",
proc: DrawInstanceSatelliteComm,
doc: "<I-Middle>",
key: $AddInstanceSatellite,
queue: doQueueAndMark
];
CDCommandOpsExtras2.RegisterWithMenu[menu: $SatellitesMenu,
entry: "draw object satellite",
proc: DrawObjectSatelliteComm,
doc: "<O-Middle>",
key: $AddObjectSatellite,
queue: doQueueAndMark
];
CDCommandOpsExtras2.RegisterWithMenu[menu: $SatellitesMenu,
entry: "set instance satellites inclusive",
proc: InclusiveInstanceSatellitesComm,
doc: "<I-Right>; adds instance satellites",
key: $SetInstanceSatellites,
queue: doQueueAndMark
];
CDCommandOpsExtras2.RegisterWithMenu[menu: $SatellitesMenu,
entry: "set instance satellites exclusive",
proc: ExclusiveInstanceSatellitesComm,
doc: "removes other instance satellites of master",
key: $SetInstanceSatellitesExclusive,
queue: doQueueAndMark
];
CDCommandOpsExtras2.RegisterWithMenu[menu: $SatellitesMenu,
entry: "set object satellites inclusive",
doc: "<O-Right> add other object satellites",
proc: InclusiveObjectSatellitesComm,
key: $SetObjectSatellites,
queue: doQueueAndMark
];
CDCommandOpsExtras2.RegisterWithMenu[menu: $SatellitesMenu,
entry: "set object satellites exclusive",
doc: "removes other object satellites",
proc: ExclusiveObjectSatellitesComm,
key: $SetObjectSatellitesExclusive,
queue: doQueueAndMark
];
CDCommandOpsExtras2.RegisterWithMenu[menu: $SatellitesMenu,
entry: "remove satellite association",
proc: UnSatelliteComm,
key: $UnSatellite,
queue: doQueueAndMark
];
END.