Changeset a54bbf2b in sasview


Ignore:
Timestamp:
Sep 11, 2018 10:00:45 AM (11 days ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Pr_fixes, ESS_GUI_iss1052, ESS_GUI_iss879
Children:
2d47985
Parents:
343d7fd
Message:

Added plot roles to Data1D/Data2D structures to allow for smoother plot logic.

Location:
src/sas/qtgui
Files:
6 edited

Legend:

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

    r2b8286c ra54bbf2b  
    574574        new_plots = [] 
    575575        for item, plot in plots.items(): 
    576             if self.updatePlot(plot) and filename != plot.name: 
     576            if self.updatePlot(plot) or filename not in plot.name: 
    577577                continue 
    578578            # Don't plot intermediate results, e.g. P(Q), S(Q) 
     
    583583            # Don't include plots from different fitpages, but always include the original data 
    584584            if fitpage_name in plot.name or filename == plot.name: 
    585                 # 'sophisticated' test to generate standalone plot for residuals 
    586                 if 'esiduals' in plot.title: 
     585                # Residuals get their own plot 
     586                if plot.plot_role == Data1D.ROLE_RESIDUAL: 
    587587                    plot.yscale='linear' 
    588588                    self.plotData([(item, plot)]) 
     
    686686 
    687687        # Update the active chart list 
    688         #self.active_plots[new_plot.data.id] = new_plot 
     688        self.active_plots[new_plot.data.name] = new_plot 
    689689 
    690690    def appendPlot(self): 
     
    729729        data_id = data.name 
    730730        if data_id in ids_keys: 
    731             self.active_plots[data_id].replacePlot(data_id, data) 
     731            # We have data, let's replace data that needs replacing 
     732            if data.plot_role != Data1D.ROLE_DATA: 
     733                self.active_plots[data_id].replacePlot(data_id, data) 
    732734            return True 
    733735        elif data_id in ids_vals: 
    734             list(self.active_plots.values())[ids_vals.index(data_id)].replacePlot(data_id, data) 
     736            if data.plot_role != Data1D.ROLE_DATA: 
     737                list(self.active_plots.values())[ids_vals.index(data_id)].replacePlot(data_id, data) 
    735738            return True 
    736739        return False 
  • src/sas/qtgui/MainWindow/DataManager.py

    r4e255d1 ra54bbf2b  
    118118        new_plot.path = path 
    119119        new_plot.list_group_id = [] 
     120        # Assign the plot role to data 
     121        new_plot.plot_role = Data1D.ROLE_DATA 
    120122        ##post data to plot 
    121123        # plot data 
  • src/sas/qtgui/Perspectives/Fitting/FittingLogic.py

    r61f0c75 ra54bbf2b  
    154154        new_plot.xaxis(_xaxis, _xunit) 
    155155        new_plot.yaxis(_yaxis, _yunit) 
     156 
     157        if component is not None: 
     158            new_plot.plot_role = Data1D.ROLE_DELETABLE #deletable 
    156159 
    157160        return new_plot 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    rf3cc979 ra54bbf2b  
    24812481        residuals_plot = FittingUtilities.plotResiduals(self.data, weighted_data) 
    24822482        residuals_plot.id = "Residual " + residuals_plot.id 
     2483        residuals_plot.plot_role = Data1D.ROLE_RESIDUAL 
    24832484        self.createNewIndex(residuals_plot) 
    24842485        return residuals_plot 
  • src/sas/qtgui/Plotting/PlotterData.py

    rcee5c78 ra54bbf2b  
    1717    """ 
    1818    """ 
     19    ROLE_DATA=0 
     20    ROLE_DEFAULT=1 
     21    ROLE_DELETABLE=2 
     22    ROLE_RESIDUAL=3 
    1923    def __init__(self, x=None, y=None, dx=None, dy=None): 
    2024        """ 
     
    3539        self.title = "" 
    3640        self.scale = None 
     41        # plot_role: 
     42        # 0: data - no reload on param change 
     43        # 1: normal lifecycle (fit) 
     44        # 2: deletable on model change (Q(I), S(I)...) 
     45        # 3: separate chart on Show Plot (residuals) 
     46        self.plot_role = Data1D.ROLE_DEFAULT 
    3747         
    3848    def copy_from_datainfo(self, data1d): 
     
    184194        self.title = "" 
    185195        self.scale = None 
     196        # Always default 
     197        self.plot_role = Data1D.ROLE_DEFAULT 
    186198         
    187199    def copy_from_datainfo(self, data2d): 
  • src/sas/qtgui/Utilities/GuiUtils.py

    r5d28d6b ra54bbf2b  
    322322    assert isinstance(item, QtGui.QStandardItem) 
    323323 
     324    # lists of plots names/ids for all deletable plots on item 
    324325    names = [p.name for p in new_plots if p.name is not None] 
    325326    ids = [p.id for p in new_plots if p.id is not None] 
     
    329330    for index in range(item.rowCount()): 
    330331        plot_item = item.child(index) 
    331         if plot_item.isCheckable(): 
    332             plot_data = plot_item.child(0).data() 
    333             if (plot_data.id is not None) and (plot_data.id not in ids) and (plot_data.name not in names): 
    334                 items_to_delete.append(plot_item) 
     332        if not plot_item.isCheckable(): 
     333            continue 
     334        plot_data = plot_item.child(0).data() 
     335        if (plot_data.id is not None) and \ 
     336            (plot_data.id not in ids) and \ 
     337            (plot_data.name not in names) and \ 
     338            (plot_data.plot_role == Data1D.ROLE_DELETABLE): 
     339            items_to_delete.append(plot_item) 
    335340 
    336341    for plot_item in items_to_delete: 
Note: See TracChangeset for help on using the changeset viewer.