diff --git a/config/jcae.properties b/config/jcae.properties index 76f5958..c95539c 100755 --- a/config/jcae.properties +++ b/config/jcae.properties @@ -1,6 +1,6 @@ -#Mon Sep 05 16:40:34 CEST 2016 +#Fri Sep 09 17:52:49 CEST 2016 ch.psi.jcae.ContextFactory.addressList=172.26.0.255 172.26.2.255 172.26.8.255 172.26.16.255 172.26.24.255 172.26.32.255 172.26.40.255 172.26.120.255 -ch.psi.jcae.ContextFactory.maxArrayBytes=20000000 +ch.psi.jcae.ContextFactory.maxArrayBytes=50000000 ch.psi.jcae.ChannelFactory.retries=1 ch.psi.jcae.ChannelFactory.timeout=500 ch.psi.jcae.impl.DefaultChannelService.retries=4 diff --git a/config/setup.properties b/config/setup.properties index 216c670..f90ceb0 100755 --- a/config/setup.properties +++ b/config/setup.properties @@ -1,4 +1,4 @@ -#Wed Dec 09 13:50:24 CET 2015 +#Fri Sep 09 14:11:02 CEST 2016 configFile={config}/config.properties configFileDevices={config}/devices.properties configFilePlugins={config}/plugins.properties @@ -9,6 +9,7 @@ contextPath={outp}/context dataPath={outp}/data devicesPath={home}/devices extensionsPath={home}/extensions +imagesPath={outp}/images libraryPath={script}; {script}/Lib logPath={outp}/log pluginsPath={home}/plugins diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index 4552a47..de4ab36 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,14 +1,14 @@ -#Thu Sep 08 17:53:42 CEST 2016 -colormap=Grayscale -colormapAutomatic=false +#Fri Sep 09 17:59:58 CEST 2016 +colormap=Temperature +colormapAutomatic=true colormapMax=0.0 -colormapMin=65535.0 -flipHorizontally=false -flipVertically=false +colormapMin=255.0 +flipHorizontally=true +flipVertically=true grayscale=false imageHeight=1628 imageWidth=1280 -invert=false +invert=true rescaleFactor=1.0 rescaleOffset=0.0 roiHeight=-1 @@ -19,8 +19,8 @@ rotation=0.0 rotationCrop=true scale=1.0 spatialCalOffsetX=-685.0 -spatialCalOffsetY=-874.0 -spatialCalScaleX=13.612279307222428 -spatialCalScaleY=12.708498808578236 +spatialCalOffsetY=-498.0 +spatialCalScaleX=16.0 +spatialCalScaleY=16.0 spatialCalUnits=mm transpose=false diff --git a/plugins/Cameras.form b/plugins/Cameras.form index b7f318a..24ea7fb 100644 --- a/plugins/Cameras.form +++ b/plugins/Cameras.form @@ -16,16 +16,16 @@ - + - - - + + + - + @@ -35,8 +35,21 @@ + + + + + + + + + + + + + - + @@ -53,9 +66,18 @@ - - - + + + + + + + + + + + + @@ -69,6 +91,9 @@ + + + @@ -110,5 +135,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/Cameras.java b/plugins/Cameras.java index 6031fa0..651d1b2 100644 --- a/plugins/Cameras.java +++ b/plugins/Cameras.java @@ -14,16 +14,23 @@ import ch.psi.utils.IO; import ch.psi.utils.swing.SwingUtils; import ch.psi.utils.swing.TextEditor; import ch.psi.pshell.epics.PsiCamera; -import ch.psi.pshell.epics.Camtool; +//import ch.psi.pshell.epics.Camtool; import ch.psi.pshell.core.JsonSerializer; +import ch.psi.pshell.device.Device; import ch.psi.pshell.epics.ArraySource; +import ch.psi.pshell.epics.ChannelDouble; +import ch.psi.pshell.epics.ChannelDoubleArray; +import ch.psi.pshell.epics.ChannelInteger; +import ch.psi.pshell.epics.ChannelIntegerArray; import ch.psi.pshell.ui.App; import ch.psi.pshell.imaging.Data; import ch.psi.pshell.imaging.Overlay; import ch.psi.pshell.imaging.Overlays; +import ch.psi.pshell.imaging.Overlays.Text; import ch.psi.pshell.imaging.Pen; -import ch.psi.pshell.imaging.PointDouble; +import static ch.psi.pshell.imaging.Renderer.PEN_ERROR_TEXT; import ch.psi.pshell.imaging.Renderer.Profile; +import static ch.psi.pshell.imaging.RendererMenu.PEN_MARKER; import ch.psi.pshell.imaging.Source; import ch.psi.pshell.imaging.Utils; import ch.psi.pshell.scripting.InterpreterResult; @@ -35,6 +42,7 @@ import ch.psi.utils.swing.Editor.EditorDialog; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; +import java.awt.Font; import java.awt.Point; import java.awt.image.BufferedImage; import java.nio.file.Files; @@ -70,6 +78,7 @@ public class Cameras extends Panel { if (App.hasArgument("zoom")) { try{ renderer.setDefaultZoom(Double.valueOf(App.getArgumentValue("zoom"))); + renderer.resetZoom(); } catch (Exception ex){ ex.printStackTrace(); } @@ -172,6 +181,25 @@ public class Cameras extends Panel { return (ArrayList) state.get("calibration"); } + public double getCalOffsetX(){ + ArrayList calibration = getCalibration(); + return - (calibration.get(0) + calibration.get(2))/2; + } + + public double getCalOffsetY(){ + ArrayList calibration = getCalibration(); + return - (calibration.get(1) + calibration.get(2))/3; + } + + public double getScaleX(){ + return getCalibrationHeight()/1000; + } + + public double getScaleY(){ + return getCalibrationHeight()/1000; + } + + public Double getCalibrationHeight() { return (Double) state.get("calibration_height"); } @@ -233,7 +261,9 @@ public class Cameras extends Panel { camera = null; renderer.setDevice(null); renderer.setShowReticle(false); + renderer.clearOverlays(); renderer.clear(); + renderer.resetZoom(); } try { Path configFile = Paths.get(configFolder, cameraName + ".json"); @@ -242,7 +272,7 @@ public class Cameras extends Panel { //SwingUtils.showMessage(null, "", json); try { if (checkCamtool.isSelected()) { - camera = new Camtool("CurrentCamera", cameraName, false, true); + camera = new Camtool("CurrentCamera", cameraName, false); camera.getConfig().flipHorizontally = false; camera.getConfig().flipVertically = false; camera.getConfig().rotation = 0.0; @@ -261,19 +291,17 @@ public class Cameras extends Panel { camera.getConfig().roiY = config.getRoiEnable() ? config.getRoi().get(1) : 0; camera.getConfig().roiWidth = config.getRoiEnable() ? config.getRoi().get(2) : -1; camera.getConfig().roiHeight = config.getRoiEnable() ? config.getRoi().get(3) : -1; - //camera.getConfig().spatialCalOffsetX = (config.getOrigin()!=null) ? config.getOrigin().get(0) : Double.NaN; - //camera.getConfig().spatialCalOffsetY = (config.getOrigin()!=null) ? config.getOrigin().get(1) : Double.NaN; - //camera.getConfig().spatialCalScaleX = (config.getUnitSize()!=null) && (config.getOrigin().get(0)!=0) ? 1.0/(config.getOrigin().get(0)*1000) : Double.NaN; - //camera.getConfig().spatialCalScaleY= (config.getUnitSize()!=null) && (config.getOrigin().get(1)!=0) ? 1.0/(config.getOrigin().get(1)*1000) : Double.NaN; - - ArrayList calibration = config.getCalibration(); - if ((calibration != null) && (calibration.size() != 4)) { - calibration = null; + try{ + camera.getConfig().spatialCalOffsetX = config.getCalOffsetX(); + camera.getConfig().spatialCalOffsetY = config.getCalOffsetY(); + camera.getConfig().spatialCalScaleX = config.getScaleX(); + camera.getConfig().spatialCalScaleY = config.getScaleY(); + } catch (Exception ex){ + camera.getConfig().spatialCalOffsetX = Double.NaN; + camera.getConfig().spatialCalOffsetY = Double.NaN; + camera.getConfig().spatialCalScaleX = Double.NaN; + camera.getConfig().spatialCalScaleY = Double.NaN; } - camera.getConfig().spatialCalOffsetX = (calibration != null) ? -calibration.get(2) : Double.NaN; - camera.getConfig().spatialCalOffsetY = (calibration != null) ? -calibration.get(3) : Double.NaN; - camera.getConfig().spatialCalScaleX = (calibration != null) && (calibration.get(0) != 0) ? 1.0 / (calibration.get(0)) : Double.NaN; - camera.getConfig().spatialCalScaleY = (calibration != null) && (calibration.get(1) != 0) ? 1.0 / (calibration.get(1)) : Double.NaN; } } catch (Exception ex) { config = null; @@ -301,6 +329,8 @@ public class Cameras extends Panel { } */ } + buttonReticle.setEnabled(camera.getConfig().isCalibrated()); + buttonBackground.setEnabled(camera instanceof Camtool); camera.getConfig().save(); if (polling<=0){ @@ -314,48 +344,47 @@ public class Cameras extends Panel { camera.addListener(new ImageListener() { @Override public void onImage(Object o, BufferedImage bi, Data data) { - + if (bi!=null){ + System.out.println(bi.getWidth() + " - " + bi.getHeight()); + } if (bi == null) { renderer.removeOverlays(fitOv); fitOv = null; } else { - //if (renderer.getReticle() != null) { - // renderer.getReticle().setSize(new Dimension(bi.getWidth(), bi.getHeight())); - //} -//long start = System.currentTimeMillis(); - Overlay[] profile = renderer.getProfileOverlays(); -//System.out.println(System.currentTimeMillis() - start); - profile = ((profile != null) && (profile.length==4)) ? getFitOverlays(bi) : null; - renderer.updateOverlays(profile, fitOv); - fitOv = profile; + if (!renderer.isPaused() && buttonFit.isSelected()){ + Overlay[] profile = renderer.getProfileOverlays(); + profile = ((profile != null) && (profile.length==4)) ? getFitOverlays(bi) : null; + renderer.updateOverlays(profile, fitOv); + fitOv = profile; + } } - //camera.removeListener(this); } @Override public void onError(Object o, Exception excptn) { } }); - - } finally { - if (renderer.getZoom() > 1.0){ - renderer.resetZoom(); - } - if (camera != null) { - if (camera.getConfig().isCalibrated()){ -System.out.println("Calibrated"); - renderer.setCalibration(camera.getCalibration()); - renderer.configureReticle(new Dimension(800,800), 200); - renderer.setShowReticle(true); - } else{ -System.out.println("Not Calibrated"); - - } - } - - onTimer(); + } catch (Exception ex) { + if (renderer.getDevice()==null){ + renderer.setZoom(1.0); + renderer.addOverlay(new Text(PEN_ERROR_TEXT, ex.toString(), new Font("Verdana", Font.PLAIN, 12), new Point(20, 20))); + } + } finally { + checkReticle(); + onTimer(); } } + + void checkReticle(){ + if ((renderer.getDevice()!=null) && (camera!=null) && (camera.getConfig().isCalibrated()) && buttonReticle.isSelected()){ + renderer.setCalibration(camera.getCalibration()); + renderer.configureReticle(new Dimension(800,800), 200); + renderer.setShowReticle(true); + } else { + renderer.setShowReticle(false); + } + renderer.refresh(); + } @Override protected void onTimer() { @@ -502,6 +531,227 @@ double[]fitGaussian(double[] y, int[] x){ return fit; } +public class Camtool extends ArraySource { + + final String prefix; + final String dataPrefix; + final boolean latch; + + final public ChannelInteger channelRun; + final public ChannelInteger channelLatch; + final public ChannelDouble channelTimestamp; + final public ChannelDoubleArray origin; + final public ChannelDouble posX, posY; + final public ChannelDoubleArray profileX, profileY; + final public ChannelIntegerArray shape; + final public ChannelInteger roiEnabled; + final public ChannelIntegerArray roiShape; + final public ChannelInteger bgEnable, bgCapture, bgCaptureRemain; + final public ChannelDouble calOffX, calOffY, calScaleX, calScaleY; + + public Camtool(String name, String prefix) { + this(name, prefix, false); + } + + public Camtool(String name, String prefix, boolean latch) { + //super(name, prefix + (latch ? ":latch" : ":pipeline") + (roi ? ".roi.output" : ".image")); + super(name, prefix + (latch ? ":latch" : ":pipeline") + ".roi.output"); + this.prefix = prefix + ":"; + this.latch = latch; + dataPrefix = this.prefix + (latch ? "latch" : "pipeline") + "."; + + channelRun = new ChannelInteger(name + " run", this.prefix + "camera.run"); + channelLatch = new ChannelInteger(name + " latch", this.prefix + "latch.capture"); + channelTimestamp = new ChannelDouble(name + " timestamp", dataPrefix + "timestamp"); + channelTimestamp.setMonitored(true); + //posX = new ChannelDouble(name + " com x", dataPrefix + "x_stats.com"); + //posY = new ChannelDouble(name + " com y", dataPrefix + "y_stats.com"); + posX = new ChannelDouble(name + " com x", dataPrefix + "x_stats.com_egu"); + posY = new ChannelDouble(name + " com y", dataPrefix + "y_stats.com_egu"); + profileX = new ChannelDoubleArray(name + " profile x", dataPrefix + "profile.x"); + profileY = new ChannelDoubleArray(name + " profile y", dataPrefix + "profile.y"); + //shape = new ChannelIntegerArray(name + " shape", dataPrefix + (roi ? "roi.output.shape" : "image.shape")); + shape = new ChannelIntegerArray(name + " shape", dataPrefix + ("image.shape")); + roiShape = new ChannelIntegerArray(name + " roi shape", dataPrefix + "roi.roi"); + roiEnabled = new ChannelInteger(name + " roi enabled", dataPrefix + "roi.enabled"); + //origin = new ChannelDoubleArray(name + " origin X", roi ? (dataPrefix + "roi.origin_out") : (prefix + "origin")); + origin = new ChannelDoubleArray(name + " origin X", dataPrefix + "roi.origin_out"); + bgEnable = new ChannelInteger(name + " bg enable", this.prefix + "pipeline.bg.enabled"); + bgCapture = new ChannelInteger(name + " bg capture", this.prefix + "pipeline.bg.capture"); + bgCaptureRemain = new ChannelInteger(name + " bg capture remain", this.prefix + "pipeline.bg.capture_remain"); + calOffX = new ChannelDouble(name + " cal off x", this.prefix + "pipeline.egu.eoff_x"); + calOffY = new ChannelDouble(name + " cal off y", this.prefix + "pipeline.egu.eoff_y"); + calScaleX = new ChannelDouble(name + " cal scale x", this.prefix + "pipeline.egu.eslo_x"); + calScaleY = new ChannelDouble(name + " cal scale y", this.prefix + "pipeline.egu.eslo_y"); + } + + @Override + public void doSetMonitored(boolean value) { + super.doSetMonitored(value); + getDevice().setMonitored(value); + } + + @Override + public void doUpdate() throws IOException, InterruptedException { + super.doUpdate(); + getDevice().update(); + } + + void safeInitialize(Device dev, int timeout) throws IOException, InterruptedException { + for (int retries = 0; retries < 10; retries++) { + try { + dev.initialize(); + break; + } catch (IOException ex) { + if (retries == 9) { + throw ex; + } + Thread.sleep(timeout / 10); + } + } + } + + + @Override + protected void doInitialize() throws IOException, InterruptedException { + try { + channelRun.initialize(); + channelLatch.initialize(); + if (latch) { + start(); + latch(); + } + safeInitialize(channelTimestamp, 2000); + posX.initialize(); + posY.initialize(); + profileX.initialize(); + profileY.initialize(); + shape.initialize(); + roiShape.initialize(); + roiEnabled.initialize(); + origin.initialize(); + bgEnable.initialize(); + bgCapture.initialize(); + bgCaptureRemain.initialize(); + try { + calOffX.initialize(); + calOffY.initialize(); + calScaleX.initialize(); + calScaleY.initialize(); + } catch (Exception ex) { + ex.printStackTrace(); + } + + if (roiEnabled.read()>0){ + int[] s = roiShape.read(); + for (int x : s){ + System.out.println(x); + } + getConfig().imageHeight = s[3]; + getConfig().imageWidth = s[2]; + } else { + int[] s = shape.read(); + for (int x : s){ + System.out.println(x); + } + getConfig().imageHeight = s[0]; + getConfig().imageWidth = s[1]; + } + + getConfig().save(); + getDevice().setSize(getConfig().imageHeight * getConfig().imageWidth); + super.doInitialize(); + System.out.println(((int[])(getDevice().read())).length); + } catch (InterruptedException ex) { + throw ex; + } catch (Exception ex) { + ex.printStackTrace(); + throw new IOException(ex); + } + } + + int numImages = 1; + + public int getNumImages() { + return numImages; + } + + public void setNumImages(int value) { + numImages = value; + } + + double grabTimeout = 3.0; + + public double getGrabTimeout() { + return grabTimeout; + } + + public void setGrabTimeou(double value) { + grabTimeout = value; + } + + public void capture() throws IOException, InterruptedException { + int retries = 3; + while (true) { + try { + double timestamp = channelTimestamp.read(); + if (latch) { + channelLatch.write(1); + } else { + channelRun.write(1); + } + long start = System.currentTimeMillis(); + while (true) { + double val = channelTimestamp.read(); + if (timestamp != val) { + return; + } + if ((System.currentTimeMillis() - start) > grabTimeout) { + throw new IOException("Frame timeout"); + } + Thread.sleep(5); + } + } catch (IOException ex) { + retries--; + if (--retries <= 0) { + throw ex; + } + } + } + } + + public void start() throws IOException, InterruptedException { + channelRun.write(-1); + } + + public void stop() throws IOException, InterruptedException { + channelRun.write(0); + } + + public void grabSingle() throws IOException, InterruptedException { + channelRun.write(1); + } + + public void latch() throws IOException, InterruptedException { + channelLatch.write(1); + } + + public void enableBackground(boolean value) throws IOException, InterruptedException { + bgEnable.write(value ? 1 : 0); + } + + public void captureBackground(int images) throws IOException, InterruptedException { + start(); + bgCapture.write(images); + Thread.sleep(200); + while (bgCaptureRemain.read() > 0) { + Thread.sleep(10); + } + } + +} + + //////// @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents @@ -515,9 +765,16 @@ double[]fitGaussian(double[] y, int[] x){ buttonConfig = new javax.swing.JButton(); buttonSetup = new javax.swing.JButton(); checkCamtool = new javax.swing.JCheckBox(); + buttonFit = new javax.swing.JToggleButton(); + buttonPause = new javax.swing.JToggleButton(); + buttonMarker = new javax.swing.JToggleButton(); + buttonSave = new javax.swing.JToggleButton(); + buttonBackground = new javax.swing.JToggleButton(); + buttonReticle = new javax.swing.JToggleButton(); jLabel1.setText("Camera:"); + comboCameras.setMaximumRowCount(30); comboCameras.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { comboCamerasActionPerformed(evt); @@ -548,20 +805,64 @@ double[]fitGaussian(double[] y, int[] x){ checkCamtool.setSelected(true); checkCamtool.setText("Camtool"); + buttonFit.setSelected(true); + buttonFit.setText("Fit"); + buttonFit.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonFitActionPerformed(evt); + } + }); + + buttonPause.setText("Pause"); + buttonPause.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonPauseActionPerformed(evt); + } + }); + + buttonMarker.setText("Marker"); + buttonMarker.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonMarkerActionPerformed(evt); + } + }); + + buttonSave.setText("Save Snapshot"); + buttonSave.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonSaveActionPerformed(evt); + } + }); + + buttonBackground.setText("Grab Background"); + buttonBackground.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonBackgroundActionPerformed(evt); + } + }); + + buttonReticle.setSelected(true); + buttonReticle.setText("Reticle"); + buttonReticle.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonReticleActionPerformed(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(renderer, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(checkCamtool) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(comboCameras, 0, 218, Short.MAX_VALUE) + .addComponent(comboCameras, 0, 170, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(buttonConfig) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) @@ -569,12 +870,28 @@ double[]fitGaussian(double[] y, int[] x){ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(buttonPause) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonMarker) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonFit) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonReticle) + .addGap(18, 18, Short.MAX_VALUE) + .addComponent(buttonBackground) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonSave))) .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonConfig, buttonSetup}); + layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonBackground, buttonSave}); + + layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonFit, buttonMarker, buttonPause, buttonReticle}); + layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() @@ -587,9 +904,17 @@ double[]fitGaussian(double[] y, int[] x){ .addComponent(buttonConfig) .addComponent(buttonSetup) .addComponent(checkCamtool)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE) - .addGap(6, 6, 6)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE) + .addGap(12, 12, 12) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonPause) + .addComponent(buttonFit) + .addComponent(buttonMarker) + .addComponent(buttonSave) + .addComponent(buttonBackground) + .addComponent(buttonReticle)) + .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboCameras, textState}); @@ -643,8 +968,85 @@ double[]fitGaussian(double[] y, int[] x){ } }//GEN-LAST:event_buttonSetupActionPerformed + private void buttonPauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPauseActionPerformed + try { + if (camera != null) { + if (buttonPause.isSelected()){ + renderer.pause(); + } else { + renderer.resume(); + } + } + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonPauseActionPerformed + + private void buttonMarkerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMarkerActionPerformed + try { + if (camera != null) { + if (buttonMarker.isSelected()){ + Dimension d = renderer.getImageSize(); + Point p = (d == null) ? new Point(renderer.getWidth() / 2, renderer.getHeight() / 2) : new Point(d.width / 2, d.height / 2); + Overlay ov = null; + ov = new Overlays.Crosshairs(PEN_MARKER, p, new Dimension(100, 100)); + ov.setMovable(true); + renderer.setMarker(ov); + } else { + renderer.setMarker(null); + } + } + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonMarkerActionPerformed + + private void buttonFitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonFitActionPerformed + try { + renderer.setProfile(buttonFit.isSelected() ? Profile.Both :Profile.None); + if (!buttonFit.isSelected()){ + renderer.removeOverlays(fitOv); + fitOv = null; + } + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonFitActionPerformed + + private void buttonReticleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReticleActionPerformed + try { + checkReticle(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonReticleActionPerformed + + private void buttonBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonBackgroundActionPerformed + try { + if (camera instanceof Camtool){ + ((Camtool)camera).captureBackground(5); + } + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonBackgroundActionPerformed + + private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveActionPerformed + try { + renderer.setSnapshotDialogVisible(buttonSave.isSelected()); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonSaveActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JToggleButton buttonBackground; private javax.swing.JButton buttonConfig; + private javax.swing.JToggleButton buttonFit; + private javax.swing.JToggleButton buttonMarker; + private javax.swing.JToggleButton buttonPause; + private javax.swing.JToggleButton buttonReticle; + private javax.swing.JToggleButton buttonSave; private javax.swing.JButton buttonSetup; private javax.swing.JCheckBox checkCamtool; private javax.swing.JComboBox comboCameras;