From 5411876d2a041ac83f649c0931cd5476dc8d2f3c Mon Sep 17 00:00:00 2001 From: JeanBilheux Date: Tue, 16 Apr 2019 08:58:27 -0400 Subject: [PATCH] Checking chemical formula. this refs #134 --- .../master_table/column_highlighting.py | 23 ++++++++++++++++++- .../mantid/master_table/tree_definition.py | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/addie/processing/mantid/master_table/column_highlighting.py b/addie/processing/mantid/master_table/column_highlighting.py index 4ba8c0ed..496375dc 100644 --- a/addie/processing/mantid/master_table/column_highlighting.py +++ b/addie/processing/mantid/master_table/column_highlighting.py @@ -2,6 +2,8 @@ from qtpy import QtGui from qtpy.QtWidgets import QTableWidgetItem +from addie.processing.mantid.master_table.utilities import Utilities + from addie.processing.mantid.master_table.tree_definition import (INDEX_OF_COLUMNS_SEARCHABLE, INDEX_OF_COLUMNS_WITH_CHEMICAL_FORMULA, INDEX_OF_COLUMNS_WITH_MASS_DENSITY, @@ -13,15 +15,23 @@ LIST_COLUMNS_TO_SEARCH_FOR_FULL_HIGHLIGTHING) from addie.processing.mantid.master_table.tree_definition import (COLUMNS_IDENTICAL_VALUES_COLOR, COLUMNS_SAME_VALUES_COLOR) +from addie.processing.mantid.master_table.tree_definition import INDEX_NORMALIZATION_START class ColumnHighlighting: + data_type = 'sample' + def __init__(self, main_window=None, column=-1): self.main_window = main_window self.column = column self.nbr_row = self.get_nbr_row() + self.set_data_type() + + def set_data_type(self): + if self.column >= INDEX_NORMALIZATION_START: + self.data_type = 'normalization' def get_nbr_row(self): nbr_row = self.main_window.processing_ui.h3_table.rowCount() @@ -96,7 +106,6 @@ def apply_cell_background(self, are_all_the_same=False): self.main_window.processing_ui.h3_table.item(_row, self.column).setBackground(background_color) def are_cells_identical(self): - def _get_item_value(row=-1, column=-1): return str(self.main_window.processing_ui.h3_table.item(row, column).text()) @@ -108,6 +117,18 @@ def _get_item_value(row=-1, column=-1): return True def are_chemical_formula_identical(self): + def _get_widget_value(row=-1): + o_utilities = Utilities(parent=self.main_window) + key_row = o_utilities.get_row_key_from_row_index(row=row) + master_table_list_ui = self.main_window.master_table_list_ui[key_row] + widget_ui = master_table_list_ui[self.data_type]['material']['text'] + return str(widget_ui.text()) + + ref_value = _get_widget_value(row=0) + for _row in np.arange(1, self.nbr_row): + _value = _get_widget_value(row=_row) + if _value != ref_value: + return False return True def are_mass_density_identical(self): diff --git a/addie/processing/mantid/master_table/tree_definition.py b/addie/processing/mantid/master_table/tree_definition.py index 11e35444..baace75e 100644 --- a/addie/processing/mantid/master_table/tree_definition.py +++ b/addie/processing/mantid/master_table/tree_definition.py @@ -86,6 +86,8 @@ INDEX_OF_INELASTIC_CORRECTION[1], ] +INDEX_SAMPLE_START = 1 +INDEX_NORMALIZATION_START = 13 INDEX_OF_COLUMNS_WITH_CHECKBOX = [0] INDEX_OF_COLUMNS_WITH_CHEMICAL_FORMULA = [5, 16] INDEX_OF_COLUMNS_WITH_GEOMETRY_INFOS = [9, 20]