Changes in / [48e55c9:4d959c8] in sasview
- Location:
- src/sas/qtgui
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/MainWindow/DataExplorer.py
r2b8286c r0cd98a1 98 98 self.communicator.maskEditorSignal.connect(self.showEditDataMask) 99 99 self.communicator.extMaskEditorSignal.connect(self.extShowEditDataMask) 100 self.communicator.changeDataExplorerTabSignal.connect(self.changeTabs)101 100 102 101 self.cbgraph.editTextChanged.connect(self.enableGraphCombo) … … 140 139 else: 141 140 self.current_view = self.freezeView 142 143 def changeTabs(self, tab=0):144 """145 Switch tabs of the data explorer146 0: data tab147 1: theory tab148 """149 assert(tab in [0,1])150 self.setCurrentIndex(tab)151 141 152 142 def displayHelp(self): … … 563 553 return item 564 554 565 def displayFile(self, filename=None, is_data=True , id=None):555 def displayFile(self, filename=None, is_data=True): 566 556 """ 567 557 Forces display of charts for the given filename … … 570 560 # Now query the model item for available plots 571 561 plots = GuiUtils.plotsFromFilename(filename, model) 572 # Each fitpage contains the name based on fit widget number 573 fitpage_name = "" if id is None else "M"+str(id) 562 574 563 new_plots = [] 575 564 for item, plot in plots.items(): 576 if self.updatePlot(plot) and filename != plot.name: 577 continue 578 # Don't plot intermediate results, e.g. P(Q), S(Q) 579 match = GuiUtils.theory_plot_ID_pattern.match(plot.id) 580 # 2nd match group contains the identifier for the intermediate result, if present (e.g. "[P(Q)]") 581 if match and match.groups()[1] != None: 582 continue 583 # Don't include plots from different fitpages, but always include the original data 584 if fitpage_name in plot.name or filename == plot.name: 565 if not self.updatePlot(plot): 566 # Don't plot intermediate results, e.g. P(Q), S(Q) 567 match = GuiUtils.theory_plot_ID_pattern.match(plot.id) 568 # 2nd match group contains the identifier for the intermediate result, if present (e.g. "[P(Q)]") 569 if match and match.groups()[1] != None: 570 continue 585 571 # 'sophisticated' test to generate standalone plot for residuals 586 572 if 'esiduals' in plot.title: … … 593 579 self.plotData(new_plots) 594 580 595 def displayData(self, data_list , id=None):581 def displayData(self, data_list): 596 582 """ 597 583 Forces display of charts for the given data set … … 602 588 # the data explorer indices. 603 589 filename = plot_to_show.filename 604 self.displayFile(filename=filename, is_data=plot_to_show.is_data , id=id)590 self.displayFile(filename=filename, is_data=plot_to_show.is_data) 605 591 606 592 def addDataPlot2D(self, plot_set, item): -
src/sas/qtgui/MainWindow/GuiManager.py
r5b144c6 r339e22b 921 921 self.filesWidget.displayFile(filename=filename, is_data=True) 922 922 923 def showPlot(self, plot , id):923 def showPlot(self, plot): 924 924 """ 925 925 Pass the show plot request to the data explorer 926 926 """ 927 927 if hasattr(self, "filesWidget"): 928 self.filesWidget.displayData(plot , id)928 self.filesWidget.displayData(plot) 929 929 930 930 def uncheckAllMenuItems(self, menuObject): -
src/sas/qtgui/Perspectives/Fitting/FittingLogic.py
r61f0c75 rdcabba7 213 213 plots = [] 214 214 for name, result in return_data['intermediate_results'].items(): 215 if not isinstance(result, np.ndarray):216 continue217 215 plots.append(self._create1DPlot(tab_id, return_data['x'], result, 218 216 return_data['model'], return_data['data'], -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
rbb477f5 rd4ba565 569 569 menu.exec_(self.lstParams.viewport().mapToGlobal(position)) 570 570 except AttributeError as ex: 571 logg er.error("Error generating context menu: %s" % ex)571 logging.error("Error generating context menu: %s" % ex) 572 572 return 573 573 … … 1456 1456 self.communicate.statusBarUpdateSignal.emit(msg) 1457 1457 msg += results.mesg 1458 logg er.error(msg)1458 logging.error(msg) 1459 1459 return 1460 1460 … … 1499 1499 if self.calc_fit._interrupting: 1500 1500 msg = "Fitting cancelled by user after: %s s." % GuiUtils.formatNumber(elapsed) 1501 logg er.warning("\n"+msg+"\n")1501 logging.warning("\n"+msg+"\n") 1502 1502 else: 1503 1503 msg = "Fitting completed successfully in: %s s." % GuiUtils.formatNumber(elapsed) … … 1841 1841 data_to_show = self.data if self.data_is_loaded else self.model_data 1842 1842 if data_to_show is not None: 1843 self.communicate.plotRequestedSignal.emit([data_to_show] , self.tab_id)1843 self.communicate.plotRequestedSignal.emit([data_to_show]) 1844 1844 1845 1845 def onOptionsUpdate(self): … … 2052 2052 kernel_module = generate.load_kernel_module(name) 2053 2053 except ModuleNotFoundError as ex: 2054 logg er.error("Can't find the model "+ str(ex))2054 logging.error("Can't find the model "+ str(ex)) 2055 2055 return 2056 2056 … … 2287 2287 fitted_data.symbol = "Line" 2288 2288 self.createTheoryIndex(fitted_data) 2289 # Switch to the theory tab for user's glee2290 self.communicate.changeDataExplorerTabSignal.emit(1)2291 2289 2292 2290 def updateModelIndex(self, fitted_data): … … 2424 2422 2425 2423 if self.data_is_loaded: 2426 # delete any plots associated with the data that were not updated (e.g. to remove beta(Q), S_eff(Q))2427 2424 GuiUtils.deleteRedundantPlots(self.all_data[self.data_index], new_plots) 2428 pass2429 2425 else: 2430 2426 # delete theory items for the model, in order to get rid of any redundant items, e.g. beta(Q), S_eff(Q) … … 2515 2511 """ 2516 2512 # TODO: remimplement thread cancellation 2517 logg er.error("".join(traceback.format_exception(etype, value, tb)))2513 logging.error("".join(traceback.format_exception(etype, value, tb))) 2518 2514 2519 2515 def setTableProperties(self, table): … … 2697 2693 2698 2694 if not datafile: 2699 logg er.info("No weight data chosen.")2695 logging.info("No weight data chosen.") 2700 2696 raise IOError 2701 2697 … … 2813 2809 self._n_shells_row = shell_row - 1 2814 2810 2815 # Get the default number of shells for the model 2816 kernel_pars = self.kernel_module._model_info.parameters.kernel_parameters 2817 shell_par = None 2818 for par in kernel_pars: 2819 if par.name == param_name: 2820 shell_par = par 2821 break 2822 if not shell_par: 2823 logger.error("Could not find %s in kernel parameters.", param_name) 2824 default_shell_count = shell_par.default 2825 2826 # Add default number of shells to the model 2827 func.setCurrentIndex(default_shell_count) 2811 # Set the index to the state-kept value 2812 func.setCurrentIndex(self.current_shell_displayed 2813 if self.current_shell_displayed < func.count() else 0) 2828 2814 2829 2815 def modifyShellsInList(self, index): … … 3139 3125 param_value = str(self._model_model.item(row, 1).text()) 3140 3126 param_error = None 3141 param_min = None3142 param_max = None3143 3127 column_offset = 0 3144 3128 if self.has_error_column: 3145 3129 param_error = str(self._model_model.item(row, 2).text()) 3146 3130 column_offset = 1 3147 3148 try: 3149 param_min = str(self._model_model.item(row, 2+column_offset).text()) 3150 param_max = str(self._model_model.item(row, 3+column_offset).text()) 3151 except: 3152 pass 3153 3131 param_min = str(self._model_model.item(row, 2+column_offset).text()) 3132 param_max = str(self._model_model.item(row, 3+column_offset).text()) 3154 3133 param_list.append([param_name, param_checked, param_value, param_error, param_min, param_max]) 3155 3134 … … 3241 3220 3242 3221 # limits 3243 try: 3244 limit_lo = item[3] 3245 context[name].append(limit_lo) 3246 limit_hi = item[4] 3247 context[name].append(limit_hi) 3248 except: 3249 pass 3222 limit_lo = item[3] 3223 context[name].append(limit_lo) 3224 limit_hi = item[4] 3225 context[name].append(limit_hi) 3250 3226 3251 3227 # Polydisp … … 3306 3282 ioffset = 1 3307 3283 # min/max 3308 try: 3309 param_repr = GuiUtils.formatNumber(param_dict[param_name][2+ioffset], high=True) 3310 self._model_model.item(row, 2+ioffset).setText(param_repr) 3311 param_repr = GuiUtils.formatNumber(param_dict[param_name][3+ioffset], high=True) 3312 self._model_model.item(row, 3+ioffset).setText(param_repr) 3313 except: 3314 pass 3315 3284 param_repr = GuiUtils.formatNumber(param_dict[param_name][2+ioffset], high=True) 3285 self._model_model.item(row, 2+ioffset).setText(param_repr) 3286 param_repr = GuiUtils.formatNumber(param_dict[param_name][3+ioffset], high=True) 3287 self._model_model.item(row, 3+ioffset).setText(param_repr) 3316 3288 self.setFocus() 3317 3318 3289 3319 3290 -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
rf712bf30 r3fbd77b 613 613 614 614 # Check that the number of rows increased 615 # (note that n == 1 by default in core_multi_shell so this increases index by 2)616 615 more_rows = self.widget._model_model.rowCount() - last_row 617 self.assertEqual(more_rows, 4) # 4new rows: 2 params per index618 619 # Setto 0616 self.assertEqual(more_rows, 6) # 6 new rows: 2 params per index 617 618 # Back to 0 620 619 self.widget.lstParams.indexWidget(func_index).setCurrentIndex(0) 621 self.assertEqual(self.widget._model_model.rowCount(), last_row - 2) # 2 fewer rows than default620 self.assertEqual(self.widget._model_model.rowCount(), last_row) 622 621 623 622 def testPlotTheory(self): -
src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
r4d959c8 r4d959c8 562 562 title = self.prPlot.name 563 563 GuiUtils.updateModelItemWithPlot(self._data, self.prPlot, title) 564 self.communicate.plotRequestedSignal.emit([self.prPlot] , None)564 self.communicate.plotRequestedSignal.emit([self.prPlot]) 565 565 if self.dataPlot is not None: 566 566 title = self.dataPlot.name 567 567 GuiUtils.updateModelItemWithPlot(self._data, self.dataPlot, title) 568 self.communicate.plotRequestedSignal.emit([self.dataPlot] , None)568 self.communicate.plotRequestedSignal.emit([self.dataPlot]) 569 569 self.enableButtons() 570 570 -
src/sas/qtgui/Plotting/Plotter.py
r5b144c6 r0cd98a1 561 561 562 562 #Remove another Fit, if exists 563 self.removePlot(" Fit")563 self.removePlot("fit") 564 564 565 565 self.fit_result.reset_view() -
src/sas/qtgui/Plotting/UnitTesting/PlotterTest.py
r5b144c6 rb8080e1 57 57 self.plotter.data = self.data 58 58 self.plotter.show() 59 FigureCanvas.draw = MagicMock()59 FigureCanvas.draw_idle = MagicMock() 60 60 61 61 self.plotter.plot(hide_error=False) 62 62 63 63 self.assertEqual(self.plotter.ax.get_xscale(), 'log') 64 self.assertTrue(FigureCanvas.draw .called)64 self.assertTrue(FigureCanvas.draw_idle.called) 65 65 66 66 self.plotter.figure.clf() … … 70 70 self.plotter.data = self.data 71 71 self.plotter.show() 72 FigureCanvas.draw = MagicMock()72 FigureCanvas.draw_idle = MagicMock() 73 73 74 74 self.plotter.plot(hide_error=True) 75 75 76 76 self.assertEqual(self.plotter.ax.get_yscale(), 'log') 77 self.assertTrue(FigureCanvas.draw .called)77 self.assertTrue(FigureCanvas.draw_idle.called) 78 78 self.plotter.figure.clf() 79 79 … … 91 91 self.plotter.data = data 92 92 self.plotter.show() 93 FigureCanvas.draw = MagicMock()93 FigureCanvas.draw_idle = MagicMock() 94 94 95 95 self.plotter.plot(hide_error=True) … … 97 97 self.assertEqual(self.plotter.ax.get_xscale(), 'linear') 98 98 self.assertEqual(self.plotter.ax.get_yscale(), 'linear') 99 self.assertTrue(FigureCanvas.draw .called)99 self.assertTrue(FigureCanvas.draw_idle.called) 100 100 101 101 def testCreateContextMenuQuick(self): … … 262 262 # Just this one plot 263 263 self.assertEqual(len(list(self.plotter.plot_dict.keys())), 1) 264 self.plotter.onLinearFit( 'Test name')264 self.plotter.onLinearFit(1) 265 265 266 266 # Check that exec_ got called … … 289 289 290 290 # Delete one set 291 self.plotter.onRemovePlot( 'Test name 2')291 self.plotter.onRemovePlot(2) 292 292 # Assure we have two sets 293 293 self.assertEqual(len(list(self.plotter.plot_dict.keys())), 1) … … 296 296 297 297 # Delete the remaining set 298 self.plotter.onRemovePlot( 'Test name')298 self.plotter.onRemovePlot(1) 299 299 # Assure we have no plots 300 300 self.assertEqual(len(list(self.plotter.plot_dict.keys())), 0) … … 331 331 self.assertEqual(yl, "$YAXIS(cake)$") 332 332 # The hide_error flag should also remain 333 self.assertTrue(self.plotter.plot_dict[ 'Test name 2'].hide_error)333 self.assertTrue(self.plotter.plot_dict[2].hide_error) 334 334 self.plotter.figure.clf() 335 335 … … 355 355 356 356 # Reverse the toggle 357 self.plotter.onToggleHideError( 'Test name 2')357 self.plotter.onToggleHideError(2) 358 358 # See that the labels didn't change 359 359 xl = self.plotter.ax.xaxis.label.get_text() … … 362 362 self.assertEqual(yl, "$YAXIS(cake)$") 363 363 # The hide_error flag should toggle 364 self.assertEqual(self.plotter.plot_dict[ 'Test name 2'].hide_error, not error_status)364 self.assertEqual(self.plotter.plot_dict[2].hide_error, not error_status) 365 365 self.plotter.figure.clf() 366 366 … … 417 417 self.assertEqual(yl, "$YAXIS(cake)$") 418 418 # The hide_error flag should be as set 419 self.assertEqual(self.plotter.plot_dict[ 'Test name 2'].hide_error, error_status)419 self.assertEqual(self.plotter.plot_dict[2].hide_error, error_status) 420 420 self.plotter.figure.clf() 421 421 -
src/sas/qtgui/Utilities/GuiUtils.py
r5d28d6b r339e22b 225 225 # New plot requested from the GUI manager 226 226 # Old "NewPlotEvent" 227 plotRequestedSignal = QtCore.pyqtSignal(list , int)227 plotRequestedSignal = QtCore.pyqtSignal(list) 228 228 229 229 # Plot from file names … … 277 277 # Notify about new categories/models from category manager 278 278 updateModelCategoriesSignal = QtCore.pyqtSignal() 279 280 # Tell the data explorer to switch tabs281 changeDataExplorerTabSignal = QtCore.pyqtSignal(int)282 279 283 280 def updateModelItemWithPlot(item, update_data, name=""): … … 291 288 for index in range(item.rowCount()): 292 289 plot_item = item.child(index) 293 if not plot_item.isCheckable(): 294 continue 295 plot_data = plot_item.child(0).data() 296 if plot_data.id is not None and \ 297 plot_data.name == update_data.name: 298 #(plot_data.name == update_data.name or plot_data.id == update_data.id): 290 if plot_item.isCheckable(): 291 plot_data = plot_item.child(0).data() 292 if plot_data.id is not None and \ 293 (plot_data.name == update_data.name or plot_data.id == update_data.id): 299 294 # if plot_data.id is not None and plot_data.id == update_data.id: 300 # replace data section in item301 plot_item.child(0).setData(update_data)302 plot_item.setText(name)303 # Plot title if any304 if plot_item.child(1).hasChildren():305 plot_item.child(1).child(0).setText("Title: %s"%name)306 # Force redisplay307 return295 # replace data section in item 296 plot_item.child(0).setData(update_data) 297 plot_item.setText(name) 298 # Plot title if any 299 if plot_item.child(1).hasChildren(): 300 plot_item.child(1).child(0).setText("Title: %s"%name) 301 # Force redisplay 302 return 308 303 309 304 # Create the new item
Note: See TracChangeset
for help on using the changeset viewer.