Commit 0c4e3b60 authored by legoc's avatar legoc
Browse files

Added axis infos

parent 18f6fbad
......@@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.logging.Logger;
......@@ -20,6 +21,7 @@ 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.Component;
import fr.ill.ics.n3d.model.Component.AxisInfo;
import fr.ill.ics.n3d.model.ConfigParams;
import fr.ill.ics.n3d.model.ReferenceAxis;
import fr.ill.ics.n3d.model.ReferenceAxisList;
......@@ -57,8 +59,11 @@ import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
......@@ -72,6 +77,7 @@ import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
/**
* Menu bar of the Nomad3DEditor.getInstance().
*
......@@ -128,6 +134,33 @@ public class EditorMenuBar extends MenuBar {
LinkedList<SubdividedChild> subdividedChilds;
public static class AxisTableEntry {
private final SimpleStringProperty axisName;
private final SimpleStringProperty componentName;
private final SimpleStringProperty type;
private AxisTableEntry(String axisName, String componentName, String type) {
super();
this.axisName = new SimpleStringProperty(axisName);
this.componentName = new SimpleStringProperty(componentName);
this.type = new SimpleStringProperty(type);
}
public String getAxisName() {
return axisName.get();
}
public String getComponentName() {
return componentName.get();
}
public String getType() {
return type.get();
}
}
/**
* Constructor.
*/
......@@ -284,7 +317,7 @@ public class EditorMenuBar extends MenuBar {
// addScene.getStylesheets().add(classLoader.getResource("Style.css").toExternalForm());
Stage addStage = new Stage(StageStyle.UTILITY);
addStage.setTitle(editAxisItem.getText());
addStage.setTitle(editAxisItem.getText() + " of " + selectedComponent.getName());
addStage.setScene(addScene);
addStage.initOwner(Nomad3DEditor.getInstance().getStage());
......@@ -816,49 +849,63 @@ public class EditorMenuBar extends MenuBar {
///////////////////////////////////////////////////////////////////////////////////////
// Axis properties menu
MenuItem displayAxisItem = new MenuItem("Axis Properties");
displayAxisItem.setAccelerator(new KeyCodeCombination(KeyCode.P, KeyCombination.CONTROL_DOWN));
displayAxisItem.setOnAction(event -> {
if (Nomad3DEditor.getInstance().getModel() == null || Nomad3DEditor.getInstance().getRoot() == null) {
return;
}
final Component selectedComponent = selectComponent("");
final Axis selectedAxis = (selectedComponent == null) ? null : selectedComponent.getAxis();
if (selectedAxis == null) {
// Error alert already display in selectComponent(String)
return;
}
GridPane scenePane = new GridPane();
Scene displayScene = new Scene(scenePane);
Stage displayStage = new Stage(StageStyle.UTILITY);
displayStage.setWidth(300);
displayStage.setTitle(selectedComponent.getName());
displayStage.setWidth(500);
displayStage.setTitle(displayAxisItem.getText());
displayStage.setScene(displayScene);
displayStage.initOwner(Nomad3DEditor.getInstance().getStage());
GridPane nomadPane = new GridPane();
nomadPane.setVgap(5);
nomadPane.setHgap(10);
nomadPane.setAlignment(Pos.CENTER);
scenePane.addRow(0, nomadPane);
GridPane.setMargin(nomadPane, new Insets(10));
Nomad3DController selectedController = selectedAxis.getController();
if (selectedController == null) {
Label noLinkText = new Label("No controller associated with\n" + selectedComponent.getName());
noLinkText.setTextAlignment(TextAlignment.CENTER);
nomadPane.addColumn(0, noLinkText);
} else {
nomadPane.addRow(0, new Label("Name :"), new Label(selectedController.getName()));
nomadPane.addRow(1, new Label("Unit :"), new Label(selectedController.getType().toString()));
nomadPane.addRow(2, new Label("Actual Position :"), new Label(Double.toString(selectedController.getActualPosition())));
nomadPane.addRow(3, new Label("Offset Position :"), new Label(Double.toString(selectedController.getOffsetPosition())));
nomadPane.addRow(4, new Label("Setpoint Position :"), new Label(Double.toString(selectedController.getWantedPosition())));
nomadPane.addRow(5, new Label("Min Position :"), new Label(Double.toString(selectedController.getMinPosition())));
nomadPane.addRow(6, new Label("Max Position :"), new Label(Double.toString(selectedController.getMaxPosition())));
}
TableView<AxisTableEntry> tableView = new TableView();
tableView.setEditable(false);
TableColumn axisNameColumn = new TableColumn<>("Name");
axisNameColumn.setMinWidth(200);
axisNameColumn.setCellValueFactory(new PropertyValueFactory<AxisTableEntry, String>("axisName"));
TableColumn componentNameColumn = new TableColumn("Component Name");
componentNameColumn.setMinWidth(200);
componentNameColumn.setCellValueFactory(new PropertyValueFactory<AxisTableEntry, String>("componentName"));
TableColumn typeColumn = new TableColumn("Type");
typeColumn.setMinWidth(100);
typeColumn.setCellValueFactory(new PropertyValueFactory<AxisTableEntry, String>("type"));
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<AxisTableEntry>() {
@Override
public void changed(ObservableValue<? extends AxisTableEntry> observable, AxisTableEntry oldValue, AxisTableEntry newValue) {
// Find the components.
if (oldValue != null) {
Component oldComponent = Nomad3DEditor.getInstance().getModel().findComponent(oldValue.getComponentName());
oldComponent.getTreeItem().selectedProperty().set(false);
}
Component newComponent = Nomad3DEditor.getInstance().getModel().findComponent(newValue.getComponentName());
newComponent.getTreeItem().selectedProperty().set(true);
}
});
final ObservableList<AxisTableEntry> data = FXCollections.observableArrayList();
List<AxisInfo> axisInfos = Nomad3DEditor.getInstance().getModel().getAxisInfo();
for (AxisInfo info : axisInfos) {
data.add(new AxisTableEntry(info.getAxisName(), info.getComponentName(), info.getType().toString()));
}
tableView.setItems(data);
tableView.getColumns().addAll(axisNameColumn, componentNameColumn, typeColumn);
scenePane.addRow(0, tableView);
displayStage.show();
});
......
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