Commit 1b5c92e0 authored by legoc's avatar legoc
Browse files

Added axis size for the display of all axes

parent 164f6754
......@@ -94,6 +94,9 @@ public class Nomad3DEditor extends Application {
/** 3D scene. */
private SubScene subScene = null;
/** Hierarchy view. */
TreeView<Component> hierarchyView;
/**
* Reference to the logger, used to prevent the garbage collector to destroy it.
* It happens when the editor is launched by the converter.
......@@ -187,7 +190,7 @@ public class Nomad3DEditor extends Application {
subScene.setManaged(false);
subScene.widthProperty().bind(subScenePane.widthProperty());
subScene.heightProperty().bind(subScenePane.heightProperty());
TreeView<Component> hierarchyView = buildHierarchyView();
hierarchyView = buildHierarchyView();
pane = new BorderPane();
......@@ -283,11 +286,11 @@ public class Nomad3DEditor extends Application {
}
/**
* Gets the pane.
* @return The pane
* Gets the hierarchy view.
* @return The view
*/
public BorderPane getPane() {
return pane;
public TreeView<Component> getHierarchyView() {
return hierarchyView;
}
/**
......@@ -394,7 +397,7 @@ public class Nomad3DEditor extends Application {
buildLights();
buildCamera();
TreeView<Component> hierarchyView = buildHierarchyView();
hierarchyView = buildHierarchyView();
this.pane = new BorderPane();
......
......@@ -79,7 +79,7 @@ import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.scene.control.Slider;
/**
* Menu bar of the Nomad3DEditor.getInstance().
......@@ -116,6 +116,9 @@ public class EditorMenuBar extends MenuBar {
/** Show type. */
private Component.ShowType showType;
/** Reference axis display. */
ReferenceAxisListDisplay referenceAxisDisplay = null;
/** Currently displayed configuration. */
private String activeConfiguration;
......@@ -1819,13 +1822,8 @@ public class EditorMenuBar extends MenuBar {
}
// 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());
removeReferenceAxes();
displayReferenceAxes();
// Pane
GridPane scenePane = new GridPane();
......@@ -1876,15 +1874,88 @@ public class EditorMenuBar extends MenuBar {
scenePane.addRow(0, tableView);
displayStage.setOnCloseRequest(closeEvent -> {
// Remove the reference axis display.
rootNode.getChildren().remove(referenceAxisDisplay.getVisualGroup());
displayStage.showAndWait();
removeReferenceAxes();
});
displayStage.show();
///////////////////////////////////////////////////////////////////////////////////////
// Axis size menu
MenuItem axisSizeItem = new MenuItem("Axis Size");
//axisSizeItem.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_DOWN));
axisSizeItem.setOnAction(event -> {
GridPane scenePane = new GridPane();
scenePane.setAlignment(Pos.CENTER);
Scene scene = new Scene(scenePane);
Stage stage = new Stage(StageStyle.UTILITY);
stage.setTitle(axisSizeItem.getText());
stage.setScene(scene);
stage.initOwner(Nomad3DEditor.getInstance().getStage());
GridPane modifyPane = new GridPane();
modifyPane.setVgap(5);
modifyPane.setHgap(10);
modifyPane.setAlignment(Pos.CENTER);
scenePane.addRow(0, modifyPane);
GridPane.setMargin(modifyPane, new Insets(10));
// Label minLabel = new Label("Min Size");
// TextField minValueField = new TextField("1");
// minValueField.setPrefWidth(100);
// modifyPane.addRow(0, minLabel, minValueField);
//
// Label maxLabel = new Label("Max Size");
// TextField maxValueField = new TextField("100");
// maxValueField.setPrefWidth(100);
// modifyPane.addRow(1, maxLabel, maxValueField);
//
Label valueLabel = new Label("Value");
TextField valueField = new TextField(Double.toString(Axis.displaySize));
valueField.setPrefWidth(100);
modifyPane.addRow(2, valueLabel, valueField);
valueField.setOnAction(valueEvent -> {
try {
double value = Double.parseDouble(valueField.getText());
Axis.displaySize = value;
}
catch (Exception e) {
// Invalid input, reset to 1.
Axis.displaySize = 1;
}
});
GridPane sliderPane = new GridPane();
sliderPane.setVgap(5);
sliderPane.setHgap(10);
sliderPane.setAlignment(Pos.CENTER);
Slider slider = new Slider();
slider.setMin(1);
slider.setMax(100);
slider.setValue(1);
sliderPane.addRow(0, slider);
scenePane.addRow(1, sliderPane);
GridPane.setMargin(sliderPane, new Insets(10));
slider.valueProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
Axis.displaySize = newValue.doubleValue();
if (referenceAxisDisplay != null) {
removeReferenceAxes();
displayReferenceAxes();
}
}
});
stage.showAndWait();
});
///////////////////////////////////////////////////////////////////////////////////////
......@@ -2308,7 +2379,7 @@ public class EditorMenuBar extends MenuBar {
undoItem,
new SeparatorMenuItem(), editAxisItem, displayAxisItem, editMaterialItem,
new SeparatorMenuItem(), addComponentItem, removeComponentsItem, renameComponentItem, moveComponentsItem,
new SeparatorMenuItem(), displayReferenceAxesItem, addReferenceAxisItem, removeReferenceAxisItem);
new SeparatorMenuItem(), displayReferenceAxesItem, addReferenceAxisItem, removeReferenceAxisItem, axisSizeItem);
this.view = new Menu("View");
Menu cameraMenu = new Menu("Camera");
......@@ -2847,6 +2918,32 @@ public class EditorMenuBar extends MenuBar {
updateWalls();
}
private void displayReferenceAxes() {
if (Nomad3DEditor.getInstance().getModel() == null) {
return;
}
// Reference axis list display.
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());
}
private void removeReferenceAxes() {
if (referenceAxisDisplay != null && Nomad3DEditor.getInstance().getModel() != null) {
// Get the root node and remove the display.
Group rootNode = (Group)Nomad3DEditor.getInstance().getModel().getRoot().getSceneNode();
rootNode.getChildren().remove(referenceAxisDisplay.getVisualGroup());
referenceAxisDisplay = null;
}
}
/**
* Updates the 3D scene and the tree view.
*/
......@@ -2867,7 +2964,7 @@ public class EditorMenuBar extends MenuBar {
Nomad3DEditor.getInstance().getRoot().getChildren().remove(Nomad3DEditor.getInstance().getModel().getRoot().getSceneNode());
Nomad3DEditor.getInstance().getModel().computeSceneHierarchies(activeLod);
Nomad3DEditor.getInstance().getRoot().getChildren().add(Nomad3DEditor.getInstance().getModel().getRoot().getSceneNode());
((TreeView<Component>) Nomad3DEditor.getInstance().getPane().getLeft()).setRoot(Nomad3DEditor.getInstance().getModel().getRoot().getTreeItem());
Nomad3DEditor.getInstance().getHierarchyView().setRoot(Nomad3DEditor.getInstance().getModel().getRoot().getTreeItem());
// Restore the expanded state of the tree items.
Nomad3DEditor.getInstance().expandTreeView(Nomad3DEditor.getInstance().getModel().getRoot().getTreeItem(), itemStates);
......
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