Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import org.micromanager.lightsheetmanager.gui.components.Panel;
import org.micromanager.lightsheetmanager.gui.components.TextField;
import org.micromanager.lightsheetmanager.LightSheetManager;
import org.micromanager.lightsheetmanager.api.internal.ScapeAcquisitionSettings;
import org.micromanager.lightsheetmanager.model.devices.vendor.ASIPiezo;
import org.micromanager.lightsheetmanager.model.devices.vendor.ASIScanner;
import org.micromanager.lightsheetmanager.model.positions.Subscriber;
import org.micromanager.lightsheetmanager.model.utils.NumberUtils;

import javax.swing.JLabel;
import javax.swing.SwingUtilities;
Expand Down Expand Up @@ -191,11 +193,7 @@ private void createEventHandlers() {
});

btnImagingCenterGo_.registerListener(() -> {
// FIXME: make sure this is the same as original plugin, diSPIM also moves Scanner with computeGalvoFromPiezo
// TODO: (also check if the move when the tab is selected is correct)
final double imagingCenter = model_.acquisitions().settingsBuilder().build()
.sheetCalibration().imagingCenter();
piezo.setPosition(imagingCenter);
centerPiezoAndGalvo();
lblImagingPositionValue_.setText(String.format("%.3f μm", piezo.getPosition()));
});

Expand Down Expand Up @@ -242,11 +240,27 @@ public void update(String topic, Object value) {
@Override
public void selected() {
if (model_.devices().isUsingPLogic()) {
// TODO: check the fixme above
final double imagingCenter = model_.acquisitions().settingsBuilder().build()
.sheetCalibration().imagingCenter();
final ASIPiezo piezo = model_.devices().device("ImagingFocus");
piezo.setPosition(imagingCenter);
centerPiezoAndGalvo();
}
}

/**
* Moves the imaging piezo to the imaging center and the sheet to the slice that images it.
*/
private void centerPiezoAndGalvo() {
final ScapeAcquisitionSettings settings = model_.acquisitions().settingsBuilder().build();
final double imagingCenter = settings.sheetCalibration().imagingCenter();
final ASIPiezo piezo = model_.devices().device("ImagingFocus");
piezo.setPosition(imagingCenter);

// with the beam off this sets where the sheet goes when the beam is turned on, so it
// also replaces a park position the scanner would otherwise restore
final double sliceSlope = settings.sliceCalibration().slope();
final ASIScanner scanner = model_.devices().device("IllumSlice");
if (scanner != null && !NumberUtils.doublesEqual(sliceSlope, 0.0)) {
final double sliceCenter =
(imagingCenter - settings.sliceCalibration().offset()) / sliceSlope;
scanner.setPosition(scanner.getPosition().x, sliceCenter);
}
}

Expand Down
Loading