Multi-Frame Integration selected by popup menu
This commit is contained in:
@@ -42,8 +42,6 @@ import ch.psi.pshell.imaging.Renderer;
|
||||
import ch.psi.pshell.imaging.RendererListener;
|
||||
import ch.psi.pshell.imaging.RendererMode;
|
||||
import ch.psi.pshell.imaging.Source;
|
||||
import ch.psi.pshell.imaging.SourceBase;
|
||||
import ch.psi.pshell.imaging.Utils;
|
||||
import ch.psi.pshell.scripting.InterpreterResult;
|
||||
import ch.psi.pshell.scripting.ScriptManager;
|
||||
import ch.psi.pshell.swing.DeviceValueChart;
|
||||
@@ -60,9 +58,9 @@ import ch.psi.utils.swing.StandardDialog.StandardDialogListener;
|
||||
import ch.psi.utils.swing.SwingUtils.OptionResult;
|
||||
import ch.psi.utils.swing.SwingUtils.OptionType;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Point;
|
||||
@@ -93,10 +91,13 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
@@ -318,10 +319,10 @@ public class ScreenPanel3 extends Panel {
|
||||
}
|
||||
if (App.hasArgument("integration")) {
|
||||
try {
|
||||
integration = Integer.valueOf(App.getArgumentValue("integration"));
|
||||
if (integration != 0) {
|
||||
setIntegration(Integer.valueOf(App.getArgumentValue("integration")));
|
||||
if (integration!=0){
|
||||
buttonFit.setSelected(false);
|
||||
buttonProfile.setSelected(false);
|
||||
buttonProfile.setSelected(false);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -447,9 +448,49 @@ public class ScreenPanel3 extends Panel {
|
||||
} catch (IOException ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JCheckBoxMenuItem menuFrameIntegration = new JCheckBoxMenuItem("Multi-Frame", (integration!=0));
|
||||
menuFrameIntegration.addActionListener((ActionEvent e) -> {
|
||||
if (integration==0){
|
||||
JPanel panel = new JPanel();
|
||||
GridBagLayout layout = new GridBagLayout();
|
||||
layout.columnWidths = new int[]{150, 50}; //Minimum width
|
||||
layout.rowHeights = new int[]{30, 30}; //Minimum height
|
||||
panel.setLayout(layout);
|
||||
JCheckBox checkContinuous = new JCheckBox("");
|
||||
JTextField textFrames = new JTextField();
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.gridx = 0;
|
||||
c.gridy = 0;
|
||||
panel.add(new JLabel("Number of frames:"), c);
|
||||
c.gridy = 1;
|
||||
panel.add(new JLabel("Continuous:"), c);
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
c.gridx = 1;
|
||||
panel.add(checkContinuous, c);
|
||||
c.gridy = 0;
|
||||
panel.add(textFrames, c);
|
||||
if (SwingUtils.showOption(getTopLevel(), "Multi-Frame Integration", panel, OptionType.OkCancel) == OptionResult.Yes) {
|
||||
setIntegration(checkContinuous.isSelected() ? -(Integer.valueOf(textFrames.getText())): (Integer.valueOf(textFrames.getText())));
|
||||
}
|
||||
} else {
|
||||
if (SwingUtils.showOption(getTopLevel(), "Multi-Frame Integration",
|
||||
"Do you want to disable " + ((integration<0)? "continuous ":"") +"multi-frame integration (" + Math.abs(integration)+ ")?", OptionType.YesNo) == OptionResult.Yes) {
|
||||
setIntegration(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
System.out.println("---");
|
||||
for (Component cmp : SwingUtils.getComponentsByType(renderer.getPopupMenu(),JMenu.class)){
|
||||
JMenu menu = (JMenu)cmp;
|
||||
if (menu.getText().equals("Integration")){
|
||||
menu.addSeparator();
|
||||
menu.add(menuFrameIntegration);
|
||||
}
|
||||
}
|
||||
renderer.getPopupMenu().addSeparator();
|
||||
renderer.getPopupMenu().add(menuRendererConfig);
|
||||
renderer.getPopupMenu().add(menuCameraConfig);
|
||||
@@ -469,6 +510,7 @@ public class ScreenPanel3 extends Panel {
|
||||
menuCalibrate.setEnabled((calibrationDialolg == null) || (!calibrationDialolg.isShowing()));
|
||||
menuSaveStack.setEnabled(imageBufferLenght > 0);
|
||||
menuSetImageBufferSize.setEnabled(!renderer.isPaused());
|
||||
menuFrameIntegration.setSelected(integration!=0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -501,6 +543,27 @@ public class ScreenPanel3 extends Panel {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
void setIntegration(int frames){
|
||||
try {
|
||||
if (integration != frames){
|
||||
integration = frames;
|
||||
if (camera!=null){
|
||||
if (Math.abs(integration) > 1) {
|
||||
renderer.setDevice(new ImageIntegrator(integration));
|
||||
} else {
|
||||
renderer.setDevice(camera);
|
||||
}
|
||||
synchronized (imageBuffer) {
|
||||
currentFrame = null;
|
||||
imageBuffer.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
Reference in New Issue
Block a user