[1b07935d] | 1 | import sys |
---|
| 2 | import wx |
---|
| 3 | import wx.lib |
---|
| 4 | import numpy |
---|
| 5 | import copy |
---|
| 6 | |
---|
[26bf293] | 7 | |
---|
[1b07935d] | 8 | from sans.guicomm.events import StatusEvent |
---|
[26bf293] | 9 | from sans.guiframe.utils import format_number |
---|
[1b07935d] | 10 | (ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent() |
---|
| 11 | _BOX_WIDTH = 80 |
---|
| 12 | |
---|
| 13 | |
---|
[26bf293] | 14 | |
---|
| 15 | |
---|
[f39511b] | 16 | class ModelPage(wx.ScrolledWindow): |
---|
[1b07935d] | 17 | """ |
---|
| 18 | FitPanel class contains fields allowing to display results when |
---|
| 19 | fitting a model and one data |
---|
| 20 | @note: For Fit to be performed the user should check at least one parameter |
---|
| 21 | on fit Panel window. |
---|
| 22 | |
---|
| 23 | """ |
---|
| 24 | ## Internal name for the AUI manager |
---|
| 25 | window_name = "Fit page" |
---|
| 26 | ## Title to appear on top of the window |
---|
| 27 | window_caption = "Fit Page" |
---|
[10c43a5] | 28 | name="" |
---|
[86c1832] | 29 | def __init__(self, parent,model,name, *args, **kwargs): |
---|
[f39511b] | 30 | wx.ScrolledWindow.__init__(self, parent, *args, **kwargs) |
---|
[1b07935d] | 31 | """ |
---|
| 32 | Initialization of the Panel |
---|
| 33 | """ |
---|
[26bf293] | 34 | # model on which the fit would be performed |
---|
| 35 | self.model=model |
---|
| 36 | #list of dispersion paramaters |
---|
[bb1e07a] | 37 | self.disp_list=[] |
---|
| 38 | try: |
---|
| 39 | self.disp_list=self.model.getDispParamList() |
---|
| 40 | except: |
---|
| 41 | pass |
---|
[1b07935d] | 42 | self.manager = None |
---|
| 43 | self.parent = parent |
---|
[26bf293] | 44 | self.event_owner = None |
---|
| 45 | # this panel does contain data .existing data allow a different drawing |
---|
| 46 | #on set_model parameters |
---|
| 47 | self.data=None |
---|
[1b07935d] | 48 | #panel interface |
---|
| 49 | self.vbox = wx.BoxSizer(wx.VERTICAL) |
---|
[26bf293] | 50 | self.sizer10 = wx.GridBagSizer(5,5) |
---|
| 51 | self.sizer9 = wx.GridBagSizer(5,5) |
---|
| 52 | self.sizer8 = wx.GridBagSizer(5,5) |
---|
| 53 | self.sizer7 = wx.GridBagSizer(5,5) |
---|
| 54 | self.sizer6 = wx.GridBagSizer(5,5) |
---|
[04edd0d] | 55 | self.sizer5 = wx.GridBagSizer(5,5) |
---|
[26bf293] | 56 | self.sizer4 = wx.GridBagSizer(5,5) |
---|
| 57 | |
---|
| 58 | #model selection |
---|
| 59 | self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) |
---|
[00561739] | 60 | self.vbox.Add(self.sizer4) |
---|
[26bf293] | 61 | #model paramaters layer |
---|
| 62 | self.vbox.Add(self.sizer5) |
---|
| 63 | #polydispersion selected |
---|
| 64 | self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) |
---|
| 65 | self.vbox.Add(self.sizer6) |
---|
| 66 | #combox box for type of dispersion |
---|
| 67 | self.vbox.Add(self.sizer7) |
---|
| 68 | #dispersion parameters layer |
---|
| 69 | self.vbox.Add(self.sizer8) |
---|
| 70 | # plotting range |
---|
| 71 | self.vbox.Add(self.sizer9) |
---|
| 72 | #close layer |
---|
| 73 | self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) |
---|
| 74 | self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) |
---|
| 75 | self.vbox.Add(self.sizer10) |
---|
[00561739] | 76 | |
---|
[26bf293] | 77 | |
---|
| 78 | #------------------ sizer 4 draw------------------------ |
---|
| 79 | # model on which the fit would be performed |
---|
| 80 | self.model=model |
---|
| 81 | |
---|
| 82 | # define combox box |
---|
| 83 | self.modelbox = wx.ComboBox(self, -1) |
---|
| 84 | # preview selected model name |
---|
| 85 | self.prevmodel_name=name |
---|
| 86 | #print "model view prev_model",name |
---|
| 87 | self.modelbox.SetValue(self.prevmodel_name) |
---|
| 88 | #enable model 2D draw |
---|
| 89 | self.enable2D= False |
---|
| 90 | #filling sizer2 |
---|
| 91 | ix = 0 |
---|
| 92 | iy = 1 |
---|
| 93 | self.sizer4.Add(wx.StaticText(self,-1,'Model'),(iy,ix),(1,1)\ |
---|
| 94 | , wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 95 | ix += 1 |
---|
| 96 | self.sizer4.Add(self.modelbox,(iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 97 | ix += 1 |
---|
[00561739] | 98 | id = wx.NewId() |
---|
[26bf293] | 99 | self.model_view =wx.Button(self,id,'View 2D') |
---|
| 100 | self.model_view.Bind(wx.EVT_BUTTON, self.onModel2D,id=id) |
---|
| 101 | self.model_view.SetToolTipString("View model in 2D") |
---|
| 102 | self.sizer4.Add(self.model_view,(iy,ix),(1,1),\ |
---|
| 103 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[ef8b580] | 104 | self.model_view.Enable() |
---|
[26bf293] | 105 | self.model_view.SetFocus() |
---|
[ef8b580] | 106 | |
---|
[26bf293] | 107 | #----------sizer6------------------------------------------------- |
---|
| 108 | self.disable_disp = wx.RadioButton(self, -1, 'No', (10, 10), style=wx.RB_GROUP) |
---|
| 109 | self.enable_disp = wx.RadioButton(self, -1, 'Yes', (10, 30)) |
---|
| 110 | self.Bind(wx.EVT_RADIOBUTTON, self.Set_DipersParam, id=self.disable_disp.GetId()) |
---|
| 111 | self.Bind(wx.EVT_RADIOBUTTON, self.Set_DipersParam, id=self.enable_disp.GetId()) |
---|
| 112 | ix= 0 |
---|
| 113 | iy=1 |
---|
| 114 | self.sizer6.Add(wx.StaticText(self,-1,'Polydispersity: '),(iy,ix),(1,1)\ |
---|
| 115 | , wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[d15c0202] | 116 | ix += 1 |
---|
[26bf293] | 117 | self.sizer6.Add(self.enable_disp ,(iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[d15c0202] | 118 | ix += 1 |
---|
[26bf293] | 119 | self.sizer6.Add(self.disable_disp ,(iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 120 | ix =0 |
---|
| 121 | iy+=1 |
---|
| 122 | self.sizer6.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | #---------sizer 9 draw---------------------------------------- |
---|
| 126 | |
---|
| 127 | ## Q range |
---|
| 128 | self.qmin_x= 0.001 |
---|
| 129 | self.qmax_x= 0.1 |
---|
[d15c0202] | 130 | self.num_points= 100 |
---|
[24ea33c] | 131 | |
---|
[00561739] | 132 | |
---|
[26bf293] | 133 | self.qmin = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) |
---|
| 134 | self.qmin.SetValue(format_number(self.qmin_x)) |
---|
[e5af88b] | 135 | self.qmin.SetToolTipString("Minimun value of Q in linear scale.") |
---|
[26bf293] | 136 | self.qmin.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 137 | self.qmin.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter) |
---|
| 138 | |
---|
| 139 | self.qmax = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) |
---|
| 140 | self.qmax.SetValue(format_number(self.qmax_x)) |
---|
[e5af88b] | 141 | self.qmax.SetToolTipString("Maximum value of Q in linear scale.") |
---|
[26bf293] | 142 | self.qmax.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 143 | self.qmax.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter) |
---|
| 144 | |
---|
| 145 | |
---|
[d15c0202] | 146 | self.npts = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) |
---|
| 147 | self.npts.SetValue(format_number(self.num_points)) |
---|
| 148 | self.npts.SetToolTipString("Number of point to plot.") |
---|
| 149 | self.npts.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 150 | self.npts.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter) |
---|
| 151 | |
---|
[dc317d1] | 152 | ix = 0 |
---|
[26bf293] | 153 | iy = 1 |
---|
| 154 | self.sizer9.Add(wx.StaticText(self, -1, 'Plotting Range'),(iy, ix),(1,1),\ |
---|
| 155 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 156 | ix += 1 |
---|
| 157 | self.sizer9.Add(wx.StaticText(self, -1, 'Min'),(iy, ix),(1,1),\ |
---|
| 158 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 159 | ix += 1 |
---|
| 160 | self.sizer9.Add(wx.StaticText(self, -1, 'Max'),(iy, ix),(1,1),\ |
---|
| 161 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 162 | ix += 1 |
---|
| 163 | self.sizer9.Add(wx.StaticText(self, -1, 'Npts'),(iy, ix),(1,1),\ |
---|
| 164 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[1b07935d] | 165 | ix = 0 |
---|
[26bf293] | 166 | iy += 1 |
---|
[e5af88b] | 167 | self.sizer9.Add(wx.StaticText(self, -1, 'Q range'),(iy, ix),(1,1),\ |
---|
[26bf293] | 168 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[1b07935d] | 169 | ix += 1 |
---|
[26bf293] | 170 | self.sizer9.Add(self.qmin,(iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[86c1832] | 171 | ix += 1 |
---|
[26bf293] | 172 | self.sizer9.Add(self.qmax,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 173 | ix += 1 |
---|
| 174 | self.sizer9.Add(self.npts,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 175 | |
---|
| 176 | ix =0 |
---|
| 177 | iy+=1 |
---|
| 178 | self.sizer9.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 179 | #----------sizer 10 draw------------------------------------------------------ |
---|
[86c1832] | 180 | id = wx.NewId() |
---|
[26bf293] | 181 | self.btClose =wx.Button(self,id,'Close') |
---|
| 182 | self.btClose.Bind(wx.EVT_BUTTON, self.onClose,id=id) |
---|
| 183 | self.btClose.SetToolTipString("Close page.") |
---|
| 184 | |
---|
| 185 | ix= 3 |
---|
| 186 | iy= 1 |
---|
| 187 | self.sizer10.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 188 | ix +=1 |
---|
| 189 | self.sizer10.Add( self.btClose,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 190 | ix =0 |
---|
| 191 | iy+=1 |
---|
| 192 | self.sizer10.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 193 | |
---|
[1b07935d] | 194 | # contains link between model ,all its parameters, and panel organization |
---|
| 195 | self.parameters=[] |
---|
[26bf293] | 196 | self.fixed_param=[] |
---|
[6b44403] | 197 | self.fittable_param=[] |
---|
[ef8b580] | 198 | self.polydisp= {} |
---|
[1b07935d] | 199 | #contains link between a model and selected parameters to fit |
---|
| 200 | self.param_toFit=[] |
---|
[26bf293] | 201 | |
---|
[1b07935d] | 202 | #dictionary of model name and model class |
---|
| 203 | self.model_list_box={} |
---|
[26bf293] | 204 | #Draw initial panel |
---|
| 205 | if self.model!=None: |
---|
| 206 | self.set_panel(self.model) |
---|
| 207 | |
---|
| 208 | |
---|
[86c1832] | 209 | |
---|
[1b07935d] | 210 | self.vbox.Layout() |
---|
| 211 | self.vbox.Fit(self) |
---|
| 212 | self.SetSizer(self.vbox) |
---|
[f39511b] | 213 | self.SetScrollbars(20,20,55,40) |
---|
[68dada4] | 214 | |
---|
[1b07935d] | 215 | self.Centre() |
---|
[26bf293] | 216 | self.Layout() |
---|
| 217 | self.parent.GetSizer().Layout() |
---|
| 218 | |
---|
| 219 | def set_owner(self,owner): |
---|
| 220 | """ |
---|
| 221 | set owner of fitpage |
---|
| 222 | @param owner: the class responsible of plotting |
---|
| 223 | """ |
---|
| 224 | self.event_owner=owner |
---|
| 225 | |
---|
| 226 | |
---|
| 227 | def set_manager(self, manager): |
---|
| 228 | """ |
---|
| 229 | set panel manager |
---|
| 230 | @param manager: instance of plugin fitting |
---|
| 231 | """ |
---|
| 232 | self.manager = manager |
---|
| 233 | |
---|
| 234 | def populate_box(self, dict): |
---|
| 235 | """ |
---|
| 236 | Populate each combox box of each page |
---|
| 237 | @param page: the page to populate |
---|
| 238 | """ |
---|
| 239 | id=0 |
---|
| 240 | self.model_list_box=dict |
---|
| 241 | list_name=[] |
---|
| 242 | for item in self.model_list_box.itervalues(): |
---|
| 243 | name = item.__name__ |
---|
| 244 | if hasattr(item, "name"): |
---|
| 245 | name = item.name |
---|
| 246 | list_name.append(name) |
---|
| 247 | list_name.sort() |
---|
| 248 | |
---|
| 249 | for name in list_name: |
---|
| 250 | self.modelbox.Insert(name,int(id)) |
---|
| 251 | id+=1 |
---|
| 252 | wx.EVT_COMBOBOX(self.modelbox,-1, self._on_select_model) |
---|
| 253 | return 0 |
---|
| 254 | |
---|
| 255 | |
---|
| 256 | def Set_DipersParam(self, event): |
---|
| 257 | if self.enable_disp.GetValue(): |
---|
| 258 | if len(self.disp_list)==0: |
---|
| 259 | ix=0 |
---|
| 260 | iy=1 |
---|
[6b44403] | 261 | self.fittable_param=[] |
---|
| 262 | self.fixed_param=[] |
---|
[26bf293] | 263 | self.sizer8.Clear(True) |
---|
| 264 | model_disp = wx.StaticText(self, -1, 'No PolyDispersity for this model') |
---|
| 265 | self.sizer7.Add(model_disp,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 266 | self.vbox.Layout() |
---|
| 267 | self.SetScrollbars(20,20,55,40) |
---|
| 268 | self.Layout() |
---|
| 269 | self.parent.GetSizer().Layout() |
---|
| 270 | return |
---|
| 271 | else: |
---|
[bb1e07a] | 272 | if self.data !=None and self.model !=None: # allow to recognize data panel from model panel |
---|
[888e62c] | 273 | #if self.data !=None and self.model !=None: |
---|
[94999eb] | 274 | self.cb1.SetValue(False) |
---|
| 275 | self.select_all_param_helper() |
---|
[e5af88b] | 276 | |
---|
[888e62c] | 277 | self.populate_disp_box() |
---|
| 278 | self.set_panel_dispers(self.disp_list) |
---|
[e5af88b] | 279 | |
---|
[26bf293] | 280 | else: |
---|
[bb1e07a] | 281 | if self.data !=None and self.model!=None: |
---|
[94999eb] | 282 | if self.cb1.GetValue(): |
---|
| 283 | self.select_all_param_helper() |
---|
[6b44403] | 284 | self.fittable_param=[] |
---|
| 285 | self.fixed_param=[] |
---|
[26bf293] | 286 | self.sizer7.Clear(True) |
---|
| 287 | self.sizer8.Clear(True) |
---|
| 288 | self.vbox.Layout() |
---|
| 289 | self.SetScrollbars(20,20,55,40) |
---|
| 290 | self.Layout() |
---|
| 291 | self.parent.GetSizer().Layout() |
---|
| 292 | |
---|
| 293 | def populate_disp_box(self): |
---|
| 294 | self.sizer7.Clear(True) |
---|
| 295 | if len(self.disp_list)>0: |
---|
| 296 | ix=0 |
---|
| 297 | iy=1 |
---|
| 298 | model_disp = wx.StaticText(self, -1, 'Model Disp') |
---|
| 299 | self.sizer7.Add(model_disp,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 300 | ix += 1 |
---|
| 301 | # set up the combox box |
---|
| 302 | id = 0 |
---|
[ef8b580] | 303 | import sans.models.dispersion_models |
---|
| 304 | self.polydisp= sans.models.dispersion_models.models |
---|
[26bf293] | 305 | self.disp_box = wx.ComboBox(self, -1) |
---|
[ef8b580] | 306 | self.disp_box.SetValue("GaussianModel") |
---|
| 307 | for k,v in self.polydisp.iteritems(): |
---|
| 308 | self.disp_box.Insert(str(v),id) |
---|
| 309 | id+=1 |
---|
[26bf293] | 310 | wx.EVT_COMBOBOX(self.disp_box,-1, self._on_select_Disp) |
---|
| 311 | self.sizer7.Add(self.disp_box,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[e5af88b] | 312 | self.vbox.Layout() |
---|
| 313 | self.SetScrollbars(20,20,55,40) |
---|
| 314 | self.Layout() |
---|
| 315 | self.parent.GetSizer().Layout() |
---|
| 316 | |
---|
| 317 | |
---|
[26bf293] | 318 | def set_range(self, qmin_x, qmax_x, npts): |
---|
[cfc68540] | 319 | """ |
---|
| 320 | Set the range for the plotted models |
---|
| 321 | @param qmin: minimum Q |
---|
| 322 | @param qmax: maximum Q |
---|
| 323 | @param npts: number of Q bins |
---|
| 324 | """ |
---|
| 325 | # Set the data members |
---|
[26bf293] | 326 | self.qmin_x = qmin_x |
---|
| 327 | self.qmax_x = qmax_x |
---|
[cfc68540] | 328 | self.num_points = npts |
---|
| 329 | |
---|
| 330 | # Set the controls |
---|
[26bf293] | 331 | self.qmin.SetValue(format_number(self.qmin_x)) |
---|
| 332 | self.qmax.SetValue(format_number(self.qmax_x)) |
---|
[cfc68540] | 333 | self.npts.SetValue(format_number(self.num_points)) |
---|
[26bf293] | 334 | def checkFitRange(self): |
---|
| 335 | """ |
---|
| 336 | Check the validity of fitting range |
---|
| 337 | @note: qmin should always be less than qmax or else each control box |
---|
| 338 | background is colored in pink. |
---|
| 339 | """ |
---|
| 340 | |
---|
| 341 | flag = True |
---|
| 342 | valueMin = self.qmin.GetValue() |
---|
| 343 | valueMax = self.qmax.GetValue() |
---|
| 344 | # Check for possible values entered |
---|
| 345 | #print "fitpage: checkfitrange:",valueMin,valueMax |
---|
| 346 | try: |
---|
| 347 | if (float(valueMax)> float(valueMin)): |
---|
| 348 | self.qmax.SetBackgroundColour(wx.WHITE) |
---|
| 349 | self.qmin.SetBackgroundColour(wx.WHITE) |
---|
| 350 | else: |
---|
| 351 | flag = False |
---|
| 352 | self.qmin.SetBackgroundColour("pink") |
---|
| 353 | self.qmax.SetBackgroundColour("pink") |
---|
| 354 | except: |
---|
| 355 | flag = False |
---|
| 356 | self.qmin.SetBackgroundColour("pink") |
---|
| 357 | self.qmax.SetBackgroundColour("pink") |
---|
| 358 | |
---|
| 359 | self.qmin.Refresh() |
---|
| 360 | self.qmax.Refresh() |
---|
| 361 | return flag |
---|
| 362 | |
---|
| 363 | |
---|
[1b07935d] | 364 | |
---|
[00561739] | 365 | def onClose(self,event): |
---|
| 366 | """ close the page associated with this panel""" |
---|
[26bf293] | 367 | self.parent.onClose() |
---|
[00561739] | 368 | |
---|
[1b07935d] | 369 | |
---|
[dc317d1] | 370 | |
---|
[f39511b] | 371 | def onModel2D(self, event): |
---|
[86c1832] | 372 | """ |
---|
| 373 | call manager to plot model in 2D |
---|
| 374 | """ |
---|
[24ea33c] | 375 | # If the 2D display is not currently enabled, plot the model in 2D |
---|
| 376 | # and set the enable2D flag. |
---|
| 377 | if self.enable2D==False: |
---|
| 378 | self.enable2D=True |
---|
[cfc68540] | 379 | self._draw_model() |
---|
[e5af88b] | 380 | self.model_view.Disable() |
---|
[24ea33c] | 381 | |
---|
[86c1832] | 382 | |
---|
[32d802f] | 383 | def select_model(self, model, name): |
---|
[3dc83be] | 384 | """ |
---|
| 385 | Select a new model |
---|
| 386 | @param model: model object |
---|
| 387 | """ |
---|
[ef8b580] | 388 | self.model = model |
---|
| 389 | self.parent.model_page.name = name |
---|
| 390 | self.parent.draw_model_name = name |
---|
| 391 | |
---|
| 392 | print "select_model", self.name,model.__class__ |
---|
[3dc83be] | 393 | self.set_panel(model) |
---|
[32d802f] | 394 | self._draw_model(name) |
---|
[3dc83be] | 395 | |
---|
| 396 | # Select the model from the combo box |
---|
| 397 | items = self.modelbox.GetItems() |
---|
| 398 | for i in range(len(items)): |
---|
[32d802f] | 399 | print "model name",items[i],model.name, model.__class__.__name__ |
---|
| 400 | if items[i]==name: |
---|
[3dc83be] | 401 | self.modelbox.SetSelection(i) |
---|
[26bf293] | 402 | |
---|
| 403 | |
---|
| 404 | def _on_select_Disp(self,event): |
---|
| 405 | """ |
---|
| 406 | allow selecting different dispersion |
---|
| 407 | self.disp_list should change type later .now only gaussian |
---|
| 408 | """ |
---|
[ef8b580] | 409 | type =event.GetString() |
---|
| 410 | self.set_panel_dispers( self.disp_list,type ) |
---|
[26bf293] | 411 | |
---|
[1b07935d] | 412 | def _on_select_model(self,event): |
---|
| 413 | """ |
---|
| 414 | react when a model is selected from page's combo box |
---|
| 415 | post an event to its owner to draw an appropriate theory |
---|
| 416 | """ |
---|
[26bf293] | 417 | self.disable_disp.SetValue(True) |
---|
| 418 | self.sizer8.Clear(True) |
---|
| 419 | self.sizer7.Clear(True) |
---|
| 420 | self.vbox.Layout() |
---|
| 421 | self.SetScrollbars(20,20,55,40) |
---|
| 422 | self.Layout() |
---|
| 423 | self.parent.GetSizer().Layout() |
---|
[1b07935d] | 424 | for item in self.model_list_box.itervalues(): |
---|
[2dbb681] | 425 | name = item.__name__ |
---|
[86c1832] | 426 | if hasattr(item, "name"): |
---|
| 427 | name = item.name |
---|
[2dbb681] | 428 | if name ==event.GetString(): |
---|
[86c1832] | 429 | model=item() |
---|
[b2c3225] | 430 | self.model= model |
---|
[2dbb681] | 431 | self.set_panel(model) |
---|
[86c1832] | 432 | self.name= name |
---|
[ef8b580] | 433 | |
---|
| 434 | self.parent.model_page.name=name |
---|
| 435 | self.parent.draw_model_name=name |
---|
[cfc68540] | 436 | #self.manager.draw_model(model, name) |
---|
[ef8b580] | 437 | #self.enable2D=False |
---|
| 438 | #self.model_view.Enable() |
---|
[32d802f] | 439 | self._draw_model(name) |
---|
[d23544dc] | 440 | |
---|
[1b07935d] | 441 | |
---|
| 442 | def get_model_box(self): |
---|
| 443 | """ return reference to combox box self.model""" |
---|
| 444 | return self.modelbox |
---|
| 445 | |
---|
| 446 | |
---|
| 447 | def get_param_list(self): |
---|
| 448 | """ |
---|
| 449 | @return self.param_toFit: list containing references to TextCtrl |
---|
| 450 | checked.Theses TextCtrl will allow reference to parameters to fit. |
---|
| 451 | @raise: if return an empty list of parameter fit will nnote work |
---|
| 452 | properly so raise ValueError,"missing parameter to fit" |
---|
| 453 | """ |
---|
| 454 | if self.param_toFit !=[]: |
---|
| 455 | return self.param_toFit |
---|
| 456 | else: |
---|
| 457 | raise ValueError,"missing parameter to fit" |
---|
| 458 | |
---|
| 459 | |
---|
[2dbb681] | 460 | def set_panel(self,model): |
---|
[1b07935d] | 461 | """ |
---|
| 462 | Build the panel from the model content |
---|
| 463 | @param model: the model selected in combo box for fitting purpose |
---|
| 464 | """ |
---|
[26bf293] | 465 | print "set_panel", model |
---|
[94999eb] | 466 | |
---|
[04edd0d] | 467 | self.sizer5.Clear(True) |
---|
[1b07935d] | 468 | self.parameters = [] |
---|
| 469 | self.param_toFit=[] |
---|
[26bf293] | 470 | self.fixed_param=[] |
---|
[1b07935d] | 471 | self.model = model |
---|
| 472 | keys = self.model.getParamList() |
---|
[26bf293] | 473 | #list of dispersion paramaters |
---|
| 474 | self.disp_list=self.model.getDispParamList() |
---|
| 475 | |
---|
[1b07935d] | 476 | keys.sort() |
---|
[26bf293] | 477 | ik=0 |
---|
| 478 | im=1 |
---|
[d171299] | 479 | |
---|
[49b7efa] | 480 | iy = 1 |
---|
[26bf293] | 481 | ix = 0 |
---|
| 482 | self.cb1 = wx.CheckBox(self, -1,"Select all", (10, 10)) |
---|
| 483 | if self.data!=None: |
---|
| 484 | wx.EVT_CHECKBOX(self, self.cb1.GetId(), self.select_all_param) |
---|
| 485 | self.cb1.SetValue(False) |
---|
| 486 | else: |
---|
| 487 | self.cb1.Disable() |
---|
| 488 | self.cb1.Hide() |
---|
| 489 | |
---|
| 490 | self.sizer5.Add(self.cb1,(iy, ix),(1,1),\ |
---|
[1b07935d] | 491 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 492 | ix +=1 |
---|
| 493 | self.text2_2 = wx.StaticText(self, -1, 'Values') |
---|
[26bf293] | 494 | self.sizer5.Add(self.text2_2,(iy, ix),(1,1),\ |
---|
[1b07935d] | 495 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[26bf293] | 496 | ix +=2 |
---|
| 497 | self.text2_3 = wx.StaticText(self, -1, 'Errors') |
---|
| 498 | self.sizer5.Add(self.text2_3,(iy, ix),(1,1),\ |
---|
| 499 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 500 | self.text2_3.Hide() |
---|
[1b07935d] | 501 | ix +=1 |
---|
| 502 | self.text2_4 = wx.StaticText(self, -1, 'Units') |
---|
[26bf293] | 503 | self.sizer5.Add(self.text2_4,(iy, ix),(1,1),\ |
---|
[1b07935d] | 504 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 505 | self.text2_4.Hide() |
---|
[26bf293] | 506 | disp_list=self.model.getDispParamList() |
---|
[1b07935d] | 507 | for item in keys: |
---|
[04edd0d] | 508 | if not item in disp_list: |
---|
| 509 | iy += 1 |
---|
| 510 | ix = 0 |
---|
[26bf293] | 511 | |
---|
| 512 | cb = wx.CheckBox(self, -1, item, (10, 10)) |
---|
| 513 | if self.data!=None: |
---|
| 514 | cb.SetValue(False) |
---|
| 515 | wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) |
---|
| 516 | else: |
---|
| 517 | cb.Disable() |
---|
| 518 | self.sizer5.Add( cb,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 519 | |
---|
[04edd0d] | 520 | ix += 1 |
---|
| 521 | value= self.model.getParam(item) |
---|
| 522 | ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) |
---|
| 523 | ctl1.SetValue(str (format_number(value))) |
---|
| 524 | ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
[26bf293] | 525 | ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) |
---|
| 526 | self.sizer5.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) |
---|
[04edd0d] | 527 | |
---|
[26bf293] | 528 | ix += 1 |
---|
| 529 | text2=wx.StaticText(self, -1, '+/-') |
---|
| 530 | self.sizer5.Add(text2,(iy, ix),(1,1),\ |
---|
| 531 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 532 | text2.Hide() |
---|
| 533 | ix += 1 |
---|
| 534 | ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) |
---|
| 535 | self.sizer5.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 536 | ctl2.Hide() |
---|
| 537 | ix +=1 |
---|
[04edd0d] | 538 | # Units |
---|
| 539 | try: |
---|
| 540 | units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) |
---|
| 541 | except: |
---|
| 542 | units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) |
---|
[26bf293] | 543 | self.sizer5.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 544 | |
---|
| 545 | self.parameters.append([cb,ctl1,text2,ctl2]) |
---|
[04edd0d] | 546 | |
---|
| 547 | iy+=1 |
---|
[26bf293] | 548 | self.sizer5.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[04edd0d] | 549 | |
---|
[1b07935d] | 550 | #Display units text on panel |
---|
| 551 | for item in keys: |
---|
| 552 | if self.model.details[item][0]!='': |
---|
| 553 | self.text2_4.Show() |
---|
| 554 | break |
---|
| 555 | else: |
---|
| 556 | self.text2_4.Hide() |
---|
[26bf293] | 557 | #Disable or enable fit button |
---|
| 558 | """ |
---|
| 559 | if not (len(self.param_toFit ) >0): |
---|
| 560 | self.qmin.Disable() |
---|
| 561 | self.qmax.Disable() |
---|
| 562 | else: |
---|
| 563 | self.qmin.Enable() |
---|
| 564 | self.qmax.Enable() |
---|
| 565 | """ |
---|
[1b07935d] | 566 | self.vbox.Layout() |
---|
[68dada4] | 567 | self.SetScrollbars(20,20,55,40) |
---|
[26bf293] | 568 | self.Layout() |
---|
| 569 | self.parent.GetSizer().Layout() |
---|
[ef8b580] | 570 | def _selectDlg(self): |
---|
| 571 | import os |
---|
| 572 | dlg = wx.FileDialog(self, "Choose a weight file", os.getcwd(), "", "*.*", wx.OPEN) |
---|
| 573 | path = None |
---|
| 574 | if dlg.ShowModal() == wx.ID_OK: |
---|
| 575 | path = dlg.GetPath() |
---|
| 576 | dlg.Destroy() |
---|
| 577 | return path |
---|
| 578 | def read_file(self, path): |
---|
| 579 | try: |
---|
| 580 | input_f = open(path, 'r') |
---|
| 581 | buff = input_f.read() |
---|
| 582 | lines = buff.split('\n') |
---|
| 583 | |
---|
| 584 | angles = [] |
---|
| 585 | weights=[] |
---|
| 586 | for line in lines: |
---|
| 587 | toks = line.split() |
---|
| 588 | if len(toks)==2: |
---|
| 589 | try: |
---|
| 590 | angle = float(toks[0]) |
---|
| 591 | weight = float(toks[1]) |
---|
| 592 | except: |
---|
| 593 | # Skip non-data lines |
---|
| 594 | pass |
---|
| 595 | angles.append(angle) |
---|
| 596 | weights.append(weight) |
---|
| 597 | return numpy.array(angles), numpy.array(weights) |
---|
| 598 | except: |
---|
| 599 | raise |
---|
| 600 | |
---|
| 601 | def set_panel_dispers(self, disp_list, type="GaussianModel" ): |
---|
[26bf293] | 602 | |
---|
[e5af88b] | 603 | self.fittable_param=[] |
---|
| 604 | self.fixed_param=[] |
---|
| 605 | |
---|
[26bf293] | 606 | ix=0 |
---|
| 607 | iy=1 |
---|
[ef8b580] | 608 | ### this will become a separate method |
---|
| 609 | if type== "MyModel": |
---|
| 610 | |
---|
| 611 | self.sizer8.Clear(True) |
---|
| 612 | path = self._selectDlg() |
---|
| 613 | dispersion=None |
---|
| 614 | for key, value in self.polydisp.iteritems(): |
---|
| 615 | if value =="MyModel": |
---|
| 616 | dispersion= key() |
---|
| 617 | break |
---|
| 618 | values,weights = self.read_file(path) |
---|
| 619 | dispersion.set_weights( values, weights) |
---|
| 620 | print "sipersion model", dispersion.value |
---|
| 621 | for param in self.model.dispersion.keys(): |
---|
| 622 | print |
---|
| 623 | print "on MyModel disp",dispersion,param, self.model.set_dispersion(param, dispersion) |
---|
| 624 | |
---|
| 625 | wx.PostEvent(self.parent.parent, StatusEvent(status=\ |
---|
| 626 | " Selected Distribution: %s"%path)) |
---|
| 627 | |
---|
| 628 | if type== "GaussianModel" : |
---|
[e5af88b] | 629 | print "went here" |
---|
[ef8b580] | 630 | |
---|
[e5af88b] | 631 | self.sizer8.Clear(True) |
---|
[26bf293] | 632 | disp = wx.StaticText(self, -1, 'Dispersion') |
---|
| 633 | self.sizer8.Add(disp,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 634 | ix += 1 |
---|
| 635 | values = wx.StaticText(self, -1, 'Values') |
---|
| 636 | self.sizer8.Add(values,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 637 | ix +=2 |
---|
| 638 | self.text2_3 = wx.StaticText(self, -1, 'Errors') |
---|
| 639 | self.sizer8.Add(self.text2_3,(iy, ix),(1,1),\ |
---|
| 640 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 641 | self.text2_3.Hide() |
---|
| 642 | |
---|
| 643 | ix += 1 |
---|
| 644 | npts = wx.StaticText(self, -1, 'Npts') |
---|
| 645 | self.sizer8.Add(npts,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 646 | ix += 1 |
---|
| 647 | nsigmas = wx.StaticText(self, -1, 'Nsigmas') |
---|
| 648 | self.sizer8.Add(nsigmas,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 649 | |
---|
| 650 | disp_list.sort() |
---|
[ef8b580] | 651 | print disp_list,self.model.dispersion |
---|
[26bf293] | 652 | for item in self.model.dispersion.keys(): |
---|
| 653 | name1=item+".width" |
---|
| 654 | name2=item+".npts" |
---|
| 655 | name3=item+".nsigmas" |
---|
| 656 | iy += 1 |
---|
| 657 | for p in self.model.dispersion[item].keys(): |
---|
| 658 | #print "name 1 2 3", name1, name2, name3 |
---|
| 659 | if p=="width": |
---|
| 660 | ix = 0 |
---|
| 661 | cb = wx.CheckBox(self, -1, name1, (10, 10)) |
---|
| 662 | if self.data !=None: |
---|
| 663 | cb.SetValue(False) |
---|
| 664 | wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) |
---|
| 665 | else: |
---|
| 666 | cb.Disable() |
---|
| 667 | self.sizer8.Add( cb,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 668 | ix = 1 |
---|
| 669 | value= self.model.getParam(name1) |
---|
| 670 | ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) |
---|
| 671 | ctl1.SetValue(str (format_number(value))) |
---|
| 672 | ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 673 | ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) |
---|
| 674 | self.sizer8.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) |
---|
| 675 | |
---|
| 676 | ix = 2 |
---|
| 677 | text2=wx.StaticText(self, -1, '+/-') |
---|
| 678 | self.sizer8.Add(text2,(iy, ix),(1,1),\ |
---|
| 679 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 680 | text2.Hide() |
---|
| 681 | ix = 3 |
---|
| 682 | ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) |
---|
| 683 | self.sizer8.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 684 | ctl2.Hide() |
---|
[94999eb] | 685 | self.fittable_param.append([cb,ctl1,text2,ctl2]) |
---|
[26bf293] | 686 | |
---|
| 687 | |
---|
| 688 | elif p=="npts": |
---|
| 689 | ix =4 |
---|
| 690 | value= self.model.getParam(name2) |
---|
| 691 | Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) |
---|
| 692 | Tctl.SetValue(str (format_number(value))) |
---|
| 693 | Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 694 | Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) |
---|
| 695 | self.sizer8.Add(Tctl, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 696 | self.fixed_param.append([name2, Tctl]) |
---|
| 697 | elif p=="nsigmas": |
---|
| 698 | ix =5 |
---|
| 699 | value= self.model.getParam(name3) |
---|
| 700 | Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) |
---|
| 701 | Tctl.SetValue(str (format_number(value))) |
---|
| 702 | Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 703 | Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) |
---|
| 704 | self.sizer8.Add(Tctl, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 705 | self.fixed_param.append([name3, Tctl]) |
---|
[ef8b580] | 706 | wx.PostEvent(self.parent.parent, StatusEvent(status=\ |
---|
| 707 | " Selected Distribution: Gaussian")) |
---|
[e5af88b] | 708 | ix =0 |
---|
| 709 | iy +=1 |
---|
| 710 | self.sizer8.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 711 | self.vbox.Layout() |
---|
| 712 | self.SetScrollbars(20,20,55,40) |
---|
| 713 | self.Layout() |
---|
| 714 | self.parent.GetSizer().Layout() |
---|
[ef8b580] | 715 | |
---|
[26bf293] | 716 | |
---|
| 717 | |
---|
[1b07935d] | 718 | |
---|
| 719 | def _onparamEnter(self,event): |
---|
| 720 | """ |
---|
| 721 | when enter value on panel redraw model according to changed |
---|
| 722 | """ |
---|
| 723 | self.set_model_parameter() |
---|
| 724 | |
---|
| 725 | def set_model_parameter(self): |
---|
| 726 | if len(self.parameters) !=0 and self.model !=None: |
---|
[24ea33c] | 727 | # Flag to register when a parameter has changed. |
---|
| 728 | is_modified = False |
---|
[e5af88b] | 729 | for item in self.fittable_param: |
---|
| 730 | try: |
---|
| 731 | name=str(item[0].GetLabelText()) |
---|
| 732 | value= float(item[1].GetValue()) |
---|
| 733 | #print "model para", name,value |
---|
| 734 | # If the value of the parameter has changed, |
---|
| 735 | # update the model and set the is_modified flag |
---|
| 736 | if value != self.model.getParam(name): |
---|
| 737 | #print "went hereee" |
---|
| 738 | self.model.setParam(name,value) |
---|
| 739 | is_modified = True |
---|
| 740 | |
---|
| 741 | except: |
---|
| 742 | raise |
---|
| 743 | wx.PostEvent(self.parent.parent, StatusEvent(status=\ |
---|
| 744 | "Model Drawing Error:wrong value entered : %s"% sys.exc_value)) |
---|
| 745 | |
---|
[26bf293] | 746 | for item in self.fixed_param: |
---|
| 747 | try: |
---|
| 748 | name=str(item[0]) |
---|
| 749 | value= float(item[1].GetValue()) |
---|
| 750 | #print "model para", name,value,self.model.getParam(name) |
---|
| 751 | # If the value of the parameter has changed, |
---|
| 752 | # update the model and set the is_modified flag |
---|
| 753 | if value != self.model.getParam(name): |
---|
| 754 | #print "went hereee" |
---|
| 755 | self.model.setParam(name,value) |
---|
| 756 | is_modified = True |
---|
| 757 | |
---|
| 758 | except: |
---|
[e5af88b] | 759 | raise |
---|
| 760 | wx.PostEvent(self.parent.parent, StatusEvent(status=\ |
---|
[26bf293] | 761 | "Model Drawing Error:wrong value entered : %s"% sys.exc_value)) |
---|
| 762 | |
---|
[db709e4] | 763 | for item in self.parameters: |
---|
[a5aaec9] | 764 | try: |
---|
| 765 | name=str(item[0].GetLabelText()) |
---|
| 766 | value= float(item[1].GetValue()) |
---|
[26bf293] | 767 | #print " fittable model para", name,value |
---|
[a5aaec9] | 768 | # If the value of the parameter has changed, |
---|
| 769 | # update the model and set the is_modified flag |
---|
| 770 | if value != self.model.getParam(name): |
---|
[26bf293] | 771 | #print "went here", name,value |
---|
[a5aaec9] | 772 | self.model.setParam(name,value) |
---|
| 773 | is_modified = True |
---|
[db709e4] | 774 | except: |
---|
[26bf293] | 775 | wx.PostEvent(self.parent.parent, StatusEvent(status=\ |
---|
[db709e4] | 776 | "Model Drawing Error:wrong value entered : %s"% sys.exc_value)) |
---|
| 777 | |
---|
| 778 | # Here we should check whether the boundaries have been modified. |
---|
| 779 | # If qmin and qmax have been modified, update qmin and qmax and |
---|
| 780 | # set the is_modified flag to True |
---|
[26bf293] | 781 | if float(self.qmin.GetValue()) != self.qmin_x: |
---|
| 782 | self.qmin_x = float(self.qmin.GetValue()) |
---|
[a5aaec9] | 783 | is_modified = True |
---|
[26bf293] | 784 | if float(self.qmax.GetValue()) != self.qmax_x: |
---|
| 785 | self.qmax_x = float(self.qmax.GetValue()) |
---|
[a5aaec9] | 786 | is_modified = True |
---|
[e9b4cc4] | 787 | |
---|
[ea20505] | 788 | if float(self.npts.GetValue()) != self.num_points: |
---|
| 789 | self.num_points = float(self.npts.GetValue()) |
---|
| 790 | is_modified = True |
---|
[e9b4cc4] | 791 | |
---|
[a5aaec9] | 792 | if is_modified: |
---|
[cfc68540] | 793 | self._draw_model() |
---|
[2e10b70] | 794 | |
---|
[32d802f] | 795 | def _draw_model(self, name=None): |
---|
[cfc68540] | 796 | """ |
---|
| 797 | Method to draw or refresh a plotted model. |
---|
| 798 | The method will use the data member from the model page |
---|
| 799 | to build a call to the fitting perspective manager. |
---|
[2e10b70] | 800 | |
---|
[cfc68540] | 801 | [Note to coder: This way future changes will be done in only one place.] |
---|
| 802 | """ |
---|
[26bf293] | 803 | #print "_draw_model",self.model |
---|
[32d802f] | 804 | if name==None: |
---|
| 805 | name= self.model.name |
---|
[26bf293] | 806 | |
---|
| 807 | self.manager.draw_model(self.model, name, data=self.data, |
---|
| 808 | qmin=self.qmin_x, qmax=self.qmax_x, |
---|
[cfc68540] | 809 | qstep= self.num_points, |
---|
| 810 | enable2D=self.enable2D) |
---|
[ef8b580] | 811 | |
---|
[26bf293] | 812 | def select_param(self,event): |
---|
| 813 | pass |
---|
| 814 | def select_all_param(self,event): |
---|
| 815 | pass |
---|
[94999eb] | 816 | def select_all_param_helper(self): |
---|
| 817 | """ |
---|
| 818 | Allows selecting or delecting button |
---|
| 819 | """ |
---|
| 820 | self.param_toFit=[] |
---|
| 821 | if self.parameters !=[]: |
---|
| 822 | if self.cb1.GetValue()==True: |
---|
| 823 | for item in self.parameters: |
---|
| 824 | item[0].SetValue(True) |
---|
| 825 | list= [item[0],item[1],item[2],item[3]] |
---|
| 826 | self.param_toFit.append(list ) |
---|
| 827 | if len(self.fittable_param)>0: |
---|
| 828 | for item in self.fittable_param: |
---|
| 829 | item[0].SetValue(True) |
---|
| 830 | list= [item[0],item[1],item[2],item[3]] |
---|
| 831 | self.param_toFit.append(list ) |
---|
| 832 | else: |
---|
| 833 | for item in self.parameters: |
---|
| 834 | item[0].SetValue(False) |
---|
| 835 | for item in self.fittable_param: |
---|
| 836 | item[0].SetValue(False) |
---|
| 837 | self.param_toFit=[] |
---|
[ef8b580] | 838 | |
---|
| 839 | |
---|
[26bf293] | 840 | |
---|