DIRECTORY AIS, BasicTime, Buttons, CastRays, CGDevice, ColorMap, Containers, CoordSys, CSG, CSGGraphics, DisplayList3d, DisplayListToTree, DisplayMap, DitherAIS, FS, Graphics, GraphicsBasic, GraphicsColor, GraphicsToPress, InputFocus, IO, Labels, Menus, MessageWindow, Preprocess3d, Real, Rope, SV2d, SV3d, SVBoundBox, SVDraw3d, SVEditUser, SVError, SVFileoutPoly, SVFiles, SVImage, SVInterfaceTypes, SVModelTypes, SVRayTypes, SVSceneTypes, SVSelections, SVSlices, SVTransforms, SVViewerTool, SVViewerTools, SVViewerUser, TFO3d, ViewerClasses, ViewerTools; SVViewerUserImplB: CEDAR PROGRAM IMPORTS AIS, BasicTime, Buttons, CastRays, ColorMap, CoordSys, CSG, CSGGraphics, DisplayList3d, DisplayListToTree, DisplayMap, DitherAIS, FS, Graphics, GraphicsToPress, InputFocus, IO, Labels, MessageWindow, Preprocess3d, Real, Rope, SVBoundBox, SVDraw3d, SVEditUser, SVError, SVFiles, SVFileoutPoly, SVImage, SVSelections, SVSlices, SVViewerUser, SVViewerTools, TFO3d, ViewerTools EXPORTS GraphicsBasic, SVViewerUser = BEGIN Assembly: TYPE = SVSceneTypes.Assembly; BoundBox: TYPE = SVModelTypes.BoundBox; Camera: TYPE = SVModelTypes.Camera; Classification: TYPE = SVRayTypes.Classification; Color: TYPE = GraphicsColor.Color; CoordSysGenerator: TYPE = DisplayList3d.CoordSysGenerator; CSGTree: TYPE = SVRayTypes.CSGTree; DeviceObject: PUBLIC TYPE = CGDevice.Rep; DrawStyle: TYPE = SVModelTypes.DrawStyle; EditToolData: TYPE = SVEditUser.EditToolData; FrameBox: TYPE = SVModelTypes.FrameBox; MasterObject: TYPE = SVSceneTypes.MasterObject; Matrix4by4: TYPE = SV3d.Matrix4by4; MouseButton: TYPE = Menus.MouseButton; Point2d: TYPE = SV2d.Point2d; Primitive: TYPE = SVRayTypes.Primitive; Ray: TYPE = SVRayTypes.Ray; Scene: TYPE = SVSceneTypes.Scene; Selection: TYPE = SVInterfaceTypes.Selection; SelectionType: TYPE = SVInterfaceTypes.SelectionType; Slice: TYPE = SVSlices.Slice; Vector: TYPE = SV3d.Vector; Viewer: TYPE = ViewerClasses.Viewer; ViewerToolData: TYPE = SVInterfaceTypes.ViewerToolData; DCProc: TYPE = SVInterfaceTypes.DCProc; globalTable: DisplayMap.ColorTable; globalSceneStyleCount: NAT = 3; globalSceneStyleArray: ARRAY[1..globalSceneStyleCount] OF Rope.ROPE _ ["WireFrame", "Shaded", "Normals"]; Press: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; camera: Camera _ viewerToolData.camera; startTime: BasicTime.GMT; endTime: BasicTime.GMT; totalTime: INT; timeRope: Rope.ROPE; pressName: Rope.ROPE; pressContext: Graphics.Context; pressName _ ViewerTools.GetContents[viewerToolData.textSection.ais]; pressName _ Rope.Concat[SVFiles.FilenameMinusExtension[pressName], ".press"]; SVError.Append[Rope.Cat["Pressing ", pressName, "... "], TRUE]; startTime _ BasicTime.Now[]; pressContext _ GraphicsToPress.NewContext[pressName]; CSGGraphics.Clip[pressContext, camera]; CSGGraphics.SetQualityCamera[camera, quality]; -- make a high quality image CSGGraphics.ColorFilmCamera[camera, FALSE]; -- but only black and white SVViewerUser.DrawSceneEtc[pressContext, viewerToolData, TRUE]; CSGGraphics.ColorFilmCamera[camera, TRUE]; -- restore to color mode CSGGraphics.SetQualityCamera[camera, fast]; -- restore to fast mode for interactive editting GraphicsToPress.Close[pressContext]; endTime _ BasicTime.Now[]; totalTime _ BasicTime.Period[startTime, endTime]; timeRope _ IO.PutFR[" Done making %g. Pressing took (%r)", [rope[pressName]], [integer[totalTime]]]; SVError.Append[timeRope, FALSE, TRUE]; }; PressAIS: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; scene: Scene _ viewerToolData.scene; camera: Camera _ viewerToolData.camera; minX, minY, maxX, maxY: REAL; tree: CSGTree; aisRope: Rope.ROPE _ ViewerTools.GetContents[viewerToolData.textSection.ais]; startTime: BasicTime.GMT; endTime: BasicTime.GMT; totalTime: INT; timeRope: Rope.ROPE; pressName: Rope.ROPE; pressStream: IO.STREAM; pressContext: Graphics.Context; startTime _ BasicTime.Now[]; pressName _ ViewerTools.GetContents[viewerToolData.textSection.ais]; pressName _ Rope.Concat[SVFiles.FilenameMinusExtension[pressName], ".press"]; pressStream _ FS.StreamOpen[pressName, $create]; pressContext _ GraphicsToPress.NewContextFromStream[ outputStream: pressStream, fileNameForHeaderPage: pressName, resolution: 384]; tree _ DisplayListToTree.AssemblyToTree[scene.assembly, scene, camera]; [minX, minY, maxX, maxY] _ MinAndMaxFromCameraAndTree[camera, tree]; SVImage.DrawAndScaleColorImage[pressContext, aisRope, [camera.screenCS.mat[1][4], camera.screenCS.mat[2][4]], minX, minY, maxX, maxY]; GraphicsToPress.Close[pressContext]; endTime _ BasicTime.Now[]; totalTime _ BasicTime.Period[startTime, endTime]; timeRope _ IO.PutFR[" Done. Pressing AIS took (%r)",[integer[totalTime]]]; SVError.Append[timeRope, TRUE, TRUE]; }; StorePoly: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; editToolData: EditToolData _ NARROW[viewerToolData.editToolData]; wdir: Rope.ROPE; success, confirmation: BOOL; f: IO.STREAM; picName: Rope.ROPE _ ViewerTools.GetSelectionContents[]; fullName: Rope.ROPE; scene: Scene _ viewerToolData.scene; IF Rope.Length[picName] = 0 THEN RETURN; wdir _ editToolData.originalWorkingDirectory; success _ TRUE; [fullName,,] _ FS.ExpandName[picName, wdir ! FS.Error => IF error.group = user THEN { success _ FALSE; CONTINUE; } ]; IF NOT success THEN RETURN; IF SVFiles.FileExists[fullName] THEN { confirmation _ MessageWindow.Confirm["Confirm overwrite of existing pic file"]; IF confirmation THEN f _ FS.StreamOpen[fullName, $create] ELSE RETURN; } ELSE f _ FS.StreamOpen[fullName, $create]; SVError.Append["Writing scene: ",TRUE]; SVError.Append[fullName]; SVError.Append[" to file: "]; SVError.Append[fullName]; SVError.Append["..."]; IF NOT success THEN RETURN; SVFileoutPoly.StorePolyScene[scene, f, fullName]; SVError.Append["Done"]; }; -- end of StorePoly CrossHairs: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; camera: Camera _ viewerToolData.camera; DoCrossHairs: PROC [dc: Graphics.Context] = TRUSTED { SVDraw3d.Draw2dCoordSys[dc, [0,0], camera]; }; SVViewerUser.Painter[DoCrossHairs, viewerToolData]; }; -- end of CrossHairs Dither: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; baseName, redName, greenName, blueName, FSFilename: Rope.ROPE; baseName _ ViewerTools.GetContents[viewerToolData.textSection.ais]; baseName _ SVFiles.FilenameMinusExtension[baseName]; redName _ Rope.Concat[baseName, "-red.ais"]; greenName _ Rope.Concat[baseName, "-grn.ais"]; blueName _ Rope.Concat[baseName, "-blu.ais"]; FSFilename _ Rope.Concat[baseName, "-std.ais"]; BEGIN globalTable _ Preprocess3d.GetGlobalTable[]; DitherAIS.Squash[redName, greenName, blueName, FSFilename, MyMap ! AIS.Error => TRUSTED { msgRope: Rope.ROPE; msgRope _ IO.PutFR["%g -*.ais - Bad file names", [rope[baseName]]]; SVError.Append[Rope.Concat[baseName, "-*.ais - Bad file names"], TRUE, TRUE]; GOTO giveUp}]; DrawDither[parent, clientData, mouseButton, shift, control]; EXITS giveUp => NULL; END; }; MyMap: DitherAIS.UserMapProc = TRUSTED { rb, gb, bb: DisplayMap.ColorMapSize; palix _ DisplayMap.GetIndex[r, g, b, globalTable]; [rb, gb, bb] _ ColorMap.GetColor[palix]; -- ought to use the table re _ r - rb; ge _ g - gb; be _ b - bb; }; DrawPt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; camera: Camera _ viewerToolData.camera; x, y: REAL; DoDrawPt: PROC [dc: Graphics.Context] = TRUSTED { SVDraw3d.DrawX[dc, [x, y], camera]; }; [x, y] _ SVViewerUser.ReadTwoReals[viewerToolData.textSection.xyz]; SVViewerUser.Painter[DoDrawPt, viewerToolData]; }; MinAndMaxFromCameraAndTree: PRIVATE PROC [camera: Camera, tree: CSGTree] RETURNS [minX, minY, maxX, maxY: REAL] = TRUSTED { frame: FrameBox _ camera.frame; boundBox: BoundBox; defaultHalfSide: REAL = 100.0; IF frame.fullScreen THEN { [boundBox] _ Preprocess3d.PreprocessForInteraction[tree, camera]; IF boundBox = NIL THEN { minX _ minY _ -defaultHalfSide; maxX _ maxY _ defaultHalfSide; } ELSE { minX _ boundBox.minVert[1]; minY _ boundBox.minVert[2]; maxX _ boundBox.maxVert[1]; maxY _ boundBox.maxVert[2]; }; } ELSE { minX _ frame.downLeft[1]; minY _ frame.downLeft[2]; maxX _ frame.upRight[1]; maxY _ frame.upRight[2]; }; }; DrawColor: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; scene: Scene _ viewerToolData.scene; resolution: REAL; boundBox: BoundBox; minX, minY, maxX, maxY: REAL; camera: Camera _ viewerToolData.camera; tree: CSGTree; aisRope: Rope.ROPE _ ViewerTools.GetContents[viewerToolData.textSection.ais]; DoDrawColor: PROC [dc: Graphics.Context] = TRUSTED { SVImage.DrawAlignedColorImage[dc, aisRope, resolution, [camera.screenCS.mat[1][4], camera.screenCS.mat[2][4]], boundBox]; }; resolution _ camera.resolution; tree _ DisplayListToTree.AssemblyToTree[scene.assembly, scene, camera]; [minX, minY, maxX, maxY] _ MinAndMaxFromCameraAndTree[camera, tree]; boundBox _ SVBoundBox.BoundBoxFromValues[minX, minY, maxX, maxY]; SVViewerUser.Painter[DoDrawColor, viewerToolData]; }; -- end of DrawColor DrawBlackAndWhite: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; resolution: REAL; scene: Scene _ viewerToolData.scene; boundBox: BoundBox; minX, minY, maxX, maxY: REAL; camera: Camera _ viewerToolData.camera; tree: CSGTree; oldMode: Graphics.PaintMode; aisRope: Rope.ROPE _ ViewerTools.GetContents[viewerToolData.textSection.ais]; DoDrawBlackAndWhite: PROC [dc: Graphics.Context] = TRUSTED { SVImage.DrawAlignedBlackAndWhiteImage[dc, aisRope, resolution, [camera.screenCS.mat[1][4], camera.screenCS.mat[2][4]], boundBox, FALSE]; }; DoDrawFrame: SAFE PROC [dc: Graphics.Context] = TRUSTED { Graphics.SetColor[dc, GraphicsColor.black]; oldMode _ Graphics.SetPaintMode[dc, invert]; CSGGraphics.DrawFrame [dc, camera]; [] _ Graphics.SetPaintMode[dc, oldMode]; }; resolution _ camera.resolution; tree _ DisplayListToTree.AssemblyToTree[scene.assembly, scene, camera]; [minX, minY, maxX, maxY] _ MinAndMaxFromCameraAndTree[camera, tree]; boundBox _ SVBoundBox.BoundBoxFromValues[minX, minY, maxX, maxY]; SVViewerUser.Painter[DoDrawBlackAndWhite, viewerToolData]; SVViewerUser.Painter[DoDrawFrame, viewerToolData]; -- redraw frame }; -- end of DrawBlackAndWhite DrawDither: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; resolution: REAL; scene: Scene _ viewerToolData.scene; boundBox: BoundBox; minX, minY, maxX, maxY: REAL; camera: Camera _ viewerToolData.camera; tree: CSGTree; aisRope: Rope.ROPE _ ViewerTools.GetContents[viewerToolData.textSection.ais]; DoDrawBlackAndWhite: PROC [dc: Graphics.Context] = TRUSTED { SVImage.DrawAlignedBlackAndWhiteImage[dc, aisRope, resolution, [camera.screenCS.mat[1][4], camera.screenCS.mat[2][4]], boundBox, TRUE]; }; resolution _ camera.resolution; aisRope _ Rope.Concat[SVFiles.FilenameMinusExtension[aisRope], "-std.ais"]; tree _ DisplayListToTree.AssemblyToTree[scene.assembly, scene, camera]; [minX, minY, maxX, maxY] _ MinAndMaxFromCameraAndTree[camera, tree]; boundBox _ SVBoundBox.BoundBoxFromValues[minX, minY, maxX, maxY]; SVViewerUser.Painter[DoDrawBlackAndWhite, viewerToolData]; }; -- end of DrawDither SetFocalLength: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; viewerToolData.camera.focalLength _ SVViewerTools.GetReal[viewerToolData.textSection.focalLength, 1800]; }; -- end of SetFocalLength AISPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; ViewerTools.SetSelection[viewerToolData.textSection.ais]; }; XYZPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; ViewerTools.SetSelection[viewerToolData.textSection.xyz]; }; FocalLengthPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; ViewerTools.SetSelection[viewerToolData.textSection.focalLength]; }; TextPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; ViewerTools.SetSelection[viewerToolData.textSection.text]; }; StylePrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; newStyle: DrawStyle; scene: Scene _ viewerToolData.scene; viewerToolData.sceneStyleIndex _ IF viewerToolData.sceneStyleIndex = globalSceneStyleCount THEN 1 ELSE viewerToolData.sceneStyleIndex + 1; Labels.Set[viewerToolData.textSection.viewStyle, globalSceneStyleArray[viewerToolData.sceneStyleIndex]]; SELECT globalSceneStyleArray[viewerToolData.sceneStyleIndex] FROM "WireFrame" => newStyle _ wire; "Shaded" => newStyle _ shaded; "Normals" => newStyle _ normals; ENDCASE => ERROR; viewerToolData.camera.style _ newStyle; }; DoubleBuffer: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { button: Buttons.Button _ NARROW[parent]; viewerToolData: ViewerToolData _ NARROW[clientData]; IF viewerToolData.doubleBuffer THEN { viewerToolData.doubleBuffer _ NOT viewerToolData.doubleBuffer; Buttons.SetDisplayStyle[button, $BlackOnWhite]; } ELSE { viewerToolData.doubleBuffer _ NOT viewerToolData.doubleBuffer; Buttons.SetDisplayStyle[button, $WhiteOnBlack]; }; }; -- end of DoubleBuffer ShowCoordsMode: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { button: Buttons.Button _ NARROW[parent]; viewerToolData: ViewerToolData _ NARROW[clientData]; IF viewerToolData.showCoordSys THEN { viewerToolData.showCoordSys _ NOT viewerToolData.showCoordSys; Buttons.SetDisplayStyle[button, $BlackOnWhite]; } ELSE { viewerToolData.showCoordSys _ NOT viewerToolData.showCoordSys; Buttons.SetDisplayStyle[button, $WhiteOnBlack]; }; }; -- end of ShowCoordsMode Selected: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; solidViewer: Viewer _ viewerToolData.viewerPicture; InputFocus.SetInputFocus[solidViewer]; SVEditUser.ReSelectViewer[viewerToolData]; }; Deselected: PUBLIC PROC [viewerToolData: ViewerToolData] = TRUSTED { IF viewerToolData = NIL THEN RETURN; viewerToolData.textSection.isSelected _ FALSE; Labels.SetDisplayStyle[viewerToolData.textSection.selected, $BlackOnWhite, TRUE]; }; KillSelectionsButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; SVSelections.KillSkitterAndSelections[viewerToolData.editToolData]; }; DeleteJacksButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; scene: Scene _ viewerToolData.scene; DisplayList3d.DeleteAllPrimitivesOfClass["jack", scene]; SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, viewerToolData.editToolData, scene]; }; SingleRay: PUBLIC PROC [viewerToolData: ViewerToolData, cameraPoint: Point2d] = TRUSTED { f: IO.STREAM _ SVError.GetErrorStream[]; color: Color; xInt, yInt: INTEGER; tree: CSGTree; scene: Scene _ viewerToolData.scene; camera: Camera _ viewerToolData.camera; class: Classification; rayWorld: Ray; xInt _ Real.FixI[cameraPoint[1]]; yInt _ Real.FixI[cameraPoint[2]]; tree _ DisplayListToTree.AssemblyToTree[scene.assembly, scene, camera]; color _ CastRays.SingleRay[xInt, yInt, tree, scene.lightSources, camera, TRUE, f]; f.PutF["[%g,%g]: ",[real[cameraPoint[1]]], [real[cameraPoint[2]]]]; TFO3d.FileoutColor[f, color]; f.PutChar[IO.CR]; [class, rayWorld] _ CastRays.SingleRay2[[xInt, yInt], tree, camera, FALSE]; ClassToStream[f, class]; f.PutChar[IO.CR]; CastRays.SortClassByPrimitive[class]; ClassToStream[f, class]; f.PutChar[IO.CR]; CSG.ReturnRayToPool[rayWorld]; CastRays.ReturnClassToPool[class]; f.PutChar[IO.CR]; }; ClassToStream: PROC [f: IO.STREAM, class: Classification] = { FOR i: NAT IN [1..class.count] DO f.PutF["(%g, %g) ", IO.rope[class.primitives[i].name], IO.real[class.params[i]]]; ENDLOOP; }; DrawSlice: PUBLIC PROC [viewerToolData: ViewerToolData, slice: Slice] = { camera: Camera _ viewerToolData.camera; DoDrawSlice: PROC [dc: Graphics.Context] = TRUSTED { SVSlices.DrawSlice3d[dc, slice, camera]; }; SVViewerUser.Painter[DoDrawSlice, viewerToolData]; }; DrawSelection: PROC [dc: Graphics.Context, viewerToolData: ViewerToolData, selection: Selection, selectionType: SelectionType, color: Color] = TRUSTED { }; RayCastProgress: PUBLIC CastRays.NotifyOfProgressProc = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; camera: Camera _ viewerToolData.camera; width: REAL _ 10; box: Graphics.Box; lowLeft, upRight: Point2d; DoRayCastProgress: PROC [dc: Graphics.Context] = TRUSTED { Graphics.SetColor[dc, GraphicsColor.black]; Graphics.DrawBox[dc, box]; }; lowLeft _ CoordSys.CameraToScreen[[minX, minY], camera.screenCS]; upRight _ CoordSys.CameraToScreen[[maxX, currentY], camera.screenCS]; box _ [lowLeft[1], lowLeft[2], upRight[1], upRight[2]]; SVViewerUser.Painter[DoRayCastProgress, viewerToolData]; }; END. RFile: SVViewerUserImplB.mesa Author: Eric Bier in October 1982 Copyright c 1984 by Xerox Corporation. All rights reserved. Last edited by Bier on January 26, 1985 10:57:07 pm PST Contents: Code to respond to button presses made in an SVViewer GLOBAL VARIABLES TIMING VARABLES PRESS VARIABLES START TIMING START PRESSING END TIMING TIMING VARABLES PRESS VARIABLES START TIMING START PRESSING PressBWAIS: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { viewerToolData: ViewerToolData _ NARROW[clientData]; editToolData: EditToolData _ NARROW[viewerToolData.editToolData]; scene: Scene _ viewerToolData.scene; camera: Camera _ viewerToolData.camera; minX, minY, maxX, maxY: REAL; tree: CSGTree; aisRope: Rope.ROPE _ ViewerTools.GetContents[viewerToolData.textSection.ais]; TIMING VARABLES startTime: BasicTime.GMT; endTime: BasicTime.GMT; totalTime: INT; timeRope: Rope.ROPE; PRESS VARIABLES pressName: Rope.ROPE; pressStream: IO.STREAM; pressContext: Graphics.Context; START TIMING startTime _ BasicTime.Now[]; START PRESSING pressName _ ViewerTools.GetContents[viewerToolData.textSection.ais]; pressName _ Rope.Concat[SVFiles.FilenameMinusExtension[pressName], ".press"]; pressStream _ FS.StreamOpen[pressName, $create]; pressContext _ GraphicsToPress.NewContextFromStream[ outputStream: pressStream, fileNameForHeaderPage: pressName, resolution: 384]; tree _ DisplayList3d.SceneToTree[scene, camera]; [minX, minY, maxX, maxY] _ MinAndMaxFromCameraAndTree[camera, tree]; SVImage.DrawAndScaleBlackAndWhiteImage[pressContext, aisRope, [camera.screenCS.mat[1][4], camera.screenCS.mat[2][4]], minX, minY, maxX, maxY]; GraphicsToPress.Close[pressContext]; endTime _ BasicTime.Now[]; totalTime _ BasicTime.Period[startTime, endTime]; timeRope _ IO.PutFR[" Done. Pressing AIS took (%r)",[integer[totalTime]]]; SVError.Append[timeRope, TRUE, TRUE]; }; viewer is the crossHairs button If the dither has worked, fake a button press of DrawDither: Move: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { newMat: Matrix4by4; target, movee: Selection; target _ SVEditUser.GetTargetSelection[]; movee _ SVEditUser.GetMoveeSelection[]; IF target = NIL THEN ERROR; IF target.assembly = NIL THEN RETURN; IF movee = NIL THEN ERROR; IF movee.assembly = NIL THEN RETURN; If the two selections are in different viewers, then see if these viewers refer to different scenes. If so do a scene to scene copy before doing any aligning and abutting. IF target.viewerToolData # movee.viewerToolData THEN { targetPicture: ViewerPictureData _ NARROW[target.viewerToolData.viewerPicture.data]; moveePicture: ViewerPictureData _ NARROW[movee.viewerToolData.viewerPicture.data]; IF targetPicture.scene # moveePicture.scene THEN { copyAssembly: Assembly _ DisplayList3d.MergeAssemblyIntoScene[movee.assembly, moveePicture.scene, targetPicture.scene.assembly, targetPicture.scene]; The new assembly has the same relationship to scene assembly as the last assembly had to its parent. This will do for now. SVViewerUser.SceneNewVersion[target.viewerToolData]; SVViewerUser.DrawSceneInternal[NIL, target.viewerToolData, red, FALSE, FALSE]; SVViewerUser.DrawSceneInternal[NIL, movee.viewerToolData, red, FALSE, FALSE]; RETURN; }; }; newMat _ Matrix3d.MakeRotateYMat[180]; SVTransforms.TugTransf[movee.assembly.coordSys, movee.coordSys, target.coordSys, newMat]; Rotate them so they are tangent in an exterior fashion. SVViewerUser.SceneNewVersion[target.viewerToolData]; SVViewerUser.DrawSceneInternal[NIL, target.viewerToolData, red, FALSE, FALSE]; }; get x and y from appropriate slots. Interpret this as camera coordinates and draw a cross. parent is the DrawColor button parent is the DrawB&W button parent is the DrawDither button PROMPTS PROMPTS WHICH CYCLE THROUGH POSSIBILITIES "RayCast" => newStyle _ rayCast; ON/OFF SWITCHES UTILITIES This window has been selected. Show its Selected button as WhiteOnBlack. This window has been deselected. Show its Selected button as BlackOnWhite. Input Notify Procs PointAt: PUBLIC PROC [viewerToolData: ViewerToolData, cameraPoint: Point2d] = TRUSTED { Adds a new assembly to the scene of class "CoordSys", isTool is true. The first one will be pointer.0, the second pointer.1 and so on. Pointer will be defined with respect to the parent of the assembly which we are pointing at. If we are not pointing at anything, don't create a pointer. Just return. f: IO.STREAM _ SVError.GetErrorStream[]; tree: CSGTree; normal: Vector; prim: Primitive; scene: Scene _ viewerToolData.scene; camera: Camera _ viewerToolData.camera; class: Classification; tree _ DisplayListToTree.AssemblyToTree[scene.assembly, scene, camera]; class _ CastRays.SingleRay2[cameraPoint, tree, camera, TRUE, TRUE, f]; IF class.count = 0 THEN RETURN; prim _ class.primitives[1]; normal _ class.normals[1]; }; ComplementOldSelection: PUBLIC PROC [viewerToolData: ViewerToolData, selection: Selection, selectionType: SelectionType] = TRUSTED { If selection is in this viewer then just complement it normally. If it is in another viewer, then have that viewer complement it. If it is a null selection, forget it. IF selection = NIL THEN RETURN; -- null selection IF selection.assembly = NIL THEN RETURN; -- null selection IF selection.viewerToolData = viewerToolData THEN ComplementSelection[viewerToolData, selection, selectionType] ELSE ComplementSelection[selection.viewerToolData, selection, selectionType]; }; DrawSelectionOpaque: PROC [viewerToolData: ViewerToolData, selection: Selection, color: Color] = TRUSTED { DoDrawSelectionOpaque: SAFE PROC [dc: Graphics.Context] = TRUSTED { [] _ Graphics.SetPaintMode[dc, opaque]; Graphics.SetColor[dc, color]; SVViewerUser.DrawOneCS[dc, viewerToolData, selection.coordSys]; }; CoordSys.TellAboutParent[selection.coordSys]; SVViewerUser.Painter[DoDrawSelectionOpaque, viewerToolData]; }; ComplementSelection: PUBLIC PROC [viewerToolData: ViewerToolData, selection: Selection, selectionType: SelectionType] = TRUSTED { DoComplementSelection: SAFE PROC [dc: Graphics.Context] = TRUSTED { DrawSelection[dc, viewerToolData, selection, selectionType, GraphicsColor.black]; }; SVViewerUser.Painter[DoComplementSelection, viewerToolData]; }; SVTransforms.TellAboutParent[selection.coordSys]; [] _ Graphics.SetPaintMode[dc, invert]; Graphics.SetColor[dc, color]; IF selectionType = movee THEN SVViewerUser.DrawOneCS[dc, viewerToolData, selection.coordSys] ELSE SVViewerUser.DrawOneTargetCS[dc, viewerToolData, selection.coordSys]; PROC [currentY, minX, minY, maxX, maxY: REAL, clientData: REF ANY]; Draw a box of width 10 and length currentY-minY+1 with origin at (minX, minY) Κπ˜Iheadšœ™Jšœ!™!Jšœ Οmœ1™Jšœ$žœ˜CJšœ\˜\Jšœ$˜$J™ Jšœ˜Jšœ1˜1Jšœe˜eJšœž œ˜&Jšœ˜—šŸœžœžœ žœžœžœžœ,žœžœ˜xJšœ!žœ ˜4Jšœ$˜$Jšœ'˜'Jšœžœ˜Jšœ˜Jšœžœ;˜MJšœ™Jšœ˜Jšœ˜Jšœ žœ˜Jšœžœ˜Jšœ™Jšœžœ˜Jšœ žœžœ˜Jšœ˜Jšœ ™ Jšœ˜Jšœ™JšœD˜DJšœM˜MJšœ0˜0šœ4˜4Jšœ˜Jšœ!˜!Jšœ˜—JšœG˜GJšœD˜DJšœ†˜†Jšœ$˜$Jšœ˜Jšœ1˜1JšœK˜KJšœž œ˜%Jšœ˜—šŸ œžœžœ žœžœžœžœ,žœžœ™zJšœ!žœ ™4Jšœžœ™AJšœ$™$Jšœ'™'Jšœžœ™Jšœ™Jšœžœ;™MJšœ™Jšœ™Jšœ™Jšœ™Jšœžœ™Jšœ™Jšœžœ™Jšœ žœžœ™Jšœ™Jšœ ™ Jšœ™Jšœ™JšœD™DJšœM™MJšœ0™0šœ4™4Jšœ™Jšœ!™!Jšœ™—Jšœ0™0JšœD™DJšœŽ™ŽJšœ$™$Jšœ™Jšœ1™1JšœK™KJšœž œ™%Jšœ™—šŸ œžœžœ žœžœžœžœ,žœžœ˜yJšœ!žœ ˜4Jšœžœ˜AJšœ žœ˜Jšœžœ˜Jšœžœžœ˜ Jšœžœ&˜8Jšœžœ˜Jšœ$˜$J˜Jšžœžœžœ˜(Jšœ-˜-Jšœ žœ˜šœžœ˜*šœžœ žœžœ˜*Jšœ žœ˜Jšžœ˜ J˜—Jšœ˜—Jšžœžœ žœžœ˜šžœžœ˜&LšœO˜Ošžœžœ˜Lšœžœ˜$—Lšžœžœ˜ Lšœ˜—Lšžœžœ˜*Lšœ!žœ˜'Lšœ˜Lšœ˜Lšœ˜Lšœ˜Jšžœžœ žœžœ˜Jšœ1˜1Lšœ˜JšœΟc˜J˜—J˜šŸ œžœžœ žœžœžœžœ,žœžœ˜zJšœ™Jšœ!žœ ˜4Jšœ'˜'šŸ œžœžœ˜5Jšœ+˜+Jšœ˜—Jšœ3˜3Jšœ˜—J˜J˜šŸœžœžœ žœžœžœžœ,žœžœ˜vJšœ!žœ ˜4Jšœ9žœ˜>JšœC˜CJšœ4˜4Jšœ,˜,Jšœ.˜.Jšœ-˜-Jšœ/˜/Jšž˜Jšœ,˜,šœ@˜@šœžœ žœ˜J˜JšœC˜CJšœAž œ˜MJšžœ ˜——J™Jšœ/˜/Jšœ˜—šžœ˜Jšœžœ˜>Jšœ/˜/Jšœ˜—Jšœ˜J˜—šŸœžœžœ žœžœžœžœ,žœžœ˜~Jšœžœ ˜(Jšœ!žœ ˜4šžœžœ˜%Jšœžœ˜>Jšœ/˜/Jšœ˜—šžœ˜Jšœžœ˜>Jšœ/˜/Jšœ˜—Jšœ˜—J˜J˜Jšœ ™ J˜šŸœžœžœ žœžœžœžœ,žœžœ˜xJšœI™IJšœ!žœ ˜4Jšœ3˜3Jšœ&˜&Jšœ*˜*Jšœ˜—šŸ œžœžœ$žœ˜DJšœK™KJšžœžœžœžœ˜$Jšœ(žœ˜.JšœKžœ˜QJšœ˜J˜—šŸœžœžœ žœžœžœžœ,žœžœ˜„Lšœ!žœ ˜4LšœC˜CL˜—J˜šŸœžœžœ žœžœžœžœ,žœžœ˜Lšœ!žœ ˜4Lšœ$˜$Lšœ8˜8Lšœg˜gL˜—J™Jšœ™J˜šŸ œžœžœ:žœ˜YJšœžœžœ˜(Jšœ ˜ Jšœ žœ˜Jšœ˜Jšœ$˜$Jšœ'˜'Jšœ˜JšœΟuœ˜JšœD˜DJšœ œ ˜GJšœ  œ/žœ˜RJšœC˜CJšœ˜Jšœ žœžœ˜Jšœ ’œ   œžœ˜KJšœ˜Jšœ žœžœ˜Jšœ%˜%Jšœ˜Jšœ žœžœ˜Jšœ’œ˜Jšœ Ÿœ˜"Jšœ žœžœ˜Jšœ˜J˜—šŸ œžœžœžœ˜=šžœžœžœž˜!Jšœžœ!žœ˜Q—Jšžœ˜J˜J˜—šŸœžœžœ:žœ™WJšœ°™°Jšœžœžœ™(Jšœ™Jšœ™Jšœ™Jšœ$™$Jšœ'™'Jšœ™JšœG™GJšœ7ž œ™FJšžœžœžœ™Jšœ™Jšœ™Jšœ™J™—šŸ œžœžœ3˜ILšœ'˜'šŸ œžœžœ˜4Lšœ(˜(L˜—Lšœ2˜2L˜L˜—šŸœž œXžœ™„Jšœ©™©Jš žœ žœžœžœ‘™1Jš žœžœžœžœ‘™:Jšžœ*™,Jšžœ>™BJšžœI™MJšœ™—Jšœ˜šŸœžœHžœ™jšŸœžœžœžœ™CJšœ'™'Jšœ™Jšœ?™?Jšœ™—Jšœ-™-Jšœ<™