ImplicitSlice.mesa
Copyright Ó 1985, 1990 by Xerox Corporation. All rights reserved.
Bloomenthal, August 11, 1992 4:07 pm PDT
DIRECTORY Commander, Controls, CtBasic, CtMisc, Draw2d, G3dBasic, G3dControl, G3dMatrix, G3dTool, Imager, Rope, ImplicitDefs;
ImplicitSlice: CEDAR DEFINITIONS
~ BEGIN
Imported Types
CommandProc:  TYPE ~ Commander.CommandProc;
ButtonList:    TYPE ~ Controls.ButtonList;
ControlList:    TYPE ~ Controls.ControlList;
Typescript:    TYPE ~ Controls.Typescript;
Viewer:     TYPE ~ Controls.Viewer;
Box:     TYPE ~ CtBasic.Box;
SampleMaps:   TYPE ~ CtBasic.SampleMaps;
DrawProc:    TYPE ~ Draw2d.DrawProc;
Triple:    TYPE ~ G3dBasic.Triple;
Slice:     TYPE ~ G3dControl.Slice;
Matrix:     TYPE ~ G3dMatrix.Matrix;
RenderTool:   TYPE ~ G3dTool.Tool;
Context:     TYPE ~ Imager.Context;
VEC:      TYPE ~ Imager.VEC;
DiagramProc:   TYPE ~ ImplicitDefs.DiagramProc;
ValueProc:    TYPE ~ ImplicitDefs.ValueProc;
ROPE:     TYPE ~ Rope.ROPE;
Local Types
Function:    TYPE ~ RECORD [
name:       ROPE ¬ NIL,
valueProc:     ValueProc ¬ NIL,
diagramProc:     DiagramProc ¬ NIL];
Pix:     TYPE ~ REF PixRep;
PixRep:    TYPE ~ RECORD [
name:       ROPE ¬ NIL,
valueProc:     ValueProc ¬ NIL,
diagramProc:     DiagramProc ¬ NIL,
start:       VEC,
context:      Context ¬ NIL,
maps:       SampleMaps,
box:       Box
];
PixSequence:   TYPE ~ RECORD [element: SEQUENCE length: CARDINAL OF Pix];
Mode:     TYPE ~ {slice, sprite};
Tool:     TYPE ~ REF ToolRep;
ToolRep:    TYPE ~ RECORD [
renderTool:     RenderTool ¬ NIL,
typescript:     Typescript ¬ NIL,
mode:       Mode ¬ slice,
slice:       Slice ¬ NIL,       -- the slice to compute
moveSlice:     REAL ¬ -0.03,      -- amount to move each slice
showSlice:     BOOL ¬ TRUE,
xSize, ySize:     NAT ¬ 80,       -- size of slice in pixels
watchData:     WatchData,
worldToLf:     Matrix ¬ NIL,
lfToWorld:     Matrix ¬ NIL,
cdContext:     Context,        -- color display Imager context
cdMaps:      SampleMaps,       -- color display sample maps
pixes:       REF PixSequence ¬ NIL,
pixPicked:     Pix ¬ NIL,
point:       Triple ¬ [],
value:       REAL ¬ 0.0,
valueViewer:    Viewer ¬ NIL,
stop:       BOOL ¬ FALSE,      -- abort drawing or exploring
stopReason:     ROPE ¬ NIL,       -- reason for stopping
clientDraw:     DrawProc ¬ NIL,
clientData:     REF ANY ¬ NIL       -- client data
];
Old:
ToolRep:    TYPE ~ RECORD [
Book-keeping:
name:      ROPE ¬ NIL,       -- name of the tool
directory:     ROPE ¬ NIL,       -- commander's directory
Controls:
controls:     ControlList ¬ NIL,     -- sliders and dials
buttons:     ButtonList ¬ NIL,     -- menu
camera:     Camera ¬ NIL,      -- viewing control
slice:      Slice ¬ NIL,       -- the slice to compute
Viewing/Drawing:
outer:      Viewer ¬ NIL,      -- parent viewer
outerData:    OuterData ¬ NIL,     -- associated data
typescript:    Typescript ¬ NIL,     -- for user io
graphics:     Viewer ¬ NIL,      -- graphics viewer
clientDraw:    DrawProc ¬ NIL,     -- client supplied drawProc
watchData:    WatchData,
showSlice:    BOOL ¬ TRUE,
Transforms:
worldToLf:    Matrix ¬ NIL,
lfToWorld:    Matrix ¬ NIL,
Shade2d:
xSize, ySize:    NAT ¬ 80,
cdContext:    Context,        -- color display Imager context
cdMaps:     SampleMaps,       -- color display sample maps
pixes:      REF PixSequence ¬ NIL,
pixPicked:     Pix ¬ NIL,
value:      REAL ¬ 0.0,
move:      REAL ¬ -0.03,
State:
stop:      BOOL ¬ FALSE,      -- abort drawing or exploring
stopReason:     ROPE ¬ NIL,       -- stopReason for stopping
Geometry:
point:      Triple,
Data:
clientData:    REF ANY ¬ NIL      -- client data
];
Implicit Test Tool
MakeTool: PROC [
toolName: ROPE,          -- name of the tool
functions: LIST OF Function ¬ NIL,    -- the functions, their names, etc. to shade
clientDraw: DrawProc ¬ NIL,      -- client supplied proc to draw the model
clientData: REF ANY ¬ NIL,      -- client supplied data passed to valueProcs
extraControls: ControlList ¬ NIL,     -- in addition to the standard set
extraButtons: ButtonList ¬ NIL]     -- in addition to the standard set
RETURNS [Tool];
Return a tool for shading a two-dimensional slice of an implicit function.
The standard set of controls include:
x, y, z global rotations,
viewing scale,
viewing field of view,
The standard set of buttons include:
measure mode
distance mode
implicit tolerance
implicit threshold
implicit spread
move
start
stop.
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 Slice;
subsequently, it may be invoked from the commander by "ImplicitSlice <name>"
ToolOptions: PROC RETURNS [toolOptions: ROPE];
Return a rope listing the registered ImplicitSlice options.
ExecuteOption: CommandProc;
Execute the named option; may return [$Failure, "No such option."].
END.