def load_images(self): caption = HexrdConfig().images_dirtion = 'Select file(s)' selected_file, selected_filter = QFileDialog.getOpenFileName( self.ui, caption, dir=HexrdConfig().images_dir) if selected_file: HexrdConfig().set_images_dir(selected_file) files, manual = ImageLoadManager().load_images([selected_file]) dialog = LoadImagesDialog(files, manual, self.ui.parent()) if not dialog.exec_(): return # If it is a hdf5 file allow the user to select the path ext = os.path.splitext(selected_file)[1] if (ImageFileManager().is_hdf(ext) and not ImageFileManager().path_exists(selected_file)): path_selected = ImageFileManager().path_prompt(selected_file) if not path_selected: return ImageLoadManager().read_data(files, parent=self.ui) file_names = [os.path.split(f[0])[1] for f in files] self.ui.files_label.setText(', '.join(file_names)) self.enable_widgets(self.ui.outline, self.ui.add_template, self.ui.transforms, self.ui.add_transform, enabled=True) self.enable_widgets(self.parent().action_show_toolbar, self.ui.save, enabled=False) self.parent().action_show_toolbar.setChecked(False)
def on_action_save_imageseries_triggered(self): if not HexrdConfig().has_images(): msg = ('No ImageSeries available for saving.') QMessageBox.warning(self.ui, 'HEXRD', msg) return if ImageLoadManager().unaggregated_images: ims_dict = ImageLoadManager().unaggregated_images else: ims_dict = HexrdConfig().imageseries_dict if len(ims_dict) > 1: # Have the user choose an imageseries to save names = list(ims_dict.keys()) name, ok = QInputDialog.getItem(self.ui, 'HEXRD', 'Select ImageSeries', names, 0, False) if not ok: # User canceled... return else: name = list(ims_dict.keys())[0] selected_file, selected_filter = QFileDialog.getSaveFileName( self.ui, 'Save ImageSeries', HexrdConfig().working_dir, 'HDF5 files (*.h5 *.hdf5);; NPZ files (*.npz)') if selected_file: HexrdConfig().working_dir = os.path.dirname(selected_file) if selected_filter.startswith('HDF5'): selected_format = 'hdf5' elif selected_filter.startswith('NPZ'): selected_format = 'frame-cache' kwargs = {} if selected_format == 'hdf5': # A path must be specified. Set it ourselves for now. kwargs['path'] = 'imageseries' elif selected_format == 'frame-cache': # Get the user to pick a threshold result, ok = QInputDialog.getDouble(self.ui, 'HEXRD', 'Choose Threshold', 10, 0, 1e12, 3) if not ok: # User canceled... return kwargs['threshold'] = result # This needs to be specified, but I think it just needs # to be the same as the file name... kwargs['cache_file'] = selected_file HexrdConfig().save_imageseries(ims_dict.get(name), name, selected_file, selected_format, **kwargs)
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 create_indexing_config(): # Creates a hexrd.config class from the indexing configuration # Make a copy to modify indexing_config = copy.deepcopy(HexrdConfig().indexing_config) material = HexrdConfig().active_material omaps = indexing_config['find_orientations']['orientation_maps'] omaps['active_hkls'] = active_hkl_indices(material.planeData) # Set the active material on the config tmp = indexing_config.setdefault('material', {}) tmp['active'] = HexrdConfig().active_material_name # Create the root config from the indexing config dict config = RootConfig(indexing_config) # Create and set instrument config iconfig = InstrumentConfig() iconfig._hedm = create_hedm_instrument() config.instrument = iconfig # Create and set material config mconfig = MaterialConfig(config) mconfig.materials = HexrdConfig().materials config.material = mconfig # Use unaggregated images if possible ims_dict = ImageLoadManager().unaggregated_images if ims_dict is None: # This probably means the image series was never aggregated. # Try using the imageseries dict. ims_dict = HexrdConfig().imageseries_dict # Load omega data if it is missing load_omegas_dict = { k: ims for k, ims in ims_dict.items() if 'omega' not in ims.metadata } if load_omegas_dict: ImageLoadManager().add_omega_metadata(load_omegas_dict) # Convert image series into OmegaImageSeries for key, ims in ims_dict.items(): ims_dict[key] = OmegaImageSeries(ims) config.image_series = ims_dict return config
def completed(self): self.cmap.block_updates(True) self.check_for_unsaved_changes() files = [] HexrdConfig().rename_detector(self.detector, 'default') 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'])) *zx, z = self.detector_defaults[key]['tilt'] HexrdConfig().set_instrument_config_val( ['detectors', key, 'transform', 'tilt', 'value'], [*zx, (z + float(val['tilt']))]) translation = self.detector_defaults[key]['translation'] HexrdConfig().set_instrument_config_val( ['detectors', key, 'transform', 'translation', 'value'], translation) files.append([val['img']]) HexrdConfig().remove_detector('default') self.new_config_loaded.emit() ImageLoadManager().read_data(files, parent=self.ui) self.reset_panel() self.parent().action_show_toolbar.setEnabled(True) self.parent().action_show_toolbar.setChecked(True) self.cmap.block_updates(False)
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 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 select_dark_img(self, selected_file=False): if not selected_file: # This takes one image to use for dark subtraction. caption = HexrdConfig().images_dirtion = 'Select image file' selected_file, selected_filter = QFileDialog.getOpenFileName( self.ui, caption, dir=self.parent_dir) if selected_file: if self.ui.all_detectors.isChecked(): files = ImageLoadManager().match_files([selected_file]) if files and all(len(f) for f in files): files.sort() for i, f in enumerate(files): self.dark_files[i] = files[i][0] self.state['dark_files'][i] = files[i][0] else: self.dark_files = [selected_file] * self.num_dets self.state['dark_files'] = [selected_file] * self.num_dets msg = ( f'Unable to match files - using the same dark file' f'for each detector.\nIf this is incorrect please ' f'de-select \"Apply Selections to All Detectors\" and ' f'select the dark file manually for each detector.') QMessageBox.warning(self.ui, 'HEXRD', msg) else: self.dark_files[self.idx] = selected_file self.state['dark_files'][self.idx] = selected_file self.dark_mode_changed() self.enable_read()
def find_images(self, fnames): self.files, manual = ImageLoadManager().load_images(fnames) if len(self.files) % len(HexrdConfig().detector_names) != 0: msg = ('Please select at least one file for each detector.') QMessageBox.warning(self.ui, 'HEXRD', msg) self.files = [] return if manual: dialog = LoadImagesDialog(self.files, manual, self.ui.parent()) if not dialog.exec_(): self.reset_data() return detector_names, files = dialog.results() image_files = [img for f in self.files for img in f] # Make sure files are matched to selected detector self.files = [[] for det in HexrdConfig().detector_names] for d, f in zip(detector_names, image_files): pos = HexrdConfig().detector_names.index(d) self.files[pos].append(f) self.dir_changed() if self.files and self.ext in YAML_EXTS: self.get_yml_files()
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 load_images(self): if self.instrument == 'PXRDIP': HexrdConfig().load_panel_state['trans'] = ( [UI_TRANS_INDEX_FLIP_HORIZONTALLY]) caption = HexrdConfig().images_dirtion = 'Select file(s)' selected_file, selected_filter = QFileDialog.getOpenFileName( self.ui, caption, dir=HexrdConfig().images_dir) if selected_file: HexrdConfig().set_images_dir(selected_file) files, manual = ImageLoadManager().load_images([selected_file]) dialog = LoadImagesDialog(files, manual, self.ui.parent()) if not dialog.exec_(): return # If it is a hdf5 file allow the user to select the path ext = os.path.splitext(selected_file)[1] if (ImageFileManager().is_hdf(ext) and not ImageFileManager().path_exists(selected_file)): path_selected = ImageFileManager().path_prompt(selected_file) if not path_selected: return if not self.canvas.raw_axes[0].get_autoscale_on(): self.canvas.raw_axes[0].set_autoscale_on(True) if self.completed_detectors: # Only reset the color map range for first detector processed self.cmap.block_updates(True) if self.ui.instrument.isEnabled(): # Only set the instrument config once success = self.get_instrument_defaults() if not success: return ImageLoadManager().read_data(files, parent=self.ui) self.cmap.block_updates(False) self.it = InteractiveTemplate(self.parent()) file_names = [os.path.split(f[0])[1] for f in files] self.ui.files_label.setText(', '.join(file_names)) self.enable_widgets(self.ui.transform_img, self.ui.association, self.ui.finalize, enabled=True) self.enable_widgets(self.ui.data, enabled=False)
def create_indexing_config(): # Creates a hexrd.config class from the indexing configuration # Make a copy to modify indexing_config = copy.deepcopy(HexrdConfig().indexing_config) available_materials = list(HexrdConfig().materials.keys()) selected_material = indexing_config.get('_selected_material') if selected_material not in available_materials: raise Exception(f'Selected material {selected_material} not available') material = HexrdConfig().material(selected_material) omaps = indexing_config['find_orientations']['orientation_maps'] omaps['active_hkls'] = list(range(len(material.planeData.getHKLs()))) # Set the active material on the config tmp = indexing_config.setdefault('material', {}) tmp['active'] = material.name # Create the root config from the indexing config dict config = RootConfig(indexing_config) # Create and set instrument config iconfig = InstrumentConfig(config) iconfig._hedm = create_hedm_instrument() config.instrument = iconfig # Create and set material config mconfig = MaterialConfig(config) mconfig.materials = HexrdConfig().materials config.material = mconfig # Set this so the config won't over-write our tThWidth config.set('material:tth_width', np.degrees(material.planeData.tThWidth)) # Use unaggregated images if possible ims_dict = HexrdConfig().unagg_images if ims_dict is None: # This probably means the image series was never aggregated. # Try using the imageseries dict. ims_dict = HexrdConfig().imageseries_dict # Load omega data if it is missing load_omegas_dict = { k: ims for k, ims in ims_dict.items() if 'omega' not in ims.metadata } if load_omegas_dict: ImageLoadManager().add_omega_metadata(load_omegas_dict) # Convert image series into OmegaImageSeries for key, ims in ims_dict.items(): if not isinstance(ims, OmegaImageSeries): ims_dict[key] = OmegaImageSeries(ims) config.image_series = ims_dict return config
def update_indexing_menu(self): enabled = False image_series_dict = ImageLoadManager().unaggregated_images image_series_dict = HexrdConfig().imageseries_dict if image_series_dict is None else image_series_dict if image_series_dict: # Check length of first series series = next(iter(image_series_dict.values())) enabled = len(series) > 1 self.ui.action_run_indexing.setEnabled(enabled)
def load_images(self): caption = HexrdConfig().images_dirtion = 'Select file(s)' selected_file, selected_filter = QFileDialog.getOpenFileName( self.ui, caption, dir=HexrdConfig().images_dir) if selected_file: HexrdConfig().set_images_dir(selected_file) files, manual = ImageLoadManager().load_images([selected_file]) dialog = LoadImagesDialog(files, manual, self.ui.parent()) if not dialog.exec_(): return # If it is a hdf5 file allow the user to select the path ext = os.path.splitext(selected_file)[1] if (ImageFileManager().is_hdf(ext) and not ImageFileManager().path_exists(selected_file)): path_selected = ImageFileManager().path_prompt(selected_file) if not path_selected: return if not self.canvas.raw_axes[0].get_autoscale_on(): self.canvas.raw_axes[0].set_autoscale_on(True) if hasattr(self, 'prev_extent'): self.canvas.axes_images[0].set_extent(self.prev_extent) if self.completed_detectors: # Only reset the color map range for first detector processed self.cmap.block_updates(True) ImageLoadManager().read_data(files, parent=self.ui) self.prev_extent = self.canvas.axes_images[0].get_extent() self.cmap.block_updates(False) file_names = [os.path.split(f[0])[1] for f in files] self.ui.files_label.setText(', '.join(file_names)) self.enable_widgets(self.ui.outline, self.ui.add_template, self.ui.transforms, self.ui.add_transform, enabled=True) self.enable_widgets(self.parent().action_show_toolbar, self.ui.save, enabled=False) self.parent().action_show_toolbar.setChecked(False)
def open_image_files(self): # Get the most recent images dir images_dir = HexrdConfig().images_dir selected_files, selected_filter = QFileDialog.getOpenFileNames( self.ui, dir=images_dir) if selected_files: # Save the chosen dir HexrdConfig().set_images_dir(selected_files[0]) files, manual = ImageLoadManager().load_images(selected_files) if not files: return if (any(len(f) != 1 for f in files) or len(files) < len(HexrdConfig().detector_names)): msg = ('Number of files must match number of detectors: ' + str(len(HexrdConfig().detector_names))) QMessageBox.warning(self.ui, 'HEXRD', msg) return # If it is a hdf5 file allow the user to select the path ext = os.path.splitext(selected_files[0])[1] if (ImageFileManager().is_hdf(ext) and not ImageFileManager().path_exists(selected_files[0])): selection = ImageFileManager().path_prompt(selected_files[0]) if not selection: return dialog = LoadImagesDialog(files, manual, self.ui) if dialog.exec_(): detector_names, image_files = dialog.results() image_files = [img for f in files for img in f] files = [[] for det in HexrdConfig().detector_names] for d, f in zip(detector_names, image_files): pos = HexrdConfig().detector_names.index(d) files[pos].append(f) ImageLoadManager().read_data(files, parent=self.ui) self.images_loaded()
def update_image_data(self): if not self.confirm_omega_range(): return self.ui.update_img_data.setDisabled(True) data = { 'omega_min': self.omega_min, 'omega_max': self.omega_max, 'nsteps': self.nsteps, } ImageLoadManager().add_omega_metadata( HexrdConfig().imageseries_dict, data)
def read_data(self): data = { 'omega_min': self.omega_min, 'omega_max': self.omega_max, 'empty_frames': self.empty_frames, 'total_frames': self.total_frames, } if self.ui.all_detectors.isChecked(): data['idx'] = self.idx if self.ext == '.yml': data['yml_files'] = self.yml_files HexrdConfig().load_panel_state.update(copy.copy(self.state)) ImageLoadManager().read_data(self.files, data, self.parent()) self.images_loaded.emit()
def read_data(self): if not self.confirm_omega_range(): return data = { 'omega_min': self.omega_min, 'omega_max': self.omega_max, 'nsteps': self.nsteps, 'empty_frames': self.empty_frames, 'total_frames': self.total_frames, } if self.ui.all_detectors.isChecked(): data['idx'] = self.idx if self.ext in YAML_EXTS: data['yml_files'] = self.yml_files if self.frame_data is not None: data.update(self.frame_data) HexrdConfig().load_panel_state.update(copy.copy(self.state)) ImageLoadManager().read_data(self.files, data, self.parent()) self.update_allowed = True
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)
def completed(self): self.import_in_progress = False self.cmap.block_updates(True) self.check_for_unsaved_changes() files = [] detectors = self.detector_defaults['default_config'].get( 'detectors', {}) not_set = [d for d in detectors if d not in self.completed_detectors] for det in not_set: del(detectors[det]) for det in self.completed_detectors: transform = detectors[det].setdefault('transform', {}) *zx, z = transform['tilt'] transform['tilt'] = ( [*zx, (z + float(self.edited_images[det]['tilt']))]) panel_buffer = detectors[det].setdefault('panel_buffer', []) panel_buffer = self.edited_images[det]['panel_buffer'] files.append([self.edited_images[det]['img']]) temp = tempfile.NamedTemporaryFile(delete=False, suffix='.yml') data = yaml.dump( self.detector_defaults['default_config'], sort_keys=False) temp.write(data.encode('utf-8')) temp.close() HexrdConfig().load_instrument_config(temp.name) self.set_convention() if self.instrument == 'PXRDIP': HexrdConfig().load_panel_state['trans'] = ( [UI_TRANS_INDEX_ROTATE_90] * len(self.detectors)) ImageLoadManager().read_data(files, parent=self.ui) self.reset_panel() self.parent().action_show_toolbar.setEnabled(True) self.parent().action_show_toolbar.setChecked(True) self.cmap.block_updates(False)
def setup_connections(self): """This is to setup connections for non-gui objects""" self.ui.installEventFilter(self) self.ui.action_open_config_file.triggered.connect( self.on_action_open_config_file_triggered) self.ui.action_open_grain_fitting_results.triggered.connect( self.open_grain_fitting_results) self.ui.action_save_config_yaml.triggered.connect( self.on_action_save_config_yaml_triggered) self.ui.action_save_config_hexrd.triggered.connect( self.on_action_save_config_hexrd_triggered) self.ui.action_open_materials.triggered.connect( self.on_action_open_materials_triggered) self.ui.action_save_imageseries.triggered.connect( self.on_action_save_imageseries_triggered) self.ui.action_save_materials.triggered.connect( self.on_action_save_materials_triggered) self.ui.action_export_current_plot.triggered.connect( self.on_action_export_current_plot_triggered) self.ui.action_edit_euler_angle_convention.triggered.connect( self.on_action_edit_euler_angle_convention) self.ui.action_edit_apply_polar_mask.triggered.connect( self.on_action_edit_apply_polar_mask_triggered) self.ui.action_edit_apply_polar_mask.triggered.connect( self.ui.image_tab_widget.toggle_off_toolbar) self.ui.action_edit_apply_laue_mask_to_polar.triggered.connect( self.on_action_edit_apply_laue_mask_to_polar_triggered) self.ui.action_edit_apply_polygon_mask.triggered.connect( self.on_action_edit_apply_polygon_mask_triggered) self.ui.action_edit_apply_polygon_mask.triggered.connect( self.ui.image_tab_widget.toggle_off_toolbar) self.ui.action_edit_reset_instrument_config.triggered.connect( self.on_action_edit_reset_instrument_config) self.ui.action_edit_refinements.triggered.connect( self.edit_refinements) self.ui.action_transform_detectors.triggered.connect( self.on_action_transform_detectors_triggered) self.ui.action_open_mask_manager.triggered.connect( self.on_action_open_mask_manager_triggered) self.ui.action_show_live_updates.toggled.connect(self.live_update) self.ui.action_show_detector_borders.toggled.connect( HexrdConfig().set_show_detector_borders) self.ui.action_view_indexing_config.triggered.connect( self.view_indexing_config) self.ui.action_view_fit_grains_config.triggered.connect( self.view_fit_grains_config) self.ui.calibration_tab_widget.currentChanged.connect( self.update_config_gui) self.image_mode_widget.tab_changed.connect(self.change_image_mode) self.image_mode_widget.mask_applied.connect(self.update_all) self.ui.action_run_powder_calibration.triggered.connect( self.start_powder_calibration) self.ui.action_run_calibration.triggered.connect( self.on_action_run_calibration_triggered) self.ui.action_run_calibration.triggered.connect( self.ui.image_tab_widget.toggle_off_toolbar) self.ui.action_run_indexing.triggered.connect( self.on_action_run_indexing_triggered) self.ui.action_run_fit_grains.triggered.connect( self.on_action_run_fit_grains_triggered) self.ui.action_run_wppf.triggered.connect(self.run_wppf) self.new_images_loaded.connect(self.images_loaded) self.ui.image_tab_widget.update_needed.connect(self.update_all) self.ui.image_tab_widget.new_mouse_position.connect( self.new_mouse_position) self.ui.image_tab_widget.clear_mouse_position.connect( self.ui.status_bar.clearMessage) self.import_data_widget.new_config_loaded.connect( self.update_config_gui) self.import_data_widget.cancel_workflow.connect(self.load_dummy_images) self.config_loaded.connect( self.import_data_widget.config_loaded_from_menu) self.ui.action_show_toolbar.toggled.connect( self.ui.image_tab_widget.toggle_off_toolbar) self.image_mode_widget.polar_show_snip1d.connect( self.ui.image_tab_widget.polar_show_snip1d) self.ui.action_open_images.triggered.connect(self.open_image_files) self.ui.action_open_aps_imageseries.triggered.connect( self.open_aps_imageseries) HexrdConfig().update_status_bar.connect(self.ui.status_bar.showMessage) HexrdConfig().detectors_changed.connect(self.on_detectors_changed) HexrdConfig().deep_rerender_needed.connect(self.deep_rerender) HexrdConfig().workflow_changed.connect(self.add_workflow_widgets) HexrdConfig().raw_masks_changed.connect( self.ui.image_tab_widget.load_images) ImageLoadManager().update_needed.connect(self.update_all) ImageLoadManager().new_images_loaded.connect(self.new_images_loaded) ImageLoadManager().images_transformed.connect(self.update_config_gui) ImageLoadManager().live_update_status.connect(self.live_update) ImageLoadManager().state_updated.connect(self.load_widget.setup_gui) self.ui.action_switch_workflow.triggered.connect( self.on_action_switch_workflow_triggered) self.new_mask_added.connect(self.mask_manager_dialog.update_masks_list) self.image_mode_widget.tab_changed.connect( self.mask_manager_dialog.image_mode_changed) HexrdConfig().calibration_complete.connect(self.calibration_finished) self.ui.action_apply_pixel_solid_angle_correction.toggled.connect( HexrdConfig().set_apply_pixel_solid_angle_correction) self.ui.action_apply_lorentz_polarization_correction.toggled.connect( self.apply_lorentz_polarization_correction_toggled) self.import_data_widget.enforce_raw_mode.connect( self.enforce_view_mode)
def setup_connections(self): """This is to setup connections for non-gui objects""" self.ui.installEventFilter(self) self.ui.action_open_config_yaml.triggered.connect( self.on_action_open_config_yaml_triggered) self.ui.action_open_config_dir.triggered.connect( self.on_action_open_config_dir_triggered) self.ui.action_save_config_yaml.triggered.connect( self.on_action_save_config_yaml_triggered) self.ui.action_save_config_dir.triggered.connect( self.on_action_save_config_dir_triggered) self.ui.action_open_materials.triggered.connect( self.on_action_open_materials_triggered) self.ui.action_save_imageseries.triggered.connect( self.on_action_save_imageseries_triggered) self.ui.action_save_materials.triggered.connect( self.on_action_save_materials_triggered) self.ui.action_export_polar_plot.triggered.connect( self.on_action_export_polar_plot_triggered) self.ui.action_edit_euler_angle_convention.triggered.connect( self.on_action_edit_euler_angle_convention) self.ui.action_edit_apply_polar_mask.triggered.connect( self.on_action_edit_apply_polar_mask_triggered) self.ui.action_edit_apply_laue_mask_to_polar.triggered.connect( self.on_action_edit_apply_laue_mask_to_polar_triggered) self.ui.action_edit_reset_instrument_config.triggered.connect( self.on_action_edit_reset_instrument_config) self.ui.action_transform_detectors.triggered.connect( self.on_action_transform_detectors_triggered) self.ui.action_open_mask_manager.triggered.connect( self.on_action_open_mask_manager_triggered) self.ui.action_show_live_updates.toggled.connect(self.live_update) self.ui.action_show_detector_borders.toggled.connect( HexrdConfig().set_show_detector_borders) self.ui.calibration_tab_widget.currentChanged.connect( self.update_config_gui) self.image_mode_widget.tab_changed.connect(self.change_image_mode) self.image_mode_widget.mask_applied.connect(self.update_all) self.ui.action_run_powder_calibration.triggered.connect( self.start_powder_calibration) self.ui.action_calibration_line_picker.triggered.connect( self.on_action_calibration_line_picker_triggered) self.ui.action_run_indexing.triggered.connect( self.on_action_run_indexing_triggered) self.new_images_loaded.connect(self.update_color_map_bounds) self.new_images_loaded.connect(self.update_indexing_menu) self.new_images_loaded.connect(self.color_map_editor.reset_range) self.new_images_loaded.connect(self.image_mode_widget.reset_masking) self.ui.image_tab_widget.update_needed.connect(self.update_all) self.ui.image_tab_widget.new_mouse_position.connect( self.new_mouse_position) self.ui.image_tab_widget.clear_mouse_position.connect( self.ui.status_bar.clearMessage) self.calibration_slider_widget.update_if_mode_matches.connect( self.update_if_mode_matches) self.load_widget.images_loaded.connect(self.images_loaded) self.import_data_widget.new_config_loaded.connect( self.update_config_gui) self.image_mode_widget.polar_show_snip1d.connect( self.ui.image_tab_widget.polar_show_snip1d) self.ui.action_open_images.triggered.connect(self.open_image_files) self.ui.action_open_aps_imageseries.triggered.connect( self.open_aps_imageseries) HexrdConfig().update_status_bar.connect(self.ui.status_bar.showMessage) HexrdConfig().detectors_changed.connect(self.on_detectors_changed) HexrdConfig().deep_rerender_needed.connect(self.deep_rerender) HexrdConfig().workflow_changed.connect(self.add_workflow_widgets) ImageLoadManager().update_needed.connect(self.update_all) ImageLoadManager().new_images_loaded.connect(self.new_images_loaded) self.ui.action_switch_workflow.triggered.connect( self.on_action_switch_workflow_triggered) self.mask_manager_dialog.update_masks.connect(self.update_all) self.new_mask_added.connect(self.mask_manager_dialog.update_masks_list)
def agg_changed(self): self.state['agg'] = self.ui.aggregation.currentIndex() if self.ui.aggregation.currentIndex() == 0: ImageLoadManager().reset_unagg_imgs()