Commit d3ab1d5f authored by legoc's avatar legoc
Browse files

Combo box for reference axis

parent 427433cb
......@@ -261,6 +261,35 @@ public class EditorMenuBar extends MenuBar {
Label yPosField = new Label("0.0");
Label zPosField = new Label("0.0");
///////////////////////////////////////////////////////////////////////////////////////
// Controller
// Filter on the unit
// if (!((selectedAxis.getType() == Axis.Type.ROTATION && selectedController.getType() == Nomad3DController.Type.ROTATION) || (selectedAxis.getType() == Axis.Type.TRANSLATION && selectedController.getType() == Nomad3DController.Type.TRANSLATION))) {
// Alert alert = new Alert(AlertType.CONFIRMATION);
// alert.setTitle(linkAxisItem.getText());
// alert.setContentText("The selected axis and controller do not have the same type.");
// Optional<ButtonType> res = alert.showAndWait();
// if (res.isPresent()) {
// if (res.get() != ButtonType.OK) {
// return;
// }
// }
// }
Label controllerLabel = new Label("Controller : ");
ObservableList<String> controllers = FXCollections.observableArrayList(NomadLinker.getInstance().getControllersNames());
ComboBox<String> controllerBox = new ComboBox<>(controllers);
if (selectedAxis.getController() != null) {
controllerBox.getSelectionModel().select(selectedAxis.getController().getName());
}
controllerBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
selectedAxis.setController(NomadLinker.getInstance().getControllerByName(newValue));
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Rotation direction
ObservableList<Axis.RotationDirection> rotationDirections = FXCollections.observableArrayList(Axis.RotationDirection.CCW, Axis.RotationDirection.CW);
......@@ -318,7 +347,6 @@ public class EditorMenuBar extends MenuBar {
xPosField.setText(String.format("%.3f", selectedAxis.getPosition().getX()));
yPosField.setText(String.format("%.3f", selectedAxis.getPosition().getY()));
zPosField.setText(String.format("%.3f", selectedAxis.getPosition().getZ()));
}
referenceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
......@@ -424,36 +452,52 @@ public class EditorMenuBar extends MenuBar {
// Invalid input, nothing to do
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Controller
// Reference for first zero value
Label zeroValueReference1Label = new Label("Zero Value Reference 1 : ");
ComboBox<String> zeroValueReference1Box = new ComboBox<>(references);
// Filter on the unit
// if (!((selectedAxis.getType() == Axis.Type.ROTATION && selectedController.getType() == Nomad3DController.Type.ROTATION) || (selectedAxis.getType() == Axis.Type.TRANSLATION && selectedController.getType() == Nomad3DController.Type.TRANSLATION))) {
// Alert alert = new Alert(AlertType.CONFIRMATION);
// alert.setTitle(linkAxisItem.getText());
// alert.setContentText("The selected axis and controller do not have the same type.");
// Optional<ButtonType> res = alert.showAndWait();
// if (res.isPresent()) {
// if (res.get() != ButtonType.OK) {
// return;
// }
// }
// }
// Select the reference axis.
if (selectedAxis.getZeroValueReferenceAxis1() != null) {
zeroValueReference1Box.getSelectionModel().select(selectedAxis.getZeroValueReferenceAxis1().getName());
}
Label controllerLabel = new Label("Controller : ");
ObservableList<String> controllers = FXCollections.observableArrayList(NomadLinker.getInstance().getControllersNames());
ComboBox<String> controllerBox = new ComboBox<>(controllers);
if (selectedAxis.getController() != null) {
controllerBox.getSelectionModel().select(selectedAxis.getController().getName());
zeroValueReference1Box.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
// Get the reference axis.
ReferenceAxis referenceAxis = ReferenceAxisList.getInstance().getAxis(newValue);
// Set the selected axis with the reference.
selectedAxis.setZeroValueReferenceAxis1(referenceAxis);
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Reference for second zero value
Label zeroValueReference2Label = new Label("Zero Value Reference 2 : ");
ComboBox<String> zeroValueReference2Box = new ComboBox<>(references);
// Select the reference axis.
if (selectedAxis.getZeroValueReferenceAxis2() != null) {
zeroValueReference2Box.getSelectionModel().select(selectedAxis.getZeroValueReferenceAxis2().getName());
}
controllerBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
zeroValueReference2Box.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
selectedAxis.setController(NomadLinker.getInstance().getControllerByName(newValue));
// Get the reference axis.
ReferenceAxis referenceAxis = ReferenceAxisList.getInstance().getAxis(newValue);
// Set the selected axis with the reference.
selectedAxis.setZeroValueReferenceAxis2(referenceAxis);
}
});
///////////////////////////////////////////////////////////////////////////////////////
// OK and Cancel
Button okButton = new Button("OK");
......@@ -551,6 +595,9 @@ public class EditorMenuBar extends MenuBar {
calibrationPane.setAlignment(Pos.TOP_LEFT);
calibrationPane.addRow(0, valueText, valueField, unitLabel, setZeroButton);
calibrationPane.addRow(1, zeroValueText, zeroValueField, zeroUnitLabel, moveToZeroButton);
calibrationPane.addRow(2, zeroValueReference1Label, zeroValueReference1Box);
calibrationPane.addRow(3, zeroValueReference2Label, zeroValueReference2Box);
addPane.addRow(2, calibrationPane);
GridPane buttonPane = new GridPane();
......
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