source: sasview/src/sas/perspectives/fitting/resultpanel.py @ 10a483f

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 10a483f was 79492222, checked in by krzywon, 10 years ago

Changed the file and folder names to remove all SANS references.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1"""
2FitPanel class contains fields allowing to fit  models and  data
3
4:note: For Fit to be performed the user should check at least one parameter
5    on fit Panel window.
6   
7"""
8import wx
9import wx.lib.newevent
10from wx.aui import AuiNotebook as Notebook
11
12from sas.guiframe.panel_base import PanelBase
13from sas.guiframe.events import StatusEvent
14
15(PlotResultEvent, EVT_PLOT_RESULT) = wx.lib.newevent.NewEvent()
16
17
18class ResultPanel(Notebook, PanelBase):
19    """
20    FitPanel class contains fields allowing to fit  models and  data
21   
22    :note: For Fit to be performed the user should check at least one parameter
23        on fit Panel window.
24       
25    """
26    ## Internal name for the AUI manager
27    window_name = "Result panel"
28    ## Title to appear on top of the window
29    window_caption = "Result Panel"
30    CENTER_PANE = True
31   
32    def __init__(self, parent, manager=None, *args, **kwargs):
33        """
34        """
35        style = ((wx.aui.AUI_NB_WINDOWLIST_BUTTON
36                 |wx.aui.AUI_NB_DEFAULT_STYLE
37                 |wx.CLIP_CHILDREN)
38                 & ~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB)
39        Notebook.__init__(self, parent, -1, style = style)
40        PanelBase.__init__(self, parent)
41        self.frame = parent
42        self.Bind(EVT_PLOT_RESULT, self.on_plot_results)
43        self.frame.Bind(wx.EVT_CLOSE, self.on_close)
44        self._manager = None
45
46    def on_close(self, event):
47        if event.CanVeto():
48            self.frame.Hide()
49            event.Veto()
50        else:
51            event.Skip()
52
53    def on_plot_results(self, event):
54        self.frame.Show()
55        result = event.result[0][0]
56        if hasattr(result, 'convergence'):
57            from bumps.gui.convergence_view import ConvergenceView
58            best, pop = result.convergence[:,0], result.convergence[:,1:]
59            self.get_panel(ConvergenceView).update(best, pop)
60        if hasattr(result, 'uncertainty_state'):
61            from bumps.gui.uncertainty_view import UncertaintyView, CorrelationView, TraceView
62            from bumps.dream.stats import var_stats,format_vars
63            stats = var_stats(result.uncertainty_state.draw())
64            msg = format_vars(stats)
65            self.get_panel(CorrelationView).update(result.uncertainty_state)
66            self.get_panel(UncertaintyView).update((result.uncertainty_state,stats))
67            self.get_panel(TraceView).update(result.uncertainty_state)
68            # TODO: stats should be stored in result rather than computed in bumps UncertaintyView
69            wx.PostEvent(self.frame.parent,
70                         StatusEvent(status=msg, info="info"))
71            print
72
73    def get_frame(self):
74        return self.frame
75
76    def add_panel(self, panel):
77        self.AddPage(panel, panel.title)
78
79    def get_panel(self, panel_class):
80        for idx in range(self.PageCount):
81            if self.GetPageText(idx) == panel_class.title:
82                return self.GetPage(idx)
83        else:
84            panel = panel_class(self)
85            self.add_panel(panel)
86            return panel
Note: See TracBrowser for help on using the repository browser.