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 { ...@@ -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 { ...@@ -127,7 +127,8 @@ 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();
...@@ -2941,31 +2942,52 @@ public class EditorMenuBar extends MenuBar { ...@@ -2941,31 +2942,52 @@ public class EditorMenuBar extends MenuBar {
* Updates the 3D scene and the tree view. * Updates the 3D scene and the tree view.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void updateScene() { private void updateScene(Component newRootComponent) {
if (!modelLoaded()) { if (!modelLoaded()) {
return; return;
} }
// Save the expanded state of the tree items. // 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 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. // 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. // 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().resetMovement();
Nomad3DEditor.getInstance().getModel().clearSelection(); 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().getModel().computeSceneHierarchies(activeLod);
Nomad3DEditor.getInstance().getRoot().getChildren().add(Nomad3DEditor.getInstance().getModel().getRoot().getSceneNode()); Nomad3DEditor.getInstance().getRoot().getChildren().add(newRootComponent.getSceneNode());
Nomad3DEditor.getInstance().getHierarchyView().setRoot(Nomad3DEditor.getInstance().getModel().getRoot().getTreeItem()); Nomad3DEditor.getInstance().getHierarchyView().setRoot(newRootComponent.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(newRootComponent.getTreeItem(), itemStates);
updateAxes(); updateAxes();
updateWalls(); updateWalls();
updateSystem(); updateSystem();
updateFocus(); 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 @@ ...@@ -3,6 +3,7 @@
*/ */
package fr.ill.ics.n3d.gui; package fr.ill.ics.n3d.gui;
import fr.ill.ics.n3d.Nomad3DEditor;
import fr.ill.ics.n3d.model.Component; import fr.ill.ics.n3d.model.Component;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.event.EventHandler; import javafx.event.EventHandler;
...@@ -38,10 +39,8 @@ public class HierarchyCell extends CheckBoxTreeCell<Component> { ...@@ -38,10 +39,8 @@ public class HierarchyCell extends CheckBoxTreeCell<Component> {
public HierarchyCell() { public HierarchyCell() {
super(); super();
MenuItem printItem = new MenuItem("Collapse Children"); MenuItem collapseItem = new MenuItem("Collapse Children");
rigthClickMenu.getItems().add(printItem); collapseItem.setOnAction(new EventHandler<ActionEvent>() {
printItem.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) { public void handle(ActionEvent t) {
// Get the component. // Get the component.
...@@ -53,6 +52,30 @@ public class HierarchyCell extends CheckBoxTreeCell<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 @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