Skip to content

Commit

Permalink
Checking chemical formula. this refs #134
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBilheux committed Apr 16, 2019
1 parent 6e811f6 commit 5411876
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion addie/processing/mantid/master_table/column_highlighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down Expand Up @@ -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())

Expand All @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions addie/processing/mantid/master_table/tree_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 5411876

Please sign in to comment.