G3dTool.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, February 19, 1993 4:39 pm PST
Glassner, July 17, 1990 2:16:39 pm PDT
Shoemake, November 6, 1989 11:57:52 pm PST
DIRECTORY CedarProcess, Commander, Controls, Draw2d, G3dBasic, G3dControl, G3dDraw, G3dLight, G3dMatrix, G3dRender, G3dShape, G3dTimeTrees, G3dView, Imager, ImagerColor, ImagerSample, IO, Prop, Rope, SF, UnixSpawnTCP, UnixTypes, ViewerClasses;
G3dTool: CEDAR DEFINITIONS
~ BEGIN
Imported Types
Process:      TYPE ~ CedarProcess.Process;
CommandHandle:  TYPE ~ Commander.Handle;
ButtonList:    TYPE ~ Controls.ButtonList;
ClickProc:    TYPE ~ Controls.ClickProc;
ControlList:   TYPE ~ Controls.ControlList;
ControlSizes:   TYPE ~ Controls.ControlSizes;
OuterData:    TYPE ~ Controls.OuterData;
Typescript:    TYPE ~ Controls.Typescript;
Viewer:     TYPE ~ Controls.Viewer;
Zip:      TYPE ~ Draw2d.Zip;
IntegerPair:   TYPE ~ G3dBasic.IntegerPair;
Pair:      TYPE ~ G3dBasic.Pair;
Plane:     TYPE ~ G3dBasic.Quad;
Triple:     TYPE ~ G3dBasic.Triple;
CameraControl:  TYPE ~ G3dControl.CameraControl;
Light:     TYPE ~ G3dLight.Light;
LightSequence:  TYPE ~ G3dLight.LightSequence;
Matrix:     TYPE ~ G3dMatrix.Matrix;
TransformOrder:  TYPE ~ G3dMatrix.TransformOrder;
Viewport:    TYPE ~ G3dMatrix.Viewport;
Context3d:    TYPE ~ G3dRender.Context3d;
DrawOptions:   TYPE ~ G3dDraw.Options;
Shape:     TYPE ~ G3dShape.Shape;
ShapeProc:    TYPE ~ G3dShape.ShapeProc;
ShapeSequence:  TYPE ~ G3dShape.ShapeSequence;
ScreenSequence:  TYPE ~ G3dShape.ScreenSequence;
TTNode:     TYPE ~ G3dTimeTrees.Node;
TimeTree:    TYPE ~ G3dTimeTrees.TimeTree;
Camera:     TYPE ~ G3dView.Camera;
CameraRep:    TYPE ~ G3dView.CameraRep;
Context:     TYPE ~ Imager.Context;
RGB:      TYPE ~ ImagerColor.RGB;
Rectangle:    TYPE ~ Imager.Rectangle;
SampleMap:   TYPE ~ ImagerSample.SampleMap;
STREAM:    TYPE ~ IO.STREAM;
PropList:    TYPE ~ Prop.PropList;
ROPE:     TYPE ~ Rope.ROPE;
SFBox:     TYPE ~ SF.Box;
SpawnData:    TYPE ~ UnixSpawnTCP.SpawnData;
FileDescriptor:   TYPE ~ UnixTypes.FileDescriptor;
IconFlavor:    TYPE ~ ViewerClasses.IconFlavor;
Procedure Types
ForkableProc:    TYPE ~ CedarProcess.ForkableProc;
ControlProc:   TYPE ~ Controls.ControlProc;
MouseProc:    TYPE ~ Controls.MouseProc;
DestroyProc:   TYPE ~ Controls.DestroyProc;
DrawProc:    TYPE ~ PROC [
context:       Context,
viewer:       Viewer,
whatChanged:     REF ANY,
view:        Matrix,
vp:        Viewport,
v:         View,
tool:        Tool,
clientData:      REF ANY];
StopProc:    TYPE ~ PROC [clientData: REF ANY, reason: ROPE];
ChangeProc:   TYPE ~ PROC [lastTool, activeTool: Tool, clientData: REF ANY];
AnimateProc:   TYPE ~ PROC [frame: NAT, alpha, time: REAL, clientData: REF ANY];
         alpha = (frame-firstFrame)/(lastFrame-firstFrame)
Animation Types
Animation:    TYPE ~ REF AnimationRep;
AnimationRep:  TYPE ~ RECORD [
name:        ROPE ¬ NIL,
length:       CARDINAL ¬ 0,
element:       SEQUENCE maxLength: CARDINAL OF SampleMap
];
Animations:   TYPE ~ REF AnimationsRep;
AnimationsRep:  TYPE ~ RECORD [
length:       CARDINAL ¬ 0,
element:       SEQUENCE maxLength: CARDINAL OF Animation
];
A Viewer and Camera Control
NamedBuffer:   TYPE ~ RECORD [id: ATOM, map: SampleMap];
WhichVertices:  TYPE ~ {selectedOnly, all};
ShapeScreens:   TYPE ~ REF ShapeScreensRep;
ShapeScreensRep:  TYPE ~ RECORD [
length:       CARDINAL ¬ 0,
element:       SEQUENCE maxLength: CARDINAL OF ScreenSequence
];
View:     TYPE ~ REF ViewRep;
ViewRep:    TYPE ~ RECORD [
tool:        Tool ¬ NIL,
once:        BOOL ¬ FALSE,
index:        NAT ¬ 0,
viewer:       Viewer ¬ NIL,
viewport:       Viewport ¬ [],
camera:       Camera ¬ NIL,
spare:        Matrix ¬ NIL, 
idBuffer:       LIST OF NamedBuffer ¬ NIL, -- buffer with id
screens:       ShapeScreens ¬ NIL,
extent, previousExtent:   SF.Box ¬ [[0, 0], [0, 0]]   -- integer screen space
];
ViewProc:    TYPE ~ PROC [view: View] RETURNS [continue: BOOL ¬ TRUE];
ViewSequence:  TYPE ~ REF ViewSequenceRep;
ViewSequenceRep: TYPE ~ RECORD [element: SEQUENCE length: CARDINAL OF View];
3d Command Registration
Register: PROC [name: ROPE, proc: Commander.CommandProc, usage: ROPE];
Register the given command, to be subsequently invoked via: 3d <name> [arguments].
The command line passed to the command has "3d <name>" removed.
A Tool for 3d Rendering and Drawing
Client:     TYPE ~ RECORD [
mouse:       MouseProc ¬ NIL,  -- client supplied mouse proc
camera:       ControlProc ¬ NIL,  -- client supplied camera control proc
draw:        DrawProc ¬ NIL,  -- client supplied draw proc
destroy:       DestroyProc ¬ NIL,  -- client supplied destroy proc
animate:       AnimateProc ¬ NIL,  -- client supplied animation proc
stop:        StopProc ¬ NIL,   -- response to STOP button
change:       ChangeProc ¬ NIL,  -- response to active tool change
data:        REF ANY ¬ NIL   -- client supplied data
];
Operations:     TYPE ~ RECORD [
lines:        BOOL ¬ FALSE,   -- provide Line Drawing Ops button
render:       BOOL ¬ FALSE,   -- provide Render Ops button
shape:        BOOL ¬ FALSE,   -- provide Shape Ops button
scene:        BOOL ¬ FALSE,   -- provide Scene Ops button
texture:       BOOL ¬ FALSE,   -- provide Texture Ops button
light:        BOOL ¬ FALSE,   -- provide Light Ops button
io:         BOOL ¬ FALSE,   -- provide IO Ops button
animation:      BOOL ¬ FALSE,   -- provide Animation Ops button
stop:        BOOL ¬ FALSE,   -- provide Stop button
help:        BOOL ¬ FALSE   -- provide Help button
];
allOps: Operations ~ [TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE];
noOps: Operations ~ [];
DisplayMode:   TYPE ~ {lined, shaded};
RIBMode:    TYPE ~ {spawn, file};
Tool:      TYPE ~ REF ToolRep;
ToolRep:     TYPE ~ RECORD [
Book-keeping:
ops:       Operations ¬ allOps, -- generic operations supported by tool
directory:      ROPE ¬ NIL,    -- directory whence tool was made
name:       ROPE ¬ NIL,    -- name of tool
cmd:       CommandHandle ¬ NIL, -- commander
command:     ROPE ¬ NIL,    -- to execute after forked process
process:      Process ¬ NIL,   -- the current, forked process
clock:       REAL ¬ 0.0,    -- for timing
props:       PropList ¬ NIL,   -- miscellaneous storage
Client Supplied:
client:       Client ¬ [],    -- one client per tool
Viewer Miscellany:
outer:       Viewer ¬ NIL,   -- parent viewer
graphics:      Viewer ¬ NIL,   -- graphical viewer
bounds:      Rectangle ¬ [0,0,0,0], -- for subsequent draw use
outerData:     OuterData ¬ NIL,  -- Control's data record
camera:      CameraControl ¬ NIL, -- viewing control
controls:      ControlList ¬ NIL,  -- list of controls
buttons:      ButtonList ¬ NIL,  -- menu
typescript:     Typescript ¬ NIL,  -- for user IO
displayMode:     DisplayMode ¬ lined, -- lines or shaded regions?
ipStrokeWidth:    REAL ¬ 2.0,    -- for interpress output
Views:
views:      ViewSequence ¬ NIL, -- multiple views
activeViews:     LIST OF NAT ¬ NIL,  -- currently controlled view
The Sprite:
sprite:       Triple ¬ [],    -- user-positionable 3d sprite
spritePlane:     Plane ¬ [],    -- plane in which sprite moves
drawSprite:     BOOL ¬ FALSE,   -- display 3d sprite
Line Drawing:
buffering:     Buffering ¬ default, -- single, double or depends
background:     Triple ¬ [1.0, 1.0, 1.0], -- background color for line drawing
nVerticesAndPolys:   NAT ¬ 0,     -- used to estimate display time
previousDisplayTime:  REAL ¬ 0.0,    -- in seconds
drawOptions:     DrawOptions ¬ [],  -- draw for drawing the shape
drawPendant:    BOOL ¬ FALSE,   -- if display of axes "pendant"
drawClient:     BOOL ¬ TRUE,   -- draw any client graphics
forInterpress:     BOOL ¬ FALSE,   -- if output is to an ip file
drawCurves:     BOOL ¬ FALSE,   -- draw shape as curves
queryVertices:    BOOL ¬ FALSE,   -- interactively query vertex info
timing:      BOOL ¬ FALSE,   -- if display line-drawing time
drawLights:     BOOL ¬ FALSE,   -- draw light sources
drawAxes:     BOOL ¬ FALSE,   -- x, y, z axes (also for rendering)
previousWhatChanged:  REF ANY ¬ NIL,   -- previous reason for paint
Rendering:
context3d:     Context3d ¬ NIL,  -- for shaded imaging
color:       BOOL ¬ FALSE,   -- or black/white?
rMap, gMap, bMap:   SampleMap ¬ NIL,  -- to buffer image
lights:       LightSequence ¬ NIL, -- lights for shaded images
frameSize:     IntegerPair ¬ [400, 300], -- render size
unixSpawn:     REF SpawnData ¬ NIL, -- spawn data for Unix renderer
ribMode:      RIBMode ¬ spawn,  -- spawn or via file
annotation:     BOOL ¬ FALSE,   -- if annotate rendered images
autoRender:     BOOL ¬ FALSE,   -- if render image when new view
antiAliasing:     BOOL ¬ FALSE,   -- if anti-aliasing
depthBuffering:    BOOL ¬ FALSE,   -- if z-buffer
normalCoding:    BOOL ¬ FALSE,   -- if normal encoding is on
textureFiltering:    BOOL ¬ FALSE,   -- sum area tables if true
Selection
hitList:      LIST OF NAT,   -- indices into shape list
Shapes and Hierarchy
shapes:      ShapeSequence ¬ NIL, -- central shape collection
selectedLight:    INT ¬ -1,     -- index to currently selected light
selectedShape:    INT ¬ -1,     -- index to currently selected shape
selectedVertex:    INT ¬ -1,     -- currently selected vertex
timeTree:      TimeTree ¬ NIL,   -- root of the time tree
focusNode:     TTNode ¬ NIL,   -- the currently active time tree node
Animation:
time0:       REAL ¬ 0.0,    -- time at first frame of animation
time1:       REAL ¬ 0.0,    -- time at last frame of animation
nFrames:      NAT ¬ 0,     -- number of frames in animation
time:       REAL ¬ 0.0,    -- the current time
frame:       NAT ¬ 0,     -- current frame of animation
playbackPause:    REAL ¬ 0.0,    -- if positive, just run-through
playback:      Animation ¬ NIL,  -- the current animation
animations:     Animations ¬ NIL,  -- saved for possible playback
animateIPName:    ROPE ¬ NIL    -- root for ip file(s)
];
Tool Creation and Control
MakeTool: PUBLIC PROC [
name: ROPE,          -- name of the tool
extraButtons: ButtonList ¬ NIL,    -- extra buttons desired by the client
extraControls: ControlList ¬ NIL,    -- extra controls desired by the client
controlSizes: ControlSizes ¬ [],    -- adjust size of controls
ops: Operations ¬ allOps,      -- default operations provided by the tool
client: Client ¬ [],        -- client supplied data and procs
nViews: NAT ¬ 1,        -- number views (0 if tool only: no viewers)
noOpen: BOOL ¬ FALSE,      -- if noOpen, leave the viewer iconic
useArcBalls: BOOL ¬ TRUE,     -- arc ball for orientations, or separate controls
arcBallSize: INTEGER ¬ 136,     -- size in pixels of the arc ball controllers
graphicsHeight: INTEGER ¬ 475,    -- height of main graphics viewer
icon: IconFlavor ¬ document,     -- for client-supplied icon
useExistingTool: BOOL ¬ FALSE,    -- latch onto last moused tool, if one exists
camera: CameraRep ¬ [[0, 2, 0], [], 1, 60],-- client can preset camera
background: Triple ¬ [1.0, 1.0, 1.0],   -- background for line drawing display
typescriptHeight: INT ¬ 36,     -- height of typescript (0 for no typescript)
toolSettings: ToolRep ¬ []]      -- client can preset tool
RETURNS [t: Tool];
Create a tool for line drawing and shaded imaging of shapes.
In addition to optional client buttons, provide those buttons specified by `operations.'
In additon to optional client controls, this tool provides these controls:
field of view
arcball translation and rotation
-- or --
camera mode, scale, translate, and rotate.
The client DrawProc may be called with whatChanged:
NIL:   the entire tool is redrawn
$Camera:  the user has modified the viewing parameters
$Moused:  the user moused in the display
$Sprite:  the user CONTROL-moused in the display; this moves the `sprite'
$Vertex:  the user SHIFT-moused in the display; this locates the nearest shape vertex
$DrawOps: the user selected a line-drawing operation; the display is redrawn
$ShapeOps: the user selected a Shape operation; the display is redrawn
$Shape:  a new shape is added to the scene; the display is redrawn
$Scene:  the scene description is modified; the display is redrawn
$Overlay: the client DrawProc is prompted for any display that is not to be buffered.
    Whenever the display is redrawn and all mouse buttons are up, the display
    is buffered (in view.contextBuffer), allowing a subsequent call to Restore.
    This permits the sprite (or a client defined object), to be overlayed on a
    (possibly complex) displayed object without redrawing the object.
Context3dOk: PROC [t: Tool];
Test that the 3d context is okay; initializing it if necessary.
SetActiveTool: PROC [tool: Tool];
Set tool to be the currently active tool. Usually, this is the tool most recently moused.
GetActiveTool: PROC RETURNS [Tool];
Return the currently active tool. Usually, this is the tool most recently moused.
GetActiveClients: PROC RETURNS [LIST OF Client];
Return the currently active clients.
ToolBusy: PROC [tool: Tool] RETURNS [BOOL];
Return true if the tool is currently busy with a forked process.
MaybeFork: PROC [tool: Tool, proc: ForkableProc, data: REF ANY ¬ NIL]
RETURNS [forked: BOOL];
Fork the forkable proc if the tool isn't busy; proc must not be nested.
If data is NIL, then tool is passed to proc as data.
ForceFork: PROC [tool: Tool, proc: ForkableProc];
Terminate any existing forked procs, and fork the given proc.
Stop: PROC [tool: Tool, reason: ROPE ¬ NIL, waitTilAborted: BOOL ¬ FALSE];
This will halt any forked tool operation and print the reason in the typescript.
Finish: PROC [tool: Tool, reason: ROPE ¬ NIL];
Execute tool.command.
View Operations
MakeViews: PROC [tool: Tool, nViews: NAT] RETURNS [ViewSequence];
Create the specified number of viewports with graphics as the parent viewer.
DoWithViews: PROC [tool: Tool, action: ViewProc, activeOnly: BOOL ¬ TRUE];
Perform action on currently active views within the tool, if activeOnly;
otherwise, perform action on all views within the tool.
GetFirstActiveView: PROC [tool: Tool] RETURNS [View];
Return the first active view of the tool.
GetView: PROC [viewer: Viewer, tool: Tool ¬ NIL] RETURNS [View];
Return the view (if any) associated with the viewer; otherwise, return tool's active view.
GetViewTransform: PROC [viewer: Viewer ¬ NIL, tool: Tool ¬ NIL, out: Matrix ¬ NIL]
RETURNS [Matrix];
Return current view transformation; use out if non-NIL. viewer is the preferred argument.
GetBufferedSampleMap: PROC [view: View, id: ATOM ¬ $Frame] RETURNS [SampleMap];
Return the named sample map associated with the view.
SetBufferedSampleMap: PROC [map: SampleMap, view: View, id: ATOM ¬ $Frame];
Set the named sample map associated with the view.
InvalidateViewScreens: PROC [view: View];
Set screen.valid to FALSE.
Camera Operations
SetRenderView: PROC [context3d: Context3d, camera: CameraControl];
Set the context3d's view given the camera.
UpdateCamera: PROC [tool: Tool];
Update the user camera controls according to tool.context3d.
MatrixFromCamera: PROC [scale: REAL, moves, rotates: Triple, leftHanded: BOOL]
RETURNS [Matrix];
Derive matrix from given camera parameters.
SetCameraToIdentity: PROC [camera: CameraControl];
Set the camera controls and matrix to identity.
Line Drawing Operations
Buffering: TYPE ~ {single, double, default};
SetMinFPS: PROC [fps: NAT];
Set minimum number frames-per-second for double-buffering.
Repaint: PROC [tool: Tool, whatChanged: REF ¬ $Client, buffering: Buffering ¬ default];
Request a repaint of the graphics viewer belonging to the tool.
If default buffering, double-buffer if draw time < 1/fps (draw time est. from last display).
whatChanged = $Pose will cause the contents of the display to be stored after displaying
shapes only; the display is then completed (showing lights, clients, etc.); this stored display
may be restored via Restore[].
Store: PROC [context: Context, view: View, id: ATOM ¬ $Frame];
Save current view's display.
Restore: PROC [context: Context, view: View, id: ATOM ¬ $Frame];
Restore previously saved display.
InvalidateVertexScreens: PROC [t: Tool, which: WhichVertices];
Invalidate the specified vertex screen coordinates.
Draw: DrawProc;
Perform the line drawing actions (data presumed to be REF Tool).
Do not call this proc via Imager.DoWithBuffer!
Shaded Rendering Operations
EnableClear: PROC [tool: Tool, on: BOOL];
If disabled (on = FALSE) images may be composited using successive renderings.
SetAntiAliasing: PROC [tool: Tool, antiAliasing: BOOL];
Set the anti-aliasing mode for rendering.
SetDepthBuffering: PROC [tool: Tool, depthBuffering: BOOL];
Set up or destroy normal buffer when rendering.
SetNormalCoding: PROC [tool: Tool, normalBuffering: BOOL];
Set up or destroy depth buffer when rendering.
Render: PROC [tool: Tool, fork: BOOL ¬ TRUE];
Render an image on the color display if tool not presently rendering.
Updates lights; checks for consistency of anti-aliasing, texture filtering, and normal coding.
Calls RenderFromCamera; annotates image if requested.
RenderFromCamera: PROC [
context3d: Context3d,
context: Context,
camera: CameraControl,
fork: BOOL ¬ TRUE];
Render the 3d context, if not already rendering. First sets the context3d's view from camera.
RenderToFile: PROC [
context3d: Context3d,
camera: CameraControl,
fileName: ROPE,
width: NAT ¬ 1024,
height: NAT ¬ 768,
fork: BOOL ¬ TRUE];
Create AIS file(s) at the specified resolution. 8 or 24 bit is determined by context3d.
Nothing is rendered on the color display.
WriteProc: TYPE ~ PROC [rope: ROPE] RETURNS [continue: BOOL ¬ TRUE];
WriteRIBtoFile: PROC [tool: Tool, fileName: ROPE];
Write tool's scene as RIB output to named file.
WriteRIBtoStream: PROC [tool: Tool, out: IO.STREAM];
Write tool's scene as RIB output to stream.
ToRIB: PROC [
imageName: ROPE ¬ NIL,
frameSize: G3dBasic.IntegerPair,
color: BOOL,
scale, fieldOfView: REAL,
moves, rotates: Triple,
shapes: G3dShape.ShapeSequence,
lights: G3dLight.LightSequence,
writer: WriteProc,
comment: ROPE ¬ NIL];
Low level access for creating RIB output;
if imageName = NIL, use frame buffer, else save image as imageName (tiff format
Shape Operations
ReadFromShapeFile: PROC [tool: Tool, name: ROPE, autoScale: BOOL ¬ FALSE]
RETURNS [err: ROPE ¬ NIL];
Read the named shape into the Tool. If autoScale, adjust Tool scale.
AddShape: PROC [tool: Tool, shape: Shape];
Add the given shape to the tool.
DeleteShape: PROC [tool: Tool, name: ROPE];
Delete first encountered instance of the named shape from the tool.
DeleteShapeEntry: PROC [tool: Tool, shapeID: NAT];
Delete the shape according to its index.
ChooseShape: PROC [t: Tool, header: ROPE ¬ NIL] RETURNS [choice: INT];
Create a pop up menu from which to select a shape.
DoWithSelectedShapes: PROC [shapes: ShapeSequence, proc: ShapeProc, choice: INT];
Apply proc to the selected shapes, depending on choice:
-2: no op, -1: apply to all shapes; else, apply to shapes[choice].
SelectShape: PROC [t: Tool, s: Shape, mb: Controls.MouseButton ¬ none];
Usually called in response to a user selection of a shape.
If the shape is an element of a time-tree:
the tool's time-tree focus is set to the shape, and
the .selected field is set for s and its children, depending on the mouse button:
left: select s only
middle or right: select s and its children.
If the shape is not part of a time-tree:
the tool's time-tree focus is set to NIL, and
only s is selected.
GetShape: PROC [t: Tool, name: ROPE] RETURNS [Shape];
Return the selected shape; it is part of a time-tree, select tool's time-tree focus to the shape.
GetSelectedShape: PROC [t: Tool] RETURNS [Shape];
Return the selected shape; if it is part of a time-tree, set tool's time-tree focus to the shape.
GetSelectedLight: PROC [t: Tool] RETURNS [Light];
Return the selected light.
SaveShape: PROC [s: Shape];
Save s.matrix in a safe place for future restoration.
RestoreShape: PROC [s: Shape];
Restore s.matrix from a safe place.
PrepareForDrawing: PROC [tool: Tool];
Ensure tool's shapes all have .edges (see G3dShape), .matrix;
ensure tool's views can support the number of shapes in tool; update tool.nVertsAndPolys.
ShapePoint: TYPE ~ RECORD [shape, point: INTEGER ¬ -1];
ScreenPick: PROC [tool: Tool, viewer: Viewer, screen: IntegerPair] RETURNS [ShapePoint];
Return [shape, index] if shape's point closest to screen.
Light Operations
LightOptions: PROC [lights: LightSequence, eyeView: Triple, ts: Typescript]
RETURNS [LightSequence];
Choose from a pop-up menu to:
delete a light,
add a light,
adjust the specular or diffuse portion of lighting,
list the lights,
set the shadow proportion.
ts is used to query the user.
If context3d # NIL, update those shapes affected by lights.
Public Procs
Mouse: MouseProc;
Provide pointing response for user
Controller: ControlProc;
Camera/orientation controller.
IOOpsButton: ClickProc;
Provide IO options to user.
LightOpsButton: ClickProc;
Provide light options to user.
TextureOpsButton: ClickProc;
Provide texture options to user.
ShapeOpsButton: ClickProc;
Provide shape options to user.
DrawOpsButton: ClickProc;
Provide lf display options to user.
RenderOpsButton: ClickProc;
Provide rendering options and direct render to user.
SceneOpsButton: ClickProc;
Provide scene and hierarchy options to user.
AnimateOpsButton: ClickProc;
Provide animation options to user.
AbortButton: ClickProc;
Provide abort option to user.
HelpButton: ClickProc;
Provide help option to user.
FinishButton: ClickProc;
Allow user to specify command to be executed upon completion of a forked process.
StopButton: ClickProc;
Stop the current forked process.
Timing
StartTimer: PROC [tool: Tool];
Set the starting time for elapsed time.
ElapsedTime: PROC [tool: Tool] RETURNS [seconds: REAL];
Return the elapsed time since the previous call on StartTimer.
PrintElapsedTime: PROC [tool: Tool, elapsedTime: REAL ¬ 0.0, action: ROPE ¬ NIL];
Print the current elapsed time to the typescript. action is the action being timed.
If elapsedTime = 0.0, compute elapsed time from tool.time to present time.
Miscellany
OpenHelp: PROC [key: ROPE];
Open Graphics3dDoc.tioga and scroll to the key.
TSWrite: PROC [tool: Tool, message: ROPE];
Write the message to the tool's typescript, if it exists; otherwise to the Commander.
SetCursor: PROC [tool: Tool, waiting: BOOL];
Set the cursor to be an hourglass or not.
TimeTree Operations
LeftRight: TYPE ~ {left, right};
Traversal: TYPE ~ {selfOnly, childrenOnly, selfAndChildren};
ParentObjectNode: PROC [node: TTNode] RETURNS [parent: TTNode];
Return first parent node that contains a non-NIL object. Return NIL if no such node.
Sibling: PROC [node: TTNode, which: LeftRight] RETURNS [TTNode];
Return the specified sibling node.
DoWithShape: PROC [node: TTNode, action: ShapeProc, traversal: Traversal ¬ selfAndChildren];
Apply action to the self and/or its children.
SelectNodeShapes: PROC [node: TTNode, traversal: Traversal ¬ selfAndChildren];
Set selected shapes associated with node according to the specified traversal.
PropagateShapeMatrices: PROC [node: TTNode];
Build the inherited transformations for this node and all descendents,
and store the result in the corresponding shape.matrix fields.
TransformAndPropagateNode: PROC [
node: TTNode,
matrix: Matrix,
order: TransformOrder];
Apply the matrix to the node in the specified order and propagate the matrices to children
nodes, storing resulting global transforms in shape.matrix fields.
Interactive Shape Changing
ChangeShapeFromMenu: PROC [t: Tool, s: Shape];
Give user a menu to change all programmable parameters for this shape.
CleanAllShapes: PROC [t: Tool];
Mark all shapes in the tool as free of changes.
CleanShape: PROC [s: Shape];
Mark this shape as free of changes.
LatchAllShapes: PROC [t: Tool];
Save the changes to all shapes in the tool.
LatchShape: PROC [s: Shape];
Save the changes to this shape.
END.