From 395ed8bf9c4170eff05913743c8701135a1a1892 Mon Sep 17 00:00:00 2001 From: gac-x09la Date: Thu, 21 Oct 2021 11:49:50 +0200 Subject: [PATCH] Ordered actions and hierarchical scan folder --- config/variables.properties | 8 +- devices/master.properties | 8 +- plugins/SIStem.form | 213 ++++++++---- plugins/SIStem.java | 660 ++++++++++++++++++++++++++---------- script/scans/scan1.json | 14 +- script/scans/scan2.json | 14 +- script/scans/scan3.json | 12 +- script/scans/scan4.json | 24 ++ script/scans/test/test.json | 18 + script/templates/SIStem.py | 8 +- 10 files changed, 690 insertions(+), 289 deletions(-) create mode 100644 script/scans/scan4.json create mode 100644 script/scans/test/test.json diff --git a/config/variables.properties b/config/variables.properties index 4b4e5ee..057e20b 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,4 +1,4 @@ -#Wed Sep 29 10:51:37 CEST 2021 -LastRunDate=210929 -DaySequentialNumber=9 -FileSequentialNumber=24 +#Thu Sep 30 11:47:34 CEST 2021 +LastRunDate=210930 +DaySequentialNumber=7 +FileSequentialNumber=53 diff --git a/devices/master.properties b/devices/master.properties index 60bdc03..85646bd 100644 --- a/devices/master.properties +++ b/devices/master.properties @@ -1,12 +1,12 @@ -#Wed Sep 29 10:50:35 CEST 2021 +#Wed Sep 29 11:32:23 CEST 2021 slave2Positions=-0.3|0.1|0.6 offset=0.0 maxValue=100.0 -slave5Positions= +slave5Positions=null rotation=false precision=4 scale=1.0 -slave4Positions= +slave4Positions=null resolution=0.1 mode=LINEAR minValue=-100.0 @@ -15,4 +15,4 @@ slave1Positions=0.2|1.0|1.3 slave3Positions=-0.5|0.0|0.7 sign_bit=0 masterPositions=-1.0|0.0|1.0 -slave6Positions= +slave6Positions=null diff --git a/plugins/SIStem.form b/plugins/SIStem.form index a2a5e3a..2b6c8b9 100644 --- a/plugins/SIStem.form +++ b/plugins/SIStem.form @@ -21,7 +21,9 @@ - + + + @@ -64,6 +66,7 @@ + @@ -126,6 +129,9 @@ + + + @@ -145,12 +151,12 @@ - - - - - - + + + + + + @@ -161,9 +167,9 @@ - - - + + + @@ -172,7 +178,7 @@ - + @@ -285,7 +291,7 @@ - + @@ -398,7 +404,7 @@ - + @@ -544,6 +550,9 @@ + + + @@ -587,74 +596,93 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - + + + + + + + + - - + + + + + - - - + + + + + + + + + + + + + + - + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - @@ -692,11 +720,17 @@ + + + + + + @@ -708,11 +742,17 @@ + + + + + + @@ -723,11 +763,34 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -785,7 +848,7 @@ - + @@ -862,7 +925,7 @@ - + @@ -989,7 +1052,7 @@ - + @@ -1143,5 +1206,13 @@ + + + + + + + + diff --git a/plugins/SIStem.java b/plugins/SIStem.java index b0eff54..0667d29 100644 --- a/plugins/SIStem.java +++ b/plugins/SIStem.java @@ -1,8 +1,12 @@ +import ch.psi.pshell.core.Context; import ch.psi.pshell.core.JsonSerializer; import ch.psi.pshell.device.Motor; import ch.psi.pshell.device.Positioner; import ch.psi.pshell.device.ReadonlyProcessVariable; +import ch.psi.pshell.plot.MatrixPlotSeries; +import ch.psi.pshell.plot.Plot; +import ch.psi.pshell.swing.DataPanel; import ch.psi.pshell.ui.PanelProcessor; import ch.psi.pshell.ui.QueueProcessor; import ch.psi.utils.Arr; @@ -11,6 +15,8 @@ import ch.psi.utils.IO; import ch.psi.utils.Reflection; import ch.psi.utils.State; import ch.psi.utils.swing.SwingUtils; +import java.awt.Color; +import java.awt.Component; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; @@ -22,6 +28,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.logging.Level; @@ -29,6 +36,7 @@ import java.util.logging.Logger; import javax.swing.DropMode; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.JTable; import javax.swing.JTextArea; @@ -46,18 +54,20 @@ public class SIStem extends PanelProcessor { final DefaultTableModel modelInactive; final DefaultTableModel modelFixed; final DefaultTableModel modelScanned; + QueueProcessor queueProcessor; + JDialog dataDialog; public static final String FILE_EXTENSION = "json"; final JTextField[] scientaFloatFields; final JTextField[] scientaIntFields; final JComboBox[] scientaCombos; - final JTextField[] scientaRangeFields; - + final JTextField[] scientaRangeFields; + public SIStem() { initComponents(); modelInactive = (DefaultTableModel) tableInactive.getModel(); modelFixed = (DefaultTableModel) tableFixed.getModel(); - modelScanned = (DefaultTableModel) tableScanned.getModel(); + modelScanned = (DefaultTableModel) tableScanned.getModel(); abstract class PositinerTransferHandler extends TransferHandler { @@ -130,12 +140,12 @@ public class SIStem extends PanelProcessor { } }); - scientaFloatFields = new JTextField[]{textLowEnergy, textCenterEnergy, textHighEnergy, textStepEnergy, - textLowThetaY, textCenterThetaY, textHighThetaY, textStepThetaY, textCenterThetaX}; - scientaIntFields= new JTextField[]{textSlices, textChannels}; - scientaRangeFields = new JTextField[]{ textXChannelMax, textXChannelMin, textYChannelMax, textYChannelMin}; - scientaCombos = new JComboBox[]{ comboPass, comboAcquisition, comboEnergy, comboLens, comboDetMode}; - + scientaFloatFields = new JTextField[]{textLowEnergy, textCenterEnergy, textHighEnergy, textStepEnergy, + textLowThetaY, textCenterThetaY, textHighThetaY, textStepThetaY, textCenterThetaX}; + scientaIntFields = new JTextField[]{textSlices, textChannels}; + scientaRangeFields = new JTextField[]{textXChannelMax, textXChannelMin, textYChannelMax, textYChannelMin}; + scientaCombos = new JComboBox[]{comboPass, comboAcquisition, comboEnergy, comboLens, comboDetMode}; + try { Class scienta = getContext().getClassByName("Scienta"); SwingUtils.setEnumCombo(comboLens, Reflection.getDeclaredClass(scienta, "LensMode"), true); @@ -146,10 +156,13 @@ public class SIStem extends PanelProcessor { } catch (Exception ex) { getLogger().log(Level.SEVERE, null, ex); } - - for (JComboBox combo : scientaCombos){ + + for (JComboBox combo : scientaCombos) { SwingUtils.insertCombo(combo, "", 0); } + buttonData.setVisible(isDetached()); + detectorPlot.getAxis(Plot.AxisId.X).setLabel("X-Scale (energy)"); + detectorPlot.getAxis(Plot.AxisId.Y).setLabel("Y-Scale (distance or angle)"); clear(); } @@ -177,7 +190,7 @@ public class SIStem extends PanelProcessor { //Overridable callbacks @Override public void onInitialize(int runCount) { - if (runCount==0) { + if (runCount == 0) { clear(); } } @@ -239,27 +252,27 @@ public class SIStem extends PanelProcessor { @Override public void saveAs(String fileName) throws IOException { currentFile = new File(fileName); - Map preActions = new HashMap(); - - for (JComboBox combo : scientaCombos){ - if (combo.getSelectedIndex()>0){ + Map preActions = new LinkedHashMap(); + + for (JComboBox combo : scientaCombos) { + if ((combo.isVisible()) &&(combo.getSelectedIndex() > 0)) { preActions.put(combo.getName(), String.valueOf(combo.getSelectedItem())); } } - for (JTextField text :scientaFloatFields) { - if (!text.getText().isBlank()){ - preActions.put(text.getName(), Double.valueOf(text.getText().trim())); - } - } - for (JTextField text :scientaIntFields) { - if (!text.getText().isBlank()){ - preActions.put(text.getName(), Integer.valueOf(text.getText().trim())); - } - } + for (JTextField text : scientaFloatFields) { + if ((text.isVisible()) && (!text.getText().isBlank())) { + preActions.put(text.getName(), Double.valueOf(text.getText().trim())); + } + } + for (JTextField text : scientaIntFields) { + if ((text.isVisible()) &&(!text.getText().isBlank())) { + preActions.put(text.getName(), Integer.valueOf(text.getText().trim())); + } + } for (int i = 0; i < modelFixed.getRowCount(); i++) { preActions.put(modelFixed.getValueAt(i, 0), modelFixed.getValueAt(i, 1)); } - + String[] positioners = new String[modelScanned.getRowCount()]; Double[] start = new Double[modelScanned.getRowCount()]; Double[] stop = new Double[modelScanned.getRowCount()]; @@ -270,16 +283,15 @@ public class SIStem extends PanelProcessor { stop[i] = (Double) modelScanned.getValueAt(i, 2); steps[i] = (Integer) modelScanned.getValueAt(i, 3) - 1; } - + Integer[] range = new Integer[4]; - for (int i=0; i< scientaRangeFields.length; i++){ + for (int i = 0; i < scientaRangeFields.length; i++) { range[i] = scientaRangeFields[i].getText().isBlank() ? null : Integer.valueOf(scientaRangeFields[i].getText().trim()); } - Map config = new HashMap(); config.put("PRE_ACTIONS", preActions); - config.put("RANGE", range.equals(new Integer[]{null,null,null,null}) ? new ArrayList() : Arr.toList(range)); + config.put("RANGE", range.equals(new Integer[]{null, null, null, null}) ? new ArrayList() : Arr.toList(range)); config.put("POSITIONERS", positioners); config.put("START", start); config.put("STOP", stop); @@ -315,23 +327,23 @@ public class SIStem extends PanelProcessor { List positioners = (List) config.get("POSITIONERS"); List start = (List) config.get("START"); List stop = (List) config.get("STOP"); - List steps = (List) config.get("STEPS"); + List steps = (List) config.get("STEPS"); for (String name : preActions.keySet()) { - for (JComboBox combo : scientaCombos){ - if (name.equals(combo.getName())){ + for (JComboBox combo : scientaCombos) { + if (name.equals(combo.getName())) { combo.setSelectedItem(String.valueOf(preActions.get(name))); break; } } - for (JTextField text :Arr.append(scientaFloatFields, scientaIntFields)) { - if (name.equals(text.getName())){ + for (JTextField text : Arr.append(scientaFloatFields, scientaIntFields)) { + if (name.equals(text.getName())) { text.setText(String.valueOf(preActions.get(name))); break; } - } - for (int i = 0; i getDevices(JTextArea text) { - return Arr.toList(text.getText().split("\n")); + String[] devices = text.getText().split("\n"); + for (int i = 0; i < devices.length; i++) { + devices[i] = devices[i].trim(); + } + return Arr.toList(Arr.removeEquals(devices, "")); } public void setDevices(JTextArea text, List devices) { @@ -436,10 +470,19 @@ public class SIStem extends PanelProcessor { } String getScanName() { + String scan = null; if (currentFile != null) { - return IO.getPrefix(currentFile); + scan = IO.getPrefix(currentFile); + String home = getContext().getSetup().expandPath(getHomePath()); + String path = IO.getRelativePath(currentFile.getParentFile().getPath(), home); + if ((path!=null) && (!path.isBlank()) && !path.equals("/")){ + if (!path.endsWith("/")){ + path=path+"/"; + } + scan=path+scan; + } } - return null; + return scan; } void updateControls() { @@ -456,10 +499,28 @@ public class SIStem extends PanelProcessor { } buttonStart.setEnabled((state == State.Ready) && (currentFile != null)); - buttonAddToQueue.setEnabled((state == State.Ready) && (currentFile != null)); + buttonAddToQueue.setEnabled(((state == State.Ready) && (currentFile != null)) || isDetached()); buttonAbort.setEnabled(state.isProcessing()); buttonScienta.setEnabled(state.isInitialized()); - + } + + void updateLens() throws Exception{ + String lens = (String) comboLens.getSelectedItem(); + boolean empty = ((lens==null)||(lens.isBlank())); + //if (empty){ + //lens = (String) eval("str(scienta.lensMode)", true); + //} + boolean visibleX = empty || lens.startsWith("A") || lens.startsWith("D"); + boolean visibleY = empty || lens.startsWith("D"); + panelX.setVisible(visibleX); + for (Component c : SwingUtils.getComponentsByType(panelX, Component.class)){ + c.setVisible(visibleX); + } + panelY.setVisible(visibleY); + for (Component c : SwingUtils.getComponentsByType(panelY, Component.class)){ + c.setVisible(visibleY); + } + } void checkValues() { @@ -488,41 +549,119 @@ public class SIStem extends PanelProcessor { } } } - - for (JTextField text :scientaFloatFields) { + + for (JTextField text : scientaFloatFields) { if (!text.getText().isBlank()) { try { Double.valueOf(text.getText().trim()); } catch (Exception ex) { - throw new IllegalArgumentException("Invalid value in " + text.getName() ); + throw new IllegalArgumentException("Invalid value in " + text.getName()); } } - } - for (JTextField text :scientaIntFields) { + } + for (JTextField text : scientaIntFields) { if (!text.getText().isBlank()) { try { Integer.valueOf(text.getText().trim()); } catch (Exception ex) { - throw new IllegalArgumentException("Invalid value in " + text.getName() ); + throw new IllegalArgumentException("Invalid value in " + text.getName()); } } - } + } List defined = new ArrayList(); - for (JTextField text :scientaRangeFields) { + for (JTextField text : scientaRangeFields) { if (!text.getText().isBlank()) { try { Integer.valueOf(text.getText().trim()); } catch (Exception ex) { - throw new IllegalArgumentException("Invalid value in " + text.getName() ); + throw new IllegalArgumentException("Invalid value in " + text.getName()); } } - defined.add(text.getText().isBlank()?false:true); - } - if ((defined.get(0) != defined.get(1)) || (defined.get(2) != defined.get(3))){ + defined.add(text.getText().isBlank() ? false : true); + } + if ((defined.get(0) != defined.get(1)) || (defined.get(2) != defined.get(3))) { throw new IllegalArgumentException("Invalid detector range"); } } + void onTabChanged() { + + } + + void updateDetectorPlot() { + try { + int[] sensor = (int[]) eval("scienta.getSensorSize()", true); + int[] roi = (int[]) eval("scienta.getROI()", true); + roi=new int[]{roi[0], roi[1], roi[2] + roi[0], roi[3] + roi[1]};//Change to xmin, ymin, xmax, ymax + try{ + roi[0]=Integer.valueOf(textXChannelMin.getText()); + } catch (Exception ex){ + } + try{ + roi[1]=Integer.valueOf(textYChannelMin.getText()); + } catch (Exception ex){ + } + try{ + roi[2]=Integer.valueOf(textXChannelMax.getText()); + } catch (Exception ex){ + } + try{ + roi[3]=Integer.valueOf(textYChannelMax.getText()); + } catch (Exception ex){ + } + + detectorPlot.getAxis(Plot.AxisId.X).setRange(0, sensor[0] - 1); + detectorPlot.getAxis(Plot.AxisId.Y).setRange(0, sensor[1] - 1); + + if (detectorPlot.getNumberOfSeries()==0){ + double[][] arr = new double[][]{new double[]{Double.NaN}}; + detectorPlot.addSeries(new MatrixPlotSeries("")); + detectorPlot.getSeries(0).setData(arr); + } + + detectorPlot.removeMarker(null); + detectorPlot.addMarker(roi[0], Plot.AxisId.X, "", Color.GREEN); + detectorPlot.addMarker(roi[1], Plot.AxisId.Y, "", Color.GREEN); + detectorPlot.addMarker(roi[2], Plot.AxisId.X, "", Color.GREEN); + detectorPlot.addMarker(roi[3], Plot.AxisId.Y, "", Color.GREEN); + } catch (Exception ex) { + getLogger().log(Level.WARNING, null, ex); + } + } + + void plotImage() throws Exception { + double[][] arr = new double[][]{new double[]{Double.NaN}}; + int[] sensor = (int[]) eval("scienta.getSensorSize()", true); + int[] roi = (int[]) eval("scienta.getROI()", true); + try { + Object data = eval("scienta.getDataMatrix().take()", true); + if (data != null) { + double[][] a = (double[][]) Convert.toDouble(data); + double scaleX = roi[2] / a[0].length; + double scaleY = roi[3] / a.length; + arr = new double[sensor[0]][sensor[1]]; + for (int i = 0; i < a.length; i++) { + for (int j = 0; j < a[0].length; j++) { + arr[(int) (scaleY * i) + roi[1]][(int) (scaleX * j) + roi[0]] = a[i][j]; + } + } + } + } catch (Exception ex) { + getLogger().log(Level.WARNING, null, ex); + } + detectorPlot.addSeries(new MatrixPlotSeries("")); + detectorPlot.getSeries(0).setData(arr); + } + + void onPlotShow() { + detectorPlot.clear(); + updateDetectorPlot(); + } + + void onPlotHide() { + detectorPlot.clear(); + } + @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -533,7 +672,7 @@ public class SIStem extends PanelProcessor { jPanel2 = new javax.swing.JPanel(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel4 = new javax.swing.JPanel(); - jPanel6 = new javax.swing.JPanel(); + panelEnergy = new javax.swing.JPanel(); jLabel14 = new javax.swing.JLabel(); textStepEnergy = new javax.swing.JTextField(); jLabel13 = new javax.swing.JLabel(); @@ -542,7 +681,7 @@ public class SIStem extends PanelProcessor { textHighEnergy = new javax.swing.JTextField(); textCenterEnergy = new javax.swing.JTextField(); textLowEnergy = new javax.swing.JTextField(); - jPanel7 = new javax.swing.JPanel(); + panelY = new javax.swing.JPanel(); jLabel17 = new javax.swing.JLabel(); textStepThetaY = new javax.swing.JTextField(); jLabel18 = new javax.swing.JLabel(); @@ -551,7 +690,7 @@ public class SIStem extends PanelProcessor { textHighThetaY = new javax.swing.JTextField(); textCenterThetaY = new javax.swing.JTextField(); textLowThetaY = new javax.swing.JTextField(); - jPanel9 = new javax.swing.JPanel(); + panelX = new javax.swing.JPanel(); jLabel26 = new javax.swing.JLabel(); textCenterThetaX = new javax.swing.JTextField(); jPanel10 = new javax.swing.JPanel(); @@ -576,6 +715,19 @@ public class SIStem extends PanelProcessor { jLabel10 = new javax.swing.JLabel(); textYChannelMin = new javax.swing.JTextField(); textYChannelMax = new javax.swing.JTextField(); + detectorPlot = new ch.psi.pshell.plot.MatrixPlotJFree(){ + @Override + protected void onShow(){ + super.onShow(); + onPlotShow(); + } + @Override + protected void onHide(){ + super.onHide(); + onPlotHide(); + } + }; + butonPlot = new javax.swing.JButton(); jPanel11 = new javax.swing.JPanel(); checkZigzag = new javax.swing.JCheckBox(); jLabel4 = new javax.swing.JLabel(); @@ -607,6 +759,7 @@ public class SIStem extends PanelProcessor { buttonOpen = new javax.swing.JButton(); buttonSave = new javax.swing.JButton(); buttonClear = new javax.swing.JButton(); + buttonData = new javax.swing.JButton(); buttonScienta.setText("Scienta Panel"); buttonScienta.addActionListener(new java.awt.event.ActionListener() { @@ -631,7 +784,13 @@ public class SIStem extends PanelProcessor { jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters")); - jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Energy Range (eV)")); + jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + jTabbedPane1StateChanged(evt); + } + }); + + panelEnergy.setBorder(javax.swing.BorderFactory.createTitledBorder("Energy Range (eV)")); jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel14.setText("High:"); @@ -653,57 +812,57 @@ public class SIStem extends PanelProcessor { textLowEnergy.setName("scienta.lowEnergy"); // NOI18N - javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); - jPanel6.setLayout(jPanel6Layout); - jPanel6Layout.setHorizontalGroup( - jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel6Layout.createSequentialGroup() + javax.swing.GroupLayout panelEnergyLayout = new javax.swing.GroupLayout(panelEnergy); + panelEnergy.setLayout(panelEnergyLayout); + panelEnergyLayout.setHorizontalGroup( + panelEnergyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelEnergyLayout.createSequentialGroup() .addContainerGap() - .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() - .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelEnergyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelEnergyLayout.createSequentialGroup() + .addGroup(panelEnergyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel14) .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelEnergyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(textLowEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(textCenterEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(textHighEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelEnergyLayout.createSequentialGroup() .addComponent(jLabel15) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(textStepEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); - jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textCenterEnergy, textHighEnergy, textLowEnergy, textStepEnergy}); + panelEnergyLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textCenterEnergy, textHighEnergy, textLowEnergy, textStepEnergy}); - jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel12, jLabel13, jLabel14, jLabel15}); + panelEnergyLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel12, jLabel13, jLabel14, jLabel15}); - jPanel6Layout.setVerticalGroup( - jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel6Layout.createSequentialGroup() + panelEnergyLayout.setVerticalGroup( + panelEnergyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelEnergyLayout.createSequentialGroup() .addContainerGap() - .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(panelEnergyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(textLowEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel12)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(panelEnergyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(textCenterEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel13)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(panelEnergyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(textHighEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel14)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(panelEnergyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(textStepEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel15)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); - jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("ThetaY ")); + panelY.setBorder(javax.swing.BorderFactory.createTitledBorder("ThetaY ")); jLabel17.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel17.setText("High:"); @@ -725,77 +884,77 @@ public class SIStem extends PanelProcessor { textLowThetaY.setName("scienta.lowThetaY"); // NOI18N - javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); - jPanel7.setLayout(jPanel7Layout); - jPanel7Layout.setHorizontalGroup( - jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel7Layout.createSequentialGroup() + javax.swing.GroupLayout panelYLayout = new javax.swing.GroupLayout(panelY); + panelY.setLayout(panelYLayout); + panelYLayout.setHorizontalGroup( + panelYLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelYLayout.createSequentialGroup() .addContainerGap() - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup() - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelYLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelYLayout.createSequentialGroup() + .addGroup(panelYLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel17) .addComponent(jLabel19, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel18, javax.swing.GroupLayout.Alignment.TRAILING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelYLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(textLowThetaY, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(textCenterThetaY, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(textHighThetaY, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup() + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelYLayout.createSequentialGroup() .addComponent(jLabel20) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(textStepThetaY, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); - jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel17, jLabel18, jLabel19, jLabel20}); + panelYLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel17, jLabel18, jLabel19, jLabel20}); - jPanel7Layout.setVerticalGroup( - jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel7Layout.createSequentialGroup() + panelYLayout.setVerticalGroup( + panelYLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelYLayout.createSequentialGroup() .addContainerGap() - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(panelYLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(textLowThetaY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel19)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(panelYLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(textCenterThetaY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel18)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(panelYLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(textHighThetaY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel17)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(panelYLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(textStepThetaY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel20)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); - jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("ThetaX")); + panelX.setBorder(javax.swing.BorderFactory.createTitledBorder("ThetaX")); jLabel26.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel26.setText("Center:"); textCenterThetaX.setName("scienta.centerThetaX"); // NOI18N - javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9); - jPanel9.setLayout(jPanel9Layout); - jPanel9Layout.setHorizontalGroup( - jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel9Layout.createSequentialGroup() + javax.swing.GroupLayout panelXLayout = new javax.swing.GroupLayout(panelX); + panelX.setLayout(panelXLayout); + panelXLayout.setHorizontalGroup( + panelXLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelXLayout.createSequentialGroup() .addContainerGap() .addComponent(jLabel26) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(textCenterThetaX, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); - jPanel9Layout.setVerticalGroup( - jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel9Layout.createSequentialGroup() + panelXLayout.setVerticalGroup( + panelXLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelXLayout.createSequentialGroup() .addGap(38, 38, 38) - .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(panelXLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(textCenterThetaX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel26)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) @@ -816,6 +975,11 @@ public class SIStem extends PanelProcessor { comboLens.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " " })); comboLens.setName("scienta.lensModeDev"); // NOI18N + comboLens.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + comboLensActionPerformed(evt); + } + }); jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel7.setText("Lens Mode:"); @@ -884,12 +1048,12 @@ public class SIStem extends PanelProcessor { .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, Short.MAX_VALUE) - .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jPanel9, 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(panelEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(12, 12, 12) + .addComponent(panelX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(panelY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(18, Short.MAX_VALUE)) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -898,9 +1062,9 @@ public class SIStem extends PanelProcessor { .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addComponent(panelEnergy, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(panelY, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(panelX, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); @@ -919,81 +1083,136 @@ public class SIStem extends PanelProcessor { jLabel25.setText("Slices:"); textSlices.setName("scienta.slices"); // NOI18N + textSlices.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + roiChanged(evt); + } + }); textChannels.setName("scienta.channels"); // NOI18N + textChannels.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + roiChanged(evt); + } + }); jLabel27.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel27.setText("Channels:"); textXChannelMin.setName("x_channel_min"); // NOI18N + textXChannelMin.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + roiChanged(evt); + } + }); textXChannelMax.setName("x_channel_max"); // NOI18N + textXChannelMax.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + roiChanged(evt); + } + }); jLabel10.setText("Y Channel Range:"); textYChannelMin.setName("y_channel_min"); // NOI18N + textYChannelMin.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + roiChanged(evt); + } + }); textYChannelMax.setName("y_channel_max"); // NOI18N + textYChannelMax.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + roiChanged(evt); + } + }); + + detectorPlot.setLegendVisible(false); + detectorPlot.setTitle(""); + + butonPlot.setText("Plot Image"); + butonPlot.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + butonPlotActionPerformed(evt); + } + }); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() - .addContainerGap(33, Short.MAX_VALUE) - .addComponent(jLabel16) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(comboDetMode, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE) - .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() - .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(jPanel5Layout.createSequentialGroup() - .addComponent(jLabel25) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textSlices, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(jPanel5Layout.createSequentialGroup() - .addComponent(jLabel27) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textChannels, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(jPanel5Layout.createSequentialGroup() - .addComponent(jLabel10) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textYChannelMin, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel16) + .addComponent(jLabel9)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textYChannelMax, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel5Layout.createSequentialGroup() + .addComponent(textXChannelMin, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textXChannelMax, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(comboDetMode, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(jPanel5Layout.createSequentialGroup() - .addComponent(jLabel9) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel10) + .addComponent(jLabel25)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textXChannelMin, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(textSlices, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel5Layout.createSequentialGroup() + .addComponent(textYChannelMin, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textYChannelMax, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGroup(jPanel5Layout.createSequentialGroup() + .addComponent(jLabel27) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textXChannelMax, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addContainerGap(202, Short.MAX_VALUE)) + .addComponent(textChannels, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(butonPlot)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(detectorPlot, javax.swing.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE) + .addContainerGap()) ); + + jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10, jLabel16, jLabel25, jLabel27, jLabel9}); + jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() - .addGap(21, 21, 21) - .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel16) - .addComponent(comboDetMode, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel9) - .addComponent(textXChannelMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(textXChannelMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel10) - .addComponent(textYChannelMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(textYChannelMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(textSlices, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel25)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(textChannels, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel27)) - .addContainerGap(39, Short.MAX_VALUE)) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel5Layout.createSequentialGroup() + .addGap(21, 21, 21) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel16) + .addComponent(comboDetMode, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9) + .addComponent(textXChannelMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textXChannelMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(textChannels, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel27)) + .addGap(18, 18, 18) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel10) + .addComponent(textYChannelMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textYChannelMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(textSlices, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel25)) + .addGap(18, 18, Short.MAX_VALUE) + .addComponent(butonPlot)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup() + .addContainerGap() + .addComponent(detectorPlot, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))) + .addContainerGap()) ); jTabbedPane1.addTab("Detector", jPanel5); @@ -1057,7 +1276,7 @@ public class SIStem extends PanelProcessor { .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(62, Short.MAX_VALUE)) + .addContainerGap(99, Short.MAX_VALUE)) ); jTabbedPane1.addTab("Scan", jPanel11); @@ -1163,7 +1382,7 @@ public class SIStem extends PanelProcessor { .addGroup(jPanel1Layout.createSequentialGroup() .addGap(14, 14, 14) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE) + .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE) .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addContainerGap()) @@ -1219,7 +1438,7 @@ public class SIStem extends PanelProcessor { .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addGap(14, 14, 14) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE) + .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE) .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane7)) @@ -1278,6 +1497,13 @@ public class SIStem extends PanelProcessor { } }); + buttonData.setText("Data Panel"); + buttonData.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonDataActionPerformed(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -1288,6 +1514,8 @@ public class SIStem extends PanelProcessor { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(buttonScienta) + .addGap(18, 18, 18) + .addComponent(buttonData) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(buttonStart) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) @@ -1311,6 +1539,8 @@ public class SIStem extends PanelProcessor { layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonClear, buttonOpen, buttonSave}); + layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonData, buttonScienta}); + layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() @@ -1328,7 +1558,8 @@ public class SIStem extends PanelProcessor { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonScienta) .addComponent(buttonStart) - .addComponent(buttonAbort)) + .addComponent(buttonAbort) + .addComponent(buttonData)) .addContainerGap()) ); }// //GEN-END:initComponents @@ -1368,6 +1599,8 @@ public class SIStem extends PanelProcessor { private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveActionPerformed try { checkValues(); + + //TODO: Factorized JFileChooser chooser = new JFileChooser(getContext().getSetup().expandPath(getHomePath())); FileNameExtensionFilter filter = new FileNameExtensionFilter(getDescription(), getExtensions()); chooser.setFileFilter(filter); @@ -1394,15 +1627,26 @@ public class SIStem extends PanelProcessor { private void buttonAddToQueueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAddToQueueActionPerformed try { QueueProcessor tq = null; - List queues = getView().getQueues(); - if (queues.size() == 0) { - tq = getView().openProcessor(QueueProcessor.class, null); + if (this.isDetached()) { + if ((queueProcessor == null) || !queueProcessor.isLoaded()) { + queueProcessor = new QueueProcessor(); + Context.getInstance().getPluginManager().loadPlugin(queueProcessor, "Queue"); + Context.getInstance().getPluginManager().startPlugin(queueProcessor); + } + tq = queueProcessor; + tq.requestFocus(); } else { - tq = queues.get(0); + List queues = getView().getQueues(); + if (queues.size() == 0) { + tq = getView().openProcessor(QueueProcessor.class, null); + } else { + tq = queues.get(0); + } + getView().getDocumentsTab().setSelectedComponent(tq); + } + if (currentFile != null) { + tq.addNewFile(currentFile.getPath()); } - getView().getDocumentsTab().setSelectedComponent(tq); - tq.addNewFile(currentFile.getPath()); - } catch (Exception ex) { showException(ex); } @@ -1416,11 +1660,55 @@ public class SIStem extends PanelProcessor { } }//GEN-LAST:event_buttonClearActionPerformed + private void buttonDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDataActionPerformed + try { + if ((dataDialog == null) || (!dataDialog.isDisplayable())) { + DataPanel panel = new DataPanel(); + panel.initialize(); + panel.setDefaultDataPanelListener(); + dataDialog = showDialog("Data", null, panel); + } + dataDialog.requestFocus(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonDataActionPerformed + + private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged + try { + onTabChanged(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_jTabbedPane1StateChanged + + private void butonPlotActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butonPlotActionPerformed + try { + plotImage(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_butonPlotActionPerformed + + private void roiChanged(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_roiChanged + updateDetectorPlot(); + }//GEN-LAST:event_roiChanged + + private void comboLensActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboLensActionPerformed + try { + updateLens(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_comboLensActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton butonPlot; private javax.swing.JButton buttonAbort; private javax.swing.JButton buttonAddToQueue; private javax.swing.JButton buttonClear; + private javax.swing.JButton buttonData; private javax.swing.JButton buttonOpen; private javax.swing.JButton buttonSave; private javax.swing.JButton buttonScienta; @@ -1432,6 +1720,7 @@ public class SIStem extends PanelProcessor { private javax.swing.JComboBox comboEnergy; private javax.swing.JComboBox comboLens; private javax.swing.JComboBox comboPass; + private ch.psi.pshell.plot.MatrixPlotJFree detectorPlot; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; @@ -1462,9 +1751,6 @@ public class SIStem extends PanelProcessor { private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; - private javax.swing.JPanel jPanel6; - private javax.swing.JPanel jPanel7; - private javax.swing.JPanel jPanel9; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; @@ -1473,6 +1759,9 @@ public class SIStem extends PanelProcessor { private javax.swing.JScrollPane jScrollPane6; private javax.swing.JScrollPane jScrollPane7; private javax.swing.JTabbedPane jTabbedPane1; + private javax.swing.JPanel panelEnergy; + private javax.swing.JPanel panelX; + private javax.swing.JPanel panelY; private javax.swing.JSpinner spinnerLatency; private javax.swing.JSpinner spinnerPasses; private javax.swing.JTable tableFixed; @@ -1500,4 +1789,3 @@ public class SIStem extends PanelProcessor { private javax.swing.JTextField textYChannelMin; // End of variables declaration//GEN-END:variables } - diff --git a/script/scans/scan1.json b/script/scans/scan1.json index 4c8f298..6e32354 100644 --- a/script/scans/scan1.json +++ b/script/scans/scan1.json @@ -3,14 +3,14 @@ "STOP" : [ 1.0 ], "DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ], "PRE_ACTIONS" : { - "scienta.detectorModeDev" : "ADC", - "scienta.acquisitionModeDev" : "Fixed", - "scienta.slices" : 512, - "scienta.lensModeDev" : "Transmission", - "y" : 0.1, - "scienta.channels" : 512, "scienta.passEnergyDev" : "20", - "scienta.energyModeDev" : "Kinetic" + "scienta.acquisitionModeDev" : "Fixed", + "scienta.energyModeDev" : "Kinetic", + "scienta.lensModeDev" : "Transmission", + "scienta.detectorModeDev" : "ADC", + "scienta.slices" : 512, + "scienta.channels" : 512, + "y" : 0.1 }, "COMPRESSION" : true, "SENSORS" : [ "scienta.dataMatrix", "keithley11" ], diff --git a/script/scans/scan2.json b/script/scans/scan2.json index ff85ba1..4054a42 100644 --- a/script/scans/scan2.json +++ b/script/scans/scan2.json @@ -3,14 +3,14 @@ "STOP" : [ 1.0, 1.0 ], "DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ], "PRE_ACTIONS" : { - "scienta.detectorModeDev" : "ADC", - "scienta.acquisitionModeDev" : "Fixed", - "scienta.slices" : 512, - "scienta.lensModeDev" : "Transmission", - "y" : 0.1, - "scienta.channels" : 512, "scienta.passEnergyDev" : "20", - "scienta.energyModeDev" : "Kinetic" + "scienta.acquisitionModeDev" : "Fixed", + "scienta.energyModeDev" : "Kinetic", + "scienta.lensModeDev" : "Transmission", + "scienta.detectorModeDev" : "ADC", + "scienta.slices" : 512, + "scienta.channels" : 512, + "y" : 0.1 }, "COMPRESSION" : true, "SENSORS" : [ "scienta.dataMatrix", "keithley11" ], diff --git a/script/scans/scan3.json b/script/scans/scan3.json index eec22f1..cd30517 100644 --- a/script/scans/scan3.json +++ b/script/scans/scan3.json @@ -3,13 +3,13 @@ "STOP" : [ 1.0 ], "DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ], "PRE_ACTIONS" : { - "scienta.detectorModeDev" : "ADC", - "scienta.acquisitionModeDev" : "Fixed", - "scienta.slices" : 512, - "scienta.lensModeDev" : "Transmission", - "scienta.channels" : 512, "scienta.passEnergyDev" : "20", - "scienta.energyModeDev" : "Kinetic" + "scienta.acquisitionModeDev" : "Fixed", + "scienta.energyModeDev" : "Kinetic", + "scienta.lensModeDev" : "Transmission", + "scienta.detectorModeDev" : "ADC", + "scienta.slices" : 512, + "scienta.channels" : 512 }, "COMPRESSION" : true, "SENSORS" : [ "scienta.dataMatrix", "keithley11" ], diff --git a/script/scans/scan4.json b/script/scans/scan4.json new file mode 100644 index 0000000..a21297e --- /dev/null +++ b/script/scans/scan4.json @@ -0,0 +1,24 @@ +{ + "PASSES" : 1, + "STOP" : [ 1.0 ], + "DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ], + "PRE_ACTIONS" : { + "scienta.detectorModeDev" : "ADC", + "scienta.acquisitionModeDev" : "Fixed", + "scienta.slices" : 512, + "scienta.lensModeDev" : "Transmission", + "scienta.channels" : 512, + "scienta.passEnergyDev" : "20", + "scienta.energyModeDev" : "Kinetic" + }, + "COMPRESSION" : true, + "SENSORS" : [ "scienta.dataMatrix", "keithley11" ], + "ZIGZAG" : true, + "SETTLING_TIME" : 0.0, + "MONITORS" : [ "current" ], + "START" : [ -1.0 ], + "RANGE" : [ 20, 10, 40, 30 ], + "POSITIONERS" : [ "master" ], + "STEPS" : [ 11 ], + "SNAPS" : [ "acmi", "energy", "exit_slit", "fe_horiz_width", "fe_vert_width", "helium_valve", "master", "tcmp", "temp_boot1", "temp_boot2", "temp_cryopump", "temp_cryostat", "temp_headmech", "temp_sample1", "temp_sample2", "temp_shield" ] +} \ No newline at end of file diff --git a/script/scans/test/test.json b/script/scans/test/test.json new file mode 100644 index 0000000..42b9d34 --- /dev/null +++ b/script/scans/test/test.json @@ -0,0 +1,18 @@ +{ + "PASSES" : 1, + "STOP" : [ ], + "DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ], + "PRE_ACTIONS" : { + "scienta.lensModeDev" : "A14_08" + }, + "COMPRESSION" : true, + "SENSORS" : [ "scienta.dataMatrix" ], + "ZIGZAG" : false, + "SETTLING_TIME" : 0.0, + "MONITORS" : [ "current" ], + "START" : [ ], + "RANGE" : [ null, null, null, null ], + "POSITIONERS" : [ ], + "STEPS" : [ ], + "SNAPS" : [ "acmi", "energy", "exit_slit", "fe_horiz_width", "fe_vert_width", "helium_valve", "master", "tcmp", "temp_boot1", "temp_boot2", "temp_cryopump", "temp_cryostat", "temp_headmech", "temp_sample1", "temp_sample2", "temp_shield" ] +} \ No newline at end of file diff --git a/script/templates/SIStem.py b/script/templates/SIStem.py index 92a1c2f..5bff4fc 100644 --- a/script/templates/SIStem.py +++ b/script/templates/SIStem.py @@ -1,6 +1,7 @@ +from collections import OrderedDict + #Debugging if get_exec_pars().args is None: - print "OK" PRE_ACTIONS = {z:0.1} POSITIONERS = ["x", "y"] START = [0.0,0.0] @@ -16,18 +17,17 @@ if get_exec_pars().args is None: MONITORS = [] NAME=None - import json def load_parameters(name): + print "Scan Name: ", name filename = get_context().setup.expandPath("{script}/scans/" + name + ".json") with open(filename) as config_file: - config = json.load(config_file) + config = json.load(config_file, object_pairs_hook=OrderedDict) #Read ordered dictionaries for key in config.keys(): globals()[key] = config[key] print str(key), " = ", config[key] if NAME: load_parameters(NAME) - #Enforece parameter types