def redraw(self):
     """Send out a command to re-do the trial addition."""
     #Create a PositionCoverage with empty qspace - means it needs to be recalculated.
     try_position = model.instrument.PositionCoverage(self.angles, None, model.experiment.exp.crystal.get_u_matrix())
     
     #Get the old try_position
     old = display_thread.get_try_position()
     if not old is None:
         if not old.try_position is None:
             #Do we have the same angles and sample orientation matrix?
             if (self.angles == old.try_position.angles) and \
                 np.allclose(model.experiment.exp.crystal.get_u_matrix(), old.try_position.sample_U_matrix):
                     #Re-use the qspace array, if it is in there.
                     try_position = model.instrument.PositionCoverage(self.angles, old.try_position.coverage, old.try_position.sample_U_matrix)
             
     #This is the try parameter
     attempt = model.experiment.ParamTryPosition(try_position, self.add_position)
     display_thread.NextParams[model.experiment.PARAM_TRY_POSITION] = attempt
 def add_to_list(self):
     """Adds the last selected angle set to the main list of positions."""
     #Get the old try_position
     old = display_thread.get_try_position()
     if not old is None:
         if not old.try_position is None:
             #Do we have the same angles?
             if (self.angles == old.try_position.angles):
                 #Was it calculated?
                 if not old.try_position.coverage is None:
                     #Great! Add it to the main list.
                     #Make a copy
                     poscov = copy.copy(old.try_position)
                     model.instrument.inst.positions.append(poscov)
                     #Auto-select (check) that position we just added.
                     display_thread.select_position_coverage(poscov)
                     #Send out a message (for the GUI) saying that the list should be updated (to reflect the selection and the new item)
                     model.messages.send_message(model.messages.MSG_POSITION_LIST_CHANGED)
                     #and we're done
                     return
                 
     #If we reach here, something was missing
     wx.MessageDialog(None, "Sorry! There was a problem adding this sample orientation to the main list. Make sure it has been calculated and is shown in the coverage view before clicking this button.", 'Error', wx.OK | wx.ICON_ERROR).ShowModal()