G2dImplicitTool.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, August 25, 1992 2:08 pm PDT
DIRECTORY CedarProcess, Commander, Controls, Draw2d, G2dBasic, Imager, Rope, ViewerClasses;
G2dImplicitTool: CEDAR DEFINITIONS
~ BEGIN
Imported Types
CommandProc:  TYPE ~ Commander.CommandProc;
ForkableProc:   TYPE ~ CedarProcess.ForkableProc;
Process:     TYPE ~ CedarProcess.Process;
ButtonList:    TYPE ~ Controls.ButtonList;
Control:     TYPE ~ Controls.Control;
ControlList:    TYPE ~ Controls.ControlList;
OuterData:    TYPE ~ Controls.OuterData;
Typescript:    TYPE ~ Controls.Typescript;
DrawProc:    TYPE ~ Draw2d.DrawProc;
Zip:      TYPE ~ Draw2d.Zip;
Pair:      TYPE ~ G2dBasic.Pair;
PairSequence:   TYPE ~ G2dBasic.PairSequence;
ROPE:     TYPE ~ Rope.ROPE;
Viewer:     TYPE ~ ViewerClasses.Viewer;
Local Types
ValueProc:   TYPE ~ PROC [point: Pair, clientData: REF ANY ¬ NIL]
        RETURNS [value: REAL ¬ 0.0];
        Return the value at point (> 0 inside, < 0 outside surface).
StartProc:    TYPE ~ PROC [clientData: REF ANY ¬ NIL, frame, nFrames: NAT ¬ 0];
Tool:     TYPE ~ REF ToolRep;
ToolRep:    TYPE ~ RECORD [
Book-keeping:
graphics:     Viewer ¬ NIL,     -- the graphics viewer
outerData:    OuterData ¬ NIL,    -- for buttons, controls
typescript:    Typescript ¬ NIL,    -- user typescript
buttons:     ButtonList ¬ NIL,    -- buttons
ipStrokeWidth:   REAL ¬ 0.0,
process:     Process ¬ NIL,     -- current, forked process
Camera:
scale:      Control ¬ NIL,     -- display scale
moveX:     Control ¬ NIL,     -- x translation
moveY:     Control ¬ NIL,     -- y translation
Sampling:
threshold:    REAL ¬ 0.0,      -- f'= f-threshold
size:      REAL ¬ 0.02,      -- size of tracking square
The Curve:
curve:     PairSequence ¬ NIL,   -- the curve
Surface Evaluation Procedures:
startProc:     StartProc ¬ NIL,     -- to find start point
valueProc:    ValueProc ¬ NIL,     -- to evaluate space
Display: 
zip:      Zip ¬ NIL,      -- draw accelerator
displayClient:   BOOL ¬ TRUE,     -- shown client draw or not
Animation:
currentFrame:   NAT ¬ 0,       -- current frame of animation
firstFrame:    NAT ¬ 0,       -- first frame of animation
lastFrame:    NAT ¬ 0,       -- last frame of animation
saveIP:     ROPE ¬ NIL,
animateIP:    ROPE ¬ NIL,
Client Support:
clientDraw:    DrawProc ¬ NIL,    -- client supplied drawProc
clientData:    REF ANY ¬ NIL      -- client data
];
Implicit Design Tool Creation
MakeTool: PROC [
name:    ROPE,      -- name of the tool
valueProc:  ValueProc,    -- to evaluate implicit function
extraButtons:  ButtonList ¬ NIL,  -- in addition to the standard set
extraControls: ControlList ¬ NIL,  -- in addition to the standard set
clientData:  REF ANY ¬ NIL,   -- data for the client
clientDraw:  DrawProc ¬ NIL,  -- to draw the client's object
startProc:   StartProc ¬ NIL,   -- to initialize client, if necessary
scale:    REAL ¬ 1.0,    -- initial display scale
move:    Pair ¬ [0.0, 0.0],   -- initial display translation
toolSettings:  ToolRep ¬ []]   -- initial tool settings
RETURNS [Tool];
Return a tool for manipulation/polygonization of a 2d implicit function.
See ImplicitDesign tool in ImplicitSurfacesDoc.
Tool Control
ToolBusy: PROC [tool: Tool] RETURNS [BOOL];
Return true if the tool is currently busy with a forked process.
MaybeFork: PROC [tool: Tool, proc: ForkableProc] RETURNS [forked: BOOL];
Fork the forkable proc if the tool isn't busy; tool is passed to proc as data.
Stop: PROC [tool: Tool, reason: ROPE ¬ NIL, waitTilAborted: BOOL ¬ FALSE];
This will halt any implicit tool operation and print the reason in the typescript.
Repaint: PROC [tool: Tool, whatChanged: REF ANY ¬ NIL];
Repaint the graphics viewer associated with the tool.
Registration and Dispatching
Register: PROC [
name: ROPE,       -- name of option
command: CommandProc,   -- proc to be called
doc: ROPE];       -- documentation of option
Register a command proc with Implicit Design.
Subsequently, it may be invoked from the commander by "ImplicitDesign2d <name>"
ToolOptions: PROC RETURNS [toolOptions: ROPE];
Return a rope listing the registered ImplicitDesign options.
ExecuteOption: CommandProc;
Execute the named option; may return [$Failure, "No such option."].
END.