Skip to content

Commit

Permalink
Merge pull request #38 from sohamazing/manual-roi-on-tab-changed
Browse files Browse the repository at this point in the history
bug fix: edits to manual region shape should not update scan coordinates while on flexible widget
  • Loading branch information
hongquanli authored Dec 20, 2024
2 parents 9fe89fc + 0d3d13e commit 1cd568f
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions software/control/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3430,7 +3430,7 @@ def __init__(self, navigationController, navigationViewer, multipointController,
self.acquisition_start_time = None
self.manual_shape = None
self.eta_seconds = 0
self.is_current_acquisition_widget = False
self.parent = self.multipointController.parent
self.add_components()
self.setFrameStyle(QFrame.Panel | QFrame.Raised)
self.set_default_scan_size()
Expand Down Expand Up @@ -3872,6 +3872,9 @@ def on_set_shape(self):
self.update_coordinates()

def update_manual_shape(self, shapes_data_mm):
if hasattr(self.parent, 'recordTabWidget') and self.parent.recordTabWidget.currentWidget() != self:
return

self.clear_regions()
if shapes_data_mm and len(shapes_data_mm) > 0:
self.manual_shapes = shapes_data_mm
Expand Down Expand Up @@ -3953,20 +3956,19 @@ def init_z(self, z_pos_mm=None):
self.entry_maxZ.blockSignals(False)

def set_live_scan_coordinates(self, x_mm, y_mm):
parent = self.multipointController.parent
is_current_widget = (parent is not None and hasattr(parent, 'recordTabWidget') and
parent.recordTabWidget.currentWidget() == self)

if self.combobox_shape.currentText() != 'Manual' and self.scanCoordinates.format == 'glass slide' and (parent is None or is_current_widget):
if hasattr(self.parent, 'recordTabWidget') and self.parent.recordTabWidget.currentWidget() != self:
return

if self.combobox_shape.currentText() != 'Manual' and self.scanCoordinates.format == 'glass slide':
if self.region_coordinates:
self.clear_regions()

self.add_region('current', x_mm, y_mm)

def set_well_coordinates(self, selected):
self.well_selected = selected and bool(self.scanCoordinates.get_selected_wells())
if hasattr(self.multipointController.parent, 'recordTabWidget') and self.multipointController.parent.recordTabWidget.currentWidget() == self:

if hasattr(self.parent, 'recordTabWidget') and self.parent.recordTabWidget.currentWidget() == self:
if self.scanCoordinates.format == 'glass slide':
x = self.navigationController.x_pos_mm
y = self.navigationController.y_pos_mm
Expand Down Expand Up @@ -5563,8 +5565,16 @@ def toggle_draw_mode(self, viewer):
self.shape_layer = self.viewer.layers['Manual ROI']

if self.is_drawing_shape:
self.shape_layer.mode = 'add_polygon'
# if there are existing shapes, switch to vertex select mode
if len(self.shape_layer.data) > 0:
self.shape_layer.mode = 'select'
self.shape_layer.select_mode = 'vertex'
else:
# if no shapes exist, switch to add polygon mode
# start drawing a new polygon on click, add vertices with additional clicks, finish/close polygon with double-click
self.shape_layer.mode = 'add_polygon'
else:
# if no shapes exist, switch to pan/zoom mode
self.shape_layer.mode = 'pan_zoom'

self.on_shape_change()
Expand Down

0 comments on commit 1cd568f

Please sign in to comment.