Changeset fd7ef36 in sasview for src/sas/qtgui/MainWindow


Ignore:
Timestamp:
Sep 6, 2018 4:53:39 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:
605d944
Parents:
2df558e
Message:

delete intermediate theory-only plots after model evaluation, before adding current ones

this applies only to beta approximation, whereby plots such as beta(Q)
and S_eff(Q) may be removed between calculations. however, since it does
not affect behaviour otherwise, I am pushing to ESS_GUI to ensure no
later conflicts occur

Location:
src/sas/qtgui/MainWindow
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/MainWindow/DataExplorer.py

    r6b50296 rfd7ef36  
    44import time 
    55import logging 
    6 import re 
    76 
    87from PyQt5 import QtCore 
     
    3736    # The controller which is responsible for managing signal slots connections 
    3837    # for the gui and providing an interface to the data model. 
    39  
    40     # This matches the ID of a plot created using FittingLogic._create1DPlot, e.g. 
    41     # "5 [P(Q)] modelname" 
    42     # or 
    43     # "4 modelname". 
    44     # Useful for determining whether the plot in question is for an intermediate result, such as P(Q) or S(Q) in the 
    45     # case of a product model; the identifier for this is held in square brackets, as in the example above. 
    46     theory_plot_ID_pattern = re.compile(r"^([0-9]+)\s+(\[(.*)\]\s+)?(.*)$") 
    4738 
    4839    def __init__(self, parent=None, guimanager=None, manager=None): 
     
    581572            else: 
    582573                # Don't plot intermediate results, e.g. P(Q), S(Q) 
    583                 match = self.theory_plot_ID_pattern.match(plot_id) 
     574                match = GuiUtils.theory_plot_ID_pattern.match(plot_id) 
    584575                # 2nd match group contains the identifier for the intermediate result, if present (e.g. "[P(Q)]") 
    585576                if match and match.groups()[1] != None: 
     
    12901281        self.theory_model.appendRow(model_item) 
    12911282 
     1283    def deleteIntermediateTheoryPlotsByModelID(self, model_id): 
     1284        """Given a model's ID, deletes all items in the theory item model which reference the same ID. Useful in the 
     1285        case of intermediate results disappearing when changing calculations (in which case you don't want them to be 
     1286        retained in the list).""" 
     1287        items_to_delete = [] 
     1288        for r in range(self.theory_model.rowCount()): 
     1289            item = self.theory_model.item(r, 0) 
     1290            data = item.child(0).data() 
     1291            if not hasattr(data, "id"): 
     1292                return 
     1293            match = GuiUtils.theory_plot_ID_pattern.match(data.id) 
     1294            if match: 
     1295                item_model_id = match.groups()[-1] 
     1296                if item_model_id == model_id: 
     1297                    # Only delete those identified as an intermediate plot 
     1298                    if match.groups()[2] not in (None, ""): 
     1299                        items_to_delete.append(item) 
     1300 
     1301        for item in items_to_delete: 
     1302            self.theory_model.removeRow(item.row()) 
  • src/sas/qtgui/MainWindow/GuiManager.py

    r6b50296 rfd7ef36  
    395395        self.communicate.perspectiveChangedSignal.connect(self.perspectiveChanged) 
    396396        self.communicate.updateTheoryFromPerspectiveSignal.connect(self.updateTheoryFromPerspective) 
     397        self.communicate.deleteIntermediateTheoryPlotsSignal.connect(self.deleteIntermediateTheoryPlotsByModelID) 
    397398        self.communicate.plotRequestedSignal.connect(self.showPlot) 
    398399        self.communicate.plotFromFilenameSignal.connect(self.showPlotFromFilename) 
     
    886887        self.filesWidget.updateTheoryFromPerspective(index) 
    887888 
     889    def deleteIntermediateTheoryPlotsByModelID(self, model_id): 
     890        """ 
     891        Catch the signal to delete items in the Theory item model which correspond to a model ID. 
     892        Send the request to the DataExplorer for updating the theory model. 
     893        """ 
     894        self.filesWidget.deleteIntermediateTheoryPlotsByModelID(model_id) 
     895 
    888896    def updateModelFromDataOperationPanel(self, new_item, new_datalist_item): 
    889897        """ 
Note: See TracChangeset for help on using the changeset viewer.