Changeset dadf255 in sasview for sansguiframe/src/sans
- Timestamp:
- Sep 15, 2011 1:57:37 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:
- c8537b5a
- Parents:
- 581d1d4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/data_processor.py
r656d65d rdadf255 113 113 self.axis_value = [] 114 114 self.axis_label = "" 115 if cell in self.selected_cells: 116 self.selected_cells.remove(cell) 115 if cell not in self.selected_cells: 116 if row > 0: 117 self.selected_cells.append(cell) 117 118 else: 118 self.selected_cells.append(cell) 119 if row > 1: 120 if (cell) in self.selected_cells: 121 self.axis_value.append(self.GetCellValue(row, col)) 122 self.axis_label = self.GetCellValue(row, col) 119 if flag: 120 self.selected_cells.remove(cell) 121 self.axis_value = [] 122 for cell_row, cell_col in self.selected_cells: 123 if cell_row > 0 and cell_row < self.max_row_touse: 124 self.axis_value.append(self.GetCellValue(cell_row, cell_col)) 125 self.axis_label = self.GetCellValue(0, col) 123 126 event.Skip() 124 127 … … 129 132 flag = event.CmdDown() or event.ControlDown() 130 133 col = event.GetCol() 134 if not flag: 135 self.selected_cols = [] 136 self.selected_cells = [] 137 self.axis_label = "" 138 for row in range(1, self.GetNumberRows()+ 1): 139 cell = (row, col) 140 if row > 0 and row < self.max_row_touse: 141 if cell not in self.selected_cells: 142 self.selected_cells.append(cell) 143 self.selected_cols.append(col) 144 self.axis_value = [] 145 for cell_row, cell_col in self.selected_cells: 146 self.axis_value.append(self.GetCellValue(cell_row, cell_col)) 147 self.axis_label = self.GetCellValue(0, col) 131 148 event.Skip() 149 132 150 133 151 def on_right_click(self, event): … … 176 194 col_name = self.GetCellValue(row, col) 177 195 self.data[col_name] = [] 178 for row in range(1, self.GetNumberRows() ):179 if row < =self.max_row_touse:196 for row in range(1, self.GetNumberRows() + 1): 197 if row < self.max_row_touse: 180 198 value = self.GetCellValue(row, col) 181 199 self.data[col_name].append(value) … … 224 242 """ 225 243 Add data to the grid 244 :param data_inputs: data to use from the context menu of the grid 245 :param data_ouputs: default columns deplayed 226 246 """ 227 247 if data_outputs is None: … … 320 340 msg += "Please select only one column" 321 341 raise ValueError, msg 322 list_of_cells = []323 342 if len(grid.selected_cols) == 1: 324 343 col = grid.selected_cols[0] … … 329 348 msg += "Please select element of the same col" 330 349 raise ValueError, msg 331 for row in range(grid.GetNumberRows()): 332 list_of_cells.append((row + 1 , col)) 333 for item in grid.selected_cells: 334 if item in list_of_cells: 335 list_of_cells.remove(item) 336 elif len(grid.selected_cols) == 0: 337 list_of_cells = [(row + 1, col) for row, col in grid.selected_cells] 338 return list_of_cells 350 return grid.selected_cells 351 339 352 340 353 def get_column_labels(self): … … 363 376 label = "" 364 377 col_name = "" 378 def create_label(col_name, row_min=None, row_max=None): 379 """ 380 """ 381 result = "" 382 if row_min is not None or row_max is not None: 383 if row_min is None: 384 result = str(row_max) + "]" 385 elif row_max is None: 386 result = str(col_name) + "[" + str(row_min) + ":" 387 else: 388 result = str(col_name) + "[" + str(row_min) + ":" 389 result += str(col_name) + str(row_max) + "]" 390 return result 391 365 392 if len(cell_list) > 0: 366 temp_list = copy.deepcopy(cell_list) 367 temp_list.sort() 368 temp = [] 369 for item in temp_list: 370 if item[0] <= 1: 371 temp.append(item) 372 for element in temp: 373 temp_list.remove(element) 374 row_min, col = temp_list[0] 375 row_max = row_min 376 col_name = grid.GetCellValue(0, col) 377 label += str(col_name) + "[" + str(row_min) + ":" 378 for index in xrange(len(temp_list)): 379 prev = index - 1 380 row, _ = temp_list[index] 381 if row > row_max + 1 : 382 if prev > 0: 383 row_max, _ = temp_list[prev] 384 label += str(row_max) + "]" + "," 385 row_min = row 386 label += "[" + str(row_min) + ":" 387 row_max = row 388 if (index == len(temp_list)- 1): 389 label += str(row_max) + "]" 390 return label, col_name 393 if len(cell_list) == 1: 394 row_min, col = cell_list[0] 395 col_name = grid.GetCellValue(0, col) 396 label = create_label(col_name, row_min+1 , row_min+1) 397 return label, col_name 398 else: 399 temp_list = copy.deepcopy(cell_list) 400 temp_list.sort() 401 length = len(temp_list) 402 row_min, col = temp_list[0] 403 row_max, _ = temp_list[length-1] 404 col_name = grid.GetCellValue(0, col) 405 index = 0 406 for row in xrange(row_min, row_max +1): 407 if index > 0 and index < len(temp_list): 408 new_row, _ = temp_list[index] 409 if row != new_row: 410 temp_list.insert(index, (None, None)) 411 if index -1 >=0: 412 new_row, _ = temp_list[index-1] 413 label += create_label(col_name, None, new_row +1) 414 label += "," 415 if index + 1 < len(temp_list): 416 new_row, _ = temp_list[index + 1] 417 label += create_label(col_name, new_row+1, None) 418 if index == 0: 419 label += create_label(col_name, row_min+1, None) 420 elif index == len(temp_list)-1: 421 label += create_label(col_name, None, row_max+1) 422 index += 1 423 return label, col_name 391 424 392 425 def on_close_page(self, event): … … 499 532 axis.append(float(row - 1)) 500 533 else: 501 axis.append(float(value)) 534 try: 535 axis.append(float(value)) 536 except: 537 msg = "Invalid data in row %s column %s" % (str(row), 538 str(col)) 539 wx.PostEvent(self.parent.parent, 540 SatusEvent(status=msg, info="error")) 502 541 else: 503 542 axis.append(None) … … 561 600 try: 562 601 title = self.notebook.GetPageText(pos) 563 data.name = title602 new_plot.name = title 564 603 wx.PostEvent(self.parent.parent, 565 604 NewPlotEvent(plot=new_plot, 566 605 group_id=str(new_plot.group_id), title =title)) 567 606 except: 568 pass 607 wx.PostEvent(self.parent.parent, 608 SatusEvent(status=msg, info="error")) 569 609 570 610 def layout_grid(self):
Note: See TracChangeset
for help on using the changeset viewer.