diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties
index 89e27d8..f5482c3 100644
--- a/devices/CurrentCamera.properties
+++ b/devices/CurrentCamera.properties
@@ -1,13 +1,13 @@
-#Thu Jun 08 10:46:19 CEST 2017
+#Fri Jun 09 12:01:41 CEST 2017
colormap=Flame
colormapAutomatic=true
-colormapMax=936.0
+colormapMax=583.0
colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
-imageHeight=2160
-imageWidth=2560
+imageHeight=1024
+imageWidth=1280
invert=false
regionStartX=1
regionStartY=1
diff --git a/plugins/ScreenPanel_back.form b/plugins/ScreenPanelDev.form
similarity index 89%
rename from plugins/ScreenPanel_back.form
rename to plugins/ScreenPanelDev.form
index 96f341e..63b209a 100644
--- a/plugins/ScreenPanel_back.form
+++ b/plugins/ScreenPanelDev.form
@@ -74,7 +74,7 @@
-
+
@@ -95,10 +95,12 @@
+
+
-
+
@@ -117,6 +119,7 @@
+
@@ -135,7 +138,6 @@
-
@@ -175,6 +177,15 @@
+
+
+
+
+
+
+
+
+
@@ -489,7 +500,7 @@
-
+
@@ -881,14 +892,31 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -902,7 +930,18 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -910,7 +949,7 @@
-
+
@@ -919,7 +958,7 @@
-
+
@@ -938,6 +977,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/ScreenPanel_back.java b/plugins/ScreenPanelDev.java
similarity index 81%
rename from plugins/ScreenPanel_back.java
rename to plugins/ScreenPanelDev.java
index 4da57d6..1272972 100644
--- a/plugins/ScreenPanel_back.java
+++ b/plugins/ScreenPanelDev.java
@@ -13,6 +13,7 @@ import ch.psi.utils.Chrono;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.utils.swing.TextEditor;
import ch.psi.pshell.bs.Camtool;
+import ch.psi.pshell.bs.StreamValue;
import ch.psi.pshell.device.DescStatsDouble;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.epics.ChannelInteger;
@@ -44,6 +45,7 @@ import ch.psi.utils.Convert;
import ch.psi.utils.TcpClient;
import ch.psi.utils.swing.Editor.EditorDialog;
import ch.psi.utils.swing.MainFrame;
+import ch.psi.utils.swing.StandardDialog;
import ch.psi.utils.swing.SwingUtils.OptionResult;
import ch.psi.utils.swing.SwingUtils.OptionType;
import java.awt.BorderLayout;
@@ -56,9 +58,11 @@ import java.awt.GridBagLayout;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
+import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
+import java.lang.reflect.Array;
import java.net.ServerSocket;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -77,10 +81,14 @@ import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
+import javax.swing.table.DefaultTableModel;
import org.apache.commons.math3.analysis.function.Gaussian;
import org.apache.commons.math3.fitting.GaussianCurveFitter;
import org.apache.commons.math3.fitting.WeightedObservedPoint;
@@ -89,7 +97,7 @@ import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
/**
*
*/
-public class ScreenPanel_back extends Panel {
+public class ScreenPanelDev extends Panel {
final String CAMERA_DEVICE_NAME = "CurrentCamera";
boolean useCamtoolStats = true;
@@ -104,13 +112,16 @@ public class ScreenPanel_back extends Panel {
DiscretePositioner screen;
DiscretePositioner filter;
boolean showFit;
+ boolean showProfile;
Overlay[] userOv;
Overlay[] fitOv;
- Overlay errorOverlay;
+ Overlay[] profileOv;
+ Overlay errorOverlay;
boolean requestCameraListUpdate;
Integer localServerPort;
Process privateServer;
String serverUrl;
+ boolean goodRegion;
Double getCamtoolDouble(String name) {
return (Double) Convert.toDouble(((Camtool) camera).getValue(name));
@@ -119,27 +130,41 @@ public class ScreenPanel_back extends Panel {
double[] getCamtoolDoubleArray(String name) {
return (double[]) Convert.toDouble(((Camtool) camera).getValue(name));
}
-
- class Frame {
-
- Frame(Data data) {
- this.data = data;
+
+ class ImageData {
+ ImageData(){
if (camera instanceof Camtool) {
- xMean = getCamtoolDouble("x_fit_mean");
- yMean = getCamtoolDouble("y_fit_mean");
- xSigma = getCamtoolDouble("x_fit_standard_deviation");
- ySigma = getCamtoolDouble("y_fit_standard_deviation");
+ String prefix = goodRegion ? "gr_" : "";
+ xMean = getCamtoolDouble(prefix + "x_fit_mean");
+ yMean = getCamtoolDouble(prefix + "y_fit_mean");
+ xSigma = getCamtoolDouble(prefix + "x_fit_standard_deviation");
+ ySigma = getCamtoolDouble(prefix + "y_fit_standard_deviation");
+ x_fit_gauss_function = getCamtoolDoubleArray(prefix +"x_fit_gauss_function");
+ y_fit_gauss_function = getCamtoolDoubleArray(prefix +"y_fit_gauss_function");
+ x_profile = getCamtoolDoubleArray("x_profile");
+ y_profile = getCamtoolDoubleArray("y_profile");
xCom = getCamtoolDouble("x_center_of_mass");
yCom = getCamtoolDouble("y_center_of_mass");
xRms = getCamtoolDouble("x_rms");
- yRms = getCamtoolDouble("y_rms");
- x_profile = getCamtoolDoubleArray("x_profile");
- x_fit_gauss_function = getCamtoolDoubleArray("x_fit_gauss_function");
- y_profile = getCamtoolDoubleArray("y_profile");
- y_fit_gauss_function = getCamtoolDoubleArray("y_fit_gauss_function");
- }
+ yRms = getCamtoolDouble("y_rms");
+ if (goodRegion){
+ double[] gX2 = new double[x_profile.length];
+ try{
+ double x = getCamtoolDoubleArray("gr_x_axis")[0];
+ System.arraycopy(x_fit_gauss_function, 0, gX2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x): x), x_fit_gauss_function.length);
+ } catch (Exception ex){
+ }
+ x_fit_gauss_function = gX2;
+ double[] gY2 = new double[y_profile.length];
+ try{
+ double y = getCamtoolDoubleArray("gr_y_axis")[0];
+ System.arraycopy(y_fit_gauss_function, 0, gY2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y): y), y_fit_gauss_function.length);
+ } catch (Exception ex){
+ }
+ y_fit_gauss_function = gY2;
+ }
+ }
}
- Data data;
Double xMean;
Double yMean;
Double xCom;
@@ -151,14 +176,22 @@ public class ScreenPanel_back extends Panel {
double[] x_profile;
double[] x_fit_gauss_function;
double[] y_profile;
- double[] y_fit_gauss_function;
+ double[] y_fit_gauss_function;
+ }
+
+ class Frame extends ImageData{
+
+ Frame(Data data) {
+ this.data = data;
+ }
+ Data data;
}
final ArrayList imageBuffer = new ArrayList();
int imageBufferLenght = 0;
Text imageBufferOverlay;
- public ScreenPanel_back() {
+ public ScreenPanelDev() {
initComponents();
renderer.setPersistenceFile(Paths.get(getContext().getSetup().getContextPath(), "Renderer_Cameras.bin"));
setPersistedComponents(new Component[]{buttonCamtool, buttonDirect});
@@ -228,10 +261,10 @@ public class ScreenPanel_back extends Panel {
}
});
- JMenuItem menuShowIdentifiers = new JMenuItem("Show Identifiers...");
- menuShowIdentifiers.addActionListener((ActionEvent e) -> {
+ JMenuItem menuShowImageData = new JMenuItem("Show Image Data");
+ menuShowImageData.addActionListener((ActionEvent e) -> {
try {
- showIdentifiers();
+ showImageData();
} catch (Exception ex) {
showException(ex);
}
@@ -293,7 +326,7 @@ public class ScreenPanel_back extends Panel {
}
});
- renderer.getPopupMenu().add(menuShowIdentifiers);
+ renderer.getPopupMenu().add(menuShowImageData);
renderer.getPopupMenu().add(menuCalibrate);
renderer.getPopupMenu().add(menuSaveStack);
renderer.getPopupMenu().addSeparator();
@@ -304,7 +337,7 @@ public class ScreenPanel_back extends Panel {
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
menuResetROI.setEnabled(camera instanceof Camtool);
menuSetROI.setEnabled(camera instanceof Camtool);
- menuShowIdentifiers.setVisible(camera instanceof Camtool);
+ menuShowImageData.setVisible(camera instanceof Camtool);
menuCalibrate.setVisible(camera instanceof Camtool);
menuCalibrate.setEnabled(calibrationOverlays==null);
}
@@ -320,6 +353,7 @@ public class ScreenPanel_back extends Panel {
renderer.getPopupMenu().setVisible(false);
showFit = buttonFit.isSelected();
+ showProfile = buttonProfile.isSelected();
pauseSelection.setVisible(false);
pauseSelection.setMinValue(1);
@@ -519,10 +553,13 @@ public class ScreenPanel_back extends Panel {
final Object lockOverlays = new Object();
void manageFit(BufferedImage bi, Data data) {
- Overlay[] fo = ((bi == null) || (!showFit)) ? null : getFitOverlays(data);
+ Overlay[][] fo = ((bi == null) || ((!showFit && !showProfile))) ? null : getFitOverlays(data);
synchronized(lockOverlays){
- renderer.updateOverlays(fo, fitOv);
- fitOv = fo;
+ fo = (fo==null) ? new Overlay[][]{null, null} : fo;
+ renderer.updateOverlays(fo[0], profileOv);
+ profileOv = fo[0];
+ renderer.updateOverlays(fo[1], fitOv);
+ fitOv = fo[1];
}
}
@@ -533,6 +570,7 @@ public class ScreenPanel_back extends Panel {
userOv = fo;
}
}
+
@Override
public void onStateChange(State state, State former) {
@@ -554,11 +592,18 @@ public class ScreenPanel_back extends Panel {
System.out.println("Setting camera: " + cameraName + " [" + (buttonCamtool.isSelected() ? "camtool" : "direct") + "]");
parseUserOverlays();
errorOverlay = null;
- buttonGrabBackground.setEnabled(false);
checkBackground.setEnabled(false);
spinnerThreshold.setEnabled(false);
-
+ spinnerGrThreshold.setEnabled(false);
+ spinnerGrScale.setEnabled(false);
checkThreshold.setEnabled(false);
+ checkGoodRegion.setEnabled(false);
+
+ if (dataTableDialog!=null){
+ dataTableDialog.dispose();
+ dataTableDialog = null;
+ }
+ dataTableModel = null;
if (calibrationDialolg!=null){
calibrationDialolg.dispose();
@@ -574,6 +619,7 @@ public class ScreenPanel_back extends Panel {
renderer.setShowReticle(false);
renderer.removeOverlays(fitOv);
+ renderer.removeOverlays(profileOv);
renderer.removeOverlays(userOv);
renderer.clear();
renderer.resetZoom();
@@ -619,21 +665,31 @@ public class ScreenPanel_back extends Panel {
camera.initialize();
camera.assertInitialized();
System.out.println("Camera initialization OK");
- if (camera instanceof Camtool) {
+ if (camera instanceof Camtool) {
//Managing no background exception. Can be done in a better way?
checkBackground.setEnabled(true);
if (changed) {
((Camtool) camera).startPipeline(cameraName, null);
updateCamtoolControls();
} else {
- ((Camtool) camera).startPipeline(cameraName, null, checkBackground.isSelected(), null, checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null, null);
+ HashMap gr = null;
+ if (goodRegion){
+ gr = new HashMap<>();
+ gr.put("threshold", spinnerGrThreshold.getValue());
+ gr.put("gfscale", spinnerGrScale.getValue());
+ }
+ ((Camtool) camera).startPipeline(cameraName, null, checkBackground.isSelected(), null, checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null, gr);
}
spinnerThreshold.setEnabled(true);
+ spinnerGrThreshold.setEnabled(true);
+ spinnerGrScale.setEnabled(true);
checkThreshold.setEnabled(true);
- buttonGrabBackground.setEnabled(true);
+ checkGoodRegion.setEnabled(true);
((Camtool) camera).startReceiver();
} else {
+ checkBackground.setEnabled(true);
+ checkBackground.setSelected(false);
if (polling <= 0) {
camera.setMonitored(true);
} else {
@@ -682,7 +738,7 @@ public class ScreenPanel_back extends Panel {
manageFit(bi, data);
manageUserOverlays(bi, data);
}
-
+ //updateImageData();
}
@Override
@@ -869,10 +925,16 @@ public class ScreenPanel_back extends Panel {
checkBackground.setSelected(((Camtool) camera).getBackgroundSubtraction());
Double threshold = ((Camtool) camera).getThreshold();
checkThreshold.setSelected(threshold != null);
- spinnerThreshold.setValue((threshold == null) ? 0 : threshold);
-
+ spinnerThreshold.setValue((threshold == null) ? 0 : threshold);
+ Map gr = ((Camtool) camera).getGoodRegion();
+ checkGoodRegion.setSelected(gr != null);
+ if (gr != null){
+ spinnerGrThreshold.setValue(gr.get("threshold"));
+ spinnerGrScale.setValue(gr.get("gfscale"));
+ }
} catch (Exception ex) {
}
+ goodRegion = checkGoodRegion.isSelected();
updatingCamtoolControls = false;
}
}
@@ -906,9 +968,9 @@ public class ScreenPanel_back extends Panel {
try {
((Source) getDevice("image")).initialize();
} catch (IOException ex) {
- Logger.getLogger(ScreenPanel.class.getName()).log(Level.SEVERE, null, ex);
+ Logger.getLogger(ScreenPanelDev.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
- Logger.getLogger(ScreenPanel.class.getName()).log(Level.SEVERE, null, ex);
+ Logger.getLogger(ScreenPanelDev.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (renderer.isPaused() != buttonPause.isSelected()) {
@@ -921,6 +983,9 @@ public class ScreenPanel_back extends Panel {
if ((renderer.getMarker() == null) && buttonMarker.isSelected()) {
buttonMarker.setSelected(false);
}
+ if (!renderer.isPaused() && (dataTableDialog!=null) && (dataTableDialog.isShowing())){
+ updateImageData();
+ }
updateZoom();
updateColormap();
updateStop();
@@ -931,7 +996,7 @@ public class ScreenPanel_back extends Panel {
Pen penFit = new Pen(new Color(192, 105, 0), 1);
Pen penCross = new Pen(new Color(192, 105, 0), 1);
- Overlay[] getFitOverlays(Data data) {
+ Overlay[][] getFitOverlays(Data data) {
Overlays.Polyline hgaussian = null;
Overlays.Polyline vgaussian = null;
Overlays.Polyline hprofile = null;
@@ -946,39 +1011,27 @@ public class ScreenPanel_back extends Panel {
int profileSize = renderer.getProfileSize();
if ((useCamtoolStats) && (camera instanceof Camtool)) {
try {
+ ImageData id = null;
if (renderer.isPaused()) {
synchronized (imageBuffer) {
for (Frame f : imageBuffer) {
if (f.data == data) {
- xMean = f.xMean;
- xSigma = f.xSigma;
- yMean = f.yMean;
- ySigma = f.ySigma;
- pX = f.x_profile;
- gX = f.x_fit_gauss_function;
- pY = f.y_profile;
- gY = f.y_fit_gauss_function;
- xCom = f.xCom;
- xRms = f.xRms;
- yCom = f.yCom;
- yRms = f.yRms;
+ id = f;
+ break;
}
}
}
} else {
- xMean = getCamtoolDouble("x_fit_mean");
- yMean = getCamtoolDouble("y_fit_mean");
- xSigma = getCamtoolDouble("x_fit_standard_deviation");
- ySigma = getCamtoolDouble("y_fit_standard_deviation");
- xCom = getCamtoolDouble("x_center_of_mass");
- yCom = getCamtoolDouble("y_center_of_mass");
- xRms = getCamtoolDouble("x_rms");
- yRms = getCamtoolDouble("y_rms");
- pX = getCamtoolDoubleArray("x_profile");
- gX = getCamtoolDoubleArray("x_fit_gauss_function");
- pY = getCamtoolDoubleArray("y_profile");
- gY = getCamtoolDoubleArray("y_fit_gauss_function");
+ id = new ImageData();
}
+ if (id==null){
+ return null;
+ }
+ xMean = id.xMean; xSigma = id.xSigma;yMean = id.yMean;ySigma = id.ySigma;
+ gX = id.x_fit_gauss_function; gY = id.y_fit_gauss_function;
+ pX = id.x_profile;pY = id.y_profile;
+ xCom = id.xCom; xRms = id.xRms; yCom = id.yCom; yRms = id.yRms;
+
profileSize /= 4;
if (pX != null) {
int[] x = Arr.indexesInt(pX.length);
@@ -1033,36 +1086,44 @@ public class ScreenPanel_back extends Panel {
if (rangePlot <= 0) {
return null;
}
- try {
+ try {
double[] sum = data.integrateVertically(true);
- double[] saux = new double[sum.length];
+ double[] saux = new double[sum.length];
int[] p = new int[sum.length];
- //xCom = getCom(sum);
+ double[] x_egu = renderer.getCalibration().getAxisX(sum.length);
+ double[] comRms = getComRms(sum, x_egu);
+ xCom = comRms[0];
+ xRms = comRms[1];
int[] x = Arr.indexesInt(sum.length);
DescriptiveStatistics stats = new DescriptiveStatistics(sum);
double min = stats.getMin();
for (int i = 0; i < sum.length; i++) {
saux[i] = sum[i] - min;
}
-
- double[] gaussian = fitGaussian(saux, x);
- if (gaussian != null) {
- if ((gaussian[2] < sum.length * 0.45)
- && (gaussian[2] > 2)
- && (gaussian[0] > min * 0.03)) {
- xNorm = gaussian[0];
- xMean = gaussian[1];
- xSigma = gaussian[2];
- double[] fit = getFitFunction(gaussian, x);
- int[] y = new int[x.length];
- for (int i = 0; i < x.length; i++) {
- y[i] = (int) (height - 1 - ((((fit[i] + min) / height - minPlot) / rangePlot) * profileSize));
- p[i] = (int) (height - 1 - (((sum[i] / height- minPlot) / rangePlot) * profileSize));
- }
- vgaussian = new Overlays.Polyline(penFit, x, y);
- vprofile = new Overlays.Polyline(renderer.getPenProfile(), x, p);
+ if (showFit){
+ double[] gaussian = fitGaussian(saux, x);
+ if (gaussian != null) {
+ if ((gaussian[2] < sum.length * 0.45)
+ && (gaussian[2] > 2)
+ && (gaussian[0] > min * 0.03)) {
+ xNorm = gaussian[0];
+ xMean = gaussian[1];
+ xSigma = gaussian[2];
+ double[] fit = getFitFunction(gaussian, x);
+ int[] y = new int[x.length];
+ for (int i = 0; i < x.length; i++) {
+ y[i] = (int) (height - 1 - ((((fit[i] + min) / height - minPlot) / rangePlot) * profileSize));
+ }
+ vgaussian = new Overlays.Polyline(penFit, x, y);
+ }
}
}
+ if (showProfile){
+ for (int i = 0; i < x.length; i++) {
+ p[i] = (int) (height - 1 - (((sum[i] / height- minPlot) / rangePlot) * profileSize));
+ }
+ vprofile = new Overlays.Polyline(renderer.getPenProfile(), x, p);
+ }
} catch (Exception ex) {
ex.printStackTrace();
}
@@ -1071,7 +1132,10 @@ public class ScreenPanel_back extends Panel {
double[] sum = data.integrateHorizontally(true);
double[] saux = new double[sum.length];
int[] p = new int[sum.length];
- //yCom = getCom(sum);
+ double[] y_egu = renderer.getCalibration().getAxisY(sum.length);
+ double[] comRms = getComRms(sum, y_egu);
+ yCom = comRms[0];
+ yRms = comRms[1];
int[] x = Arr.indexesInt(sum.length);
DescriptiveStatistics stats = new DescriptiveStatistics(sum);
double min = stats.getMin();
@@ -1079,25 +1143,31 @@ public class ScreenPanel_back extends Panel {
saux[i] = sum[i] - min;
}
- double[] gaussian = fitGaussian(saux, x);
- if (gaussian != null) {
- //Only aknowledge beam fully inside the image and peak over 3% of min
- if ((gaussian[2] < sum.length * 0.45)
- && (gaussian[2] > 2)
- && (gaussian[0] > min * 0.03)) {
- yNorm = gaussian[0];
- yMean = gaussian[1];
- ySigma = gaussian[2];
- double[] fit = getFitFunction(gaussian, x);
+ if (showFit){
+ double[] gaussian = fitGaussian(saux, x);
+ if (gaussian != null) {
+ //Only aknowledge beam fully inside the image and peak over 3% of min
+ if ((gaussian[2] < sum.length * 0.45)
+ && (gaussian[2] > 2)
+ && (gaussian[0] > min * 0.03)) {
+ yNorm = gaussian[0];
+ yMean = gaussian[1];
+ ySigma = gaussian[2];
+ double[] fit = getFitFunction(gaussian, x);
- int[] y = new int[x.length];
- for (int i = 0; i < x.length; i++) {
- y[i] = (int) ((((fit[i] + min) / width - minPlot) / rangePlot) * profileSize);
- p[i] = (int) (((sum[i] / width - minPlot) / rangePlot) * profileSize);
- }
- hgaussian = new Overlays.Polyline(penFit, y, x);
- hprofile = new Overlays.Polyline(renderer.getPenProfile(), p, x);
+ int[] y = new int[x.length];
+ for (int i = 0; i < x.length; i++) {
+ y[i] = (int) ((((fit[i] + min) / width - minPlot) / rangePlot) * profileSize);
+ }
+ hgaussian = new Overlays.Polyline(penFit, y, x);
+ }
}
+ }
+ if (showProfile){
+ for (int i = 0; i < x.length; i++) {
+ p[i] = (int) (((sum[i] / width - minPlot) / rangePlot) * profileSize);
+ }
+ hprofile = new Overlays.Polyline(renderer.getPenProfile(), p, x);
}
} catch (Exception ex) {
@@ -1117,38 +1187,54 @@ public class ScreenPanel_back extends Panel {
yMean = data.getY((int) Math.round(yMean));
}
}
- }
+ }
final String units = (renderer.getCalibration() != null) ? "\u00B5m" : "px";
final String fmt = "%7.1f" + units;
-
Overlays.Text textCom = null;
- if ((xCom != null) && (yCom != null)) {
- textCom = new Overlays.Text(renderer.getPenProfile(),
- String.format("x: m=" + fmt + " \u03C3=" + fmt + "\ny: m=" + fmt + " \u03C3=" + fmt,xCom, xRms,yCom, yRms),
- new Font(Font.MONOSPACED, 0, 14), new Point(12, 20));
- textCom.setFixed(true);
- textCom.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_LEFT);
- }
-
- Overlays.Crosshairs cross = null;
- Overlays.Text textFit = null;
- if ((xMean != null) && (yMean != null)) {
- textFit = new Overlays.Text(penFit,
- String.format("x: m=" + fmt + " \u03C3=" + fmt + "\ny: m=" + fmt + " \u03C3=" + fmt,xMean, xSigma, yMean, ySigma),
- new Font(Font.MONOSPACED, 0, 14), new Point(12, 54));
- textFit.setFixed(true);
- textFit.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_LEFT);
-
- Point center = new Point(xMean.intValue(), yMean.intValue());
- if (renderer.getCalibration() != null) {
- center = renderer.getCalibration().convertToImagePosition(new PointDouble(xMean, yMean));
- xSigma /= renderer.getCalibration().getScaleX();
- ySigma /= renderer.getCalibration().getScaleY();
- }
- cross = new Overlays.Crosshairs(penCross, center, new Dimension(Math.abs(2 * xSigma.intValue()), 2 * Math.abs(ySigma.intValue())));
+ Overlay[] pOv=null, fOv=null;
+ Point textPosition = new Point(12, 20);
+ if (showProfile){
+ if ((xCom != null) && (yCom != null)) {
+ String text = String.format("com x: m=" + fmt + " \u03C3=" + fmt + "\ncom y: m=" + fmt + " \u03C3=" + fmt,xCom, xRms,yCom, yRms);
+ textCom = new Overlays.Text(renderer.getPenProfile(), text, new Font(Font.MONOSPACED, 0, 14), textPosition);
+ textCom.setFixed(true);
+ textCom.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_LEFT);
+ }
+ pOv = new Overlay[]{hprofile, vprofile, textCom};
}
-
- return new Overlay[]{hprofile, vprofile, hgaussian, vgaussian, cross, textFit, textCom};
+ if (showFit){
+ Overlays.Crosshairs cross = null;
+ Overlays.Text textFit = null;
+ if ((xMean != null) && (yMean != null)) {
+ String text = String.format("fit x: m=" + fmt + " \u03C3=" + fmt + "\nfit y: m=" + fmt + " \u03C3=" + fmt,xMean, xSigma, yMean, ySigma);
+ textFit = new Overlays.Text(penFit, text, new Font(Font.MONOSPACED, 0, 14), showProfile ? new Point(12, 54) : textPosition );
+ textFit.setFixed(true);
+ textFit.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_LEFT);
+ Point center = new Point(xMean.intValue(), yMean.intValue());
+ if (renderer.getCalibration() != null) {
+ center = renderer.getCalibration().convertToImagePosition(new PointDouble(xMean, yMean));
+ xSigma /= renderer.getCalibration().getScaleX();
+ ySigma /= renderer.getCalibration().getScaleY();
+ }
+ cross = new Overlays.Crosshairs(penCross, center, new Dimension(Math.abs(2 * xSigma.intValue()), 2 * Math.abs(ySigma.intValue())));
+ }
+ fOv = new Overlay[]{hgaussian, vgaussian, cross, textFit};
+
+ if (goodRegion){
+ try{
+ double[] x = getCamtoolDoubleArray("gr_x_axis"); double[] y = getCamtoolDoubleArray("gr_y_axis");
+ double x1 = x[0]; double x2 = x[x.length-1]; double y1 = y[0]; double y2 = y[y.length-1];
+ Overlays.Rect goodRegionOv = new Overlays.Rect(new Pen(penFit.getColor(), 0, Pen.LineStyle.dotted));
+ goodRegionOv.setCalibration(renderer.getCalibration());
+ goodRegionOv.setAbsolutePosition(new PointDouble(x1, y1));
+ goodRegionOv.setAbsoluteSize(new DimensionDouble(x2-x1, y2-y1));
+ fOv = Arr.append(fOv, goodRegionOv);
+ } catch (Exception ex){
+ }
+ }
+
+ }
+ return new Overlay[][]{pOv, fOv};
}
return null;
}
@@ -1241,25 +1327,40 @@ public class ScreenPanel_back extends Panel {
Overlay ov = uo.obj;
//Overlay ov = (Overlay)uo.cls.newInstance();
ov.setCalibration(renderer.getCalibration());
+ boolean valid = false;
if (ov instanceof Overlays.Polyline) {
double[] x = (uo.channels[0].equals("null")) ? null : getCamtoolDoubleArray(uo.channels[0]);
double[] y = (uo.channels[1].equals("null")) ? null : getCamtoolDoubleArray(uo.channels[1]);
- if (x == null) {
- x = (renderer.getCalibration() == null) ? Arr.indexesDouble(y.length) : renderer.getCalibration().getAxisX(y.length);
+ if ((x != null) || (y !=null)) {
+ if (x == null) {
+ x = (renderer.getCalibration() == null) ? Arr.indexesDouble(y.length) : renderer.getCalibration().getAxisX(y.length);
+ }
+ if (y == null) {
+ y = (renderer.getCalibration() == null) ? Arr.indexesDouble(x.length) : renderer.getCalibration().getAxisY(x.length);
+ }
+ ((Overlays.Polyline) ov).updateAbsolute(x, y);
+ valid = true;
}
- if (y == null) {
- y = (renderer.getCalibration() == null) ? Arr.indexesDouble(x.length) : renderer.getCalibration().getAxisY(x.length);
- }
- ((Overlays.Polyline) ov).updateAbsolute(x, y);
} else {
- PointDouble position = new PointDouble(getCamtoolDouble(uo.channels[0]), getCamtoolDouble(uo.channels[1]));
- ov.setAbsolutePosition(position);
- if (!(ov instanceof Overlays.Crosshairs)) {
- DimensionDouble size = new DimensionDouble(getCamtoolDouble(uo.channels[2]) - position.x, getCamtoolDouble(uo.channels[3]) - position.y);
- ov.setAbsoluteSize(size);
+ Double x = getCamtoolDouble(uo.channels[0]); Double y = getCamtoolDouble(uo.channels[1]);
+ if ((x != null) && (y !=null)) {
+ PointDouble position = new PointDouble(x,y);
+ ov.setAbsolutePosition(position);
+ if (!(ov instanceof Overlays.Crosshairs)) {
+ Double x2 = getCamtoolDouble(uo.channels[2]); Double y2 = getCamtoolDouble(uo.channels[3]);
+ if ((x != null) && (y !=null)) {
+ DimensionDouble size = new DimensionDouble(x2 - position.x, y2 - position.y);
+ ov.setAbsoluteSize(size);
+ valid = true;
+ }
+ } else {
+ valid = true;
+ }
}
}
- ret.add(ov);
+ if (valid){
+ ret.add(ov);
+ }
} catch (Exception ex) {
ex.printStackTrace();
}
@@ -1268,22 +1369,26 @@ public class ScreenPanel_back extends Panel {
return ret.toArray(new Overlay[0]);
}
- double getCom(double[] arr) {
- if (arr == null) {
- return Double.NaN;
+ double[] getComRms(double[] arr, double[] x) {
+ if (arr != null) {
+ double xmd = 0;
+ double xmd2 = 0;
+ double total = 0;
+ for (int i=0; i< arr.length; i++) {
+ double v = (arr[i] * x[i]);
+ xmd += v;
+ xmd2 += (v * x[i]);
+ total += arr[i];
+ }
+ if (total > 0) {
+ double com = xmd / total;
+ double com2 = xmd2 / total;
+ double rms = Math.sqrt(Math.abs(com2 - com * com));
+ return new double[] {com, rms};
+ }
}
- int index = 0;
- double ret = 0;
- double total = 0;
- for (double v : arr) {
- ret += (v * index++);
- total += v;
- }
- if (total == 0) {
- return Double.NaN;
- }
- return ret / total;
- }
+ return new double[]{Double.NaN, Double.NaN};
+ }
double[] fitGaussianScript(int[] y, int[] x) {
ScriptManager sm = Context.getInstance().getScriptManager();
@@ -1346,7 +1451,7 @@ public class ScreenPanel_back extends Panel {
}
void setLaserState(boolean value) throws Exception {
-
+ System.out.println( "Setting laser state: " + value);
Epics.putq("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", value ? 0 : 1);
Epics.putq("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1);
Thread.sleep(3000);
@@ -1594,11 +1699,11 @@ public class ScreenPanel_back extends Panel {
c.put("reference_marker_height", Double.valueOf(textHeight.getText()));
}
((Camtool) camera).setCalibration(cameraName, c);
- Logger.getLogger(ScreenPanel.class.getName()).warning("Updated " + cameraName + " calibration: " + x1 + ", "+ x2 + ", " + y1 + ", " + y2);
+ Logger.getLogger(ScreenPanelDev.class.getName()).warning("Updated " + cameraName + " calibration: " + x1 + ", "+ x2 + ", " + y1 + ", " + y2);
}
}
} catch (IOException ex) {
- Logger.getLogger(ScreenPanel.class.getName()).log(Level.SEVERE, null, ex);
+ Logger.getLogger(ScreenPanelDev.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
@@ -1613,12 +1718,75 @@ public class ScreenPanel_back extends Panel {
}
}
- void showIdentifiers(){
+ StandardDialog dataTableDialog;
+ DefaultTableModel dataTableModel;
+ void showImageData(){
+ dataTableModel = null;
if (camera instanceof Camtool){
- List ids = ((Camtool)camera).getValue().getIdentifiers();
- Collections.sort(ids);
- String msg = String.join("\n", ids);
- SwingUtils.showMessage(getTopLevel(), "Camtool Identifiers", msg);
+
+ if ((dataTableDialog!=null) && (dataTableDialog.isShowing())){
+ SwingUtils.centerComponent(getTopLevel(), dataTableDialog);
+ dataTableDialog.requestFocus();
+ return;
+ }
+ //String msg = String.join("\n", ids);
+ //SwingUtils.showMessage(getTopLevel(), "Image Data", msg);
+ dataTableModel = new DefaultTableModel(new Object[0][2], new String[]{"Name", "Value"}) {
+ public Class getColumnClass(int columnIndex) {
+ return String.class;
+ }
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return false;
+ }
+ };
+ updateImageData();
+ StreamValue val = ((Camtool)camera).getStream().take();
+ JTable dataTable = new JTable(dataTableModel);
+ dataTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ dataTable.getTableHeader().setReorderingAllowed(false);
+ dataTable.getTableHeader().setResizingAllowed(true);
+ dataTableDialog = new StandardDialog(getTopLevel(), "Image Data", false);
+ dataTableDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE );
+ JScrollPane scrollPane = new JScrollPane();
+ scrollPane.setViewportView(dataTable);
+ scrollPane.setPreferredSize(new Dimension(300, 400));
+ dataTableDialog.setContentPane(scrollPane);
+ dataTableDialog.pack();
+ SwingUtils.centerComponent(getTopLevel(), dataTableDialog);
+ dataTableDialog.setVisible(true);
+ dataTableDialog.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ dataTableModel = null;
+ }
+ });
+ }
+ }
+
+ void updateImageData(){
+ if ((dataTableModel!=null)&&(camera instanceof Camtool)){
+ List ids = new ArrayList(((Camtool)camera).getValue().getIdentifiers());
+ if (ids.size() != dataTableModel.getRowCount()){
+ dataTableModel.setNumRows(0);
+ Collections.sort(ids);
+ for (String id : ids){
+ dataTableModel.addRow(new Object[]{id, ""});
+ }
+ }
+ for (int i = 0 ; i< dataTableModel.getRowCount(); i++){
+ String id = String.valueOf(dataTableModel.getValueAt(i, 0));
+ Object obj = ((Camtool)camera).getValue(id);
+ if (obj!=null){
+ if (obj.getClass().isArray()){
+ obj = obj.getClass().getComponentType().getSimpleName() + "[" + Array.getLength(obj) + "]";
+ } else if (obj instanceof Double){
+ obj = Convert.roundDouble((Double) obj, 1);
+ } else if (obj instanceof Float){
+ obj = Convert.roundDouble((Float) obj, 1);
+ }
+ }
+ dataTableModel.setValueAt(String.valueOf(obj), i, 1);
+ }
}
}
@@ -1640,6 +1808,7 @@ public class ScreenPanel_back extends Panel {
buttonFit = new javax.swing.JToggleButton();
buttonReticle = new javax.swing.JToggleButton();
buttonPause = new javax.swing.JToggleButton();
+ buttonProfile = new javax.swing.JToggleButton();
jPanel6 = new javax.swing.JPanel();
textState = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
@@ -1686,6 +1855,11 @@ public class ScreenPanel_back extends Panel {
checkThreshold = new javax.swing.JCheckBox();
spinnerThreshold = new javax.swing.JSpinner();
checkBackground = new javax.swing.JCheckBox();
+ checkGoodRegion = new javax.swing.JCheckBox();
+ spinnerGrScale = new javax.swing.JSpinner();
+ spinnerGrThreshold = new javax.swing.JSpinner();
+ jLabel5 = new javax.swing.JLabel();
+ jLabel6 = new javax.swing.JLabel();
setPreferredSize(new java.awt.Dimension(873, 600));
@@ -1697,7 +1871,6 @@ public class ScreenPanel_back extends Panel {
});
buttonGrabBackground.setText("Grab Background");
- buttonGrabBackground.setEnabled(false);
buttonGrabBackground.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonGrabBackgroundActionPerformed(evt);
@@ -1734,6 +1907,14 @@ public class ScreenPanel_back extends Panel {
}
});
+ buttonProfile.setSelected(true);
+ buttonProfile.setText("Profile");
+ buttonProfile.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonProfileActionPerformed(evt);
+ }
+ });
+
javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
jPanel7.setLayout(jPanel7Layout);
jPanel7Layout.setHorizontalGroup(
@@ -1744,17 +1925,19 @@ public class ScreenPanel_back extends Panel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonMarker)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(buttonProfile)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonFit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonReticle)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGap(18, 18, Short.MAX_VALUE)
.addComponent(buttonGrabBackground)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonSave)
.addGap(0, 0, 0))
);
- jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonFit, buttonMarker, buttonPause, buttonReticle});
+ jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonFit, buttonMarker, buttonPause, buttonProfile, buttonReticle});
jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonGrabBackground, buttonSave});
@@ -1768,7 +1951,8 @@ public class ScreenPanel_back extends Panel {
.addComponent(buttonMarker)
.addComponent(buttonSave)
.addComponent(buttonReticle)
- .addComponent(buttonGrabBackground))
+ .addComponent(buttonGrabBackground)
+ .addComponent(buttonProfile))
.addGap(0, 0, 0))
);
@@ -1866,7 +2050,7 @@ public class ScreenPanel_back extends Panel {
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
@@ -2121,7 +2305,7 @@ public class ScreenPanel_back extends Panel {
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
- .addContainerGap()
+ .addGap(4, 4, 4)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(buttonAutomatic)
@@ -2246,14 +2430,14 @@ public class ScreenPanel_back extends Panel {
panelScreen2.setBorder(javax.swing.BorderFactory.createTitledBorder("Image"));
- checkThreshold.setText("Threshold");
+ checkThreshold.setText("Threshold:");
checkThreshold.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
checkThresholdActionPerformed(evt);
}
});
- spinnerThreshold.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 65535.0d, 1.0d));
+ spinnerThreshold.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 99999.0d, 1.0d));
spinnerThreshold.setEnabled(false);
spinnerThreshold.setPreferredSize(new java.awt.Dimension(77, 20));
spinnerThreshold.addChangeListener(new javax.swing.event.ChangeListener() {
@@ -2269,6 +2453,35 @@ public class ScreenPanel_back extends Panel {
}
});
+ checkGoodRegion.setText("Good Region");
+ checkGoodRegion.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ checkGoodRegionActionPerformed(evt);
+ }
+ });
+
+ spinnerGrScale.setModel(new javax.swing.SpinnerNumberModel(3.0d, 0.01d, 100.0d, 1.0d));
+ spinnerGrScale.setEnabled(false);
+ spinnerGrScale.setPreferredSize(new java.awt.Dimension(77, 20));
+ spinnerGrScale.addChangeListener(new javax.swing.event.ChangeListener() {
+ public void stateChanged(javax.swing.event.ChangeEvent evt) {
+ spinnerGrThresholdonChange(evt);
+ }
+ });
+
+ spinnerGrThreshold.setModel(new javax.swing.SpinnerNumberModel(0.5d, 0.04d, 1.0d, 0.1d));
+ spinnerGrThreshold.setEnabled(false);
+ spinnerGrThreshold.setPreferredSize(new java.awt.Dimension(77, 20));
+ spinnerGrThreshold.addChangeListener(new javax.swing.event.ChangeListener() {
+ public void stateChanged(javax.swing.event.ChangeEvent evt) {
+ spinnerGrThresholdonChange(evt);
+ }
+ });
+
+ jLabel5.setText("Threshold:");
+
+ jLabel6.setText("Scale:");
+
javax.swing.GroupLayout panelScreen2Layout = new javax.swing.GroupLayout(panelScreen2);
panelScreen2.setLayout(panelScreen2Layout);
panelScreen2Layout.setHorizontalGroup(
@@ -2280,8 +2493,21 @@ public class ScreenPanel_back extends Panel {
.addGroup(panelScreen2Layout.createSequentialGroup()
.addComponent(checkThreshold)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(spinnerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addComponent(spinnerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(panelScreen2Layout.createSequentialGroup()
+ .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addGroup(panelScreen2Layout.createSequentialGroup()
+ .addComponent(checkGoodRegion)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jLabel6)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(spinnerGrScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(panelScreen2Layout.createSequentialGroup()
+ .addGap(0, 0, Short.MAX_VALUE)
+ .addComponent(jLabel5)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(spinnerGrThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap())))
);
panelScreen2Layout.setVerticalGroup(
panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -2292,7 +2518,16 @@ public class ScreenPanel_back extends Panel {
.addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(checkThreshold)
.addComponent(spinnerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap())
+ .addGap(2, 2, 2)
+ .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(checkGoodRegion)
+ .addComponent(spinnerGrScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel6))
+ .addGap(2, 2, 2)
+ .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(spinnerGrThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel5))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
@@ -2435,6 +2670,7 @@ public class ScreenPanel_back extends Panel {
pauseSelection.setValue(imageBuffer.size());;
}
}
+ updateImageData();
}
} catch (Exception ex) {
ex.printStackTrace();
@@ -2453,11 +2689,11 @@ public class ScreenPanel_back extends Panel {
private void buttonFitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonFitActionPerformed
try {
showFit = buttonFit.isSelected();
- if (!buttonFit.isSelected()) {
- renderer.removeOverlays(fitOv);
- fitOv = null;
- } else {
+ if (showFit) {
renderer.setProfile(Renderer.Profile.None);
+ } else {
+ renderer.removeOverlays(fitOv);
+ fitOv = null;
}
} catch (Exception ex) {
showException(ex);
@@ -2483,27 +2719,40 @@ public class ScreenPanel_back extends Panel {
private void buttonGrabBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGrabBackgroundActionPerformed
try {
- if ((camera != null) && (camera instanceof Camtool)) {
+ if (camera != null) {
if (SwingUtils.showOption(getTopLevel(), "Background", "Do you want to capture background now?", OptionType.YesNo) == OptionResult.Yes) {
boolean laserOn = getLaserState();
- boolean rendering = (!camera.isClosed());
- if (rendering) {
- camera.close();
- }
- if (laserOn) {
- setLaserState(false);
- }
- try {
- System.out.println("Grabbing background for: " + cameraName);
- ((Camtool) camera).grabBackground(cameraName, 5);
- } finally {
- if (laserOn) {
- setLaserState(true);
- }
+ if (camera instanceof Camtool){
+ boolean rendering = (!camera.isClosed());
if (rendering) {
- comboCamerasActionPerformed(null);
+ camera.close();
+ }
+ if (laserOn) {
+ setLaserState(false);
+ }
+ try {
+ System.out.println("Grabbing background for: " + cameraName);
+ ((Camtool) camera).grabBackground(cameraName, 5);
+ } finally {
+ if (laserOn) {
+ setLaserState(true);
+ }
+ if (rendering) {
+ comboCamerasActionPerformed(null);
+ }
+ updateStop();
+ }
+ } else {
+ if (laserOn) {
+ setLaserState(false);
+ }
+ try {
+ camera.captureBackground(5, 0);
+ } finally {
+ if (laserOn) {
+ setLaserState(true);
+ }
}
- updateStop();
}
SwingUtils.showMessage(getTopLevel(), "Success", "Success capturing background", 5000);
}
@@ -2679,50 +2928,51 @@ public class ScreenPanel_back extends Panel {
}//GEN-LAST:event_buttonZoom2ActionPerformed
private void spinnerThresholdonChange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerThresholdonChange
- if (updatingCamtoolControls) {
- return;
- }
- try {
- if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) {
- ((Camtool) camera).setThreshold((Double) spinnerThreshold.getValue());
+ if (!updatingCamtoolControls) {
+ try {
+ if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) {
+ ((Camtool) camera).setThreshold((Double) spinnerThreshold.getValue());
+ }
+ } catch (Exception ex) {
+ showException(ex);
+ updateCamtoolControls();
}
- } catch (Exception ex) {
- showException(ex);
- updateCamtoolControls();
}
}//GEN-LAST:event_spinnerThresholdonChange
private void checkBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBackgroundActionPerformed
- if (updatingCamtoolControls) {
- return;
- }
- try {
- if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) {
- ((Camtool) camera).setBackgroundSubtraction(checkBackground.isSelected());
- }
- } catch (Exception ex) {
- showException(ex);
- updateCamtoolControls();
- //There is a bug in camtool: it will flag bg extraction as on:
- updatingCamtoolControls = true;
- checkBackground.setSelected(false);
- updatingCamtoolControls = false;
+ if (camera instanceof Camtool){
+ if (!updatingCamtoolControls) {
+ try {
+ if (((Camtool) camera).isPipelineStarted()) {
+ ((Camtool) camera).setBackgroundSubtraction(checkBackground.isSelected());
+ }
+ } catch (Exception ex) {
+ showException(ex);
+ updateCamtoolControls();
+ //There is a bug in camtool: it will flag bg extraction as on:
+ updatingCamtoolControls = true;
+ checkBackground.setSelected(false);
+ updatingCamtoolControls = false;
+ }
+ }
+ } else {
+ camera.setBackgroundEnabled(checkBackground.isSelected());
}
}//GEN-LAST:event_checkBackgroundActionPerformed
private void checkThresholdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkThresholdActionPerformed
- if (updatingCamtoolControls) {
- return;
- }
- try {
- if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) {
- spinnerThreshold.setEnabled(checkThreshold.isSelected());
- ((Camtool) camera).setThreshold(checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null);
+ if (!updatingCamtoolControls) {
+ try {
+ if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) {
+ spinnerThreshold.setEnabled(checkThreshold.isSelected());
+ ((Camtool) camera).setThreshold(checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null);
+ }
+ } catch (Exception ex) {
+ showException(ex);
+ updateCamtoolControls();
}
- } catch (Exception ex) {
- showException(ex);
- updateCamtoolControls();
}
}//GEN-LAST:event_checkThresholdActionPerformed
@@ -2744,6 +2994,53 @@ public class ScreenPanel_back extends Panel {
}
}//GEN-LAST:event_buttonStopActionPerformed
+ private void buttonProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonProfileActionPerformed
+ try {
+ showProfile = buttonProfile.isSelected();
+ if (showProfile) {
+ renderer.setProfile(Renderer.Profile.None);
+ } else {
+ renderer.removeOverlays(profileOv);
+ profileOv = null;
+ }
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ }//GEN-LAST:event_buttonProfileActionPerformed
+
+ private void checkGoodRegionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkGoodRegionActionPerformed
+ if (!updatingCamtoolControls) {
+ try {
+ if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) {
+ spinnerGrScale.setEnabled(checkGoodRegion.isSelected());
+ spinnerGrThreshold.setEnabled(checkGoodRegion.isSelected());
+ if (checkGoodRegion.isSelected()){
+ ((Camtool) camera).setGoodRegion( (Double)spinnerGrThreshold.getValue(), (Double)spinnerGrScale.getValue() );
+ } else {
+ ((Camtool) camera).setGoodRegion(null);
+ }
+ goodRegion = checkGoodRegion.isSelected();
+ }
+ } catch (Exception ex) {
+ showException(ex);
+ updateCamtoolControls();
+ }
+ }
+ }//GEN-LAST:event_checkGoodRegionActionPerformed
+
+ private void spinnerGrThresholdonChange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerGrThresholdonChange
+ if (!updatingCamtoolControls) {
+ try {
+ if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) {
+ ((Camtool) camera).setGoodRegion( (Double)spinnerGrThreshold.getValue(), (Double)spinnerGrScale.getValue() );
+ }
+ } catch (Exception ex) {
+ showException(ex);
+ updateCamtoolControls();
+ }
+ }
+ }//GEN-LAST:event_spinnerGrThresholdonChange
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonArgs;
private javax.swing.JRadioButton buttonAutomatic;
@@ -2763,6 +3060,7 @@ public class ScreenPanel_back extends Panel {
private javax.swing.JRadioButton buttonManual;
private javax.swing.JToggleButton buttonMarker;
private javax.swing.JToggleButton buttonPause;
+ private javax.swing.JToggleButton buttonProfile;
private javax.swing.JRadioButton buttonRainbow;
private javax.swing.JToggleButton buttonReticle;
private javax.swing.JToggleButton buttonSave;
@@ -2775,6 +3073,7 @@ public class ScreenPanel_back extends Panel {
private javax.swing.JRadioButton buttonZoomNormal;
private javax.swing.JRadioButton buttonZoomStretch;
private javax.swing.JCheckBox checkBackground;
+ private javax.swing.JCheckBox checkGoodRegion;
private javax.swing.JCheckBox checkHistogram;
private javax.swing.JCheckBox checkThreshold;
private javax.swing.JComboBox comboCameras;
@@ -2784,6 +3083,8 @@ public class ScreenPanel_back 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.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
@@ -2798,6 +3099,8 @@ public class ScreenPanel_back extends Panel {
private javax.swing.JPanel panelScreen2;
private ch.psi.pshell.swing.ValueSelection pauseSelection;
private ch.psi.pshell.imaging.Renderer renderer;
+ private javax.swing.JSpinner spinnerGrScale;
+ private javax.swing.JSpinner spinnerGrThreshold;
private javax.swing.JSpinner spinnerMax;
private javax.swing.JSpinner spinnerMin;
private javax.swing.JSpinner spinnerThreshold;