Commit 8b28597f authored by legoc's avatar legoc
Browse files

Implemented show selection from a view

parent b126fce3
......@@ -4,11 +4,11 @@ $ mvn clean package
The application can be launched with a connection to Nomad e.g:
$ java -jar target/nomad-3d-editor-0.0.6-full.jar "{\"name\":\"n3d\", \"server\":\"tcp://localhost:7000\"}"
$ java -jar target/nomad-3d-editor-0.0.7-full.jar "{\"name\":\"n3d\", \"server\":\"tcp://localhost:7000\"}"
Or standalone:
$ java -jar target/nomad-3d-editor-0.0.6-full.jar --no-link
$ java -jar target/nomad-3d-editor-0.0.7-full.jar --no-link
For windows, ensure that jzmq.dll and libzmq.dll are accessible from the path.
......
......@@ -4,6 +4,7 @@ import java.io.File;
import java.util.HashMap;
import java.util.Locale;
import java.util.Optional;
import java.util.Set;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
......@@ -452,6 +453,24 @@ public class Nomad3DEditor extends Application {
return scene;
}
public void loadView(String modelPath) {
Nomad3DImporter n3dImporter = new Nomad3DImporter();
if (modelPath != null) {
n3dImporter.read(modelPath);
} else {
n3dImporter.read();
}
if (n3dImporter.getModel().getRoot() != null) {
Model model = n3dImporter.getModel();
Set<String> componentList = model.getRoot().getComponentNames();
// Set invisible the component whose name is not in the list.
this.model.getRoot().showSelection(componentList);
}
}
/**
* Sets the camera center and zoom according to the component.
* @param component
......
package fr.ill.ics.n3d.gui;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.math.RoundingMode;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.Scanner;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -16,13 +10,10 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;
import java.util.Set;
import java.util.logging.Logger;
import fr.ill.ics.n3d.util.CameraTableExporter;
import fr.ill.ics.n3d.Nomad3DEditor;
import fr.ill.ics.n3d.gui.EditorMenuBar.CameraTableEntry;
import fr.ill.ics.n3d.io.Nomad3DExporter;
import fr.ill.ics.n3d.io.Nomad3DImporter;
import fr.ill.ics.n3d.link.Nomad3DController;
......@@ -43,6 +34,7 @@ import fr.ill.ics.n3d.operations.RemoveReferenceAxisOperation;
import fr.ill.ics.n3d.operations.RenameComponentOperation;
import fr.ill.ics.n3d.operations.SetAxisOperation;
import fr.ill.ics.n3d.operations.SetMaterialOperation;
import fr.ill.ics.n3d.util.CameraTableExporter;
import javafx.application.Platform;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
......@@ -52,7 +44,6 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Bounds;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
......@@ -73,7 +64,6 @@ import javafx.scene.control.MenuItem;
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.Slider;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.CellDataFeatures;
import javafx.scene.control.TableColumn.CellEditEvent;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
......@@ -84,21 +74,17 @@ import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Sphere;
import javafx.scene.text.TextAlignment;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Callback;
import javafx.util.converter.DoubleStringConverter;
import javafx.geometry.Point3D;
/**
* Menu bar of the Nomad3DEditor.getInstance().
......@@ -2577,7 +2563,7 @@ public class EditorMenuBar extends MenuBar {
}
});
MenuItem onlySelectionItem = new MenuItem("Hide Non Selection");
MenuItem onlySelectionItem = new MenuItem("Show Selection");
onlySelectionItem.setAccelerator(new KeyCodeCombination(KeyCode.S));
onlySelectionItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
......@@ -2588,7 +2574,7 @@ public class EditorMenuBar extends MenuBar {
});
MenuItem hideSelectionItem = new MenuItem("Hide Selection");
hideSelectionItem.setAccelerator(new KeyCodeCombination(KeyCode.Q));
hideSelectionItem.setAccelerator(new KeyCodeCombination(KeyCode.H));
hideSelectionItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
......@@ -2613,6 +2599,26 @@ public class EditorMenuBar extends MenuBar {
}
});
MenuItem loadViewItem = new MenuItem("Load View");
loadViewItem.setAccelerator(new KeyCodeCombination(KeyCode.L));
loadViewItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
// Choose a file.
FileChooser chooser = new FileChooser();
chooser.setInitialDirectory(new File(Nomad3DEditor.getInstance().getModel().getDirectoryPath()));
chooser.setTitle("Load View");
chooser.getExtensionFilters().addAll(new ExtensionFilter("XML files", "*.xml"));
File selectedFile = chooser.showOpenDialog(null);
if (selectedFile != null) {
String viewPath = selectedFile.getAbsolutePath();
Nomad3DEditor.getInstance().loadView(viewPath);
}
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Hide Using Bounding Boxes menu
MenuItem hideUsingBBsItem = new MenuItem("Hide Using Bounding Boxes");
......@@ -2703,7 +2709,7 @@ public class EditorMenuBar extends MenuBar {
}
});
this.selection.getItems().addAll(allItem, onlySelectionItem, hideSelectionItem, unselectAllItem,
this.selection.getItems().addAll(allItem, onlySelectionItem, hideSelectionItem, unselectAllItem, loadViewItem,
hideUsingBBsItem, new SeparatorMenuItem(), markWallItem, markPartsItem);
this.help = new Menu("Help");
......
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