DIRECTORY Buttons USING [Button, ButtonProc, Create, SetDisplayStyle], CADIO USING [Error, ReadInfoFile, ReadVAXCadFiles, SelectCell, WriteInfoFile], CADTypes USING [Scad, VisibleMask], Commander USING [CommandProc, Register], Containers USING [ChildXBound, Container, Create], Convert USING [AtomFromRope, Error, IntFromRope, RealFromRope, RopeFromInt], Geometry3dMatrix USING [MakePureRotate, Matrix, Transform], Geometry3dVector USING [Add, Cross, Mul, Negate, Normalize, Ortho, Sub, Triple], ImagerColor USING [RGB], ImagerColorFns USING [RGBFromHSL], IO USING [real, PutFR], Labels USING [Create, Label, Set], Menus USING [AppendMenuEntry, CreateEntry, CreateMenu, Menu, MenuEntry, MenuProc], MessageWindow USING [Append, Blink], MultiPolynomial USING [RopeFromRef], NamedColors USING [BadGrammar, RopeToHSL, UndefinedName], PopUpSelection USING [Request], Real USING [InlineFix], Rope USING [Concat, Length, ROPE], Rules USING [Create, Rule], SurfaceTool, SurfaceViewer, ThreeDBasics USING [SetView], UserProfile USING [Number, Token], VFonts USING [CharWidth, EstablishFont, StringWidth], ViewerClasses USING [Viewer], ViewerOps USING [OpenIcon], ViewerSpecs USING [openLeftWidth], ViewerTools USING [GetContents, GetSelectionContents, MakeNewTextViewer, SetContents, SetSelection]; SurfaceToolImpl: CEDAR PROGRAM IMPORTS Buttons, CADIO, Commander, Containers, Convert, ImagerColorFns, IO, Labels, Geometry3dMatrix, Menus, MessageWindow, MultiPolynomial, NamedColors, PopUpSelection, Real, Rope, Rules, SurfaceViewer, ThreeDBasics, UserProfile, Geometry3dVector, VFonts, ViewerOps, ViewerSpecs, ViewerTools EXPORTS SurfaceTool ~ BEGIN SurfaceToolRef: TYPE ~ REF SurfaceToolRec; SurfaceToolRec: TYPE ~ RECORD [ outer: Containers.Container _ NIL, height: CARDINAL _ 0, buttonsLocked: BOOLEAN _ FALSE, sviewer: REF SurfaceViewer.SurfaceViewer, conversionState: ConversionState, positionAndOrientationState: PositionAndOrientationState, activeState: ActiveState, rayTracerState: RayTracerState]; MakeSurfaceTool: PUBLIC PROC[sviewer: REF SurfaceViewer.SurfaceViewer] ~ BEGIN surfaceTool: SurfaceToolRef _ NEW[SurfaceToolRec]; topMenu: Menus.Menu; viewEntry, breakEntry: Menus.MenuEntry; topMenu _ Menus.CreateMenu[]; viewEntry _ Menus.CreateEntry["View", BugView, surfaceTool]; breakEntry _ Menus.CreateEntry["Break", BugBreak, surfaceTool]; Menus.AppendMenuEntry[topMenu, viewEntry]; Menus.AppendMenuEntry[topMenu, breakEntry]; surfaceTool.outer _ Containers.Create[[ name: "Algebraic Surface Tool", iconic: TRUE, column: left, menu: topMenu, scrollable: FALSE]]; surfaceTool.sviewer _ sviewer; BuildPositionSubviewer[surfaceTool]; BuildActiveSubviewer[surfaceTool]; BuildRayTracerSubviewer[surfaceTool]; BuildConversionSubviewer[surfaceTool]; ViewerOps.OpenIcon[icon: surfaceTool.outer, closeOthers: TRUE, bottom: FALSE]; END; BugOpen: Menus.MenuProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; surfaceTool.sviewer _ SurfaceViewer.CreateSurfaceViewer[]; MakeNewFrame[surfaceTool]; END; BugView: Menus.MenuProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; MakeNewFrame[surfaceTool]; END; BugBreak: Menus.MenuProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; SIGNAL SurfaceToolBreak; END; SurfaceToolBreak: SIGNAL = CODE; MakeNewFrame: PROC[surfaceTool: SurfaceToolRef] ~ BEGIN ThreeDBasics.SetView [ context: SurfaceViewer.GetThreeDContext[surfaceTool.sviewer], eyePoint: surfaceTool.positionAndOrientationState.position, ptOfInterest: Geometry3dVector.Add[surfaceTool.positionAndOrientationState.position, surfaceTool.positionAndOrientationState.forward], upDirection: surfaceTool.positionAndOrientationState.up]; SurfaceViewer.DrawFrame[surfaceTool.sviewer]; END; smallHorizontalSpacing: CARDINAL ~ 10; largeHorizontalSpacing: CARDINAL ~ 20; smallVerticalSpacing: CARDINAL ~ 8; largeVerticalSpacing: CARDINAL ~ 16; smallButtonWidth: CARDINAL ~ 3 * VFonts.CharWidth['+]; dataButtonWidth: CARDINAL ~ 5 * VFonts.CharWidth['=]; dataViewerWidth: CARDINAL ~ 6*VFonts.CharWidth['0]; fileViewerWidth: CARDINAL ~ 30*VFonts.CharWidth['N]; verticalHeight: CARDINAL ~ 15; textViewerHeight: CARDINAL ~ verticalHeight + 6; toolWidth: CARDINAL ~ ViewerSpecs.openLeftWidth; verticalSpacingAboveSubviewer: CARDINAL ~ 1; verticalSpacingBelowSubviewer: CARDINAL ~ 1; ConversionState: TYPE ~ RECORD [ sourceDir: ViewerClasses.Viewer _ NIL, cadFile: ViewerClasses.Viewer _ NIL, csFile: ViewerClasses.Viewer _ NIL, destDir: ViewerClasses.Viewer _ NIL, destFile: ViewerClasses.Viewer _ NIL ]; BuildConversionSubviewer: PROC [surfaceTool: SurfaceToolRef] ~ BEGIN baseX: CARDINAL ~ 5; baseY: CARDINAL ~ surfaceTool.height + verticalSpacingAboveSubviewer; title: Rope.ROPE ~ "File Conversion"; titleRow: CARDINAL ~ baseY; titleColumn: CARDINAL ~ (toolWidth - VFonts.StringWidth[title])/2; buttonWidth: CARDINAL ~ VFonts.StringWidth["CAD: "]; viewerWidth: CARDINAL ~ (toolWidth/2) - baseX - buttonWidth; sourceButtonColumn: CARDINAL ~ baseX; sourceViewerColumn: CARDINAL ~ sourceButtonColumn + buttonWidth; destButtonColumn: CARDINAL ~ toolWidth / 2; destViewerColumn: CARDINAL ~ destButtonColumn + buttonWidth; doItWidth: CARDINAL ~ VFonts.StringWidth[" Do It "]; doItColumn: CARDINAL ~ toolWidth - doItWidth - smallHorizontalSpacing; doItRow: CARDINAL ~ titleRow + smallVerticalSpacing; subtitleRow: CARDINAL ~ titleRow + verticalHeight + smallVerticalSpacing; directoryRow: CARDINAL ~ subtitleRow + verticalHeight + smallVerticalSpacing; fileRow: CARDINAL ~ directoryRow + verticalHeight + smallVerticalSpacing; secondFileRow: CARDINAL ~ fileRow + verticalHeight + smallVerticalSpacing; bottomRow: CARDINAL ~ secondFileRow + verticalHeight + smallVerticalSpacing; theBottomLine: Rules.Rule; [] _ BuildLabel [title, surfaceTool.outer, titleColumn, titleRow, TRUE]; [] _ BuildLabel ["Source files (CAD and Covering Set)", surfaceTool.outer, sourceButtonColumn, subtitleRow]; [] _ BuildLabel ["Destination file (Algebraic surface)", surfaceTool.outer, destButtonColumn, subtitleRow]; [] _ BuildButton [surfaceTool, "Dir:", sourceButtonColumn, directoryRow, BugSourceDir, FALSE, buttonWidth]; [] _ BuildButton [surfaceTool, "CAD:", sourceButtonColumn, fileRow, BugCadFile, FALSE, buttonWidth]; [] _ BuildButton [surfaceTool, "CS:", sourceButtonColumn, secondFileRow, BugCSFile, FALSE, buttonWidth]; [] _ BuildButton [surfaceTool, "Dir:", destButtonColumn, directoryRow, BugDestDir, FALSE, buttonWidth]; [] _ BuildButton [surfaceTool, "File:", destButtonColumn, fileRow, BugDestFile, FALSE, buttonWidth]; [] _ BuildButton [surfaceTool, "Do It", doItColumn, doItRow, BugConvert, TRUE, doItWidth]; surfaceTool.conversionState.sourceDir _ BuildTextViewer [surfaceTool.outer, sourceViewerColumn, directoryRow, viewerWidth]; surfaceTool.conversionState.cadFile _ BuildTextViewer [surfaceTool.outer, sourceViewerColumn, fileRow, viewerWidth]; surfaceTool.conversionState.csFile _ BuildTextViewer [surfaceTool.outer, sourceViewerColumn, secondFileRow, viewerWidth]; surfaceTool.conversionState.destDir _ BuildTextViewer [surfaceTool.outer, destViewerColumn, directoryRow, viewerWidth]; surfaceTool.conversionState.destFile _ BuildTextViewer [surfaceTool.outer, destViewerColumn, fileRow, viewerWidth]; ViewerTools.SetContents[surfaceTool.conversionState.sourceDir, UserProfile.Token["AlgebraicSurfaces.SourceDir"]]; ViewerTools.SetContents[surfaceTool.conversionState.destDir, UserProfile.Token["AlgebraicSurfaces.DestDir"]]; theBottomLine _ Rules.Create [[ wx: 0, wy: bottomRow, wh: 1, parent: surfaceTool.outer]]; Containers.ChildXBound[surfaceTool.outer, theBottomLine]; surfaceTool.height _ surfaceTool.height + bottomRow - baseY + 1 + verticalSpacingBelowSubviewer; END; BugSourceDir: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; ViewerTools.SetSelection[surfaceTool.conversionState.sourceDir]; END; BugCadFile: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; ViewerTools.SetSelection[surfaceTool.conversionState.cadFile]; END; BugCSFile: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; ViewerTools.SetSelection[surfaceTool.conversionState.csFile]; END; BugDestDir: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; ViewerTools.SetSelection[surfaceTool.conversionState.destDir]; END; BugDestFile: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; ViewerTools.SetSelection[surfaceTool.conversionState.destFile]; END; BugConvert: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; sourceDir: Rope.ROPE _ ViewerTools.GetContents[surfaceTool.conversionState.sourceDir]; cadFile: Rope.ROPE _ ViewerTools.GetContents[surfaceTool.conversionState.cadFile]; csFile: Rope.ROPE _ ViewerTools.GetContents[surfaceTool.conversionState.csFile]; destDir: Rope.ROPE _ ViewerTools.GetContents[surfaceTool.conversionState.destDir]; destFile: Rope.ROPE _ ViewerTools.GetContents[surfaceTool.conversionState.destFile]; cadSource: Rope.ROPE _ Rope.Concat[sourceDir, cadFile]; csSource: Rope.ROPE _ Rope.Concat[sourceDir, csFile]; dest: Rope.ROPE _ Rope.Concat[destDir, destFile]; cad: CADTypes.Scad _ CADIO.ReadVAXCadFiles[cadSource, csSource]; CADIO.WriteInfoFile[dest, cad]; END; PositionAndOrientationState: TYPE ~ RECORD [ position: Geometry3dVector.Triple _ [-6, 0, 0.2], increment: REAL _ 0.1, xDataLabel: Labels.Label _ NIL, yDataLabel: Labels.Label _ NIL, zDataLabel: Labels.Label _ NIL, incrementLabel: Labels.Label _ NIL, forward: Geometry3dVector.Triple _ [1, 0, 0], up: Geometry3dVector.Triple _ [0, 0, 1], angularIncrement: REAL _ 15., forwardXLabel: Labels.Label _ NIL, forwardYLabel: Labels.Label _ NIL, forwardZLabel: Labels.Label _ NIL, upXLabel: Labels.Label _ NIL, upYLabel: Labels.Label _ NIL, upZLabel: Labels.Label _ NIL, angularIncrementLabel: Labels.Label _ NIL]; BuildPositionSubviewer: PROC [surfaceTool: SurfaceToolRef] ~ BEGIN baseX: CARDINAL ~ 5; baseY: CARDINAL ~ surfaceTool.height + verticalSpacingAboveSubviewer; topRow: CARDINAL ~ baseY; subRow: CARDINAL ~ topRow + verticalHeight; -- + smallVerticalSpacing; firstDataRow: CARDINAL ~ subRow + smallVerticalSpacing; secondDataRow: CARDINAL ~ firstDataRow + verticalHeight + smallVerticalSpacing; thirdDataRow: CARDINAL ~ secondDataRow + verticalHeight + smallVerticalSpacing; fourthRow: CARDINAL ~ thirdDataRow + verticalHeight + smallVerticalSpacing; bottomRow: CARDINAL ~ fourthRow + verticalHeight + smallVerticalSpacing; plusColumn: CARDINAL ~ baseX; plusButtonWidth: CARDINAL ~ VFonts.StringWidth[" +X "]; forwButtonWidth: CARDINAL ~ VFonts.StringWidth[" Forw "]; minusColumn: CARDINAL ~ plusColumn + forwButtonWidth + smallHorizontalSpacing; minusButtonWidth: CARDINAL ~ VFonts.StringWidth[" -X "]; backButtonWidth: CARDINAL ~ VFonts.StringWidth[" Back "]; setColumn: CARDINAL ~ minusColumn + backButtonWidth + smallHorizontalSpacing; setButtonWidth: CARDINAL ~ VFonts.StringWidth[" Set S "]; xyzLabelColumn: CARDINAL ~ setColumn + setButtonWidth + smallHorizontalSpacing; xyzLabelWidth: CARDINAL ~ VFonts.StringWidth["Step:"]; dataViewerColumn: CARDINAL ~ xyzLabelColumn + xyzLabelWidth + smallHorizontalSpacing; breakLineColumn: CARDINAL ~ dataViewerColumn + dataViewerWidth + largeHorizontalSpacing; rotateOpsColumn: CARDINAL ~ breakLineColumn + largeHorizontalSpacing; rotateOpsWidth: CARDINAL ~ VFonts.StringWidth["Angle: "]; rotateLeftColumn: CARDINAL ~ rotateOpsColumn + rotateOpsWidth + smallHorizontalSpacing; rotateLeftWidth: CARDINAL ~ VFonts.StringWidth[" Left "]; rotateRightColumn: CARDINAL ~ rotateLeftColumn + dataViewerWidth + smallHorizontalSpacing; rotateRightWidth: CARDINAL ~ VFonts.StringWidth[" Down "]; orientationLabelColumn: CARDINAL ~ rotateRightColumn + rotateRightWidth + smallHorizontalSpacing; orientationLabelWidth: CARDINAL ~ VFonts.StringWidth["Fwd: "]; orientationXColumn: CARDINAL ~ orientationLabelColumn + orientationLabelWidth + smallHorizontalSpacing; orientationYColumn: CARDINAL ~ orientationXColumn + dataViewerWidth + smallHorizontalSpacing; orientationZColumn: CARDINAL ~ orientationYColumn + dataViewerWidth + smallHorizontalSpacing; positionTitle: Rope.ROPE ~ "Position"; positionTitleColumn: CARDINAL ~ (breakLineColumn - VFonts.StringWidth[positionTitle])/2; orientationTitle: Rope.ROPE ~ "Orientation"; orientationTitleColumn: CARDINAL ~ (toolWidth + breakLineColumn - VFonts.StringWidth[orientationTitle])/2; hrule1, hrule2, hrule3, hrule4: Rules.Rule; [] _ BuildLabel [positionTitle, surfaceTool.outer, positionTitleColumn, topRow, TRUE]; [] _ BuildLabel [orientationTitle, surfaceTool.outer, orientationTitleColumn, topRow, TRUE]; [] _ BuildButton [surfaceTool, "+X", plusColumn, firstDataRow, BugPlusX, TRUE, plusButtonWidth]; [] _ BuildButton [surfaceTool, "+Y", plusColumn, secondDataRow, BugPlusY, TRUE, plusButtonWidth]; [] _ BuildButton [surfaceTool, "+Z", plusColumn, thirdDataRow, BugPlusZ, TRUE, plusButtonWidth]; [] _ BuildButton [surfaceTool, "Forw", plusColumn, fourthRow, BugForward, TRUE, forwButtonWidth]; [] _ BuildButton [surfaceTool, "-X", minusColumn, firstDataRow, BugMinusX, TRUE, minusButtonWidth]; [] _ BuildButton [surfaceTool, "-Y", minusColumn, secondDataRow, BugMinusY, TRUE, minusButtonWidth]; [] _ BuildButton [surfaceTool, "-Z", minusColumn, thirdDataRow, BugMinusZ, TRUE, minusButtonWidth]; [] _ BuildButton [surfaceTool, "Back", minusColumn, fourthRow, BugBackward, TRUE, backButtonWidth]; [] _ BuildButton [surfaceTool, "Set X", setColumn, firstDataRow, BugNewX, TRUE, setButtonWidth]; [] _ BuildButton [surfaceTool, "Set Y", setColumn, secondDataRow, BugNewY, TRUE, setButtonWidth]; [] _ BuildButton [surfaceTool, "Set Z", setColumn, thirdDataRow, BugNewZ, TRUE, setButtonWidth]; [] _ BuildButton [surfaceTool, "Set S", setColumn, fourthRow, BugSetStep, TRUE, setButtonWidth]; [] _ BuildLabel ["x =", surfaceTool.outer, xyzLabelColumn, firstDataRow]; [] _ BuildLabel ["y =", surfaceTool.outer, xyzLabelColumn, secondDataRow]; [] _ BuildLabel ["z =", surfaceTool.outer, xyzLabelColumn, thirdDataRow]; [] _ BuildLabel ["Step:", surfaceTool.outer, xyzLabelColumn, fourthRow]; surfaceTool.positionAndOrientationState.xDataLabel _ BuildDataLabel [surfaceTool.outer, dataViewerColumn, firstDataRow]; surfaceTool.positionAndOrientationState.yDataLabel _ BuildDataLabel [surfaceTool.outer, dataViewerColumn, secondDataRow]; surfaceTool.positionAndOrientationState.zDataLabel _ BuildDataLabel [surfaceTool.outer, dataViewerColumn, thirdDataRow]; surfaceTool.positionAndOrientationState.incrementLabel _ BuildDataLabel [surfaceTool.outer, dataViewerColumn, fourthRow]; [] _ Labels.Create[[name: "Turn", wx: rotateOpsColumn, wy: firstDataRow, wh: verticalHeight, parent: surfaceTool.outer, border: FALSE]]; [] _ BuildButton[surfaceTool, "Left", rotateLeftColumn, firstDataRow, BugTurnLeft, TRUE, rotateLeftWidth]; [] _ BuildButton[surfaceTool, "Right", rotateRightColumn, firstDataRow, BugTurnRight, TRUE, rotateRightWidth]; [] _ Labels.Create[[name: "Roll", wx: rotateOpsColumn, wy: secondDataRow, wh: verticalHeight, parent: surfaceTool.outer, border: FALSE]]; [] _ BuildButton[surfaceTool, "Left", rotateLeftColumn, secondDataRow, BugRollLeft, TRUE, rotateLeftWidth]; [] _ BuildButton[surfaceTool, "Right", rotateRightColumn, secondDataRow, BugRollRight, TRUE, rotateRightWidth]; [] _ Labels.Create[[name: "Dive", wx: rotateOpsColumn, wy: thirdDataRow, wh: verticalHeight, parent: surfaceTool.outer, border: FALSE]]; [] _ BuildButton[surfaceTool, "Up", rotateLeftColumn, thirdDataRow, BugClimb, TRUE]; [] _ BuildButton[surfaceTool, "Down", rotateRightColumn, thirdDataRow, BugDive, TRUE, rotateRightWidth]; [] _ BuildLabel ["Angle:", surfaceTool.outer, rotateOpsColumn, fourthRow]; surfaceTool.positionAndOrientationState.angularIncrementLabel _ BuildDataLabel [surfaceTool.outer, rotateLeftColumn, fourthRow]; [] _ BuildButton [surfaceTool, "Set A", rotateRightColumn, fourthRow, BugSetAngularStep, TRUE, rotateRightWidth]; [] _ Labels.Create[[name: "Fwd:", wx: orientationLabelColumn, wy: firstDataRow, wh: verticalHeight, parent: surfaceTool.outer, border: FALSE]]; [] _ Labels.Create[[name: "Up:", wx: orientationLabelColumn, wy: secondDataRow, wh: verticalHeight, parent: surfaceTool.outer, border: FALSE]]; surfaceTool.positionAndOrientationState.forwardXLabel _ BuildDataLabel[surfaceTool.outer, orientationXColumn, firstDataRow]; surfaceTool.positionAndOrientationState.forwardYLabel _ BuildDataLabel[surfaceTool.outer, orientationYColumn, firstDataRow]; surfaceTool.positionAndOrientationState.forwardZLabel _ BuildDataLabel[surfaceTool.outer, orientationZColumn, firstDataRow]; surfaceTool.positionAndOrientationState.upXLabel _ BuildDataLabel[surfaceTool.outer, orientationXColumn, secondDataRow]; surfaceTool.positionAndOrientationState.upYLabel _ BuildDataLabel[surfaceTool.outer, orientationYColumn, secondDataRow]; surfaceTool.positionAndOrientationState.upZLabel _ BuildDataLabel[surfaceTool.outer, orientationZColumn, secondDataRow]; [] _ BuildButton[surfaceTool, "Fancy maneuvers", orientationXColumn, fourthRow, BugFancy, TRUE]; UpdatePositionAndOrientationData[surfaceTool]; [] _ Rules.Create [[wx: breakLineColumn, wy: subRow, ww: 1, wh: bottomRow - subRow, parent: surfaceTool.outer]]; hrule1 _ Rules.Create [[wx: 0, wy: topRow, wh: 1, parent: surfaceTool.outer]]; hrule2 _ Rules.Create [[wx: 0, wy: subRow, wh: 1, parent: surfaceTool.outer]]; hrule3 _ Rules.Create [[wx: 0, wy: bottomRow, wh: 1, parent: surfaceTool.outer]]; Containers.ChildXBound[surfaceTool.outer, hrule1]; Containers.ChildXBound[surfaceTool.outer, hrule2]; Containers.ChildXBound[surfaceTool.outer, hrule3]; [] _ Rules.Create [[wx: orientationLabelColumn, wy: thirdDataRow, ww: 1, wh: bottomRow - thirdDataRow, parent: surfaceTool.outer]]; hrule4 _ Rules.Create [[wx: orientationLabelColumn, wy: thirdDataRow, wh: 1, parent: surfaceTool.outer]]; Containers.ChildXBound[surfaceTool.outer, hrule4]; surfaceTool.height _ surfaceTool.height + bottomRow - baseY + 1 + verticalSpacingBelowSubviewer; END; UpdatePositionAndOrientationData: PROC[surfaceTool: SurfaceToolRef] ~ BEGIN Labels.Set[surfaceTool.positionAndOrientationState.xDataLabel, RopeFromReal[surfaceTool.positionAndOrientationState.position.x]]; Labels.Set[surfaceTool.positionAndOrientationState.yDataLabel, RopeFromReal[surfaceTool.positionAndOrientationState.position.y]]; Labels.Set[surfaceTool.positionAndOrientationState.zDataLabel, RopeFromReal[surfaceTool.positionAndOrientationState.position.z]]; Labels.Set[surfaceTool.positionAndOrientationState.incrementLabel, RopeFromReal[surfaceTool.positionAndOrientationState.increment]]; Labels.Set[surfaceTool.positionAndOrientationState.forwardXLabel, RopeFromReal[surfaceTool.positionAndOrientationState.forward.x]]; Labels.Set[surfaceTool.positionAndOrientationState.forwardYLabel, RopeFromReal[surfaceTool.positionAndOrientationState.forward.y]]; Labels.Set[surfaceTool.positionAndOrientationState.forwardZLabel, RopeFromReal[surfaceTool.positionAndOrientationState.forward.z]]; Labels.Set[surfaceTool.positionAndOrientationState.upXLabel, RopeFromReal[surfaceTool.positionAndOrientationState.up.x]]; Labels.Set[surfaceTool.positionAndOrientationState.upYLabel, RopeFromReal[surfaceTool.positionAndOrientationState.up.y]]; Labels.Set[surfaceTool.positionAndOrientationState.upZLabel, RopeFromReal[surfaceTool.positionAndOrientationState.up.z]]; Labels.Set[surfaceTool.positionAndOrientationState.angularIncrementLabel, Convert.RopeFromInt[Real.InlineFix[surfaceTool.positionAndOrientationState.angularIncrement]]]; END; BugPlusX: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; surfaceTool.positionAndOrientationState.position.x _ surfaceTool.positionAndOrientationState.position.x + surfaceTool.positionAndOrientationState.increment; UpdatePositionAndOrientationData[surfaceTool]; END; BugPlusY: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; surfaceTool.positionAndOrientationState.position.y _ surfaceTool.positionAndOrientationState.position.y + surfaceTool.positionAndOrientationState.increment; UpdatePositionAndOrientationData[surfaceTool]; END; BugPlusZ: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; surfaceTool.positionAndOrientationState.position.z _ surfaceTool.positionAndOrientationState.position.z + surfaceTool.positionAndOrientationState.increment; UpdatePositionAndOrientationData[surfaceTool]; END; BugMinusX: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; surfaceTool.positionAndOrientationState.position.x _ surfaceTool.positionAndOrientationState.position.x - surfaceTool.positionAndOrientationState.increment; UpdatePositionAndOrientationData[surfaceTool]; END; BugMinusY: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; surfaceTool.positionAndOrientationState.position.y _ surfaceTool.positionAndOrientationState.position.y - surfaceTool.positionAndOrientationState.increment; UpdatePositionAndOrientationData[surfaceTool]; END; BugMinusZ: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; surfaceTool.positionAndOrientationState.position.z _ surfaceTool.positionAndOrientationState.position.z - surfaceTool.positionAndOrientationState.increment; UpdatePositionAndOrientationData[surfaceTool]; END; BugNewX: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; value: REAL _ GetRealSelection[surfaceTool.positionAndOrientationState.position.x]; surfaceTool.positionAndOrientationState.position.x _ value; UpdatePositionAndOrientationData[surfaceTool]; END; BugNewY: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; value: REAL _ GetRealSelection[surfaceTool.positionAndOrientationState.position.y]; surfaceTool.positionAndOrientationState.position.y _ value; UpdatePositionAndOrientationData[surfaceTool]; END; BugNewZ: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; value: REAL _ GetRealSelection[surfaceTool.positionAndOrientationState.position.z]; surfaceTool.positionAndOrientationState.position.z _ value; UpdatePositionAndOrientationData[surfaceTool]; END; BugSetStep: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; value: REAL _ GetRealSelection[surfaceTool.positionAndOrientationState.increment]; surfaceTool.positionAndOrientationState.increment _ value; UpdatePositionAndOrientationData[surfaceTool]; END; BugTurnLeft: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; axis: Geometry3dVector.Triple _ surfaceTool.positionAndOrientationState.up; rotationMatrix: Geometry3dMatrix.Matrix _ Geometry3dMatrix.MakePureRotate[axis, -(surfaceTool.positionAndOrientationState.angularIncrement)]; oldForward: Geometry3dVector.Triple _ surfaceTool.positionAndOrientationState.forward; newForward: Geometry3dVector.Triple _ Geometry3dMatrix.Transform[oldForward, rotationMatrix]; surfaceTool.positionAndOrientationState.forward _ newForward; UpdatePositionAndOrientationData[surfaceTool]; END; BugTurnRight: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; axis: Geometry3dVector.Triple _ surfaceTool.positionAndOrientationState.up; rotationMatrix: Geometry3dMatrix.Matrix _ Geometry3dMatrix.MakePureRotate[axis, surfaceTool.positionAndOrientationState.angularIncrement]; oldForward: Geometry3dVector.Triple _ surfaceTool.positionAndOrientationState.forward; newForward: Geometry3dVector.Triple _ Geometry3dMatrix.Transform[oldForward, rotationMatrix]; surfaceTool.positionAndOrientationState.forward _ newForward; UpdatePositionAndOrientationData[surfaceTool]; END; BugRollLeft: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; axis: Geometry3dVector.Triple _ surfaceTool.positionAndOrientationState.forward; rotationMatrix: Geometry3dMatrix.Matrix _ Geometry3dMatrix.MakePureRotate[axis, surfaceTool.positionAndOrientationState.angularIncrement]; oldUp: Geometry3dVector.Triple _ surfaceTool.positionAndOrientationState.up; newUp: Geometry3dVector.Triple _ Geometry3dMatrix.Transform[oldUp, rotationMatrix]; surfaceTool.positionAndOrientationState.up _ newUp; UpdatePositionAndOrientationData[surfaceTool]; END; BugRollRight: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; axis: Geometry3dVector.Triple _ surfaceTool.positionAndOrientationState.forward; rotationMatrix: Geometry3dMatrix.Matrix _ Geometry3dMatrix.MakePureRotate[axis, -(surfaceTool.positionAndOrientationState.angularIncrement)]; oldUp: Geometry3dVector.Triple _ surfaceTool.positionAndOrientationState.up; newUp: Geometry3dVector.Triple _ Geometry3dMatrix.Transform[oldUp, rotationMatrix]; surfaceTool.positionAndOrientationState.up _ newUp; UpdatePositionAndOrientationData[surfaceTool]; END; BugClimb: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; axis: Geometry3dVector.Triple _ Geometry3dVector.Cross[surfaceTool.positionAndOrientationState.forward, surfaceTool.positionAndOrientationState.up]; rotationMatrix: Geometry3dMatrix.Matrix _ Geometry3dMatrix.MakePureRotate[axis, -(surfaceTool.positionAndOrientationState.angularIncrement)]; oldUp: Geometry3dVector.Triple _ surfaceTool.positionAndOrientationState.up; oldForward: Geometry3dVector.Triple _ surfaceTool.positionAndOrientationState.forward; newUp: Geometry3dVector.Triple _ Geometry3dMatrix.Transform[oldUp, rotationMatrix]; newForward: Geometry3dVector.Triple _ Geometry3dMatrix.Transform[oldForward, rotationMatrix]; surfaceTool.positionAndOrientationState.up _ newUp; surfaceTool.positionAndOrientationState.forward _ newForward; UpdatePositionAndOrientationData[surfaceTool]; END; BugDive: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; axis: Geometry3dVector.Triple _ Geometry3dVector.Cross[surfaceTool.positionAndOrientationState.forward, surfaceTool.positionAndOrientationState.up]; rotationMatrix: Geometry3dMatrix.Matrix _ Geometry3dMatrix.MakePureRotate[axis, surfaceTool.positionAndOrientationState.angularIncrement]; oldUp: Geometry3dVector.Triple _ surfaceTool.positionAndOrientationState.up; oldForward: Geometry3dVector.Triple _ surfaceTool.positionAndOrientationState.forward; newUp: Geometry3dVector.Triple _ Geometry3dMatrix.Transform[oldUp, rotationMatrix]; newForward: Geometry3dVector.Triple _ Geometry3dMatrix.Transform[oldForward, rotationMatrix]; surfaceTool.positionAndOrientationState.up _ newUp; surfaceTool.positionAndOrientationState.forward _ newForward; UpdatePositionAndOrientationData[surfaceTool]; END; BugSetAngularStep: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; value: REAL _ GetRealSelection[surfaceTool.positionAndOrientationState.angularIncrement]; surfaceTool.positionAndOrientationState.angularIncrement _ value; UpdatePositionAndOrientationData[surfaceTool]; END; BugForward: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; displacement: Geometry3dVector.Triple _ Geometry3dVector.Mul[surfaceTool.positionAndOrientationState.forward, surfaceTool.positionAndOrientationState.increment]; surfaceTool.positionAndOrientationState.position _ Geometry3dVector.Add[surfaceTool.positionAndOrientationState.position, displacement]; UpdatePositionAndOrientationData[surfaceTool]; END; BugBackward: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; displacement: Geometry3dVector.Triple _ Geometry3dVector.Mul[surfaceTool.positionAndOrientationState.forward, surfaceTool.positionAndOrientationState.increment]; surfaceTool.positionAndOrientationState.position _ Geometry3dVector.Sub[surfaceTool.positionAndOrientationState.position, displacement]; UpdatePositionAndOrientationData[surfaceTool]; END; BugFancy: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; options: LIST OF Rope.ROPE _ LIST[ "Turn around", "Go to origin", "Look towards origin", "Look towards origin from +x axis", "Look towards origin from +y axis", "Look towards origin from +z axis", "Look towards origin from -x axis", "Look towards origin from -y axis", "Look towards origin from -z axis", "Look in +x direction", "Look in +y direction", "Look in +z direction", "Look toward origin from +++ octant", "Look toward origin from ++ octant", "Look toward origin from ++ octant", "Look toward origin from + octant", "Look toward origin from ++ octant", "Look toward origin from + octant", "Look toward origin from + octant", "Look toward origin from  octant", ]; selection: INT _ PopUpSelection.Request[ header: "Fancy maneuvers", choice: options]; SELECT selection FROM -1 => NULL; -- Timeout 0 => NULL; -- No selection 1 => -- Turn around surfaceTool.positionAndOrientationState.forward _ Geometry3dVector.Mul[surfaceTool.positionAndOrientationState.forward, -1]; 2 => { -- Go to originB surfaceTool.positionAndOrientationState.position _ [0, 0, 0]; }; 3 => { -- Look towards origin forward: Geometry3dVector.Triple _ Geometry3dVector.Negate[surfaceTool.positionAndOrientationState.position]; surfaceTool.positionAndOrientationState.forward _ Geometry3dVector.Normalize[forward]; surfaceTool.positionAndOrientationState.up _ Geometry3dVector.Ortho[forward, [1,0,0] ]; }; 4 => { -- Look toward origin from +x axis surfaceTool.positionAndOrientationState.position _ [10, 0, 0]; surfaceTool.positionAndOrientationState.forward _ [-1, 0, 0]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 5 => { -- Look toward origin from +y axis surfaceTool.positionAndOrientationState.position _ [0, 10, 0]; surfaceTool.positionAndOrientationState.forward _ [0, -1, 0]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 6 => { -- Look toward origin from +z axis surfaceTool.positionAndOrientationState.position _ [0, 0, 10]; surfaceTool.positionAndOrientationState.forward _ [0, 0, -1]; surfaceTool.positionAndOrientationState.up _ [0, 1, 0]; }; 7 => { -- Look toward origin from -x axis surfaceTool.positionAndOrientationState.position _ [-10, 0, 0]; surfaceTool.positionAndOrientationState.forward _ [1, 0, 0]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 8 => { -- Look toward origin from -y axis surfaceTool.positionAndOrientationState.position _ [0, -10, 0]; surfaceTool.positionAndOrientationState.forward _ [0, 1, 0]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 9 => { -- Look toward origin from -z axis surfaceTool.positionAndOrientationState.position _ [0, 0, -10]; surfaceTool.positionAndOrientationState.forward _ [0, 0, 1]; surfaceTool.positionAndOrientationState.up _ [0, 1, 0]; }; 10 => { -- Look in +x direction surfaceTool.positionAndOrientationState.forward _ [1, 0, 0]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 11 => { -- Look in +y direction surfaceTool.positionAndOrientationState.forward _ [0, 1, 0]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 12 => { -- Look in +z direction surfaceTool.positionAndOrientationState.forward _ [0, 0, 1]; surfaceTool.positionAndOrientationState.up _ [0, 1, 0]; }; 13 => { surfaceTool.positionAndOrientationState.position _ [3, 3, 3]; surfaceTool.positionAndOrientationState.forward _ Geometry3dVector.Normalize[[-1, -1, -1]]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 14 => { surfaceTool.positionAndOrientationState.position _ [3, 3, -3]; surfaceTool.positionAndOrientationState.forward _ Geometry3dVector.Normalize[[-1, -1, 1]]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 15 => { surfaceTool.positionAndOrientationState.position _ [3, -3, 3]; surfaceTool.positionAndOrientationState.forward _ Geometry3dVector.Normalize[[-1, 1, -1]]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 16 => { surfaceTool.positionAndOrientationState.position _ [3, -3, -3]; surfaceTool.positionAndOrientationState.forward _ Geometry3dVector.Normalize[[-1, 1, 1]]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 17 => { surfaceTool.positionAndOrientationState.position _ [-3, 3, 3]; surfaceTool.positionAndOrientationState.forward _ Geometry3dVector.Normalize[[1, -1, -1]]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 18 => { surfaceTool.positionAndOrientationState.position _ [-3, 3, -3]; surfaceTool.positionAndOrientationState.forward _ Geometry3dVector.Normalize[[1, -1, 1]]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 19 => { surfaceTool.positionAndOrientationState.position _ [-3, -3, 3]; surfaceTool.positionAndOrientationState.forward _ Geometry3dVector.Normalize[[1, 1, -1]]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; 20 => { surfaceTool.positionAndOrientationState.position _ [-3, -3, -3]; surfaceTool.positionAndOrientationState.forward _ Geometry3dVector.Normalize[[1, 1, 1]]; surfaceTool.positionAndOrientationState.up _ [0, 0, 1]; }; ENDCASE => NULL; UpdatePositionAndOrientationData[surfaceTool]; END; ActiveState: TYPE ~ RECORD [ surfaces: REF ActiveSurfaceSequence, selectedSurface: NAT _ 0, -- 0=none dir: ViewerClasses.Viewer _ NIL, filename: ViewerClasses.Viewer _ NIL ]; ActiveSurfaceRec: TYPE ~ RECORD [ button: Buttons.Button _ NIL, viewer: ViewerClasses.Viewer _ NIL, visibleLabel: Labels.Label _ NIL, surfaceID: NAT, isLoaded: BOOLEAN _ FALSE, cad: CADTypes.Scad, mask: REF CADTypes.VisibleMask, isVisible: BOOLEAN _ TRUE ]; ActiveSurfaceSequence: TYPE ~ RECORD [ activeSurfaceRecs: SEQUENCE length: NAT OF ActiveSurfaceRec]; BuildActiveSubviewer: PROC [surfaceTool: SurfaceToolRef] ~ BEGIN baseX: CARDINAL ~ 5; baseY: CARDINAL ~ surfaceTool.height + verticalSpacingAboveSubviewer; topRow: CARDINAL ~ baseY; subRow: CARDINAL ~ topRow + verticalHeight; activeBlockX: CARDINAL ~ 20; activeBlockY: CARDINAL ~ baseY; activeTitle: Rope.ROPE ~ "Active Surfaces"; activeTitleRow: CARDINAL ~ activeBlockY; activeTitleColumn: CARDINAL ~ (toolWidth - VFonts.StringWidth[activeTitle])/2; activeLetterColumn: CARDINAL ~ activeBlockX; activeLetterButtonWidth: CARDINAL ~ VFonts.StringWidth[" B "]; activeNameColumn: CARDINAL ~ activeLetterColumn + activeLetterButtonWidth + smallHorizontalSpacing; activeNameViewerWidth: CARDINAL ~ (toolWidth/2) - activeNameColumn; activeVisibleColumn: CARDINAL ~ activeNameColumn + activeNameViewerWidth + smallHorizontalSpacing; activeVisibleLabelWidth: CARDINAL ~ 20; activeFirstButtonColumn: CARDINAL ~ activeVisibleColumn + activeVisibleLabelWidth + smallHorizontalSpacing; activeFirstButtonWidth: CARDINAL ~ VFonts.StringWidth[" Set color "]; activeSecondButtonColumn: CARDINAL ~ activeFirstButtonColumn + activeFirstButtonWidth + smallHorizontalSpacing; activeSecondButtonWidth: CARDINAL ~ VFonts.StringWidth[" Show/Don't show "]; activeIOLabelColumn: CARDINAL ~ activeBlockX; cellLabelColumn: CARDINAL ~ activeBlockX; cellButtonSpacing: CARDINAL ~ VFonts.StringWidth[" Reveal One "]; cellFirstButtonColumn: CARDINAL ~ cellLabelColumn + cellButtonSpacing; cellSecondButtonColumn: CARDINAL ~ cellFirstButtonColumn + cellButtonSpacing; cellThirdButtonColumn: CARDINAL ~ cellSecondButtonColumn + cellButtonSpacing; cellFourthButtonColumn: CARDINAL ~ cellThirdButtonColumn + cellButtonSpacing; cellFifthButtonColumn: CARDINAL ~ cellFourthButtonColumn + cellButtonSpacing; activeIOLabelWidth: CARDINAL ~ VFonts.StringWidth[" Working dir: "]; activeIOViewerColumn: CARDINAL ~ activeIOLabelColumn + activeIOLabelWidth + smallHorizontalSpacing; activeIOViewerWidth: CARDINAL ~ (toolWidth/2); activeIOButtonColumn: CARDINAL ~ activeIOViewerColumn + activeIOViewerWidth + smallHorizontalSpacing; activeIOButtonWidth: CARDINAL ~ VFonts.StringWidth[" Store "]; activeARow: CARDINAL ~ activeTitleRow + verticalHeight + smallVerticalSpacing; activeBRow: CARDINAL ~ activeARow + verticalHeight + smallVerticalSpacing; activeCRow: CARDINAL ~ activeBRow + verticalHeight + smallVerticalSpacing; activeDirRow: CARDINAL ~ activeCRow + verticalHeight + 2 * smallVerticalSpacing; activeFileRow: CARDINAL ~ activeDirRow + verticalHeight + smallVerticalSpacing; cellRow: CARDINAL ~ activeFileRow + verticalHeight + 2 * smallVerticalSpacing; bottomRow: CARDINAL ~ cellRow + verticalHeight + smallVerticalSpacing; hrule1, hrule2, hrule3: Rules.Rule; surfaceTool.activeState.surfaces _ NEW[ActiveSurfaceSequence[3]]; [] _ BuildLabel [activeTitle, surfaceTool.outer, activeTitleColumn, activeTitleRow, TRUE]; surfaceTool.activeState.surfaces[0].button _ BuildButton [surfaceTool, "A", activeLetterColumn, activeARow, BugA, TRUE, activeLetterButtonWidth]; surfaceTool.activeState.surfaces[1].button _ BuildButton [surfaceTool, "B", activeLetterColumn, activeBRow, BugB, TRUE, activeLetterButtonWidth]; surfaceTool.activeState.surfaces[2].button _ BuildButton [surfaceTool, "C", activeLetterColumn, activeCRow, BugC, TRUE, activeLetterButtonWidth]; surfaceTool.activeState.surfaces[0].viewer _ BuildTextViewer [surfaceTool.outer, activeNameColumn, activeARow, activeNameViewerWidth]; surfaceTool.activeState.surfaces[1].viewer _ BuildTextViewer [surfaceTool.outer, activeNameColumn, activeBRow, activeNameViewerWidth]; surfaceTool.activeState.surfaces[2].viewer _ BuildTextViewer [surfaceTool.outer, activeNameColumn, activeCRow, activeNameViewerWidth]; surfaceTool.activeState.surfaces[0].visibleLabel _ BuildLabel ["N", surfaceTool.outer, activeVisibleColumn, activeARow, FALSE]; surfaceTool.activeState.surfaces[1].visibleLabel _ BuildLabel ["N", surfaceTool.outer, activeVisibleColumn, activeBRow, FALSE]; surfaceTool.activeState.surfaces[2].visibleLabel _ BuildLabel ["N", surfaceTool.outer, activeVisibleColumn, activeCRow, FALSE]; [] _ BuildButton [surfaceTool, "Rename", activeFirstButtonColumn, activeARow, BugRename, TRUE, activeFirstButtonWidth]; [] _ BuildButton [surfaceTool, "Delete", activeFirstButtonColumn, activeBRow, BugDelete, TRUE, activeFirstButtonWidth]; [] _ BuildButton [surfaceTool, "Set color", activeFirstButtonColumn, activeCRow, BugSetColor, TRUE, activeFirstButtonWidth]; [] _ BuildButton [surfaceTool, "Name/Formula", activeSecondButtonColumn, activeARow, BugName, TRUE, activeSecondButtonWidth]; [] _ BuildButton [surfaceTool, "Show/Don't Show", activeSecondButtonColumn, activeBRow, BugShow, TRUE, activeSecondButtonWidth]; [] _ BuildButton [surfaceTool, "Set Render Mode", activeSecondButtonColumn, activeCRow, BugSetRenderMode, TRUE, activeSecondButtonWidth]; [] _ BuildButton [surfaceTool, "Working dir:", activeIOLabelColumn, activeDirRow, BugDir, TRUE, activeIOLabelWidth]; [] _ BuildButton [surfaceTool, "File name:", activeIOLabelColumn, activeFileRow, BugFile, TRUE, activeIOLabelWidth]; surfaceTool.activeState.dir _ BuildTextViewer [surfaceTool.outer, activeIOViewerColumn, activeDirRow, activeIOViewerWidth]; surfaceTool.activeState.filename _ BuildTextViewer [surfaceTool.outer, activeIOViewerColumn, activeFileRow, activeIOViewerWidth]; ViewerTools.SetContents[surfaceTool.activeState.dir, UserProfile.Token["AlgebraicSurfaces.ActiveDir"]]; [] _ BuildButton [surfaceTool, "Load", activeIOButtonColumn, activeDirRow, BugLoadSurface, TRUE, activeIOButtonWidth]; [] _ BuildButton [surfaceTool, "Store", activeIOButtonColumn, activeFileRow, BugStore, TRUE, activeIOButtonWidth]; [] _ BuildLabel ["Cell Ops:", surfaceTool.outer, cellLabelColumn, cellRow, TRUE]; [] _ BuildButton [surfaceTool, "Hide All", cellFirstButtonColumn, cellRow, BugHideAll, TRUE]; [] _ BuildButton [surfaceTool, "Hide One", cellSecondButtonColumn, cellRow, BugHideOne, TRUE]; [] _ BuildButton [surfaceTool, "Reveal All", cellThirdButtonColumn, cellRow, BugRevealAll, TRUE]; [] _ BuildButton [surfaceTool, "Reveal One", cellFourthButtonColumn, cellRow, BugRevealOne, TRUE]; [] _ BuildButton [surfaceTool, "List All", cellFifthButtonColumn, cellRow, BugListAll, TRUE]; hrule1 _ Rules.Create [[wx: 0, wy: topRow, wh: 1, parent: surfaceTool.outer]]; hrule2 _ Rules.Create [[wx: 0, wy: subRow, wh: 1, parent: surfaceTool.outer]]; hrule3 _ Rules.Create [[wx: 0, wy: bottomRow, wh: 1, parent: surfaceTool.outer]]; Containers.ChildXBound[surfaceTool.outer, hrule1]; Containers.ChildXBound[surfaceTool.outer, hrule2]; Containers.ChildXBound[surfaceTool.outer, hrule3]; surfaceTool.height _ surfaceTool.height + bottomRow - baseY + 1 + verticalSpacingBelowSubviewer; END; BugA: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; IF surfaceTool.activeState.surfaces[0].isLoaded THEN BEGIN surfaceTool.activeState.selectedSurface _ 0; ViewerTools.SetSelection[surfaceTool.activeState.surfaces[0].viewer]; RepaintLetterButtons[surfaceTool]; END; END; BugB: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; IF surfaceTool.activeState.surfaces[1].isLoaded THEN BEGIN surfaceTool.activeState.selectedSurface _ 1; ViewerTools.SetSelection[surfaceTool.activeState.surfaces[1].viewer]; RepaintLetterButtons[surfaceTool]; END; END; BugC: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; IF surfaceTool.activeState.surfaces[2].isLoaded THEN BEGIN surfaceTool.activeState.selectedSurface _ 2; ViewerTools.SetSelection[surfaceTool.activeState.surfaces[2].viewer]; RepaintLetterButtons[surfaceTool]; END; END; RepaintLetterButtons: PROC [surfaceTool: SurfaceToolRef] ~ BEGIN RepaintLetterButtonsError: ERROR = CODE; Buttons.SetDisplayStyle [surfaceTool.activeState.surfaces[0].button, $BlackOnWhite]; Buttons.SetDisplayStyle [surfaceTool.activeState.surfaces[1].button, $BlackOnWhite]; Buttons.SetDisplayStyle [surfaceTool.activeState.surfaces[2].button, $BlackOnWhite]; SELECT surfaceTool.activeState.selectedSurface FROM 0 => Buttons.SetDisplayStyle [surfaceTool.activeState.surfaces[0].button, $WhiteOnBlack]; 1 => Buttons.SetDisplayStyle [surfaceTool.activeState.surfaces[1].button, $WhiteOnBlack]; 2 => Buttons.SetDisplayStyle [surfaceTool.activeState.surfaces[2].button, $WhiteOnBlack]; ENDCASE => ERROR RepaintLetterButtonsError; END; RedrawEquationViewers: PROC [surfaceTool: SurfaceToolRef] ~ BEGIN FOR i: NAT IN [0..3) DO IF surfaceTool.activeState.surfaces[i].isLoaded THEN BEGIN ViewerTools.SetContents[surfaceTool.activeState.surfaces[i].viewer, MultiPolynomial.RopeFromRef[surfaceTool.activeState.surfaces[i].cad.surface]]; Labels.Set[ surfaceTool.activeState.surfaces[i].visibleLabel, IF surfaceTool.activeState.surfaces[i].isVisible THEN "Y" ELSE "N"]; END ELSE BEGIN ViewerTools.SetContents[surfaceTool.activeState.surfaces[i].viewer, ""]; Labels.Set[surfaceTool.activeState.surfaces[i].visibleLabel, "-"]; END; ENDLOOP; END; BugRename: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; END; BugDelete: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; selectedSurface: NAT _ surfaceTool.activeState.selectedSurface; IF surfaceTool.activeState.surfaces[selectedSurface].isLoaded THEN BEGIN SurfaceViewer.DeleteSurface[surfaceTool.activeState.surfaces[selectedSurface].surfaceID, surfaceTool.sviewer]; surfaceTool.activeState.surfaces[selectedSurface].isLoaded _ FALSE; RedrawEquationViewers[surfaceTool]; END; END; BugSetColor: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; id: NAT; color: ImagerColor.RGB; BEGIN selectedSurface: NAT _ surfaceTool.activeState.selectedSurface; IF surfaceTool.activeState.surfaces[selectedSurface].isLoaded = FALSE THEN BEGIN FlashMessage["No selected surface"]; RETURN; END; id _ surfaceTool.activeState.surfaces[selectedSurface].surfaceID; END; BEGIN selection: Rope.ROPE _ ViewerTools.GetSelectionContents[]; failure: BOOL _ FALSE; color: ImagerColor.RGB _ ImagerColorFns.RGBFromHSL[ NamedColors.RopeToHSL[selection ! NamedColors.UndefinedName => BEGIN FlashMessage["Select the name of a color first"]; failure _ TRUE; END; NamedColors.BadGrammar => BEGIN FlashMessage["Select a valid color name first"]; failure _ TRUE; END; ]]; IF failure THEN RETURN; END; SurfaceViewer.SetSurfaceColor[id, color, surfaceTool.sviewer]; END; BugName: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; END; BugShow: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; selectedSurface: NAT _ surfaceTool.activeState.selectedSurface; IF surfaceTool.activeState.surfaces[selectedSurface].isLoaded THEN BEGIN IF surfaceTool.activeState.surfaces[selectedSurface].isVisible THEN BEGIN SurfaceViewer.HideSurface [surfaceTool.activeState.surfaces[selectedSurface].surfaceID, surfaceTool.sviewer]; surfaceTool.activeState.surfaces[selectedSurface].isVisible _ FALSE; END ELSE BEGIN SurfaceViewer.UnHideSurface [surfaceTool.activeState.surfaces[selectedSurface].surfaceID, surfaceTool.sviewer]; surfaceTool.activeState.surfaces[selectedSurface].isVisible _ TRUE; END; RedrawEquationViewers[surfaceTool]; MakeNewFrame[surfaceTool]; END; END; BugSetRenderMode: Buttons.ButtonProc ~ BEGIN selection: INT; id: NAT; surfaceTool: SurfaceToolRef _ NARROW[clientData]; options: LIST OF Rope.ROPE _ LIST["Lines", "Faceted", "Smooth", "Hidden Lines", "Normaled Lines", "Shaded Lines"]; selectedSurface: NAT _ surfaceTool.activeState.selectedSurface; IF surfaceTool.activeState.surfaces[selectedSurface].isLoaded = FALSE THEN BEGIN FlashMessage["No selected surface"]; RETURN; END; id _ surfaceTool.activeState.surfaces[selectedSurface].surfaceID; selection _ PopUpSelection.Request[ header: "Select a rendering mode", choice: options]; SELECT selection FROM -1 => NULL; -- Timeout 0 => NULL; -- No selection 1 => SurfaceViewer.SetSurfaceRenderingMode[id, $Lines, surfaceTool.sviewer]; 2 => SurfaceViewer.SetSurfaceRenderingMode[id, $Faceted, surfaceTool.sviewer]; 3 => SurfaceViewer.SetSurfaceRenderingMode[id, $Smooth, surfaceTool.sviewer]; 4 => SurfaceViewer.SetSurfaceRenderingMode[id, $HiddenLines, surfaceTool.sviewer]; 5 => SurfaceViewer.SetSurfaceRenderingMode[id, $NormaledLines, surfaceTool.sviewer]; 6 => SurfaceViewer.SetSurfaceRenderingMode[id, $ShadedLines, surfaceTool.sviewer]; ENDCASE => NULL; END; BugDir: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; ViewerTools.SetSelection[surfaceTool.activeState.dir]; END; BugFile: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; ViewerTools.SetSelection[surfaceTool.activeState.filename]; END; BugLoadSurface: Buttons.ButtonProc ~ BEGIN dir, file: Rope.ROPE; scad: CADTypes.Scad; id: NAT; slot: NAT; abort: BOOLEAN _ FALSE; surfaceTool: SurfaceToolRef _ NARROW[clientData]; IF surfaceTool.activeState.surfaces[0].isLoaded = FALSE THEN slot _ 0 ELSE IF surfaceTool.activeState.surfaces[1].isLoaded = FALSE THEN slot _ 1 ELSE IF surfaceTool.activeState.surfaces[2].isLoaded = FALSE THEN slot _ 2 ELSE {FlashMessage["No more slots available."]; RETURN}; dir _ ViewerTools.GetContents[surfaceTool.activeState.dir]; file _ ViewerTools.GetContents[surfaceTool.activeState.filename]; scad _ CADIO.ReadInfoFile[Rope.Concat[dir, file] ! CADIO.Error => {FlashMessage["Error in Info file."]; abort _ TRUE; CONTINUE} ]; IF abort THEN RETURN; id _ SurfaceViewer.LoadSurface[scad, surfaceTool.sviewer ! SurfaceViewer.Error => {FlashMessage["SurfaceViewer raised error."]; abort _ TRUE; CONTINUE} ]; IF abort THEN RETURN; surfaceTool.activeState.surfaces[slot].surfaceID _ id; surfaceTool.activeState.surfaces[slot].isLoaded _ TRUE; surfaceTool.activeState.surfaces[slot].cad _ scad; surfaceTool.activeState.surfaces[slot].isVisible _ TRUE; surfaceTool.activeState.surfaces[slot].mask _ NEW[CADTypes.VisibleMask[scad.cells.nCells]]; FOR i: NAT IN [0..scad.cells.nCells) DO surfaceTool.activeState.surfaces[slot].mask[i] _ TRUE; ENDLOOP; surfaceTool.activeState.selectedSurface _ slot; RepaintLetterButtons[surfaceTool]; RedrawEquationViewers[surfaceTool]; END; BugStore: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; END; BugHideAll: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; activeSurface: ActiveSurfaceRec _ surfaceTool.activeState.surfaces[surfaceTool.activeState.selectedSurface]; IF activeSurface.isLoaded = FALSE THEN BEGIN FlashMessage["No selected surface"]; RETURN; END; FOR i: NAT IN [0..activeSurface.mask.length) DO activeSurface.mask[i] _ FALSE; ENDLOOP; SurfaceViewer.MaskSurface[activeSurface.surfaceID, activeSurface.mask, surfaceTool.sviewer]; END; BugHideOne: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; activeSurface: ActiveSurfaceRec _ surfaceTool.activeState.surfaces[surfaceTool.activeState.selectedSurface]; cellIndex: NAT; IF activeSurface.isLoaded = FALSE THEN BEGIN FlashMessage["No selected surface"]; RETURN; END; cellIndex _ CADIO.SelectCell[ activeSurface.cad, activeSurface.mask, "Select cell to hide"]; IF cellIndex # -1 THEN BEGIN activeSurface.mask[cellIndex] _ FALSE; SurfaceViewer.MaskSurface[activeSurface.surfaceID, activeSurface.mask, surfaceTool.sviewer]; END; END; BugRevealAll: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; activeSurface: ActiveSurfaceRec _ surfaceTool.activeState.surfaces[surfaceTool.activeState.selectedSurface]; selection: INT; IF activeSurface.isLoaded = FALSE THEN BEGIN FlashMessage["No selected surface"]; RETURN; END; selection _ 1; FOR i: NAT IN [0..activeSurface.mask.length) DO SELECT selection FROM 1 => activeSurface.mask[i] _ TRUE; 2 => IF activeSurface.cad.cells[i].dimension = 0 THEN activeSurface.mask[i] _ TRUE; 3 => IF activeSurface.cad.cells[i].dimension = 1 THEN activeSurface.mask[i] _ TRUE; 4 => IF activeSurface.cad.cells[i].dimension = 2 THEN activeSurface.mask[i] _ TRUE; ENDCASE; ENDLOOP; SurfaceViewer.MaskSurface[activeSurface.surfaceID, activeSurface.mask, surfaceTool.sviewer]; END; BugRevealOne: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; activeSurface: ActiveSurfaceRec _ surfaceTool.activeState.surfaces[surfaceTool.activeState.selectedSurface]; cellIndex: INT; IF activeSurface.isLoaded = FALSE THEN BEGIN FlashMessage["No selected surface"]; RETURN; END; cellIndex _ CADIO.SelectCell[ activeSurface.cad, activeSurface.mask, "Select cell to reveal"]; IF cellIndex # -1 THEN BEGIN activeSurface.mask[cellIndex] _ TRUE; END; SurfaceViewer.MaskSurface[activeSurface.surfaceID, activeSurface.mask, surfaceTool.sviewer]; END; BugListAll: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; slot: NAT _ surfaceTool.activeState.selectedSurface; IF surfaceTool.activeState.surfaces[slot].isLoaded = FALSE THEN BEGIN FlashMessage["No selected surface"]; RETURN; END; [] _ CADIO.SelectCell[ surfaceTool.activeState.surfaces[slot].cad, surfaceTool.activeState.surfaces[slot].mask, "Cells"]; END; RayTracerState: TYPE ~ RECORD [ variableX: ViewerClasses.Viewer _ NIL, variableY: ViewerClasses.Viewer _ NIL, variableZ: ViewerClasses.Viewer _ NIL, widthInPixels: ViewerClasses.Viewer _ NIL, heightInPixels: ViewerClasses.Viewer _ NIL, dir: ViewerClasses.Viewer _ NIL, filename: ViewerClasses.Viewer _ NIL ]; BuildRayTracerSubviewer: PROC [surfaceTool: SurfaceToolRef] ~ BEGIN baseX: CARDINAL ~ 5; baseY: CARDINAL ~ surfaceTool.height + verticalSpacingAboveSubviewer; title: Rope.ROPE ~ "Ray Tracer"; titleRow: CARDINAL ~ baseY; titleColumn: CARDINAL ~ (toolWidth - VFonts.StringWidth[title])/2; leftLabelColumn: CARDINAL ~ baseX; varLabel: Rope.ROPE ~ "Variables: "; sizeLabel: Rope.ROPE ~ "Size: "; varViewerWidth: CARDINAL ~ VFonts.StringWidth[" Z "]; widthViewerWidth: CARDINAL ~ VFonts.StringWidth[" 256 "]; xViewerColumn: CARDINAL ~ leftLabelColumn + VFonts.StringWidth[varLabel]; yViewerColumn: CARDINAL ~ xViewerColumn + varViewerWidth; zViewerColumn: CARDINAL ~ yViewerColumn + varViewerWidth; widthViewerColumn: CARDINAL ~ leftLabelColumn + VFonts.StringWidth[varLabel]; byLabelColumn: CARDINAL ~ widthViewerColumn + widthViewerWidth; heightViewerColumn: CARDINAL ~ byLabelColumn + widthViewerWidth + smallHorizontalSpacing; rightLabelColumn: CARDINAL ~ toolWidth/2; rightLabelWidth: CARDINAL ~ VFonts.StringWidth["Filename: "]; rightViewerWidth: CARDINAL ~ (toolWidth/2) - rightLabelWidth; rightViewerColumn: CARDINAL ~ rightLabelColumn + rightLabelWidth + smallHorizontalSpacing; doItWidth: CARDINAL ~ VFonts.StringWidth[" Do It "]; doItColumn: CARDINAL ~ toolWidth - doItWidth - smallHorizontalSpacing; doItRow: CARDINAL ~ titleRow + smallVerticalSpacing; firstRow: CARDINAL ~ titleRow + verticalHeight + smallVerticalSpacing; secondRow: CARDINAL ~ firstRow + verticalHeight + smallVerticalSpacing; bottomRow: CARDINAL ~ secondRow + verticalHeight + smallVerticalSpacing; theBottomLine: Rules.Rule; [] _ BuildLabel [title, surfaceTool.outer, titleColumn, titleRow, TRUE]; [] _ BuildLabel [varLabel, surfaceTool.outer, leftLabelColumn, firstRow, FALSE]; [] _ BuildLabel [sizeLabel, surfaceTool.outer, leftLabelColumn, secondRow, FALSE]; surfaceTool.rayTracerState.variableX _ BuildTextViewer [surfaceTool.outer, xViewerColumn, firstRow, varViewerWidth]; surfaceTool.rayTracerState.variableY _ BuildTextViewer [surfaceTool.outer, yViewerColumn, firstRow, varViewerWidth]; surfaceTool.rayTracerState.variableZ _ BuildTextViewer [surfaceTool.outer, zViewerColumn, firstRow, varViewerWidth]; surfaceTool.rayTracerState.widthInPixels _ BuildTextViewer [surfaceTool.outer, widthViewerColumn, secondRow, widthViewerWidth]; [] _ BuildLabel ["by", surfaceTool.outer, byLabelColumn, secondRow, FALSE]; surfaceTool.rayTracerState.heightInPixels _ BuildTextViewer [surfaceTool.outer, heightViewerColumn, secondRow, widthViewerWidth]; [] _ BuildLabel ["Dir: ", surfaceTool.outer, rightLabelColumn, firstRow, FALSE]; [] _ BuildLabel ["Filename: ", surfaceTool.outer, rightLabelColumn, secondRow, FALSE]; surfaceTool.rayTracerState.dir _ BuildTextViewer [surfaceTool.outer, rightViewerColumn, firstRow, rightViewerWidth]; surfaceTool.rayTracerState.filename _ BuildTextViewer [surfaceTool.outer, rightViewerColumn, secondRow, rightViewerWidth]; [] _ BuildButton [surfaceTool, "Do It", doItColumn, doItRow, BugRayTrace, TRUE, doItWidth]; ViewerTools.SetContents[surfaceTool.rayTracerState.variableX, "x"]; ViewerTools.SetContents[surfaceTool.rayTracerState.variableY, "y"]; ViewerTools.SetContents[surfaceTool.rayTracerState.variableZ, "z"]; ViewerTools.SetContents[surfaceTool.rayTracerState.widthInPixels, "100"]; ViewerTools.SetContents[surfaceTool.rayTracerState.heightInPixels, "100"]; ViewerTools.SetContents[surfaceTool.rayTracerState.dir, UserProfile.Token["AlgebraicSurfaces.ImageDir"]]; theBottomLine _ Rules.Create [[ wx: 0, wy: bottomRow, wh: 1, parent: surfaceTool.outer]]; Containers.ChildXBound[surfaceTool.outer, theBottomLine]; surfaceTool.height _ surfaceTool.height + bottomRow - baseY + 1 + verticalSpacingBelowSubviewer; END; BugRayTrace: Buttons.ButtonProc ~ BEGIN surfaceTool: SurfaceToolRef _ NARROW[clientData]; varXRope: Rope.ROPE _ ViewerTools.GetContents[surfaceTool.rayTracerState.variableX]; varYRope: Rope.ROPE _ ViewerTools.GetContents[surfaceTool.rayTracerState.variableY]; varZRope: Rope.ROPE _ ViewerTools.GetContents[surfaceTool.rayTracerState.variableZ]; widthRope: Rope.ROPE _ ViewerTools.GetContents[surfaceTool.rayTracerState.widthInPixels]; heightRope: Rope.ROPE _ ViewerTools.GetContents[surfaceTool.rayTracerState.heightInPixels]; dir: Rope.ROPE _ ViewerTools.GetContents[surfaceTool.rayTracerState.dir]; filename: Rope.ROPE _ ViewerTools.GetContents[surfaceTool.rayTracerState.filename]; varX, varY, varZ: ATOM; width, height: CARDINAL; trouble: BOOLEAN _ FALSE; IF Rope.Length[varXRope] # 1 OR Rope.Length[varYRope] # 1 OR Rope.Length[varZRope] # 1 THEN trouble _ TRUE; varX _ Convert.AtomFromRope[varXRope ! Convert.Error => {trouble _ TRUE; CONTINUE}]; varY _ Convert.AtomFromRope[varYRope ! Convert.Error => {trouble _ TRUE; CONTINUE}]; varZ _ Convert.AtomFromRope[varZRope ! Convert.Error => {trouble _ TRUE; CONTINUE}]; width _ Convert.IntFromRope[widthRope ! Convert.Error => {trouble _ TRUE; CONTINUE}]; height _ Convert.IntFromRope[heightRope ! Convert.Error => {trouble _ TRUE; CONTINUE}]; IF width < 10 OR width > 255 OR height < 10 OR height > 255 THEN trouble _ TRUE; IF trouble THEN {FlashMessage["Bad parameters; try again."]; RETURN}; SurfaceViewer.InvokeRayTracer [ variables: [varX, varY, varZ], filename: Rope.Concat[dir, filename], pixelsU: height, pixelsV: width, sviewer: surfaceTool.sviewer ]; END; BuildButton: PROC [surfaceTool: SurfaceToolRef, name: Rope.ROPE, column, row: CARDINAL, procedure: Buttons.ButtonProc, border: BOOLEAN, width: CARDINAL _ 0] RETURNS [button: Buttons.Button] ~ BEGIN IF width = 0 THEN button _ Buttons.Create[ info: [ name: name, wx: column, wy: row, wh: verticalHeight, parent: surfaceTool.outer, border: border], proc: procedure, clientData: surfaceTool] ELSE button _ Buttons.Create[ info: [ name: name, wx: column, wy: row, wh: verticalHeight, ww: width, parent: surfaceTool.outer, border: border], proc: procedure, clientData: surfaceTool] END; BuildDataLabel: PROC [parent: Containers.Container, column, row: CARDINAL] RETURNS [label: Labels.Label] ~ BEGIN label _ Labels.Create[[ name: "initializedwithanextremelylongishstring", wx: column, wy: row, wh: verticalHeight, ww: dataViewerWidth, parent: parent, border: FALSE]]; END; BuildLabel: PROC [text: Rope.ROPE, parent: Containers.Container, column, row: CARDINAL, bold: BOOLEAN _ FALSE] RETURNS [label: Labels.Label] ~ BEGIN fontFamily: Rope.ROPE = UserProfile.Token["DFTool.FontFamily", "Tioga"]; fontSize: NAT = UserProfile.Number["DFTool.FontSize", 10]; label _ Labels.Create[ info: [ name: text, wx: column, wy: row, wh: verticalHeight, parent: parent, border: FALSE], font: VFonts.EstablishFont[family: fontFamily, size: fontSize, bold: bold] ]; END; BuildTextViewer: PROC [parent: ViewerClasses.Viewer, column, row: CARDINAL, width: CARDINAL _ fileViewerWidth] RETURNS [ViewerClasses.Viewer] ~ BEGIN RETURN [ViewerTools.MakeNewTextViewer[info: [ parent: parent, wx: column, wy: row, wh: textViewerHeight, ww: width, border: FALSE, scrollable: TRUE]]]; END; RopeFromReal: PROC [from: REAL] RETURNS [result: Rope.ROPE] ~ BEGIN result _ IO.PutFR["%f", IO.real[from]]; END; GetRealSelection: PROC [oldValue: REAL] RETURNS [value: REAL] ~ BEGIN selection: Rope.ROPE _ ViewerTools.GetSelectionContents[]; valid: BOOLEAN _ TRUE; selectedValue: REAL; selectedValue _ Convert.RealFromRope[selection ! Convert.Error => {valid _ FALSE; CONTINUE}; ]; IF valid THEN value _ selectedValue ELSE value _ oldValue; END; LockButtons: PROC [surfaceTool: SurfaceToolRef] ~ BEGIN surfaceTool.buttonsLocked _ TRUE; END; UnlockButtons: PROC [surfaceTool: SurfaceToolRef] ~ BEGIN surfaceTool.buttonsLocked _ FALSE; END; FlashMessage: PROC [message: Rope.ROPE] ~ BEGIN MessageWindow.Append[message, TRUE]; MessageWindow.Blink[]; END; OpenViewers: Commander.CommandProc ~ BEGIN sviewer: REF SurfaceViewer.SurfaceViewer _ SurfaceViewer.CreateSurfaceViewer[]; MakeSurfaceTool[sviewer]; END; Commander.Register[key: "ASViewers", proc: OpenViewers]; END. SurfaceToolImpl.mesa James Rauen, July 3, 1986 10:27:31 pm PDT July 14, 1986 5:20:47 pm PDT Last edited by: James Rauen January 20, 1988 8:13:58 pm PST SurfaceIcons USING [SurfaceToolIcon], Type declarations Declarations Build the top menu Menus.SetGuarded [openEntry, TRUE]; Create the tool icon: SurfaceIcons.SurfaceToolIcon[], Add the subviewers Add edges on the left and right -- so the viewer looks nice when turned into an IP file. [] _ Rules.Create [[wx: 0, wy: 0, ww: 1, wh: surfaceTool.height, parent: surfaceTool.outer]]; [] _ Rules.Create [[wx: (toolWidth - 1), wy: 0, ww: 1, wh: surfaceTool.height, parent: surfaceTool.outer]]; Open it ViewerOps.PaintViewer[surfaceTool.outer, all]; SurfaceTool button procedures Updates everything in the SurfaceViewer context, then draws a frame. Window formatting constants Conversion subviewer Formatting constants. Declare the rules and buttons that will be built. Build the title. Build the labels. Build the buttons. Build the text viewers. Fill in their defaults from the user profile. Draw the bottom line and constrain it to be the width of the tool. Extend the tool's height. Conversion subviewer button procedures Position/Orientation subviewer Position State Orientation State Formatting constants. Declare the rules that will be built. Build the title label. [] _ BuildLabel [title, surfaceTool.outer, titleColumn, topRow, TRUE]; Build the position buttons and labels. Build the Turn, Roll, and Dive labels and buttons. Build the angular increment button and label. Build the orientation vector labels and buttons. Build the Fancy Maneuvers button. Fill in the numbers. Draw the vertical rule. Draw the horizontal lines and constrain them to be the width of the tool. Draw the lower-right-hand-corner rules. Extend the tool's height. Update the position labels. Update the orientation labels. Rotation axis is side-to-side, perpendicular to both the forward and the up vectors. Rotation axis is side-to-side, perpendicular to both the forward and the up vectors. Active surfaces subviewer Formatting constants. Declare the rules that will be built. Instantiate the activeState. Build the title. Build the letter buttons. Build the name/equation viewers. Build the visible labels. Build some buttons. Build the directory and file buttons. Build the directory and file viewers. Build the load and store buttons. Build the cell operation labels and buttons. Draw the horizontal lines and constrain them to be the width of the tool. Extend the tool's height. Get the id of the selected surface Get a color Declarations Get a handle on the surface tool. Decide which slot to use. Read in the info file. Add it to the surface viewer context. Add it to the surface tool's active state. selection _ PopUpMenu.RequestSelection[ label: "Options for Reveal", choice: LIST [ "Reveal all cells", "Reveal all 0-cells", "Reveal all 1-cells", "Reveal all 2-cells" ] ]; Ray tracer subviewer Formatting constants Declare the rules and buttons that will be built. Build the title. Build the left-hand labels and viewers. Build the right-hand labels and viewers. Build the Do It button. Fill in the defaults. Draw the bottom line and constrain it to be the width of the tool. Extend the tool's height. Get the contents of the various viewers. Convert them from ropes, flagging trouble if there is any. Generate the image. Useful constructors. Builds a button which, when bugged, calls procedure. The button is labeled with name. If border is TRUE, the button has a border. If width is defaulted, the button's width will be sized to fit it. Builds a label which will be used to display a real number. Initially, the label contains the string "initialized". Build a label which will be used to display text. ww: dataViewerWidth, Private conversion of real numbers into displayable ropes.. Converts whatever is selected into a real number. If converting the selection to a real causes an error, an error message is flashed in the message window and oldValue is returned. Other internal procedures. Define a CommandTool procedure. Κ+Π˜code™K™)K™K™;—K˜šΟk ˜ Kšœœ/˜Kšœ<˜˜>Kšœ˜K˜—š  œ˜%Kšœœ ˜1Kšœ=˜=Kšœ˜K˜—š  œ˜&Kšœœ ˜1Kšœ>˜>Kšœ˜K˜—š  œ˜'Kšœœ ˜1Kšœ?˜?Kšœ˜——˜š  œ˜&Kšœœ ˜1KšœœB˜VKšœœ@˜RKšœ œ?˜PKšœœ@˜RKšœœA˜TKšœœ#˜7Kšœœ"˜5Kšœ œ"˜1Kšœœ&˜@Kšœ˜Kšœ˜K˜———K™šŸ™K™šœœœ˜,™Kšœ1˜1Kšœ œ˜Kšœœ˜Kšœœ˜Kšœœ˜Kšœœ˜#—™Kšœ-˜-Kšœ(˜(Kšœœ˜Kšœœ˜"Kšœœ˜"Kšœœ˜"Kšœœ˜Kšœœ˜Kšœ˜Kšœ&œ˜+—K˜—š œœ!˜BK˜™Kšœ˜Kšœœ6˜EKšœœ ˜KšœœΟc˜GKšœœ!˜7Kšœœ8˜OKšœœ9˜OKšœ œ8˜KKšœ œ5˜HK˜Kšœ œ ˜Kšœœ˜7Kšœœ ˜9Kšœ œ9˜NKšœœ˜8Kšœœ ˜9Kšœ œ:˜MKšœœ!˜9Kšœœ7˜OKšœœ˜6Kšœœ;˜UKšœœ?˜XKšœœ,˜EKšœœ!˜9Kšœœ=˜WKšœœ ˜9Kšœœ?˜ZKšœœ ˜:KšœœA˜aKšœœ˜>KšœœK˜gKšœœA˜]KšœœA˜]K˜Kšœœ˜&Kšœœ;˜XKšœœ˜,KšœœJ˜jK˜—™%K˜+K˜—™Kšœ@œ™FKšœPœ˜VKšœVœ˜\K™—™&KšœIœ˜`KšœJœ˜aKšœIœ˜`KšœJœ˜aKšœKœ˜cKšœLœ˜dKšœKœ˜cKšœLœ˜cKšœJœ˜`KšœKœ˜aKšœJœ˜`KšœJœ˜`KšœI˜IKšœJ˜JKšœI˜IKšœH˜HKšœx˜xKšœy˜yKšœx˜xKšœy˜yK˜—™2Kšœ€œ˜ˆKšœTœ˜kKšœVœ˜nKšœœ˜‰KšœTœ˜kKšœWœ˜oKšœ€œ˜ˆKšœNœ˜TKšœPœ˜hK˜—™-KšœJ˜JKšœ€˜€KšœYœ˜qK™—™0Kšœ‡œ˜Kšœ‡œ˜Kšœ|˜|Kšœ|˜|Kšœ|˜|Kšœx˜xKšœx˜xKšœx˜xK™—™!KšœZœ˜`K™—™Kšœ.˜.K™—™K˜pK˜—™KK˜NK˜NK˜QK˜2K˜2K˜2K˜—™'Kšœƒ˜ƒKšœi˜iKšœ2˜2K˜—™Kšœ`˜`K™—Kšœ˜K˜—š  œœ ˜K™K˜K˜K˜Kšœ„˜„—™K˜ƒK˜ƒK˜ƒK˜yK˜yK˜yKšœ©˜©—Kšœ˜K˜—K˜š œ˜$Kšœœ ˜1K˜œKšœ.˜.Kšœ˜K˜—š œ˜$Kšœœ ˜1K˜œKšœ.˜.Kšœ˜K˜—š œ˜$Kšœœ ˜1K˜œKšœ.˜.Kšœ˜K˜—š  œ˜%Kšœœ ˜1K˜œKšœ.˜.Kšœ˜K˜—š  œ˜%Kšœœ ˜1K˜œKšœ.˜.Kšœ˜K˜—š  œ˜%Kšœœ ˜1K˜œKšœ.˜.Kšœ˜K˜—š œ˜#Kšœœ ˜1KšœœH˜SKšœ;˜;Kšœ.˜.Kšœ˜K˜—š œ˜#Kšœœ ˜1KšœœH˜SKšœ;˜;Kšœ.˜.Kšœ˜K˜—š œ˜#Kšœœ ˜1KšœœH˜SKšœ;˜;Kšœ.˜.Kšœ˜K˜—š  œ˜&Kšœœ ˜1KšœœG˜RKšœ:˜:Kšœ.˜.Kšœ˜K˜—š  œ˜'Kšœœ ˜1KšœK˜KKšœ˜KšœV˜VKšœ]˜]K˜=Kšœ.˜.Kšœ˜K˜—š  œ˜(Kšœœ ˜1KšœK˜KKšœŠ˜ŠKšœV˜VKšœ]˜]K˜=Kšœ.˜.Kšœ˜K˜—š  œ˜'Kšœœ ˜1KšœP˜PKšœŠ˜ŠKšœL˜LKšœS˜SK˜3Kšœ.˜.Kšœ˜K˜—š  œ˜(Kšœœ ˜1KšœP˜PKšœ˜KšœL˜LKšœS˜SK˜3Kšœ.˜.Kšœ˜K˜—š œ˜$Kšœœ ˜1K™TKšœ”˜”Kšœ˜KšœL˜LKšœV˜VKšœS˜SKšœ]˜]K˜3K˜=Kšœ.˜.Kšœ˜K˜—š œ˜#Kšœœ ˜1K™TKšœ”˜”KšœŠ˜ŠKšœL˜LKšœV˜VKšœS˜SKšœ]˜]K˜3K˜=Kšœ.˜.Kšœ˜K˜—š œ˜-Kšœœ ˜1KšœœN˜YKšœA˜AKšœ.˜.Kšœ˜K˜—š  œ˜&Kšœœ ˜1Kšœ‘˜‘Kšœˆ˜ˆKšœ.˜.Kšœ˜K˜—š  œ˜'Kšœœ ˜1Kšœ‘˜‘Kšœˆ˜ˆKšœ.˜.Kšœ˜K˜—š œ˜$Kšœœ ˜1š œ œœœœ˜"K˜K˜K˜K˜#K˜#K˜#K˜#K˜#K˜#K˜K˜K˜K˜%K˜%K˜%K˜%K˜%K˜%K˜%K˜%K˜—šœ œ˜(Kšœ˜K˜—šœ ˜Kšœœ’ ˜Kšœœ’˜šœ’˜Kšœ|˜|—šœ’œ’ ˜Kšœ=˜=Kšœ˜—šœ’˜Kšœn˜nKšœV˜VKšœW˜WKšœ˜—šœ’"˜)Kšœ>˜>Kšœ=˜=Kšœ7˜7K˜—šœ’"˜)Kšœ>˜>Kšœ=˜=Kšœ7˜7K˜—šœ’"˜)Kšœ>˜>Kšœ=˜=Kšœ7˜7K˜—šœ’"˜)Kšœ?˜?Kšœ<˜˜>KšœZ˜ZKšœ7˜7K˜—˜Kšœ>˜>KšœZ˜ZKšœ7˜7K˜—˜Kšœ?˜?KšœY˜YKšœ7˜7K˜—˜Kšœ>˜>KšœZ˜ZKšœ7˜7K˜—˜Kšœ?˜?KšœY˜YKšœ7˜7K˜—˜Kšœ?˜?KšœY˜YKšœ7˜7K˜—˜Kšœ@˜@KšœX˜XKšœ7˜7K˜—Kšœœ˜—Kšœ.˜.Kšœ˜K˜—˜K˜—K˜—J™šŸ™K™šœ œœ˜Kšœ œ˜$Kšœœ’ ˜#Kšœœ˜ Kšœ!˜$K˜K˜—šœœœ˜!Kšœœ˜Kšœœ˜#Kšœœ˜!Kšœ œ˜Kšœ œœ˜Kšœ˜Kšœœ˜Kšœ œ˜K˜K˜—šœœœ˜&Kšœœ œœ˜=K˜—š œœ!˜@K˜™Kšœœ˜Kšœœ6˜EKšœœ ˜Kšœœ˜+Kšœœ˜Kšœœ ˜Kšœœ˜+Kšœœ˜(Kšœœ3˜NKšœœ˜,Kšœœ˜>KšœœI˜cKšœœ$˜CKšœœE˜bKšœœ˜'KšœœJ˜kKšœœ%˜EKšœœM˜oKšœœ+˜LKšœœ˜-Kšœœ˜)Kšœœ&˜AKšœœ'˜FKšœœ-˜MKšœœ.˜MKšœœ-˜MKšœœ.˜MKšœœ(˜DKšœœE˜cKšœœ˜.KšœœG˜eKšœœ!˜>Kšœ œ:˜NKšœ œ6˜JKšœ œ6˜JKšœœ:˜PKšœœ8˜OKšœ œ=˜NKšœ œ3˜FK˜—™%K˜#K˜—™Kšœ#œ˜A—K˜™KšœTœ˜ZK˜—™Kšœrœ˜‘Kšœrœ˜‘Kšœrœ˜‘K˜—™ Kšœ†˜†Kšœ†˜†Kšœ†˜†K˜—™Kšœxœ˜Kšœxœ˜Kšœxœ˜K˜—™KšœYœ˜wKšœYœ˜wKšœ^œ˜|Kšœ^œ˜}Kšœaœ˜€Kšœjœ˜‰K˜—™%KšœZœ˜tKšœZœ˜tK™—™%Kšœ{˜{šœ˜Kšœg˜g—K˜—™!Kšœ[œ˜vKšœWœ˜rK˜—™,KšœKœ˜QKšœWœ˜]KšœXœ˜^Kšœ[œ˜aKšœ\œ˜bKšœWœ˜]K˜—™JK˜NK˜NK˜QK˜2K˜2K˜2K˜—™Kšœ`˜`—K˜šœ˜K˜——š œ˜ Kšœœ ˜1šœ.œ˜:Kšœ,˜,KšœE˜EK˜"Kšœ˜—Kšœ˜K˜—š œ˜ Kšœœ ˜1šœ.œ˜:Kšœ,˜,KšœE˜EK˜"Kšœ˜—Kšœ˜K˜—š œ˜ Kšœœ ˜1šœ.œ˜:Kšœ,˜,KšœE˜EK˜"Kšœ˜—Kšœ˜K˜—š œœ!˜@Kš œœœ˜(KšœT˜TKšœT˜TKšœT˜Tšœ)˜3KšœY˜YKšœY˜YKšœY˜YKšœœ˜+—Kšœ˜K˜—š œœ!˜Ašœœœ˜šœ.œ˜:Kšœ’˜’šœ ˜ Kšœ1˜1Kšœ/œœ˜D—Kš˜—šœ˜ KšœH˜HKšœB˜BKšœ˜—Kšœ˜—Kšœ˜K˜K˜—š  œ˜%Kšœœ ˜1Kšœ˜K˜—š  œ˜%Kšœœ ˜1Kšœœ+˜?šœ<œ˜HKšœn˜nKšœ=œ˜CKšœ#˜#Kšœ˜—Kšœ˜K˜—š  œ˜'Kšœœ ˜1Kšœœ˜Kšœœ˜™"š˜Kšœœ+˜?šœ>œœ˜PKšœ$˜$Kšœ˜Kšœ˜—KšœA˜A—Kšœ˜—™ š˜Kšœœ&˜:Kšœ œœ˜šœœ?˜UKšœœ=œœ˜kKšœœ<œœ˜eKšœ˜—Kšœ œœ˜—Kšœ˜—Kšœ>˜>Kšœ˜K˜—š œ˜#Kšœœ ˜1Kšœ˜K˜—š œ˜#Kšœœ ˜1Kšœœ+˜?šœ<œ˜Hšœ=œ˜IKšœm˜mKšœ>œ˜DKš˜—šœ˜ Kšœo˜oKšœ>œ˜CKšœ˜—Kšœ#˜#Jšœ˜Kšœ˜—Kšœ˜K˜—š œ˜,Kšœ œ˜Kšœœ˜Kšœœ ˜1Kš œ œœœœQ˜rKšœœ+˜?šœ>œœ˜PKšœ$˜$Kšœ˜Kšœ˜—KšœA˜Ašœ#˜#Kšœ"˜"K˜—šœ ˜Kšœœ’ ˜Kšœœ’˜KšœL˜LKšœN˜NKšœM˜MKšœR˜RKšœT˜TKšœR˜RKšœœ˜—Kšœ˜K˜—š œ˜"Kšœœ ˜1Kšœ6˜6Kšœ˜K˜—š œ˜#Kšœœ ˜1Kšœ;˜;Kšœ˜K˜—š œ˜*K˜™ Kšœœ˜K˜Kšœœ˜Kšœœ˜ Kšœœœ˜K˜—™!Kšœœ ˜1K˜—™Kšœ0œœ ˜EKšœœ0œœ ˜JKšœœ0œœ ˜JKšœ,œ˜8K˜—™Kšœ;˜;KšœA˜Ašœœ$˜0Kšœœ8œœ˜NK˜—šœœœ˜K˜——™%šœ8˜8KšœOœœ˜^K˜—šœœœ˜K˜——™*Kšœ6˜6Kšœ2œ˜7Kšœ2˜2Kšœ3œ˜8Kšœ.œ*˜[šœœœ˜'Kšœ1œ˜6Kšœ˜—Kšœ/˜/K˜"J˜#K˜—Kšœ˜K˜—š œ˜$Kšœœ ˜1Kšœ˜K˜—š  œ˜&Kšœœ ˜1Kšœl˜lšœœœ˜,K˜$Kšœ˜Kšœ˜—šœœœ ˜/Kšœœ˜Kšœ˜—Kšœ\˜\Kšœ˜K˜—š  œ˜&Kšœœ ˜1Kšœl˜lKšœ œ˜šœœœ˜,K˜$Kšœ˜Kšœ˜—šœ œ ˜Kšœ˜Kšœ˜K˜—šœœ˜Kšœ œ˜&Kšœ\˜\Kšœ˜—Kšœ˜K˜—š  œ˜(Kšœœ ˜1Kšœl˜lKšœ œ˜šœœœ˜,K˜$Kšœ˜Kšœ˜—K˜šœ'™'K™šœœ™K™K™K™K™K™—K™—šœœœ ˜/šœ ˜Kšœœ˜"Kšœœ*œœ˜SKšœœ*œœ˜SKšœœ*œœ˜SKšœ˜—Kšœ˜—Kšœ\˜\Kšœ˜K˜—š  œ˜(Kšœœ ˜1Kšœl˜lKšœ œ˜šœœœ˜,K˜$Kšœ˜Kšœ˜—šœ œ ˜Kšœ˜Kšœ˜K˜—šœœ˜Kšœ œ˜%Kšœ˜—Kšœ\˜\Kšœ˜K˜—š  œ˜&Kšœœ ˜1Kšœœ+˜4šœ3œœ˜EK˜$Kšœ˜Kšœ˜—šœœ ˜Kšœ+˜+Kšœ,˜,K˜ —Kšœ˜K˜——K˜šŸ™J™˜J˜&J˜&J˜&J˜*J˜+J˜ J˜$J˜J˜—š œœ!˜CJ˜™Kšœœ˜Kšœœ6˜EKšœ œ˜ Kšœ œ ˜Kšœ œ-˜BKšœœ ˜"Kšœœ˜$Kšœœ ˜ Kšœœ!˜9Kšœœ#˜=Kšœœ2˜IKšœœ"˜9Kšœœ"˜9Kšœœ2˜MKšœœ(˜?Kšœœ=˜YKšœœ˜)Kšœœ$˜=Kšœœ#˜=Kšœœ?˜ZKšœ œ!˜4Kšœ œ2˜FKšœ œ#˜4Kšœ œ4˜FKšœ œ4˜GKšœ œ5˜HJ™—™1K˜K˜—™KšœBœ˜HK˜—™'KšœIœ˜PKšœKœ˜RKšœt˜tKšœt˜tKšœt˜tKšœ˜KšœDœ˜KKšœ˜K˜—™(KšœIœ˜PKšœOœ˜VKšœt˜tKšœz˜zK˜—™KšœJœ ˜[K˜—™KšœC˜CKšœC˜CKšœC˜CKšœI˜IKšœJ˜JKšœi˜iK˜—™D˜K˜K˜K˜K˜—K˜9K˜—™Kšœ`˜`—K˜Kšœ˜K˜—š  œ˜'Kšœœ ˜1K˜K˜™(KšœœA˜TKšœœA˜TKšœœA˜TKšœœE˜YKšœœF˜[Kšœ œ;˜IKšœœ@˜SK˜—™:Kšœœ˜Kšœœ˜Kšœ œœ˜Kš œœœœ œ˜kšœ$˜$Kšœœœ˜/—šœ$˜$Kšœœœ˜/—šœ$˜$Kšœœœ˜/—šœ%˜%Kšœœœ˜/—šœ(˜(Kšœœœ˜/—Kš œ œ œ œœ œ˜PKšœ œ.œ˜EK˜—™˜Kšœ˜K˜%K˜K˜K˜K˜—K˜—Kšœ˜K˜J™——J™šŸ™K™š  œœ*œœ)œ œœ˜ΕKšœΗ™Ηšœ ˜˜šœ˜Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ˜—K˜K˜——š˜˜šœ˜Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ˜—K˜K˜——Kšœ˜K˜—š  œœ-œœ˜pK™t˜K˜0K˜ K˜K˜K˜K˜Kšœœ˜—Kšœ˜K˜—š  œœ œ-œœœœ˜”K˜K™1Kšœœ3˜HKšœ œ-˜:˜˜K˜ K˜ K˜K˜K™K˜Kšœœ˜—K˜M—Kšœ˜K˜—š  œœ-œ œœ˜•šœ'˜-K˜K˜ K˜Kšœ˜Kšœ ˜ Kšœœ˜Kšœ œ˜—šœ˜K˜—K™—š   œœœœœ˜CK˜Kšœ;™;Kšœ œ œ ˜'Kšœ˜K˜—š  œœ œœ œ˜EK˜K™΅Kšœœ&˜:Kšœœœ˜Kšœœ˜šœ.˜.Kšœœœ˜-Kšœ˜—Kšœœœ˜:Kšœ˜K˜——J™šŸ™J™š  œœ!˜7Jšœœ˜!Jšœ˜J˜—š  œœ!˜9Jšœœ˜"Jšœ˜J˜—š  œœœ˜/Jšœœ˜$J˜Jšœ˜——K˜K˜KšŸ™˜š  œ˜*Kšœ œC˜OK˜Kšœ˜K˜—Kšœ8˜8K˜—K˜K˜—Kšœ˜—…—ζ^"<