Commit 8969d07b authored by Ivan Dages's avatar Ivan Dages
Browse files

calibrate axis : remove limits

parent 86b8401c
...@@ -499,7 +499,18 @@ public class EditorMenuBar extends MenuBar { ...@@ -499,7 +499,18 @@ public class EditorMenuBar extends MenuBar {
// Invalid input, nothing to do // Invalid input, nothing to do
} }
}); });
valuePane.addRow(0, valueText, valueField); Label unitLabel = new Label();
switch (selectedAxis.getType()) {
case TRANSLATION:
unitLabel.setText("mm");
break;
case ROTATION:
unitLabel.setText("");
break;
default:
break;
}
valuePane.addRow(0, valueText, valueField, unitLabel);
Thread valueThread = new Thread(new Runnable() { Thread valueThread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -547,14 +558,9 @@ public class EditorMenuBar extends MenuBar { ...@@ -547,14 +558,9 @@ public class EditorMenuBar extends MenuBar {
buttonsPane.setAlignment(Pos.CENTER); buttonsPane.setAlignment(Pos.CENTER);
scenePane.addRow(2, buttonsPane); scenePane.addRow(2, buttonsPane);
GridPane.setMargin(buttonsPane, new Insets(10)); GridPane.setMargin(buttonsPane, new Insets(10));
Button okButton = new Button("OK");
okButton.setDefaultButton(true);
okButton.setOnAction(okEvent -> {
calibrateStage.close();
valueThread.interrupt();
});
Button resetButton = new Button("Reset"); Button resetButton = new Button("Reset");
resetButton.setPrefWidth(100);
final double minInit = selectedAxis.getMinValue(); final double minInit = selectedAxis.getMinValue();
final double medianInit = selectedAxis.getMedianValue(); final double medianInit = selectedAxis.getMedianValue();
final double maxInit = selectedAxis.getMaxValue(); final double maxInit = selectedAxis.getMaxValue();
...@@ -565,13 +571,28 @@ public class EditorMenuBar extends MenuBar { ...@@ -565,13 +571,28 @@ public class EditorMenuBar extends MenuBar {
selectedAxis.setMaxValue(maxInit); selectedAxis.setMaxValue(maxInit);
selectedAxis.move(valueInit - selectedAxis.getValue()); selectedAxis.move(valueInit - selectedAxis.getValue());
}); });
Button rmLimitsButton = new Button("Remove limits");
rmLimitsButton.setPrefWidth(resetButton.getPrefWidth());
rmLimitsButton.setOnAction(rmEvent -> {
selectedAxis.setMinValue(Double.NEGATIVE_INFINITY);
selectedAxis.setMaxValue(Double.POSITIVE_INFINITY);
});
Button okButton = new Button("OK");
okButton.setDefaultButton(true);
okButton.setOnAction(okEvent -> {
calibrateStage.close();
valueThread.interrupt();
});
Button cancelButton = new Button("Cancel"); Button cancelButton = new Button("Cancel");
cancelButton.setCancelButton(true); cancelButton.setCancelButton(true);
cancelButton.setOnAction(cancelEvent -> { cancelButton.setOnAction(cancelEvent -> {
resetButton.getOnAction().handle(null); resetButton.getOnAction().handle(null);
okButton.getOnAction().handle(null); okButton.getOnAction().handle(null);
}); });
buttonsPane.addRow(1, okButton, resetButton, cancelButton); buttonsPane.addRow(0, resetButton, rmLimitsButton);
buttonsPane.addRow(1, okButton, cancelButton);
GridPane.setHalignment(okButton, HPos.RIGHT);
GridPane.setHalignment(cancelButton, HPos.LEFT);
valueThread.start(); valueThread.start();
calibrateStage.show(); calibrateStage.show();
...@@ -1276,7 +1297,7 @@ public class EditorMenuBar extends MenuBar { ...@@ -1276,7 +1297,7 @@ public class EditorMenuBar extends MenuBar {
modifyButton.setDefaultButton(true); modifyButton.setDefaultButton(true);
buttonsPane.addColumn(0, modifyButton); buttonsPane.addColumn(0, modifyButton);
modifyButton.setOnAction(modifyEvent -> { modifyButton.setOnAction(modifyEvent -> {
Nomad3DEditor.getInstance().getModel().getRoot().saveCurrentConfiguration(nameField.getText()); Nomad3DEditor.getInstance().getModel().getRoot().saveCurrentConfiguration(nameField.getText(), activeConfiguration);
updateConfigMenus(); updateConfigMenus();
modifyStage.close(); modifyStage.close();
}); });
...@@ -1291,17 +1312,17 @@ public class EditorMenuBar extends MenuBar { ...@@ -1291,17 +1312,17 @@ public class EditorMenuBar extends MenuBar {
}); });
MenuItem saveMedianConfigItem = new MenuItem("Save median configuration"); MenuItem saveMedianConfigItem = new MenuItem("Save median configuration");
saveMedianConfigItem.setOnAction(event -> { saveMedianConfigItem.setOnAction(event -> {
Nomad3DEditor.getInstance().getModel().getRoot().saveMedianConfiguration(); Nomad3DEditor.getInstance().getModel().getRoot().saveMedianConfiguration(activeConfiguration);
updateConfigMenus(); updateConfigMenus();
}); });
MenuItem saveMinConfigItem = new MenuItem("Save min configuration"); MenuItem saveMinConfigItem = new MenuItem("Save min configuration");
saveMinConfigItem.setOnAction(event -> { saveMinConfigItem.setOnAction(event -> {
Nomad3DEditor.getInstance().getModel().getRoot().saveMinConfiguration(); Nomad3DEditor.getInstance().getModel().getRoot().saveMinConfiguration(activeConfiguration);
updateConfigMenus(); updateConfigMenus();
}); });
MenuItem saveMaxConfigItem = new MenuItem("Save max configuration"); MenuItem saveMaxConfigItem = new MenuItem("Save max configuration");
saveMaxConfigItem.setOnAction(event -> { saveMaxConfigItem.setOnAction(event -> {
Nomad3DEditor.getInstance().getModel().getRoot().saveMaxConfiguration(); Nomad3DEditor.getInstance().getModel().getRoot().saveMaxConfiguration(activeConfiguration);
updateConfigMenus(); updateConfigMenus();
}); });
this.removeConfig = new Menu("Remove configuration"); this.removeConfig = new Menu("Remove configuration");
...@@ -1536,9 +1557,10 @@ public class EditorMenuBar extends MenuBar { ...@@ -1536,9 +1557,10 @@ public class EditorMenuBar extends MenuBar {
return; return;
} }
for (Component comp : Nomad3DEditor.getInstance().getModel().getSelection()) { for (Component comp : Nomad3DEditor.getInstance().getModel().getSelection()) {
comp.setConfigurationVisibility(false, activeConfiguration, null, false); comp.setConfigurationVisibility(false, activeConfiguration, null, true, false);
comp.setVisible(false, activeConfiguration, false); comp.setVisible(false, activeConfiguration, false);
} }
Nomad3DEditor.getInstance().getModel().clearSelection();
}); });
this.selection.getItems().addAll(selectAllItem, unselectAllItem, this.selection.getItems().addAll(selectAllItem, unselectAllItem,
new SeparatorMenuItem(), new SeparatorMenuItem(),
...@@ -1607,7 +1629,7 @@ public class EditorMenuBar extends MenuBar { ...@@ -1607,7 +1629,7 @@ public class EditorMenuBar extends MenuBar {
wikiItem.setGraphic(urlView); wikiItem.setGraphic(urlView);
wikiItem.setOnAction(event -> { wikiItem.setOnAction(event -> {
try { try {
java.awt.Desktop.getDesktop().browse(new java.net.URI("https://code.ill.fr/instrument-control/protos/nomad-3d/nomad-3d-commons/wikis/home")); java.awt.Desktop.getDesktop().browse(new java.net.URI("https://code.ill.fr/instrument-control/protos/nomad-3d/nomad-3d-editor/wikis/home"));
} catch (Exception e) { } catch (Exception e) {
Logger.getLogger("nomad-3d").severe(e.getMessage()); Logger.getLogger("nomad-3d").severe(e.getMessage());
e.printStackTrace(); e.printStackTrace();
...@@ -1722,7 +1744,10 @@ public class EditorMenuBar extends MenuBar { ...@@ -1722,7 +1744,10 @@ public class EditorMenuBar extends MenuBar {
return; return;
} }
activeConfiguration = Nomad3DEditor.getInstance().getModel().getRoot().getConfigurations().get(0).getConfiguration(); // Reset active configuration if needed
if (Nomad3DEditor.getInstance().getModel().getRoot().getConfigurationByName(activeConfiguration) == null) {
activeConfiguration = Nomad3DEditor.getInstance().getModel().getRoot().getConfigurations().get(0).getConfiguration();
}
// Show configuration // Show configuration
this.showConfig.getItems().clear(); this.showConfig.getItems().clear();
...@@ -1766,7 +1791,7 @@ public class EditorMenuBar extends MenuBar { ...@@ -1766,7 +1791,7 @@ public class EditorMenuBar extends MenuBar {
MenuItem configItem = new MenuItem(config.getConfiguration()); MenuItem configItem = new MenuItem(config.getConfiguration());
configItem.setOnAction(event -> { configItem.setOnAction(event -> {
for (Component comp : Nomad3DEditor.getInstance().getModel().getSelection()) { for (Component comp : Nomad3DEditor.getInstance().getModel().getSelection()) {
comp.setConfigurationVisibility(true, configItem.getText(), activeConfiguration, false); comp.setConfigurationVisibility(true, configItem.getText(), activeConfiguration, false, false);
} }
Nomad3DEditor.getInstance().getModel().showConfiguration(activeConfiguration); Nomad3DEditor.getInstance().getModel().showConfiguration(activeConfiguration);
}); });
......
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