ScreenPanel display camera type
This commit is contained in:
@@ -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
|
||||
|
||||
+28
-18
@@ -194,21 +194,23 @@
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="comboCameras" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
|
||||
<Component id="textType" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonArgs" linkSize="3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="buttonConfig" linkSize="3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonStop" linkSize="3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="textState" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="textState" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@@ -222,8 +224,9 @@
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="textState" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonArgs" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonConfig" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonStop" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="textType" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@@ -257,14 +260,6 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboCamerasActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="buttonConfig">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Config"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonConfigActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Camera:"/>
|
||||
@@ -286,6 +281,21 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStopActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel5">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Type:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="textType">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="0" green="0" red="0" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="ch.psi.pshell.imaging.Renderer" name="renderer">
|
||||
|
||||
+207
-200
@@ -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<Frame> 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<Frame> 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<String, Object> getProcessingParameters(StreamValue value) throws IOException {
|
||||
return (Map) JsonSerializer.decode(value.getValue("processing_parameters").toString(), Map.class);
|
||||
}
|
||||
|
||||
void saveFrames(String name, ArrayList<Frame> frames) throws IOException{
|
||||
ArrayList<StreamValue> values = new ArrayList<>();
|
||||
for (Frame frame : frames){
|
||||
values.add(frame.cache);
|
||||
}
|
||||
saveImages(name, values);
|
||||
}
|
||||
public Map<String, Object> getProcessingParameters(StreamValue value) throws IOException {
|
||||
return (Map) JsonSerializer.decode(value.getValue("processing_parameters").toString(), Map.class);
|
||||
}
|
||||
|
||||
void saveImages(String name, ArrayList<StreamValue> 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<String, Object> 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<String, Object> 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<Frame> frames) throws IOException {
|
||||
ArrayList<StreamValue> values = new ArrayList<>();
|
||||
for (Frame frame : frames) {
|
||||
values.add(frame.cache);
|
||||
}
|
||||
saveImages(name, values);
|
||||
}
|
||||
|
||||
void saveImages(String name, ArrayList<StreamValue> 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<String, Object> 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<String, Object> 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<depth; index++){
|
||||
StreamValue streamValue = images.get(index);
|
||||
dm.setItem(pathImage, streamValue.getValue("image"), new long[]{index,0,0}, new int[]{1, height, width});
|
||||
dm.setItem(pathPid, streamValue.getPulseId(), index);
|
||||
dm.setItem(pathTimestampStr, Chrono.getTimeStr(streamValue.getTimestamp(), "YYYY-MM-dd HH:mm:ss.SSS") , index);
|
||||
|
||||
for (String id : streamValue.getIdentifiers()){
|
||||
Object val = streamValue.getValue(id);
|
||||
if (id.equals("image")){
|
||||
} else if (id.equals("processing_parameters")){
|
||||
} else if (val.getClass().isArray()) {
|
||||
dm.setItem(pathRoot + id, val, index);
|
||||
} else {
|
||||
dm.setItem(pathRoot + id, val, index);
|
||||
dm.setAttribute(pathImage, key, (pars.get(key) == null) ? "" : pars.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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});
|
||||
}
|
||||
getContext().getDataManager().closeOutput();
|
||||
}
|
||||
|
||||
|
||||
//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 < depth; index++) {
|
||||
StreamValue streamValue = images.get(index);
|
||||
dm.setItem(pathImage, streamValue.getValue("image"), new long[]{index, 0, 0}, new int[]{1, height, width});
|
||||
dm.setItem(pathPid, streamValue.getPulseId(), index);
|
||||
dm.setItem(pathTimestampStr, Chrono.getTimeStr(streamValue.getTimestamp(), "YYYY-MM-dd HH:mm:ss.SSS"), index);
|
||||
|
||||
for (String id : streamValue.getIdentifiers()) {
|
||||
Object val = streamValue.getValue(id);
|
||||
if (id.equals("image")) {
|
||||
} else if (id.equals("processing_parameters")) {
|
||||
} else if (val.getClass().isArray()) {
|
||||
dm.setItem(pathRoot + id, val, index);
|
||||
} else {
|
||||
dm.setItem(pathRoot + id, val, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
getContext().getDataManager().closeOutput();
|
||||
}
|
||||
|
||||
StandardDialog calibrationDialolg;
|
||||
|
||||
@@ -1926,10 +1942,11 @@ public class ScreenPanel extends Panel {
|
||||
textState = new javax.swing.JTextField();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
comboCameras = new javax.swing.JComboBox();
|
||||
buttonConfig = new javax.swing.JButton();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
buttonArgs = new javax.swing.JButton();
|
||||
buttonStop = new javax.swing.JButton();
|
||||
jLabel5 = new javax.swing.JLabel();
|
||||
textType = new javax.swing.JTextField();
|
||||
renderer = new ch.psi.pshell.imaging.Renderer();
|
||||
jPanel4 = new javax.swing.JPanel();
|
||||
jPanel3 = new javax.swing.JPanel();
|
||||
@@ -2090,13 +2107,6 @@ public class ScreenPanel extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
buttonConfig.setText("Config");
|
||||
buttonConfig.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonConfigActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel1.setText("Camera:");
|
||||
|
||||
buttonArgs.setText("Setup");
|
||||
@@ -2113,6 +2123,13 @@ public class ScreenPanel extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
jLabel5.setText("Type:");
|
||||
|
||||
textType.setEditable(false);
|
||||
textType.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||
textType.setDisabledTextColor(new java.awt.Color(0, 0, 0));
|
||||
textType.setEnabled(false);
|
||||
|
||||
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
|
||||
jPanel6.setLayout(jPanel6Layout);
|
||||
jPanel6Layout.setHorizontalGroup(
|
||||
@@ -2122,20 +2139,22 @@ public class ScreenPanel extends Panel {
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(comboCameras, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jLabel5)
|
||||
.addGap(6, 6, 6)
|
||||
.addComponent(textType, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonArgs)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonConfig)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonStop)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(jLabel2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0))
|
||||
);
|
||||
|
||||
jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonArgs, buttonConfig, buttonStop});
|
||||
jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonArgs, buttonStop});
|
||||
|
||||
jPanel6Layout.setVerticalGroup(
|
||||
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -2147,12 +2166,13 @@ public class ScreenPanel extends Panel {
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(buttonArgs)
|
||||
.addComponent(buttonConfig)
|
||||
.addComponent(buttonStop))
|
||||
.addComponent(buttonStop)
|
||||
.addComponent(jLabel5)
|
||||
.addComponent(textType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(0, 0, 0))
|
||||
);
|
||||
|
||||
jPanel6Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboCameras, textState});
|
||||
jPanel6Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboCameras, textState, textType});
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
@@ -2814,16 +2834,6 @@ public class ScreenPanel extends Panel {
|
||||
}
|
||||
}//GEN-LAST:event_buttonArgsActionPerformed
|
||||
|
||||
private void buttonConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigActionPerformed
|
||||
try {
|
||||
if (camera != null) {
|
||||
this.showDeviceConfigDialog(camera, false);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonConfigActionPerformed
|
||||
|
||||
private void buttonPauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPauseActionPerformed
|
||||
try {
|
||||
renderer.removeOverlay(imageBufferOverlay);
|
||||
@@ -2845,7 +2855,6 @@ public class ScreenPanel extends Panel {
|
||||
updateStreamData();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonPauseActionPerformed
|
||||
@@ -2884,7 +2893,6 @@ public class ScreenPanel extends Panel {
|
||||
try {
|
||||
saveSnapshot();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonSaveActionPerformed
|
||||
@@ -2894,19 +2902,19 @@ public class ScreenPanel extends Panel {
|
||||
if (camera != null) {
|
||||
boolean laserOn = getLaserState();
|
||||
OptionResult ret = null;
|
||||
if (laserOn){
|
||||
if (laserOn) {
|
||||
ret = SwingUtils.showOption(getTopLevel(), "Capture Background", "Do you want to put laser on delay for capturing background?", OptionType.YesNoCancel);
|
||||
if (ret == OptionResult.No){
|
||||
if (ret == OptionResult.No) {
|
||||
laserOn = false;
|
||||
}
|
||||
} else {
|
||||
ret = SwingUtils.showOption(getTopLevel(), "Capture Background", "Do you want to capture background now?", OptionType.OkCancel);
|
||||
}
|
||||
|
||||
if (ret == OptionResult.Cancel){
|
||||
|
||||
if (ret == OptionResult.Cancel) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (laserOn) {
|
||||
setLaserState(false);
|
||||
}
|
||||
@@ -2966,7 +2974,7 @@ public class ScreenPanel extends Panel {
|
||||
case Inverted:
|
||||
case Red:
|
||||
case Green:
|
||||
case Blue:
|
||||
case Blue:
|
||||
colorReticule = new Color(0, 192, 0);
|
||||
colorMarker = new Color(64, 255, 64);
|
||||
break;
|
||||
@@ -3196,7 +3204,6 @@ public class ScreenPanel extends Panel {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
ex.printStackTrace();
|
||||
updateServerControls();
|
||||
}
|
||||
}
|
||||
@@ -3244,7 +3251,6 @@ public class ScreenPanel extends Panel {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
ex.printStackTrace();
|
||||
updateServerControls();
|
||||
}
|
||||
}
|
||||
@@ -3267,7 +3273,6 @@ public class ScreenPanel extends Panel {
|
||||
private javax.swing.JButton btFixColormapRange;
|
||||
private javax.swing.JButton buttonArgs;
|
||||
private javax.swing.JRadioButton buttonAutomatic;
|
||||
private javax.swing.JButton buttonConfig;
|
||||
private javax.swing.JRadioButton buttonDirect;
|
||||
private javax.swing.JToggleButton buttonFit;
|
||||
private javax.swing.JRadioButton buttonFullRange;
|
||||
@@ -3303,6 +3308,7 @@ public class ScreenPanel extends Panel {
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel jLabel4;
|
||||
private javax.swing.JLabel jLabel5;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JPanel jPanel3;
|
||||
@@ -3333,6 +3339,7 @@ public class ScreenPanel extends Panel {
|
||||
private javax.swing.JSpinner spinnerSlScale;
|
||||
private javax.swing.JSpinner spinnerThreshold;
|
||||
private javax.swing.JTextField textState;
|
||||
private javax.swing.JTextField textType;
|
||||
private ch.psi.pshell.swing.DeviceValuePanel valueFilter;
|
||||
private ch.psi.pshell.swing.DeviceValuePanel valueScreen;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
Reference in New Issue
Block a user