Commit 32384275 authored by legoc's avatar legoc
Browse files

Added hide component using BBs feature

parent 0cab1778
......@@ -126,6 +126,13 @@ public class EditorMenuBar extends MenuBar {
/** The active level of detail. */
private int activeLod;
/** Hide BB type. */
private final static String LESS_THAN = "<";
private final static String GREATER_THAN = ">";
private String hideBBType = LESS_THAN;
private double hideBBDiagonal = 50.0; // 5cm
/** True if there are some operations not saved. */
private boolean modified = false;
......@@ -2563,7 +2570,7 @@ public class EditorMenuBar extends MenuBar {
this.selection = new Menu("Selection");
MenuItem allItem = new MenuItem("Show all");
MenuItem allItem = new MenuItem("Show All");
allItem.setAccelerator(new KeyCodeCombination(KeyCode.A));
allItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
......@@ -2610,6 +2617,93 @@ public class EditorMenuBar extends MenuBar {
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Hide Using Bounding Boxes menu
MenuItem hideUsingBBsItem = new MenuItem("Hide Using BBs");
hideUsingBBsItem.setOnAction(event -> {
if (!modelLoaded()) {
return;
}
///////////////////////////////////////////////////////////////////////////////////
// Diagonal
Label diagonalLabel = new Label("Diagonal ");
ObservableList<String> typeList = FXCollections.observableArrayList(LESS_THAN, GREATER_THAN);
ComboBox<String> typeBox = new ComboBox<String>(typeList);
typeBox.getSelectionModel().select(hideBBType);
TextField valueField = new TextField("");
valueField.setAlignment(Pos.TOP_LEFT);
valueField.setPrefWidth(100);
valueField.setText(Double.toString(hideBBDiagonal));
Label unitLabel = new Label("mm");
///////////////////////////////////////////////////////////////////////////////////
// Layout
GridPane scenePane = new GridPane();
scenePane.setAlignment(Pos.CENTER);
Scene scene = new Scene(scenePane);
Stage stage = new Stage(StageStyle.UTILITY);
stage.setTitle("Hide Components Using Bounding Boxes");
stage.setScene(scene);
stage.initOwner(Nomad3DEditor.getInstance().getStage());
GridPane mainPane = new GridPane();
mainPane.setVgap(5);
mainPane.setHgap(10);
mainPane.setAlignment(Pos.CENTER);
scenePane.addRow(0, mainPane);
GridPane.setMargin(mainPane, new Insets(10));
GridPane movePane = new GridPane();
movePane.setVgap(5);
movePane.setHgap(10);
movePane.setAlignment(Pos.CENTER);
scenePane.addRow(0, movePane);
GridPane.setMargin(movePane, new Insets(10));
movePane.addRow(1, diagonalLabel, typeBox, valueField, unitLabel);
class Apply {
void doIt() {
// Check the selection.
if (Nomad3DEditor.getInstance().getModel() == null || Nomad3DEditor.getInstance().getModel().getRoot() == null) {
return;
}
hideBBDiagonal = Double.parseDouble(valueField.getText());
if (hideBBType.equals(LESS_THAN)) {
Nomad3DEditor.getInstance().getModel().hideComponentsUsingBBs(true, hideBBDiagonal);
}
else {
Nomad3DEditor.getInstance().getModel().hideComponentsUsingBBs(false, hideBBDiagonal);
}
}
}
typeBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
hideBBType = newValue;
new Apply().doIt();
}
});
valueField.setOnAction(valueEvent -> {
new Apply().doIt();
});
mainPane.addRow(0, movePane);
stage.showAndWait();
});
MenuItem markWallItem = new MenuItem("Mark Selection As Walls");
markWallItem.setAccelerator(new KeyCodeCombination(KeyCode.W));
markWallItem.setOnAction(new EventHandler<ActionEvent>() {
......@@ -2633,7 +2727,7 @@ public class EditorMenuBar extends MenuBar {
}
});
this.selection.getItems().addAll(allItem, onlySelectionItem, hideSelectionItem, unselectAllItem, new SeparatorMenuItem(), markWallItem, markPartsItem);
this.selection.getItems().addAll(allItem, onlySelectionItem, hideSelectionItem, unselectAllItem, hideUsingBBsItem, new SeparatorMenuItem(), markWallItem, markPartsItem);
this.help = new Menu("Help");
MenuItem cameraHelpItem = new MenuItem("Camera");
......
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