BuildPositionSubviewer:
PROC [surfaceTool: SurfaceToolRef] ~
BEGIN
Formatting constants.
baseX: CARDINAL ~ 20;
baseY: CARDINAL ~ surfaceTool.height + verticalSpacingBetweenSubviewers;
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;
Declare the rules that will be built.
hrule1, hrule2, hrule3, hrule4: Rules.Rule;
Build the title label.
[] ← BuildLabel [title, surfaceTool.outer, titleColumn, topRow, TRUE];
[] ← BuildLabel [positionTitle, surfaceTool.outer, positionTitleColumn, topRow, TRUE];
[] ← BuildLabel [orientationTitle, surfaceTool.outer, orientationTitleColumn, topRow, TRUE];
Build the position buttons and labels.
[] ← 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];
Build the Turn, Roll, and Dive labels and buttons.
[] ← 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];
Build the angular increment button and label.
[] ← BuildLabel ["Angle:", surfaceTool.outer, rotateOpsColumn, fourthRow];
surfaceTool.positionAndOrientationState.angularIncrementLabel ←
BuildDataLabel [surfaceTool.outer, rotateLeftColumn, fourthRow];
[] ← BuildButton [surfaceTool, "Set A", rotateRightColumn, fourthRow, BugSetAngularStep, TRUE, rotateRightWidth];
Build the orientation vector labels and buttons.
[] ← 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];
Build the Fancy Maneuvers button.
[] ← BuildButton[surfaceTool, "Fancy maneuvers", orientationXColumn, fourthRow, BugFancy, TRUE];
Fill in the numbers.
UpdatePositionAndOrientationData[surfaceTool];
Draw the vertical rule.
[] ← Rules.Create [[wx: breakLineColumn, wy: subRow, ww: 1, wh: bottomRow - subRow, parent: surfaceTool.outer]];
Draw the horizontal lines and constrain them to be the width of the tool.
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];
Draw the lower-right-hand-corner rules.
[] ← 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];
Extend the tool's height.
surfaceTool.height ← surfaceTool.height + bottomRow - baseY;
END;