Ignore:
Timestamp:
Sep 7, 2018 10:10:42 AM (6 years ago)
Author:
Torin Cooper-Bennun <torin.cooper-bennun@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
5fb714b
Parents:
bc7371fd (diff), fb560d2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ESS_GUI' into ESS_GUI_iss1032

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py

    rbc7371fd rb69b549  
    167167    return rows 
    168168 
    169 def addSimpleParametersToModel(parameters, is2D, model=None, view=None): 
     169def addSimpleParametersToModel(parameters, is2D, parameters_original=None, model=None, view=None): 
    170170    """ 
    171171    Update local ModelModel with sasmodel parameters (non-dispersed, non-magnetic) 
    172172    Actually appends to model, if model and view params are not None. 
    173173    Always returns list of lists of QStandardItems. 
     174 
     175    parameters_original: list of parameters before any tagging on their IDs, e.g. for product model (so that those are 
     176    the display names; see below) 
    174177    """ 
    175178    if is2D: 
     
    178181        params = parameters.iq_parameters 
    179182 
     183    if parameters_original: 
     184        # 'parameters_original' contains the parameters as they are to be DISPLAYED, while 'parameters' 
     185        # contains the parameters as they were renamed; this is for handling name collisions in product model. 
     186        # The 'real name' of the parameter will be stored in the item's user data. 
     187        if is2D: 
     188            params_orig = [p for p in parameters_original.kernel_parameters if p.type != 'magnetic'] 
     189        else: 
     190            params_orig = parameters_original.iq_parameters 
     191    else: 
     192        # no difference in names anyway 
     193        params_orig = params 
     194 
    180195    rows = [] 
    181     for param in params: 
     196    for param, param_orig in zip(params, params_orig): 
    182197        # Create the top level, checkable item 
    183         item_name = param.name 
     198        item_name = param_orig.name 
    184199        item1 = QtGui.QStandardItem(item_name) 
     200        item1.setData(param.name, QtCore.Qt.UserRole) 
    185201        item1.setCheckable(True) 
    186202        item1.setEditable(False) 
     
    240256    model.appendRow(item_list) 
    241257 
     258def addHeadingRowToModel(model, name): 
     259    """adds a non-interactive top-level row to the model""" 
     260    header_row = [QtGui.QStandardItem() for i in range(5)] 
     261    header_row[0].setText(name) 
     262 
     263    font = header_row[0].font() 
     264    font.setBold(True) 
     265    header_row[0].setFont(font) 
     266 
     267    for item in header_row: 
     268        item.setEditable(False) 
     269        item.setCheckable(False) 
     270        item.setSelectable(False) 
     271 
     272    model.appendRow(header_row) 
     273 
    242274def addHeadersToModel(model): 
    243275    """ 
     
    285317    model.header_tooltips = copy.copy(poly_header_error_tooltips) 
    286318 
    287 def addShellsToModel(parameters, model, index, view=None): 
    288     """ 
    289     Find out multishell parameters and update the model with the requested number of them 
    290     Always appends to model. If view param is not None, supports fixed-choice params. 
    291     Returns list of lists of QStandardItems. 
     319def addShellsToModel(parameters, model, index, row_num=None, view=None): 
     320    """ 
     321    Find out multishell parameters and update the model with the requested number of them. 
     322    Inserts them after the row at row_num, if not None; otherwise, appends to end. 
     323    If view param is not None, supports fixed-choice params. 
     324    Returns a list of lists of QStandardItem objects. 
    292325    """ 
    293326    multishell_parameters = getIterParams(parameters) 
     
    326359            cbox = createFixedChoiceComboBox(par, row) 
    327360 
    328             # Always append to the model 
    329             model.appendRow(row) 
     361            # Always add to the model 
     362            if row_num is None: 
     363                model.appendRow(row) 
     364            else: 
     365                model.insertRow(row_num, row) 
     366                row_num += 1 
    330367 
    331368            # Apply combobox if required 
Note: See TracChangeset for help on using the changeset viewer.