<> <> <> <> 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 <> 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; <> 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.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 { <> 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 { <> <> ViewerTools.SetContents[editToolData.cameraSection.name, cameraName]; <> 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]; <> 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]; <> outStream _ IO.ROS[]; TFO3d.FileoutFrame[outStream, fileCamera.frame]; frameRope _ IO.RopeFromROS[outStream]; IO.Close[outStream]; ViewerTools.SetContents[editToolData.cameraSection.frame, frameRope]; <> 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; <> 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 _ SVEditUser.GetPoint3d[editToolData.cameraSection.origin]; focusPoint _ SVEditUser.GetPoint3d[editToolData.cameraSection.focusPoint]; slant _ SVViewerTools.GetReal[editToolData.cameraSection.slant, 0]; <> 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; <> frameRope _ ViewerTools.GetContents[editToolData.cameraSection.frame]; frameStream _ IO.RIS[frameRope]; frame _ TFI3d.ReadFrame[frameStream]; <> <> 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]; <> [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 { <> 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 { <> 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 { <> 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 { <> 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 { <> 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 { <> 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 { <> 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; }; <> 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.