source: sasview/theoryview/perspectives/theory/model_panel.py @ 535752b

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 535752b was d7b7156, checked in by Jae Cho <jhjcho@…>, 14 years ago

updated the titles of polydisp. and params due to the changes of unit

  • Property mode set to 100644
File size: 32.4 KB
Line 
1
2import wx
3import wx.lib.newevent
4import numpy
5import copy
6import math
7from sans.models.dispersion_models import ArrayDispersion, GaussianDispersion
8
9from sans.guicomm.events import StatusEvent   
10from sans.guiframe.utils import format_number
11(ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent()
12_BOX_WIDTH = 76
13
14import basepage
15from basepage import BasicPage
16from basepage import PageInfoEvent
17
18class ModelPanel(BasicPage):
19    """
20    FitPanel class contains fields allowing to display results when
21    fitting  a model and one data
22   
23    :note: For Fit to be performed the user should check at least
24        one parameter on fit Panel window.
25    """
26    ## Flag to tell the AUI manager to put this panel in the center pane
27    CENTER_PANE = True
28    ## Internal name for the AUI manager
29    window_name = "Theory model"
30    ## Title to appear on top of the window
31    window_caption = "Theory Model"
32    def __init__(self,parent, page_info, model_list_box):
33        BasicPage.__init__(self, parent, page_info , model_list_box)
34        """
35        Initialization of the Panel
36        """
37        self._fill_model_sizer( self.sizer1) 
38        self._fill_range_sizer()
39        self.engine_type = None 
40         
41        description=""
42        if self.model!=None:
43           
44            description = self.model.description
45           
46            self.select_model(self.model)
47            self.set_model_description(description,self.sizer2)
48           
49    def _on_display_description(self, event):
50        """
51        Show or Hide description
52       
53        :param event: wx.EVT_RADIOBUTTON
54       
55        """
56        self._on_display_description_helper()
57       
58        self.SetScrollbars(20,20,25,65)
59        self.Refresh()
60
61    def _on_display_description_helper(self):
62        """
63        Show or Hide description
64       
65        :param event: wx.EVT_RADIOBUTTON
66       
67        """
68        ## Show description
69        if self.description_hide.GetValue():
70            self.sizer_description.Clear(True)
71           
72        else:
73            description="Model contains no description"
74            if self.model!=None:
75                description = self.model.description
76            if description.lstrip().rstrip() =="": 
77                description="Model contains no description"
78            self.description = wx.StaticText( self,-1,str(description) )
79            self.sizer_description.Add( self.description, 1, wx.EXPAND | wx.ALL, 10 )
80           
81        self.Layout()
82   
83   
84    def _fill_range_sizer(self):
85        """
86        Fill the sizer containing the plotting range
87        add  access to npts
88       
89        """
90        ##The following 3 lines are for Mac. Let JHC know before modifying..
91        title = "Plotted Q Range"
92        box_description= wx.StaticBox(self, -1,str(title))
93        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
94
95        sizer_npts= wx.GridSizer(1, 1,5, 5)   
96        self.npts    = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)
97        self.npts.SetValue(format_number(self.num_points))
98        self.npts.SetToolTipString("Number of point to plot.")
99       
100        sizer_npts.Add(wx.StaticText(self, -1, 'Npts'),1, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 13)       
101
102        sizer_npts.Add(self.npts,1,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
103        self._set_range_sizer( title=title, box_sizer=boxsizer1, object= sizer_npts)
104       
105       
106    def _on_select_model(self, event): 
107        """
108        call back for model selection
109       
110        """   
111        self._on_select_model_helper() 
112        #Reset dispersity that was not done in _on_select_model_helper()
113        self._reset_dispersity()
114        self.select_model(self.model)
115       
116       
117    def _fill_model_sizer(self, sizer):
118        """
119        fill sizer containing model info
120       
121        """
122        ##The following 3 lines are for Mac. Let JHC know before modifying..
123        title = "Model"
124        box_description= wx.StaticBox(self, -1,str(title))
125        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
126       
127        id = wx.NewId()
128        self.model_view =wx.Button(self,id,'View 2D', size=(80,23))
129        self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D,id=id)
130        self.model_view.SetToolTipString("View model in 2D")
131       
132        ## class base method  to add view 2d button   
133        self._set_model_sizer(sizer=sizer,box_sizer=boxsizer1, title=title,object= self.model_view )   
134   
135 
136    #def _set_sizer_gaussian(self):
137    def _set_sizer_dispersion(self, dispersity):
138        """
139        draw sizer with gaussian, log or schulz dispersity parameters
140       
141        """
142        self.fittable_param=[]
143        self.fixed_param=[]
144        self.orientation_params_disp=[]
145        #self.temp=[]
146       
147        self.sizer4_4.Clear(True)
148        if self.model==None:
149            ##no model is selected
150            return
151        if not self.enable_disp.GetValue():
152            ## the user didn't select dispersity display
153            return 
154        self._reset_dispersity()
155        # Create the dispersion objects
156        for item in self.model.dispersion.keys():
157            #disp_model =  GaussianDispersion()
158            disp_model = dispersity()
159            self._disp_obj_dict[item] = disp_model
160            self.model.set_dispersion(item, disp_model)
161            self.state._disp_obj_dict[item]= disp_model
162           
163           
164        ix=0
165        iy=1
166        disp = wx.StaticText(self, -1, ' ')
167        self.sizer4_4.Add(disp,( iy, ix),(1,1), 
168                           wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
169        ix += 1 
170        values = wx.StaticText(self, -1, 'Sigma [A]')
171        values.SetToolTipString(\
172        "Sigma(STD) in the A unit; the standard deviation from the mean value.")
173
174        self.sizer4_4.Add(values,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 
175                          0)
176       
177        ix += 1 
178        npts = wx.StaticText(self, -1, 'Npts')
179        npts.SetToolTipString("Number of sampling points for the numerical\n\
180        integration over the distribution function.")
181        self.sizer4_4.Add(npts,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
182        ix += 1 
183        nsigmas = wx.StaticText(self, -1, 'Nsigmas')
184        nsigmas.SetToolTipString("   Number of sigmas between which the range\n\
185         of the distribution function will be used for weighting. \n\
186        The value '3' covers 99.5% for Gaussian distribution \n\
187        function.")
188        self.sizer4_4.Add(nsigmas,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE,
189                           0)
190         
191        for item in self.model.dispersion.keys():
192            if not item in self.model.orientation_params:
193                self.disp_cb_dict[item]= None
194                name0="Distribution of " + item
195                name1=item+".width"
196                name2=item+".npts"
197                name3=item+".nsigmas"
198                iy += 1
199                for p in self.model.dispersion[item].keys():
200                    if p=="width":
201                        ix = 0
202                        name = wx.StaticText(self, -1,  name0)
203                        self.sizer4_4.Add( name,( iy, ix),(1,1), 
204                                           wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
205                        ix = 1
206                        value= self.model.getParam(name1)
207                        ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
208                                            style=wx.TE_PROCESS_ENTER)
209                        ctl1.SetToolTipString("Absolute Sigma: \n\
210                        1) It is the STD (ratio*mean) of '%s' distribution.\n \
211                        2) It should not exceed Mean/(2*Nsigmas)." %item)
212                        ctl1.SetValue(str (format_number(value)))
213                        self.sizer4_4.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
214                        self.fittable_param.append([None,name1,ctl1,None,
215                                                    None, None, None,None])
216                    elif p=="npts":
217                            ix =2
218                            value= self.model.getParam(name2)
219                            Tctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),
220                                                style=wx.TE_PROCESS_ENTER)
221                           
222                            Tctl1.SetValue(str (format_number(value)))
223                            self.sizer4_4.Add(Tctl1, (iy,ix),(1,1),
224                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
225                            self.fixed_param.append([None,name2, Tctl1,None,None,
226                                                      None, None,None])
227                    elif p=="nsigmas":
228                            ix =3 
229                            value= self.model.getParam(name3)
230                            Tctl2 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),
231                                                style=wx.TE_PROCESS_ENTER)
232                           
233                            Tctl2.SetValue(str (format_number(value)))
234                            self.sizer4_4.Add(Tctl2, (iy,ix),(1,1),
235                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
236                            ix +=1
237                            self.sizer4_4.Add((20,20), (iy,ix),(1,1),
238                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
239                            self.fixed_param.append([None,name3, Tctl2,
240                                                     None,None, None, None,None])
241        first_orient  = True
242        for item in self.model.dispersion.keys():
243            if item in self.model.orientation_params:
244                self.disp_cb_dict[item]= None
245                name0="Distribution of " + item
246                name1=item+".width"
247                name2=item+".npts"
248                name3=item+".nsigmas"
249                iy += 1
250                for p in self.model.dispersion[item].keys():
251                    if p=="width":
252                        ix = 0
253                        name = wx.StaticText(self, -1,  name0)
254                        self.sizer4_4.Add( name,( iy, ix),(1,1), 
255                                           wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
256                        if not self.enable2D:
257                            name.Hide()
258                        else:
259                            name.Show(True)
260                        ix = 1
261                        value= self.model.getParam(name1)
262                        ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
263                                            style=wx.TE_PROCESS_ENTER)
264                        ctl1.SetToolTipString("Absolute Sigma: \n\
265                        1) It is the STD (ratio*mean) of '%s' distribution."% \
266                        item)
267                        ctl1.SetValue(str (format_number(value)))
268                        if not self.enable2D:
269                            ctl1.Hide()
270                            ctl1.Disable()
271                        else:
272                            # in the case of 2D and angle parameter
273                            if first_orient:
274                                values.SetLabel('Sigma [A (or deg)]')
275                                values.SetToolTipString(\
276                                "Sigma(STD) in the A or deg(for angles) unit;\n\
277                                the standard deviation from the mean value.")
278                                first_orient = False 
279                            ctl1.Show(True)
280                            ctl1.Enable()
281                        self.sizer4_4.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
282                        self.fittable_param.append([None,name1,ctl1,None,
283                                                    None, None, None,None])
284                        self.orientation_params_disp.append([None,name1,ctl1,None,
285                                                    None, None, None,None])
286                    elif p=="npts":
287                            ix =2
288                            value= self.model.getParam(name2)
289                            Tctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),
290                                                style=wx.TE_PROCESS_ENTER)
291
292                            Tctl1.SetValue(str (format_number(value)))
293                            if not self.enable2D:
294                                Tctl1.Hide()
295                                Tctl1.Disable()
296                            else:
297                                Tctl1.Show(True)
298                                Tctl1.Enable()
299                            self.sizer4_4.Add(Tctl1, (iy,ix),(1,1),
300                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
301                            self.fixed_param.append([None,name2, Tctl1,None,None,
302                                                      None, None,None])
303                            self.orientation_params_disp.append([None,name2, Tctl1,None,None,
304                                                      None, None,None])
305                    elif p=="nsigmas":
306                            ix =3 
307                            value= self.model.getParam(name3)
308                            Tctl2 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),
309                                                style=wx.TE_PROCESS_ENTER)
310                           
311                            Tctl2.SetValue(str (format_number(value)))
312                            if not self.enable2D:
313                                Tctl2.Hide()
314                                Tctl2.Disable()
315                            else:
316                                Tctl2.Show(True)
317                                Tctl2.Enable()
318                            self.sizer4_4.Add(Tctl2, (iy,ix),(1,1),
319                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
320                            ix +=1
321                            #self.sizer4_4.Add((20,20), (iy,ix),(1,1),
322                                               #wx.EXPAND|wx.ADJUST_MINSIZE, 0)
323                            self.fixed_param.append([None,name3, Tctl2,
324                                                     None,None, None, None,None])
325                            self.orientation_params_disp.append([None,name3, Tctl2,
326                                                     None,None, None, None,None])
327         
328        msg = " Selected Distribution: Gaussian"       
329        wx.PostEvent(self.parent, StatusEvent( status= msg )) 
330        self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict)   
331        ix =0
332        iy +=1 
333        #self.sizer4_4.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)   
334        self.sizer4_4.Layout()
335        self.sizer4.Layout()
336        self.SetScrollbars(20,20,25,65)
337             
338 
339    def _onModel2D(self, event):
340        """
341        call manager to plot model in 2D
342       
343        """
344        # If the 2D display is not currently enabled, plot the model in 2D
345        # and set the enable2D flag.
346
347        if self.fitrange:
348            self.enable2D = True
349 
350        if self.enable2D:
351            self._draw_model()
352            self.model_view.Disable()
353           
354            n = self.disp_box.GetCurrentSelection()
355            dispersity= self.disp_box.GetClientData(n)
356            #TODO:Find a better way to reinitialize the parameters containers
357            # when resetting the page and 2D view is enable
358            #self.set_model_param_sizer(self.model): called here is using a lot
359            #of for loops and redraw the sizer again .How to avoid it?
360            self.set_model_param_sizer(self.model)
361           
362            if len(self.orientation_params)>0:
363                for item in self.orientation_params:
364                    if item[2]!=None:     
365                        item[2].Enable()
366            # same as above why do we have to redraw the sizer of dispersity to get
367            # the appropriate value of parameters containers on reset page?
368            # Reset containers of dispersity parameters for the appropriate dispersity
369            #and model
370            if  self.disp_name.lower()in ["array","arraydispersion"]:               
371                self._set_sizer_arraydispersion() 
372            else:
373                self._set_sizer_dispersion(dispersity)
374                if len(self.orientation_params_disp)>0:
375                   
376                    for item in self.orientation_params_disp:
377                        if item[2]!=None:
378                            item[2].Enable()
379                           
380        self.state.enable2D =  copy.deepcopy(self.enable2D)
381        self.Layout()
382        ## post state to fit panel
383        #self._undo.Enable(True)
384        event = PageInfoEvent(page = self)
385        wx.PostEvent(self.parent, event)
386       
387    def _set_fun_box_list(self,fun_box):
388        """
389        Set the list of func for multifunctional models
390       
391        :param fun_box: function combo box
392        """
393        # Check if it is multi_functional model
394        if self.model.__class__ not in self.model_list_box["Multi-Functions"]:
395            return None
396        # Get the func name list
397        list = self.model.fun_list
398       
399        if len(list) == 0:
400            return None
401
402        # build function (combo)box
403        ind = 0
404        while(ind < len(list)):
405            for key, val in list.iteritems():
406                if (val == ind):
407                    fun_box.Append(key,val)
408                    break
409            ind += 1
410           
411    def _on_fun_box(self,event):
412        """
413        Select an func: Erf,Rparabola,LParabola...
414        """
415        fun_val = None
416        fun_box = event.GetEventObject()
417        name = fun_box.Name
418        value = fun_box.GetValue()
419        if self.model.fun_list.has_key(value):
420            fun_val = self.model.fun_list[value]
421       
422        self.model.setParam(name,fun_val)
423        # save state
424        self._copy_parameters_state(self.str_parameters, self.state.str_parameters)
425        # update params
426        #self._update_paramv_on_fit()
427
428        # draw
429        self._draw_model()
430        self.Refresh()
431        # get ready for new event
432        event.Skip()
433             
434    def set_data(self, list=[], state=None):
435        """
436        Receive  a list of data from gui_manager to plot theory
437        """
438        pass
439     
440    def reset_page(self, state):
441        """
442        reset the state
443       
444        """
445        self.reset_page_helper(state)
446       
447       
448    def select_model(self, model):
449        """
450        Select a new model
451       
452        :param model: model object
453       
454        """
455        self.model = model
456        if self.model !=None:
457            self.disp_list= self.model.getDispParamList()
458        self.set_model_param_sizer(self.model)
459        ## keep the sizer view consistent with the model menu selecting
460        self._set_model_sizer_selection( self.model )
461        self.enable_disp.SetValue(False)
462        self.disable_disp.SetValue(True)
463        self.set_dispers_sizer()
464       
465        self.model_view.SetFocus()
466        if self.model !=None:
467            self._draw_model()
468        self.state.structurecombobox = self.structurebox.GetCurrentSelection()
469        self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection()
470       
471        ## post state to fit panel
472        #self._undo.Enable(True)
473        event = PageInfoEvent(page = self)
474        wx.PostEvent(self.parent, event)               
475   
476   
477    def set_model_description(self,description,sizer):
478        """
479        fill a sizer with description
480       
481        :param description: of type string
482        :param sizer: wx.BoxSizer()
483       
484        """
485   
486        sizer.Clear(True)
487        box_description= wx.StaticBox(self, -1, 'Model Description')
488        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
489
490        sizer_selection=wx.BoxSizer(wx.HORIZONTAL)
491        self.description_hide = wx.RadioButton(self, -1, 'Hide', style=wx.RB_GROUP)
492        self.description_show = wx.RadioButton(self, -1, 'Show')
493       
494       
495        if description=="":
496            self.description_hide.SetValue(True)
497            description=" Description unavailable. Click for details"
498           
499        self.description = wx.StaticText( self,-1,str(description) )
500       
501        self.Bind( wx.EVT_RADIOBUTTON, self._on_display_description,
502                   id=self.description_hide.GetId() )
503       
504        self.Bind( wx.EVT_RADIOBUTTON, self._on_display_description,
505                   id=self.description_show.GetId() )
506        #MAC needs SetValue
507        self.description_hide.SetValue(True)
508       
509        self.model_description = wx.Button(self,-1, label="Details", size=(80,23))
510       
511        self.model_description.Bind(wx.EVT_BUTTON,self.on_button_clicked)
512        self.model_description.SetToolTipString("Click Model Functions in HelpWindow...")
513        self.model_description.SetFocus()
514        sizer_selection.Add( self.description_show )
515        sizer_selection.Add( (20,20)) 
516        sizer_selection.Add( self.description_hide )
517        sizer_selection.Add((20,20),0, wx.LEFT|wx.RIGHT|wx.EXPAND,75)
518        sizer_selection.Add( self.model_description )
519                     
520         
521        self.sizer_description=wx.BoxSizer(wx.HORIZONTAL)
522        self.sizer_description.Add( self.description, 1, wx.EXPAND | wx.ALL, 10 )
523        boxsizer1.Add( sizer_selection) 
524        boxsizer1.Add( (20,20)) 
525        boxsizer1.Add( self.sizer_description) 
526   
527        self._on_display_description(event=None)
528        sizer.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
529        sizer.Layout()
530   
531    def on_button_clicked(self,event):
532        """
533        On 'More details' button
534        """
535        from help_panel import  HelpWindow
536       
537        if self.model == None:
538            name = 'FuncHelp'
539        else:
540            name = self.model.name
541        frame = HelpWindow(None, -1,  pageToOpen="media/model_functions.html")   
542        frame.Show(True)
543        if frame.rhelp.HasAnchor(name):
544            frame.rhelp.ScrollToAnchor(name)
545        else:
546           msg= "Model does not contains an available description "
547           msg +="Please.Search in the Help window"
548           wx.PostEvent(self.parent, StatusEvent(status = msg ))
549                     
550    def set_range(self, qmin_x, qmax_x, npts):
551        """
552        Set the range for the plotted models
553       
554        :param qmin: minimum Q
555        :param qmax: maximum Q
556        :param npts: number of Q bins
557       
558        """
559        # Set the data members
560        self.qmin_x = qmin_x
561        self.qmax_x = qmax_x
562        self.num_points = npts
563        # Set the controls
564        #For qmin and qmax, do not use format_number.(If do, qmin and max could be different from what is in the data.)
565        self.qmin.SetValue(str(self.qmin_x))
566        self.qmax.SetValue(str(self.qmax_x))
567        self.npts.SetValue(format_number(self.num_points))
568       
569    def set_model_param_sizer(self, model):
570        """
571        Build the panel from the model content
572       
573        :param model: the model selected in combo box for fitting purpose
574       
575        """
576        self.sizer3.Clear(True)
577        self.parameters = []
578        self.str_parameters = []
579        self.param_toFit=[]
580        self.fixed_param=[]
581        self.orientation_params=[]
582        self.orientation_params_disp=[]
583        #self.temp=[]
584        if model ==None:
585            ##no model avaiable to draw sizer
586            self.sizer3.Layout()
587            self.SetScrollbars(20,20,25,65)
588            return
589        box_description= wx.StaticBox(self, -1,str("Model Parameters"))
590        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
591        sizer = wx.GridBagSizer(5,5)
592       
593        self.model = model
594        self.set_model_description(self.model.description,self.sizer2)
595       
596        keys = self.model.getParamList()
597        ##list of dispersion parameters
598        self.disp_list=self.model.getDispParamList()
599       
600        def custom_compare(a,b):
601            """
602            Custom compare to order, first by alphabets then second by number.
603            """ 
604            # number at the last digit
605            a_last = a[len(a)-1]
606            b_last = b[len(b)-1]
607            # default
608            num_a = None
609            num_b = None
610            # split the names
611            a2 = a.lower().split('_')
612            b2 = b.lower().split('_')
613            # check length of a2, b2
614            len_a2 = len(a2)
615            len_b2 = len(b2)
616            # check if it contains a int number(<10)
617            try: 
618                num_a = int(a_last)
619            except: pass
620            try:
621                num_b = int(b_last)
622            except: pass
623            # Put 'scale' near the top; happens
624            # when numbered param name exists
625            if a == 'scale':
626                return -1
627            # both have a number   
628            if num_a != None and num_b != None:
629                if num_a > num_b: return -1
630                # same number
631                elif num_a == num_b: 
632                    # different last names
633                    if a2[len_a2-1] != b2[len_b2-1] and num_a != 0:
634                        return -cmp(a2[len_a2-1], b2[len_b2-1])
635                    else: 
636                        return cmp(a, b) 
637                else: return 1
638            # one of them has a number
639            elif num_a != None: return 1
640            elif num_b != None: return -1
641            # no numbers
642            else: return cmp(a.lower(), b.lower())
643
644        keys.sort(custom_compare)
645
646   
647        iy = 0
648        ix = 0
649        self.text1_2 = wx.StaticText(self, -1, 'Names')
650        sizer.Add(self.text1_2,(iy, ix),(1,1),\
651                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
652        ix +=1
653        self.text2_2 = wx.StaticText(self, -1, 'Values')
654        sizer.Add(self.text2_2,(iy, ix),(1,1),\
655                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
656        ix +=1
657        self.text2_4 = wx.StaticText(self, -1, '[Units]')
658        sizer.Add(self.text2_4,(iy, ix),(1,1),\
659                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
660        self.text2_4.Hide()
661       
662        for item in keys:
663            if not item in self.disp_list and not item in self.model.orientation_params:
664                iy += 1
665                ix = 0
666                if self.model.__class__ in self.model_list_box["Multi-Functions"]\
667                            and item in self.model.non_fittable:
668                    non_fittable_name = wx.StaticText(self, -1, item )
669                    sizer.Add(non_fittable_name,(iy, ix),(1,1),\
670                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
671                    ## add parameter value
672                    ix += 1
673                    value= self.model.getParam(item)
674                    if len(self.model.fun_list) > 0:
675                        num = item.split('_')[1][5:7]
676                        fun_box = wx.ComboBox(self, -1,size=(100,-1),style=wx.CB_READONLY, name = '%s'% item)
677                        self._set_fun_box_list(fun_box)
678                        fun_box.SetSelection(0)
679                        #self.fun_box.SetToolTipString("A function describing the interface")
680                        wx.EVT_COMBOBOX(fun_box,-1, self._on_fun_box)
681                    else:
682                        fun_box = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
683                                        style=wx.TE_PROCESS_ENTER, name ='%s'% item)
684                        fun_box.SetToolTipString("Hit 'Enter' after typing.")
685                        fun_box.SetValue(format_number(value))
686                    sizer.Add(fun_box, (iy,ix),(1,1), wx.EXPAND)
687                    ##[cb state, name, value, "+/-", error of fit, min, max , units]
688                    self.str_parameters.append([None,item, fun_box, \
689                                                None,None,None,None,None])
690                else:
691                    name = wx.StaticText(self, -1,item)
692                    sizer.Add( name,( iy, ix),(1,1),
693                                 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
694   
695                    ix += 1
696                    value= self.model.getParam(item)
697                    ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
698                        style=wx.TE_PROCESS_ENTER)
699                   
700                    ctl1.SetValue(str (format_number(value)))
701                   
702                    sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
703                    ix +=1
704                    # Units
705                    if self.model.details.has_key(item):
706                        units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT)
707                    else:
708                        units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT)
709                    sizer.Add(units, (iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
710                    ##[cb state, name, value, "+/-", error of fit, min, max , units]
711                    self.parameters.append([None,item, ctl1,
712                                            None,None, None, None,None])
713        iy+=1
714        sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
715        iy += 1
716        ix = 0
717       
718        #Add tile for orientational angle parameters
719        for item in keys:
720            if item in self.model.orientation_params:       
721                orient_angle = wx.StaticText(self, -1, '[For 2D only]:')
722                sizer.Add(orient_angle,(iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
723                if not self.enable2D:
724                    orient_angle.Hide()
725                else:
726                    orient_angle.Show(True)
727                break
728                                         
729        for item  in self.model.orientation_params:
730            if not item in self.disp_list and item in keys:
731                iy += 1
732                ix = 0
733                name = wx.StaticText(self, -1,item)
734                sizer.Add( name,( iy, ix),(1,1),
735                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
736                if not self.enable2D:
737                    name.Hide()
738                else:
739                    name.Show(True)
740
741                ix += 1
742                value= self.model.getParam(item)
743                ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
744                    style=wx.TE_PROCESS_ENTER)
745               
746                ctl1.SetValue(str (format_number(value)))
747                if not self.enable2D:
748                    ctl1.Hide()
749                    ctl1.Disable()
750                else:
751                    ctl1.Show(True)
752                    ctl1.Enable()
753               
754                sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
755                ix +=1
756                # Units
757                if self.model.details.has_key(item):
758                    units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT)
759                else:
760                    units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT)
761                if not self.enable2D:
762                    units.Hide()
763                else:
764                    units.Show(True)
765   
766                sizer.Add(units, (iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
767                #Save 2D orient. params
768                #self.temp.append([name,ctl1,units,orient_angle])
769               
770                               
771                ##[cb state, name, value, "+/-", error of fit, min, max , units]
772                self.parameters.append([None,item, ctl1,
773                                        None,None, None, None,None])
774                self.orientation_params.append([None,item, ctl1,
775                                        None,None, None, None,None]) 
776        iy += 1
777       
778        #Display units text on panel
779        for item in keys:   
780            self.text2_4.Show()
781
782        boxsizer1.Add(sizer)
783        self.sizer3.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
784        self.sizer3.Layout()
785        self.SetScrollbars(20,20,25,65)
786               
Note: See TracBrowser for help on using the repository browser.