Commit 94af7c06 authored by legoc's avatar legoc

Added TranslationDirection to Axis

parent f104ee4d
......@@ -580,6 +580,36 @@ public class EditorMenuBar extends MenuBar {
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Translation direction
ObservableList<Axis.TranslationDirection> translationDirections = FXCollections.observableArrayList(Axis.TranslationDirection.FW, Axis.TranslationDirection.BW);
ComboBox<Axis.TranslationDirection> translationDirectionBox = new ComboBox<>(translationDirections);
translationDirectionBox.setVisible(editedAxis.getType() == Axis.Type.TRANSLATION);
translationDirectionBox.getSelectionModel().select(editedAxis.getTranslationDirection());
translationDirectionBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Axis.TranslationDirection>() {
@Override
public void changed(ObservableValue<? extends Axis.TranslationDirection> observable, Axis.TranslationDirection oldValue, Axis.TranslationDirection newValue) {
// Reset the movement.
editedAxis.resetMovement();
// Set the translation direction.
editedAxis.setTranslationDirection(newValue);
// Set the status.
zeroValueReference1Label.setTextFill(editedAxis.calculateZeroValueReferenceAxis1Status() == Axis.Status.NOK ? Color.RED : Color.BLACK);
zeroValueReference2Label.setTextFill(editedAxis.calculateZeroValueReferenceAxis2Status() == Axis.Status.NOK ? Color.RED : Color.BLACK);
// Calculate the zero value if possible.
editedAxis.calculateZeroValueFromReferences();
// Set the direction fields.
xDirField.setText(String.format("%.3f", editedAxis.getDirection().getX()));
yDirField.setText(String.format("%.3f", editedAxis.getDirection().getY()));
zDirField.setText(String.format("%.3f", editedAxis.getDirection().getZ()));
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Type
Label typeLabel = new Label("Type : ");
......@@ -597,6 +627,9 @@ public class EditorMenuBar extends MenuBar {
// Change the visibility of the rotation direction box.
rotationDirectionBox.setVisible(newValue == Axis.Type.ROTATION);
// Change the visibility of the translation direction box.
translationDirectionBox.setVisible(newValue == Axis.Type.TRANSLATION);
// Change the visibility of the zero value reference boxes and labels.
zeroValueReference1Label.setVisible(newValue == Axis.Type.ROTATION || newValue == Axis.Type.TRANSLATION);
zeroValueReference1Box.setVisible(newValue == Axis.Type.ROTATION || newValue == Axis.Type.TRANSLATION);
......@@ -729,6 +762,9 @@ public class EditorMenuBar extends MenuBar {
rotationDirectionBox.setValue(Axis.RotationDirection.CCW);
editedAxis.setRotationDirection(Axis.RotationDirection.CCW);
translationDirectionBox.setValue(Axis.TranslationDirection.FW);
editedAxis.setTranslationDirection(Axis.TranslationDirection.FW);
// Set the status.
zeroValueReference1Label.setTextFill(editedAxis.calculateZeroValueReferenceAxis1Status() == Axis.Status.NOK ? Color.RED : Color.BLACK);
zeroValueReference2Label.setTextFill(editedAxis.calculateZeroValueReferenceAxis2Status() == Axis.Status.NOK ? Color.RED : Color.BLACK);
......@@ -825,6 +861,7 @@ public class EditorMenuBar extends MenuBar {
editedAxis.getType(),
referenceAxisName,
editedAxis.getRotationDirection(),
editedAxis.getTranslationDirection(),
zeroValueReferenceAxis1Name,
reversedDirection1Check.isSelected(),
zeroValueReferenceAxis2Name,
......@@ -871,7 +908,7 @@ public class EditorMenuBar extends MenuBar {
mainPane.setVgap(5);
mainPane.setAlignment(Pos.TOP_LEFT);
mainPane.addRow(0, controllerLabel, controllerBox, minValueLabel, maxValueLabel);
mainPane.addRow(1, typeLabel, typeBox, rotationDirectionBox);
mainPane.addRow(1, typeLabel, typeBox, rotationDirectionBox, translationDirectionBox);
mainPane.addRow(2, referenceLabel, referenceBox);
GridPane.setColumnSpan(typeBox, GridPane.REMAINING);
addPane.addRow(0, mainPane);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment