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

change buttons to toggle buttons on setup path tab for live mode #294

Merged
merged 1 commit into from
Jul 29, 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 @@ -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
Loading