Changeset 4d457df in sasview
- Timestamp:
- Mar 17, 2017 10:58:33 AM (8 years ago)
- Branches:
- 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
- Children:
- 7248d75d
- Parents:
- 811bec1
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r811bec1 r4d457df 20 20 from sas.sasgui.guiframe.dataFitting import Data2D 21 21 import sas.qtgui.GuiUtils as GuiUtils 22 from sas.sascalc.dataloader.data_info import Detector23 from sas.sascalc.dataloader.data_info import Source24 22 from sas.sasgui.perspectives.fitting.model_thread import Calc1D 25 23 from sas.sasgui.perspectives.fitting.model_thread import Calc2D 26 24 27 25 from UI.FittingWidgetUI import Ui_FittingWidgetUI 26 from sas.qtgui.Perspectives.Fitting.FittingLogic import FittingLogic 27 from sas.qtgui.Perspectives.Fitting import FittingUtilities 28 28 29 29 TAB_MAGNETISM = 4 30 30 TAB_POLY = 3 31 31 CATEGORY_DEFAULT = "Choose category..." 32 CATEGORY_STRUCTURE = "Structure Factor" 32 33 QMIN_DEFAULT = 0.0005 33 34 QMAX_DEFAULT = 0.5 … … 70 71 71 72 # Main Data[12]D holder 72 self. _data = None73 self.logic = FittingLogic(data=data) 73 74 74 75 # Main GUI setup up … … 111 112 self.cbCategory.addItem(CATEGORY_DEFAULT) 112 113 self.cbCategory.addItems(category_list) 113 self.cbCategory.addItem( "Structure Factor")114 self.cbCategory.addItem(CATEGORY_STRUCTURE) 114 115 self.cbCategory.setCurrentIndex(0) 115 116 … … 126 127 @property 127 128 def data(self): 128 return self. _data129 return self.logic.data 129 130 130 131 @data.setter 131 132 def data(self, value): 132 133 """ data setter """ 134 assert isinstance(value[0], QtGui.QStandardItem) 133 135 # _index contains the QIndex with data 134 136 self._index = value 135 # _data contains the actual Data[12]D 136 self._data = GuiUtils.dataFromItem(value[0]) 137 # Update logics with data items 138 self.logic.data = GuiUtils.dataFromItem(value[0]) 139 137 140 self.data_is_loaded = True 138 141 # Tag along functionality … … 169 172 """ 170 173 if self.data_is_loaded: 171 self.q_range_min, self.q_range_max, self.npts = self. computeDataRange(self.data)174 self.q_range_min, self.q_range_max, self.npts = self.logic.computeDataRange() 172 175 # set Q range labels on the main tab 173 176 self.lblMinRangeDef.setText(str(self.q_range_min)) … … 227 230 Fill in the structure factors combo box with defaults 228 231 """ 229 structure_factor_list = self.master_category_dict.pop( 'Structure Factor')232 structure_factor_list = self.master_category_dict.pop(CATEGORY_STRUCTURE) 230 233 structure_factors = ["None"] 231 234 self.cbStructureFactor.clear() … … 237 240 Select Category from list 238 241 """ 239 category = s elf.cbCategory.currentText()242 category = str(self.cbCategory.currentText()) 240 243 # Check if the user chose "Choose category entry" 241 if str(category)== CATEGORY_DEFAULT:244 if category == CATEGORY_DEFAULT: 242 245 # if the previous category was not the default, keep it. 243 246 # Otherwise, just return … … 246 249 return 247 250 248 if category == "Structure Factor":251 if category == CATEGORY_STRUCTURE: 249 252 self.disableModelCombo() 250 253 self.enableStructureCombo() … … 260 263 self._previous_category_index = self.cbCategory.currentIndex() 261 264 # Retrieve the list of models 262 model_list = self.master_category_dict[ str(category)]265 model_list = self.master_category_dict[category] 263 266 models = [] 264 267 # Populate the models combobox 265 for (model, _) in model_list: 266 models.append(model) 267 self.cbModel.addItems(sorted(models)) 268 self.cbModel.addItems(sorted([model for (model,_) in model_list])) 269 270 def createDefaultDataset(self): 271 """ 272 Generate default Dataset 1D/2D for the given model 273 """ 274 # Create default datasets if no data passed 275 if self.is2D: 276 qmax = self.q_range_max/numpy.sqrt(2) 277 qstep = self.npts 278 self.logic.createDefault2dData(qmax, qstep, self.tab_id) 279 else: 280 interval = numpy.linspace(start=self.q_range_min, stop=self.q_range_max, 281 num=self.npts, endpoint=True) 282 self.logic.createDefault1dData(interval, self.tab_id) 268 283 269 284 def onSelectModel(self): … … 274 289 275 290 # SasModel -> QModel 276 self. setModelModel(model)291 self.SASModelToQModel(model) 277 292 278 293 if self._index is None: 279 294 # Create default datasets if no data passed 280 if self.is2D: 281 self.createDefault2dData() 282 else: 283 self.createDefault1dData() 284 # DESIGN: create the theory now or on Plot event? 285 #self.createTheoryIndex() 295 self.createDefaultDataset() 286 296 else: 287 # Create datasets and errorbars for current data 288 if self.is2D: 289 self.calculate2DForModel() 290 else: 291 self.calculate1DForModel() 292 # TODO: attach the chart to index 297 self.calculateDataForModel() 293 298 294 299 def onSelectStructureFactor(self): … … 298 303 model = str(self.cbModel.currentText()) 299 304 structure = str(self.cbStructureFactor.currentText()) 300 self. setModelModel(model, structure_factor=structure)305 self.SASModelToQModel(model, structure_factor=structure) 301 306 302 307 def readCategoryInfo(self): … … 332 337 self.model_enabled_dict[model] = enabled 333 338 334 def getIterParams(self, model):335 """336 Returns a list of all multi-shell parameters in 'model'337 """338 return list(filter(lambda par: "[" in par.name, model.iq_parameters))339 340 def getMultiplicity(self, model):341 """342 Finds out if 'model' has multishell parameters.343 If so, returns the name of the counter parameter and the number of shells344 """345 iter_params = self.getIterParams(model)346 # return the iterator parameter name and length347 return (iter_params[0].length_control if iter_params else "",348 iter_params[0].length if iter_params else 0)349 350 339 def addBackgroundToModel(self, model): 351 340 """ … … 354 343 assert isinstance(model, QtGui.QStandardItemModel) 355 344 checked_list = ['background', '0.001', '-inf', 'inf', '1/cm'] 356 self.addCheckedListToModel(model, checked_list)345 FittingUtilities.addCheckedListToModel(model, checked_list) 357 346 358 347 def addScaleToModel(self, model): … … 362 351 assert isinstance(model, QtGui.QStandardItemModel) 363 352 checked_list = ['scale', '1.0', '0.0', 'inf', ''] 364 self.addCheckedListToModel(model, checked_list) 365 366 def addCheckedListToModel(self, model, param_list): 367 """ 368 Add a QItem to model. Makes the QItem checkable 369 """ 370 assert isinstance(model, QtGui.QStandardItemModel) 371 item_list = [QtGui.QStandardItem(item) for item in param_list] 372 item_list[0].setCheckable(True) 373 model.appendRow(item_list) 374 375 def addHeadersToModel(self, model): 376 """ 377 Adds predefined headers to the model 378 """ 379 model.setHeaderData(0, QtCore.Qt.Horizontal, QtCore.QVariant("Parameter")) 380 model.setHeaderData(1, QtCore.Qt.Horizontal, QtCore.QVariant("Value")) 381 model.setHeaderData(2, QtCore.Qt.Horizontal, QtCore.QVariant("Min")) 382 model.setHeaderData(3, QtCore.Qt.Horizontal, QtCore.QVariant("Max")) 383 model.setHeaderData(4, QtCore.Qt.Horizontal, QtCore.QVariant("[Units]")) 384 385 def addPolyHeadersToModel(self, model): 386 """ 387 Adds predefined headers to the model 388 """ 389 model.setHeaderData(0, QtCore.Qt.Horizontal, QtCore.QVariant("Parameter")) 390 model.setHeaderData(1, QtCore.Qt.Horizontal, QtCore.QVariant("PD[ratio]")) 391 model.setHeaderData(2, QtCore.Qt.Horizontal, QtCore.QVariant("Min")) 392 model.setHeaderData(3, QtCore.Qt.Horizontal, QtCore.QVariant("Max")) 393 model.setHeaderData(4, QtCore.Qt.Horizontal, QtCore.QVariant("Npts")) 394 model.setHeaderData(5, QtCore.Qt.Horizontal, QtCore.QVariant("Nsigs")) 395 model.setHeaderData(6, QtCore.Qt.Horizontal, QtCore.QVariant("Function")) 396 397 def setModelModel(self, model_name, structure_factor=None): 353 FittingUtilities.addCheckedListToModel(model, checked_list) 354 355 def SASModelToQModel(self, model_name, structure_factor=None): 398 356 """ 399 357 Setting model parameters into table based on selected category … … 413 371 414 372 # Update the QModel 415 self.addParametersToModel(self.model_parameters, self._model_model) 416 self.addHeadersToModel(self._model_model) 373 FittingUtilities.addParametersToModel(self.model_parameters, self._model_model) 374 # Update the counter used for multishell display 375 self._last_model_row = self._model_model.rowCount() 376 377 FittingUtilities.addHeadersToModel(self._model_model) 417 378 418 379 # Add structure factor … … 420 381 structure_module = generate.load_kernel_module(structure_factor) 421 382 structure_parameters = modelinfo.make_parameter_table(getattr(structure_module, 'parameters', [])) 422 self.addSimpleParametersToModel(structure_parameters, self._model_model) 383 FittingUtilities.addSimpleParametersToModel(structure_parameters, self._model_model) 384 # Update the counter used for multishell display 385 self._last_model_row = self._model_model.rowCount() 423 386 else: 424 387 self.addStructureFactor() … … 459 422 # Reload the main model - may not be required if no variable is shown in main view 460 423 #model = str(self.cbModel.currentText()) 461 #self. setModelModel(model)424 #self.SASModelToQModel(model) 462 425 463 426 pass # debug anchor … … 499 462 # multishell params in self.kernel_module.details[??] = value 500 463 501 def computeDataRange(self, data):502 """503 Compute the minimum and the maximum range of the data504 return the npts contains in data505 """506 assert data is not None507 assert (isinstance(data, Data1D) or isinstance(data, Data2D))508 qmin, qmax, npts = None, None, None509 if isinstance(data, Data1D):510 try:511 qmin = min(data.x)512 qmax = max(data.x)513 npts = len(data.x)514 except (ValueError, TypeError):515 msg = "Unable to find min/max/length of \n data named %s" % \516 data.filename517 raise ValueError, msg518 519 else:520 qmin = 0521 try:522 x = max(numpy.fabs(data.xmin), numpy.fabs(data.xmax))523 y = max(numpy.fabs(data.ymin), numpy.fabs(data.ymax))524 except (ValueError, TypeError):525 msg = "Unable to find min/max of \n data named %s" % \526 data.filename527 raise ValueError, msg528 qmax = numpy.sqrt(x * x + y * y)529 npts = len(data.data)530 return qmin, qmax, npts531 532 def addParametersToModel(self, parameters, model):533 """534 Update local ModelModel with sasmodel parameters535 """536 multishell_parameters = self.getIterParams(parameters)537 multishell_param_name, _ = self.getMultiplicity(parameters)538 539 for param in parameters.iq_parameters:540 # don't include shell parameters541 if param.name == multishell_param_name:542 continue543 # Modify parameter name from <param>[n] to <param>1544 item_name = param.name545 if param in multishell_parameters:546 item_name = self.replaceShellName(param.name, 1)547 548 item1 = QtGui.QStandardItem(item_name)549 item1.setCheckable(True)550 # check for polydisp params551 if param.polydisperse:552 poly_item = QtGui.QStandardItem("Polydispersity")553 item1_1 = QtGui.QStandardItem("Distribution")554 # Find param in volume_params555 for p in parameters.form_volume_parameters:556 if p.name != param.name:557 continue558 item1_2 = QtGui.QStandardItem(str(p.default))559 item1_3 = QtGui.QStandardItem(str(p.limits[0]))560 item1_4 = QtGui.QStandardItem(str(p.limits[1]))561 item1_5 = QtGui.QStandardItem(p.units)562 poly_item.appendRow([item1_1, item1_2, item1_3, item1_4, item1_5])563 break564 # Add the polydisp item as a child565 item1.appendRow([poly_item])566 # Param values567 item2 = QtGui.QStandardItem(str(param.default))568 # TODO: the error column.569 # Either add a proxy model or a custom view delegate570 #item_err = QtGui.QStandardItem()571 item3 = QtGui.QStandardItem(str(param.limits[0]))572 item4 = QtGui.QStandardItem(str(param.limits[1]))573 item5 = QtGui.QStandardItem(param.units)574 model.appendRow([item1, item2, item3, item4, item5])575 576 # Update the counter used for multishell display577 self._last_model_row = self._model_model.rowCount()578 579 def addSimpleParametersToModel(self, parameters, model):580 """581 Update local ModelModel with sasmodel parameters582 """583 for param in parameters.iq_parameters:584 # Modify parameter name from <param>[n] to <param>1585 item_name = param.name586 item1 = QtGui.QStandardItem(item_name)587 item1.setCheckable(True)588 # Param values589 item2 = QtGui.QStandardItem(str(param.default))590 # TODO: the error column.591 # Either add a proxy model or a custom view delegate592 #item_err = QtGui.QStandardItem()593 item3 = QtGui.QStandardItem(str(param.limits[0]))594 item4 = QtGui.QStandardItem(str(param.limits[1]))595 item5 = QtGui.QStandardItem(param.units)596 model.appendRow([item1, item2, item3, item4, item5])597 598 # Update the counter used for multishell display599 self._last_model_row = self._model_model.rowCount()600 601 def createDefault1dData(self):602 """603 Create default data for fitting perspective604 Only when the page is on theory mode.605 """606 x = numpy.linspace(start=self.q_range_min, stop=self.q_range_max,607 num=self.npts, endpoint=True)608 self._data = Data1D(x=x)609 self._data.xaxis('\\rm{Q}', "A^{-1}")610 self._data.yaxis('\\rm{Intensity}', "cm^{-1}")611 self._data.is_data = False612 self._data.id = str(self.tab_id) + " data"613 self._data.group_id = str(self.tab_id) + " Model1D"614 615 def createDefault2dData(self):616 """617 Create 2D data by default618 Only when the page is on theory mode.619 """620 self._data = Data2D()621 qmax = self.q_range_max / numpy.sqrt(2)622 self._data.xaxis('\\rm{Q_{x}}', 'A^{-1}')623 self._data.yaxis('\\rm{Q_{y}}', 'A^{-1}')624 self._data.is_data = False625 self._data.id = str(self.tab_id) + " data"626 self._data.group_id = str(self.tab_id) + " Model2D"627 628 # Default detector629 self._data.detector.append(Detector())630 index = len(self._data.detector) - 1631 self._data.detector[index].distance = 8000 # mm632 self._data.source.wavelength = 6 # A633 self._data.detector[index].pixel_size.x = 5 # mm634 self._data.detector[index].pixel_size.y = 5 # mm635 self._data.detector[index].beam_center.x = qmax636 self._data.detector[index].beam_center.y = qmax637 # theory default: assume the beam638 #center is located at the center of sqr detector639 xmax = qmax640 xmin = -qmax641 ymax = qmax642 ymin = -qmax643 qstep = self.npts644 645 x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)646 y = numpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True)647 # Use data info instead648 new_x = numpy.tile(x, (len(y), 1))649 new_y = numpy.tile(y, (len(x), 1))650 new_y = new_y.swapaxes(0, 1)651 652 # all data required in 1d array653 qx_data = new_x.flatten()654 qy_data = new_y.flatten()655 q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data)656 657 # set all True (standing for unmasked) as default658 mask = numpy.ones(len(qx_data), dtype=bool)659 # calculate the range of qx and qy: this way,660 # it is a little more independent661 # store x and y bin centers in q space662 x_bins = x663 y_bins = y664 665 self._data.source = Source()666 self._data.data = numpy.ones(len(mask))667 self._data.err_data = numpy.ones(len(mask))668 self._data.qx_data = qx_data669 self._data.qy_data = qy_data670 self._data.q_data = q_data671 self._data.mask = mask672 self._data.x_bins = x_bins673 self._data.y_bins = y_bins674 # max and min taking account of the bin sizes675 self._data.xmin = xmin676 self._data.xmax = xmax677 self._data.ymin = ymin678 self._data.ymax = ymax679 464 680 465 def createTheoryIndex(self): … … 702 487 """ 703 488 # TODO: reimplement basepage.py/_update_paramv_on_fit 704 if self.data is None or not self. _data.is_data:705 self.createDefault 2dData() if self.is2D else self.createDefault1dData()706 self.calculate 2DForModel() if self.is2D else self.calculate1DForModel()489 if self.data is None or not self.data.is_data: 490 self.createDefaultDataset() 491 self.calculateDataForModel() 707 492 708 493 def onNpts(self, text): … … 740 525 self.lblMaxRangeDef.setText(str(self.q_range_max)) 741 526 742 def calculate1DForModel(self): 527 def methodCalculateForData(self): 528 '''return the method for data calculation''' 529 return Calc1D if isinstance(self.data, Data1D) else Calc2D 530 531 def methodCompleteForData(self): 532 '''return the method for result parsin on calc complete ''' 533 return self.complete1D if isinstance(self.data, Data1D) else self.complete2D 534 535 def calculateDataForModel(self): 743 536 """ 744 537 Prepare the fitting data object, based on current ModelModel 745 538 """ 746 self.calc_1D = Calc1D(data=self.data, 539 # Awful API to a backend method. 540 method = self.methodCalculateForData()(data=self.data, 747 541 model=self.kernel_module, 748 542 page_id=0, … … 754 548 fid=None, 755 549 toggle_mode_on=False, 756 completefn= self.complete1D,550 completefn=None, 757 551 update_chisqr=True, 758 552 exception_handler=self.calcException, 759 553 source=None) 760 # Instead of starting the thread with 761 # self.calc_1D.queue() 762 # let's try running the async request 763 calc_thread = threads.deferToThread(self.calc_1D.compute) 764 calc_thread.addCallback(self.complete1D) 554 555 calc_thread = threads.deferToThread(method.compute) 556 calc_thread.addCallback(self.methodCompleteForData()) 765 557 766 558 def complete1D(self, return_data): 767 559 """ 768 Plot the current data 769 """ 770 # Unpack return data from Calc1D 771 x, y, page_id, state, weight,\ 772 fid, toggle_mode_on, \ 773 elapsed, index, model,\ 774 data, update_chisqr, source = return_data 775 776 # Create the new plot 777 new_plot = Data1D(x=x, y=y) 778 new_plot.is_data = False 779 new_plot.dy = numpy.zeros(len(y)) 780 _yaxis, _yunit = data.get_yaxis() 781 _xaxis, _xunit = data.get_xaxis() 782 new_plot.title = data.name 783 784 new_plot.group_id = data.group_id 785 if new_plot.group_id == None: 786 new_plot.group_id = data.group_id 787 new_plot.id = str(self.tab_id) + " " + data.name 788 new_plot.name = model.name + " [" + data.name + "]" 789 new_plot.xaxis(_xaxis, _xunit) 790 new_plot.yaxis(_yaxis, _yunit) 791 792 # Assign the new Data1D object-wide 793 self._data = new_plot 560 Plot the current 1D data 561 """ 562 self.logic.new1DPlot(return_data) 794 563 self.createTheoryIndex() 795 564 … … 800 569 # index=index) 801 570 802 def calculate2DForModel(self):803 """804 Prepare the fitting data object, based on current ModelModel805 """806 self.calc_2D = Calc2D(data=self.data,807 model=self.kernel_module,808 page_id=0,809 qmin=self.q_range_min,810 qmax=self.q_range_max,811 smearer=None,812 state=None,813 weight=None,814 fid=None,815 toggle_mode_on=False,816 completefn=self.complete2D,817 update_chisqr=True,818 exception_handler=self.calcException,819 source=None)820 821 # Instead of starting the thread with822 # self.calc_2D.queue()823 # let's try running the async request824 calc_thread = threads.deferToThread(self.calc_2D.compute)825 calc_thread.addCallback(self.complete2D)826 827 571 def complete2D(self, return_data): 828 572 """ 829 Plot the current data 830 Should be a rewrite of fitting.py/_complete2D 831 """ 832 image, data, page_id, model, state, toggle_mode_on,\ 833 elapsed, index, fid, qmin, qmax, weight, \ 834 update_chisqr, source = return_data 835 836 numpy.nan_to_num(image) 837 new_plot = Data2D(image=image, err_image=data.err_data) 838 new_plot.name = model.name + '2d' 839 new_plot.title = "Analytical model 2D " 840 new_plot.id = str(page_id) + " " + data.name 841 new_plot.group_id = str(page_id) + " Model2D" 842 new_plot.detector = data.detector 843 new_plot.source = data.source 844 new_plot.is_data = False 845 new_plot.qx_data = data.qx_data 846 new_plot.qy_data = data.qy_data 847 new_plot.q_data = data.q_data 848 new_plot.mask = data.mask 849 ## plot boundaries 850 new_plot.ymin = data.ymin 851 new_plot.ymax = data.ymax 852 new_plot.xmin = data.xmin 853 new_plot.xmax = data.xmax 854 855 title = data.title 856 857 new_plot.is_data = False 858 if data.is_data: 859 data_name = str(data.name) 860 else: 861 data_name = str(model.__class__.__name__) + '2d' 862 863 if len(title) > 1: 864 new_plot.title = "Model2D for %s " % model.name + data_name 865 new_plot.name = model.name + " [" + \ 866 data_name + "]" 867 868 # Assign the new Data2D object-wide 869 self._data = new_plot 573 Plot the current 2D data 574 """ 575 self.logic.new2DPlot(return_data) 870 576 self.createTheoryIndex() 871 577 … … 885 591 msg = traceback.format_exception(etype, value, tb, limit=1) 886 592 887 def replaceShellName(self, param_name, value):888 """889 Updates parameter name from <param_name>[n_shell] to <param_name>value890 """891 assert '[' in param_name892 return param_name[:param_name.index('[')]+str(value)893 894 593 def setTableProperties(self, table): 895 594 """ … … 927 626 str(param.limits[0]), str(param.limits[1]), 928 627 "35", "3", ""] 929 self.addCheckedListToModel(self._poly_model, checked_list)628 FittingUtilities.addCheckedListToModel(self._poly_model, checked_list) 930 629 931 630 #TODO: Need to find cleaner way to input functions … … 935 634 self.lstPoly.setIndexWidget(func_index, func) 936 635 937 self.addPolyHeadersToModel(self._poly_model)636 FittingUtilities.addPolyHeadersToModel(self._poly_model) 938 637 939 638 def setMagneticModel(self): … … 952 651 str(param.limits[1]), 953 652 param.units] 954 self.addCheckedListToModel(self._magnet_model, checked_list)955 956 self.addHeadersToModel(self._magnet_model)653 FittingUtilities.addCheckedListToModel(self._magnet_model, checked_list) 654 655 FittingUtilities.addHeadersToModel(self._magnet_model) 957 656 958 657 def addStructureFactor(self): … … 969 668 Add a combobox for multiple shell display 970 669 """ 971 param_name, param_length = self.getMultiplicity(self.model_parameters)670 param_name, param_length = FittingUtilities.getMultiplicity(self.model_parameters) 972 671 973 672 if param_length == 0: … … 988 687 shell_row = self._model_model.rowCount() 989 688 shell_index = self._model_model.index(shell_row-1, 1) 689 990 690 self.lstParams.setIndexWidget(shell_index, func) 991 992 691 self._last_model_row = self._model_model.rowCount() 993 692 … … 1004 703 self._model_model.removeRows(last_row, remove_rows) 1005 704 1006 multishell_parameters = self.getIterParams(self.model_parameters) 1007 1008 for i in xrange(index): 1009 for par in multishell_parameters: 1010 param_name = self.replaceShellName(par.name, i+2) 1011 #param_name = str(p.name) + str(i+2) 1012 item1 = QtGui.QStandardItem(param_name) 1013 item1.setCheckable(True) 1014 # check for polydisp params 1015 if par.polydisperse: 1016 poly_item = QtGui.QStandardItem("Polydispersity") 1017 item1_1 = QtGui.QStandardItem("Distribution") 1018 # Find param in volume_params 1019 for p in self.model_parameters.form_volume_parameters: 1020 if p.name != par.name: 1021 continue 1022 item1_2 = QtGui.QStandardItem(str(p.default)) 1023 item1_3 = QtGui.QStandardItem(str(p.limits[0])) 1024 item1_4 = QtGui.QStandardItem(str(p.limits[1])) 1025 item1_5 = QtGui.QStandardItem(p.units) 1026 poly_item.appendRow([item1_1, item1_2, item1_3, item1_4, item1_5]) 1027 break 1028 item1.appendRow([poly_item]) 1029 1030 item2 = QtGui.QStandardItem(str(par.default)) 1031 item3 = QtGui.QStandardItem(str(par.limits[0])) 1032 item4 = QtGui.QStandardItem(str(par.limits[1])) 1033 item5 = QtGui.QStandardItem(par.units) 1034 self._model_model.appendRow([item1, item2, item3, item4, item5]) 705 FittingUtilities.addShellsToModel(self.model_parameters, self._model_model, index) 1035 706 1036 707 def togglePoly(self, isChecked):
Note: See TracChangeset
for help on using the changeset viewer.