BuildPositionSubviewer:
PROC [surfaceTool: SurfaceToolRef] ~
BEGIN
Formatting constants.
baseX: CARDINAL ~ 20;
baseY: CARDINAL ~ surfaceTool.height;
locationBlockX: CARDINAL ~ 20;
locationBlockY: CARDINAL ~ baseY;
locationTitleRow: CARDINAL ~ locationBlockY;
locationLongRuleRow: CARDINAL ~ locationSubtitleRow;
locationSubtitleRow: CARDINAL ~ locationTitleRow + verticalHeight + smallVerticalSpacing;
firstDataRow: CARDINAL ~ locationSubtitleRow + verticalHeight + smallVerticalSpacing;
secondDataRow: CARDINAL ~ firstDataRow + verticalHeight + smallVerticalSpacing;
thirdDataRow: CARDINAL ~ secondDataRow + verticalHeight + smallVerticalSpacing;
fourthRow: CARDINAL ~ thirdDataRow + verticalHeight + smallVerticalSpacing;
bottomRow: CARDINAL ~ fourthRow + verticalHeight + smallVerticalSpacing;
positionBlockX: CARDINAL ~ locationBlockX;
positionBlockY: CARDINAL ~ locationBlockY;
positionTitle: Rope.ROPE ~ "Position";
positionTitleRow: CARDINAL ~ locationTitleRow;
positionTitleColumn: CARDINAL ~ (positionEndColumn + positionBlockX - VFonts.StringWidth[positionTitle])/2;
positionPlusColumn: CARDINAL ~ positionBlockX;
positionMinusColumn: CARDINAL ~ positionBlockX + smallButtonWidth + smallHorizontalSpacing;
positionNewColumn: CARDINAL ~ positionMinusColumn + smallButtonWidth + smallHorizontalSpacing;
positionDataColumn: CARDINAL ~ positionNewColumn + dataButtonWidth;
positionEndColumn: CARDINAL ~ positionDataColumn + dataViewerWidth;
orientationBlockX: CARDINAL ~ positionEndColumn + smallHorizontalSpacing;
orientationBlockY: CARDINAL ~ locationBlockY;
orientationTitle: Rope.ROPE ~ "Orientation";
orientationTitleRow: CARDINAL ~ locationTitleRow;
orientationTitleColumn: CARDINAL ~ (orientationEndColumn + orientationBlockX - VFonts.StringWidth[orientationTitle])/2;
orientationLabelsColumn: CARDINAL ~ orientationBlockX;
orientationLeftColumn: CARDINAL ~ orientationLabelsColumn + 40;
orientationRightColumn: CARDINAL ~ orientationLeftColumn + 40;
orientationEndOfLabelsColumn: CARDINAL ~ orientationRightColumn + 40 + largeHorizontalSpacing;
orientationForwardTitle: Rope.ROPE ~ "Forward vector";
orientationForwardButtonColumn: CARDINAL ~ orientationEndOfLabelsColumn + largeHorizontalSpacing;
orientationForwardVectorColumn: CARDINAL ~ orientationForwardButtonColumn + smallButtonWidth + smallHorizontalSpacing;
orientationEndOfForwardColumn: CARDINAL ~ orientationForwardVectorColumn + dataViewerWidth + largeHorizontalSpacing;
orientationForwardTitleColumn: CARDINAL ~ (orientationEndOfForwardColumn + orientationEndOfLabelsColumn - VFonts.StringWidth[orientationForwardTitle])/2;
orientationUpTitle: Rope.ROPE ~ "Up vector";
orientationUpButtonColumn: CARDINAL ~ orientationEndOfForwardColumn + largeHorizontalSpacing;
orientationUpVectorColumn: CARDINAL ~ orientationUpButtonColumn + smallButtonWidth + smallHorizontalSpacing;
orientationEndOfUpColumn: CARDINAL ~ orientationUpVectorColumn + dataViewerWidth + largeHorizontalSpacing;
orientationUpTitleColumn: CARDINAL ~ (orientationEndOfUpColumn + orientationEndOfForwardColumn - VFonts.StringWidth[orientationUpTitle])/2;
orientationEndColumn: CARDINAL ~ orientationEndOfUpColumn;
orientationVectorTitleRow: CARDINAL ~ locationSubtitleRow;
bottomButtonWidth: CARDINAL ~ VFonts.StringWidth[" Backward "];
firstBottomButtonColumn: CARDINAL ~ locationBlockX;
secondBottomButtonColumn: CARDINAL ~ firstBottomButtonColumn + bottomButtonWidth;
thirdBottomButtonColumn: CARDINAL ~ secondBottomButtonColumn + bottomButtonWidth;
Declare the rules and buttons that will be built.
breakLine, horizontalLine, theBottomLine: Rules.Rule;
Orientation subtitles
forwardVectorTitle: Rope.ROPE ~ "Forward vector";
upVectorTitle: Rope.ROPE ~ "Up vector";
Build the position title.
[] ← BuildLabel [positionTitle, surfaceTool.outer, positionTitleColumn, positionTitleRow, TRUE];
Build the position buttons and labels.
[] ← BuildButton [surfaceTool, "+X", positionPlusColumn, firstDataRow, BugPlusX, TRUE, smallButtonWidth];
[] ← BuildButton [surfaceTool, "+Y", positionPlusColumn, secondDataRow, BugPlusY, TRUE, smallButtonWidth];
[] ← BuildButton [surfaceTool, "+Z", positionPlusColumn, thirdDataRow, BugPlusZ, TRUE, smallButtonWidth];
[] ← BuildButton [surfaceTool, "-X", positionMinusColumn, firstDataRow, BugMinusX, TRUE, smallButtonWidth];
[] ← BuildButton [surfaceTool, "-Y", positionMinusColumn, secondDataRow, BugMinusY, TRUE, smallButtonWidth];
[] ← BuildButton [surfaceTool, "-Z", positionMinusColumn, thirdDataRow, BugMinusZ, TRUE, smallButtonWidth];
[] ← BuildButton [surfaceTool, "x = ", positionNewColumn, firstDataRow, BugNewX, FALSE, smallButtonWidth];
[] ← BuildButton [surfaceTool, "y = ", positionNewColumn, secondDataRow, BugNewY, FALSE, smallButtonWidth];
[] ← BuildButton [surfaceTool, "z = ", positionNewColumn, thirdDataRow, BugNewZ, FALSE, smallButtonWidth];
surfaceTool.positionState.xDataLabel ←
BuildDataLabel [surfaceTool.outer, positionDataColumn, firstDataRow];
surfaceTool.positionState.yDataLabel ←
BuildDataLabel [surfaceTool.outer, positionDataColumn, secondDataRow];
surfaceTool.positionState.zDataLabel ←
BuildDataLabel [surfaceTool.outer, positionDataColumn, thirdDataRow];
Fill in the numbers.
UpdatePositionData[surfaceTool];
Build the orientation title.
[] ← BuildLabel [orientationTitle, surfaceTool.outer, orientationTitleColumn, orientationTitleRow, TRUE];
Build the Turn, Roll, and Dive labels and buttons.
[] ← Labels.Create[[name: "Turn", wx: orientationLabelsColumn, wy: firstDataRow, wh: verticalHeight, parent: surfaceTool.outer, border: FALSE]];
[] ← BuildButton[surfaceTool, "Left", orientationLeftColumn, firstDataRow, BugTurnLeft, TRUE];
[] ← BuildButton[surfaceTool, "Right", orientationRightColumn, firstDataRow, BugTurnRight, TRUE];
[] ← Labels.Create[[name: "Roll", wx: orientationLabelsColumn, wy: secondDataRow, wh: verticalHeight, parent: surfaceTool.outer, border: FALSE]];
[] ← BuildButton[surfaceTool, "Left", orientationLeftColumn, secondDataRow, BugRollLeft, TRUE];
[] ← BuildButton[surfaceTool, "Right", orientationRightColumn, secondDataRow, BugRollRight, TRUE];
[] ← Labels.Create[[name: "Dive", wx: orientationLabelsColumn, wy: thirdDataRow, wh: verticalHeight, parent: surfaceTool.outer, border: FALSE]];
[] ← BuildButton[surfaceTool, "Up", orientationLeftColumn, thirdDataRow, BugClimb, TRUE];
[] ← BuildButton[surfaceTool, "Down", orientationRightColumn, thirdDataRow, BugDive, TRUE];
Build the forward orientation vector labels and buttons.
[] ← BuildLabel[orientationForwardTitle, surfaceTool.outer, orientationForwardTitleColumn, orientationVectorTitleRow];
[] ← BuildButton[surfaceTool, "x = ", orientationForwardButtonColumn, firstDataRow, BugForwardX, FALSE, smallButtonWidth];
[] ← BuildButton[surfaceTool, "y = ", orientationForwardButtonColumn, secondDataRow, BugForwardY, FALSE, smallButtonWidth];
[] ← BuildButton[surfaceTool, "z = ", orientationForwardButtonColumn, thirdDataRow, BugForwardZ, FALSE, smallButtonWidth];
surfaceTool.orientationState.forwardXLabel ←
BuildDataLabel[surfaceTool.outer, orientationForwardVectorColumn, firstDataRow];
surfaceTool.orientationState.forwardYLabel ←
BuildDataLabel[surfaceTool.outer, orientationForwardVectorColumn, secondDataRow];
surfaceTool.orientationState.forwardZLabel ←
BuildDataLabel[surfaceTool.outer, orientationForwardVectorColumn, thirdDataRow];
Build the up orientation vector labels and buttons.
[] ← BuildLabel[orientationUpTitle, surfaceTool.outer, orientationUpTitleColumn, orientationVectorTitleRow];
[] ← BuildButton[surfaceTool, "x = ", orientationUpButtonColumn, firstDataRow, BugUpX, FALSE, smallButtonWidth];
[] ← BuildButton[surfaceTool, "y = ", orientationUpButtonColumn, secondDataRow, BugUpY, FALSE, smallButtonWidth];
[] ← BuildButton[surfaceTool, "z = ", orientationUpButtonColumn, thirdDataRow, BugUpZ, FALSE, smallButtonWidth];
surfaceTool.orientationState.upXLabel ←
BuildDataLabel[surfaceTool.outer, orientationUpVectorColumn, firstDataRow];
surfaceTool.orientationState.upYLabel ←
BuildDataLabel[surfaceTool.outer, orientationUpVectorColumn, secondDataRow];
surfaceTool.orientationState.upZLabel ←
BuildDataLabel[surfaceTool.outer, orientationUpVectorColumn, thirdDataRow];
Build the bottom row of buttons.
[] ← BuildButton[surfaceTool, "Forward", firstBottomButtonColumn, fourthRow, BugForward, TRUE];
[] ← BuildButton[surfaceTool, "Backward", secondBottomButtonColumn, fourthRow, BugBackward, TRUE];
[] ← BuildButton[surfaceTool, "Fancy maneuvers", thirdBottomButtonColumn, fourthRow, BugFancy, TRUE];
Fill in the numbers.
UpdateOrientationData[surfaceTool];
Draw the lines between the different orientation areas.
breakLine ← Rules.Create [[
wx: orientationEndOfLabelsColumn,
wy: orientationVectorTitleRow,
ww: 1,
wh: bottomRow - orientationVectorTitleRow,
parent: surfaceTool.outer]];
breakLine ← Rules.Create [[
wx: orientationEndOfForwardColumn,
wy: orientationVectorTitleRow,
ww: 1,
wh: bottomRow - orientationVectorTitleRow,
parent: surfaceTool.outer]];
Draw the horizontal lines and constrain them to be the width of the tool.
horizontalLine ← Rules.Create [[
wx: 0,
wy: orientationVectorTitleRow,
wh: 1,
parent: surfaceTool.outer]];
Containers.ChildXBound[surfaceTool.outer, horizontalLine];
Draw the bottom line and constrain it to be the width of the tool.
theBottomLine ← Rules.Create [[
wx: 0,
wy: bottomRow,
wh: 1,
parent: surfaceTool.outer]];
Containers.ChildXBound[surfaceTool.outer, theBottomLine];
Extend the tool's height.
surfaceTool.height ← surfaceTool.height + bottomRow - baseY;
END;