File: JaMSolidviewsImpl.mesa
Last edited by: Bier on January 3, 1985 10:29:30 pm PST
Copyright © 1984 by Xerox Corporation. All rights reserved.
Contents: Someday this may be a way to call Solidviews procedures from a JaM typescript. For now, it is a set of procedures to be called from the Cedar Language Interpreter.
DIRECTORY
CoordSys,
CSG,
CSGGraphics,
DisplayList3d,
JaM,
JaMSolidviews,
Menus,
Rope,
SVEditUser,
SVError,
SVInterfaceTypes,
SVModelTypes,
SVRayTypes,
SVSceneTypes,
SVSlices,
SVViewerUser,
SVTransforms,
ViewerClasses;
JaMSolidviewsImpl: CEDAR PROGRAM
IMPORTS CoordSys, DisplayList3d, SVEditUser, SVError, SVViewerUser, SVTransforms
EXPORTS JaMSolidviews =
BEGIN
Assembly: TYPE = SVSceneTypes.Assembly;
Camera: TYPE = SVModelTypes.Camera;
CoordSysList: TYPE = SVModelTypes.CoordSysList;
CoordSystem: TYPE = SVModelTypes.CoordSystem;
CSGTree: TYPE = SVRayTypes.CSGTree;
EditToolData: TYPE = SVInterfaceTypes.EditToolData;
FrameBox: TYPE = REF FrameBoxObj;
FrameBoxObj: TYPE = SVModelTypes.FrameBoxObj;
Scene: TYPE = SVSceneTypes.Scene;
ScratchpadData: TYPE = SVInterfaceTypes.ScratchpadData;
ScratchViewerData: TYPE = SVInterfaceTypes.ScratchViewerData;
Slice: TYPE = SVSlices.Slice;
Viewer: TYPE = ViewerClasses.Viewer;
ViewerToolData: TYPE = SVInterfaceTypes.ViewerToolData;
State: TYPE = JaM.State;
editToolData: EditToolData;
RegisterThisEditTool: PUBLIC PROC [etd: EditToolData] ~ {
editToolData ← etd;
};
Init: PROC [] ~ {
JaM.RegisterInit[name: "Solidviews", init: JamSolidviewsInit];
};
JamSolidviewsInit: PROC[state: State] ~ {
state.Register["RotX", RotX];
state.Register["EvenScaleChildren", EvenScaleChildren];
};
GetCoordSys: PRIVATE PROC [csRope: Rope.ROPE, scene: Scene] RETURNS [cs: CoordSystem, success: BOOL] ~ TRUSTED {
csList: CoordSysList;
success ← TRUE;
csList ← CoordSys.MakeListFromTree[scene.coordSysRoot];
cs ← CoordSys.FindCoordSysInList[csRope, csList
! CoordSys.CoordSysNotFound => {success ← FALSE; CONTINUE}];
IF NOT success THEN {
SVError.Append["Assembly ", TRUE];
SVError.Append[csRope];
SVError.Append[" not found", FALSE, TRUE];
SVError.Blink[];
};
};
GetAssembly: PRIVATE PROC [asRope: Rope.ROPE, scene: Scene] RETURNS [as: Assembly, success: BOOL] = TRUSTED {
success ← TRUE;
[as, ----] ← DisplayList3d.FindAssemblyFromName[asRope, scene
!DisplayList3d.AssemblyNotFound => {
SVError.Append["Assembly ", TRUE];
SVError.Append[asRope];
SVError.Append[" not found", FALSE, TRUE];
SVError.Blink[];
success ← FALSE;
CONTINUE}]
};
RotX: PROC [asRope: Rope.ROPE, csRope: Rope.ROPE, degrees: REAL] ~ TRUSTED {
scene: Scene ← editToolData.sceneSection.currentScene;
wrt: CoordSystem;
assembly: Assembly;
found: BOOL;
[wrt, found] ← GetCoordSys[csRope, scene];
IF NOT found THEN RETURN;
[assembly, found] ← GetAssembly[asRope, scene];
IF NOT found THEN RETURN;
SVTransforms.XRotate[assembly.coordSys, wrt, degrees];
SVEditUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene];
};
EvenScaleChildren: PROC [asRope: Rope.ROPE, scalar: REAL] ~ TRUSTED {
scene: Scene ← editToolData.sceneSection.currentScene;
assembly: Assembly;
found: BOOL;
[assembly, found] ← GetAssembly[asRope, scene];
IF NOT found THEN RETURN;
SVTransforms.ScaleEvenChildren[assembly, NIL, scalar];
SVEditUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene];
};
SetBoundBox: PROC [boundBoxes: BOOL] ~ TRUSTED {
camera: Camera;
currentScene: Scene ← editToolData.sceneSection.currentScene;
currentViewerToolData: ViewerToolData ← NARROW[editToolData.currentViewerToolData];
camera ← currentViewerToolData.camera;
camera.useBoundBoxes ← boundBoxes;
};
Init[];
END.