Changeset 2d9526d in sasview for src/sas/sasgui/perspectives


Ignore:
Timestamp:
Aug 30, 2017 5:55:36 AM (7 years ago)
Author:
lewis
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
7b15990, 729198e
Parents:
0f9ea1c
Message:

Refactor P(Q)*S(Q) plot updating logic, and ensure unsmeared theory is also updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/fitting.py

    r0f9ea1c r2d9526d  
    17471747                                         data_description=model.name, 
    17481748                                         data_id=str(page_id) + " " + data.name) 
     1749        plots_to_update = [] # List of plottables that have changed since last calculation 
     1750        # Create the new theories 
    17491751        if unsmeared_model is not None: 
    1750             self.create_theory_1D(x, unsmeared_model, page_id, model, data, state, 
     1752            unsmeared_model_plot = self.create_theory_1D(x, unsmeared_model,  
     1753                                  page_id, model, data, state, 
    17511754                                  data_description=model.name + " unsmeared", 
    17521755                                  data_id=str(page_id) + " " + data.name + " unsmeared") 
     1756            plots_to_update.append(unsmeared_model_plot) 
    17531757 
    17541758            if unsmeared_data is not None and unsmeared_error is not None: 
    1755                 self.create_theory_1D(x, unsmeared_data, page_id, model, data, state, 
     1759                unsmeared_data_plot = self.create_theory_1D(x, unsmeared_data,  
     1760                                      page_id, model, data, state, 
    17561761                                      data_description="Data unsmeared", 
    17571762                                      data_id="Data  " + data.name + " unsmeared", 
    17581763                                      dy=unsmeared_error) 
     1764                plots_to_update.append(unsmeared_data_plot) 
    17591765        if sq_model is not None and pq_model is not None: 
    1760             # Store which data sets are plotted in which windows 
    1761             # plot_ids[data_id] = [group_id1, group_id2, ...] 
    1762             plot_ids = {} 
    1763             for plot_panel in self.parent.plot_panels.values(): 
    1764                 for data_id in plot_panel.plots.keys(): 
    1765                     if data_id in plot_ids: 
    1766                         plot_ids[data_id].append(plot_panel.group_id) 
    1767                     else: 
    1768                         plot_ids[data_id] = [plot_panel.group_id] 
    1769             # Create/Update the theories 
    17701766            sq_id = str(page_id) + " " + data.name + " S(q)" 
    17711767            sq_plot = self.create_theory_1D(x, sq_model, page_id, model, data, state, 
    17721768                                  data_description=model.name + " S(q)", 
    17731769                                  data_id=sq_id) 
     1770            plots_to_update.append(sq_plot) 
    17741771            pq_id = str(page_id) + " " + data.name + " P(q)" 
    17751772            pq_plot = self.create_theory_1D(x, pq_model, page_id, model, data, state, 
    17761773                                  data_description=model.name + " P(q)", 
    17771774                                  data_id=pq_id) 
    1778             # Update the P(Q) and S(Q) plots if they exist 
    1779             if sq_id in plot_ids: 
    1780                 # If the S(Q) theory has been plotted, update its plots 
    1781                 sq_plot.list_group_id = plot_ids[sq_id] 
    1782                 for group_id in plot_ids[sq_id]: 
    1783                     # Only create a copy of the data object if more than one plot of it exists 
    1784                     if len(plot_ids[sq_id]) > 1: 
    1785                         to_plot = deepcopy(sq_plot) 
    1786                     else: 
    1787                         to_plot = sq_plot 
    1788                     to_plot.group_id = group_id 
    1789                     wx.PostEvent(self.parent, NewPlotEvent(plot=to_plot, 
    1790                         title=str(to_plot.title), group_id=to_plot.group_id)) 
    1791             if pq_id in plot_ids: 
    1792                 # If the P(Q) theory has been plotted, update its plots 
    1793                 pq_plot.list_group_id = plot_ids[pq_id] 
    1794                 for group_id in plot_ids[pq_id]: 
    1795                     # Only create a copy of the data object if more than one plot of it exists 
    1796                     if len(plot_ids[pq_id]) > 1: 
    1797                         to_plot = deepcopy(pq_plot) 
    1798                     else: 
    1799                         to_plot = pq_plot 
    1800                     to_plot.group_id = group_id 
    1801                     wx.PostEvent(self.parent, NewPlotEvent(plot=to_plot, 
    1802                         title=str(to_plot.title), group_id=to_plot.group_id)) 
     1775            plots_to_update.append(pq_plot) 
     1776        # Update the P(Q), S(Q) and unsmeared theory plots if they exist 
     1777        wx.PostEvent(self.parent, NewPlotEvent(plots=plots_to_update,  
     1778                                              action='update')) 
    18031779 
    18041780        current_pg = self.fit_panel.get_page_by_id(page_id) 
Note: See TracChangeset for help on using the changeset viewer.