Changeset fd7ef36 in sasview


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
Files:
4 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        """ 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r444c221c rfd7ef36  
    23032303            new_plots.append(residuals) 
    23042304 
     2305        if self.data_is_loaded: 
     2306            GuiUtils.deleteRedundantPlots(self.all_data[self.data_index], new_plots) 
     2307        else: 
     2308            # delete theory items for the model, in order to get rid of any redundant items, e.g. beta(Q), S_eff(Q) 
     2309            self.communicate.deleteIntermediateTheoryPlotsSignal.emit(self.kernel_module.id) 
     2310 
    23052311        # Create plots for intermediate product data 
    23062312        pq_data, sq_data = self.logic.new1DProductPlots(return_data, self.tab_id) 
     
    23152321            # self.communicate.plotUpdateSignal.emit([sq_data]) 
    23162322            new_plots.append(sq_data) 
    2317  
    2318         if self.data_is_loaded: 
    2319             GuiUtils.deleteRedundantPlots(self.all_data[self.data_index], new_plots) 
    23202323 
    23212324        # Update/generate plots 
  • src/sas/qtgui/Utilities/GuiUtils.py

    r9463ca2 rfd7ef36  
    3535        HELP_DIRECTORY_LOCATION = "docs/sphinx-docs/build/html" 
    3636IMAGES_DIRECTORY_LOCATION = HELP_DIRECTORY_LOCATION + "/_images" 
     37 
     38# This matches the ID of a plot created using FittingLogic._create1DPlot, e.g. 
     39# "5 [P(Q)] modelname" 
     40# or 
     41# "4 modelname". 
     42# Useful for determining whether the plot in question is for an intermediate result, such as P(Q) or S(Q) in the 
     43# case of a product model; the identifier for this is held in square brackets, as in the example above. 
     44theory_plot_ID_pattern = re.compile(r"^([0-9]+)\s+(\[(.*)\]\s+)?(.*)$") 
    3745 
    3846def get_app_dir(): 
     
    211219    # New theory data in current perspective 
    212220    updateTheoryFromPerspectiveSignal = QtCore.pyqtSignal(QtGui.QStandardItem) 
     221 
     222    # Request to delete plots (in the theory view) related to a given model ID 
     223    deleteIntermediateTheoryPlotsSignal = QtCore.pyqtSignal(str) 
    213224 
    214225    # New plot requested from the GUI manager 
Note: See TracChangeset for help on using the changeset viewer.