def OnReturningFromEditCrystal(self, old_U): """Call when changing the crystal, either from the button or from loading a UB file. Model.exp.crystal needs to have changed before calling """ #Whenever the crystal changes, you need a new symmetry map. model.experiment.exp.initialize_volume_symmetry_map() #User clicked okay, something (proably) changed new_U = model.experiment.exp.crystal.get_u_matrix() if not np.allclose(old_U, new_U): #The sample mounting U changed, so we need to recalc all the 3D volume coverage gui_utils.do_recalculation_with_progress_bar(new_U) #Send message signaling a redraw of volume plots display_thread.handle_change_of_qspace(changed_sample_U_matrix=new_U) #Now handle the reflections, and warn if the auto-range is huge... (b, n) = self.range_settings.is_too_many() if b: dlg = wx.MessageDialog( self, "The number of reflections given by this range, %s, is very large. Are you sure?\nIf you click no, a default range of -5 to +5 HKL will be used instead, but you can increase the range later." % gui_utils.print_large_number(n), "Too Many Reflections", wx.YES_NO | wx.ICON_INFORMATION) res = dlg.ShowModal() dlg.Destroy() if res != wx.ID_YES: #Disable automatic if its on; put on smaller numbers. self.range_settings.automatic = False self.range_settings.h_range = np.array([-5, 5]).reshape(1, 2) self.range_settings.k_range = np.array([-5, 5]).reshape(1, 2) self.range_settings.l_range = np.array([-5, 5]).reshape(1, 2) #Update the hkl range settings, especially for automatic settings self.apply_crystal_range()
def load_detector_file(self, filename): """Load detectors from a file.""" #Load if it exists if not os.path.exists(filename): wx.MessageDialog(self, "File '%s' was not found!" % filename, 'Error', wx.OK | wx.ICON_ERROR).ShowModal() else: old_detectors = model.instrument.inst.detectors try: model.instrument.inst.load_detectors_file(filename) #Save as the next default model.config.cfg.default_detector_filename = filename #Send a message saying that the detector list has changed model.messages.send_message(model.messages.MSG_DETECTOR_LIST_CHANGED) #Recalculate everything! gui_utils.do_recalculation_with_progress_bar(new_sample_U_matrix=None) #Update displays display_thread.handle_change_of_qspace() if not self.panel.frame3d is None: pass #The 3D view is open, update that by closing and re-opening wx.CallAfter(self.panel.frame3d.Close) # #Open a new one! # wx.CallAfter(self.panel.OnButton_view_detectorsButton, None) # #self.panel.frame3d.update(reset_view=False) except: #Go back to the old list model.instrument.inst.detectors = old_detectors #Re-raise the error raise
def OnReturningFromEditCrystal(self, old_U): """Call when changing the crystal, either from the button or from loading a UB file. Model.exp.crystal needs to have changed before calling """ #Whenever the crystal changes, you need a new symmetry map. model.experiment.exp.initialize_volume_symmetry_map() #User clicked okay, something (proably) changed new_U = model.experiment.exp.crystal.get_u_matrix() if not np.allclose(old_U, new_U): #The sample mounting U changed, so we need to recalc all the 3D volume coverage gui_utils.do_recalculation_with_progress_bar(new_U) #Send message signaling a redraw of volume plots display_thread.handle_change_of_qspace(changed_sample_U_matrix=new_U) #Now handle the reflections, and warn if the auto-range is huge... (b,n) = self.range_settings.is_too_many() if b: dlg = wx.MessageDialog(self, "The number of reflections given by this range, %s, is very large. Are you sure?\nIf you click no, a default range of -5 to +5 HKL will be used instead, but you can increase the range later." % gui_utils.print_large_number(n), "Too Many Reflections", wx.YES_NO | wx.ICON_INFORMATION) res = dlg.ShowModal() dlg.Destroy() if res != wx.ID_YES: #Disable automatic if its on; put on smaller numbers. self.range_settings.automatic = False self.range_settings.h_range = np.array( [-5,5] ).reshape(1,2) self.range_settings.k_range = np.array( [-5,5] ).reshape(1,2) self.range_settings.l_range = np.array( [-5,5] ).reshape(1,2) #Update the hkl range settings, especially for automatic settings self.apply_crystal_range()
def load_detector_file(self, filename): """Load detectors from a file.""" #Load if it exists if not os.path.exists(filename): wx.MessageDialog(self, "File '%s' was not found!" % filename, 'Error', wx.OK | wx.ICON_ERROR).ShowModal() else: old_detectors = model.instrument.inst.detectors try: model.instrument.inst.load_detectors_file(filename) #Save as the next default model.config.cfg.default_detector_filename = filename #Send a message saying that the detector list has changed model.messages.send_message( model.messages.MSG_DETECTOR_LIST_CHANGED) #Recalculate everything! gui_utils.do_recalculation_with_progress_bar( new_sample_U_matrix=None) #Update displays display_thread.handle_change_of_qspace() if not self.panel.frame3d is None: pass #The 3D view is open, update that by closing and re-opening wx.CallAfter(self.panel.frame3d.Close) # #Open a new one! # wx.CallAfter(self.panel.OnButton_view_detectorsButton, None) # #self.panel.frame3d.update(reset_view=False) except: #Go back to the old list model.instrument.inst.detectors = old_detectors #Re-raise the error raise
def apply(self): """Apply changes now.""" #This sets up the new size q-space model.instrument.inst.change_qspace_size(self.get_params_dictionary()) #Whenever the q-space changes, you need a new symmetry map. model.experiment.exp.initialize_volume_symmetry_map() #Always re-initialize the reflections model.experiment.exp.initialize_reflections() #This recalcs the volumes and reflections gui_utils.do_recalculation_with_progress_bar(new_sample_U_matrix=None) #Ensure that the q-space viewer refreshes properly. display_thread.handle_change_of_qspace() #Save the points goal par = self.frame.params #@type par StartupParameters par.points_goal = par.points