Commit cedc63dd authored by legoc's avatar legoc
Browse files

Starting with review of axis

parent bb85f247
......@@ -12,16 +12,16 @@ import java.util.logging.Logger;
import org.apache.commons.io.FilenameUtils;
import fr.ill.ics.n3d.Nomad3DEditor;
import fr.ill.ics.n3d.io.Nomad3DExporter;
import fr.ill.ics.n3d.io.Nomad3DImporter;
import fr.ill.ics.n3d.link.Nomad3DController;
import fr.ill.ics.n3d.link.NomadLinker;
import fr.ill.ics.n3d.model.Axis;
import fr.ill.ics.n3d.model.Axis.Type;
import fr.ill.ics.n3d.operations.Operations;
import fr.ill.ics.n3d.operations.OperationsSerializer;
import fr.ill.ics.n3d.model.Component;
import fr.ill.ics.n3d.model.ConfigParams;
import fr.ill.ics.n3d.operations.Operations;
import fr.ill.ics.n3d.operations.OperationsSerializer;
import fr.ill.ics.n3d.utils.ReferenceAxisList;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
......@@ -148,6 +148,9 @@ public class EditorMenuBar extends MenuBar {
Nomad3DEditor.getInstance().getStage().setScene(scene);
Nomad3DEditor.getInstance().getStage().setTitle(Nomad3DEditor.getInstance().getModel().getName() + " - " + Nomad3DEditor.TITLE);
update();
// Reset the list of reference axes.
ReferenceAxisList.getInstance().init(Nomad3DEditor.getInstance().getModel());
}
}
});
......@@ -175,7 +178,7 @@ public class EditorMenuBar extends MenuBar {
});
Menu axisMenu = new Menu("Axis");
MenuItem addAxisItem = new MenuItem("Modify axis");
MenuItem addAxisItem = new MenuItem("Define axis");
addAxisItem.setOnAction(event -> {
if (Nomad3DEditor.getInstance().getModel() == null || Nomad3DEditor.getInstance().getModel().getRoot() == null) {
return;
......@@ -254,6 +257,13 @@ public class EditorMenuBar extends MenuBar {
}
});
Label referenceLabel = new Label("Reference : ");
ObservableList<String> references = FXCollections.observableArrayList(ReferenceAxisList.getInstance().getNames());
ComboBox<String> referenceBox = new ComboBox<>(references);
Label dirLabel = new Label("Direction : ");
Label xDirLabel = new Label("X : ");
Label yDirLabel = new Label("Y : ");
......@@ -391,26 +401,33 @@ public class EditorMenuBar extends MenuBar {
GridPane typePane = new GridPane();
typePane.setHgap(10);
typePane.setVgap(5);
typePane.setAlignment(Pos.CENTER);
typePane.setAlignment(Pos.TOP_LEFT);
typePane.addRow(0, typeLabel, typeBox);
typePane.addRow(1, dirLabel, xDirLabel, xDirField, yDirLabel, yDirField, zDirLabel, zDirField);
typePane.addRow(2, posLabel, xPosLabel, xPosField, yPosLabel, yPosField, zPosLabel, zPosField);
typePane.addRow(1, referenceLabel, referenceBox);
GridPane.setColumnSpan(typeBox, GridPane.REMAINING);
addPane.addRow(0, typePane);
GridPane vectorsPane = new GridPane();
vectorsPane.setHgap(10);
vectorsPane.setVgap(5);
vectorsPane.setAlignment(Pos.TOP_LEFT);
vectorsPane.addRow(0, dirLabel, xDirLabel, xDirField, yDirLabel, yDirField, zDirLabel, zDirField);
vectorsPane.addRow(1, posLabel, xPosLabel, xPosField, yPosLabel, yPosField, zPosLabel, zPosField);
addPane.addRow(1, vectorsPane);
GridPane conveniencePane = new GridPane();
conveniencePane.setHgap(10);
conveniencePane.setVgap(5);
conveniencePane.setAlignment(Pos.CENTER);
conveniencePane.addRow(0, reverseButton, centerButton);
addPane.addRow(1, conveniencePane);
addPane.addRow(2, conveniencePane);
GridPane.setMargin(conveniencePane, new Insets(10));
GridPane buttonPane = new GridPane();
buttonPane.setHgap(10);
buttonPane.setAlignment(Pos.CENTER);
buttonPane.addRow(0, okButton, cancelButton);
addPane.addRow(2, buttonPane);
addPane.addRow(3, buttonPane);
Nomad3DEditor.getInstance().getAxisBuilder().start(selectedAxis, Nomad3DEditor.getInstance().getRoot(), Nomad3DEditor.getInstance().getControls(), modified);
updateThread.start();
......
package fr.ill.ics.n3d.utils;
import java.util.ArrayList;
import java.util.List;
import fr.ill.ics.n3d.model.Axis;
import fr.ill.ics.n3d.model.Component;
import fr.ill.ics.n3d.model.Model;
/**
* Class storing the list of reference axis.
*/
public class ReferenceAxisList {
private static ReferenceAxisList instance = new ReferenceAxisList();
private ArrayList<Axis> list = new ArrayList<Axis>();
/**
* Gets the instance of the ReferenceAxisList class.
* @return The single instance.
*/
public static ReferenceAxisList getInstance() {
return instance;
}
/**
* Initializes the list.
* @param model The model.
*/
public void init(Model model) {
// Reset the list.
list.clear();
// Traverse all the components.
init(model.getRoot());
}
/**
* Gets the list of reference axes.
* @return The list of reference axes.
*/
public ArrayList<Axis> get() {
return list;
}
/**
* Gets the list of the names of reference axes.
* @return The list of names.
*/
public ArrayList<String> getNames() {
ArrayList<String> result = new ArrayList<String>();
// Get the names.
for (Axis axis : list) {
result.add(axis.getName());
}
return result;
}
/**
* Initializes the list recursively.
* @param component The component.
*/
private void init(Component component) {
// Add all the reference axes of the component.
list.addAll(component.getReferenceAxes());
// Traverse the children.
List<Component> children = component.getChildren();
for (Component child : children) {
init(child);
}
}
}
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