diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties
index da9d66e..f6e71dc 100644
--- a/devices/CurrentCamera.properties
+++ b/devices/CurrentCamera.properties
@@ -1,4 +1,4 @@
-#Mon Nov 27 10:01:03 CET 2017
+#Mon Nov 27 10:35:37 CET 2017
\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
@@ -9,11 +9,11 @@ colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
-imageHeight=1200
-imageWidth=1246
+imageHeight=1024
+imageWidth=1280
invert=false
-regionStartX=304
-regionStartY=8
+regionStartX=1
+regionStartY=1
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
@@ -24,9 +24,9 @@ rotation=0.0
rotationCrop=false
scale=1.0
serverURL=localhost\:10000
-spatialCalOffsetX=-1285.5021743822372
-spatialCalOffsetY=-1063.492325271727
-spatialCalScaleX=-17.12279119040641
-spatialCalScaleY=-17.316017253358037
+spatialCalOffsetX=-50.03909304143862
+spatialCalOffsetY=-50.048875855327466
+spatialCalScaleX=-1.0
+spatialCalScaleY=-1.0
spatialCalUnits=
transpose=false
diff --git a/plugins/ScreenPanel.form b/plugins/ScreenPanel.form
index 9751fdb..d917500 100644
--- a/plugins/ScreenPanel.form
+++ b/plugins/ScreenPanel.form
@@ -194,21 +194,23 @@
-
+
-
+
+
+
+
+
-
-
-
+
-
+
-
-
-
+
+
+
@@ -222,8 +224,9 @@
-
+
+
@@ -257,14 +260,6 @@
-
-
-
-
-
-
-
-
@@ -286,6 +281,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/ScreenPanel.java b/plugins/ScreenPanel.java
index 0f5b368..82c1048 100644
--- a/plugins/ScreenPanel.java
+++ b/plugins/ScreenPanel.java
@@ -228,7 +228,7 @@ public class ScreenPanel extends Panel {
setSlicingOptionsVisible(false);
JComponent editor = spinnerSlOrientation.getEditor();
if (editor instanceof JSpinner.DefaultEditor) {
- ((JSpinner.DefaultEditor)editor).getTextField().setHorizontalAlignment(JTextField.RIGHT);
+ ((JSpinner.DefaultEditor) editor).getTextField().setHorizontalAlignment(JTextField.RIGHT);
}
//spinnerMin.setVisible(false); labelMin.setVisible(false);
//spinnerMax.setVisible(false); labelMax.setVisible(false);
@@ -283,7 +283,17 @@ public class ScreenPanel extends Panel {
try {
calibrate();
} catch (Exception ex) {
- ex.printStackTrace();
+ showException(ex);
+ }
+ });
+
+ JMenuItem menuCameraConfig = new JMenuItem("Renderer Config");
+ menuCameraConfig.addActionListener((ActionEvent e) -> {
+ try {
+ if (camera != null) {
+ this.showDeviceConfigDialog(camera, false);
+ }
+ } catch (Exception ex) {
showException(ex);
}
});
@@ -353,6 +363,8 @@ public class ScreenPanel extends Panel {
}
});
+ renderer.getPopupMenu().addSeparator();
+ renderer.getPopupMenu().add(menuCameraConfig);
renderer.getPopupMenu().add(menuShowStreamData);
renderer.getPopupMenu().add(menuCalibrate);
renderer.getPopupMenu().add(menuSaveStack);
@@ -397,6 +409,7 @@ public class ScreenPanel extends Panel {
imageBufferOverlay.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_RIGHT);
if (MainFrame.isDark()) {
textState.setEnabled(true);
+ textType.setEnabled(true);
}
}
@@ -603,6 +616,7 @@ public class ScreenPanel extends Panel {
boolean changed = !String.valueOf(cameraName).equals(this.cameraName);
this.cameraName = cameraName;
+ textType.setText(getCameraType(cameraName));
if (changed || buttonDirect.isSelected()) {
spinnerThreshold.setVisible(false);
@@ -731,7 +745,6 @@ public class ScreenPanel extends Panel {
});
} catch (Exception ex) {
- ex.printStackTrace();
showException(ex);
renderer.clearOverlays();
updateServerControls();
@@ -750,9 +763,11 @@ public class ScreenPanel extends Panel {
onChangeColormap(null);
checkBackground.setEnabled(true);
if (changed) {
- comboScreen.setModel(new DefaultComboBoxModel()); comboScreen.setEnabled(false);
- comboFilter.setModel(new DefaultComboBoxModel()); comboFilter.setEnabled(false);
- if (getCameraType(cameraName).equals("ELECTRONS")){
+ comboScreen.setModel(new DefaultComboBoxModel());
+ comboScreen.setEnabled(false);
+ comboFilter.setModel(new DefaultComboBoxModel());
+ comboFilter.setEnabled(false);
+ if (getCameraType(cameraName).equals("Electrons")) {
//Parallelizing initialization
devicesInitTask = new Thread(() -> {
try {
@@ -1286,11 +1301,11 @@ public class ScreenPanel extends Panel {
if (sliceCenters.length > 1) {
double[] fit = fitPolynomial(sliceCenters, 1);
double angle = Math.toDegrees(Math.atan(fit[1]));
- Overlays.Text text = new Overlays.Text(penSlices, String.format("slice: \u03B8= %5.1fdeg", angle), fontInfoText, textPosition);
+ Overlays.Text text = new Overlays.Text(penSlices, String.format("slice: \u03B8= %5.1fdeg", angle), fontInfoText, textPosition);
text.setFixed(true);
text.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_LEFT);
fOv = Arr.append(fOv, text);
- }
+ }
}
}
} catch (Exception ex) {
@@ -1621,177 +1636,178 @@ public class ScreenPanel extends Panel {
}
void saveSnapshot() throws Exception {
- String snapshotFile = null;
- synchronized (imageBuffer) {
- Frame frame = getCurrentFrame();
- if (frame == null) {
- throw new Exception("No current image");
- }
- ArrayList frames = new ArrayList<>();
- frames.add(frame);
- this.saveFrames("camera_snapshot", frames);
-
- //Enforce the same timestamp to data & image files.
- snapshotFile = getContext().getExecutionPars().getPath() + ".png";
- ImageBuffer.saveImage(SwingUtils.createImage(renderer), snapshotFile, "png");
+ String snapshotFile = null;
+ synchronized (imageBuffer) {
+ Frame frame = getCurrentFrame();
+ if (frame == null) {
+ throw new Exception("No current image");
}
-
- JPanel panel = new JPanel();
- GridBagLayout layout = new GridBagLayout();
- layout.columnWidths = new int[]{0, 180}; //Minimum width
- layout.rowHeights = new int[]{30, 30, 30}; //Minimum height
- panel.setLayout(layout);
- JComboBox comboLogbook = new JComboBox(new String[]{"SwissFEL commissioning data", "SwissFEL commissioning"});
- JTextField textComment = new JTextField();
- GridBagConstraints c = new GridBagConstraints();
- c.gridx = 0;
- c.gridy = 0;
- panel.add(new JLabel("Data file:"), c);
- c.gridy = 1;
- panel.add(new JLabel("Logbook:"), c);
- c.gridy = 2;
- panel.add(new JLabel("Comment:"), c);
- c.fill = GridBagConstraints.HORIZONTAL;
- c.gridx = 1;
- panel.add(textComment, c);
- c.gridy = 1;
- panel.add(comboLogbook, c);
- c.gridy = 0;
- panel.add(new JLabel(getContext().getExecutionPars().getPath()), c);
+ ArrayList frames = new ArrayList<>();
+ frames.add(frame);
+ this.saveFrames("camera_snapshot", frames);
- if (SwingUtils.showOption(getTopLevel(), "Success", panel, OptionType.OkCancel) == OptionResult.Yes) {
- StringBuilder message = new StringBuilder();
- message.append("Camera: ").append(cameraName).append(" (").
- append((server != null) ? "server" : "direct").append(")").append("\n");
- message.append("Screen: ").append(String.valueOf(valueScreen.getLabel().getText())).append("\n");
- message.append("Filter: ").append(String.valueOf(valueFilter.getLabel().getText())).append("\n");
- message.append("Data file: ").append(getContext().getExecutionPars().getPath()).append("\n");
- message.append("Comment: ").append(textComment.getText()).append("\n");
- if ((fitOv != null) && (fitOv.length > 5)) {
- Overlays.Text text = (Overlays.Text) fitOv[5];
- message.append(text.getText()).append("\n");
- }
- elog((String) comboLogbook.getSelectedItem(), "ScreenPanel Snapshot", message.toString(), new String[]{snapshotFile});
+ //Enforce the same timestamp to data & image files.
+ snapshotFile = getContext().getExecutionPars().getPath() + ".png";
+ ImageBuffer.saveImage(SwingUtils.createImage(renderer), snapshotFile, "png");
+ }
+
+ JPanel panel = new JPanel();
+ GridBagLayout layout = new GridBagLayout();
+ layout.columnWidths = new int[]{0, 180}; //Minimum width
+ layout.rowHeights = new int[]{30, 30, 30}; //Minimum height
+ panel.setLayout(layout);
+ JComboBox comboLogbook = new JComboBox(new String[]{"SwissFEL commissioning data", "SwissFEL commissioning"});
+ JTextField textComment = new JTextField();
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridx = 0;
+ c.gridy = 0;
+ panel.add(new JLabel("Data file:"), c);
+ c.gridy = 1;
+ panel.add(new JLabel("Logbook:"), c);
+ c.gridy = 2;
+ panel.add(new JLabel("Comment:"), c);
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.gridx = 1;
+ panel.add(textComment, c);
+ c.gridy = 1;
+ panel.add(comboLogbook, c);
+ c.gridy = 0;
+ panel.add(new JLabel(getContext().getExecutionPars().getPath()), c);
+
+ if (SwingUtils.showOption(getTopLevel(), "Success", panel, OptionType.OkCancel) == OptionResult.Yes) {
+ StringBuilder message = new StringBuilder();
+ message.append("Camera: ").append(cameraName).append(" (").
+ append((server != null) ? "server" : "direct").append(")").append("\n");
+ message.append("Screen: ").append(String.valueOf(valueScreen.getLabel().getText())).append("\n");
+ message.append("Filter: ").append(String.valueOf(valueFilter.getLabel().getText())).append("\n");
+ message.append("Data file: ").append(getContext().getExecutionPars().getPath()).append("\n");
+ message.append("Comment: ").append(textComment.getText()).append("\n");
+ if ((fitOv != null) && (fitOv.length > 5)) {
+ Overlays.Text text = (Overlays.Text) fitOv[5];
+ message.append(text.getText()).append("\n");
}
+ elog((String) comboLogbook.getSelectedItem(), "ScreenPanel Snapshot", message.toString(), new String[]{snapshotFile});
+ }
}
void saveStack() throws Exception {
- synchronized (imageBuffer) {
- saveFrames("camera_stack", imageBuffer);
- }
- SwingUtils.showMessage(getTopLevel(), "Success", "Generated data file:\n" + getContext().getExecutionPars().getPath(), 5000);
+ synchronized (imageBuffer) {
+ saveFrames("camera_stack", imageBuffer);
}
+ SwingUtils.showMessage(getTopLevel(), "Success", "Generated data file:\n" + getContext().getExecutionPars().getPath(), 5000);
+ }
-
- public static String getCameraType(String name){
- for (String s : new String[]{"LCAM"}){
- if (name.contains(s)){
- return "LCAM";
- }
- }
- for (String s : new String[]{"DSCR", "DSRM", "DLAC"}){
- if (name.contains(s)){
- return "ELECTRONS";
- }
- }
- for (String s : new String[]{"PROF", "PPRM", "PSSS", "PSCR", "PSRD"}){
- if (name.contains(s)){
- return "PHOTONICS";
- }
- }
- return "UNKNOWN";
+ public static String getCameraType(String name) {
+ if (name == null) {
+ return "";
}
+ for (String s : new String[]{"LCAM"}) {
+ if (name.contains(s)) {
+ return "Laser";
+ }
+ }
+ for (String s : new String[]{"DSCR", "DSRM", "DLAC"}) {
+ if (name.contains(s)) {
+ return "Electrons";
+ }
+ }
+ for (String s : new String[]{"PROF", "PPRM", "PSSS", "PSCR", "PSRD"}) {
+ if (name.contains(s)) {
+ return "Photonics";
+ }
+ }
+ return "Unknown";
+ }
- public Map getProcessingParameters(StreamValue value) throws IOException {
- return (Map) JsonSerializer.decode(value.getValue("processing_parameters").toString(), Map.class);
- }
-
- void saveFrames(String name, ArrayList frames) throws IOException{
- ArrayList values = new ArrayList<>();
- for (Frame frame : frames){
- values.add(frame.cache);
- }
- saveImages(name, values);
- }
+ public Map getProcessingParameters(StreamValue value) throws IOException {
+ return (Map) JsonSerializer.decode(value.getValue("processing_parameters").toString(), Map.class);
+ }
- void saveImages(String name, ArrayList images) throws IOException{
- int depth = images.size();
- if (depth == 0){
- return;
- }
- StreamValue first = images.get(0);
- String pathRoot = "/camera1/";
- String pathImage = pathRoot + "image";
- String pathPid = pathRoot + "pulse_id";
- String pathTimestampStr = pathRoot + "timestamp_str";
- Map processingPars = getProcessingParameters(first);
- String camera = (String) processingPars.get("camera_name");
- String type = getCameraType(camera);
-
- int width = ((Number)first.getValue("width")).intValue();
- int height = ((Number)first.getValue("height")).intValue();
- Class dataType = first.getValue("image").getClass().getComponentType();
-
- getContext().setExecutionPars(name);
- DataManager dm = getContext().getDataManager();
-
- //Create tables
- dm.createDataset(pathImage, dataType, new int[]{depth, height, width});
- dm.createDataset(pathPid, Long.class, new int[]{depth});
- dm.createDataset(pathTimestampStr, String.class, new int[]{depth});
- for (String id : first.getIdentifiers()){
- Object val = first.getValue(id);
- if (id.equals("image")){
- } else if (id.equals("processing_parameters")){
- Map pars = getProcessingParameters(first);
- for (String key : pars.keySet()){
- if ((pars.get(key) != null) && (pars.get(key) instanceof Map)){
- for (Object k : ((Map)pars.get(key)).keySet()){
- Object v = ((Map)pars.get(key)).get(k);
- dm.setAttribute(pathImage, key + " " + k, (v == null)? "" : v);
- }
- } else {
- dm.setAttribute(pathImage, key, (pars.get(key) == null)? "" : pars.get(key));
+ void saveFrames(String name, ArrayList frames) throws IOException {
+ ArrayList values = new ArrayList<>();
+ for (Frame frame : frames) {
+ values.add(frame.cache);
+ }
+ saveImages(name, values);
+ }
+
+ void saveImages(String name, ArrayList images) throws IOException {
+ int depth = images.size();
+ if (depth == 0) {
+ return;
+ }
+ StreamValue first = images.get(0);
+ String pathRoot = "/camera1/";
+ String pathImage = pathRoot + "image";
+ String pathPid = pathRoot + "pulse_id";
+ String pathTimestampStr = pathRoot + "timestamp_str";
+ Map processingPars = getProcessingParameters(first);
+ String camera = (String) processingPars.get("camera_name");
+ String type = getCameraType(camera);
+
+ int width = ((Number) first.getValue("width")).intValue();
+ int height = ((Number) first.getValue("height")).intValue();
+ Class dataType = first.getValue("image").getClass().getComponentType();
+
+ getContext().setExecutionPars(name);
+ DataManager dm = getContext().getDataManager();
+
+ //Create tables
+ dm.createDataset(pathImage, dataType, new int[]{depth, height, width});
+ dm.createDataset(pathPid, Long.class, new int[]{depth});
+ dm.createDataset(pathTimestampStr, String.class, new int[]{depth});
+ for (String id : first.getIdentifiers()) {
+ Object val = first.getValue(id);
+ if (id.equals("image")) {
+ } else if (id.equals("processing_parameters")) {
+ Map pars = getProcessingParameters(first);
+ for (String key : pars.keySet()) {
+ if ((pars.get(key) != null) && (pars.get(key) instanceof Map)) {
+ for (Object k : ((Map) pars.get(key)).keySet()) {
+ Object v = ((Map) pars.get(key)).get(k);
+ dm.setAttribute(pathImage, key + " " + k, (v == null) ? "" : v);
}
- }
- } else if (val.getClass().isArray()) {
- dm.createDataset(pathRoot + id, Double.class, new int[]{depth, Array.getLength(val)});
- } else {
- dm.createDataset(pathRoot + id, val.getClass(), new int[]{depth});
- }
- }
-
- //Add metadata
- dm.setAttribute(pathRoot,"Camera", camera);
- dm.setAttribute(pathRoot,"Images", depth);
- dm.setAttribute(pathRoot,"Interval", -1);
- dm.setAttribute(pathRoot,"Type", type);
- if (type.equals("ELECTRONS")){
- dm.setAttribute(pathRoot,"Screen", String.valueOf(valueScreen.getLabel().getText()));
- dm.setAttribute(pathRoot,"Filter", String.valueOf(valueFilter.getLabel().getText()));
- }
-
- //Save data
- for (int index=0; index