source: sasview/src/sans/perspectives/fitting/resultpanel.py @ 1790664

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 1790664 was ed4aef2, checked in by pkienzle, 10 years ago

add panel for bumps results

  • Property mode set to 100644
File size: 3.0 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 sans.guiframe.panel_base import PanelBase
13from sans.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 format_vars
63            self.get_panel(CorrelationView).update(result.uncertainty_state)
64            self.get_panel(UncertaintyView).update(result.uncertainty_state)
65            self.get_panel(TraceView).update(result.uncertainty_state)
66            # TODO: stats should be stored in result rather than computed in bumps UncertaintyView
67            msg = format_vars(self.get_panel(UncertaintyView).stats)
68            wx.PostEvent(self.frame.parent,
69                         StatusEvent(status=msg, info="info"))
70            print
71
72    def get_frame(self):
73        return self.frame
74
75    def add_panel(self, panel):
76        self.AddPage(panel, panel.title)
77
78    def get_panel(self, panel_class):
79        for idx in range(self.PageCount):
80            if self.GetPageText(idx) == panel_class.title:
81                return self.GetPage(idx)
82        else:
83            panel = panel_class(self)
84            self.add_panel(panel)
85            return panel
Note: See TracBrowser for help on using the repository browser.