Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable xyz grid button #297

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
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 @@ -63,6 +63,7 @@ private void createUserInterface() {
"[]10[]"
));

Spinner.setDefaultSize(7);
Button.setDefaultSize(160, 26);
btnComputeGrid_ = new Button("Compute Grid");
btnEditPositionList_ = new Button("Edit Position List...");
Expand All @@ -80,7 +81,7 @@ private void createUserInterface() {

Panel.setMigLayoutDefault(
"insets 10 10 10 10",
"[]15[]",
"[]10[]",
"[]10[]"
);
final Panel pnlX = new Panel(cbxUseX_);
Expand All @@ -89,29 +90,29 @@ private void createUserInterface() {
final Panel pnlButtons = new Panel();

// X
final JLabel lblXStart = new JLabel("X start [\u00B5m]:");
final JLabel lblXStop = new JLabel("X stop [\u00B5m]:");
final JLabel lblXDelta = new JLabel("X delta [\u00B5m]:");
final JLabel lblXStart = new JLabel("X start [µm]:");
final JLabel lblXStop = new JLabel("X stop [µm]:");
final JLabel lblXDelta = new JLabel("X delta [µm]:");
final JLabel lblXCount = new JLabel("Slice count:");

spnXStart_ = Spinner.createDoubleSpinner(0.0, -Double.MAX_VALUE, Double.MAX_VALUE, 100.0);
spnXStop_ = Spinner.createDoubleSpinner(0.0, -Double.MAX_VALUE, Double.MAX_VALUE, 100.0);
spnXDelta_ = Spinner.createDoubleSpinner(0.0, -Double.MAX_VALUE, Double.MAX_VALUE, 100.0);

// Y
final JLabel lblYStart = new JLabel("Y start [\u00B5m]:");
final JLabel lblYStop = new JLabel("Y stop [\u00B5m]:");
final JLabel lblYDelta = new JLabel("Y delta [\u00B5m]:");
final JLabel lblYStart = new JLabel("Y start [µm]:");
final JLabel lblYStop = new JLabel("Y stop [µm]:");
final JLabel lblYDelta = new JLabel("Y delta [µm]:");
final JLabel lblYCount = new JLabel("Y count:");

spnYStart_ = Spinner.createDoubleSpinner(0.0, -Double.MAX_VALUE, Double.MAX_VALUE, 100.0);
spnYStop_ = Spinner.createDoubleSpinner(0.0, -Double.MAX_VALUE, Double.MAX_VALUE, 100.0);
spnYDelta_ = Spinner.createDoubleSpinner(0.0, -Double.MAX_VALUE, Double.MAX_VALUE, 100.0);

// Z
final JLabel lblZStart = new JLabel("Z start [\u00B5m]:");
final JLabel lblZStop = new JLabel("Z stop [\u00B5m]:");
final JLabel lblZDelta = new JLabel("Z delta [\u00B5m]:");
final JLabel lblZStart = new JLabel("Z start [µm]:");
final JLabel lblZStop = new JLabel("Z stop [µm]:");
final JLabel lblZDelta = new JLabel("Z delta [µm]:");
final JLabel lblZCount = new JLabel("Z count:");

spnZStart_ = Spinner.createDoubleSpinner(0.0, -Double.MAX_VALUE, Double.MAX_VALUE, 100.0);
Expand All @@ -120,6 +121,7 @@ private void createUserInterface() {

final Panel pnlSettings = new Panel("Grid Settings");
final JLabel lblOverlap = new JLabel("Overlap (Y and Z) [%]");
Spinner.setDefaultSize(4);
spnOverlapYZ_ = Spinner.createIntegerSpinner(10, 0, 100, 1);
cbxClearPositions_ = new CheckBox("Clear position list if YZ unused", false);

Expand Down Expand Up @@ -160,12 +162,13 @@ private void createUserInterface() {
pnlButtons.add(btnRunOverviewAcq_, "");

add(pnlY, "growx");
add(pnlZ, "wrap");
add(pnlZ, "growx, wrap");
add(pnlX, "growx");
add(pnlSettings, "wrap");
add(pnlButtons, "");

pack();
pack(); // fit window size to layout
setIconImage(Icons.MICROSCOPE.getImage());
}

private void createEventHandlers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private void createUserInterface() {
"Multiple positions (XY)", acqSettings.isUsingMultiplePositions());
pnlMultiPositions_ = new MultiPositionPanel(model_, cbxUseMultiplePositions_);
// disable elements based on acqSettings
pnlMultiPositions_.setEnabled(acqSettings.isUsingMultiplePositions());
pnlMultiPositions_.setPanelEnabled(acqSettings.isUsingMultiplePositions());

// time points
cbxUseTimePoints_ = new CheckBox(
Expand Down Expand Up @@ -308,6 +308,10 @@ public SliceSettingsPanel getSliceSettingsPanel() {
return pnlSliceSettings_;
}

public MultiPositionPanel getMultiPositionPanel() {
return pnlMultiPositions_;
}

private void acqFinishedCallback() {
try {
SwingUtilities.invokeAndWait(() -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.micromanager.lightsheetmanager.gui.tabs.acquisition;

import org.micromanager.lightsheetmanager.api.internal.DefaultAcquisitionSettingsSCAPE;
import org.micromanager.lightsheetmanager.gui.components.Button;
import org.micromanager.lightsheetmanager.gui.components.CheckBox;
import org.micromanager.lightsheetmanager.gui.components.Label;
Expand Down Expand Up @@ -30,17 +29,17 @@ public MultiPositionPanel(final LightSheetManager model, final CheckBox cbxUseMu
}

private void createUserInterface() {
final DefaultAcquisitionSettingsSCAPE acqSettings =
model_.acquisitions().settings();

Spinner.setDefaultSize(7);
// post move delay
lblPostMoveDelay_ = new Label("Post-move delay [ms]:");
Spinner.setDefaultSize(8);
spnPostMoveDelay_ = Spinner.createIntegerSpinner(
acqSettings.postMoveDelay(), 0, Integer.MAX_VALUE, 100);
btnEditPositionList_ = new Button("Edit Position List", 120, 24);
btnOpenXYZGrid_ = new Button("XYZ Grid", 80, 24);
model_.acquisitions().settings().postMoveDelay(),
0, Integer.MAX_VALUE, 100);

btnOpenXYZGrid_.setEnabled(false);
// XYZ grid
btnEditPositionList_ = new Button("Edit Position List...", 130, 24);
btnOpenXYZGrid_ = new Button("XYZ Grid...", 90, 24);

add(btnEditPositionList_, "");
add(btnOpenXYZGrid_, "wrap");
Expand All @@ -50,21 +49,32 @@ private void createUserInterface() {

private void createEventHandlers() {

btnOpenXYZGrid_.registerListener(e -> xyzGridFrame_.setVisible(true));
// open XYZ grid
btnOpenXYZGrid_.registerListener(e -> {
if (model_.devices().hasDevice("SampleXY")
&& model_.devices().hasDevice("SampleZ")) {
xyzGridFrame_.setVisible(true);
} else {
model_.studio().logs().showError(
"SampleXY and SampleZ must not be \"Undefined\" to use the XYZ grid.");
}
});

// open position list
btnEditPositionList_.registerListener(e -> model_.studio().app().showPositionList());

spnPostMoveDelay_.registerListener(e -> {
model_.acquisitions().settingsBuilder().postMoveDelay(spnPostMoveDelay_.getInt());
//System.out.println("getPostMoveDelay: " + model_.acquisitions().getAcquisitionSettings().getPostMoveDelay());
});
spnPostMoveDelay_.registerListener(e -> model_.acquisitions()
.settingsBuilder().postMoveDelay(spnPostMoveDelay_.getInt()));

}

@Override
public void setEnabled(final boolean state) {
public void setPanelEnabled(final boolean state) {
lblPostMoveDelay_.setEnabled(state);
spnPostMoveDelay_.setEnabled(state);
btnEditPositionList_.setEnabled(state);
}

public XYZGridFrame getXYZGridFrame() {
return xyzGridFrame_;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private void createUserInterface() {
"[]5[]"
);

Spinner.setDefaultSize(6);
lblNumTimePoints_ = new Label("Number:");
lblTimePointInterval_ = new Label("Interval [s]:");
spnNumTimePoints_ = Spinner.createIntegerSpinner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public class DeviceManager {
private final Studio studio_;
private final CMMCore core_;

private Map<String, DeviceBase> deviceMap_;
/* Maps the Device Adapter device name to a Device object */
private final Map<String, DeviceBase> deviceMap_;

private static String deviceAdapterName_;

Expand Down Expand Up @@ -463,4 +464,13 @@ public void checkDevices(final JFrame frame) {
}
}

/**
* Return true if the device is set to a value other than "Undefined".
*
* @param deviceName the device adapter name ("SampleXY", "SampleZ", etc.)
* @return true if the device is present
*/
public boolean hasDevice(final String deviceName) {
return !deviceMap_.get(deviceName).getDeviceName().equals("Undefined");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import org.micromanager.PositionList;
import org.micromanager.StagePosition;
import org.micromanager.lightsheetmanager.LightSheetManager;
import org.micromanager.lightsheetmanager.api.data.DISPIMDevice;
import org.micromanager.lightsheetmanager.model.devices.vendor.ASIXYStage;
import org.micromanager.lightsheetmanager.model.devices.vendor.ASIZStage;
import org.micromanager.lightsheetmanager.model.devices.Stage;
import org.micromanager.lightsheetmanager.model.devices.XYStage;
import org.micromanager.lightsheetmanager.model.utils.GeometryUtils;
import org.micromanager.lightsheetmanager.model.utils.NumberUtils;

Expand Down Expand Up @@ -38,7 +37,7 @@ public class XYZGrid {
private int overlapYZ_;
private boolean clearYZ_;

private LightSheetManager model_;
private final LightSheetManager model_;

public XYZGrid(final LightSheetManager model) {
model_ = Objects.requireNonNull(model);
Expand Down Expand Up @@ -88,8 +87,8 @@ private int updateGridZCount() {
*/
public void computeGrid() {

ASIXYStage xyStage = model_.devices().getDevice(DISPIMDevice.SAMPLE_XY);
ASIZStage zStage = model_.devices().getDevice(DISPIMDevice.SAMPLE_Z);
XYStage xyStage = model_.devices().getDevice("SampleXY");
Stage zStage = model_.devices().getDevice("SampleZ");

final int numX = useX_ ? updateGridXCount() : 1;
final int numY = useY_ ? updateGridYCount() : 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,22 @@ public class Stage extends DeviceBase {
public Stage(final Studio studio, final String deviceName) {
super(studio, deviceName);
}

public void setPosition(final double position) {
try {
core_.setPosition(deviceName_, position);
} catch (Exception e) {
studio_.logs().showError("could not set position for " + deviceName_);
}
}

public double getPosition() {
try {
return core_.getPosition(deviceName_);
} catch (Exception e) {
studio_.logs().showError("could not get position for " + deviceName_);
return 0.0;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void setRelativeXYPosition(final int x, final int y) {
}
}

public void setXYPosition(final int x, final int y) {
public void setXYPosition(final double x, final double y) {
try {
core_.setXYPosition(deviceName_, x, y);
} catch (Exception e) {
Expand Down
Loading