Commit 14640457 authored by Ivan Dages's avatar Ivan Dages
Browse files

configurations edition

parent 0dbbf97c
...@@ -19,6 +19,7 @@ import javafx.beans.value.ChangeListener; ...@@ -19,6 +19,7 @@ import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.geometry.Bounds; import javafx.geometry.Bounds;
import javafx.geometry.Point2D; import javafx.geometry.Point2D;
import javafx.geometry.Point3D;
import javafx.scene.AmbientLight; import javafx.scene.AmbientLight;
import javafx.scene.Camera; import javafx.scene.Camera;
import javafx.scene.Cursor; import javafx.scene.Cursor;
...@@ -335,6 +336,13 @@ public class Nomad3DEditor extends Application { ...@@ -335,6 +336,13 @@ public class Nomad3DEditor extends Application {
scene.setFill(Color.WHITE); scene.setFill(Color.WHITE);
buildEventHandlers(axesGroup); buildEventHandlers(axesGroup);
// Initialize the camera position
Bounds rootBounds = this.model.getRoot().getSceneNode().localToScene(this.model.getRoot().getSceneNode().getBoundsInLocal());
Point3D rootCenter = new Point3D(rootBounds.getMinX(), rootBounds.getMinY(), rootBounds.getMinZ());
rootCenter = rootCenter.add(rootBounds.getWidth() / 2.0, rootBounds.getHeight() / 2.0, rootBounds.getDepth() / 2.0);
this.controls.setCenter(rootCenter);
this.controls.zoom(-1.0 * ((new Point3D(rootBounds.getWidth(), rootBounds.getHeight(), rootBounds.getDepth())).magnitude()), false, false);
return scene; return scene;
} }
......
...@@ -82,6 +82,8 @@ public class EditorMenuBar extends MenuBar { ...@@ -82,6 +82,8 @@ public class EditorMenuBar extends MenuBar {
/** Selection menu. */ /** Selection menu. */
private Menu selection; private Menu selection;
private Menu showSelectionInConfig;
/** Help menu. */ /** Help menu. */
private Menu help; private Menu help;
...@@ -686,10 +688,8 @@ public class EditorMenuBar extends MenuBar { ...@@ -686,10 +688,8 @@ public class EditorMenuBar extends MenuBar {
}); });
scenePane.addRow(0, searchField); scenePane.addRow(0, searchField);
searchField.setPrefWidth(sceneWidth);
GridPane.setColumnSpan(searchField, GridPane.REMAINING); GridPane.setColumnSpan(searchField, GridPane.REMAINING);
scenePane.addRow(1, controllersList); scenePane.addRow(1, controllersList);
controllersList.setPrefWidth(sceneWidth);
GridPane.setColumnSpan(controllersList, GridPane.REMAINING); GridPane.setColumnSpan(controllersList, GridPane.REMAINING);
Button selectButton = new Button("Select"); Button selectButton = new Button("Select");
...@@ -735,6 +735,12 @@ public class EditorMenuBar extends MenuBar { ...@@ -735,6 +735,12 @@ public class EditorMenuBar extends MenuBar {
scenePane.addRow(2, selectButton, cancelButton); scenePane.addRow(2, selectButton, cancelButton);
GridPane.setMargin(scenePane, new Insets(10)); GridPane.setMargin(scenePane, new Insets(10));
scenePane.setPrefSize(sceneWidth, 500);
searchField.prefWidthProperty().bind(scenePane.widthProperty());
controllersList.prefWidthProperty().bind(scenePane.widthProperty());
controllersList.prefHeightProperty().bind(scenePane.heightProperty());
selectButton.prefWidthProperty().bind(scenePane.widthProperty());
cancelButton.prefWidthProperty().bind(scenePane.widthProperty());
controllersList.requestFocus(); controllersList.requestFocus();
linkStage.show(); linkStage.show();
...@@ -1037,7 +1043,6 @@ public class EditorMenuBar extends MenuBar { ...@@ -1037,7 +1043,6 @@ public class EditorMenuBar extends MenuBar {
} }
}); });
this.showConfig = new Menu("Show configuration"); this.showConfig = new Menu("Show configuration");
updateConfigMenus();
MenuItem resetMoveItem = new MenuItem("Reset movement"); MenuItem resetMoveItem = new MenuItem("Reset movement");
resetMoveItem.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.SHIFT_DOWN)); resetMoveItem.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.SHIFT_DOWN));
resetMoveItem.setOnAction(new EventHandler<ActionEvent>() { resetMoveItem.setOnAction(new EventHandler<ActionEvent>() {
...@@ -1186,9 +1191,22 @@ public class EditorMenuBar extends MenuBar { ...@@ -1186,9 +1191,22 @@ public class EditorMenuBar extends MenuBar {
updateWalls(); updateWalls();
} }
}); });
this.showSelectionInConfig = new Menu("Show selection in current configuration");
MenuItem hideInConfigItem = new MenuItem("Hide selection in current configuration");
hideInConfigItem.setOnAction(event -> {
if (Nomad3DEditor.getInstance().getModel() == null || activeConfiguration == null) {
return;
}
for (Component comp : Nomad3DEditor.getInstance().getModel().getSelection()) {
comp.setConfigurationVisibility(false, activeConfiguration, null, false);
comp.setVisible(false, activeConfiguration, false);
}
});
this.selection.getItems().addAll(selectAllItem, unselectAllItem, this.selection.getItems().addAll(selectAllItem, unselectAllItem,
new SeparatorMenuItem(), new SeparatorMenuItem(),
showSelectionItem, hideSelectionItem, focusSelectionItem, showSelectionItem, hideSelectionItem, focusSelectionItem,
new SeparatorMenuItem(),
showSelectionInConfig, hideInConfigItem,
new SeparatorMenuItem(), new SeparatorMenuItem(),
markWallItem, markPartsItem); markWallItem, markPartsItem);
...@@ -1245,6 +1263,8 @@ public class EditorMenuBar extends MenuBar { ...@@ -1245,6 +1263,8 @@ public class EditorMenuBar extends MenuBar {
helpStage.show(); helpStage.show();
}); });
this.help.getItems().addAll(cameraHelpItem); this.help.getItems().addAll(cameraHelpItem);
update();
this.getMenus().addAll(this.file, this.edit, this.view, this.selection, this.help); this.getMenus().addAll(this.file, this.edit, this.view, this.selection, this.help);
} }
...@@ -1282,6 +1302,11 @@ public class EditorMenuBar extends MenuBar { ...@@ -1282,6 +1302,11 @@ public class EditorMenuBar extends MenuBar {
} }
return modifiedComponent; return modifiedComponent;
} }
private boolean modelLoaded() {
return !(Nomad3DEditor.getInstance().getModel() == null
|| Nomad3DEditor.getInstance().getModel().getRoot() == null);
}
/** /**
* Updates the menu bar and the Nomad3DEditor.getInstance() accordingly. * Updates the menu bar and the Nomad3DEditor.getInstance() accordingly.
...@@ -1298,7 +1323,7 @@ public class EditorMenuBar extends MenuBar { ...@@ -1298,7 +1323,7 @@ public class EditorMenuBar extends MenuBar {
private void updateLodMenu() { private void updateLodMenu() {
Logger.getLogger("nomad-3d").info("Updating LODs..."); Logger.getLogger("nomad-3d").info("Updating LODs...");
if (Nomad3DEditor.getInstance().getModel() == null || Nomad3DEditor.getInstance().getModel().getRoot() == null) { if (!modelLoaded()) {
return; return;
} }
this.lodMenu.getItems().clear(); this.lodMenu.getItems().clear();
...@@ -1330,6 +1355,9 @@ public class EditorMenuBar extends MenuBar { ...@@ -1330,6 +1355,9 @@ public class EditorMenuBar extends MenuBar {
* Updates the camera. * Updates the camera.
*/ */
private void updateCamera() { private void updateCamera() {
if (!modelLoaded()) {
return;
}
Nomad3DEditor.getInstance().buildCamera(); Nomad3DEditor.getInstance().buildCamera();
Nomad3DEditor.getInstance().getControls().setTarget(Nomad3DEditor.getInstance().getCamera()); Nomad3DEditor.getInstance().getControls().setTarget(Nomad3DEditor.getInstance().getCamera());
Nomad3DEditor.getInstance().getControls().update(); Nomad3DEditor.getInstance().getControls().update();
...@@ -1339,7 +1367,7 @@ public class EditorMenuBar extends MenuBar { ...@@ -1339,7 +1367,7 @@ public class EditorMenuBar extends MenuBar {
* Updates the "show configuration" sub-menu. * Updates the "show configuration" sub-menu.
*/ */
private void updateConfigMenus() { private void updateConfigMenus() {
if (Nomad3DEditor.getInstance().getModel() == null || Nomad3DEditor.getInstance().getModel().getRoot() == null) { if (!modelLoaded()) {
return; return;
} }
...@@ -1380,13 +1408,26 @@ public class EditorMenuBar extends MenuBar { ...@@ -1380,13 +1408,26 @@ public class EditorMenuBar extends MenuBar {
}); });
this.removeConfig.getItems().add(configItem); this.removeConfig.getItems().add(configItem);
} }
// Show selection in current configuration
this.showSelectionInConfig.getItems().clear();
for (ConfigParams config : Nomad3DEditor.getInstance().getModel().getRoot().getConfigurations()) {
MenuItem configItem = new MenuItem(config.getConfiguration());
configItem.setOnAction(event -> {
for (Component comp : Nomad3DEditor.getInstance().getModel().getSelection()) {
comp.setConfigurationVisibility(true, configItem.getText(), activeConfiguration, false);
}
Nomad3DEditor.getInstance().getModel().showConfiguration(activeConfiguration);
});
this.showSelectionInConfig.getItems().add(configItem);
}
} }
/** /**
* Updates the axes visibility.. * Updates the axes visibility..
*/ */
private void updateAxes() { private void updateAxes() {
if (Nomad3DEditor.getInstance().getModel() != null && Nomad3DEditor.getInstance().getModel().getRoot() != null) { if (modelLoaded()) {
Nomad3DEditor.getInstance().getModel().setVisualizeAxes(showAxes); Nomad3DEditor.getInstance().getModel().setVisualizeAxes(showAxes);
} }
} }
...@@ -1395,7 +1436,7 @@ public class EditorMenuBar extends MenuBar { ...@@ -1395,7 +1436,7 @@ public class EditorMenuBar extends MenuBar {
* Updates the walls visibility. * Updates the walls visibility.
*/ */
private void updateWalls() { private void updateWalls() {
if(Nomad3DEditor.getInstance().getModel() != null && Nomad3DEditor.getInstance().getModel().getRoot() != null) { if(modelLoaded()) {
Nomad3DEditor.getInstance().getModel().getRoot().setWallsVisible(showWalls, activeConfiguration); Nomad3DEditor.getInstance().getModel().getRoot().setWallsVisible(showWalls, activeConfiguration);
if (!showWalls) { if (!showWalls) {
// Hidden parts are unselected // Hidden parts are unselected
...@@ -1412,7 +1453,7 @@ public class EditorMenuBar extends MenuBar { ...@@ -1412,7 +1453,7 @@ public class EditorMenuBar extends MenuBar {
* Updates the coordinate system visibility. * Updates the coordinate system visibility.
*/ */
private void updateSystem() { private void updateSystem() {
if (Nomad3DEditor.getInstance().getControls() != null && Nomad3DEditor.getInstance().getControls().getCenterNode() != null) { if (modelLoaded() && Nomad3DEditor.getInstance().getControls().getCenterNode() != null) {
Nomad3DEditor.getInstance().getControls().getCenterNode().setVisible(showSystem); Nomad3DEditor.getInstance().getControls().getCenterNode().setVisible(showSystem);
} }
} }
...@@ -1421,9 +1462,9 @@ public class EditorMenuBar extends MenuBar { ...@@ -1421,9 +1462,9 @@ public class EditorMenuBar extends MenuBar {
* Updates the focus of the selection. * Updates the focus of the selection.
*/ */
private void updateFocus() { private void updateFocus() {
if (Nomad3DEditor.getInstance().getModel() == null || Nomad3DEditor.getInstance().getModel().getRoot() == null) { if (!modelLoaded()) {
return; return;
} }
Nomad3DEditor.getInstance().getModel().getRoot().focusSelection(Nomad3DEditor.getInstance().getModel().getSelection(), focusSelection, activeConfiguration, true); Nomad3DEditor.getInstance().getModel().getRoot().focusSelection(Nomad3DEditor.getInstance().getModel().getSelection(), focusSelection, activeConfiguration, true);
...@@ -1435,6 +1476,10 @@ public class EditorMenuBar extends MenuBar { ...@@ -1435,6 +1476,10 @@ public class EditorMenuBar extends MenuBar {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void updateScene() { private void updateScene() {
if (!modelLoaded()) {
return;
}
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());
......
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