def completed(self): self.check_for_unsaved_changes() state = {'rect': []} files = [] for key, val in self.edited_images.items(): HexrdConfig().add_detector(key, 'default') HexrdConfig().set_instrument_config_val( ['detectors', key, 'pixels', 'columns', 'value'], int(val['width'])) HexrdConfig().set_instrument_config_val( ['detectors', key, 'pixels', 'rows', 'value'], int(val['height'])) state['rect'].append(val['rect']) files.append([val['img']]) HexrdConfig().remove_detector('default') ilm = ImageLoadManager() ilm.read_data(files, parent=self.ui) ilm.set_state(state) ilm.begin_processing() self.new_config_loaded.emit() self.reset_panel() self.parent().action_show_toolbar.setEnabled(True) self.parent().action_show_toolbar.setChecked(True)
def apply_transforms(self): num_dets = len(HexrdConfig().detector_names) trans = [] if self.ui.update_all.isChecked(): idx = self.ui.transform_all_menu.currentIndex() trans = [idx for x in range(num_dets)] else: for combo in self.det_cboxes: trans.append(combo.currentIndex()) ilm = ImageLoadManager() state = HexrdConfig().load_panel_state state['trans'] = trans new_state = { 'trans': trans, 'agg': state.get('agg', 0), } if self.ui.subtract_minimum.isChecked(): new_state['zero-min'] = None state['zero-min'] = None ilm.set_state(new_state) ilm.begin_processing(postprocess=True)
def add_transform(self): ilm = ImageLoadManager() state = HexrdConfig().load_panel_state ilm.set_state({'trans': [self.ui.transforms.currentIndex()]}) ilm.begin_processing(postprocess=True) self.ui.transforms.setCurrentIndex(0) self.it.update_image(HexrdConfig().image('default', 0))
def finalize(self): self.it.cropped_image img = self.it.masked_image ilm = ImageLoadManager() self.cmap.block_updates(True) ilm.read_data([[img]], parent=self.ui) if self.instrument == 'PXRDIP': ilm.set_state({'trans': [UI_TRANS_INDEX_ROTATE_90]}) ilm.begin_processing(postprocess=True) img = HexrdConfig().image(self.detector, 0) self.cmap.block_updates(False) self.it.update_image(img) self.edited_images[self.detector] = { 'img': img, 'height': img.shape[0], 'width': img.shape[1], 'tilt': self.it.rotation } self.canvas.axes_images[0].set_extent( (0, img.shape[1], img.shape[0], 0)) self.it.redraw() self.clear_boundry()
def finalize(self, img, bounds): ImageLoadManager().read_data([[img]], parent=self.ui) ilm = ImageLoadManager() ilm.set_state({'rect': [bounds]}) ilm.begin_processing() det = self.ui.detectors.currentText() self.edited_images[det] = { 'img': img, 'rect': bounds, 'height': np.abs(bounds[0][0] - bounds[0][1]), 'width': np.abs(bounds[1][0] - bounds[1][1]) } self.it.redraw() self.clear_boundry()
def add_transform(self): # Prevent color map reset on transform self.cmap.block_updates(True) self.it.toggle_boundaries(show=False) ilm = ImageLoadManager() ilm.set_state({'trans': [self.ui.transforms.currentIndex()]}) ilm.begin_processing(postprocess=True) self.cmap.block_updates(False) self.ui.transforms.setCurrentIndex(0) img = HexrdConfig().image('default', 0) if self.detector in self.edited_images.keys(): # This transform is being done post-processing self.edited_images[self.detector]['img'] = img self.edited_images[self.detector]['height'] = img.shape[0] self.edited_images[self.detector]['width'] = img.shape[1] self.it.toggle_boundaries(show=True) if self.it.shape is not None: self.it.update_image(img)
def add_transform(self): # Prevent color map reset on transform self.cmap.block_updates(True) ilm = ImageLoadManager() ilm.set_state({'trans': [self.ui.transforms.currentIndex()]}) ilm.begin_processing(postprocess=True) self.cmap.block_updates(False) self.ui.transforms.setCurrentIndex(0) img = HexrdConfig().image(self.detector, 0) if self.detector in self.edited_images.keys(): # This transform is being done post-processing self.edited_images[self.detector]['img'] = img self.edited_images[self.detector]['height'] = img.shape[0] self.edited_images[self.detector]['width'] = img.shape[1] self.canvas.axes_images[0].set_extent( (0, img.shape[1], img.shape[0], 0)) self.canvas.draw() if self.it: self.it.update_image(img)