Commit 645bb150 authored by legoc's avatar legoc
Browse files

Save an axis operation if the axis is different from the initial one

parent 9756107d
......@@ -415,6 +415,15 @@ public class EditorMenuBar extends MenuBar {
selectedAxis.setZeroValue(selectedAxis.getValue());
zeroValueField.setText(String.format("%.3f", selectedAxis.getZeroValue()));
});
Button moveToZeroButton = new Button("Move To Zero");
moveToZeroButton.setOnAction(medianEvent -> {
try {
selectedAxis.move(selectedAxis.getZeroValue() - selectedAxis.getValue());
} catch (Exception e) {
// Invalid input, nothing to do
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Controller
......@@ -449,42 +458,52 @@ public class EditorMenuBar extends MenuBar {
// OK and Cancel
Button okButton = new Button("OK");
okButton.setOnAction(okEvent -> {
// Normalize here the direction, because the norm has an impact on the
// translation.
selectedAxis.setDirection(selectedAxis.getDirection().normalize());
// Stop the build.
Nomad3DEditor.getInstance().getAxisBuilder().stop(selectedComponent);
String zeroValueReferenceAxis1Name = null;
String zeroValueReferenceAxis2Name = null;
String controllerName = null;
// Do not save the operation if the axis is the same.
if (!selectedAxis.equals(initialAxis)) {
if (selectedAxis.getZeroValueReferenceAxis1() != null) {
zeroValueReferenceAxis1Name = selectedAxis.getZeroValueReferenceAxis1().getName();
}
if (selectedAxis.getZeroValueReferenceAxis2() != null) {
zeroValueReferenceAxis2Name = selectedAxis.getZeroValueReferenceAxis2().getName();
System.out.println("Axis modified");
// Normalize here the direction, because the norm has an impact on the
// translation.
selectedAxis.setDirection(selectedAxis.getDirection().normalize());
// Stop the build.
Nomad3DEditor.getInstance().getAxisBuilder().stop(selectedComponent);
String zeroValueReferenceAxis1Name = null;
String zeroValueReferenceAxis2Name = null;
String controllerName = null;
if (selectedAxis.getZeroValueReferenceAxis1() != null) {
zeroValueReferenceAxis1Name = selectedAxis.getZeroValueReferenceAxis1().getName();
}
if (selectedAxis.getZeroValueReferenceAxis2() != null) {
zeroValueReferenceAxis2Name = selectedAxis.getZeroValueReferenceAxis2().getName();
}
if (selectedAxis.getController() != null) {
controllerName = selectedAxis.getController().getName();
}
// Save the operation.
Operations.getInstance().addOperation(new SetAxisOperation(
selectedComponent.getName(),
selectedAxis.getType(),
selectedAxis.getReferenceAxis().getName(),
selectedAxis.getRotationDirection(),
selectedAxis.getMinValue(),
selectedAxis.getMaxValue(),
zeroValueReferenceAxis1Name,
zeroValueReferenceAxis2Name,
selectedAxis.getZeroValue(),
controllerName));
}
if (selectedAxis.getController() != null) {
controllerName = selectedAxis.getController().getName();
else {
System.out.println("Axis NOT modified");
}
// Save the operation.
Operations.getInstance().addOperation(new SetAxisOperation(
selectedComponent.getName(),
selectedAxis.getType(),
selectedAxis.getReferenceAxis().getName(),
selectedAxis.getRotationDirection(),
selectedAxis.getMinValue(),
selectedAxis.getMaxValue(),
zeroValueReferenceAxis1Name,
zeroValueReferenceAxis2Name,
selectedAxis.getZeroValue(),
controllerName));
Nomad3DEditor.getInstance().getModel().clearSelection();
updateScene();
Nomad3DEditor.getInstance().getModel().addToSelection(selectedComponent);
......@@ -531,7 +550,7 @@ public class EditorMenuBar extends MenuBar {
calibrationPane.setVgap(5);
calibrationPane.setAlignment(Pos.TOP_LEFT);
calibrationPane.addRow(0, valueText, valueField, unitLabel, setZeroButton);
calibrationPane.addRow(1, zeroValueText, zeroValueField, zeroUnitLabel);
calibrationPane.addRow(1, zeroValueText, zeroValueField, zeroUnitLabel, moveToZeroButton);
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