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

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 f21d496 was 2f4b430, checked in by Doucet, Mathieu <doucetm@…>, 10 years ago

Take care of white spaces (pylint)

  • Property mode set to 100644
File size: 3.1 KB
RevLine 
[ed4aef2]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.
[2f4b430]6
[ed4aef2]7"""
8import wx
9import wx.lib.newevent
10from wx.aui import AuiNotebook as Notebook
11
[79492222]12from sas.guiframe.panel_base import PanelBase
13from sas.guiframe.events import StatusEvent
[ed4aef2]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
[2f4b430]21
[ed4aef2]22    :note: For Fit to be performed the user should check at least one parameter
23        on fit Panel window.
[2f4b430]24
[ed4aef2]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
[2f4b430]31
[ed4aef2]32    def __init__(self, parent, manager=None, *args, **kwargs):
33        """
34        """
35        style = ((wx.aui.AUI_NB_WINDOWLIST_BUTTON
[2f4b430]36                 | wx.aui.AUI_NB_DEFAULT_STYLE
37                 | wx.CLIP_CHILDREN)
[ed4aef2]38                 & ~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB)
[2f4b430]39        Notebook.__init__(self, parent, -1, style=style)
[ed4aef2]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
[2f4b430]58            best, pop = result.convergence[:, 0], result.convergence[:, 1:]
[ed4aef2]59            self.get_panel(ConvergenceView).update(best, pop)
60        if hasattr(result, 'uncertainty_state'):
61            from bumps.gui.uncertainty_view import UncertaintyView, CorrelationView, TraceView
[2f4b430]62            from bumps.dream.stats import var_stats, format_vars
[c915053]63            stats = var_stats(result.uncertainty_state.draw())
64            msg = format_vars(stats)
[ed4aef2]65            self.get_panel(CorrelationView).update(result.uncertainty_state)
[2f4b430]66            self.get_panel(UncertaintyView).update((result.uncertainty_state, stats))
[ed4aef2]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.