From 58ad8b69f92f2a11e15dcf361336d6d9a6aee062 Mon Sep 17 00:00:00 2001 From: Yuanpeng Zhang Date: Thu, 15 Dec 2022 16:04:20 -0500 Subject: [PATCH] multiple s(Q) processing and bug fixing --- addie/calculate_gr/event_handler.py | 32 +++++++++++++++++------------ addie/calculate_gr/gofrtree.py | 9 ++++++-- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/addie/calculate_gr/event_handler.py b/addie/calculate_gr/event_handler.py index cd83f99d..4b314180 100644 --- a/addie/calculate_gr/event_handler.py +++ b/addie/calculate_gr/event_handler.py @@ -150,20 +150,26 @@ def generate_gr_step1(main_window): :return: """ # get S(Q) workspace - comboBox_SofQ = main_window.calculategr_ui.comboBox_SofQ - selected_sq = str(comboBox_SofQ.currentText()) - if selected_sq == 'All': - sq_ws_name_list = list() - for index in range(comboBox_SofQ.count()): - item = str(comboBox_SofQ.itemText(index)) - if item != 'All': - # add S(Q) name unless it is 'All' - sq_ws_name_list.append(item) - # END-IF - # END-FOR + gr_list = main_window.calculategr_ui.treeWidget_grWsList + sq_name_list = gr_list.get_selected_items_of_level( + 2, excluded_parent='GofR', return_item_text=True) + if len(sq_name_list) == 0: + comboBox_SofQ = main_window.calculategr_ui.comboBox_SofQ + selected_sq = str(comboBox_SofQ.currentText()) + if selected_sq == 'All': + sq_ws_name_list = list() + for index in range(comboBox_SofQ.count()): + item = str(comboBox_SofQ.itemText(index)) + if item != 'All': + # add S(Q) name unless it is 'All' + sq_ws_name_list.append(item) + # END-IF + # END-FOR + else: + # selected S(Q) is a single S(Q) name + sq_ws_name_list = [selected_sq] else: - # selected S(Q) is a single S(Q) name - sq_ws_name_list = [selected_sq] + sq_ws_name_list = sq_name_list # generate G(r) generate_gr_step2(main_window, diff --git a/addie/calculate_gr/gofrtree.py b/addie/calculate_gr/gofrtree.py index a86b4994..75286c83 100644 --- a/addie/calculate_gr/gofrtree.py +++ b/addie/calculate_gr/gofrtree.py @@ -235,8 +235,11 @@ def do_delete_selected_items(self): if curr_level == -1: curr_level = temp_level elif curr_level != temp_level: - raise RuntimeError( - 'Nodes of different levels are selected. It is not supported for deletion.') + err_msg = "Nodes of different levels are selected." + self.parent.ui.statusbar.setStyleSheet("color: red") + self.parent.ui.statusbar.showMessage(err_msg, + self.parent.statusbar_display_time) + return # get item and delete if curr_level == 0: @@ -316,6 +319,8 @@ def _delete_ws_node(self, ws_item, is_gr, check_gr_sq): print('Unable to remove %s from canvas due to %s.' % (leaf_node_name, str(ass_err))) # delete node + item_tmp = self.parent.calculategr_ui.comboBox_SofQ.findText(ws_item.text()) + self.parent.calculategr_ui.comboBox_SofQ.removeItem(item_tmp) self.delete_node(ws_item) def do_plot(self):