source: sasview/src/sas/sasgui/perspectives/corfunc/corfunc_panel.py @ 37e7223

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

Refactor plot labels into separate file

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