diff --git a/hexrdgui/image_canvas.py b/hexrdgui/image_canvas.py index 7fd90db30..774552737 100644 --- a/hexrdgui/image_canvas.py +++ b/hexrdgui/image_canvas.py @@ -24,6 +24,7 @@ from hexrdgui.constants import OverlayType, PolarXAxisType, ViewType from hexrdgui.create_hedm_instrument import create_view_hedm_instrument from hexrdgui.hexrd_config import HexrdConfig +from hexrdgui.masking.constants import MaskType from hexrdgui.masking.create_polar_mask import create_polar_line_data_from_raw from hexrdgui.masking.mask_manager import MaskManager from hexrdgui.snip_viewer_dialog import SnipViewerDialog @@ -1668,7 +1669,13 @@ def draw_mask_boundaries(self, axis, det=None): else: verts = [v for k, v in mask.data if k == det] elif self.mode == ViewType.polar or self.mode == ViewType.stereo: - verts = create_polar_line_data_from_raw(instr, mask.data) + # Do not apply tth distortion for the pinhole mask + apply_tth_distortion = mask.type != MaskType.pinhole + verts = create_polar_line_data_from_raw( + instr, + mask.data, + apply_tth_distortion=apply_tth_distortion, + ) if self.mode == ViewType.polar: # Check for any major jumps in eta. That probably means # the border is wrapping around. diff --git a/hexrdgui/masking/create_polar_mask.py b/hexrdgui/masking/create_polar_mask.py index 5f9648645..8d70691b6 100644 --- a/hexrdgui/masking/create_polar_mask.py +++ b/hexrdgui/masking/create_polar_mask.py @@ -9,7 +9,7 @@ from hexrdgui.utils.tth_distortion import apply_tth_distortion_if_needed -def convert_raw_to_polar(instr, det, line): +def convert_raw_to_polar(instr, det, line, apply_tth_distortion=True): # This accepts an instrument rather than creating one for performance # Make sure there at least 500 sample points so that the conversion @@ -27,7 +27,10 @@ def convert_raw_to_polar(instr, det, line): 'tvec_s': instr.tvec } line = cart_to_angles(xys, panel, **kwargs) - line = apply_tth_distortion_if_needed(line, in_degrees=True) + + if apply_tth_distortion: + line = apply_tth_distortion_if_needed(line, in_degrees=True) + return [line] if line.size else None @@ -144,22 +147,31 @@ def _interpolate_split_coords_1d(coords1, coords2): return coords1, coords2 -def create_polar_line_data_from_raw(instr, value): +def create_polar_line_data_from_raw(instr, value, apply_tth_distortion=True): # This accepts an instrument rather than creating one for performance line_data = [] for det, data in value: - if polar := convert_raw_to_polar(instr, det, data): + if polar := convert_raw_to_polar( + instr, + det, + data, + apply_tth_distortion=apply_tth_distortion, + ): line_data.extend(polar) return line_data -def create_polar_mask_from_raw(value, instr=None): +def create_polar_mask_from_raw(value, instr=None, apply_tth_distortion=True): if instr is None: # An instrument can be passed for improved performance. # If one wasn't passed, create one. instr = create_hedm_instrument() - line_data = create_polar_line_data_from_raw(instr, value) + line_data = create_polar_line_data_from_raw( + instr, + value, + apply_tth_distortion=apply_tth_distortion, + ) return create_polar_mask(line_data) diff --git a/hexrdgui/masking/mask_manager.py b/hexrdgui/masking/mask_manager.py index f348c263f..2d2d975a2 100644 --- a/hexrdgui/masking/mask_manager.py +++ b/hexrdgui/masking/mask_manager.py @@ -91,7 +91,13 @@ def update_masked_arrays(self, view=ViewType.raw, instr=None): if view == ViewType.raw: self.masked_arrays = create_raw_mask(self._raw) else: - self.masked_arrays = create_polar_mask_from_raw(self._raw, instr) + # Do not apply tth distortion for pinhole mask types + apply_tth_distortion = self.type != MaskType.pinhole + self.masked_arrays = create_polar_mask_from_raw( + self._raw, + instr, + apply_tth_distortion=apply_tth_distortion, + ) def get_masked_arrays(self, image_mode=ViewType.raw, instr=None): if self.masked_arrays is None or self.masked_arrays_view_mode != image_mode: @@ -100,7 +106,7 @@ def get_masked_arrays(self, image_mode=ViewType.raw, instr=None): return self.masked_arrays def update_border_visibility(self, visibility): - can_have_border = [MaskType.region, MaskType.polygon] + can_have_border = [MaskType.region, MaskType.polygon, MaskType.pinhole] if self.type not in can_have_border: # Only rectangle, ellipse and hand-drawn masks can show borders visibility = False diff --git a/hexrdgui/masking/mask_manager_dialog.py b/hexrdgui/masking/mask_manager_dialog.py index e7b5b935f..f615b9ad2 100644 --- a/hexrdgui/masking/mask_manager_dialog.py +++ b/hexrdgui/masking/mask_manager_dialog.py @@ -75,7 +75,8 @@ def update_table(self): if key in MaskManager().visible_masks: idx = MaskStatus.visible if (mask_type == MaskType.region or - mask_type == MaskType.polygon): + mask_type == MaskType.polygon or + mask_type == MaskType.pinhole): presentation_combo.addItem('Boundary Only') presentation_combo.addItem('Visible + Boundary') if key in MaskManager().visible_boundaries: