source: sasview/src/sas/sasgui/perspectives/corfunc/corfunc_panel.py @ 0bbebee

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.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 0bbebee was 0bbebee, checked in by lewis, 8 years ago

Fix syntax error

  • Property mode set to 100644
File size: 21.7 KB
RevLine 
[c23f303]1import wx
2import sys
3from wx.lib.scrolledpanel import ScrolledPanel
[3901e7c]4from sas.sasgui.guiframe.events import PlotQrangeEvent
5from sas.sasgui.guiframe.events import StatusEvent
[c23f303]6from sas.sasgui.guiframe.panel_base import PanelBase
[3901e7c]7from sas.sasgui.guiframe.utils import check_float
[3b8efec]8from sas.sasgui.guiframe.dataFitting import Data1D
[7858575]9from sas.sasgui.perspectives.invariant.invariant_widgets import OutputTextCtrl
[9f7dde3]10from sas.sasgui.perspectives.invariant.invariant_widgets import InvTextCtrl
[3901e7c]11from sas.sasgui.perspectives.fitting.basepage import ModelTextCtrl
[e02d8f6]12from sas.sasgui.perspectives.corfunc.corfunc_state import CorfuncState
[3b8efec]13import sas.sasgui.perspectives.corfunc.corfunc
14from sas.sascalc.corfunc.corfunc_calculator import CorfuncCalculator
[c23f303]15
[033c14c]16OUTPUT_STRINGS = {
17    'max': "Long Period (A): ",
18    'Lc': "Average Hard Block Thickness (A): ",
19    'dtr': "Average Interface Thickness (A): ",
20    'd0': "Average Core Thickness: ",
21    'A': "PolyDispersity: ",
[a684c64]22    'fill': "Filling Fraction: "
[033c14c]23}
24
[c23f303]25if sys.platform.count("win32") > 0:
[7858575]26    _STATICBOX_WIDTH = 350
27    PANEL_WIDTH = 400
[c23f303]28    PANEL_HEIGHT = 700
29    FONT_VARIANT = 0
30else:
[7858575]31    _STATICBOX_WIDTH = 390
32    PANEL_WIDTH = 430
[c23f303]33    PANEL_HEIGHT = 700
34    FONT_VARIANT = 1
35
36class CorfuncPanel(ScrolledPanel,PanelBase):
37    window_name = "Correlation Function"
38    window_caption = "Correlation Function"
39    CENTER_PANE = True
40
41    def __init__(self, parent, data=None, manager=None, *args, **kwds):
42        kwds["size"] = (PANEL_WIDTH, PANEL_HEIGHT)
43        kwds["style"] = wx.FULL_REPAINT_ON_RESIZE
44        ScrolledPanel.__init__(self, parent=parent, *args, **kwds)
45        PanelBase.__init__(self, parent)
46        self.SetupScrolling()
47        self.SetWindowVariant(variant=FONT_VARIANT)
48        self._manager = manager
[911dbe4]49        # The data with no correction for background values
50        self._data = data # The data to be analysed (corrected fr background)
[3b8efec]51        self._extrapolated_data = None # The extrapolated data set
[033c14c]52        self._transformed_data = None # Fourier trans. of the extrapolated data
[911dbe4]53        self._calculator = CorfuncCalculator()
[3ec4b8f]54        self._data_name_box = None # Text box to show name of file
[b564ea2]55        self._background_input = None
[3901e7c]56        self._qmin_input = None
57        self._qmax1_input = None
58        self._qmax2_input = None
[911dbe4]59        self._transform_btn = None
[033c14c]60        self._extract_btn = None
[e02d8f6]61        self.qmin = 0
62        self.qmax = (0, 0)
[b564ea2]63        self.background = 0
[a684c64]64        self.extracted_params = None
[033c14c]65        # Dictionary for saving refs to text boxes used to display output data
66        self._output_boxes = None
[c23f303]67        self.state = None
68        self._do_layout()
[54a0989]69        self._disable_inputs()
[e02d8f6]70        self.set_state()
[b564ea2]71        self._qmin_input.Bind(wx.EVT_TEXT, self._on_enter_input)
72        self._qmax1_input.Bind(wx.EVT_TEXT, self._on_enter_input)
73        self._qmax2_input.Bind(wx.EVT_TEXT, self._on_enter_input)
[688d029]74        self._qmin_input.Bind(wx.EVT_MOUSE_EVENTS, self._on_click_qrange)
75        self._qmax1_input.Bind(wx.EVT_MOUSE_EVENTS, self._on_click_qrange)
76        self._qmax2_input.Bind(wx.EVT_MOUSE_EVENTS, self._on_click_qrange)
[3b8efec]77        self._background_input.Bind(wx.EVT_TEXT, self._on_enter_input)
[c23f303]78
79    def set_state(self, state=None, data=None):
[9c90cf3]80        """
81        Set the state of the panel. If no state is provided, the panel will
82        be set to the default state.
83
84        :param state: A CorfuncState object
85        :param data: A Data1D object
86        """
[e02d8f6]87        if state is None:
88            self.state = CorfuncState()
89        else:
90            self.state = state
91        if data is not None:
92            self.state.data = data
[3b8efec]93        self.set_data(data, set_qrange=False)
[e02d8f6]94        if self.state.qmin is not None:
95            self.set_qmin(self.state.qmin)
96        if self.state.qmax is not None and self.state.qmax != (None, None):
97            self.set_qmax(tuple(self.state.qmax))
[b564ea2]98        if self.state.background is not None:
99            self.set_background(self.state.background)
[2ff9e37]100        if self.state.is_extrapolated:
[6ccf18e]101            self.compute_extrapolation()
[2ff9e37]102        else:
103            return
104        if self.state.is_transformed:
[6ccf18e]105            self.compute_transform()
[2ff9e37]106        else:
107            return
108        if self.state.outputs is not None and self.state.outputs != {}:
109            self.set_extracted_params(self.state.outputs)
[e02d8f6]110
111    def get_state(self):
112        """
113        Return the state of the panel
114        """
115        state = CorfuncState()
116        state.set_saved_state('qmin_tcl', self.qmin)
117        state.set_saved_state('qmax1_tcl', self.qmax[0])
118        state.set_saved_state('qmax2_tcl', self.qmax[1])
[b564ea2]119        state.set_saved_state('background_tcl', self.background)
[a684c64]120        state.outputs = self.extracted_params
[e02d8f6]121        if self._data is not None:
122            state.file = self._data.title
123            state.data = self._data
[2ff9e37]124        if self._extrapolated_data is not None:
125            state.is_extrapolated = True
126        if self._transformed_data is not None:
127            state.is_transformed = True
[e02d8f6]128        self.state = state
129
130        return self.state
[c23f303]131
[3901e7c]132    def onSetFocus(self, evt):
133        if evt is not None:
134            evt.Skip()
[b564ea2]135        self._validate_inputs()
[3901e7c]136
[e02d8f6]137    def set_data(self, data=None, set_qrange=True):
[7858575]138        """
139        Update the GUI to reflect new data that has been loaded in
140
141        :param data: The data that has been loaded
142        """
[e02d8f6]143        if data is None:
144            return
[54a0989]145        self._enable_inputs()
146        self._transform_btn.Disable()
[033c14c]147        self._extract_btn.Disable()
[e02d8f6]148        self._data_name_box.SetValue(str(data.title))
[3901e7c]149        self._data = data
[911dbe4]150        self._calculator.set_data(data)
[1150083]151        # Reset the outputs
[a684c64]152        self.set_extracted_params(None)
[7858575]153        if self._manager is not None:
[3b8efec]154            from sas.sasgui.perspectives.corfunc.corfunc import IQ_DATA_LABEL
[1150083]155            self._manager.clear_data()
[911dbe4]156            self._manager.show_data(self._data, IQ_DATA_LABEL, reset=True)
[1150083]157
[e02d8f6]158        if set_qrange:
159            lower = data.x[-1]*0.05
160            upper1 = data.x[-1] - lower*5
161            upper2 = data.x[-1]
162            self.set_qmin(lower)
163            self.set_qmax((upper1, upper2))
[911dbe4]164            self.set_background(self._calculator.compute_background(self.qmax))
[e02d8f6]165
166    def get_data(self):
167        return self._data
168
[3b8efec]169    def compute_extrapolation(self, event=None):
[6970e51]170        """
171        Compute and plot the extrapolated data.
172        Called when Extrapolate button is pressed.
173        """
[3b8efec]174        if not self._validate_inputs:
175            msg = "Invalid Q range entered."
176            wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
177            return
[911dbe4]178        self._calculator.set_data(self._data)
179        self._calculator.lowerq = self.qmin
180        self._calculator.upperq = self.qmax
[275b448]181        self._calculator.background = self.background
[cdd1c3b]182        try:
183            self._extrapolated_data = self._calculator.compute_extrapolation()
184        except:
185            msg = "Error extrapolating data."
186            wx.PostEvent(self._manager.parent,
187                StatusEvent(status=msg, info="Error"))
188            self._transform_btn.Disable()
189            return
[3b8efec]190        # TODO: Find way to set xlim and ylim so full range of data can be
191        # plotted
192        maxq = self._data.x.max()
193        mask = self._extrapolated_data.x <= maxq
194        numpts = len(self._extrapolated_data.x[mask]) + 250
195        plot_x = self._extrapolated_data.x[0:numpts]
196        plot_y = self._extrapolated_data.y[0:numpts]
197        to_plot = Data1D(plot_x, plot_y)
198        from sas.sasgui.perspectives.corfunc.corfunc import\
199            IQ_EXTRAPOLATED_DATA_LABEL
200        self._manager.show_data(to_plot, IQ_EXTRAPOLATED_DATA_LABEL)
[911dbe4]201        self._transform_btn.Enable()
202
203    def compute_transform(self, event=None):
[6970e51]204        """
205        Compute and plot the transformed data.
206        Called when Transform button is pressed.
207        """
[cdd1c3b]208        try:
209            transformed_data = self._calculator.compute_transform(
210                self._extrapolated_data, self.background)
211        except:
212            transformed_data = None
213        if transformed_data is None:
214            msg = "Error calculating Transform."
215            wx.PostEvent(self._manager.parent,
216                StatusEvent(status=msg, info="Error"))
217            self._extract_btn.Disable()
218            return
[033c14c]219        self._transformed_data = transformed_data
[911dbe4]220        from sas.sasgui.perspectives.corfunc.corfunc import TRANSFORM_LABEL
221        import numpy as np
222        plot_x = transformed_data.x[np.where(transformed_data.x <= 200)]
223        plot_y = transformed_data.y[np.where(transformed_data.x <= 200)]
224        self._manager.show_data(Data1D(plot_x, plot_y), TRANSFORM_LABEL)
[033c14c]225        self._extract_btn.Enable()
226
227    def extract_parameters(self, event=None):
228        try:
229            params = self._calculator.extract_parameters(self._transformed_data)
230        except:
231            params = None
232        if params is None:
233            msg = "Error extracting parameters."
234            wx.PostEvent(self._manager.parent,
[cdd1c3b]235                StatusEvent(status=msg, info="Error"))
[033c14c]236            return
[a684c64]237        self.set_extracted_params(params)
[033c14c]238
[e02d8f6]239    def save_project(self, doc=None):
240        """
241        Return an XML node containing the state of the panel
[9c90cf3]242
243        :param doc: Am xml node to attach the project state to (optional)
[e02d8f6]244        """
245        data = self._data
246        state = self.get_state()
[0bbebee]247        if data is not None:
[e02d8f6]248            new_doc, sasentry = self._manager.state_reader._to_xml_doc(data)
249            new_doc = state.toXML(doc=new_doc, entry_node=sasentry)
250            if new_doc is not None:
251                if doc is not None and hasattr(doc, "firstChild"):
252                    child = new_doc.getElementsByTagName("SASentry")
253                    for item in child:
254                        doc.firstChild.appendChild(item)
255                else:
256                    doc = new_doc
257        return doc
[3901e7c]258
[9c90cf3]259    def set_qmin(self, qmin):
260        self.qmin = qmin
261        self._qmin_input.SetValue(str(qmin))
262
263    def set_qmax(self, qmax):
264        self.qmax = qmax
265        self._qmax1_input.SetValue(str(qmax[0]))
266        self._qmax2_input.SetValue(str(qmax[1]))
267
[b564ea2]268    def set_background(self, bg):
269        self.background = bg
270        self._background_input.SetValue(str(bg))
[dc72638]271        self._calculator.background = bg
[7858575]272
[a684c64]273    def set_extracted_params(self, params):
274        self.extracted_params = params
275        if params is None:
276            for key in OUTPUT_STRINGS.keys():
277                self._output_boxes[key].SetValue('-')
278        else:
279            for key in OUTPUT_STRINGS.keys():
280                value = params[key]
281                self._output_boxes[key].SetValue(value)
282
[1150083]283
[911dbe4]284    def _compute_background(self, event=None):
285        self.set_background(self._calculator.compute_background(self.qmax))
[b564ea2]286
287    def _on_enter_input(self, event=None):
[3901e7c]288        """
289        Read values from input boxes and save to memory.
290        """
[e02d8f6]291        if event is not None: event.Skip()
[b564ea2]292        if not self._validate_inputs():
[3901e7c]293            return
[b564ea2]294        self.qmin = float(self._qmin_input.GetValue())
[3901e7c]295        new_qmax1 = float(self._qmax1_input.GetValue())
296        new_qmax2 = float(self._qmax2_input.GetValue())
297        self.qmax = (new_qmax1, new_qmax2)
[b564ea2]298        self.background = float(self._background_input.GetValue())
[688d029]299        self._calculator.background = self.background
[3b8efec]300        from sas.sasgui.perspectives.corfunc.corfunc import GROUP_ID_IQ_DATA,\
301            IQ_DATA_LABEL
[e02d8f6]302        if event is not None:
[688d029]303            active_ctrl = event.GetEventObject()
304            if active_ctrl == self._background_input:
[911dbe4]305                from sas.sasgui.perspectives.corfunc.corfunc\
306                    import IQ_DATA_LABEL
[688d029]307                self._manager.show_data(self._data, IQ_DATA_LABEL, reset=False)
308            wx.PostEvent(self._manager.parent, PlotQrangeEvent(
309                ctrl=[self._qmin_input, self._qmax1_input, self._qmax2_input],
[5a54aa4]310                active=active_ctrl, id=IQ_DATA_LABEL, is_corfunc=True,
[688d029]311                group_id=GROUP_ID_IQ_DATA, leftdown=False))
312
313    def _on_click_qrange(self, event=None):
314        if event is None:
315            return
316        event.Skip()
317        if not self._validate_inputs(): return
318        is_click = event.LeftDown()
319        if is_click:
320            from sas.sasgui.perspectives.corfunc.corfunc import GROUP_ID_IQ_DATA,\
321                IQ_DATA_LABEL
[e02d8f6]322            wx.PostEvent(self._manager.parent, PlotQrangeEvent(
323                ctrl=[self._qmin_input, self._qmax1_input, self._qmax2_input],
[77e9ac6]324                active=event.GetEventObject(), id=IQ_DATA_LABEL,
[688d029]325                group_id=GROUP_ID_IQ_DATA, leftdown=is_click))
[3901e7c]326
[b564ea2]327    def _validate_inputs(self):
[3901e7c]328        """
329        Check that the values for qmin and qmax in the input boxes are valid
330        """
331        if self._data is None:
332            return False
333        qmin_valid = check_float(self._qmin_input)
334        qmax1_valid = check_float(self._qmax1_input)
335        qmax2_valid = check_float(self._qmax2_input)
336        qmax_valid = qmax1_valid and qmax2_valid
[b564ea2]337        background_valid = check_float(self._background_input)
[3901e7c]338        msg = ""
[b564ea2]339        if (qmin_valid and qmax_valid and background_valid):
340            qmin = float(self._qmin_input.GetValue())
341            qmax1 = float(self._qmax1_input.GetValue())
342            qmax2 = float(self._qmax2_input.GetValue())
343            background = float(self._background_input.GetValue())
344            if not qmin > self._data.x.min():
345                msg = "qmin must be greater than the lowest q value"
346                qmin_valid = False
347            elif qmax2 < qmax1:
348                msg = "qmax1 must be less than qmax2"
349                qmax_valid = False
350            elif qmin > qmax1:
351                msg = "qmin must be less than qmax"
352                qmin_valid = False
[033c14c]353            elif background > self._data.y.max():
354                msg = "background must be less than highest I"
[b564ea2]355                background_valid = False
356        if not qmin_valid:
357            self._qmin_input.SetBackgroundColour('pink')
358        if not qmax_valid:
359            self._qmax1_input.SetBackgroundColour('pink')
360            self._qmax2_input.SetBackgroundColour('pink')
361        if not background_valid:
362            self._background_input.SetBackgroundColour('pink')
363            if msg != "":
364                wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
365        if (qmin_valid and qmax_valid and background_valid):
[3901e7c]366            self._qmin_input.SetBackgroundColour(wx.WHITE)
367            self._qmax1_input.SetBackgroundColour(wx.WHITE)
368            self._qmax2_input.SetBackgroundColour(wx.WHITE)
[b564ea2]369            self._background_input.SetBackgroundColour(wx.WHITE)
[3901e7c]370        self._qmin_input.Refresh()
371        self._qmax1_input.Refresh()
372        self._qmax2_input.Refresh()
[f2bbabf]373        self._background_input.Refresh()
[b564ea2]374        return (qmin_valid and qmax_valid and background_valid)
[7858575]375
[c23f303]376    def _do_layout(self):
377        """
378        Draw the window content
379        """
[7858575]380        vbox = wx.GridBagSizer(0,0)
381
382        # I(q) data box
[9f7dde3]383        databox = wx.StaticBox(self, -1, "I(Q) Data Source")
384        databox_sizer = wx.StaticBoxSizer(databox, wx.VERTICAL)
[7858575]385
[9f7dde3]386        file_sizer = wx.GridBagSizer(5, 5)
[7858575]387
388        file_name_label = wx.StaticText(self, -1, "Name:")
[9f7dde3]389        file_sizer.Add(file_name_label, (0, 0), (1, 1),
[7858575]390            wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
391
[9f7dde3]392        self._data_name_box = OutputTextCtrl(self, -1,
393            size=(300,20))
394        file_sizer.Add(self._data_name_box, (0, 1), (1, 1),
395            wx.CENTER | wx.ADJUST_MINSIZE, 15)
396
397        file_sizer.AddSpacer((1, 25), pos=(0,2))
398        databox_sizer.Add(file_sizer, wx.TOP, 15)
399
400        vbox.Add(databox_sizer, (0, 0), (1, 1),
401            wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE | wx.TOP, 15)
402
403
404        # Parameters
405        qbox = wx.StaticBox(self, -1, "Parameters")
406        qbox_sizer = wx.StaticBoxSizer(qbox, wx.VERTICAL)
407        qbox_sizer.SetMinSize((_STATICBOX_WIDTH, 75))
408
409        q_sizer = wx.GridBagSizer(5, 5)
410
411        # Explanation
412        explanation_txt = ("Corfunc will use all values in the lower range for"
413            " Guinier back extrapolation, and all values in the upper range "
414            "for Porod forward extrapolation.")
415        explanation_label = wx.StaticText(self, -1, explanation_txt,
416            size=(_STATICBOX_WIDTH, 60))
417
418        q_sizer.Add(explanation_label, (0,0), (1,4), wx.LEFT | wx.EXPAND, 5)
419
420        qrange_label = wx.StaticText(self, -1, "Q Range:", size=(50,20))
[7a219e3e]421        q_sizer.Add(qrange_label, (1,0), (1,1), wx.LEFT | wx.EXPAND, 5)
[9f7dde3]422
423        # Lower Q Range
424        qmin_label = wx.StaticText(self, -1, "Lower:", size=(50,20))
425        qmin_dash_label = wx.StaticText(self, -1, "-", size=(10,20),
426            style=wx.ALIGN_CENTER_HORIZONTAL)
427
[3560196]428        qmin_lower = OutputTextCtrl(self, -1, size=(75, 20), value="0.0")
429        self._qmin_input = ModelTextCtrl(self, -1, size=(75, 20),
[3901e7c]430                        style=wx.TE_PROCESS_ENTER, name='qmin_input',
[b564ea2]431                        text_enter_callback=self._on_enter_input)
[3901e7c]432        self._qmin_input.SetToolTipString(("Values with q < qmin will be used "
433            "for Guinier back extrapolation"))
[9f7dde3]434
[7a219e3e]435        q_sizer.Add(qmin_label, (2, 0), (1, 1), wx.LEFT | wx.EXPAND, 5)
436        q_sizer.Add(qmin_lower, (2, 1), (1, 1), wx.LEFT, 5)
437        q_sizer.Add(qmin_dash_label, (2, 2), (1, 1), wx.CENTER | wx.EXPAND, 5)
438        q_sizer.Add(self._qmin_input, (2, 3), (1, 1), wx.LEFT, 5)
[9f7dde3]439
440        # Upper Q range
441        qmax_tooltip = ("Values with qmax1 < q < qmax2 will be used for Porod"
442            " forward extrapolation")
443
444        qmax_label = wx.StaticText(self, -1, "Upper:", size=(50,20))
445        qmax_dash_label = wx.StaticText(self, -1, "-", size=(10,20),
446            style=wx.ALIGN_CENTER_HORIZONTAL)
447
[3560196]448        self._qmax1_input = ModelTextCtrl(self, -1, size=(75, 20),
[3901e7c]449            style=wx.TE_PROCESS_ENTER, name="qmax1_input",
[b564ea2]450            text_enter_callback=self._on_enter_input)
[3901e7c]451        self._qmax1_input.SetToolTipString(qmax_tooltip)
[3560196]452        self._qmax2_input = ModelTextCtrl(self, -1, size=(75, 20),
[3901e7c]453            style=wx.TE_PROCESS_ENTER, name="qmax2_input",
[b564ea2]454            text_enter_callback=self._on_enter_input)
[3901e7c]455        self._qmax2_input.SetToolTipString(qmax_tooltip)
[9f7dde3]456
[7a219e3e]457        q_sizer.Add(qmax_label, (3, 0), (1, 1), wx.LEFT | wx.EXPAND, 5)
458        q_sizer.Add(self._qmax1_input, (3, 1), (1, 1), wx.LEFT, 5)
459        q_sizer.Add(qmax_dash_label, (3, 2), (1, 1), wx.CENTER | wx.EXPAND, 5)
460        q_sizer.Add(self._qmax2_input, (3,3), (1, 1), wx.LEFT, 5)
461
462        background_label = wx.StaticText(self, -1, "Background:", size=(80,20))
463        q_sizer.Add(background_label, (4,0), (1,1), wx.LEFT | wx.EXPAND, 5)
464
[3560196]465        self._background_input = ModelTextCtrl(self, -1, size=(75,20),
[7a219e3e]466            style=wx.TE_PROCESS_ENTER, name='background_input',
467            text_enter_callback=self._on_enter_input)
468        self._background_input.SetToolTipString(("A background value to "
469            "subtract from all intensity values"))
470        q_sizer.Add(self._background_input, (4,1), (1,1),
471            wx.RIGHT, 5)
472
473        background_button = wx.Button(self, wx.NewId(), "Calculate",
474            size=(75, 20))
475        background_button.Bind(wx.EVT_BUTTON, self._compute_background)
476        q_sizer.Add(background_button, (4, 2), (1, 1), wx.RIGHT, 5)
[9f7dde3]477
478        qbox_sizer.Add(q_sizer, wx.TOP, 0)
479
480        vbox.Add(qbox_sizer, (1, 0), (1, 1),
481            wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
482
483        # Output data
484        outputbox = wx.StaticBox(self, -1, "Output Measuments")
485        outputbox_sizer = wx.StaticBoxSizer(outputbox, wx.VERTICAL)
486
487        output_sizer = wx.GridBagSizer(5, 5)
488
[033c14c]489        self._output_boxes = dict()
490        i = 0
491        for key, value in OUTPUT_STRINGS.iteritems():
[3ec4b8f]492            # Create a label and a text box for each poperty
[033c14c]493            label = wx.StaticText(self, -1, value)
494            output_box = OutputTextCtrl(self, wx.NewId(),
[9f7dde3]495                value="-", style=wx.ALIGN_CENTER_HORIZONTAL)
[3ec4b8f]496            # Save the ID of each of the text boxes for accessing after the
497            # output data has been calculated
[033c14c]498            self._output_boxes[key] = output_box
[9f7dde3]499            output_sizer.Add(label, (i, 0), (1, 1), wx.LEFT | wx.EXPAND, 15)
500            output_sizer.Add(output_box, (i, 2), (1, 1),
501                wx.RIGHT | wx.EXPAND, 15)
[033c14c]502            i += 1
[9f7dde3]503
504        outputbox_sizer.Add(output_sizer, wx.TOP, 0)
505
506        vbox.Add(outputbox_sizer, (2, 0), (1, 1),
507            wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
508
[3ec4b8f]509        # Controls
[9f7dde3]510        controlbox = wx.StaticBox(self, -1, "Controls")
511        controlbox_sizer = wx.StaticBoxSizer(controlbox, wx.VERTICAL)
512
513        controls_sizer = wx.BoxSizer(wx.VERTICAL)
514
515        extrapolate_btn = wx.Button(self, wx.NewId(), "Extrapolate")
[911dbe4]516        self._transform_btn = wx.Button(self, wx.NewId(), "Transform")
[033c14c]517        self._extract_btn = wx.Button(self, wx.NewId(), "Compute Measuments")
[911dbe4]518
519        self._transform_btn.Disable()
[033c14c]520        self._extract_btn.Disable()
[9f7dde3]521
[3b8efec]522        extrapolate_btn.Bind(wx.EVT_BUTTON, self.compute_extrapolation)
[911dbe4]523        self._transform_btn.Bind(wx.EVT_BUTTON, self.compute_transform)
[033c14c]524        self._extract_btn.Bind(wx.EVT_BUTTON, self.extract_parameters)
[3b8efec]525
[9f7dde3]526        controls_sizer.Add(extrapolate_btn, wx.CENTER | wx.EXPAND)
[911dbe4]527        controls_sizer.Add(self._transform_btn, wx.CENTER | wx.EXPAND)
[033c14c]528        controls_sizer.Add(self._extract_btn, wx.CENTER | wx.EXPAND)
[7858575]529
[9f7dde3]530        controlbox_sizer.Add(controls_sizer, wx.TOP | wx.EXPAND, 0)
531        vbox.Add(controlbox_sizer, (3, 0), (1, 1),
532            wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
[7858575]533
534        self.SetSizer(vbox)
[54a0989]535
536    def _disable_inputs(self):
[6970e51]537        """
538        Disable all input fields
539        """
[54a0989]540        self._qmin_input.Disable()
541        self._qmax1_input.Disable()
542        self._qmax2_input.Disable()
543        self._background_input.Disable()
544
545    def _enable_inputs(self):
[6970e51]546        """
547        Enable all input fields
548        """
[54a0989]549        self._qmin_input.Enable()
550        self._qmax1_input.Enable()
551        self._qmax2_input.Enable()
552        self._background_input.Enable()
Note: See TracBrowser for help on using the repository browser.