Commit 46723388 authored by legoc's avatar legoc
Browse files

Possibility to restrict the view to a component

parent fccec922
......@@ -694,4 +694,9 @@ public class Nomad3DEditor extends Application {
}
}
}
public void setComponentAsRoot(Component component) {
menuBar.setDisplayedRoot(component);
}
}
......@@ -127,7 +127,8 @@ public class EditorMenuBar extends MenuBar {
/** True if there are some operations not saved. */
private boolean modified = false;
private class SubdividedChild {
SimpleStringProperty name = new SimpleStringProperty();
SimpleStringProperty path = new SimpleStringProperty();
......@@ -2941,31 +2942,52 @@ public class EditorMenuBar extends MenuBar {
* Updates the 3D scene and the tree view.
*/
@SuppressWarnings("unchecked")
private void updateScene() {
private void updateScene(Component newRootComponent) {
if (!modelLoaded()) {
return;
}
// Save the expanded state of the tree items.
HashMap<String, Boolean> itemStates = Nomad3DEditor.getInstance().getTreeViewExpandedStates(Nomad3DEditor.getInstance().getModel().getRoot().getTreeItem());
HashMap<String, Boolean> itemStates = Nomad3DEditor.getInstance().getTreeViewExpandedStates(newRootComponent.getTreeItem());
// We need to reset the movement here.
// We prefer to do it in any case because even for axis edition, the change of axis (when cancelling) resets the axis to the initial clone.
// It would be necessary to see how to do be able to keep the axis states in the case of reset.
Nomad3DEditor.getInstance().getModel().resetMovement();
Nomad3DEditor.getInstance().getModel().clearSelection();
Nomad3DEditor.getInstance().getRoot().getChildren().remove(Nomad3DEditor.getInstance().getModel().getRoot().getSceneNode());
Nomad3DEditor.getInstance().getRoot().getChildren().remove(Nomad3DEditor.getInstance().getModel().getDisplayedRoot().getSceneNode());
Nomad3DEditor.getInstance().getModel().computeSceneHierarchies(activeLod);
Nomad3DEditor.getInstance().getRoot().getChildren().add(Nomad3DEditor.getInstance().getModel().getRoot().getSceneNode());
Nomad3DEditor.getInstance().getHierarchyView().setRoot(Nomad3DEditor.getInstance().getModel().getRoot().getTreeItem());
Nomad3DEditor.getInstance().getRoot().getChildren().add(newRootComponent.getSceneNode());
Nomad3DEditor.getInstance().getHierarchyView().setRoot(newRootComponent.getTreeItem());
// Restore the expanded state of the tree items.
Nomad3DEditor.getInstance().expandTreeView(Nomad3DEditor.getInstance().getModel().getRoot().getTreeItem(), itemStates);
Nomad3DEditor.getInstance().expandTreeView(newRootComponent.getTreeItem(), itemStates);
updateAxes();
updateWalls();
updateSystem();
updateFocus();
Nomad3DEditor.getInstance().getModel().setDisplayedRoot(newRootComponent);
}
/**
* Updates the 3D scene and the tree view.
*/
@SuppressWarnings("unchecked")
private void updateScene() {
updateScene(Nomad3DEditor.getInstance().getModel().getDisplayedRoot());
}
public void setDisplayedRoot(Component component) {
if (component == null) {
updateScene(Nomad3DEditor.getInstance().getModel().getRoot());
}
else {
updateScene(component);
}
}
}
......@@ -3,6 +3,7 @@
*/
package fr.ill.ics.n3d.gui;
import fr.ill.ics.n3d.Nomad3DEditor;
import fr.ill.ics.n3d.model.Component;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
......@@ -38,10 +39,8 @@ public class HierarchyCell extends CheckBoxTreeCell<Component> {
public HierarchyCell() {
super();
MenuItem printItem = new MenuItem("Collapse Children");
rigthClickMenu.getItems().add(printItem);
printItem.setOnAction(new EventHandler<ActionEvent>() {
MenuItem collapseItem = new MenuItem("Collapse Children");
collapseItem.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
// Get the component.
......@@ -53,6 +52,30 @@ public class HierarchyCell extends CheckBoxTreeCell<Component> {
}
}
});
rigthClickMenu.getItems().add(collapseItem);
MenuItem displayOnlyTheComponentItem = new MenuItem("Display Only The Component");
displayOnlyTheComponentItem.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
// Get the component.
Component component = getItem();
Nomad3DEditor.getInstance().setComponentAsRoot(component);
}
});
rigthClickMenu.getItems().add(displayOnlyTheComponentItem);
MenuItem displayAllTheComponentsItem = new MenuItem("Display All The Components");
displayAllTheComponentsItem.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
Nomad3DEditor.getInstance().setComponentAsRoot(null);
}
});
rigthClickMenu.getItems().add(displayAllTheComponentsItem);
}
@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