source: sasview/src/sas/sasgui/perspectives/corfunc/corfunc_panel.py @ 5878a9ea

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

Minor tweaks to UI and calculator behaviour

  • Property mode set to 100644
File size: 23.6 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 but zoomed in
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        # Update state of the GUI
205        self._transform_btn.Enable()
206        self._extract_btn.Disable()
207        self.set_extracted_params(reset=True)
208
209    def compute_transform(self, event=None):
210        """
211        Compute and plot the transformed data.
212        Called when Transform button is pressed.
213        """
214        if not self._calculator.transform_isrunning():
215            self._calculator.compute_transform(self._extrapolated_data,
216                self.transform_type, background=self.background,
217                completefn=self.transform_complete,
218                updatefn=self.transform_update)
219
220            self._transform_btn.SetLabel("Stop Tansform")
221        else:
222            self._calculator.stop_transform()
223            self.transform_update("Transform cancelled.")
224            self._transform_btn.SetLabel("Tansform")
225
226    def transform_update(self, msg=""):
227        """
228        Called from FourierThread to update on status of calculation
229        """
230        wx.PostEvent(self._manager.parent,
231            StatusEvent(status=msg))
232
233    def transform_complete(self, transform=None):
234        """
235        Called from FourierThread when calculation has completed
236        """
237        self._transform_btn.SetLabel("Tansform")
238        if transform is None:
239            msg = "Error calculating Transform."
240            if self.transform_type == 'hilbert':
241                msg = "Not yet implemented"
242            wx.PostEvent(self._manager.parent,
243                StatusEvent(status=msg, info="Error"))
244            self._extract_btn.Disable()
245            return
246        self._transformed_data = transform
247        import numpy as np
248        plot_x = transform.x[np.where(transform.x <= 200)]
249        plot_y = transform.y[np.where(transform.x <= 200)]
250        self._manager.show_data(Data1D(plot_x, plot_y), TRANSFORM_LABEL)
251        # Only enable extract params button if a fourier trans. has been done
252        if self.transform_type == 'fourier':
253            self._extract_btn.Enable()
254        else:
255            self._extract_btn.Disable()
256
257    def extract_parameters(self, event=None):
258        try:
259            params = self._calculator.extract_parameters(self._transformed_data)
260        except:
261            params = None
262        if params is None:
263            msg = "Error extracting parameters."
264            wx.PostEvent(self._manager.parent,
265                StatusEvent(status=msg, info="Error"))
266            return
267        self.set_extracted_params(params)
268
269    def save_project(self, doc=None):
270        """
271        Return an XML node containing the state of the panel
272
273        :param doc: Am xml node to attach the project state to (optional)
274        """
275        data = self._data
276        state = self.get_state()
277        if data is not None:
278            new_doc, sasentry = self._manager.state_reader._to_xml_doc(data)
279            new_doc = state.toXML(doc=new_doc, entry_node=sasentry)
280            if new_doc is not None:
281                if doc is not None and hasattr(doc, "firstChild"):
282                    child = new_doc.getElementsByTagName("SASentry")
283                    for item in child:
284                        doc.firstChild.appendChild(item)
285                else:
286                    doc = new_doc
287        return doc
288
289    def set_qmin(self, qmin):
290        self.qmin = qmin
291        self._qmin_input.SetValue(str(qmin))
292
293    def set_qmax(self, qmax):
294        self.qmax = qmax
295        self._qmax1_input.SetValue(str(qmax[0]))
296        self._qmax2_input.SetValue(str(qmax[1]))
297
298    def set_background(self, bg):
299        self.background = bg
300        self._background_input.SetValue(str(bg))
301        self._calculator.background = bg
302
303    def set_extracted_params(self, params=None, reset=False):
304        self.extracted_params = params
305        error = False
306        if params is None:
307            if not reset: error = True
308            for key in OUTPUT_STRINGS.keys():
309                self._output_boxes[key].SetValue('-')
310        else:
311            if len(params) < len(OUTPUT_STRINGS):
312                # Not all parameters were calculated
313                error = True
314            for key, value in params.iteritems():
315                self._output_boxes[key].SetValue(value)
316        if error:
317            msg = 'Not all parameters were able to be calculated'
318            wx.PostEvent(self._manager.parent, StatusEvent(
319                status=msg, info='error'))
320
321
322    def plot_qrange(self, active=None, leftdown=False):
323        if active is None:
324            active = self._qmin_input
325        wx.PostEvent(self._manager.parent, PlotQrangeEvent(
326            ctrl=[self._qmin_input, self._qmax1_input, self._qmax2_input],
327            active=active, id=IQ_DATA_LABEL, is_corfunc=True,
328            group_id=GROUP_ID_IQ_DATA, leftdown=leftdown))
329
330
331    def _compute_background(self, event=None):
332        self.set_background(self._calculator.compute_background(self.qmax))
333
334    def _on_enter_input(self, event=None):
335        """
336        Read values from input boxes and save to memory.
337        """
338        if event is not None: event.Skip()
339        if not self._validate_inputs():
340            return
341        self.qmin = float(self._qmin_input.GetValue())
342        new_qmax1 = float(self._qmax1_input.GetValue())
343        new_qmax2 = float(self._qmax2_input.GetValue())
344        self.qmax = (new_qmax1, new_qmax2)
345        self.background = float(self._background_input.GetValue())
346        self._calculator.background = self.background
347        if event is not None:
348            active_ctrl = event.GetEventObject()
349            if active_ctrl == self._background_input:
350                self._manager.show_data(self._data, IQ_DATA_LABEL,
351                    reset=False, active_ctrl=active_ctrl)
352
353    def _on_click_qrange(self, event=None):
354        if event is None:
355            return
356        event.Skip()
357        if not self._validate_inputs(): return
358        self.plot_qrange(active=event.GetEventObject(),
359            leftdown=event.LeftDown())
360
361    def _validate_inputs(self):
362        """
363        Check that the values for qmin and qmax in the input boxes are valid
364        """
365        if self._data is None:
366            return False
367        qmin_valid = check_float(self._qmin_input)
368        qmax1_valid = check_float(self._qmax1_input)
369        qmax2_valid = check_float(self._qmax2_input)
370        qmax_valid = qmax1_valid and qmax2_valid
371        background_valid = check_float(self._background_input)
372        msg = ""
373        if (qmin_valid and qmax_valid and background_valid):
374            qmin = float(self._qmin_input.GetValue())
375            qmax1 = float(self._qmax1_input.GetValue())
376            qmax2 = float(self._qmax2_input.GetValue())
377            background = float(self._background_input.GetValue())
378            if not qmin > self._data.x.min():
379                msg = "qmin must be greater than the lowest q value"
380                qmin_valid = False
381            elif qmax2 < qmax1:
382                msg = "qmax1 must be less than qmax2"
383                qmax_valid = False
384            elif qmin > qmax1:
385                msg = "qmin must be less than qmax"
386                qmin_valid = False
387            elif background > self._data.y.max():
388                msg = "background must be less than highest I"
389                background_valid = False
390        if not qmin_valid:
391            self._qmin_input.SetBackgroundColour('pink')
392        if not qmax_valid:
393            self._qmax1_input.SetBackgroundColour('pink')
394            self._qmax2_input.SetBackgroundColour('pink')
395        if not background_valid:
396            self._background_input.SetBackgroundColour('pink')
397            if msg != "":
398                wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
399        if (qmin_valid and qmax_valid and background_valid):
400            self._qmin_input.SetBackgroundColour(wx.WHITE)
401            self._qmax1_input.SetBackgroundColour(wx.WHITE)
402            self._qmax2_input.SetBackgroundColour(wx.WHITE)
403            self._background_input.SetBackgroundColour(wx.WHITE)
404        self._qmin_input.Refresh()
405        self._qmax1_input.Refresh()
406        self._qmax2_input.Refresh()
407        self._background_input.Refresh()
408        return (qmin_valid and qmax_valid and background_valid)
409
410    def _do_layout(self):
411        """
412        Draw the window content
413        """
414        vbox = wx.GridBagSizer(0,0)
415
416        # I(q) data box
417        databox = wx.StaticBox(self, -1, "I(Q) Data Source")
418        databox_sizer = wx.StaticBoxSizer(databox, wx.VERTICAL)
419
420        file_sizer = wx.GridBagSizer(5, 5)
421
422        file_name_label = wx.StaticText(self, -1, "Name:")
423        file_sizer.Add(file_name_label, (0, 0), (1, 1),
424            wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
425
426        self._data_name_box = OutputTextCtrl(self, -1,
427            size=(300,20))
428        file_sizer.Add(self._data_name_box, (0, 1), (1, 1),
429            wx.CENTER | wx.ADJUST_MINSIZE, 15)
430
431        file_sizer.AddSpacer((1, 25), pos=(0,2))
432        databox_sizer.Add(file_sizer, wx.TOP, 15)
433
434        vbox.Add(databox_sizer, (0, 0), (1, 1),
435            wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE | wx.TOP, 15)
436
437
438        # Parameters
439        qbox = wx.StaticBox(self, -1, "Input Parameters")
440        qbox_sizer = wx.StaticBoxSizer(qbox, wx.VERTICAL)
441        qbox_sizer.SetMinSize((_STATICBOX_WIDTH, 75))
442
443        q_sizer = wx.GridBagSizer(5, 5)
444
445        # Explanation
446        explanation_txt = ("Corfunc will use all values in the lower range for"
447            " Guinier back extrapolation, and all values in the upper range "
448            "for Porod forward extrapolation.")
449        explanation_label = wx.StaticText(self, -1, explanation_txt,
450            size=(_STATICBOX_WIDTH, 60))
451
452        q_sizer.Add(explanation_label, (0,0), (1,4), wx.LEFT | wx.EXPAND, 5)
453
454        qrange_label = wx.StaticText(self, -1, "Q Range:", size=(50,20))
455        q_sizer.Add(qrange_label, (1,0), (1,1), wx.LEFT | wx.EXPAND, 5)
456
457        # Lower Q Range
458        qmin_label = wx.StaticText(self, -1, "Lower:", size=(50,20))
459        qmin_dash_label = wx.StaticText(self, -1, "-", size=(10,20),
460            style=wx.ALIGN_CENTER_HORIZONTAL)
461
462        qmin_lower = OutputTextCtrl(self, -1, size=(75, 20), value="0.0")
463        self._qmin_input = ModelTextCtrl(self, -1, size=(75, 20),
464                        style=wx.TE_PROCESS_ENTER, name='qmin_input',
465                        text_enter_callback=self._on_enter_input)
466        self._qmin_input.SetToolTipString(("Values with q < qmin will be used "
467            "for Guinier back extrapolation"))
468
469        q_sizer.Add(qmin_label, (2, 0), (1, 1), wx.LEFT | wx.EXPAND, 5)
470        q_sizer.Add(qmin_lower, (2, 1), (1, 1), wx.LEFT, 5)
471        q_sizer.Add(qmin_dash_label, (2, 2), (1, 1), wx.CENTER | wx.EXPAND, 5)
472        q_sizer.Add(self._qmin_input, (2, 3), (1, 1), wx.LEFT, 5)
473
474        # Upper Q range
475        qmax_tooltip = ("Values with qmax1 < q < qmax2 will be used for Porod"
476            " forward extrapolation")
477
478        qmax_label = wx.StaticText(self, -1, "Upper:", size=(50,20))
479        qmax_dash_label = wx.StaticText(self, -1, "-", size=(10,20),
480            style=wx.ALIGN_CENTER_HORIZONTAL)
481
482        self._qmax1_input = ModelTextCtrl(self, -1, size=(75, 20),
483            style=wx.TE_PROCESS_ENTER, name="qmax1_input",
484            text_enter_callback=self._on_enter_input)
485        self._qmax1_input.SetToolTipString(qmax_tooltip)
486        self._qmax2_input = ModelTextCtrl(self, -1, size=(75, 20),
487            style=wx.TE_PROCESS_ENTER, name="qmax2_input",
488            text_enter_callback=self._on_enter_input)
489        self._qmax2_input.SetToolTipString(qmax_tooltip)
490
491        q_sizer.Add(qmax_label, (3, 0), (1, 1), wx.LEFT | wx.EXPAND, 5)
492        q_sizer.Add(self._qmax1_input, (3, 1), (1, 1), wx.LEFT, 5)
493        q_sizer.Add(qmax_dash_label, (3, 2), (1, 1), wx.CENTER | wx.EXPAND, 5)
494        q_sizer.Add(self._qmax2_input, (3,3), (1, 1), wx.LEFT, 5)
495
496        background_label = wx.StaticText(self, -1, "Background:", size=(80,20))
497        q_sizer.Add(background_label, (4,0), (1,1), wx.LEFT | wx.EXPAND, 5)
498
499        self._background_input = ModelTextCtrl(self, -1, size=(75,20),
500            style=wx.TE_PROCESS_ENTER, name='background_input',
501            text_enter_callback=self._on_enter_input)
502        self._background_input.SetToolTipString(("A background value to "
503            "subtract from all intensity values"))
504        q_sizer.Add(self._background_input, (4,1), (1,1),
505            wx.RIGHT, 5)
506
507        background_button = wx.Button(self, wx.NewId(), "Calculate",
508            size=(75, 20))
509        background_button.Bind(wx.EVT_BUTTON, self._compute_background)
510        q_sizer.Add(background_button, (4, 2), (1, 1), wx.RIGHT, 5)
511
512        qbox_sizer.Add(q_sizer, wx.TOP, 0)
513
514        vbox.Add(qbox_sizer, (1, 0), (1, 1),
515            wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
516
517        # Transform type
518        transform_box = wx.StaticBox(self, -1, "Transform Type")
519        transform_sizer = wx.StaticBoxSizer(transform_box, wx.VERTICAL)
520
521        radio_sizer = wx.GridBagSizer(5,5)
522
523        fourier_btn = wx.RadioButton(self, -1, "Fourier", name='fourier',
524            style=wx.RB_GROUP)
525        hilbert_btn = wx.RadioButton(self, -1, "Hilbert", name='hilbert')
526
527        fourier_btn.Bind(wx.EVT_RADIOBUTTON, self.radio_changed)
528        hilbert_btn.Bind(wx.EVT_RADIOBUTTON, self.radio_changed)
529
530        radio_sizer.Add(fourier_btn, (0,0), (1,1), wx.LEFT | wx.EXPAND)
531        radio_sizer.Add(hilbert_btn, (0,1), (1,1), wx.RIGHT | wx.EXPAND)
532
533        transform_sizer.Add(radio_sizer, wx.TOP, 0)
534        vbox.Add(transform_sizer, (2, 0), (1, 1),
535            wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
536
537        # Output data
538        outputbox = wx.StaticBox(self, -1, "Output Parameters")
539        outputbox_sizer = wx.StaticBoxSizer(outputbox, wx.VERTICAL)
540
541        output_sizer = wx.GridBagSizer(5, 5)
542
543        self._output_boxes = dict()
544        i = 0
545        for key, value in OUTPUT_STRINGS.iteritems():
546            # Create a label and a text box for each poperty
547            label = wx.StaticText(self, -1, value)
548            output_box = OutputTextCtrl(self, wx.NewId(),
549                value="-", style=wx.ALIGN_CENTER_HORIZONTAL)
550            # Save the ID of each of the text boxes for accessing after the
551            # output data has been calculated
552            self._output_boxes[key] = output_box
553            output_sizer.Add(label, (i, 0), (1, 1), wx.LEFT | wx.EXPAND, 15)
554            output_sizer.Add(output_box, (i, 2), (1, 1),
555                wx.RIGHT | wx.EXPAND, 15)
556            i += 1
557
558        outputbox_sizer.Add(output_sizer, wx.TOP, 0)
559
560        vbox.Add(outputbox_sizer, (3, 0), (1, 1),
561            wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
562
563        # Controls
564        controlbox = wx.StaticBox(self, -1, "Controls")
565        controlbox_sizer = wx.StaticBoxSizer(controlbox, wx.VERTICAL)
566
567        controls_sizer = wx.BoxSizer(wx.VERTICAL)
568
569        extrapolate_btn = wx.Button(self, wx.NewId(), "Extrapolate")
570        self._transform_btn = wx.Button(self, wx.NewId(), "Transform")
571        self._extract_btn = wx.Button(self, wx.NewId(), "Compute Parameters")
572
573        self._transform_btn.Disable()
574        self._extract_btn.Disable()
575
576        extrapolate_btn.Bind(wx.EVT_BUTTON, self.compute_extrapolation)
577        self._transform_btn.Bind(wx.EVT_BUTTON, self.compute_transform)
578        self._extract_btn.Bind(wx.EVT_BUTTON, self.extract_parameters)
579
580        controls_sizer.Add(extrapolate_btn, wx.CENTER | wx.EXPAND)
581        controls_sizer.Add(self._transform_btn, wx.CENTER | wx.EXPAND)
582        controls_sizer.Add(self._extract_btn, wx.CENTER | wx.EXPAND)
583
584        controlbox_sizer.Add(controls_sizer, wx.TOP | wx.EXPAND, 0)
585        vbox.Add(controlbox_sizer, (4, 0), (1, 1),
586            wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
587
588        self.SetSizer(vbox)
589
590    def _disable_inputs(self):
591        """
592        Disable all input fields
593        """
594        self._qmin_input.Disable()
595        self._qmax1_input.Disable()
596        self._qmax2_input.Disable()
597        self._background_input.Disable()
598
599    def _enable_inputs(self):
600        """
601        Enable all input fields
602        """
603        self._qmin_input.Enable()
604        self._qmax1_input.Enable()
605        self._qmax2_input.Enable()
606        self._background_input.Enable()
Note: See TracBrowser for help on using the repository browser.