Skip to content

Commit

Permalink
Merge pull request #294 from bls337/main
Browse files Browse the repository at this point in the history
change buttons to toggle buttons on setup path tab for live mode
  • Loading branch information
bls337 authored Jul 29, 2024
2 parents 857be5e + b5e97f9 commit 626ef06
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class LightSheetManagerFrame extends JFrame {

private TabPanel tabPanel_;

private LightSheetManagerModel model_;
private final LightSheetManagerModel model_;

public LightSheetManagerFrame(final LightSheetManagerModel model, final boolean isLoaded) {
model_ = Objects.requireNonNull(model);
Expand All @@ -48,7 +48,7 @@ public LightSheetManagerFrame(final LightSheetManagerModel model, final boolean
// create the user interface
if (isLoaded) {
initDialogs();
GeometryType geometryType = model_.devices()
final GeometryType geometryType = model_.devices()
.getDeviceAdapter().getMicroscopeGeometry();
switch (geometryType) {
case DISPIM:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.micromanager.lightsheetmanager.gui.tabs.setup;

import com.google.common.eventbus.Subscribe;
import org.micromanager.events.LiveModeEvent;
import org.micromanager.lightsheetmanager.api.data.CameraMode;
import org.micromanager.lightsheetmanager.api.data.GeometryType;
import org.micromanager.lightsheetmanager.gui.components.Button;
import org.micromanager.lightsheetmanager.gui.components.Panel;
import org.micromanager.lightsheetmanager.gui.components.ToggleButton;
import org.micromanager.lightsheetmanager.gui.data.Icons;
import org.micromanager.lightsheetmanager.model.LightSheetManagerModel;
import org.micromanager.lightsheetmanager.model.devices.cameras.CameraBase;
Expand All @@ -16,13 +19,18 @@
*/
public class CameraPanel extends Panel {

private boolean isPreviewPressed = false;
private boolean isLivePressed = false;

private Button btnImagingPath_;
private Button btnEpiPath_;
private Button btnMultiPath_;
private Button btnInvertedPath_;
private Button btnLiveMode_;

private ToggleButton btnInvertedPath_;
private ToggleButton btnLiveMode_;

private final LightSheetManagerModel model_;

public CameraPanel(final LightSheetManagerModel model) {
super("Cameras");
model_ = Objects.requireNonNull(model);
Expand All @@ -40,14 +48,23 @@ private void createUserInterface() {
"[]5[]"
);

// register micro-manager events
model_.studio().events().registerForEvents(this);

Button.setDefaultSize(80, 26);
btnImagingPath_ = new Button("Imaging");
btnMultiPath_ = new Button("Multi");
btnEpiPath_ = new Button("Epi");
btnInvertedPath_ = new Button("Inverted");

Button.setDefaultSize(165, 26);
btnLiveMode_ = new Button("Live", Icons.CAMERA);
ToggleButton.setDefaultSize(165, 26);
btnInvertedPath_ = new ToggleButton(
"Preview", "Stop Preview",
Icons.CAMERA, Icons.CANCEL
);
btnLiveMode_ = new ToggleButton(
"Live", "Stop Live",
Icons.CAMERA, Icons.CANCEL
);

switch (geometryType) {
case DISPIM:
Expand All @@ -58,7 +75,7 @@ private void createUserInterface() {
add(btnLiveMode_, "span 2");
break;
case SCAPE:
btnInvertedPath_.setAbsoluteSize(165, 26);
//btnInvertedPath_.setAbsoluteSize(165, 26);
add(btnInvertedPath_, "wrap");
add(btnLiveMode_, "");
break;
Expand Down Expand Up @@ -94,9 +111,8 @@ private void createEventHandlers() {
});
break;
case SCAPE:
btnInvertedPath_.setText("Preview");
//btnInvertedPath_.setText("Preview");
btnInvertedPath_.registerListener(e -> {
// TODO: make this work, needs Device Adapter pull request and name for camera...
closeLiveModeWindow();
final CameraBase camera = model_.devices().getDevice("PreviewCamera");
if (camera != null) {
Expand All @@ -105,9 +121,12 @@ private void createEventHandlers() {
camera.setTriggerMode(CameraMode.INTERNAL);
} catch (Exception ex) {
model_.studio().logs().showError("could not set camera to " + camera.getDeviceName());
return; // early exit
}
isPreviewPressed = true;
model_.studio().live().setLiveModeOn(true);
} else {
btnInvertedPath_.setState(false);
model_.studio().logs().showError(
"No device for \"PreviewCamera\" set in the device adapter.");
}
Expand All @@ -123,7 +142,9 @@ private void createEventHandlers() {
camera.setTriggerMode(CameraMode.INTERNAL);
} catch (Exception ex) {
model_.studio().logs().showError("could not set camera to " + camera.getDeviceName());
return; // early exit
}
isLivePressed = true;
model_.studio().live().setLiveModeOn(true);
} else {
model_.studio().logs().showError(
Expand All @@ -150,4 +171,18 @@ private void closeLiveModeWindow() {
}
}

@Subscribe
public void liveModeListener(LiveModeEvent event) {
if (!model_.studio().live().isLiveModeOn()) {
if (isPreviewPressed) {
isPreviewPressed = false;
btnInvertedPath_.setState(false);
}
if (isLivePressed) {
isLivePressed = false;
btnLiveMode_.setState(false);;
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public int roiReadoutRowsSplitReadout(Rectangle roi, Rectangle sensor) {

@Override
public void setTriggerMode(CameraMode cameraMode) {
System.out.println("this!");
mode_ = cameraMode;
}

Expand Down

0 comments on commit 626ef06

Please sign in to comment.