CDMarkObjectsCommands.mesa (part of Chipndale)
Copyright © 1984 by Xerox Corporation. All rights reserved.
by Christian Jacobi September 14, 1984 9:36:44 am PDT
last edited Christian Jacobi November 20, 1984 2:47:01 pm PST
DIRECTORY
CD,
CDApplications,
CDBasics,
CDCommandOps,
CDInterestRects,
CDMarkObjects,
CDMenus,
CDOps,
CDOrient,
CDSequencer,
Rope,
TerminalIO;
CDMarkObjectsCommands: CEDAR PROGRAM
IMPORTS CDApplications, CDBasics, CDCommandOps, CDInterestRects, CDMarkObjects, CDMenus, CDOps, CDOrient, CDSequencer, Rope, TerminalIO =
BEGIN
DrawMarkComm: PROC [comm: CDSequencer.Command] =
BEGIN
name: Rope.ROPE;
mark: CD.ApplicationPtr;
TerminalIO.WriteRope["Draw alignment mark\n"];
name ← TerminalIO.RequestRope[" type name: "];
mark ← CDApplications.NewApplicationI[CDMarkObjects.markOb, comm.pos];
CDMarkObjects.SetMarkName[mark, name];
CDOps.IncludeApplication[comm.design, mark];
END;
ReComputeTheInterestRect: PROC [cellOb: CD.ObPtr] =
--uses the marks "BottomLeft" and "UpperRight" to overide
--coordinates, initialized with innerrect
BEGIN
rect: CD.DesignRect ← cellOb.p.insideRect[cellOb];
bl, ur: BOOLFALSE;
Enumerate: PROC [markApp: CD.ApplicationPtr] RETURNS [quit: BOOLFALSE] =
BEGIN
pos: CD.DesignPosition;
name: Rope.ROPE = CDMarkObjects.GetMarkName[markApp];
IF Rope.Equal[name, "BottomLeft"] THEN {
IF bl THEN TerminalIO.WriteRope["multiple BottomLeft marks\n"];
bl ← TRUE;
pos ← CDMarkObjects.GetMarkPosition[markApp];
rect.x1 ← pos.x;
rect.y1 ← pos.y
}
ELSE IF Rope.Equal[name, "UpperRight"] THEN {
IF ur THEN TerminalIO.WriteRope["multiple UpperRight marks\n"];
ur ← TRUE;
pos ← CDMarkObjects.GetMarkPosition[markApp];
rect.x2 ← pos.x;
rect.y2 ← pos.y
}
END;
[] ← CDMarkObjects.EnumerateMarks[cellOb: cellOb, proc: Enumerate];
IF rect.x1>rect.x2 OR rect.y1>rect.y2 THEN {
TerminalIO.WriteRope["bad rectangle\n"];
rect�sics.empty;
};
IF rect.x1>rect.x2 OR rect.y1>rect.y2 THEN {
TerminalIO.WriteRope["marks are badly placed\n"];
rect ← CDBasics.empty;
};
IF ~bl AND ~ur THEN rect�sics.empty;
CDInterestRects.SetInterestRect[cellOb, rect]
END;
SetInterestRectComm: PROC [comm: CDSequencer.Command] =
BEGIN
aptr: CD.ApplicationPtr = CDCommandOps.TheApplication[comm, "Recompute interestrect"];
IF aptr#NIL THEN {
IF ISTYPE[aptr.ob.specificRef, CD.CellPtr] THEN
ReComputeTheInterestRect[aptr.ob]
ELSE TerminalIO.WriteRope[" not done; Selected object is not cell\n"];
}
END;
PaintInterestRectComm: PROC [comm: CDSequencer.Command] =
BEGIN
aptr: CD.ApplicationPtr = CDCommandOps.TheApplication[comm, "Repaint the interestrect"];
IF aptr#NIL THEN {
rect: CD.DesignRect = CDBasics.ToRect[comm.pos, comm.sPos];
oRect: CD.DesignRect = CDOrient.DeMapRect[
itemInWorld: rect,
cellSize: aptr.ob.size,
cellInstOrient: aptr.orientation,
cellInstPos: aptr.location
];
IF aptr.ob.p.inDirectory THEN CDInterestRects.SetInterestRect[aptr.ob, oRect]
ELSE TerminalIO.WriteRope["only possible for mutable objectclasses\n"];
}
END;
ClearInterestRectComm: PROC [comm: CDSequencer.Command] =
BEGIN
aptr: CD.ApplicationPtr = CDCommandOps.TheApplication[comm, "Clear the interestrect"];
IF aptr#NIL THEN
IF aptr.ob.p.inDirectory THEN CDInterestRects.SetInterestRect[aptr.ob]
ELSE TerminalIO.WriteRope["only possible for mutable objectclasses\n"];
END;
CDSequencer.ImplementCommand[$DrawMark, DrawMarkComm];
CDSequencer.ImplementCommand[$SetInterestRect, SetInterestRectComm];
CDSequencer.ImplementCommand[$PaintInterestRect, PaintInterestRectComm];
CDSequencer.ImplementCommand[$ClearInterestRect, ClearInterestRectComm];
CDMenus.CreateEntry[menu: $RectProgramMenu, entry: "Set InterestRect", key: $PaintInterestRect];
CDMenus.CreateEntry[menu: $ProgramMenu, entry: "Clear InterestRect", key: $ClearInterestRect];
END.