def on_action_edit_apply_laue_mask_to_polar_triggered(self): if not HexrdConfig().show_overlays: msg = 'Overlays are not displayed' QMessageBox.critical(self.ui, 'HEXRD', msg) return overlays = HexrdConfig().overlays laue_overlays = [x for x in overlays if x['type'] == OverlayType.laue] laue_overlays = [x for x in laue_overlays if x['visible']] if not laue_overlays: msg = 'No Laue overlays found' QMessageBox.critical(self.ui, 'HEXRD', msg) return data = [] for overlay in laue_overlays: for det, val in overlay['data'].items(): for ranges in val['ranges']: data.append(ranges) if not data: msg = 'No Laue overlay ranges found' QMessageBox.critical(self.ui, 'HEXRD', msg) return name = create_unique_name(HexrdConfig().polar_masks_line_data, 'laue_mask') create_polar_mask(data, name) HexrdConfig().polar_masks_line_data[name] = data HexrdConfig().visible_masks.append(name) self.new_mask_added.emit(self.image_mode) HexrdConfig().polar_masks_changed.emit()
def update_masks_list(self, mask_type): if mask_type == 'polar': if not HexrdConfig().polar_masks_line_data: return for name, data in HexrdConfig().polar_masks_line_data.items(): vals = self.masks.values() for val in data: if any(np.array_equal(val, m) for t, m in vals): continue self.masks[name] = (mask_type, val) elif mask_type == 'raw': if not HexrdConfig().raw_masks_line_data: return for name, value in HexrdConfig().raw_masks_line_data.items(): det, val = value[0] vals = self.masks.values() if any(np.array_equal(val, m) for t, m in vals): continue self.masks[name] = (det, val) elif not self.threshold: name = create_unique_name(self.masks, 'threshold') self.masks[name] = ('threshold', HexrdConfig().threshold_mask) HexrdConfig().visible_masks.append(name) self.threshold = True self.setup_table()
def create_masks(self): for data in self.raw_masks_line_data: name = create_unique_name(HexrdConfig().raw_masks_line_data, 'raw_mask_0') HexrdConfig().raw_masks_line_data[name] = [data] create_raw_mask(name, [data]) HexrdConfig().visible_masks.append(name) HexrdConfig().raw_masks_changed.emit() for data_coords in self.polar_masks_line_data: name = create_unique_name(HexrdConfig().polar_masks_line_data, 'polar_mask_0') HexrdConfig().polar_masks_line_data[name] = data_coords create_polar_mask([data_coords], name) HexrdConfig().visible_masks.append(name) HexrdConfig().polar_masks_changed.emit()
def run_apply_polar_mask(self, line_data): name = create_unique_name(HexrdConfig().polar_masks_line_data, 'polar_mask_0') ld = line_data.copy() HexrdConfig().polar_masks_line_data[name] = ld create_polar_mask(name, ld) HexrdConfig().polar_masks_changed.emit() self.new_mask_added.emit(self.image_mode)
def run_apply_polar_mask(self, line_data): for line in line_data: name = create_unique_name(HexrdConfig().polar_masks_line_data, 'polar_mask_0') HexrdConfig().polar_masks_line_data[name] = line.copy() HexrdConfig().visible_masks.append(name) create_polar_mask([line.copy()], name) HexrdConfig().polar_masks_changed.emit() self.new_mask_added.emit(self.image_mode)