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 { ...@@ -94,6 +94,9 @@ public class Nomad3DEditor extends Application {
/** 3D scene. */ /** 3D scene. */
private SubScene subScene = null; private SubScene subScene = null;
/** Hierarchy view. */
TreeView<Component> hierarchyView;
/** /**
* Reference to the logger, used to prevent the garbage collector to destroy it. * Reference to the logger, used to prevent the garbage collector to destroy it.
* It happens when the editor is launched by the converter. * It happens when the editor is launched by the converter.
...@@ -187,7 +190,7 @@ public class Nomad3DEditor extends Application { ...@@ -187,7 +190,7 @@ public class Nomad3DEditor extends Application {
subScene.setManaged(false); subScene.setManaged(false);
subScene.widthProperty().bind(subScenePane.widthProperty()); subScene.widthProperty().bind(subScenePane.widthProperty());
subScene.heightProperty().bind(subScenePane.heightProperty()); subScene.heightProperty().bind(subScenePane.heightProperty());
TreeView<Component> hierarchyView = buildHierarchyView(); hierarchyView = buildHierarchyView();
pane = new BorderPane(); pane = new BorderPane();
...@@ -283,11 +286,11 @@ public class Nomad3DEditor extends Application { ...@@ -283,11 +286,11 @@ public class Nomad3DEditor extends Application {
} }
/** /**
* Gets the pane. * Gets the hierarchy view.
* @return The pane * @return The view
*/ */
public BorderPane getPane() { public TreeView<Component> getHierarchyView() {
return pane; return hierarchyView;
} }
/** /**
...@@ -394,7 +397,7 @@ public class Nomad3DEditor extends Application { ...@@ -394,7 +397,7 @@ public class Nomad3DEditor extends Application {
buildLights(); buildLights();
buildCamera(); buildCamera();
TreeView<Component> hierarchyView = buildHierarchyView(); hierarchyView = buildHierarchyView();
this.pane = new BorderPane(); this.pane = new BorderPane();
......
...@@ -79,7 +79,7 @@ import javafx.stage.FileChooser; ...@@ -79,7 +79,7 @@ import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter; import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.StageStyle; import javafx.stage.StageStyle;
import javafx.scene.control.Slider;
/** /**
* Menu bar of the Nomad3DEditor.getInstance(). * Menu bar of the Nomad3DEditor.getInstance().
...@@ -116,6 +116,9 @@ public class EditorMenuBar extends MenuBar { ...@@ -116,6 +116,9 @@ public class EditorMenuBar extends MenuBar {
/** Show type. */ /** Show type. */
private Component.ShowType showType; private Component.ShowType showType;
/** Reference axis display. */
ReferenceAxisListDisplay referenceAxisDisplay = null;
/** Currently displayed configuration. */ /** Currently displayed configuration. */
private String activeConfiguration; private String activeConfiguration;
...@@ -124,7 +127,7 @@ public class EditorMenuBar extends MenuBar { ...@@ -124,7 +127,7 @@ public class EditorMenuBar extends MenuBar {
/** True if there are some operations not saved. */ /** True if there are some operations not saved. */
private boolean modified = false; private boolean modified = false;
private class SubdividedChild { private class SubdividedChild {
SimpleStringProperty name = new SimpleStringProperty(); SimpleStringProperty name = new SimpleStringProperty();
SimpleStringProperty path = new SimpleStringProperty(); SimpleStringProperty path = new SimpleStringProperty();
...@@ -1819,13 +1822,8 @@ public class EditorMenuBar extends MenuBar { ...@@ -1819,13 +1822,8 @@ public class EditorMenuBar extends MenuBar {
} }
// Reference axis list display. // Reference axis list display.
ReferenceAxisListDisplay referenceAxisDisplay = new ReferenceAxisListDisplay(); removeReferenceAxes();
displayReferenceAxes();
// 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 // Pane
GridPane scenePane = new GridPane(); GridPane scenePane = new GridPane();
...@@ -1876,15 +1874,88 @@ public class EditorMenuBar extends MenuBar { ...@@ -1876,15 +1874,88 @@ public class EditorMenuBar extends MenuBar {
scenePane.addRow(0, tableView); scenePane.addRow(0, tableView);
displayStage.setOnCloseRequest(closeEvent -> { displayStage.showAndWait();
// Remove the reference axis display. removeReferenceAxes();
rootNode.getChildren().remove(referenceAxisDisplay.getVisualGroup());
});
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 { ...@@ -2308,7 +2379,7 @@ public class EditorMenuBar extends MenuBar {
undoItem, undoItem,
new SeparatorMenuItem(), editAxisItem, displayAxisItem, editMaterialItem, new SeparatorMenuItem(), editAxisItem, displayAxisItem, editMaterialItem,
new SeparatorMenuItem(), addComponentItem, removeComponentsItem, renameComponentItem, moveComponentsItem, new SeparatorMenuItem(), addComponentItem, removeComponentsItem, renameComponentItem, moveComponentsItem,
new SeparatorMenuItem(), displayReferenceAxesItem, addReferenceAxisItem, removeReferenceAxisItem); new SeparatorMenuItem(), displayReferenceAxesItem, addReferenceAxisItem, removeReferenceAxisItem, axisSizeItem);
this.view = new Menu("View"); this.view = new Menu("View");
Menu cameraMenu = new Menu("Camera"); Menu cameraMenu = new Menu("Camera");
...@@ -2847,6 +2918,32 @@ public class EditorMenuBar extends MenuBar { ...@@ -2847,6 +2918,32 @@ public class EditorMenuBar extends MenuBar {
updateWalls(); 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. * Updates the 3D scene and the tree view.
*/ */
...@@ -2867,7 +2964,7 @@ public class EditorMenuBar extends MenuBar { ...@@ -2867,7 +2964,7 @@ public class EditorMenuBar extends MenuBar {
Nomad3DEditor.getInstance().getRoot().getChildren().remove(Nomad3DEditor.getInstance().getModel().getRoot().getSceneNode()); Nomad3DEditor.getInstance().getRoot().getChildren().remove(Nomad3DEditor.getInstance().getModel().getRoot().getSceneNode());
Nomad3DEditor.getInstance().getModel().computeSceneHierarchies(activeLod); Nomad3DEditor.getInstance().getModel().computeSceneHierarchies(activeLod);
Nomad3DEditor.getInstance().getRoot().getChildren().add(Nomad3DEditor.getInstance().getModel().getRoot().getSceneNode()); 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. // Restore the expanded state of the tree items.
Nomad3DEditor.getInstance().expandTreeView(Nomad3DEditor.getInstance().getModel().getRoot().getTreeItem(), itemStates); 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