Skip to content

Commit

Permalink
Move mask signals to MaskManager
Browse files Browse the repository at this point in the history
Signed-off-by: Brianna Major <[email protected]>
  • Loading branch information
bnmajor committed Dec 20, 2023
1 parent aa0cd11 commit cfb7de1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
12 changes: 0 additions & 12 deletions hexrdgui/hexrd_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@ class HexrdConfig(QObject, metaclass=QSingleton):
"""Emitted when the Euler angle convention changes"""
euler_angle_convention_changed = Signal()

"""Emitted when the threshold mask status changes via the dialog"""
threshold_mask_changed = Signal(str)

"""Emitted when the threshold mask status changes via mask manager"""
mgr_threshold_mask_changed = Signal()

"""Emitted when the active material is changed to a different material"""
active_material_changed = Signal()

Expand Down Expand Up @@ -165,12 +159,6 @@ class HexrdConfig(QObject, metaclass=QSingleton):
"""Emitted to update the tth width in the powder overlay editor"""
material_tth_width_modified = Signal(str)

"""Emitted when a new raw mask has been created"""
raw_masks_changed = Signal()

"""Emitted when a new polar mask has been created"""
polar_masks_changed = Signal()

"""Emitted when the polar x-axis type changes"""
polar_x_axis_type_changed = Signal()

Expand Down
5 changes: 3 additions & 2 deletions hexrdgui/image_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from hexrdgui.calibration.stereo_plot import stereo_viewer
from hexrdgui.constants import OverlayType, PolarXAxisType, ViewType
from hexrdgui.hexrd_config import HexrdConfig
from hexrdgui.masking.mask_manager import MaskManager
from hexrdgui.snip_viewer_dialog import SnipViewerDialog
from hexrdgui import utils
from hexrdgui.utils.array import split_array
Expand Down Expand Up @@ -92,7 +93,7 @@ def setup_connections(self):
HexrdConfig().beam_marker_modified.connect(self.update_beam_marker)
HexrdConfig().oscillation_stage_changed.connect(
self.oscillation_stage_changed)
HexrdConfig().polar_masks_changed.connect(self.polar_masks_changed)
MaskManager().polar_masks_changed.connect(self.polar_masks_changed)
HexrdConfig().overlay_renamed.connect(self.overlay_renamed)
HexrdConfig().azimuthal_overlay_modified.connect(
self.update_azimuthal_integral_plot)
Expand Down Expand Up @@ -203,7 +204,7 @@ def load_images(self, image_names):
def unscaled_image_dict(self):
# Returns a dict of the unscaled images
if self.mode == ViewType.raw:
return HexrdConfig().create_masked_images_dict(fill_value=np.nan)
return MaskManager().create_masked_images_dict(fill_value=np.nan)
else:
# Masks are already applied...
return {'img': self.iviewer.img}
Expand Down
14 changes: 7 additions & 7 deletions hexrdgui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def setup_connections(self):
self.on_detector_shape_changed)
HexrdConfig().deep_rerender_needed.connect(self.deep_rerender)
HexrdConfig().rerender_needed.connect(self.on_rerender_needed)
HexrdConfig().raw_masks_changed.connect(self.update_all)
MaskManager().raw_masks_changed.connect(self.update_all)
HexrdConfig().enable_canvas_toolbar.connect(
self.on_enable_canvas_toolbar)
HexrdConfig().tab_images_changed.connect(
Expand All @@ -315,7 +315,7 @@ def setup_connections(self):
ImageLoadManager().state_updated.connect(
self.simple_image_series_dialog.setup_gui)

self.new_mask_added.connect(self.mask_manager_dialog.update_masks_list)
self.new_mask_added.connect(self.mask_manager_dialog.setup_table)
self.image_mode_widget.tab_changed.connect(MaskManager().view_mode_changed)

self.ui.action_apply_pixel_solid_angle_correction.toggled.connect(
Expand Down Expand Up @@ -752,14 +752,14 @@ def run_apply_hand_drawn_mask(self, dets, line_data):
raw_line = convert_polar_to_raw([line])
mask = MaskManager().add_mask(name, raw_line, MaskType.polygon)
mask.update_masked_arrays(self.image_mode)
HexrdConfig().polar_masks_changed.emit()
MaskManager().polar_masks_changed.emit()
elif self.image_mode == ViewType.raw:
for det, line in zip(dets, line_data):
name = unique_name(MaskManager().mask_names, 'raw_mask_0')
mask = MaskManager().add_mask(
name, [(det, line.copy())], MaskType.polygon)
mask.update_masked_arrays(self.image_mode)
HexrdConfig().raw_masks_changed.emit()
MaskManager().raw_masks_changed.emit()
self.new_mask_added.emit(self.image_mode)

def on_action_edit_apply_laue_mask_to_polar_triggered(self):
Expand Down Expand Up @@ -791,7 +791,7 @@ def on_action_edit_apply_laue_mask_to_polar_triggered(self):
mask = MaskManager().add_mask(name, raw_data, MaskType.laue)
mask.update_masked_arrays(self.image_mode)
self.new_mask_added.emit(self.image_mode)
HexrdConfig().polar_masks_changed.emit()
MaskManager().polar_masks_changed.emit()

def action_edit_apply_powder_mask_to_polar(self):
if not HexrdConfig().show_overlays:
Expand Down Expand Up @@ -847,7 +847,7 @@ def action_edit_apply_powder_mask_to_polar(self):
mask = MaskManager().add_mask(name, raw_data, MaskType.powder)
mask.update_masked_arrays(self.image_mode)
self.new_mask_added.emit(self.image_mode)
HexrdConfig().polar_masks_changed.emit()
MaskManager().polar_masks_changed.emit()

def update_mask_region_canvas(self):
if hasattr(self, '_masks_regions_dialog'):
Expand Down Expand Up @@ -911,7 +911,7 @@ def apply_pinhole_mask(self, radius, thickness):
MaskManager().masks[name].set_data(ph_masks)
else:
MaskManager().add_mask(name, ph_masks, MaskType.pinhole)
HexrdConfig().raw_masks_changed.emit()
MaskManager().raw_masks_changed.emit()

self.new_mask_added.emit(self.image_mode)

Expand Down
2 changes: 2 additions & 0 deletions hexrdgui/masking/mask_manager_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def setup_connections(self):
self.ui.view_masks.clicked.connect(self.show_masks)
self.ui.hide_all_masks.clicked.connect(self.hide_all_masks)
self.ui.show_all_masks.clicked.connect(self.show_all_masks)
MaskManager().mask_mgr_dialog_update.connect(self.setup_table)
MaskManager().export_masks_to_file.connect(self.export_masks_to_file)

def setup_table(self):
with block_signals(self.ui.masks_table):
Expand Down
4 changes: 2 additions & 2 deletions hexrdgui/masking/mask_regions_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ def create_masks(self):
mask.update_masked_arrays(self.image_mode)

masks_changed_signal = {
'raw': HexrdConfig().raw_masks_changed,
'polar': HexrdConfig().polar_masks_changed
'raw': MaskManager().raw_masks_changed,
'polar': MaskManager().polar_masks_changed
}
masks_changed_signal[self.image_mode].emit()

Expand Down

0 comments on commit cfb7de1

Please sign in to comment.