source: sasview/src/sas/sasgui/perspectives/corfunc/corfunc_panel.py @ 8bdc103

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 8bdc103 was 8bdc103, checked in by lewis, 8 years ago

Take absolute value of polydispersity

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