File: SVEditUserImplD.mesa
Last edited by Bier on July 22, 1987 4:16:24 pm PDT
Copyright © 1984 by Xerox Corporation. All rights reserved.
Contents: All of the procedures called by SVEditTool when menus and buttons are pressed (part 4)
DIRECTORY
Atom, SVCoordSys, Feedback, Imager, IO, Labels, Menus, Rope, SV2d, SV3d, SVCoordSys2d, SVEditUser, SVEditUserB, SVEvent, SVFileOut, SVGraphics, SVInterfaceTypes, SVModelTypes, SVScene, SVSceneTypes, SVSelections, SVTransforms, SVViewersOnScene, SVViewerTools, SVWindow, SVParseIn, SVParseOut, ViewerClasses, ViewerTools;
SVEditUserImplD:
CEDAR
PROGRAM
IMPORTS Atom, SVCoordSys, Feedback, IO, Labels, Rope, SVEditUser, SVEvent, SVFileOut, SVGraphics, SVScene, SVSelections, SVTransforms, SVViewersOnScene, SVViewerTools, SVWindow, SVParseIn, SVParseOut, ViewerTools
EXPORTS SVEditUser, SVEditUserB =
BEGIN
Artwork: TYPE = SVModelTypes.Artwork;
Slice: TYPE = SVSceneTypes.Slice;
SliceList: TYPE = SVSceneTypes.SliceList;
AssemblyGenerator: TYPE = SVScene.AssemblyGenerator;
Camera: TYPE = SVModelTypes.Camera;
Color: TYPE = Imager.Color;
CoordSystem: TYPE = SVModelTypes.CoordSystem;
DrawStyle: TYPE = SVModelTypes.DrawStyle;
EditToolData: TYPE = SVEditUser.EditToolData;
FileCamera: TYPE = SVSceneTypes.FileCamera;
FileCameraList: TYPE = SVSceneTypes.FileCameraList;
FrameBox: TYPE = SVModelTypes.FrameBox;
LightSource: TYPE = SVModelTypes.LightSource;
Material: TYPE = SVModelTypes.Material;
Matrix3by3: TYPE = SV2d.Matrix3by3;
MasterObject: TYPE = SVSceneTypes.MasterObject;
MasterObjectList: TYPE = SVSceneTypes.MasterObjectList;
Matrix4by4: TYPE = SV3d.Matrix4by4;
MouseButton: TYPE = Menus.MouseButton;
NameAlreadyPresent: SIGNAL = SVScene.NameAlreadyPresent;
OMap: TYPE = SVModelTypes.OMap;
Plane: TYPE = SV3d.Plane;
Point3d: TYPE = SV3d.Point3d;
Projection: TYPE = SVModelTypes.Projection;
Scene: TYPE = SVSceneTypes.Scene;
Selection: TYPE = SVInterfaceTypes.Selection;
SelectionGenerator: TYPE = SVInterfaceTypes.SelectionGenerator;
SMap: TYPE = SVModelTypes.SMap;
SpaceFunction: TYPE = SVModelTypes.SpaceFunction;
Tube: TYPE = SVModelTypes.Tube;
Box: TYPE = SVModelTypes.Box;
Viewer: TYPE = ViewerClasses.Viewer;
ViewerCell: TYPE = SVInterfaceTypes.ViewerCell;
SVData: TYPE = SVInterfaceTypes.SVData;
GLOBAL VARIABLES
globalProjectionCount: NAT = SVEditUser.globalProjectionCount;
globalProjectionArray: PUBLIC ARRAY[1..globalProjectionCount] OF Rope.ROPE ←
["perspect", "ortho"];
globalMatCount: NAT = SVEditUser.globalMatCount;
globalMatArray: PUBLIC ARRAY[1..globalMatCount] OF Rope.ROPE ←
["plastic", "chalk"];
ListScenes:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
g: SVScene.SceneGenerator;
scene: Scene;
outHandle: IO.STREAM ← Feedback.GetTypescriptStream[$Solidviews];
g ← SVScene.GetSceneGenerator[];
scene ← SVScene.NextScene[g];
outHandle.PutRope["Listing Current Scenes...\n"];
UNTIL scene = NIL DO
outHandle.PutF[" %g\n",[rope[scene.name]]];
scene ← SVScene.NextScene[g];
ENDLOOP;
}; -- end of ListScenes
ListAssemblies:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
scene: Scene ← editToolData.sceneSection.currentScene;
name: Rope.ROPE;
outHandle: IO.STREAM ← Feedback.GetTypescriptStream[$Solidviews];
g: AssemblyGenerator;
a: Slice;
outHandle.PutF["Listing top level assemblies in scene: %g\n",
[rope[scene.name]]];
g ← SVScene.GetAssemblyGenerator[scene];
a ← SVScene.NextAssembly[g];
UNTIL a =
NIL
DO
name ← a.name;
outHandle.PutF[" %g coordSys: %g wrt: %g",
[rope[name]], [rope[SVCoordSys.Name[a.coordSys]]], [rope[SVCoordSys.Name[SVCoordSys.Parent[a.coordSys]]]]];
IF ISTYPE[a.shape, SliceList] THEN outHandle.PutF[" [cluster]\n"]
ELSE outHandle.PutF[" [primitive]\n"];
a ← SVScene.NextAssembly[g];
ENDLOOP;
}; -- end of ListAssemblies
ListCoordSystems:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
currentScene: Scene ← editToolData.sceneSection.currentScene;
g: SVScene.CoordSysGenerator;
outHandle: IO.STREAM ← Feedback.GetTypescriptStream[$Solidviews];
g ← SVScene.GetCoordSysGenerator[currentScene];
outHandle.PutF["Listing Current CoordinateSystems in %g...\n", [rope[currentScene.name]]];
FOR cs: CoordSystem ← SVScene.NextCoordSys[g], SVScene.NextCoordSys[g]
UNTIL cs =
NIL
DO
outHandle.PutF[" %g",[rope[SVCoordSys.Name[cs]]]];
outHandle.PutChar[IO.SP];
outHandle.PutRope["parent: "];
IF SVCoordSys.Parent[cs] = NIL
THEN IO.PutRope[outHandle,"NIL"]
ELSE IO.PutRope[outHandle, SVCoordSys.Name[SVCoordSys.Parent[cs]]];
IF SVCoordSys.IsScalarsOnly[cs]
THEN {
IO.PutRope[outHandle, " scalars: "];
SVParseOut.FileoutPoint3d[outHandle, SVCoordSys.GetScalars[cs]];
}
ELSE {
IO.PutRope[outHandle, " mat:\n"];
SVParseOut.FileoutMatrix[outHandle, SVCoordSys.GetMat[cs]];
IO.PutChar[outHandle, IO.CR];
IO.PutRope[outHandle, "wrtCamera:\n"];
SVParseOut.FileoutMatrix[outHandle, cs.wrtCamera];
};
IO.PutChar[outHandle, IO.CR];
IO.PutChar[outHandle, IO.CR];
ENDLOOP;
}; -- end of ListCoordSystems
ListLights:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
currentScene: Scene ← editToolData.sceneSection.currentScene;
outHandle: IO.STREAM ← Feedback.GetTypescriptStream[$Solidviews];
outHandle.PutRope["Listing Current LightSources...\n"];
SVFileOut.FileoutLightSources[outHandle, currentScene.lightSources];
};
ListMasterObjects:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
currentScene: Scene ← editToolData.sceneSection.currentScene;
outHandle: IO.STREAM ← Feedback.GetTypescriptStream[$Solidviews];
list: MasterObjectList;
outHandle.PutRope["Listing Current MasterObjects...\n"];
FOR list ← SVScene.MasterObjectsOfScene[currentScene], list.rest
UNTIL list =
NIL
DO
outHandle.PutF["%g\n",
[rope[list.first.name]] ];
ENDLOOP;
};
ListViewers:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
firstViewer: Viewer;
count: NAT;
outHandle: IO.STREAM ← Feedback.GetTypescriptStream[$Solidviews];
FOR allList:
LIST
OF ViewerCell ← editToolData.allViewers, allList.rest
UNTIL allList =
NIL
DO
firstViewer ← allList.first.viewersOnScene;
IF firstViewer = NIL THEN LOOP;
svData ← NARROW[firstViewer.data];
outHandle.PutF["\n%g: 1", [rope[svData.scene.name]]];
count ← 1;
FOR viewerList: Viewer ← firstViewer.link, viewerList.link
UNTIL viewerList = firstViewer
OR viewerList =
NIL
DO
count ← count + 1;
outHandle.PutF[", %g", [integer[count]]];
ENDLOOP;
ENDLOOP;
};
ListCameras:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
currentScene: Scene ← editToolData.sceneSection.currentScene;
outHandle: IO.STREAM ← Feedback.GetTypescriptStream[$Solidviews];
list: FileCameraList;
outHandle.PutRope["Listing Current Cameras...\n"];
FOR list ← currentScene.cameras, list.rest
UNTIL list =
NIL
DO
outHandle.PutF["%g\n",
[rope[list.first.name]] ];
ENDLOOP;
};
GetCamera:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
Get the camera named in the "name" slot of the edittool camera section.
cameraName: Rope.ROPE ← ViewerTools.GetSelectionContents[];
editToolData: EditToolData ← svData.editToolData;
GetCameraNamed[cameraName, editToolData];
};
GetCameraNamed:
PUBLIC
PROC [cameraName: Rope.
ROPE, editToolData: EditToolData] = {
currentScene: Scene ← editToolData.sceneSection.currentScene;
success: BOOL;
outStream: IO.STREAM;
fileCamera: FileCamera;
frameRope, visibleAssemblyRope, clippingRope, projectionRope: Rope.ROPE;
IF Rope.Length[cameraName] = 0
THEN {
Feedback.AppendRaw[$Solidviews, "Please select a camera name.", oneLiner];
Feedback.BlinkRaw[$Solidviews];
RETURN;
};
[fileCamera, success] ← SVScene.FindFileCameraFromName[cameraName, currentScene];
IF
NOT success
THEN {
Feedback.AppendRaw[$Solidviews, Rope.Cat["Camera ", cameraName, " not found"], oneLiner];
Feedback.BlinkRaw[$Solidviews];
}
ELSE {
Stuff all of the file camera fields into the appropriate slots.
name
ViewerTools.SetContents[editToolData.cameraSection.name, cameraName];
origin, focus point and slant
SVViewerTools.SetThreeReals[editToolData.cameraSection.origin, fileCamera.origin[1], fileCamera.origin[2], fileCamera.origin[3]];
SVViewerTools.SetThreeReals[editToolData.cameraSection.focusPoint, fileCamera.focusPoint[1], fileCamera.focusPoint[2], fileCamera.focusPoint[3]];
SVViewerTools.SetReal[editToolData.cameraSection.slant, fileCamera.slant];
resolution, focal length, and projection
SVViewerTools.SetReal[editToolData.cameraSection.resolution, fileCamera.resolution];
SVViewerTools.SetReal[editToolData.cameraSection.focalLength, fileCamera.focalLength];
projectionRope ← SVGraphics.ProjectionToRope[fileCamera.projection];
ViewerTools.SetContents[editToolData.cameraSection.projection, projectionRope];
frame
outStream ← IO.ROS[];
SVParseOut.FileoutFrame[outStream, fileCamera.frame];
frameRope ← IO.RopeFromROS[outStream];
IO.Close[outStream];
ViewerTools.SetContents[editToolData.cameraSection.frame, frameRope];
clipping planes and visible assemblies
outStream ← IO.ROS[];
SVParseOut.FileoutClippingPlanes[outStream, fileCamera.clippingPlanes];
clippingRope ← IO.RopeFromROS[outStream, FALSE];
ViewerTools.SetContents[editToolData.cameraSection.clippingPlanes, clippingRope];
IO.Reset[outStream];
SVParseOut.FileoutListOfRope[outStream, fileCamera.visibleAssemblies];
visibleAssemblyRope ← IO.RopeFromROS[outStream, TRUE];
ViewerTools.SetContents[editToolData.cameraSection.visibleAssemblies, visibleAssemblyRope];
};
}; -- end of GetCameraNamed
SetCamera:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
currentScene: Scene ← editToolData.sceneSection.currentScene;
currentSVData: SVData ← NARROW[editToolData.currentSVData];
camera: Camera ← currentSVData.camera;
focusPoint, origin: Point3d;
success: BOOL;
focalLength, slant, resolution: REAL;
cameraName, frameRope, clippingPlaneRope, visibleAssembliesRope: Rope.ROPE;
frame: FrameBox;
fileCamera, oldFileCamera: FileCamera;
frameStream, clippingStream, visibleAssembliesStream: IO.STREAM;
clippingPlanes: LIST OF Plane;
visibleAssemblies: LIST OF Rope.ROPE;
projection: Projection;
projectionRope: Rope.ROPE;
name
cameraName ← ViewerTools.GetContents[editToolData.cameraSection.name];
IF Rope.Length[cameraName] = 0
THEN {
Feedback.AppendRaw[$Solidviews, "Please give camera a name.", oneLiner];
Feedback.BlinkRaw[$Solidviews];
RETURN;
};
origin, focus point, and slant
origin ← SVEditUser.GetPoint3d[editToolData.cameraSection.origin];
focusPoint ← SVEditUser.GetPoint3d[editToolData.cameraSection.focusPoint];
slant ← SVViewerTools.GetReal[editToolData.cameraSection.slant, 0];
resolution, focal length and projection
resolution ← SVViewerTools.GetReal[editToolData.cameraSection.resolution, 10.0];
focalLength ← SVViewerTools.GetReal[editToolData.cameraSection.focalLength, 1800];
projectionRope ← ViewerTools.GetContents[editToolData.cameraSection.projection];
[projection, success] ← SVGraphics.RopeToProjection[projectionRope];
IF NOT success THEN projection ← perspective;
frame
frameRope ← ViewerTools.GetContents[editToolData.cameraSection.frame];
frameStream ← IO.RIS[frameRope];
frame ← SVParseIn.ReadFrame[frameStream, SVScene.version];
clipping planes and visible Assemblies
just one clipping plane for now
clippingPlaneRope ← ViewerTools.GetContents[editToolData.cameraSection.clippingPlanes];
clippingStream ← IO.RIS[clippingPlaneRope];
clippingPlanes ← SVParseIn.ReadClippingPlanes[clippingStream];
visibleAssembliesRope ← ViewerTools.GetContents[editToolData.cameraSection.visibleAssemblies];
visibleAssembliesStream ← IO.RIS[visibleAssembliesRope];
visibleAssemblies ← SVParseIn.ReadListOfRope[visibleAssembliesStream];
make the camera
[oldFileCamera, success] ← SVScene.FindFileCameraFromName[cameraName, currentScene];
IF success
THEN {
-- put new information in old camera
oldFileCamera.origin ← origin;
oldFileCamera.focusPoint ← focusPoint;
oldFileCamera.slant ← slant;
oldFileCamera.resolution ← resolution;
oldFileCamera.focalLength ← focalLength;
oldFileCamera.projection ← projection;
oldFileCamera.frame ← frame;
oldFileCamera.clippingPlanes ← clippingPlanes;
oldFileCamera.visibleAssemblies ← visibleAssemblies;
fileCamera ← oldFileCamera;
}
ELSE {
fileCamera ← SVScene.CreateFileCamera[cameraName, origin, focusPoint, slant, resolution, focalLength, projection, frame, clippingPlanes, visibleAssemblies];
SVScene.AddCameraToScene[fileCamera, currentScene];
};
SVViewersOnScene.SceneNewVersion[currentSVData];
IF Rope.Equal[fileCamera.name, camera.viewName,
TRUE]
THEN {
UseCameraInternal[fileCamera.name, currentScene, currentSVData];
SVEvent.EraseAndDrawScene[currentSVData]; -- Bier, April 9, 1986
};
}; -- end of SetCamera
UseCamera:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
cameraName: Rope.ROPE ← ViewerTools.GetSelectionContents[];
currentSVData: SVData ← editToolData.currentSVData;
currentScene: Scene ← currentSVData.scene;
IF Rope.Length[cameraName] = 0
THEN {
Feedback.AppendRaw[$Solidviews, "Please select a camera name.", oneLiner];
Feedback.BlinkRaw[$Solidviews];
}
ELSE {
UseCameraInternal[cameraName, currentScene, currentSVData];
SVWindow.RestoreScreenAndInvariants[paintAction: $PaintEntireScene, svData: currentSVData, remake: triggerBag, backgndOK: FALSE, edited: FALSE, okToClearFeedback: TRUE];
};
}; -- end of UseCamera
UseCameraInternal:
PRIVATE
PROC [cameraName: Rope.
ROPE, currentScene: Scene, currentSVData: SVData] = {
fileCamera: FileCamera;
success: BOOL;
style: DrawStyle;
worldCS, screenCS: CoordSystem;
worldCS ← currentScene.coordSysRoot;
screenCS ← currentSVData.camera.screenCS;
[fileCamera, success] ← SVScene.FindFileCameraFromName[cameraName, currentScene];
IF
NOT success
THEN {
Feedback.AppendRaw[$Solidviews, Rope.Cat["Camera ", cameraName, " not found"], oneLiner];
Feedback.BlinkRaw[$Solidviews];
}
ELSE {
style ← currentSVData.camera.style;
SVScene.StuffCameraFromFileCamera[currentSVData.camera, fileCamera, style, currentScene];
};
SVEvent.UpdateHeader[currentScene.name, currentSVData];
}; -- end of UseCameraInternal
GetCameraOrder:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
currentScene: Scene ← editToolData.sceneSection.currentScene;
currentSVData: SVData ← NARROW[editToolData.currentSVData];
cameraOrderStream: IO.STREAM;
cameraOrderRope: Rope.ROPE;
cameraOrderStream ← IO.ROS[];
SVParseOut.FileoutListOfRope[cameraOrderStream, currentScene.cameraOrder];
cameraOrderRope ← IO.RopeFromROS[cameraOrderStream];
ViewerTools.SetContents[editToolData.cameraOrderSection.order, cameraOrderRope];
};
SetCameraOrder:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
currentScene: Scene ← editToolData.sceneSection.currentScene;
currentSVData: SVData ← NARROW[editToolData.currentSVData];
cameraOrderRope: Rope.ROPE ← ViewerTools.GetContents[editToolData.cameraOrderSection.order];
cameraOrderStream: IO.STREAM ← IO.RIS[cameraOrderRope];
cameraOrder: LIST OF Rope.ROPE ← SVParseIn.ReadListOfRope[cameraOrderStream];
currentScene.cameraOrder ← cameraOrder;
SVViewersOnScene.SceneNewVersion[currentSVData];
}; -- end of SetCameraOrder
SetShadows:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
currentScene: Scene ← editToolData.sceneSection.currentScene;
currentSVData: SVData ← NARROW[editToolData.currentSVData];
currentScene.shadows ← editToolData.shadowSection.shadowValue;
SVViewersOnScene.SceneNewVersion[currentSVData];
}; -- end of SetShadows
NormalizeRot:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
Find the mat between source and the distinguished target, remove its rotational components leaving translation and scaling as they were.
editToolData: EditToolData ← svData.editToolData;
scene: Scene ← editToolData.sceneSection.currentScene;
found: BOOL ← TRUE;
targetCS: CoordSystem;
g: SelectionGenerator;
selectionsExist: BOOL;
targetCS ← SVSelections.TopTargetCoinCoordSys[];
IF targetCS = NIL THEN RETURN;
[g, selectionsExist] ← SVSelections.GetSelectionGenerator[movee];
SVSelections.ComplainIfNot[selectionsExist];
IF NOT selectionsExist THEN RETURN;
FOR thisSel: Selection ← SVSelections.NextSelection[g], SVSelections.NextSelection[g]
UNTIL thisSel =
NIL
DO
IF thisSel.referentType = hook
THEN
SVTransforms.NormalizeRotTug[thisSel.indirect, scene, thisSel.coincident, targetCS]
ELSE SVTransforms.NormalizeRot[thisSel.coincident, scene, targetCS];
ENDLOOP;
SVViewersOnScene.SceneNewVersion[editToolData.currentSVData];
SVViewersOnScene.PaintSceneAllViewers[$PaintEntireScene, editToolData, scene];
}; -- end of NormalizeRot
Normalize:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
Find the mat between each source and the distinguished target, remove its rotational and translational components leaving scaling as it was.
editToolData: EditToolData ← svData.editToolData;
scene: Scene ← editToolData.sceneSection.currentScene;
found: BOOL ← TRUE;
targetCS: CoordSystem;
g: SelectionGenerator;
selectionsExist: BOOL;
targetCS ← SVSelections.TopTargetCoinCoordSys[];
IF targetCS = NIL THEN RETURN;
[g, selectionsExist] ← SVSelections.GetSelectionGenerator[movee];
SVSelections.ComplainIfNot[selectionsExist];
IF NOT selectionsExist THEN RETURN;
FOR thisSel: Selection ← SVSelections.NextSelection[g], SVSelections.NextSelection[g]
UNTIL thisSel =
NIL
DO
IF thisSel.referentType = hook
THEN
SVTransforms.NormalizeTug[thisSel.indirect, scene, thisSel.coincident, targetCS]
ELSE SVTransforms.Normalize[thisSel.coincident, scene, targetCS];
ENDLOOP;
SVViewersOnScene.SceneNewVersion[editToolData.currentSVData];
SVViewersOnScene.PaintSceneAllViewers[$PaintEntireScene, editToolData, scene];
}; -- end of Normalize
Align:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
Find the mat between each source and the distinguished target, rotate it as little as possible so that the axes of the source are parallel to some ordering of the axes of the target.
editToolData: EditToolData ← svData.editToolData;
scene: Scene ← editToolData.sceneSection.currentScene;
found: BOOL ← TRUE;
targetCS: CoordSystem;
g: SelectionGenerator;
selectionsExist: BOOL;
targetCS ← SVSelections.TopTargetCoinCoordSys[];
IF targetCS = NIL THEN RETURN;
[g, selectionsExist] ← SVSelections.GetSelectionGenerator[movee];
SVSelections.ComplainIfNot[selectionsExist];
IF NOT selectionsExist THEN RETURN;
FOR thisSel: Selection ← SVSelections.NextSelection[g], SVSelections.NextSelection[g]
UNTIL thisSel =
NIL
DO
IF thisSel.referentType = hook
THEN
SVTransforms.AlignTug[thisSel.indirect, scene, thisSel.coincident, targetCS]
ELSE SVTransforms.Align[thisSel.coincident, scene, targetCS];
ENDLOOP;
SVViewersOnScene.SceneNewVersion[editToolData.currentSVData];
SVViewersOnScene.PaintSceneAllViewers[$PaintEntireScene, editToolData, scene];
}; -- end of Align
Abut:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
Simply translate each source to the origin of the distinguished target.
editToolData: EditToolData ← svData.editToolData;
scene: Scene ← editToolData.sceneSection.currentScene;
found: BOOL ← TRUE;
targetCS: CoordSystem;
g: SelectionGenerator;
selectionsExist: BOOL;
targetCS ← SVSelections.TopTargetCoinCoordSys[];
IF targetCS = NIL THEN RETURN;
[g, selectionsExist] ← SVSelections.GetSelectionGenerator[movee];
SVSelections.ComplainIfNot[selectionsExist];
IF NOT selectionsExist THEN RETURN;
FOR thisSel: Selection ← SVSelections.NextSelection[g], SVSelections.NextSelection[g]
UNTIL thisSel =
NIL
DO
IF thisSel.referentType = hook
THEN
SVTransforms.AbutTug[thisSel.indirect, scene, thisSel.coincident, targetCS]
ELSE SVTransforms.Abut[thisSel.coincident, scene, targetCS];
ENDLOOP;
SVViewersOnScene.SceneNewVersion[editToolData.currentSVData];
SVViewersOnScene.PaintSceneAllViewers[$PaintEntireScene, editToolData, scene];
}; -- end of Abut
AbutX:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
AbutAxis[editToolData, 1];
};
AbutY:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
AbutAxis[editToolData, 2];
};
AbutZ:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
AbutAxis[editToolData, 3];
};
AbutAxis:
PUBLIC
PROC [editToolData: EditToolData, axis: [1..3]] = {
Change the x translation between each source and the distinguished target to be zero.
scene: Scene ← editToolData.sceneSection.currentScene;
found: BOOL ← TRUE;
targetCS: CoordSystem;
g: SelectionGenerator;
selectionsExist: BOOL;
targetCS ← SVSelections.TopTargetCoinCoordSys[];
IF targetCS = NIL THEN RETURN;
[g, selectionsExist] ← SVSelections.GetSelectionGenerator[movee];
SVSelections.ComplainIfNot[selectionsExist];
IF NOT selectionsExist THEN RETURN;
FOR thisSel: Selection ← SVSelections.NextSelection[g], SVSelections.NextSelection[g]
UNTIL thisSel =
NIL
DO
IF thisSel.referentType = hook
THEN
SVTransforms.AbutTugAxis[thisSel.indirect, scene, axis, thisSel.coincident, targetCS]
ELSE SVTransforms.AbutAxis[thisSel.coincident, scene, axis, targetCS];
ENDLOOP;
SVViewersOnScene.SceneNewVersion[editToolData.currentSVData];
SVViewersOnScene.PaintSceneAllViewers[$PaintEntireScene, editToolData, scene];
}; -- end of AbutAxis
ProjectionCycle:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
editToolData.cameraSection.projectionValue ← IF editToolData.cameraSection.projectionValue = globalProjectionCount THEN 1 ELSE editToolData.cameraSection.projectionValue + 1;
Labels.Set[editToolData.cameraSection.projection, globalProjectionArray[editToolData.cameraSection.projectionValue]];
};
MaterialCycle:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
editToolData.artworkSection.materialValue ← IF editToolData.artworkSection.materialValue = globalMatCount THEN 1 ELSE editToolData.artworkSection.materialValue + 1;
Labels.Set[editToolData.artworkSection.material, globalMatArray[editToolData.artworkSection.materialValue]];
};
ShadowsPrompt:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
IF editToolData.shadowSection.shadowValue
THEN {
Labels.Set[editToolData.shadowSection.shadowLabel, "FALSE"];
editToolData.shadowSection.shadowValue ← FALSE;
}
ELSE {
Labels.Set[editToolData.shadowSection.shadowLabel, "TRUE"];
editToolData.shadowSection.shadowValue ← TRUE;
};
};
AddLight:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
scene: Scene ← editToolData.sceneSection.currentScene;
lightsource: LightSource;
name: Rope.ROPE;
position: Point3d;
success, alreadyPresent: BOOL;
color: Color;
arg: ATOM ← NARROW[event.rest.first];
name ← ViewerTools.GetContents[editToolData.lightSection.name];
[position[1], position[2], position[3]] ←
SVViewerTools.GetThreeReals[editToolData.lightSection.position];
[color, success] ← SVViewerTools.GetColor[editToolData.lightSection.color];
IF NOT success THEN RETURN;
IF arg = $Add
THEN {
lightsource ← SVScene.CreateLightSource[name, position, color];
alreadyPresent ← FALSE;
SVScene.AddLightSourceToScene[lightsource, scene
!SVScene.NameAlreadyPresent => {alreadyPresent ← TRUE; CONTINUE}];
IF alreadyPresent
THEN {
Feedback.AppendRaw[$Solidviews, Rope.Cat["Lightsource named ", name, " is already present"], oneLiner];
Feedback.BlinkRaw[$Solidviews];
RETURN}
}
ELSE
IF arg = $Replace
THEN {
[lightsource, success] ← SVScene.FindLightFromName[name, scene];
IF NOT success THEN {
Feedback.AppendRaw[$Solidviews, Rope.Cat["Lightsource named ", name, " is not present"], oneLiner];
Feedback.BlinkRaw[$Solidviews];
RETURN};
lightsource.position ← position;
lightsource.color ← color;
}
ELSE Feedback.PutF[svData.feedback, oneLiner, "Illegal option: %g", [rope[Atom.GetPName[arg]]]];
SVViewersOnScene.PaintSceneAllViewers[paintAction: $PaintEntireScene, editToolData: editToolData, scene: scene, remake: none, backgndOK: FALSE, edited: TRUE, okToClearFeedback: FALSE];
};
DeleteLight:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
scene: Scene ← editToolData.sceneSection.currentScene;
name: Rope.ROPE;
name ← ViewerTools.GetContents[editToolData.lightSection.name];
SVScene.DeleteLightSourceNamed[name, scene];
SVViewersOnScene.SceneNewVersion[editToolData.currentSVData];
SVViewersOnScene.PaintSceneAllViewers[$PaintEntireScene, editToolData, scene];
};
EditLight:
PUBLIC
PROC [event:
LIST
OF
REF
ANY, svData: SVData] = {
editToolData: EditToolData ← svData.editToolData;
scene: Scene ← editToolData.sceneSection.currentScene;
success: BOOL;
lightName: Rope.ROPE;
light: LightSource;
lightName ← ViewerTools.GetContents[editToolData.lightSection.name];
[light, success] ← SVScene.FindLightFromName[lightName, scene];
IF
NOT success
THEN {
Feedback.AppendRaw[$Solidviews, Rope.Cat["Lightsource: ", lightName, "not found."], oneLiner];
Feedback.BlinkRaw[$Solidviews];
RETURN;
};
Stuff position and color into the appropriate spaces.
SVViewerTools.SetThreeReals[editToolData.lightSection.position, light.position[1], light.position[2], light.position[3]];
SVViewerTools.SetColor[editToolData.lightSection.color, light.color];
}; -- end of EditLight
END.