Changeset 08dc9e87 in sasview
- Timestamp:
- Oct 19, 2011 2:54:06 PM (13 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- e80e704
- Parents:
- 3b70cc7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/data_processor.py
r1ec979d r08dc9e87 54 54 for label in list: 55 55 label_pos = elt.find(label) 56 if label_pos != -1: 56 separator_pos = label_pos + len(label) 57 if label_pos != -1 and len(elt) >= separator_pos and\ 58 elt[separator_pos]== "[": 59 # the label contain , meaning the range selected is not 60 # continuous 57 61 if elt.count(',') > 0: 58 62 new_temp = [] … … 66 70 temp_arr += new_temp 67 71 else: 72 # continuous range 68 73 temp = elt.split(label) 69 74 for item in temp: 70 range_pos = item.find(":") 71 if range_pos != -1: 72 rang = p2.findall(item) 73 for i in xrange(int(rang[0]), int(rang[1])+1 ): 74 temp_arr.append(i) 75 if item.strip() != "": 76 range_pos = item.find(":") 77 if range_pos != -1: 78 rang = p2.findall(item) 79 for i in xrange(int(rang[0]), int(rang[1])+1 ): 80 temp_arr.append(i) 75 81 col_dict[elt] = (label, temp_arr) 76 82 return col_dict … … 148 154 event.Skip() 149 155 if not flag: 156 self.selected_cols = [] 157 self.selected_rows = [] 150 158 self.selected_cells = [] 159 self.axis_label = "" 151 160 self.axis_value = [] 152 self.axis_label = "" 161 self.plottable_list = [] 162 self.plottable_cells = [] 163 self.plottable_flag = False 164 self.last_selected_col = col 165 self.last_selected_row = row 153 166 if col >= 0: 154 self.axis_label = self.GetCellValue(0, col) 167 label_row = 0 168 self.axis_label = self.GetCellValue(label_row, col) 169 self.selected_cols.append(col) 155 170 if cell not in self.selected_cells: 156 171 if row > 0: 157 172 self.selected_cells.append(cell) 173 self.selected_rows.append(row) 158 174 else: 159 175 if flag: … … 163 179 if cell_row > 0 and cell_row < self.max_row_touse: 164 180 self.axis_value.append(self.GetCellValue(cell_row, cell_col)) 165 166 181 167 182 168 183 def on_left_click(self, event): … … 179 194 self.selected_cells = [] 180 195 self.axis_label = "" 196 self.axis_value = [] 181 197 self.plottable_list = [] 182 198 self.plottable_cells = [] … … 194 210 if cell not in self.selected_cells: 195 211 self.selected_cells.append(cell) 212 else: 213 if flag: 214 self.selected_cells.remove(cell) 196 215 self.selected_cols.append(col) 197 216 self.axis_value = [] … … 506 525 def on_edit_axis(self): 507 526 """ 508 Return the select cell of a given selected column 527 Return the select cell of a given selected column. Check that all cells 528 are from the same column 509 529 """ 510 530 pos = self.GetSelection() 511 531 grid = self.GetPage(pos) 512 if len(grid.selected_cols) > 1: 513 msg = "Edit axis doesn't understand this selection.\n" 514 msg += "Please select only one column" 532 if len(grid.selected_cols) >= 1: 533 col = grid.selected_cols[0] 534 for c in grid.selected_cols: 535 if c != col: 536 msg = "Edit axis doesn't understand this selection.\n" 537 msg += "Please select only one column" 538 raise ValueError, msg 539 for (cell_row, cell_col) in grid.selected_cells: 540 if cell_col != col: 541 msg = "Cannot use cells from different columns for " 542 msg += "this operation.\n" 543 msg += "Please select elements of the same col.\n" 544 raise ValueError, msg 545 else: 546 msg = "No item selected.\n" 547 msg += "Please select only one column or one cell" 515 548 raise ValueError, msg 516 if len(grid.selected_cols) == 1: 517 col = grid.selected_cols[0] 518 if len(grid.selected_cells) > 0: 519 cell_row, cell_col = grid.selected_cells[0] 520 if cell_col != col: 521 msg = "Edit axis doesn't understand this selection.\n" 522 msg += "Please select element of the same col" 523 raise ValueError, msg 549 524 550 return grid.selected_cells 525 551 … … 561 587 else: 562 588 result = str(col_name) + "[" + str(row_min) + ":" 563 result += str( col_name) + str(row_max) + "]"564 return result589 result += str(row_max) + "]" 590 return str(result) 565 591 566 592 if len(cell_list) > 0: … … 583 609 if row != new_row: 584 610 temp_list.insert(index, (None, None)) 585 if index -1 >= 0:611 if index -1 >= 0: 586 612 new_row, _ = temp_list[index-1] 587 613 label += create_label(col_name, None, new_row +1) … … 827 853 if grid is not None: 828 854 column_names = self.notebook.get_column_labels() 829 #evalu e x855 #evaluate x 830 856 sentence = self.x_axis_label.GetValue() 831 857 try: 832 858 if sentence.strip() == "": 833 msg = "Select column values for x axis and y axis"859 msg = "Select column values for x axis" 834 860 raise ValueError, msg 835 861 except: … … 837 863 StatusEvent(status=msg, info="error")) 838 864 return 839 840 865 841 866 dict = parse_string(sentence, column_names.keys()) 842 867 for tok, (col_name, list) in dict.iteritems(): … … 862 887 sentence = sentence.replace(key, value) 863 888 y = eval(sentence) 889 if len(x) != len(y) and (len(x) == 0 or len(y) == 0): 890 msg = "Need same length for X and Y axis and both greater than 0" 891 msg += " to plot.\n" 892 msg += "Got X length = %s, Y length = %s" % (str(len(x)), 893 str(len(y))) 894 wx.PostEvent(self.parent.parent, 895 StatusEvent(status=msg, info="error")) 896 return 897 864 898 #plotting 865 899 new_plot = Data1D(x=x, y=y) … … 959 993 Get the selected column on the visible grid and set values for axis 960 994 """ 961 cell_list = self.notebook.on_edit_axis() 995 try: 996 cell_list = self.notebook.on_edit_axis() 997 except: 998 msg = str(sys.exc_value) 999 wx.PostEvent(self.parent.parent, 1000 StatusEvent(status=msg, info="error")) 1001 return 962 1002 label, title = self.create_axis_label(cell_list) 963 1003 tcrtl = event.GetEventObject()
Note: See TracChangeset
for help on using the changeset viewer.