<> <> <> DIRECTORY CoordSys, CSGGraphics, DisplayList3d, Fileout3d, GraphicsColor, IO, Labels, Matrix3d, Menus, MessageWindow, Rope, SVArtwork, SVArtworkUser, SVEditUser, SVEditUserB, SVMappings, SVPolygon3d, SVTransforms, SVViewerTools, SVViewerUser, TFI3d, TFO3d, ViewerClasses, ViewerTools; SVEditUserImplD: CEDAR PROGRAM IMPORTS CoordSys, DisplayList3d, Fileout3d, IO, Labels, Matrix3d, MessageWindow, Rope, SVArtwork, SVArtworkUser, SVEditUser, SVMappings, SVTransforms, SVViewerTools, SVViewerUser, TFI3d, TFO3d, ViewerTools EXPORTS SVEditUser, SVEditUserB = BEGIN <> Artwork: TYPE = SVArtwork.Artwork; Assembly: TYPE = DisplayList3d.Assembly; AssemblyList: TYPE = DisplayList3d.AssemblyList; AssemblyGenerator: TYPE = DisplayList3d.AssemblyGenerator; Camera: TYPE = CSGGraphics.Camera; Color: TYPE = GraphicsColor.Color; CoordSystem: TYPE = CoordSys.CoordSystem; DrawStyle: TYPE = CSGGraphics.DrawStyle; EditToolData: TYPE = SVEditUser.EditToolData; FileCamera: TYPE = DisplayList3d.FileCamera; FileCameraList: TYPE = DisplayList3d.FileCameraList; FrameBox: TYPE = CSGGraphics.FrameBox; LightSource: TYPE = DisplayList3d.LightSource; Material: TYPE = SVArtwork.Material; MasterObject: TYPE = DisplayList3d.MasterObject; MasterObjectList: TYPE = DisplayList3d.MasterObjectList; Matrix4by4: TYPE = Matrix3d.Matrix4by4; MouseButton: TYPE = Menus.MouseButton; NameAlreadyPresent: SIGNAL = DisplayList3d.NameAlreadyPresent; OMap: TYPE = SVArtwork.OMap; Plane: TYPE = SVPolygon3d.Plane; Point3d: TYPE = Matrix3d.Point3d; Scene: TYPE = DisplayList3d.Scene; SMap: TYPE = SVArtwork.SMap; Tube: TYPE = SVMappings.Tube; Box: TYPE = SVMappings.Box; Viewer: TYPE = ViewerClasses.Viewer; ViewerCell: TYPE = REF ViewerCellObj; ViewerCellObj: TYPE = SVEditUser.ViewerCellObj; ViewerToolData: TYPE = SVViewerUser.ViewerToolData; ViewerPictureData: TYPE = SVViewerUser.ViewerPictureData; <> globalMatCount: NAT = SVEditUser.globalMatCount; globalMatArray: PUBLIC ARRAY[1..globalMatCount] OF Rope.ROPE _ ["plastic", "chalk"]; globalBoxOMapIndex: PUBLIC NAT _ 1; globalBoxOMapCount: NAT = 2; globalBoxOMapArray: PUBLIC ARRAY[1..globalBoxOMapCount] OF Rope.ROPE _ ["Orthogonal", "Radial"]; ListScenes: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { g: DisplayList3d.SceneGenerator; scene: Scene; outHandle: IO.STREAM _ SVEditUser.GetOutHandle[]; 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 _ SVEditUser.GetOutHandle[]; 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.withRespectTo.name]]]; IF ISTYPE[a.object, 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: CoordSys.Generator; outHandle: IO.STREAM _ SVEditUser.GetOutHandle[]; cs: CoordSystem; g _ CoordSys.GetGenerator[currentScene.coordSystems]; cs _ CoordSys.Next[g]; outHandle.PutF["Listing Current CoordinateSystems in %g...\n", [rope[currentScene.name]]]; UNTIL cs = NIL DO outHandle.PutF[" %g",[rope[cs.name]]]; outHandle.PutChar[IO.SP]; outHandle.PutRope["withRespectTo: "]; IF cs.withRespectTo = NIL THEN IO.PutRope[outHandle,"NIL"] ELSE IO.PutRope[outHandle,cs.withRespectTo.name]; 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]; cs _ CoordSys.Next[g]; 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 _ SVEditUser.GetOutHandle[]; 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 _ SVEditUser.GetOutHandle[]; 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; viewerPictureData: ViewerPictureData; firstViewer: Viewer; count: NAT; outHandle: IO.STREAM _ SVEditUser.GetOutHandle[]; 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]; viewerPictureData _ NARROW[viewerToolData.viewerPicture.data]; outHandle.PutF["\n%g: 1", [rope[viewerPictureData.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 _ SVEditUser.GetOutHandle[]; 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 { <> editToolData: EditToolData _ NARROW[clientData]; cameraName: Rope.ROPE _ ViewerTools.GetSelectionContents[]; currentScene: Scene _ editToolData.sceneSection.currentScene; success: BOOL; outStream: IO.STREAM; fileCamera: FileCamera; frameRope, visibleAssemblyRope, clippingRope: Rope.ROPE; IF Rope.Length[cameraName] = 0 THEN { MessageWindow.Append["Please select a camera name.", TRUE]; MessageWindow.Blink[]; RETURN; }; [fileCamera, success] _ DisplayList3d.FindFileCameraFromName[cameraName, currentScene]; IF NOT success THEN { MessageWindow.Append[Rope.Cat["Camera ", cameraName, " not found"], TRUE]; MessageWindow.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]; <> outStream _ IO.ROS[]; TFO3d.FileoutFrame[outStream, fileCamera.frame]; frameRope _ IO.GetOutputStreamRope[outStream]; IO.Close[outStream]; ViewerTools.SetContents[editToolData.cameraSection.frame, frameRope]; <> outStream _ IO.ROS[]; TFO3d.FileoutClippingPlanes[outStream, fileCamera.clippingPlanes]; clippingRope _ IO.GetOutputStreamRope[outStream]; ViewerTools.SetContents[editToolData.cameraSection.clippingPlanes, clippingRope]; IO.Reset[outStream]; TFO3d.FileoutListOfRope[outStream, fileCamera.visibleAssemblies]; visibleAssemblyRope _ IO.GetOutputStreamRope[outStream]; IO.Close[outStream]; ViewerTools.SetContents[editToolData.cameraSection.visibleAssemblies, visibleAssemblyRope]; }; }; -- end of GetCamera 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]; currentViewerPictureData: ViewerPictureData _ NARROW[currentViewerToolData.viewerPicture.data]; camera: Camera _ currentViewerPictureData.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; <> cameraName _ ViewerTools.GetContents[editToolData.cameraSection.name]; IF Rope.Length[cameraName] = 0 THEN { MessageWindow.Append["Please give camera a name.", TRUE]; MessageWindow.Blink[]; RETURN; }; <> origin _ SVEditUser.GetPoint3d[editToolData.cameraSection.origin]; focusPoint _ SVEditUser.GetPoint3d[editToolData.cameraSection.focusPoint]; slant _ SVViewerTools.GetReal[editToolData.cameraSection.slant, 0]; << resolution and focal length>> resolution _ SVViewerTools.GetReal[editToolData.cameraSection.resolution, 10.0]; focalLength _ SVViewerTools.GetReal[editToolData.cameraSection.focalLength, 1800]; <> 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.frame _ frame; oldFileCamera.clippingPlanes _ clippingPlanes; oldFileCamera.visibleAssemblies _ visibleAssemblies; fileCamera _ oldFileCamera; } ELSE { fileCamera _ DisplayList3d.CreateFileCamera[cameraName, origin, focusPoint, slant, resolution, focalLength, clippingPlanes, visibleAssemblies]; DisplayList3d.AddCameraToScene[fileCamera, currentScene]; }; SVEditUser.SceneNewVersion[currentViewerToolData, currentScene]; 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 { MessageWindow.Append["Please select a camera name.", TRUE]; MessageWindow.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; currentViewerPictureData: ViewerPictureData _ NARROW[currentViewerToolData.viewerPicture.data]; worldCS _ CoordSys.FindCoordSysFromName["WORLD", currentScene.coordSystems]; screenCS _ currentViewerPictureData.camera.screenCS; style _ currentViewerPictureData.camera.style; [fileCamera, success] _ DisplayList3d.FindFileCameraFromName[cameraName, currentScene]; IF NOT success THEN { MessageWindow.Append[Rope.Cat["Camera ", cameraName, " not found"]]; MessageWindow.Blink[]; } ELSE { currentViewerPictureData.camera _ DisplayList3d.CameraFromFileCamera[fileCamera, worldCS, screenCS, style]; }; SVViewerUser.DrawSceneInternal[currentViewerToolData.outer, currentViewerToolData, red, FALSE, FALSE]; -- fake a button push 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.GetOutputStreamRope[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, currentScene]; }; -- 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, currentScene]; }; -- 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; assemblyCS, wrtCS: CoordSystem; oldMat, newMat: Matrix4by4; [assemblyCS, found] _ SVEditUser.GetCoordSys[editToolData.sceneSection.assemblyName, scene]; IF NOT found THEN RETURN; [wrtCS, found] _ SVEditUser.GetCoordSys[editToolData.sceneSection.wrt, scene]; IF NOT found THEN RETURN; oldMat _ CoordSys.FindAinTermsOfB[a: assemblyCS, b: wrtCS]; newMat _ Matrix3d.NormalizeNoRotation[oldMat]; CoordSys.TPlaceAwrtB[a: assemblyCS, b: wrtCS, aWRTb: newMat]; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control]; }; 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; <> assemblyCS, wrtCS: CoordSystem; <> newMat: Matrix4by4; [assemblyCS, found] _ SVEditUser.GetCoordSys[editToolData.sceneSection.assemblyName, scene]; IF NOT found THEN RETURN; [wrtCS, found] _ SVEditUser.GetCoordSys[editToolData.sceneSection.wrt, scene]; IF NOT found THEN RETURN; <> <<[sx, sy, sz] _ Matrix3d.ScaleFromMatrix[oldMat];>> <> newMat _ Matrix3d.Identity[]; CoordSys.TPlaceAwrtB[a: assemblyCS, b: wrtCS, aWRTb: newMat]; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control]; }; 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; wrtCS: CoordSystem; assembly: Assembly; [assembly, found] _ SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene]; IF NOT found THEN RETURN; [wrtCS, found] _ SVEditUser.GetCoordSys[editToolData.sceneSection.wrt, scene]; IF NOT found THEN RETURN; SVTransforms.Align[assembly, wrtCS]; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control]; }; -- 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; wrtCS: CoordSystem; assembly: Assembly; [assembly, found] _ SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene]; IF NOT found THEN RETURN; [wrtCS, found] _ SVEditUser.GetCoordSys[editToolData.sceneSection.wrt, scene]; IF NOT found THEN RETURN; SVTransforms.Abut[assembly, wrtCS]; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control]; }; -- 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; wrtCS: CoordSystem; assembly: Assembly; [assembly, found] _ SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene]; IF NOT found THEN RETURN; [wrtCS, found] _ SVEditUser.GetCoordSys[editToolData.sceneSection.wrt, scene]; IF NOT found THEN RETURN; SVTransforms.AbutX[assembly, wrtCS]; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control]; }; -- 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; wrtCS: CoordSystem; assembly: Assembly; [assembly, found] _ SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene]; IF NOT found THEN RETURN; [wrtCS, found] _ SVEditUser.GetCoordSys[editToolData.sceneSection.wrt, scene]; IF NOT found THEN RETURN; SVTransforms.AbutY[assembly, wrtCS]; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control]; }; -- 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; wrtCS: CoordSystem; assembly: Assembly; [assembly, found] _ SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene]; IF NOT found THEN RETURN; [wrtCS, found] _ SVEditUser.GetCoordSys[editToolData.sceneSection.wrt, scene]; IF NOT found THEN RETURN; SVTransforms.AbutZ[assembly, wrtCS]; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control]; }; -- end of AbutZ 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]]; }; BoxOCycle: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; globalBoxOMapIndex _ IF globalBoxOMapIndex = globalBoxOMapCount THEN 1 ELSE globalBoxOMapIndex + 1; Labels.Set[editToolData.artworkSection.oMapLabel, globalBoxOMapArray[globalBoxOMapIndex]]; }; 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; }; }; SetTubeArtwork: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; tubeHeight: REAL _ SVViewerTools.GetReal[editToolData.artworkSection.tubeHeight, 100]; tubeRadius: REAL _ SVViewerTools.GetReal[editToolData.artworkSection.tubeRadius, 50]; picName: Rope.ROPE _ ViewerTools.GetContents[editToolData.artworkSection.picName]; materialName: Rope.ROPE _ globalMatArray[editToolData.artworkSection.materialValue]; resolution: REAL _ SVViewerTools.GetReal[editToolData.artworkSection.resolution, 72.0]; material: Material; background: Color; tube: Tube; artwork: Artwork; assembly: Assembly; found: BOOL; [assembly, found] _ SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene]; IF NOT found THEN RETURN; [background, found] _ SVViewerTools.GetColor[editToolData.artworkSection.rgb]; IF NOT found THEN RETURN; [material, found] _ SVArtwork.RopeToMaterial[materialName]; IF NOT found THEN { MessageWindow.Append[Rope.Concat[materialName, "not known as a material"], TRUE]; MessageWindow.Blink[]; RETURN}; tube _ SVMappings.CreateTube[tubeRadius, tubeHeight]; found _ TRUE; IF SVViewerTools.GetBool[editToolData.artworkSection.isColor] THEN artwork _ SVArtwork.CreateFileArtwork[material: material, surface: tube, oMap: tubeO, sMap: tubeS, filename: picName, isColor: TRUE, background: background, resolution: resolution !SVArtwork.FileNotFound => { MessageWindow.Append[Rope.Cat["Sampled image ", picName, " not found."], TRUE]; MessageWindow.Blink[]; found _ FALSE} ] ELSE artwork _ SVArtwork.CreateFileArtwork[material: material, surface: tube, oMap: tubeO, sMap: tubeS, filename: picName, isColor: FALSE, background: background, resolution: resolution !SVArtwork.FileNotFound => { MessageWindow.Append[Rope.Cat["Sampled image ", picName, " not found."], TRUE]; MessageWindow.Blink[]; found _ FALSE} ]; IF NOT found THEN RETURN; DisplayList3d.SetArtworkAssembly[assembly, artwork, scene]; SVArtworkUser.SetArtwork[editToolData.artworkTool, artwork, scene.name, assembly.name]; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; }; GetBoxOMap: PRIVATE PROC [viewer: Viewer] RETURNS [oMap: OMap] = TRUSTED { mapRope: Rope.ROPE _ ViewerTools.GetContents[viewer]; SELECT TRUE FROM Rope.Equal[mapRope, "Orthogonal", TRUE] => RETURN[orthogonal]; Rope.Equal[mapRope, "Radial", TRUE] => RETURN[radial]; ENDCASE => ERROR UnknownOMap; }; UnknownOMap: ERROR = CODE; SetBoxArtwork: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; x, y, z: REAL; picName: Rope.ROPE _ ViewerTools.GetContents[editToolData.artworkSection.picName]; materialName: Rope.ROPE _ globalMatArray[editToolData.artworkSection.materialValue]; resolution: REAL _ SVViewerTools.GetReal[editToolData.artworkSection.resolution, 72.0]; material: Material; background: Color; box: Box; oMap: OMap _ GetBoxOMap[editToolData.artworkSection.oMapLabel]; artwork: Artwork; assembly: Assembly; found: BOOL; [assembly, found] _ SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene]; IF NOT found THEN RETURN; [background, found] _ SVViewerTools.GetColor[editToolData.artworkSection.rgb]; IF NOT found THEN RETURN; [material, found] _ SVArtwork.RopeToMaterial[materialName]; IF NOT found THEN { MessageWindow.Append[Rope.Concat[materialName, "not known as a material"], TRUE]; MessageWindow.Blink[]; RETURN}; [x, y, z] _ SVViewerTools.GetThreeReals[editToolData.artworkSection.boxXYZ]; box _ SVMappings.CreateBox[x,y,z]; found _ TRUE; IF SVViewerTools.GetBool[editToolData.artworkSection.isColor] THEN artwork _ SVArtwork.CreateFileArtwork[material: material, surface: box, oMap: oMap, sMap: unfoldedBox, filename: picName, isColor: TRUE, background: background, resolution: resolution !SVArtwork.FileNotFound => {found _ FALSE; CONTINUE}] ELSE artwork _ SVArtwork.CreateFileArtwork[material: material, surface: box, oMap: oMap, sMap: unfoldedBox, filename: picName, isColor: FALSE, background: background, resolution: resolution !SVArtwork.FileNotFound => {found _ FALSE; CONTINUE}]; IF NOT found THEN RETURN; DisplayList3d.SetArtworkAssembly[assembly, artwork, scene]; SVArtworkUser.SetArtwork[editToolData.artworkTool, artwork, scene.name, assembly.name]; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; }; GetArtwork: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { <> editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; assembly: Assembly; artwork: Artwork; materialName: Rope.ROPE; found: BOOL; [assembly, found] _ SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene]; IF NOT found THEN RETURN; artwork _ assembly.artwork; ViewerTools.SetContents[editToolData.artworkSection.picName, artwork.source]; SVViewerTools.SetColor[editToolData.artworkSection.rgb, artwork.color]; materialName _ SVArtwork.MaterialToRope[artwork.material]; ViewerTools.SetContents[editToolData.artworkSection.material, materialName]; IF artwork.source = NIL THEN {}-- a pure color artwork. Update color and material only. ELSE {-- a file artwork. Display isColorFile, resolution, simple surface parameters and mapping types SVViewerTools.SetBool[editToolData.artworkSection.isColor, artwork.isColorFile]; SVViewerTools.SetReal[editToolData.artworkSection.resolution, artwork.resolution]; WITH artwork.surface SELECT FROM tube: SVMappings.Tube => { SVViewerTools.SetReal[editToolData.artworkSection.tubeHeight, tube.H]; SVViewerTools.SetReal[editToolData.artworkSection.tubeRadius, tube.R]; }; box: SVMappings.Box => { SVViewerTools.SetThreeReals[editToolData.artworkSection.boxXYZ, box.x, 2*box.halfY, box.z]; }; ENDCASE => ERROR; }; SVArtworkUser.SetArtwork[editToolData.artworkTool, artwork, scene.name, assembly.name]; }; -- end of GetArtwork RotateArtwork: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; degrees: REAL _ SVViewerTools.GetReal[editToolData.artworkTransformSection.degrees, 45]; SVArtworkUser.RotateArtwork[editToolData.artworkTool, degrees]; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; }; NormalizeArtwork: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; SVArtworkUser.NormalizeArtwork[editToolData.artworkTool]; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; }; 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 { MessageWindow.Append[Rope.Cat["Lightsource named ", name, " is already present"], TRUE]; MessageWindow.Blink[]; RETURN} } ELSE { [lightsource, success] _ DisplayList3d.FindLightFromName[name, scene]; IF NOT success THEN { MessageWindow.Append[Rope.Cat["Lightsource named ", name, " is not present"], TRUE]; MessageWindow.Blink[]; RETURN}; lightsource.position _ position; lightsource.color _ color; }; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control]; }; 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]; SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData]; SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control]; }; 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 { MessageWindow.Append[Rope.Cat["Lightsource: ", lightName, "not found."]]; MessageWindow.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.