Ignore:
Timestamp:
Apr 14, 2009 6:27:50 PM (15 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
ac166e9c
Parents:
fff74cb
Message:

add disabling parameter for 1D and 2D orientation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/fitpage.py

    r2a5bba7 r780d095  
    194194        self.fittable_param=[] 
    195195        self.fixed_param=[] 
    196      
     196        self.orientation_params=[] 
    197197        self.sizer4_4.Clear(True) 
    198198        
     
    232232        
    233233        for item in self.model.dispersion.keys(): 
    234             self.disp_cb_dict[item]= None 
    235             name1=item+".width" 
    236             name2=item+".npts" 
    237             name3=item+".nsigmas" 
    238             iy += 1 
    239             for p in self.model.dispersion[item].keys(): 
    240      
    241                 if p=="width": 
    242                     ix = 0 
    243                     cb = wx.CheckBox(self, -1, name1, (10, 10)) 
    244                     wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 
    245                      
    246                     self.sizer4_4.Add( cb,( iy, ix),(1,1),   
    247                                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    248                     ix = 1 
    249                     value= self.model.getParam(name1) 
    250                     ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), 
    251                                         style=wx.TE_PROCESS_ENTER) 
    252                      
    253                     ctl1.SetValue(str (format_number(value))) 
    254                     ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
    255                     ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
    256                     ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 
    257                     self.sizer4_4.Add(ctl1, (iy,ix),(1,1),wx.EXPAND) 
    258                      
    259                     ## text to show error sign 
    260                     ix = 2 
    261                     text2=wx.StaticText(self, -1, '+/-') 
    262                     self.sizer4_4.Add(text2,(iy, ix),(1,1), 
    263                                       wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    264                     text2.Hide()  
    265                     ## txtcrtl to add error from fit 
    266                     ix = 3 
    267                     ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 
    268                     self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    269                     ctl2.Hide() 
    270                      
    271                     self.fittable_param.append([cb,name1,ctl1,text2, 
    272                                                 ctl2, None, None,None]) 
    273                 elif p=="npts": 
    274                         ix = 4 
    275                         value= self.model.getParam(name2) 
    276                         Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 
     234            if not item in self.model.orientation_params: 
     235                self.disp_cb_dict[item]= None 
     236                name1=item+".width" 
     237                name2=item+".npts" 
     238                name3=item+".nsigmas" 
     239                iy += 1 
     240                for p in self.model.dispersion[item].keys():  
     241         
     242                    if p=="width": 
     243                        ix = 0 
     244                        cb = wx.CheckBox(self, -1, name1, (10, 10)) 
     245                        wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 
     246                        self.sizer4_4.Add( cb,( iy, ix),(1,1),   
     247                                           wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     248                        ix = 1 
     249                        value= self.model.getParam(name1) 
     250                        ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), 
    277251                                            style=wx.TE_PROCESS_ENTER) 
    278                          
    279                         Tctl.SetValue(str (format_number(value))) 
    280                         Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
    281                         Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
    282                         Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 
    283                         self.sizer4_4.Add(Tctl, (iy,ix),(1,1), 
    284                                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    285                          
    286                         self.fixed_param.append([None,name2, Tctl,None,None, 
    287                                                   None, None,None]) 
    288                  
    289                 elif p=="nsigmas": 
    290                         ix = 5 
    291                         value= self.model.getParam(name3) 
    292                         Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 
     252                        ctl1.SetValue(str (format_number(value))) 
     253                        ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
     254                        ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
     255                        ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 
     256                        self.sizer4_4.Add(ctl1, (iy,ix),(1,1),wx.EXPAND) 
     257                        ## text to show error sign 
     258                        ix = 2 
     259                        text2=wx.StaticText(self, -1, '+/-') 
     260                        self.sizer4_4.Add(text2,(iy, ix),(1,1), 
     261                                          wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     262                        text2.Hide()  
     263                        ## txtcrtl to add error from fit 
     264                        ix = 3 
     265                        ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 
     266                        self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     267                        ctl2.Hide() 
     268                        self.fittable_param.append([cb,name1,ctl1,text2, 
     269                                                    ctl2, None, None,None]) 
     270                    elif p=="npts": 
     271                            ix = 4 
     272                            value= self.model.getParam(name2) 
     273                            Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 
     274                                                style=wx.TE_PROCESS_ENTER) 
     275                             
     276                            Tctl.SetValue(str (format_number(value))) 
     277                            Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
     278                            Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
     279                            Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 
     280                            self.sizer4_4.Add(Tctl, (iy,ix),(1,1), 
     281                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     282                            self.fixed_param.append([None,name2, Tctl,None,None, 
     283                                                      None, None,None]) 
     284                    elif p=="nsigmas": 
     285                            ix = 5 
     286                            value= self.model.getParam(name3) 
     287                            Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 
     288                                                style=wx.TE_PROCESS_ENTER) 
     289                            Tctl.SetValue(str (format_number(value))) 
     290                            Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
     291                            Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
     292                            Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 
     293                            self.sizer4_4.Add(Tctl, (iy,ix),(1,1), 
     294                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     295                            ix +=1 
     296                            self.sizer4_4.Add((20,20), (iy,ix),(1,1), 
     297                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     298                             
     299                            self.fixed_param.append([None,name3, Tctl 
     300                                                     ,None,None, None, None,None]) 
     301        ix =0 
     302        iy +=1  
     303        self.sizer4_4.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)   
     304        for item in self.model.dispersion.keys(): 
     305            if  item in self.model.orientation_params: 
     306                self.disp_cb_dict[item]= None 
     307                name1=item+".width" 
     308                name2=item+".npts" 
     309                name3=item+".nsigmas" 
     310                iy += 1 
     311                for p in self.model.dispersion[item].keys():  
     312         
     313                    if p=="width": 
     314                        ix = 0 
     315                        cb = wx.CheckBox(self, -1, name1, (10, 10)) 
     316                        wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 
     317                        self.sizer4_4.Add( cb,( iy, ix),(1,1),   
     318                                           wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     319                        if self.data.__class__.__name__ =="Data2D": 
     320                            cb.Enable() 
     321                        else: 
     322                            cb.Disable() 
     323                        ix = 1 
     324                        value= self.model.getParam(name1) 
     325                        ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), 
    293326                                            style=wx.TE_PROCESS_ENTER) 
    294                         Tctl.SetValue(str (format_number(value))) 
    295                         Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
    296                         Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
    297                         Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 
    298                         self.sizer4_4.Add(Tctl, (iy,ix),(1,1), 
    299                                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    300                         ix +=1 
    301                         self.sizer4_4.Add((20,20), (iy,ix),(1,1), 
    302                                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    303                          
    304                         self.fixed_param.append([None,name3, Tctl 
    305                                                  ,None,None, None, None,None]) 
    306                  
     327                        ctl1.SetValue(str (format_number(value))) 
     328                        if self.data.__class__.__name__ =="Data2D": 
     329                            ctl1.Enable() 
     330                        else: 
     331                            ctl1.Disable() 
     332                        ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
     333                        ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
     334                        ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 
     335                        self.sizer4_4.Add(ctl1, (iy,ix),(1,1),wx.EXPAND) 
     336                        ## text to show error sign 
     337                        ix = 2 
     338                        text2=wx.StaticText(self, -1, '+/-') 
     339                        self.sizer4_4.Add(text2,(iy, ix),(1,1), 
     340                                          wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     341                        text2.Hide()  
     342                        ## txtcrtl to add error from fit 
     343                        ix = 3 
     344                        ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 
     345                        self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     346                        ctl2.Hide() 
     347                        if self.data.__class__.__name__ =="Data2D": 
     348                            ctl2.Enable() 
     349                        else: 
     350                            ctl2.Disable() 
     351                        self.fittable_param.append([cb,name1,ctl1,text2, 
     352                                                    ctl2, None, None,None]) 
     353                        self.orientation_params.append([cb,name1,ctl1,text2, 
     354                                                    ctl2, None, None,None]) 
     355                    elif p=="npts": 
     356                            ix = 4 
     357                            value= self.model.getParam(name2) 
     358                            Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 
     359                                                style=wx.TE_PROCESS_ENTER) 
     360                             
     361                            Tctl.SetValue(str (format_number(value))) 
     362                            if self.data.__class__.__name__ =="Data2D": 
     363                                Tctl.Enable() 
     364                            else: 
     365                                Tctl.Disable() 
     366                            Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
     367                            Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
     368                            Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 
     369                            self.sizer4_4.Add(Tctl, (iy,ix),(1,1), 
     370                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     371                            self.fixed_param.append([None,name2, Tctl,None,None, 
     372                                                      None, None,None]) 
     373                            self.orientation_params.append([None,name2, Tctl,None,None, 
     374                                                      None, None,None]) 
     375                    elif p=="nsigmas": 
     376                            ix = 5 
     377                            value= self.model.getParam(name3) 
     378                            Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 
     379                                                style=wx.TE_PROCESS_ENTER) 
     380                            Tctl.SetValue(str (format_number(value))) 
     381                            if self.data.__class__.__name__ =="Data2D": 
     382                                Tctl.Enable() 
     383                            else: 
     384                                Tctl.Disable() 
     385                            Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
     386                            Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
     387                            Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 
     388                            self.sizer4_4.Add(Tctl, (iy,ix),(1,1), 
     389                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     390                            ix +=1 
     391                            self.sizer4_4.Add((20,20), (iy,ix),(1,1), 
     392                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     393                            self.fixed_param.append([None,name3, Tctl 
     394                                                     ,None,None, None, None,None])     
     395                            self.orientation_params.append([None,name3, Tctl 
     396                                                     ,None,None, None, None,None])  
     397                                   
    307398        wx.PostEvent(self.parent, StatusEvent(status=\ 
    308399                        " Selected Distribution: Gaussian"))    
     
    644735        self.fittable_param=[] 
    645736        self.fixed_param=[] 
     737        self.orientation_params=[] 
    646738         
    647739        if model ==None: 
     
    702794 
    703795        for item in keys: 
    704             if not item in self.disp_list: 
     796            if not item in self.disp_list and not item in self.model.orientation_params: 
    705797                iy += 1 
    706798                ix = 0 
     
    771863        iy+=1 
    772864        sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     865        for item in self.model.orientation_params: 
     866            if not item in self.disp_list : 
     867                iy += 1 
     868                ix = 0 
     869                ## add parameters name with checkbox for selecting to fit 
     870                cb = wx.CheckBox(self, -1, item ) 
     871                cb.SetValue(False) 
     872                wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 
     873                if self.data.__class__.__name__ =="Data2D": 
     874                    cb.Enable() 
     875                else: 
     876                    cb.Disable() 
     877                sizer.Add( cb,( iy, ix),(1,1), 
     878                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     879                ## add parameter value 
     880                ix += 1 
     881                value= self.model.getParam(item) 
     882                ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), 
     883                                    style=wx.TE_PROCESS_ENTER) 
     884                 
     885                ctl1.SetValue(format_number(value)) 
     886                if self.data.__class__.__name__ =="Data2D": 
     887                    ctl1.Enable() 
     888                else: 
     889                    ctl1.Disable() 
     890                ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
     891                ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
     892                ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 
     893                sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 
     894                ## text to show error sign 
     895                ix += 1 
     896                text2=wx.StaticText(self, -1, '+/-') 
     897                sizer.Add(text2,(iy, ix),(1,1),\ 
     898                                wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     899                text2.Hide()  
     900                ## txtcrtl to add error from fit 
     901                ix += 1 
     902                ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 
     903                sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     904                ctl2.Hide() 
     905                if self.data.__class__.__name__ =="Data2D": 
     906                    ctl1.Enable() 
     907                else: 
     908                    ctl1.Disable() 
     909                param_min, param_max= self.model.details[item][1:] 
     910                ix += 1 
     911                ctl3 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) 
     912                ctl3.SetValue(format_number(param_min)) 
     913                ctl3.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
     914                ctl3.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
     915                ctl3.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 
     916                sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     917                ctl3.Hide() 
     918                if self.data.__class__.__name__ =="Data2D": 
     919                    ctl3.Enable() 
     920                else: 
     921                    ctl3.Disable() 
     922         
     923                ix += 1 
     924                ctl4 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) 
     925                ctl4.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
     926                ctl4.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
     927                ctl4.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 
     928                sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     929                ctl4.SetValue(format_number(param_max)) 
     930                ctl4.Hide() 
     931                if self.data.__class__.__name__ =="Data2D": 
     932                    ctl4.Enable() 
     933                else: 
     934                    ctl4.Disable() 
     935                if self.engine_type=="park": 
     936                    ctl3.Show(True) 
     937                    ctl4.Show(True) 
     938                     
     939                ix +=1 
     940                # Units 
     941                try: 
     942                    units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 
     943                except: 
     944                    units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 
     945                sizer.Add(units, (iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     946                 
     947                ##[cb state, name, value, "+/-", error of fit, min, max , units] 
     948                self.parameters.append([cb,item, ctl1, 
     949                                        text2,ctl2, ctl3, ctl4,None]) 
     950                self.orientation_params.append([cb,item, ctl1, 
     951                                        text2,ctl2, ctl3, ctl4,None]) 
     952               
     953        iy+=1 
     954        sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    773955         
    774956        #Display units text on panel 
Note: See TracChangeset for help on using the changeset viewer.