File: SVEditUserImplD.mesa
Last edited by Bier on May 24, 1985 0:12:41 am 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
CSGGraphics,
DisplayList3d,
Fileout3d,
GraphicsColor,
IO,
Labels,
Menus,
Rope,
SV2d,
SV3d,
SVCoordSys2d,
SVEditUser,
SVEditUserB,
SVError,
SVInterfaceTypes,
SVModelTypes,
SVSceneTypes,
SVSelections,
SVTransforms,
SVViewerTools,
SVViewerUser,
TFI3d,
TFO3d,
ViewerClasses,
ViewerTools;
SVEditUserImplD:
CEDAR
PROGRAM
IMPORTS CSGGraphics, DisplayList3d, Fileout3d, IO, Labels, Rope, SVEditUser, SVError, SVSelections, SVTransforms, SVViewerTools, SVViewerUser, TFI3d, TFO3d, ViewerTools
EXPORTS SVEditUser, SVEditUserB =
BEGIN
IMPORTED TYPES
Artwork: TYPE = SVModelTypes.Artwork;
Assembly: TYPE = SVSceneTypes.Assembly;
AssemblyList: TYPE = SVSceneTypes.AssemblyList;
AssemblyGenerator: TYPE = DisplayList3d.AssemblyGenerator;
Camera: TYPE = SVModelTypes.Camera;
Color: TYPE = GraphicsColor.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 = DisplayList3d.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;
ViewerToolData: TYPE = SVInterfaceTypes.ViewerToolData;
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 [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
g: DisplayList3d.SceneGenerator;
scene: Scene;
outHandle: IO.STREAM ← SVError.GetErrorStream[];
g ← DisplayList3d.GetSceneGenerator[];
scene ← DisplayList3d.NextScene[g];
outHandle.PutRope["Listing Current Scenes...\n"];
UNTIL scene = NIL DO
outHandle.PutF[" %g\n",[rope[scene.name]]];
scene ← DisplayList3d.NextScene[g];
ENDLOOP;
}; -- end of ListScenes
ListAssemblies:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
name: Rope.ROPE;
outHandle: IO.STREAM ← SVError.GetErrorStream[];
g: AssemblyGenerator;
a: Assembly;
outHandle.PutF["Listing top level assemblies in scene: %g\n",
[rope[scene.name]]];
g ← DisplayList3d.GetAssemblyGenerator[scene];
a ← DisplayList3d.NextAssembly[g];
UNTIL a =
NIL
DO
name ← a.name;
outHandle.PutF[" %g coordSys: %g wrt: %g",
[rope[name]], [rope[a.coordSys.name]], [rope[a.coordSys.parent.name]]];
IF ISTYPE[a.shape, AssemblyList] THEN outHandle.PutF[" [cluster]\n"]
ELSE outHandle.PutF[" [primitive]\n"];
a ← DisplayList3d.NextAssembly[g];
ENDLOOP;
}; -- end of ListAssemblies
ListCoordSystems:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
currentScene: Scene ← editToolData.sceneSection.currentScene;
g: DisplayList3d.CoordSysGenerator;
outHandle: IO.STREAM ← SVError.GetErrorStream[];
g ← DisplayList3d.GetCoordSysGenerator[currentScene];
outHandle.PutF["Listing Current CoordinateSystems in %g...\n", [rope[currentScene.name]]];
FOR cs: CoordSystem ← DisplayList3d.NextCoordSys[g], DisplayList3d.NextCoordSys[g]
UNTIL cs =
NIL
DO
outHandle.PutF[" %g",[rope[cs.name]]];
outHandle.PutChar[IO.SP];
outHandle.PutRope["parent: "];
IF cs.parent = NIL
THEN IO.PutRope[outHandle,"NIL"]
ELSE IO.PutRope[outHandle, cs.parent.name];
IF cs.scalarsOnly
THEN {
IO.PutRope[outHandle, " scalars: "];
TFO3d.FileoutPoint3d[outHandle, cs.scalars];
}
ELSE {
IO.PutRope[outHandle, " mat:\n"];
TFO3d.FileoutMatrix[outHandle, cs.mat];
IO.PutChar[outHandle, IO.CR];
IO.PutRope[outHandle, "wrtCamera:\n"];
TFO3d.FileoutMatrix[outHandle, cs.wrtCamera];
};
IO.PutChar[outHandle, IO.CR];
IO.PutChar[outHandle, IO.CR];
ENDLOOP;
}; -- end of ListCoordSystems
ListLights:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
currentScene: Scene ← editToolData.sceneSection.currentScene;
outHandle: IO.STREAM ← SVError.GetErrorStream[];
outHandle.PutRope["Listing Current LightSources...\n"];
Fileout3d.FileoutLightSources[outHandle, currentScene.lightSources];
};
ListMasterObjects:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
currentScene: Scene ← editToolData.sceneSection.currentScene;
outHandle: IO.STREAM ← SVError.GetErrorStream[];
list: MasterObjectList;
outHandle.PutRope["Listing Current MasterObjects...\n"];
FOR list ← DisplayList3d.MasterObjectsOfScene[currentScene], list.rest
UNTIL list =
NIL
DO
outHandle.PutF["%g\n",
[rope[list.first.name]] ];
ENDLOOP;
};
ListViewers:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
viewerToolData: ViewerToolData;
firstViewer: Viewer;
count: NAT;
outHandle: IO.STREAM ← SVError.GetErrorStream[];
FOR allList:
LIST
OF ViewerCell ← editToolData.allViewers, allList.rest
UNTIL allList =
NIL
DO
firstViewer ← allList.first.viewersOnScene;
IF firstViewer = NIL THEN LOOP;
viewerToolData ← NARROW[firstViewer.data];
outHandle.PutF["\n%g: 1", [rope[viewerToolData.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 [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
currentScene: Scene ← editToolData.sceneSection.currentScene;
outHandle: IO.STREAM ← SVError.GetErrorStream[];
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 [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
Get the camera named in the "name" slot of the edittool camera section.
cameraName: Rope.ROPE ← ViewerTools.GetSelectionContents[];
editToolData: EditToolData ← NARROW[clientData];
GetCameraNamed[cameraName, editToolData];
};
GetCameraNamed:
PUBLIC
PROC [cameraName: Rope.
ROPE, editToolData: EditToolData] =
TRUSTED {
currentScene: Scene ← editToolData.sceneSection.currentScene;
success: BOOL;
outStream: IO.STREAM;
fileCamera: FileCamera;
frameRope, visibleAssemblyRope, clippingRope, projectionRope: Rope.ROPE;
IF Rope.Length[cameraName] = 0
THEN {
SVError.Append["Please select a camera name.", TRUE, TRUE];
SVError.Blink[];
RETURN;
};
[fileCamera, success] ← DisplayList3d.FindFileCameraFromName[cameraName, currentScene];
IF
NOT success
THEN {
SVError.Append[Rope.Cat["Camera ", cameraName, " not found"], TRUE, TRUE];
SVError.Blink[];
}
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 ← CSGGraphics.ProjectionToRope[fileCamera.projection];
ViewerTools.SetContents[editToolData.cameraSection.projection, projectionRope];
frame
outStream ← IO.ROS[];
TFO3d.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[];
TFO3d.FileoutClippingPlanes[outStream, fileCamera.clippingPlanes];
clippingRope ← IO.RopeFromROS[outStream, FALSE];
ViewerTools.SetContents[editToolData.cameraSection.clippingPlanes, clippingRope];
IO.Reset[outStream];
TFO3d.FileoutListOfRope[outStream, fileCamera.visibleAssemblies];
visibleAssemblyRope ← IO.RopeFromROS[outStream, TRUE];
ViewerTools.SetContents[editToolData.cameraSection.visibleAssemblies, visibleAssemblyRope];
};
}; -- end of GetCameraNamed
SetCamera:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
currentScene: Scene ← editToolData.sceneSection.currentScene;
currentViewerToolData: ViewerToolData ← NARROW[editToolData.currentViewerToolData];
camera: Camera ← currentViewerToolData.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 {
SVError.Append["Please give camera a name.", TRUE, TRUE];
SVError.Blink[];
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] ← CSGGraphics.RopeToProjection[projectionRope];
IF NOT success THEN projection ← perspective;
frame
frameRope ← ViewerTools.GetContents[editToolData.cameraSection.frame];
frameStream ← IO.RIS[frameRope];
frame ← TFI3d.ReadFrame[frameStream];
clipping planes and visible Assemblies
just one clipping plane for now
clippingPlaneRope ← ViewerTools.GetContents[editToolData.cameraSection.clippingPlanes];
clippingStream ← IO.RIS[clippingPlaneRope];
clippingPlanes ← TFI3d.ReadClippingPlanes[clippingStream];
visibleAssembliesRope ← ViewerTools.GetContents[editToolData.cameraSection.visibleAssemblies];
visibleAssembliesStream ← IO.RIS[visibleAssembliesRope];
visibleAssemblies ← TFI3d.ReadListOfRope[visibleAssembliesStream];
make the camera
[oldFileCamera, success] ← DisplayList3d.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 ← DisplayList3d.CreateFileCamera[cameraName, origin, focusPoint, slant, resolution, focalLength, projection, frame, clippingPlanes, visibleAssemblies];
DisplayList3d.AddCameraToScene[fileCamera, currentScene];
};
SVEditUser.SceneNewVersion[currentViewerToolData];
IF Rope.Equal[fileCamera.name, camera.viewName, TRUE] THEN UseCameraInternal[fileCamera.name, currentScene, currentViewerToolData];
}; -- end of SetCamera
UseCamera:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
cameraName: Rope.ROPE ← ViewerTools.GetSelectionContents[];
currentViewerToolData: ViewerToolData ← NARROW[editToolData.currentViewerToolData];
currentScene: Scene ← editToolData.sceneSection.currentScene;
IF Rope.Length[cameraName] = 0
THEN {
SVError.Append["Please select a camera name.", TRUE, TRUE];
SVError.Blink[];
}
ELSE UseCameraInternal[cameraName, currentScene, currentViewerToolData];
}; -- end of UseCamera
UseCameraInternal:
PRIVATE
PROC [cameraName: Rope.
ROPE, currentScene: Scene, currentViewerToolData: ViewerToolData] =
TRUSTED {
fileCamera: FileCamera;
success: BOOL;
style: DrawStyle;
worldCS, screenCS: CoordSystem;
worldCS ← currentScene.coordSysRoot;
screenCS ← currentViewerToolData.camera.screenCS;
style ← currentViewerToolData.camera.style;
[fileCamera, success] ← DisplayList3d.FindFileCameraFromName[cameraName, currentScene];
IF
NOT success
THEN {
SVError.Append[Rope.Cat["Camera ", cameraName, " not found"], TRUE, TRUE];
SVError.Blink[];
}
ELSE {
DisplayList3d.StuffCameraFromFileCamera[currentViewerToolData.camera, fileCamera, style];
};
SVViewerUser.EraseAndDrawScene[currentViewerToolData];
SVViewerUser.UpdateHeader[currentScene.name, currentViewerToolData];
}; -- end of UseCameraInternal
GetCameraOrder:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
currentScene: Scene ← editToolData.sceneSection.currentScene;
currentViewerToolData: ViewerToolData ← NARROW[editToolData.currentViewerToolData];
cameraOrderStream: IO.STREAM;
cameraOrderRope: Rope.ROPE;
cameraOrderStream ← IO.ROS[];
TFO3d.FileoutListOfRope[cameraOrderStream, currentScene.cameraOrder];
cameraOrderRope ← IO.RopeFromROS[cameraOrderStream];
ViewerTools.SetContents[editToolData.cameraOrderSection.order, cameraOrderRope];
};
SetCameraOrder:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
currentScene: Scene ← editToolData.sceneSection.currentScene;
currentViewerToolData: ViewerToolData ← NARROW[editToolData.currentViewerToolData];
cameraOrderRope: Rope.ROPE ← ViewerTools.GetContents[editToolData.cameraOrderSection.order];
cameraOrderStream: IO.STREAM ← IO.RIS[cameraOrderRope];
cameraOrder: LIST OF Rope.ROPE ← TFI3d.ReadListOfRope[cameraOrderStream];
currentScene.cameraOrder ← cameraOrder;
SVEditUser.SceneNewVersion[currentViewerToolData];
}; -- end of SetCameraOrder
SetShadows:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
currentScene: Scene ← editToolData.sceneSection.currentScene;
currentViewerToolData: ViewerToolData ← NARROW[editToolData.currentViewerToolData];
currentScene.shadows ← editToolData.shadowSection.shadowValue;
SVEditUser.SceneNewVersion[currentViewerToolData];
}; -- end of SetShadows
NormalizeRot:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
Find the mat between source and the distinguished target, remove its rotational components leaving translation and scaling as they were.
editToolData: EditToolData ← NARROW[clientData];
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.coordSys, thisSel.coincident.coordSys, targetCS]
ELSE SVTransforms.NormalizeRot[thisSel.coincident.coordSys, targetCS];
ENDLOOP;
SVEditUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene];
}; -- end of NormalizeRot
Normalize:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
Find the mat between each source and the distinguished target, remove its rotational and translational components leaving scaling as it was.
editToolData: EditToolData ← NARROW[clientData];
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.coordSys, thisSel.coincident.coordSys, targetCS]
ELSE SVTransforms.Normalize[thisSel.coincident.coordSys, targetCS];
ENDLOOP;
SVEditUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene];
}; -- end of Normalize
Align:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
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 ← NARROW[clientData];
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.coordSys, thisSel.coincident.coordSys, targetCS]
ELSE SVTransforms.Align[thisSel.coincident.coordSys, targetCS];
ENDLOOP;
SVEditUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene];
}; -- end of Align
Abut:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
Simply translate each source to the origin of the distinguished target.
editToolData: EditToolData ← NARROW[clientData];
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.coordSys, thisSel.coincident.coordSys, targetCS]
ELSE SVTransforms.Abut[thisSel.coincident.coordSys, targetCS];
ENDLOOP;
SVEditUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene];
}; -- end of Abut
AbutX:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
Change the x translation between each source and the distinguished target to be zero.
editToolData: EditToolData ← NARROW[clientData];
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.AbutXTug[thisSel.indirect.coordSys, thisSel.coincident.coordSys, targetCS]
ELSE SVTransforms.AbutX[thisSel.coincident.coordSys, targetCS];
ENDLOOP;
SVEditUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene];
}; -- end of AbutX
AbutY:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
Change the y translation between each source and the distinguished target to be zero.
editToolData: EditToolData ← NARROW[clientData];
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.AbutYTug[thisSel.indirect.coordSys, thisSel.coincident.coordSys, targetCS]
ELSE SVTransforms.AbutY[thisSel.coincident.coordSys, targetCS];
ENDLOOP;
SVEditUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene];
}; -- end of AbutY
AbutZ:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
Change the z translation between each source and the distinguished target to be zero.
editToolData: EditToolData ← NARROW[clientData];
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.AbutZTug[thisSel.indirect.coordSys, thisSel.coincident.coordSys, targetCS]
ELSE SVTransforms.AbutZ[thisSel.coincident.coordSys, targetCS];
ENDLOOP;
SVEditUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene];
}; -- end of AbutZ
ProjectionCycle:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
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 [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
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 [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] = {
editToolData: EditToolData ← NARROW[clientData];
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 [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
lightsource: LightSource;
name: Rope.ROPE;
position: Point3d;
success, alreadyPresent: BOOL;
color: Color;
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 mouseButton = red
OR mouseButton = yellow
THEN {
lightsource ← DisplayList3d.CreateLightSource[name, position, color];
alreadyPresent ← FALSE;
DisplayList3d.AddLightSourceToScene[lightsource, scene
!DisplayList3d.NameAlreadyPresent => {alreadyPresent ← TRUE; CONTINUE}];
IF alreadyPresent
THEN {
SVError.Append[Rope.Cat["Lightsource named ", name, " is already present"], TRUE, TRUE];
SVError.Blink[];
RETURN}
}
ELSE {
[lightsource, success] ← DisplayList3d.FindLightFromName[name, scene];
IF NOT success THEN {
SVError.Append[Rope.Cat["Lightsource named ", name, " is not present"], TRUE, TRUE];
SVError.Blink[];
RETURN};
lightsource.position ← position;
lightsource.color ← color;
};
SVEditUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene];
};
DeleteLight:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
name: Rope.ROPE;
name ← ViewerTools.GetContents[editToolData.lightSection.name];
DisplayList3d.DeleteLightSourceNamed[name, scene];
SVEditUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene];
};
EditLight:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
success: BOOL;
lightName: Rope.ROPE;
light: LightSource;
lightName ← ViewerTools.GetContents[editToolData.lightSection.name];
[light, success] ← DisplayList3d.FindLightFromName[lightName, scene];
IF
NOT success
THEN {
SVError.Append[Rope.Cat["Lightsource: ", lightName, "not found."], TRUE, TRUE];
SVError.Blink[];
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.