source: sasview/theoryview/perspectives/theory/model_panel.py @ 20905a0

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 20905a0 was 20905a0, checked in by Jae Cho <jhjcho@…>, 14 years ago

fixed small problem of custom order

  • Property mode set to 100644
File size: 27.7 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 (STD)')
171        values.SetToolTipString("Polydispersity multiplied by the value of the original parameter.")
172        self.sizer4_4.Add(values,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
173       
174        ix += 1 
175        npts = wx.StaticText(self, -1, 'Npts')
176        npts.SetToolTipString("Number of points for weighting.")
177        self.sizer4_4.Add(npts,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
178        ix += 1 
179        nsigmas = wx.StaticText(self, -1, 'Nsigmas')
180        nsigmas.SetToolTipString("Number of sigmas between which the range of the distribution function will be used for weighting. The value '3' covers 99.5% for Gaussian distribution function.")
181        self.sizer4_4.Add(nsigmas,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
182       
183        for item in self.model.dispersion.keys():
184            if not item in self.model.orientation_params:
185                self.disp_cb_dict[item]= None
186                name1=item+".width"
187                name2=item+".npts"
188                name3=item+".nsigmas"
189                iy += 1
190                for p in self.model.dispersion[item].keys():
191                    if p=="width":
192                        ix = 0
193                        name = wx.StaticText(self, -1,  name1)
194                        self.sizer4_4.Add( name,( iy, ix),(1,1), 
195                                           wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
196                        ix = 1
197                        value= self.model.getParam(name1)
198                        ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
199                                            style=wx.TE_PROCESS_ENTER)
200                        ctl1.SetToolTipString("Polydispersity multiplied by the value of the '%s'."%item)
201                        ctl1.SetValue(str (format_number(value)))
202                        self.sizer4_4.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
203                        self.fittable_param.append([None,name1,ctl1,None,
204                                                    None, None, None,None])
205                    elif p=="npts":
206                            ix =2
207                            value= self.model.getParam(name2)
208                            Tctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),
209                                                style=wx.TE_PROCESS_ENTER)
210                           
211                            Tctl1.SetValue(str (format_number(value)))
212                            self.sizer4_4.Add(Tctl1, (iy,ix),(1,1),
213                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
214                            self.fixed_param.append([None,name2, Tctl1,None,None,
215                                                      None, None,None])
216                    elif p=="nsigmas":
217                            ix =3 
218                            value= self.model.getParam(name3)
219                            Tctl2 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),
220                                                style=wx.TE_PROCESS_ENTER)
221                           
222                            Tctl2.SetValue(str (format_number(value)))
223                            self.sizer4_4.Add(Tctl2, (iy,ix),(1,1),
224                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
225                            ix +=1
226                            self.sizer4_4.Add((20,20), (iy,ix),(1,1),
227                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
228                            self.fixed_param.append([None,name3, Tctl2,
229                                                     None,None, None, None,None])
230        for item in self.model.dispersion.keys():
231            if item in self.model.orientation_params:
232                self.disp_cb_dict[item]= None
233                name1=item+".width"
234                name2=item+".npts"
235                name3=item+".nsigmas"
236                iy += 1
237                for p in self.model.dispersion[item].keys():
238                    if p=="width":
239                        ix = 0
240                        name = wx.StaticText(self, -1,  name1)
241                        self.sizer4_4.Add( name,( iy, ix),(1,1), 
242                                           wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
243                        if not self.enable2D:
244                            name.Hide()
245                        else:
246                            name.Show(True)
247                        ix = 1
248                        value= self.model.getParam(name1)
249                        ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
250                                            style=wx.TE_PROCESS_ENTER)
251                        ctl1.SetToolTipString("Polydispersity multiplied by the value of '%s'."%item)
252                        ctl1.SetValue(str (format_number(value)))
253                        if not self.enable2D:
254                            ctl1.Hide()
255                            ctl1.Disable()
256                        else:
257                            ctl1.Show(True)
258                            ctl1.Enable()
259                        self.sizer4_4.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
260                        self.fittable_param.append([None,name1,ctl1,None,
261                                                    None, None, None,None])
262                        self.orientation_params_disp.append([None,name1,ctl1,None,
263                                                    None, None, None,None])
264                    elif p=="npts":
265                            ix =2
266                            value= self.model.getParam(name2)
267                            Tctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),
268                                                style=wx.TE_PROCESS_ENTER)
269
270                            Tctl1.SetValue(str (format_number(value)))
271                            if not self.enable2D:
272                                Tctl1.Hide()
273                                Tctl1.Disable()
274                            else:
275                                Tctl1.Show(True)
276                                Tctl1.Enable()
277                            self.sizer4_4.Add(Tctl1, (iy,ix),(1,1),
278                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
279                            self.fixed_param.append([None,name2, Tctl1,None,None,
280                                                      None, None,None])
281                            self.orientation_params_disp.append([None,name2, Tctl1,None,None,
282                                                      None, None,None])
283                    elif p=="nsigmas":
284                            ix =3 
285                            value= self.model.getParam(name3)
286                            Tctl2 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),
287                                                style=wx.TE_PROCESS_ENTER)
288                           
289                            Tctl2.SetValue(str (format_number(value)))
290                            if not self.enable2D:
291                                Tctl2.Hide()
292                                Tctl2.Disable()
293                            else:
294                                Tctl2.Show(True)
295                                Tctl2.Enable()
296                            self.sizer4_4.Add(Tctl2, (iy,ix),(1,1),
297                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
298                            ix +=1
299                            #self.sizer4_4.Add((20,20), (iy,ix),(1,1),
300                                               #wx.EXPAND|wx.ADJUST_MINSIZE, 0)
301                            self.fixed_param.append([None,name3, Tctl2,
302                                                     None,None, None, None,None])
303                            self.orientation_params_disp.append([None,name3, Tctl2,
304                                                     None,None, None, None,None])
305           
306        msg = " Selected Distribution: Gaussian"       
307        wx.PostEvent(self.parent, StatusEvent( status= msg )) 
308        self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict)   
309        ix =0
310        iy +=1 
311        #self.sizer4_4.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)   
312        self.sizer4_4.Layout()
313        self.sizer4.Layout()
314        self.SetScrollbars(20,20,25,65)
315             
316 
317    def _onModel2D(self, event):
318        """
319        call manager to plot model in 2D
320       
321        """
322        # If the 2D display is not currently enabled, plot the model in 2D
323        # and set the enable2D flag.
324
325        if self.fitrange:
326            self.enable2D = True
327 
328        if self.enable2D:
329            self._draw_model()
330            self.model_view.Disable()
331           
332            n = self.disp_box.GetCurrentSelection()
333            dispersity= self.disp_box.GetClientData(n)
334            #TODO:Find a better way to reinitialize the parameters containers
335            # when resetting the page and 2D view is enable
336            #self.set_model_param_sizer(self.model): called here is using a lot
337            #of for loops and redraw the sizer again .How to avoid it?
338            self.set_model_param_sizer(self.model)
339           
340            if len(self.orientation_params)>0:
341                for item in self.orientation_params:
342                    if item[2]!=None:     
343                        item[2].Enable()
344            # same as above why do we have to redraw the sizer of dispersity to get
345            # the appropriate value of parameters containers on reset page?
346            # Reset containers of dispersity parameters for the appropriate dispersity
347            #and model
348            if  self.disp_name.lower()in ["array","arraydispersion"]:               
349                self._set_sizer_arraydispersion() 
350            else:
351                self._set_sizer_dispersion(dispersity)
352                if len(self.orientation_params_disp)>0:
353                   
354                    for item in self.orientation_params_disp:
355                        if item[2]!=None:
356                            item[2].Enable()
357                           
358        self.state.enable2D =  copy.deepcopy(self.enable2D)
359        self.Layout()
360        ## post state to fit panel
361        #self._undo.Enable(True)
362        event = PageInfoEvent(page = self)
363        wx.PostEvent(self.parent, event)
364             
365    def set_data(self, list=[], state=None):
366        """
367        Receive  a list of data from gui_manager to plot theory
368        """
369        pass
370     
371    def reset_page(self, state):
372        """
373        reset the state
374       
375        """
376        self.reset_page_helper(state)
377       
378       
379    def select_model(self, model):
380        """
381        Select a new model
382       
383        :param model: model object
384       
385        """
386        self.model = model
387        if self.model !=None:
388            self.disp_list= self.model.getDispParamList()
389        self.set_model_param_sizer(self.model)
390        ## keep the sizer view consistent with the model menu selecting
391        self._set_model_sizer_selection( self.model )
392        self.enable_disp.SetValue(False)
393        self.disable_disp.SetValue(True)
394        self.set_dispers_sizer()
395       
396        self.model_view.SetFocus()
397        if self.model !=None:
398            self._draw_model()
399        self.state.structurecombobox = self.structurebox.GetCurrentSelection()
400        self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection()
401       
402        ## post state to fit panel
403        #self._undo.Enable(True)
404        event = PageInfoEvent(page = self)
405        wx.PostEvent(self.parent, event)               
406   
407   
408    def set_model_description(self,description,sizer):
409        """
410        fill a sizer with description
411       
412        :param description: of type string
413        :param sizer: wx.BoxSizer()
414       
415        """
416   
417        sizer.Clear(True)
418        box_description= wx.StaticBox(self, -1, 'Model Description')
419        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
420
421        sizer_selection=wx.BoxSizer(wx.HORIZONTAL)
422        self.description_hide = wx.RadioButton(self, -1, 'Hide', style=wx.RB_GROUP)
423        self.description_show = wx.RadioButton(self, -1, 'Show')
424       
425       
426        if description=="":
427            self.description_hide.SetValue(True)
428            description=" Description unavailable. Click for details"
429           
430        self.description = wx.StaticText( self,-1,str(description) )
431       
432        self.Bind( wx.EVT_RADIOBUTTON, self._on_display_description,
433                   id=self.description_hide.GetId() )
434       
435        self.Bind( wx.EVT_RADIOBUTTON, self._on_display_description,
436                   id=self.description_show.GetId() )
437        #MAC needs SetValue
438        self.description_hide.SetValue(True)
439       
440        self.model_description = wx.Button(self,-1, label="Details", size=(80,23))
441       
442        self.model_description.Bind(wx.EVT_BUTTON,self.on_button_clicked)
443        self.model_description.SetToolTipString("Click Model Functions in HelpWindow...")
444        self.model_description.SetFocus()
445        sizer_selection.Add( self.description_show )
446        sizer_selection.Add( (20,20)) 
447        sizer_selection.Add( self.description_hide )
448        sizer_selection.Add((20,20),0, wx.LEFT|wx.RIGHT|wx.EXPAND,75)
449        sizer_selection.Add( self.model_description )
450                     
451         
452        self.sizer_description=wx.BoxSizer(wx.HORIZONTAL)
453        self.sizer_description.Add( self.description, 1, wx.EXPAND | wx.ALL, 10 )
454        boxsizer1.Add( sizer_selection) 
455        boxsizer1.Add( (20,20)) 
456        boxsizer1.Add( self.sizer_description) 
457   
458        self._on_display_description(event=None)
459        sizer.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
460        sizer.Layout()
461   
462    def on_button_clicked(self,event):
463        """
464        On 'More details' button
465        """
466        from help_panel import  HelpWindow
467       
468        if self.model == None:
469            name = 'FuncHelp'
470        else:
471            name = self.model.name
472        frame = HelpWindow(None, -1,  pageToOpen="media/model_functions.html")   
473        frame.Show(True)
474        if frame.rhelp.HasAnchor(name):
475            frame.rhelp.ScrollToAnchor(name)
476        else:
477           msg= "Model does not contains an available description "
478           msg +="Please.Search in the Help window"
479           wx.PostEvent(self.parent, StatusEvent(status = msg ))
480                     
481    def set_range(self, qmin_x, qmax_x, npts):
482        """
483        Set the range for the plotted models
484       
485        :param qmin: minimum Q
486        :param qmax: maximum Q
487        :param npts: number of Q bins
488       
489        """
490        # Set the data members
491        self.qmin_x = qmin_x
492        self.qmax_x = qmax_x
493        self.num_points = npts
494        # Set the controls
495        #For qmin and qmax, do not use format_number.(If do, qmin and max could be different from what is in the data.)
496        self.qmin.SetValue(str(self.qmin_x))
497        self.qmax.SetValue(str(self.qmax_x))
498        self.npts.SetValue(format_number(self.num_points))
499       
500    def set_model_param_sizer(self, model):
501        """
502        Build the panel from the model content
503       
504        :param model: the model selected in combo box for fitting purpose
505       
506        """
507        self.sizer3.Clear(True)
508        self.parameters = []
509        self.param_toFit=[]
510        self.fixed_param=[]
511        self.orientation_params=[]
512        self.orientation_params_disp=[]
513        #self.temp=[]
514        if model ==None:
515            ##no model avaiable to draw sizer
516            self.sizer3.Layout()
517            self.SetScrollbars(20,20,25,65)
518            return
519        box_description= wx.StaticBox(self, -1,str("Model Parameters"))
520        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
521        sizer = wx.GridBagSizer(5,5)
522       
523        self.model = model
524        self.set_model_description(self.model.description,self.sizer2)
525       
526        keys = self.model.getParamList()
527        ##list of dispersion parameters
528        self.disp_list=self.model.getDispParamList()
529       
530        def custom_compare(a,b):
531            """
532            Custom compare to order, first by alphabets then second by number.
533            """ 
534            a_last = a[len(a)-1]
535            b_last = b[len(b)-1]
536           
537            num_a = None
538            num_b = None
539            # check if it contains a int number(<10)
540            try: 
541                num_a = int(a_last)
542            except: pass
543            try:
544                num_b = int(b_last)
545            except: pass
546            # both have a number   
547            if num_a != None and num_b != None:
548                if num_a > num_b: return 1
549                elif num_a == num_b: 
550                    return cmp(a.lower(), b.lower())
551                else: return -1
552            # one of them has a number
553            elif num_a != None: return 1
554            elif num_b != None: return -1
555            # no nuumbers
556            else: return cmp(a.lower(), b.lower())
557           
558        keys.sort(custom_compare)
559
560   
561        iy = 0
562        ix = 0
563        self.text1_2 = wx.StaticText(self, -1, 'Names')
564        sizer.Add(self.text1_2,(iy, ix),(1,1),\
565                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
566        ix +=1
567        self.text2_2 = wx.StaticText(self, -1, 'Values')
568        sizer.Add(self.text2_2,(iy, ix),(1,1),\
569                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
570        ix +=1
571        self.text2_4 = wx.StaticText(self, -1, '[Units]')
572        sizer.Add(self.text2_4,(iy, ix),(1,1),\
573                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
574        self.text2_4.Hide()
575       
576        for item in keys:
577            if not item in self.disp_list and not item in self.model.orientation_params:
578                iy += 1
579                ix = 0
580                name = wx.StaticText(self, -1,item)
581                sizer.Add( name,( iy, ix),(1,1),
582                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
583
584                ix += 1
585                value= self.model.getParam(item)
586                ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
587                    style=wx.TE_PROCESS_ENTER)
588               
589                ctl1.SetValue(str (format_number(value)))
590               
591                sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
592                ix +=1
593                # Units
594                if self.model.details.has_key(item):
595                    units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT)
596                else:
597                    units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT)
598                sizer.Add(units, (iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
599                ##[cb state, name, value, "+/-", error of fit, min, max , units]
600                self.parameters.append([None,item, ctl1,
601                                        None,None, None, None,None])
602        iy+=1
603        sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
604        iy += 1
605        ix = 0
606       
607        #Add tile for orientational angle parameters
608        for item in keys:
609            if item in self.model.orientation_params:       
610                orient_angle = wx.StaticText(self, -1, '[For 2D only]:')
611                sizer.Add(orient_angle,(iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
612                if not self.enable2D:
613                    orient_angle.Hide()
614                else:
615                    orient_angle.Show(True)
616                break
617                                         
618        for item  in self.model.orientation_params:
619            if not item in self.disp_list and item in keys:
620                iy += 1
621                ix = 0
622                name = wx.StaticText(self, -1,item)
623                sizer.Add( name,( iy, ix),(1,1),
624                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
625                if not self.enable2D:
626                    name.Hide()
627                else:
628                    name.Show(True)
629
630                ix += 1
631                value= self.model.getParam(item)
632                ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
633                    style=wx.TE_PROCESS_ENTER)
634               
635                ctl1.SetValue(str (format_number(value)))
636                if not self.enable2D:
637                    ctl1.Hide()
638                    ctl1.Disable()
639                else:
640                    ctl1.Show(True)
641                    ctl1.Enable()
642               
643                sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
644                ix +=1
645                # Units
646                if self.model.details.has_key(item):
647                    units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT)
648                else:
649                    units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT)
650                if not self.enable2D:
651                    units.Hide()
652                else:
653                    units.Show(True)
654   
655                sizer.Add(units, (iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
656                #Save 2D orient. params
657                #self.temp.append([name,ctl1,units,orient_angle])
658               
659                               
660                ##[cb state, name, value, "+/-", error of fit, min, max , units]
661                self.parameters.append([None,item, ctl1,
662                                        None,None, None, None,None])
663                self.orientation_params.append([None,item, ctl1,
664                                        None,None, None, None,None]) 
665        iy += 1
666       
667        #Display units text on panel
668        for item in keys:   
669            self.text2_4.Show()
670
671        boxsizer1.Add(sizer)
672        self.sizer3.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
673        self.sizer3.Layout()
674        self.SetScrollbars(20,20,25,65)
675               
Note: See TracBrowser for help on using the repository browser.