diff --git a/src/main/java/org/micromanager/lightsheetmanager/gui/LightSheetManagerFrame.java b/src/main/java/org/micromanager/lightsheetmanager/gui/LightSheetManagerFrame.java index 495651c..d6a67ad 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/gui/LightSheetManagerFrame.java +++ b/src/main/java/org/micromanager/lightsheetmanager/gui/LightSheetManagerFrame.java @@ -47,6 +47,7 @@ public LightSheetManagerFrame(final LightSheetManagerModel model, final boolean // create the user interface if (isLoaded) { + initDialogs(); GeometryType geometryType = model_.devices() .getDeviceAdapter().getMicroscopeGeometry(); switch (geometryType) { @@ -139,7 +140,7 @@ private void createUserInterface() { WindowUtils.registerWindowClosingEvent(this, event -> { tabPanel_.getNavigationTab().getNavigationPanel().stopPolling(); model_.getUserSettings().save(); - System.out.println("main window closed!"); + studio_.logs().logMessage("user settings saved"); }); } @@ -153,6 +154,14 @@ public Studio getStudio_() { return studio_; } + /** + * Detect settings after the model is loaded, + * ask to change settings with dialogs. + */ + private void initDialogs() { + model_.devices().checkDevices(this); + } + public void toggleLiveMode() { if (studio_.live().isLiveModeOn()) { studio_.live().setLiveModeOn(false); diff --git a/src/main/java/org/micromanager/lightsheetmanager/gui/utils/DialogUtils.java b/src/main/java/org/micromanager/lightsheetmanager/gui/utils/DialogUtils.java index ccf5b7d..01ba48d 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/gui/utils/DialogUtils.java +++ b/src/main/java/org/micromanager/lightsheetmanager/gui/utils/DialogUtils.java @@ -32,6 +32,10 @@ public static String showTextEntryDialog(final JFrame frame, final String title, JOptionPane.PLAIN_MESSAGE, null, null, ""); } + public static int showYesNoDialog(final JFrame frame, final String title, final String message) { + return JOptionPane.showConfirmDialog(frame, message, title, JOptionPane.YES_NO_OPTION); + } + /** * Shows a customized message dialog box, this method does not log the error.

* This is used for reporting errors in the AcquisitionTable. diff --git a/src/main/java/org/micromanager/lightsheetmanager/model/DeviceManager.java b/src/main/java/org/micromanager/lightsheetmanager/model/DeviceManager.java index 2f1a414..5eb623a 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/model/DeviceManager.java +++ b/src/main/java/org/micromanager/lightsheetmanager/model/DeviceManager.java @@ -6,6 +6,7 @@ import mmcorej.CMMCore; import mmcorej.DeviceType; import org.micromanager.Studio; +import org.micromanager.lightsheetmanager.gui.utils.DialogUtils; import org.micromanager.lightsheetmanager.model.devices.DeviceBase; import org.micromanager.lightsheetmanager.model.devices.Galvo; import org.micromanager.lightsheetmanager.model.devices.LightSheetDeviceManager; @@ -24,6 +25,7 @@ import org.micromanager.lightsheetmanager.model.devices.vendor.ASIXYStage; import org.micromanager.lightsheetmanager.model.devices.vendor.ASIZStage; +import javax.swing.JFrame; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -419,4 +421,37 @@ private ArrayList updateConfig(final String groupName, final String conf return newProperties; } + // TODO: adapt for diSPIM and multiple cameras + /** + * Check user settings and ask to change settings with dialogs. + */ + public void checkDevices(final JFrame frame) { + + final String cameraKey = "ImagingCamera"; + CameraBase cameraDevice = getDevice(cameraKey); + CameraLibrary cameraLib = CameraLibrary.UNKNOWN; + if (cameraDevice != null) { + cameraLib = CameraLibrary.fromString(cameraDevice.getDeviceLibrary()); + } + + switch (cameraLib) { + case HAMAMATSU: + // Flash4, Fusion, etc + HamamatsuCamera camera = getDevice(cameraKey); + if (camera.getTriggerPolarity().equals(HamamatsuCamera.Values.NEGATIVE)) { + final int result = DialogUtils.showYesNoDialog(frame, "Hamamatsu Camera", + "The trigger polarity should be set to POSITIVE. Set it now?"); + if (result == 0) { + camera.setTriggerPolarity(HamamatsuCamera.Values.POSITIVE); + } + } + break; + case PVCAM: + // Kinetix, etc + break; + default: + break; + } + } + } diff --git a/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineSCAPE.java b/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineSCAPE.java index 301436b..721fb0a 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineSCAPE.java +++ b/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineSCAPE.java @@ -55,6 +55,12 @@ public AcquisitionEngineSCAPE(final LightSheetManagerModel model) { @Override boolean setup() { + // this is needed for LSMAcquisitionEvents to work with multiple positions + if (core_.getFocusDevice().isEmpty() + && acqSettings_.isUsingMultiplePositions()) { + studio_.logs().showError("The default focus device \"Core-Focus\" needs to be set to use multiple positions."); + } + // make sure that there are positions in the PositionList if (acqSettings_.isUsingMultiplePositions()) { final int numPositions = studio_.positions().getPositionList().getNumberOfPositions(); diff --git a/src/main/java/org/micromanager/lightsheetmanager/model/devices/cameras/HamamatsuCamera.java b/src/main/java/org/micromanager/lightsheetmanager/model/devices/cameras/HamamatsuCamera.java index 5165a01..eecdff1 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/model/devices/cameras/HamamatsuCamera.java +++ b/src/main/java/org/micromanager/lightsheetmanager/model/devices/cameras/HamamatsuCamera.java @@ -23,6 +23,7 @@ public static class Properties { public static final String CAMERA_BUS = "Camera Bus"; public static final String TRIGGER_SOURCE = "TRIGGER SOURCE"; public static final String TRIGGER_ACTIVE = "TRIGGER ACTIVE"; + public static final String TRIGGER_POLARITY = "TriggerPolarity"; public static final String SENSOR_MODE = "SENSOR MODE"; public static final String INTERNAL_LINE_INTERVAL = "INTERNAL LINE INTERVAL"; public static final String SCAN_MODE = "ScanMode"; @@ -39,6 +40,8 @@ public static class Values { public static final String PROGRESSIVE = "PROGRESSIVE"; public static final String AREA = "AREA"; public static final String USB3 = "USB3"; + public static final String POSITIVE = "POSITIVE"; + public static final String NEGATIVE = "NEGATIVE"; public static final String SCAN_MODE_1 = "1"; public static final String SCAN_MODE_2 = "2"; public static final String SCAN_MODE_3 = "3"; @@ -238,4 +241,13 @@ public boolean isFusion() { public boolean isFlash4() { return getProperty(Properties.CAMERA_NAME).startsWith(Models.FLASH4); } + + public String getTriggerPolarity() { + return getProperty(Properties.TRIGGER_POLARITY); + } + + public void setTriggerPolarity(final String polarity) { + setProperty(Properties.TRIGGER_POLARITY, polarity); + } + }