Commit 17f3b80e authored by legoc's avatar legoc
Browse files

Added min and max values and axis type dependency from the controller

parent 65551ae2
......@@ -199,7 +199,7 @@ public class EditorMenuBar extends MenuBar {
if (selectRoots.size() > 1) {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle(editAxisItem.getText());
alert.setContentText("Select only one component.");
alert.setContentText("Select only one Component.");
alert.showAndWait();
} else {
......@@ -269,36 +269,7 @@ public class EditorMenuBar extends MenuBar {
ObservableList<String> references = FXCollections.observableArrayList("");
references.addAll(ReferenceAxisList.getInstance().getNames());
///////////////////////////////////////////////////////////////////////////////////////
// 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("");
controllers.addAll(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));
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Zero value
Label zeroValueText = new Label("Zero Value : ");
......@@ -330,6 +301,24 @@ public class EditorMenuBar extends MenuBar {
}
});
Button moveToMinButton = new Button("Move To Min");
moveToMinButton.setOnAction(medianEvent -> {
try {
selectedAxis.move(selectedAxis.getController().getMinPosition() + selectedAxis.getZeroValue() - selectedAxis.getValue());
} catch (Exception e) {
// Invalid input, nothing to do
}
});
Button moveToMaxButton = new Button("Move To Max");
moveToMaxButton.setOnAction(medianEvent -> {
try {
selectedAxis.move(selectedAxis.getController().getMaxPosition() + selectedAxis.getZeroValue() - selectedAxis.getValue());
} catch (Exception e) {
// Invalid input, nothing to do
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Reference for first zero value
Label zeroValueReference1Label = new Label("Zero Value A : ");
......@@ -492,6 +481,51 @@ public class EditorMenuBar extends MenuBar {
valueText.setText(currentValueText(selectedAxis.getType()));
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Controller
Label controllerLabel = new Label("Controller : ");
Label minValueLabel = new Label("");
Label maxValueLabel = new Label("");
ObservableList<String> controllers = FXCollections.observableArrayList("");
controllers.addAll(NomadLinker.getInstance().getControllersNames());
ComboBox<String> controllerBox = new ComboBox<>(controllers);
if (selectedAxis.getController() != null) {
// Select the controller.
controllerBox.getSelectionModel().select(selectedAxis.getController().getName());
// Set the text of the min and max labels.
minValueLabel.setText("Min Value : " + selectedAxis.getController().getMinPosition());
maxValueLabel.setText("Max Value : " + selectedAxis.getController().getMaxPosition());
}
controllerBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
// Select the controller.
selectedAxis.setController(NomadLinker.getInstance().getControllerByName(newValue));
// Set the text of the min and max labels.
minValueLabel.setText("Min Value : " + selectedAxis.getController().getMinPosition());
maxValueLabel.setText("Max Value : " + selectedAxis.getController().getMaxPosition());
// Set the type of axis based on the type of the controller.
Nomad3DController.Type type = selectedAxis.getController().getType();
if (type == Nomad3DController.Type.ROTATION) {
selectedAxis.setType(Axis.Type.ROTATION);
}
else if (type == Nomad3DController.Type.TRANSLATION) {
selectedAxis.setType(Axis.Type.TRANSLATION);
}
else {
selectedAxis.setType(Axis.Type.FIXED);
}
typeBox.getSelectionModel().select(selectedAxis.getType());
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Reference
......@@ -642,8 +676,6 @@ public class EditorMenuBar extends MenuBar {
selectedAxis.getType(),
referenceAxisName,
selectedAxis.getRotationDirection(),
selectedAxis.getMinValue(),
selectedAxis.getMaxValue(),
zeroValueReferenceAxis1Name,
reversedDirection1Check.isSelected(),
zeroValueReferenceAxis2Name,
......@@ -681,7 +713,7 @@ public class EditorMenuBar extends MenuBar {
mainPane.setHgap(10);
mainPane.setVgap(5);
mainPane.setAlignment(Pos.TOP_LEFT);
mainPane.addRow(0, controllerLabel, controllerBox);
mainPane.addRow(0, controllerLabel, controllerBox, minValueLabel, maxValueLabel);
mainPane.addRow(1, typeLabel, typeBox, rotationDirectionBox);
mainPane.addRow(2, referenceLabel, referenceBox);
GridPane.setColumnSpan(typeBox, GridPane.REMAINING);
......@@ -705,6 +737,7 @@ public class EditorMenuBar extends MenuBar {
calibrationPane.addRow(2, zeroValueReference1Label, zeroValueReference1Box, reversedDirection1Check);
calibrationPane.addRow(3, zeroValueReference2Label, zeroValueReference2Box, reversedDirection2Check);
calibrationPane.addRow(4, resetButton, moveToZeroButton);
calibrationPane.addRow(5, moveToMinButton, moveToMaxButton);
addPane.addRow(2, calibrationPane);
......@@ -758,17 +791,17 @@ public class EditorMenuBar extends MenuBar {
} else {
nomadPane.addRow(0, new Label("Name :"), new Label(selectedController.getName()));
nomadPane.addRow(1, new Label("Unit :"), new Label(selectedController.getType().toString()));
nomadPane.addRow(2, new Label("Actual position :"), new Label(Double.toString(selectedController.getActualPosition())));
nomadPane.addRow(3, new Label("Offset position :"), new Label(Double.toString(selectedController.getOffsetPosition())));
nomadPane.addRow(4, new Label("Wanted position :"), new Label(Double.toString(selectedController.getWantedPosition())));
nomadPane.addRow(5, new Label("Min position :"), new Label(Double.toString(selectedController.getMinPosition())));
nomadPane.addRow(6, new Label("Max position :"), new Label(Double.toString(selectedController.getMaxPosition())));
nomadPane.addRow(2, new Label("Actual Position :"), new Label(Double.toString(selectedController.getActualPosition())));
nomadPane.addRow(3, new Label("Offset Position :"), new Label(Double.toString(selectedController.getOffsetPosition())));
nomadPane.addRow(4, new Label("Setpoint Position :"), new Label(Double.toString(selectedController.getWantedPosition())));
nomadPane.addRow(5, new Label("Min Position :"), new Label(Double.toString(selectedController.getMinPosition())));
nomadPane.addRow(6, new Label("Max Position :"), new Label(Double.toString(selectedController.getMaxPosition())));
}
displayStage.show();
});
MenuItem editMaterialItem = new MenuItem("Edit material");
MenuItem editMaterialItem = new MenuItem("Edit Material");
editMaterialItem.setAccelerator(new KeyCodeCombination(KeyCode.M, KeyCombination.CONTROL_DOWN));
editMaterialItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
......@@ -856,7 +889,7 @@ public class EditorMenuBar extends MenuBar {
modifyStage.showAndWait();
}
});
MenuItem regroupComponentsItem = new MenuItem("Regroup components");
MenuItem regroupComponentsItem = new MenuItem("Regroup Components");
regroupComponentsItem.setOnAction(event -> {
if (!modelLoaded()) {
return;
......@@ -902,7 +935,7 @@ public class EditorMenuBar extends MenuBar {
scenePane.addRow(1, buttonsPane);
GridPane.setMargin(buttonsPane, new Insets(10));
Label parentLabel = new Label("Parent of the group :");
Label parentLabel = new Label("Parent Of The Group :");
ToggleGroup buttonsGroup = new ToggleGroup();
RadioButton commonButton = new RadioButton("Common parent : ");
commonButton.setSelected(true);
......@@ -913,7 +946,7 @@ public class EditorMenuBar extends MenuBar {
ObservableList<Component> selectList = FXCollections.observableArrayList(selectRoots);
ComboBox<Component> selectBox = new ComboBox<>(selectList);
selectBox.setCellFactory(ComboCell.FACTORY);
CheckBox addLevelBox = new CheckBox("Insert a new component regrouping the selection");
CheckBox addLevelBox = new CheckBox("Insert A New Component Regrouping The Selection");
addLevelBox.setSelected(true);
parentPane.addRow(0, parentLabel);
......@@ -960,7 +993,7 @@ public class EditorMenuBar extends MenuBar {
regroupStage.show();
});
MenuItem subdivideComponentItem = new MenuItem("Subdivide component");
MenuItem subdivideComponentItem = new MenuItem("Subdivide Component");
subdivideComponentItem.setOnAction(event -> {
if (!modelLoaded()) {
return;
......@@ -1026,11 +1059,11 @@ public class EditorMenuBar extends MenuBar {
meshField.setPrefColumnCount(colCount);
meshField.setPrefHeight(lineHeight);
newChild.path.bind(meshField.textProperty());
Button browseButton = new Button("Browse files");
Button browseButton = new Button("Browse Files");
browseButton.setPrefSize(80, lineHeight);
browseButton.setOnAction(browseEvent -> {
FileChooser chooser = new FileChooser();
chooser.setTitle("Open model");
chooser.setTitle("Open Model");
if (!meshField.getText().isEmpty()) {
File meshFile = new File(meshField.getText());
if (meshFile.exists() && meshFile.getParentFile() != null && meshFile.getParentFile().exists()) {
......@@ -1470,7 +1503,7 @@ public class EditorMenuBar extends MenuBar {
updateSystem();
}
});
CheckMenuItem showWallsItem = new CheckMenuItem("Show walls");
CheckMenuItem showWallsItem = new CheckMenuItem("Show Walls");
showWallsItem.setSelected(this.showWalls);
showWallsItem.setAccelerator(new KeyCodeCombination(KeyCode.W, KeyCombination.SHIFT_DOWN));
showWallsItem.setOnAction(new EventHandler<ActionEvent>() {
......@@ -1481,7 +1514,7 @@ public class EditorMenuBar extends MenuBar {
}
});
MenuItem resetMoveItem = new MenuItem("Reset movement");
MenuItem resetMoveItem = new MenuItem("Reset Movement");
resetMoveItem.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.SHIFT_DOWN));
resetMoveItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
......@@ -1490,7 +1523,7 @@ public class EditorMenuBar extends MenuBar {
}
});
MenuItem moveToZeroItem = new MenuItem("Move to zero");
MenuItem moveToZeroItem = new MenuItem("Move To Zero");
moveToZeroItem.setAccelerator(new KeyCodeCombination(KeyCode.Z, KeyCombination.SHIFT_DOWN));
moveToZeroItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
......
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