diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/data/AcquisitionMode.java b/src/main/java/org/micromanager/lightsheetmanager/api/data/AcquisitionMode.java index 34a3ca3..2839d4e 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/data/AcquisitionMode.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/data/AcquisitionMode.java @@ -1,5 +1,6 @@ package org.micromanager.lightsheetmanager.api.data; +import java.util.ArrayList; import java.util.Arrays; // TODO: account for different naming on each geometry type (SLICE_SCAN_ONLY) @@ -39,12 +40,21 @@ public static String[] toArray() { .toArray(String[]::new); } - // TODO: check if stage scanning exists - public static String[] getValidKeys() { - final AcquisitionMode[] keys = new AcquisitionMode[] { - NO_SCAN, STAGE_SCAN, SLICE_SCAN_ONLY, PIEZO_SCAN_ONLY - }; - return Arrays.stream(keys) + /** + * Returns an array of valid acquisition modes as strings. + * + * @param isStageScanning {@code true} if stage scanning + * @return an array of strings + */ + public static String[] getValidKeys(final boolean isStageScanning) { + final ArrayList keys = new ArrayList<>(); + keys.add(NO_SCAN); + if (isStageScanning) { + keys.add(STAGE_SCAN); + } + keys.add(SLICE_SCAN_ONLY); + keys.add(PIEZO_SCAN_ONLY); + return keys.stream() .map(AcquisitionMode::toString) .toArray(String[]::new); diff --git a/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/AcquisitionTab.java b/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/AcquisitionTab.java index 5521c04..21d1f2d 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/AcquisitionTab.java +++ b/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/AcquisitionTab.java @@ -157,7 +157,9 @@ private void createUserInterface() { pnlChannelTable_.setItemsEnabled(false); } - cmbAcquisitionModes_ = new ComboBox(AcquisitionMode.getValidKeys(), + // acquisition mode combo box + final boolean isUsingScanSettings = model_.devices().isUsingStageScanning(); + cmbAcquisitionModes_ = new ComboBox(AcquisitionMode.getValidKeys(isUsingScanSettings), acqSettings.acquisitionMode().toString(), 180, 24); diff --git a/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/SettingsTab.java b/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/SettingsTab.java index 2c6f909..bf0c3a0 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/SettingsTab.java +++ b/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/SettingsTab.java @@ -47,14 +47,7 @@ private void createUserInterface() { // check for devices to set up the tab isUsingPLogic_ = model_.devices().isUsingPLogic(); - if (isUsingPLogic_) { - final ASIXYStage xyStage = model_.devices().getDevice("SampleXY"); - if (xyStage != null) { - isUsingScanSettings_ = xyStage.hasProperty(ASIXYStage.Properties.SCAN_NUM_LINES); - } else { - isUsingScanSettings_ = false; - } - } + isUsingScanSettings_ = model_.devices().isUsingStageScanning(); final Panel pnlScanSettings = new Panel("Stage Scan Settings"); pnlScanSettings.setMigLayout( diff --git a/src/main/java/org/micromanager/lightsheetmanager/model/DeviceManager.java b/src/main/java/org/micromanager/lightsheetmanager/model/DeviceManager.java index 5eb623a..3a57e90 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/model/DeviceManager.java +++ b/src/main/java/org/micromanager/lightsheetmanager/model/DeviceManager.java @@ -321,9 +321,8 @@ public boolean hasDeviceAdapter() { // check for ASI hardware triggering device public boolean isUsingPLogic() { - // make sure that we have devices set if (deviceMap_.get("TriggerLaser") == null && deviceMap_.get("TriggerCamera") == null) { - return false; + return false; // early exit => devices not set } // check if both device names contain "PLogic" boolean result = false; @@ -338,6 +337,15 @@ public boolean isUsingPLogic() { return result; } + // check for ASI stage scanning + public boolean isUsingStageScanning() { + if (deviceMap_.get("SampleXY") == null) { + return false; // early exit => device not set + } + return deviceMap_.get("SampleXY") + .hasProperty(ASIXYStage.Properties.SCAN_NUM_LINES); + } + /** * Creates a configuration group named "System" that includes all device properties * the Light Sheet Manager device adapter.