Commit 3e2acac2 authored by legoc's avatar legoc
Browse files

Reset axis movement when changing some parameters

parent b03a443a
......@@ -253,13 +253,13 @@ public class EditorMenuBar extends MenuBar {
scenePane.addRow(0, addPane);
GridPane.setMargin(addPane, new Insets(10));
Label xDirField = new Label("0.0");
Label yDirField = new Label("0.0");
Label zDirField = new Label("0.0");
Label xDirField = new Label("-");
Label yDirField = new Label("-");
Label zDirField = new Label("-");
Label xPosField = new Label("0.0");
Label yPosField = new Label("0.0");
Label zPosField = new Label("0.0");
Label xPosField = new Label("-");
Label yPosField = new Label("-");
Label zPosField = new Label("-");
///////////////////////////////////////////////////////////////////////////////////////
// Controller
......@@ -301,8 +301,11 @@ public class EditorMenuBar extends MenuBar {
@Override
public void changed(ObservableValue<? extends Axis.RotationDirection> observable, Axis.RotationDirection oldValue, Axis.RotationDirection newValue) {
// Reset the movement.
selectedAxis.resetMovement();
// Set the rotation direction.
Nomad3DEditor.getInstance().getAxisBuilder().getAxis().setRotationDirection(newValue);
selectedAxis.setRotationDirection(newValue);
// Set the direction fields.
xDirField.setText(String.format("%.3f", selectedAxis.getDirection().getX()));
......@@ -322,6 +325,9 @@ public class EditorMenuBar extends MenuBar {
public void changed(ObservableValue<? extends Axis.Type> observable, Axis.Type oldValue, Axis.Type newValue) {
Nomad3DEditor.getInstance().getAxisBuilder().setType(newValue);
// Reset the movement.
selectedAxis.resetMovement();
// Change the visibility of the rotation direction box.
rotationDirectionBox.setVisible(newValue == Axis.Type.ROTATION);
}
......@@ -352,18 +358,33 @@ public class EditorMenuBar extends MenuBar {
referenceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
// Reset the movement.
selectedAxis.resetMovement();
// Get the reference axis.
ReferenceAxis referenceAxis = ReferenceAxisList.getInstance().getAxis(newValue);
// Set the fields.
xDirField.setText(String.format("%.3f", referenceAxis.getDirection().getX()));
yDirField.setText(String.format("%.3f", referenceAxis.getDirection().getY()));
zDirField.setText(String.format("%.3f", referenceAxis.getDirection().getZ()));
// Set the fields if the reference axis exists.
if (referenceAxis != null) {
xPosField.setText(String.format("%.3f", referenceAxis.getPosition().getX()));
yPosField.setText(String.format("%.3f", referenceAxis.getPosition().getY()));
zPosField.setText(String.format("%.3f", referenceAxis.getPosition().getZ()));
xDirField.setText(String.format("%.3f", referenceAxis.getDirection().getX()));
yDirField.setText(String.format("%.3f", referenceAxis.getDirection().getY()));
zDirField.setText(String.format("%.3f", referenceAxis.getDirection().getZ()));
xPosField.setText(String.format("%.3f", referenceAxis.getPosition().getX()));
yPosField.setText(String.format("%.3f", referenceAxis.getPosition().getY()));
zPosField.setText(String.format("%.3f", referenceAxis.getPosition().getZ()));
}
else {
xDirField.setText("-");
yDirField.setText("-");
zDirField.setText("-");
xPosField.setText("-");
yPosField.setText("-");
zPosField.setText("-");
}
// Set the selected axis with the reference.
Nomad3DEditor.getInstance().getAxisBuilder().getAxis().setReferenceAxis(referenceAxis);
......@@ -376,12 +397,12 @@ public class EditorMenuBar extends MenuBar {
///////////////////////////////////////////////////////////////////////////////////////
// Direction and position
Label dirLabel = new Label("Direction : ");
Label dirLabel = new Label("Direction ");
Label xDirLabel = new Label("X : ");
Label yDirLabel = new Label("Y : ");
Label zDirLabel = new Label("Z : ");
Label posLabel = new Label("Position : ");
Label posLabel = new Label("Position ");
Label xPosLabel = new Label("X : ");
Label yPosLabel = new Label("Y : ");
Label zPosLabel = new Label("Z : ");
......@@ -511,9 +532,14 @@ public class EditorMenuBar extends MenuBar {
// Stop the build.
Nomad3DEditor.getInstance().getAxisBuilder().stop(selectedComponent);
String referenceAxisName = null;
String zeroValueReferenceAxis1Name = null;
String zeroValueReferenceAxis2Name = null;
String controllerName = null;
if (selectedAxis.getReferenceAxis() != null) {
referenceAxisName = selectedAxis.getReferenceAxis().getName();
}
if (selectedAxis.getZeroValueReferenceAxis1() != null) {
zeroValueReferenceAxis1Name = selectedAxis.getZeroValueReferenceAxis1().getName();
......@@ -531,7 +557,7 @@ public class EditorMenuBar extends MenuBar {
Operations.getInstance().addOperation(new SetAxisOperation(
selectedComponent.getName(),
selectedAxis.getType(),
selectedAxis.getReferenceAxis().getName(),
referenceAxisName,
selectedAxis.getRotationDirection(),
selectedAxis.getMinValue(),
selectedAxis.getMaxValue(),
......
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