def on_processed_clicked(self): """ Prepares the batch reduction. 0. Validate rows and create dummy workspace if it does not exist 1. Sets up the states 2. Adds a dummy input workspace 3. Adds row index information """ try: self._view.disable_buttons() self._processing = True self.sans_logger.information("Starting processing of batch table.") # 1. Set up the states and convert them into property managers selected_rows = self._view.get_selected_rows() selected_rows = selected_rows if selected_rows else range( self._table_model.get_number_of_rows()) for row in selected_rows: self._table_model.reset_row_state(row) self.update_view_from_table_model() states, errors = self.get_states(row_index=selected_rows) for row, error in errors.items(): self.on_processing_error(row, error) if not states: self.on_processing_finished(None) return # 4. Create the graph if continuous output is specified if mantidplot: if self._view.plot_results and not mantidplot.graph( self.output_graph): mantidplot.newGraph(self.output_graph) # Check if optimizations should be used use_optimizations = self._view.use_optimizations # Get the output mode output_mode = self._view.output_mode # Check if results should be plotted plot_results = self._view.plot_results # Get the name of the graph to output to output_graph = self.output_graph self.progress = 0 setattr(self._view, 'progress_bar_value', self.progress) setattr(self._view, 'progress_bar_maximum', len(states)) self.batch_process_runner.process_states(states, use_optimizations, output_mode, plot_results, output_graph) except Exception as e: self._view.enable_buttons() self.sans_logger.error("Process halted due to: {}".format(str(e))) self.display_warning_box('Warning', 'Process halted', str(e))
def _create_external_mantidplot_fig_window(self): from mantidplot import newGraph if self.number_of_axes == 1: graph_window = newGraph(layers=1) else: graph_window = self._create_tiled_external_mantidplot_fig_window() return graph_window
def _create_tiled_external_mantidplot_fig_window(self): from mantidplot import newGraph ncols = ceil(sqrt(self.number_of_axes)) nrows = ceil(self.number_of_axes / ncols) graph_window = newGraph() graph_window.setCols(ncols) graph_window.setRows(nrows) graph_window.setLayerCanvasSize(100, 100) graph_window.setNumLayers(self.number_of_axes) return graph_window