def select_all(self, value): """Select or deselect all items in the list.""" if not self.inside_set_checkUseAll: display_thread.select_additional_position_coverage( model.instrument.inst.positions, update_gui=True, select_items=value)
def add_to_list(self): """Adds the calculated angle set to the main list of positions.""" #Angles in radians, as a list angles = np.deg2rad(self.angles_deg.flatten()).tolist() #Do the calculation poscov = model.instrument.inst.simulate_position(angles, sample_U_matrix=model.experiment.exp.crystal.get_u_matrix(), use_multiprocessing=False) #Make sure the position list is updated in GUI model.messages.send_message(model.messages.MSG_POSITION_LIST_CHANGED) #Add it to the list of selected items display_thread.select_additional_position_coverage(poscov, update_gui=True)
def select_several(self, row_list, value): """Select or deselect several items in the list. Parameter: row_list: list of row numbers to delete. """ poscov_list = [model.instrument.inst.positions[x] for x in row_list if (x>=0) and (x<len(model.instrument.inst.positions))] display_thread.select_additional_position_coverage(poscov_list, update_gui=True, select_items=value) #Make sure the GUI updates self.update_selection()
def select_several(self, row_list, value): """Select or deselect several items in the list. Parameter: row_list: list of row numbers to delete. """ poscov_list = [ model.instrument.inst.positions[x] for x in row_list if (x >= 0) and (x < len(model.instrument.inst.positions)) ] display_thread.select_additional_position_coverage(poscov_list, update_gui=True, select_items=value) #Make sure the GUI updates self.update_selection()
def cell_double_click(self, event): """Called when a cell is double-clicked by the user.""" # @type event wx.grid.GridEvent #Find the positionCoverage object row = event.GetRow() poscov = model.instrument.inst.get_position_num(row) if poscov is None: return #Can't do anything is something is screwy here #Where did we click? col = event.GetCol() if col == 0: #Find what it is now was_selected = display_thread.is_position_selected(poscov) #Toggle the selection state display_thread.select_additional_position_coverage(poscov, update_gui=True, select_items=(not was_selected))
def cell_double_click(self, event): """Called when a cell is double-clicked by the user.""" # @type event wx.grid.GridEvent #Find the positionCoverage object row = event.GetRow() poscov = model.instrument.inst.get_position_num(row) if poscov is None: return #Can't do anything is something is screwy here #Where did we click? col = event.GetCol() if col == 0: #Find what it is now was_selected = display_thread.is_position_selected(poscov) #Toggle the selection state display_thread.select_additional_position_coverage( poscov, update_gui=True, select_items=(not was_selected))
def cell_changed(self, event): """Called when a cell is changed by the user.""" # @type event wx.grid.GridEvent #Find the positionCoverage object row = event.GetRow() poscov = model.instrument.inst.get_position_num(row) if poscov is None: return #Can't do anything is something is screwy here #What string was typed in? col = event.GetCol() cell_str = self.panel.gridExp.GetCellValue(row, col) if col == 0: #Clicked use/don't use value = (cell_str == "X") # print "changed use box to ", cell_str, value #Select or de-select these display_thread.select_additional_position_coverage( poscov, update_gui=False, select_items=value) elif col == self.criterion_col: #Changed criterion poscov.criterion = model.experiment.get_stopping_criterion_from_friendly_name( cell_str) #Need to update the time estimate self.update_estimated_time() elif col == self.criterion_col + 1: #Criterion value try: poscov.criterion_value = float(cell_str) except ValueError: #Invalid input to the string, revert display to show the original value self.panel.gridExp.SetCellValue(row, col, str(poscov.criterion_value)) #Need to update the time estimate self.update_estimated_time() elif col == self.criterion_col + 2: #Comment poscov.comment = cell_str else: raise NotImplementedError( "You should not be able to edit this cell, as it is read-only!" )
def cell_changed(self, event): """Called when a cell is changed by the user.""" # @type event wx.grid.GridEvent #Find the positionCoverage object row = event.GetRow() poscov = model.instrument.inst.get_position_num(row) if poscov is None: return #Can't do anything is something is screwy here #What string was typed in? col = event.GetCol() cell_str = self.panel.gridExp.GetCellValue(row, col) if col == 0: #Clicked use/don't use value = (cell_str == "X") # print "changed use box to ", cell_str, value #Select or de-select these display_thread.select_additional_position_coverage(poscov, update_gui=False, select_items=value) elif col == self.criterion_col: #Changed criterion poscov.criterion = model.experiment.get_stopping_criterion_from_friendly_name(cell_str) #Need to update the time estimate self.update_estimated_time() elif col == self.criterion_col+1: #Criterion value try: poscov.criterion_value = float(cell_str) except ValueError: #Invalid input to the string, revert display to show the original value self.panel.gridExp.SetCellValue(row, col, str(poscov.criterion_value)) #Need to update the time estimate self.update_estimated_time() elif col == self.criterion_col+2: #Comment poscov.comment = cell_str else: raise NotImplementedError("You should not be able to edit this cell, as it is read-only!")
def select_all(self, value): """Select or deselect all items in the list.""" if not self.inside_set_checkUseAll: display_thread.select_additional_position_coverage(model.instrument.inst.positions, update_gui=True, select_items=value)