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. €File: SVEditUserImplD.mesa Last edited by Bier on May 24, 1985 0:12:41 am PDT Copyright c 1984 by Xerox Corporation. All rights reserved. Contents: All of the procedures called by SVEditTool when menus and buttons are pressed (part 4) IMPORTED TYPES GLOBAL VARIABLES IO.PutChar[outHandle, IO.CR]; IO.PutRope[outHandle, "wrtCamera:\n"]; TFO3d.FileoutMatrix[outHandle, cs.wrtCamera]; Get the camera named in the "name" slot of the edittool camera section. Stuff all of the file camera fields into the appropriate slots. name origin, focus point and slant resolution, focal length, and projection frame clipping planes and visible assemblies name origin, focus point, and slant resolution, focal length and projection frame clipping planes and visible Assemblies just one clipping plane for now make the camera Find the mat between source and the distinguished target, remove its rotational components leaving translation and scaling as they were. Find the mat between each source and the distinguished target, remove its rotational and translational components leaving scaling as it was. 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. Simply translate each source to the origin of the distinguished target. Change the x translation between each source and the distinguished target to be zero. Change the y translation between each source and the distinguished target to be zero. Change the z translation between each source and the distinguished target to be zero. Stuff position and color into the appropriate spaces. ส{˜Iheadšœ™Jšœ2™2Jšœ ฯmœ1™Jšœžœ˜Jšœžœ˜Jšœ žœ˜Jšœ žœ˜+Jšœžœ˜!Jšœ žœ˜-Jšœžœ'˜?Jšœžœ˜Jšœžœ˜1Jšœžœ˜Jšœžœ˜Jšœžœ˜$Jšœ žœ˜/Jšœžœ#˜7—J˜Jšœ™˜Jšœžœ$˜>Jš œžœžœžœžœ˜MJšœ˜Jšœžœ˜0Jš œžœžœžœžœ˜?Jšœ˜—J˜—šฯn œžœžœ žœžœžœžœ,žœžœ˜zJšœ ˜ Jšœ ˜ Jšœ žœžœ˜0Jšœ&˜&Jšœ#˜#šœ1˜1Jšžœ žœž˜Jšœ,˜,Jšœ#˜#—Jšžœ˜Jšœฯc˜—šŸœžœžœ žœžœžœžœ,žœžœ˜~Jšœžœ ˜0Jšœ6˜6Jšœ žœ˜Jšœ žœžœ˜0Jšœ˜Jšœ ˜ Jšœ=˜=Jšœ˜Jšœ.˜.Jšœ"˜"šžœžœž˜Jšœ˜Jšœ+˜+JšœG˜GJšžœžœžœ˜DJšžœ"˜&Jšœ"˜"—Jšžœ˜Jšœ ˜J˜—šŸœžœžœ žœžœžœžœ,žœžœ˜€Jšœžœ ˜0Jšœ=˜=Jšœ#˜#Jšœ žœžœ˜0Jšœ5˜5J˜JšœZ˜ZšžœPžœžœž˜dJšœ'˜'Jšœžœžœ˜Jšœ˜Jšžœ ž˜Jšžœžœ˜ Jšžœžœ$˜+šžœžœ˜Jšžœ"˜$Jšœ,˜,J˜—šžœ˜Jšžœ˜!Jšœ'˜'Jšžœžœžœ™Jšžœ$™&Jšœ-™-J˜—Jšžœžœžœ˜Jšžœžœžœ˜—Jšžœ˜Jšœ ˜J˜—šŸ œžœžœ žœžœžœžœ,žœžœ˜zJšœžœ ˜0Jšœ=˜=Jšœ žœžœ˜0Jšœ7˜7JšœD˜DJšœ˜—šŸœžœžœ žœžœžœžœ,žœžœ˜Jšœžœ ˜0Jšœ=˜=Jšœ žœžœ˜0Jšœ˜Jšœ8˜8šžœDžœžœž˜ZJšœ˜Jšœ˜—Jšžœ˜Jšœ˜J˜—šŸ œžœžœ žœžœžœžœ,žœžœ˜{Jšœžœ ˜0Jšœ˜Jšœ˜Jšœžœ˜ Jšœ žœžœ˜0š žœ žœžœ4žœ žœž˜^Jšœ+˜+Jšžœžœžœžœ˜Jšœžœ˜*Jšœ=˜=Jšœ ˜ šžœ7˜:Jšžœžœžœž˜5Jšœ˜Jšœ)˜)—Jšžœ˜—Jšžœ˜Jšœ˜J˜—šŸ œžœžœ žœžœžœžœ,žœžœ˜{Jšœžœ ˜0Jšœ=˜=Jšœ žœžœ˜0Jšœ˜Jšœ2˜2šžœ(žœžœž˜>Jšœ˜Jšœ˜—Jšžœ˜Jšœ˜—J˜šŸ œžœžœ žœžœžœžœ,žœžœ˜yJšœG™GJšœžœ&˜;Jšœžœ ˜0Jšœ)˜)J˜J™—š Ÿœžœžœžœ žœ˜[Jšœ=˜=Jšœ žœ˜Jšœ žœžœ˜Jšœ˜JšœCžœ˜Išžœžœ˜%Jšœ/žœžœ˜;J˜Jšžœ˜J˜—JšœW˜Wšžœžœ žœ˜Jšœ>žœžœ˜JJšœ˜Jšœ˜—šžœ˜Jšœ?™?Jšฯb™JšœF˜FJšก™Jšœ˜Jšœ‘˜‘JšœJ˜JJ˜Jšก(™(JšœT˜TJšœV˜VJšœE˜EJšœO˜OJ˜Jšก™Jšœ žœžœ˜Jšœ0˜0Jšœ žœ˜&Jšžœ˜JšœE˜EJ˜Jšก&™&Jšœ žœžœ˜JšœB˜BJšœžœžœ˜0JšœQ˜QJšžœ˜JšœA˜AJšœžœžœ˜6Jšœ[˜[Jšœ˜—Jšœ ˜J˜—šŸ œžœžœ žœžœžœžœ,žœžœ˜yJšœžœ ˜0Jšœ=˜=Jšœ(žœ%˜SJšœ.˜.Jšœ˜Jšœ žœ˜Jšœ žœ˜%JšœFžœ˜KJšœ˜J˜&Jšœ6žœžœ˜@Jšœžœžœ˜Jšœžœžœžœ˜%Jšœ˜Jšœžœ˜J˜Jšก™JšœF˜Fšžœžœ˜%Jšœ-žœžœ˜9J˜Jšžœ˜J˜—J˜Jšก™JšœB˜BJšœJ˜JJšœC˜CJ˜Jšก'™'JšœP˜PJšœR˜RJšœP˜PJšœE˜EJšžœžœ žœ˜-J˜Jšก™JšœF˜FJšœžœžœ ˜ Jšœ%˜%J˜Jšก&™&Jšœ™JšœW˜WJšœžœžœ˜+Jšœ:˜:Jšœ^˜^Jšœžœžœ˜8JšœC˜CJšก™JšœZ˜Zšžœ žœ $˜5Jšœ˜Jšœ&˜&Jšœ˜Jšœ&˜&Jšœ(˜(Jšœ&˜&Jšœ˜Jšœ.˜.Jšœ4˜4Jšœ˜Jšœ˜—šžœ˜Jšœข˜ขJšœ9˜9Jšœ˜—Jšœ2˜2Jšžœ.žœžœI˜ƒJšœ ˜J˜—šŸ œžœžœ žœžœžœžœ,žœžœ˜yJšœžœ ˜0Jšœžœ&˜;Jšœ(žœ%˜SJšœ=˜=šžœžœ˜%Jšœ/žœžœ˜;J˜J˜—JšžœD˜HJšœ ˜J˜—š Ÿœžœžœžœ@žœ˜Jšœ˜Jšœ žœ˜Jšœ˜Jšœ˜Jšœ$˜$Jšœ1˜1Jšœ+˜+JšœW˜Wšžœžœ žœ˜Jšœ>žœžœ˜JJšœ˜Jšœ˜—šžœ˜JšœY˜YJšœ˜—Jšœ6˜6JšœD˜DJšœ ˜—šŸœžœžœ žœžœžœžœ,žœžœ˜~Jšœžœ ˜0Jšœ=˜=Jšœ(žœ%˜SJšœžœžœ˜Jšœžœ˜Jšœžœžœ˜JšœE˜EJšœžœ ˜4JšœP˜PJ˜J˜—šŸœžœžœ žœžœžœžœ,žœžœ˜~Jšœžœ ˜0Jšœ=˜=Jšœ(žœ%˜SJšœžœB˜\Jš œžœžœžœžœ˜7Jšœ žœžœžœ+˜IJšœ'˜'Jšœ2˜2Jšœ Ÿ˜—šŸ œžœžœ žœžœžœžœ,žœžœ˜zJšœžœ ˜0Jšœ=˜=Jšœ(žœ%˜SJšœ>˜>Jšœ2˜2Jšœ ˜—J˜šŸ œžœžœ žœžœžœžœ,žœžœ˜|Jšœˆ™ˆJšœžœ ˜0Jšœ6˜6Jšœžœžœ˜Jšœ˜Jšœ˜Jšœžœ˜J˜Jšœ0˜0Jšžœ žœžœžœ˜JšœA˜AJšœ,˜,Jšžœžœžœžœ˜#šžœSžœ žœž˜lšžœž˜#Jšœ กœB˜^—Jšžœก œ(˜F—Jšžœ˜Jšœ?˜?IprocšœX˜XJšœ ˜J˜—šŸ œžœžœ žœžœžœžœ,žœžœ˜yJšœŒ™ŒJšœžœ ˜0Jšœ6˜6Jšœžœžœ˜Jšœ˜Jšœ˜Jšœžœ˜J˜Jšœ0˜0Jšžœ žœžœžœ˜JšœA˜AJšœ,˜,Jšžœžœžœžœ˜#šžœSžœ žœž˜lšžœž˜#Jšœ ก œB˜[—Jšžœก œ(˜C—Jšžœ˜Jšœ?˜?LšœX˜XJšœ ˜—šŸœžœžœ žœžœžœžœ,žœžœ˜uJšœถ™ถJšœžœ ˜0Jšœ6˜6Jšœžœžœ˜Jšœ˜Jšœ˜Jšœžœ˜J˜Jšœ0˜0Jšžœ žœžœžœ˜JšœA˜AJšœ,˜,Jšžœžœžœžœ˜#šžœSžœ žœž˜lšžœž˜#Jšœ กœB˜W—Jšžœกœ(˜?—Jšžœ˜Jšœ?˜?LšœX˜XJšœ ˜—šŸœžœžœ žœžœžœžœ,žœžœ˜tJšœG™GJšœžœ ˜0Jšœ6˜6Jšœžœžœ˜Jšœ˜Jšœ˜Jšœžœ˜J˜Jšœ0˜0Jšžœ žœžœžœ˜JšœA˜AJšœ,˜,Jšžœžœžœžœ˜#šžœSžœ žœž˜lšžœž˜#Jšœ กœB˜V—Jšžœกœ(˜>—Jšžœ˜Jšœ?˜?LšœX˜XJšœ ˜—šŸœžœžœ žœžœžœžœ,žœžœ˜uJšœU™UJšœžœ ˜0Jšœ6˜6Jšœžœžœ˜Jšœ˜Jšœ˜Jšœžœ˜J˜Jšœ0˜0Jšžœ žœžœžœ˜JšœA˜AJšœ,˜,Jšžœžœžœžœ˜#šžœSžœ žœž˜lšžœž˜#Jšœ กœB˜W—Jšžœกœ(˜?—Jšžœ˜Jšœ?˜?LšœX˜XJšœ ˜—šŸœžœžœ žœžœžœžœ,žœžœ˜uJšœU™UJšœžœ ˜0Jšœ6˜6Jšœžœžœ˜Jšœ˜Jšœ˜Jšœžœ˜J˜Jšœ0˜0Jšžœ žœžœžœ˜JšœA˜AJšœ,˜,Jšžœžœžœžœ˜#šžœSžœ žœž˜lšžœž˜#Jšœ กœB˜W—Jšžœกœ(˜?—Jšžœ˜Jšœ?˜?LšœX˜XJšœ ˜—šŸœžœžœ žœžœžœžœ,žœžœ˜uJšœU™UJšœžœ ˜0Jšœ6˜6Jšœžœžœ˜Jšœ˜Jšœ˜Jšœžœ˜J˜Jšœ0˜0Jšžœ žœžœžœ˜JšœA˜AJšœ,˜,Jšžœžœžœžœ˜#šžœSžœ žœž˜lšžœž˜#Jšœ กœB˜W—Jšžœกœ(˜?—Jšžœ˜Jšœ?˜?LšœX˜XJšœ ˜—J˜J˜šŸœžœžœ žœžœžœžœ,žœžœ˜Jšœžœ ˜0Jšœ-žœDžœžœ0˜ฎJšœu˜uJšœ˜—šŸ œžœžœ žœžœžœžœ,žœžœ˜}Jšœžœ ˜0Jšœ,žœ<žœžœ/˜คJšœl˜lJšœ˜—šŸ œžœžœ žœžœžœžœ,žœ˜uJšœžœ ˜0šžœ(žœ˜0Jšœ<˜