Commit 258f6e75 authored by legoc's avatar legoc
Browse files

Choose a file for the viewer

parent f9a31d00
......@@ -117,7 +117,7 @@ public class Nomad3DEditor extends Application {
private EditorMenuBar menuBar;
/** Title of the editor's window. */
public final static String TITLE = "Nomad 3D editor";
public final static String TITLE = "Nomad3D Editor";
/** Length of the axes of the coordinate system (XYZ). */
private final static double AXIS_LENGTH = 50;
......
......@@ -263,30 +263,31 @@ public class EditorMenuBar extends MenuBar {
}
});
MenuItem saveViewerItem = new MenuItem("Save Viewer");
MenuItem saveViewerItem = new MenuItem("Save Current View");
saveViewerItem.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN));
saveViewerItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if (Nomad3DEditor.getInstance().getModel() != null) {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Save Viewer");
alert.setHeaderText("Hide the components with Bounding Box diagonal < " + hideBBDiagonal + "mm ?");
// Choose a file.
FileChooser chooser = new FileChooser();
chooser.setInitialFileName(Nomad3DEditor.getInstance().getModel().getName() + "-viewer.xml");
chooser.setInitialDirectory(new File(Nomad3DEditor.getInstance().getModel().getDirectoryPath()));
chooser.setTitle("Save Current View");
chooser.getExtensionFilters().addAll(new ExtensionFilter("XML files", "*.xml"));
File selectedFile = chooser.showSaveDialog(null);
Optional<ButtonType> option = alert.showAndWait();
if (selectedFile != null) {
if (option.get() == null) {
return;
}
else if (option.get() == ButtonType.OK) {
System.out.println("Selected file : " + selectedFile);
// Reset the mergeable components.
Nomad3DEditor.getInstance().getModel().getRoot().setMergeable();
// Save the viewer file.
Nomad3DExporter exporter = new Nomad3DExporter();
exporter.writeForViewer(Nomad3DEditor.getInstance().getModel(), hideBBDiagonal);
exporter.writeForViewer(Nomad3DEditor.getInstance().getModel(), hideBBDiagonal, selectedFile);
}
}
}
......@@ -2331,7 +2332,7 @@ public class EditorMenuBar extends MenuBar {
browseButton.setPrefSize(80, lineHeight);
browseButton.setOnAction(browseEvent -> {
FileChooser chooser = new FileChooser();
chooser.setTitle("Open model");
chooser.setTitle("Open Model");
if (!meshField.getText().isEmpty()) {
File meshFile = new File(meshField.getText());
if (meshFile.exists() && meshFile.getParentFile() != null && meshFile.getParentFile().exists()) {
......@@ -2685,7 +2686,7 @@ public class EditorMenuBar extends MenuBar {
///////////////////////////////////////////////////////////////////////////////////////
// Hide Using Bounding Boxes menu
MenuItem hideUsingBBsItem = new MenuItem("Hide Using BBs");
MenuItem hideUsingBBsItem = new MenuItem("Hide Using Bounding Boxes");
hideUsingBBsItem.setOnAction(event -> {
if (!modelLoaded()) {
return;
......
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