Commit c5142824 authored by legoc's avatar legoc
Browse files

Added reference axis list display

parent b403dec0
......@@ -149,6 +149,13 @@ public class EditorMenuBar extends MenuBar {
this.componentName = new SimpleStringProperty(componentName);
this.type = new SimpleStringProperty(type);
}
private AxisTableEntry(String axisName) {
super();
this.axisName = new SimpleStringProperty(axisName);
this.componentName = new SimpleStringProperty("");
this.type = new SimpleStringProperty("");
}
public String getAxisName() {
return axisName.get();
......@@ -1475,8 +1482,7 @@ public class EditorMenuBar extends MenuBar {
Group rootNode = (Group)Nomad3DEditor.getInstance().getModel().getRoot().getSceneNode();
// We set it at the end of the group so that it is always in front of the components.
rootNode.getChildren().add(0, referenceAxisBuilder.getVisualGroup());
referenceAxisBuilder.getVisualGroup().toFront();
rootNode.getChildren().add(referenceAxisBuilder.getVisualGroup());
///////////////////////////////////////////////////////////////////////////////////////
// Length
......@@ -1800,9 +1806,74 @@ public class EditorMenuBar extends MenuBar {
mainPane.addRow(1, buttonPane);
stage.showAndWait();
});
///////////////////////////////////////////////////////////////////////////////////////
// Reference axis menu
MenuItem displayReferenceAxesItem = new MenuItem("Show Reference Axes");
displayReferenceAxesItem.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_DOWN));
displayReferenceAxesItem.setOnAction(event -> {
if (Nomad3DEditor.getInstance().getModel() == null || Nomad3DEditor.getInstance().getRoot() == null) {
return;
}
// Reference axis list display.
ReferenceAxisListDisplay referenceAxisDisplay = new ReferenceAxisListDisplay();
// Get the root node.
Group rootNode = (Group)Nomad3DEditor.getInstance().getModel().getRoot().getSceneNode();
// We set it at the end of the group so that it is always in front of the components.
rootNode.getChildren().add(referenceAxisDisplay.getVisualGroup());
// Pane
GridPane scenePane = new GridPane();
Scene displayScene = new Scene(scenePane);
Stage displayStage = new Stage(StageStyle.UTILITY);
displayStage.setWidth(300);
displayStage.setTitle("Reference Axes");
displayStage.setScene(displayScene);
displayStage.initOwner(Nomad3DEditor.getInstance().getStage());
TableView<AxisTableEntry> tableView = new TableView();
tableView.setEditable(false);
TableColumn axisNameColumn = new TableColumn<>("Name");
axisNameColumn.setMinWidth(300);
axisNameColumn.setCellValueFactory(new PropertyValueFactory<AxisTableEntry, String>("axisName"));
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<AxisTableEntry>() {
@Override
public void changed(ObservableValue<? extends AxisTableEntry> observable, AxisTableEntry oldValue, AxisTableEntry newValue) {
referenceAxisDisplay.select(newValue.getAxisName());
}
});
final ObservableList<AxisTableEntry> data = FXCollections.observableArrayList();
List<ReferenceAxis> axes = ReferenceAxisList.getInstance().get();
for (ReferenceAxis axis : axes) {
data.add(new AxisTableEntry(axis.getName()));
}
tableView.setItems(data);
tableView.getColumns().addAll(axisNameColumn);
scenePane.addRow(0, tableView);
displayStage.setOnCloseRequest(closeEvent -> {
// Remove the reference axis display.
rootNode.getChildren().remove(referenceAxisDisplay.getVisualGroup());
});
displayStage.show();
});
///////////////////////////////////////////////////////////////////////////////////////
// Not used anymore
......@@ -2225,7 +2296,7 @@ public class EditorMenuBar extends MenuBar {
undoItem,
new SeparatorMenuItem(), editAxisItem, displayAxisItem, editMaterialItem,
new SeparatorMenuItem(), addComponentItem, removeComponentsItem, renameComponentItem, moveComponentsItem,
new SeparatorMenuItem(), addReferenceAxisItem, removeReferenceAxisItem);
new SeparatorMenuItem(), displayReferenceAxesItem, addReferenceAxisItem, removeReferenceAxisItem);
this.view = new Menu("View");
Menu cameraMenu = new Menu("Camera");
......
package fr.ill.ics.n3d.gui;
import java.util.ArrayList;
import fr.ill.ics.n3d.gui.EditorMenuBar.AxisTableEntry;
import fr.ill.ics.n3d.model.Axis;
import fr.ill.ics.n3d.model.ReferenceAxis;
import fr.ill.ics.n3d.model.ReferenceAxisList;
import javafx.geometry.Point3D;
import javafx.scene.DepthTest;
import javafx.scene.Group;
/**
* Class for creating reference axes.
*/
public class ReferenceAxisListDisplay {
private Group visualGroup;
private String selectedAxisName = "";
/**
* Default constructor.
*/
public ReferenceAxisListDisplay() {
visualGroup = new Group();
visualGroup.setVisible(true);
init();
}
public Group getVisualGroup() {
return visualGroup;
}
private void init() {
visualGroup.getChildren().clear();
visualGroup.getTransforms().clear();
ArrayList<ReferenceAxis> axes = ReferenceAxisList.getInstance().get();
for (ReferenceAxis axis : axes) {
Group visualAxisGroup = new Group();
if (axis.getName().equals(selectedAxisName)) {
Axis.updateVisualAxisGroup(visualAxisGroup, Axis.Type.NEW, axis.getPosition(), axis.getDirection(), false);
}
else {
Axis.updateVisualAxisGroup(visualAxisGroup, Axis.Type.REFERENCE1, axis.getPosition(), axis.getDirection(), false);
}
visualGroup.getChildren().add(visualAxisGroup);
}
visualGroup.setDepthTest(DepthTest.DISABLE);
}
public void select(String axisName) {
this.selectedAxisName = axisName;
init();
}
}
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