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

GUI: Merging live control and timelapse control widgets #87

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
6 changes: 2 additions & 4 deletions copylot/gui/_qt/dockables/live_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ def __init__(self, parent, threadpool):

# view and channel combobox widgets and options
self.view_combobox = QComboBox()
self.view_combobox.addItem("view 1")
self.view_combobox.addItem("view 2")
self.view_combobox.addItems(["view 1", "view 2"])
self.view_combobox.setCurrentIndex(self.parent.defaults["live"]["view"])

self.layout.addWidget(self.view_combobox)
self.view_combobox.activated.connect(self.launch_nidaq)

self.laser_combobox = QComboBox()
self.laser_combobox.addItem("488")
self.laser_combobox.addItem("561")
self.laser_combobox.addItems(["488", "561"])
self.laser_combobox.setCurrentIndex(self.parent.defaults["live"]["laser"])

self.layout.addWidget(self.laser_combobox)
Expand Down
48 changes: 48 additions & 0 deletions copylot/gui/_qt/dockables/live_timelapse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton

from copylot.hardware.ni_daq.nidaq import NIDaq


class LiveTimelapseDockWidget(QWidget):
def __init__(self, parent, threadpool):
super(QWidget, self).__init__(parent)

self.parent = parent
self.threadpool = threadpool

self.running = False
self.wait_before_shutdown = False

self.layout = QVBoxLayout()
self.layout.setAlignment(Qt.AlignTop)

# add instance launching button
self.live_button = QPushButton("Live Button")
self.timelapse_button = QPushButton("Timelapse Button")

self.layout.addWidget(self.live_button)
self.layout.addWidget(self.timelapse_button)

self.setLayout(self.layout)

def timelapse_worker_method(self):
view = self.view_combobox.currentIndex()
channel = (
[int(self.laser_combobox.currentText())]
if self.laser_combobox.currentIndex() != 2
else [488, 561]
)
parameters = self.parent.parameters_widget.parameters

daq_card = NIDaq(self, **parameters)
daq_card.acquire_stacks(channels=channel, view=view)

def live_worker_method(self):
view = self.combobox_view
channel = self.combobox_channel
parameters = self.parent.parameters_widget.parameters

daq_card = NIDaq(self, **parameters)
daq_card.select_view(view)
daq_card.select_channel_remove_stripes(channel)
8 changes: 2 additions & 6 deletions copylot/gui/_qt/dockables/timelapse_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,13 @@ def __init__(self, parent, threadpool):

# view and channel combobox widgets and options
self.view_combobox = QComboBox()
self.view_combobox.addItem("view 1")
self.view_combobox.addItem("view 2")
self.view_combobox.addItem("view 1 and 2")
self.view_combobox.addItems(["view 1", "view 2", "view 1 and 2"])
self.view_combobox.setCurrentIndex(self.parent.defaults["timelapse"]["view"])

self.layout.addWidget(self.view_combobox)

self.laser_combobox = QComboBox()
self.laser_combobox.addItem("488")
self.laser_combobox.addItem("561")
self.laser_combobox.addItem("488 and 561")
self.laser_combobox.addItems(["488", "561", "488 and 561"])
self.laser_combobox.setCurrentIndex(self.parent.defaults["timelapse"]["laser"])

self.layout.addWidget(self.laser_combobox)
Expand Down
28 changes: 9 additions & 19 deletions copylot/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,40 +91,29 @@ def __init__(self, *args, **kwargs):
json.dump(self.defaults, outfile)

# initialize docks
self.live_dock = QDockWidget(self)
self.live_dock.setTitleBarWidget(QLabel("Live Mode"))
self.timelapse_dock = QDockWidget(self)
self.timelapse_dock.setTitleBarWidget(QLabel("Timelapse Mode"))
self.livetimelapse_dock = QDockWidget(self)
self.livetimelapse_dock.setTitleBarWidget(QLabel("Live/Timelapse Mode"))
self.water_dock = QDockWidget(self)
self.water_dock.setTitleBarWidget(QLabel("Water Dispenser"))
self.parameters_dock = QDockWidget(self)
self.parameters_dock.setTitleBarWidget(QLabel("NI DAQ Parameters"))

# set common configurations for docks
self.dock_list = [
self.live_dock,
self.timelapse_dock,
self.livetimelapse_dock,
self.water_dock,
self.parameters_dock,
]
for dock in self.dock_list:
_apply_dock_config(dock)

# initialize widgets and assign to their dock
self.live_dock.setWidget(
self.livetimelapse_dock.setWidget(
DockPlaceholder(
self, self.live_dock, "live_control", [self, self.threadpool]
self, self.livetimelapse_dock, "live_timelapse", [self, self.threadpool]
)
)
# self.addDockWidget(Qt.RightDockWidgetArea, self.live_dock)
#
# self.timelapse_widget = TimelapseControl(self, self.threadpool)
self.timelapse_dock.setWidget(
DockPlaceholder(
self, self.timelapse_dock, "timelapse_control", [self, self.threadpool]
)
)
# self.addDockWidget(Qt.RightDockWidgetArea, self.timelapse_dock)

# self.water_widget = WaterDispenser(self, self.threadpool)
self.water_dock.setWidget(
Expand All @@ -142,9 +131,10 @@ def __init__(self, *args, **kwargs):
self.addDockWidget(Qt.LeftDockWidgetArea, self.parameters_dock)

# split horizontal and vertical space between docks
self.splitDockWidget(self.parameters_dock, self.live_dock, Qt.Horizontal)
self.splitDockWidget(self.live_dock, self.timelapse_dock, Qt.Vertical)
self.splitDockWidget(self.timelapse_dock, self.water_dock, Qt.Vertical)
self.splitDockWidget(
self.parameters_dock, self.livetimelapse_dock, Qt.Horizontal
)
self.splitDockWidget(self.livetimelapse_dock, self.water_dock, Qt.Vertical)

# create status bar that is updated from live and timelapse control classes
self.status_bar = QStatusBar()
Expand Down