G3dSkeletonCmdImpl.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, October 20, 1992 3:25 pm PDT
DIRECTORY Args, Commander, Controls, Convert, Draw2d, FileNames, G3dBasic, G3dControl, G3dDraw, G3dMatrix, G3dModel, G3dPlane, G3dShape, G3dTool, Icons, Imager, ImagerBackdoor, ImagerSample, IO, Rope, ViewerClasses, ViewerOps, ViewerTools;
G3dSkeletonCmdImpl: CEDAR PROGRAM
IMPORTS Args, Controls, FileNames, G3dControl, G3dShape, G3dTool, Icons, Rope, ViewerOps, ViewerTools
~ BEGIN
Types
Viewer:    TYPE ~ Controls.Viewer;
ClickProc:   TYPE ~ Controls.ClickProc;
Control:    TYPE ~ Controls.Control;
Tool:     TYPE ~ G3dTool.Tool;
Shape:    TYPE ~ G3dShape.Shape;
ROPE:     TYPE ~ Rope.ROPE;
Data:     TYPE ~ REF DataRep;
DataRep:    TYPE ~ RECORD [
fileName:      ROPE ¬ NIL,
shape:       Shape ¬ NIL,
tool:       Tool ¬ NIL
];
Skeleton Command
CommandProc: Commander.CommandProc ~ {
d: Data ¬ NEW[DataRep];
IF Args.GetRope[cmd] = NIL THEN RETURN[$Failure, "Specify shape file."];
d.fileName ¬ FileNames.ResolveRelativePath[Args.GetRope[cmd]];
d.shape ¬ G3dShape.ShapeFromFile[d.fileName ! G3dShape.Error => {msg ¬ reason; GOTO Bad}];
d.tool ¬ G3dTool.MakeTool[
name: Rope.Concat["3dSkeleton ", d.fileName],
extraButtons: LIST[
Controls.ClickButton["Output", Output, d]],
ops: [FALSE, FALSE],
client: [data: d, draw: Draw],
controlSizes: [wVSlider: 15],
icon: icon,
noOpen: TRUE];
G3dControl.UpdateControl[d.tool.camera, d.tool.camera.scale, G3dShape.ObjectScale[d.shape]];
ViewerOps.OpenIcon[d.tool.outer];
[] ¬ ViewerTools.MakeNewTextViewer[[parent: d.tool.outer, wx: 200, wy: d.tool.outer.wh-33, ww: 80, wh: 14, border: FALSE, scrollable: FALSE, data: "Plane:"]];
G3dTool.Repaint[d.tool];
Controls.TypescriptWrite[d.tool.typescript, "Skeleton removes parts on arrow side of plane\n"];
EXITS
Bad => RETURN[$Failure, msg];
};
Output
Output: ClickProc ~ {
d: Data ¬ NARROW[clientData];
IF d.shape = NIL
THEN Controls.TypescriptWrite[d.tool.typescript, "No shape to write.\n"]
ELSE {
fileName: ROPE ¬ Controls.TypescriptReadFileName[d.tool.typescript];
IF fileName # NIL THEN G3dShape.ShapeToFile[fileName, d.shape];
};
};
Display
Draw: G3dTool.DrawProc ~ {
d: Data ~ NARROW[clientData];
};
Start Code
icon: Icons.IconFlavor ¬ Icons.NewIconFromFile["G3dUser.icons", 6];
G3dTool.Register["Skeleton", CommandProc, "skeleton <FileName>"];
END.