Changeset 0fe7e5b in sasview for src/sas/qtgui/Utilities/GuiUtils.py


Ignore:
Timestamp:
Aug 21, 2018 4:29:41 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:
c0de493
Parents:
e11106e
Message:

remove redundant intermediate plots when a new model is selected that does not plot them

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Utilities/GuiUtils.py

    r3933ee9 r0fe7e5b  
    292292    # Append the new row to the main item 
    293293    item.appendRow(checkbox_item) 
     294 
     295def deleteRedundantPlots(item, new_plots): 
     296    """ 
     297    Checks all plots that are children of the given item; if any have an ID or name not included in new_plots, 
     298    it is deleted. Useful for e.g. switching from P(Q)S(Q) to P(Q); this would remove the old S(Q) plot. 
     299 
     300    Ensure that new_plots contains ALL the relevant plots(!!!) 
     301    """ 
     302    assert isinstance(item, QtGui.QStandardItem) 
     303 
     304    names = [p.name for p in new_plots if p.name is not None] 
     305    ids = [p.id for p in new_plots if p.id is not None] 
     306 
     307    items_to_delete = [] 
     308 
     309    for index in range(item.rowCount()): 
     310        plot_item = item.child(index) 
     311        if plot_item.isCheckable(): 
     312            plot_data = plot_item.child(0).data() 
     313            if (plot_data.id is not None) and (plot_data.id not in ids) and (plot_data.name not in names): 
     314                items_to_delete.append(plot_item) 
     315 
     316    for plot_item in items_to_delete: 
     317        item.removeRow(plot_item.row()) 
    294318 
    295319class HashableStandardItem(QtGui.QStandardItem): 
Note: See TracChangeset for help on using the changeset viewer.