1 | |
---|
2 | import wx |
---|
3 | import wx.lib.newevent |
---|
4 | import numpy |
---|
5 | import copy |
---|
6 | import math |
---|
7 | from sans.models.dispersion_models import ArrayDispersion, GaussianDispersion |
---|
8 | |
---|
9 | from sans.guicomm.events import StatusEvent |
---|
10 | from sans.guiframe.utils import format_number |
---|
11 | (ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent() |
---|
12 | _BOX_WIDTH = 76 |
---|
13 | |
---|
14 | import basepage |
---|
15 | from basepage import BasicPage |
---|
16 | from basepage import PageInfoEvent |
---|
17 | |
---|
18 | class ModelPage(BasicPage): |
---|
19 | """ |
---|
20 | FitPanel class contains fields allowing to display results when |
---|
21 | fitting a model and one data |
---|
22 | @note: For Fit to be performed the user should check at least one parameter |
---|
23 | on fit Panel window. |
---|
24 | |
---|
25 | """ |
---|
26 | |
---|
27 | def __init__(self,parent, page_info): |
---|
28 | BasicPage.__init__(self, parent, page_info) |
---|
29 | """ |
---|
30 | Initialization of the Panel |
---|
31 | """ |
---|
32 | self._fill_model_sizer( self.sizer1) |
---|
33 | self._fill_range_sizer() |
---|
34 | |
---|
35 | description="" |
---|
36 | if self.model!=None: |
---|
37 | |
---|
38 | description = self.model.description |
---|
39 | |
---|
40 | self.select_model(self.model) |
---|
41 | self.set_model_description(description,self.sizer2) |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | |
---|
46 | def _on_display_description(self, event): |
---|
47 | """ |
---|
48 | Show or Hide description |
---|
49 | @param event: wx.EVT_RADIOBUTTON |
---|
50 | """ |
---|
51 | self._on_display_description_helper() |
---|
52 | |
---|
53 | self.SetScrollbars(20,20,200,100) |
---|
54 | self.Refresh() |
---|
55 | |
---|
56 | |
---|
57 | |
---|
58 | def _on_display_description_helper(self): |
---|
59 | """ |
---|
60 | Show or Hide description |
---|
61 | @param event: wx.EVT_RADIOBUTTON |
---|
62 | """ |
---|
63 | |
---|
64 | ## Show description |
---|
65 | if self.description_hide.GetValue(): |
---|
66 | self.sizer_description.Clear(True) |
---|
67 | |
---|
68 | else: |
---|
69 | description="Model contains no description" |
---|
70 | if self.model!=None: |
---|
71 | description = self.model.description |
---|
72 | if description.lstrip().rstrip() =="": |
---|
73 | description="Model contains no description" |
---|
74 | self.description = wx.StaticText( self,-1,str(description) ) |
---|
75 | self.sizer_description.Add( self.description, 1, wx.EXPAND | wx.ALL, 10 ) |
---|
76 | |
---|
77 | self.Layout() |
---|
78 | |
---|
79 | |
---|
80 | def _fill_range_sizer(self): |
---|
81 | """ |
---|
82 | Fill the sizer containing the plotting range |
---|
83 | add access to npts |
---|
84 | """ |
---|
85 | sizer_npts= wx.GridSizer(1, 1,5, 5) |
---|
86 | |
---|
87 | self.npts = BasicPage.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20)) |
---|
88 | self.npts.SetValue(format_number(self.num_points)) |
---|
89 | self.npts.SetToolTipString("Number of point to plot.") |
---|
90 | |
---|
91 | sizer_npts.Add(wx.StaticText(self, -1, 'Npts'),1, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) |
---|
92 | sizer_npts.Add(self.npts,1, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) |
---|
93 | self._set_range_sizer( title="Plotted Q Range", object= sizer_npts) |
---|
94 | |
---|
95 | |
---|
96 | def _on_select_model(self, event): |
---|
97 | """ |
---|
98 | call back for model selection |
---|
99 | """ |
---|
100 | self._on_select_model_helper() |
---|
101 | |
---|
102 | self.select_model(self.model) |
---|
103 | |
---|
104 | |
---|
105 | def _fill_model_sizer(self, sizer): |
---|
106 | """ |
---|
107 | fill sizer containing model info |
---|
108 | """ |
---|
109 | id = wx.NewId() |
---|
110 | self.model_view =wx.Button(self,id,'View 2D') |
---|
111 | self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D,id=id) |
---|
112 | self.model_view.SetToolTipString("View model in 2D") |
---|
113 | |
---|
114 | ## class base method to add view 2d button |
---|
115 | self._set_model_sizer(sizer=sizer, title="Model",object= self.model_view ) |
---|
116 | |
---|
117 | |
---|
118 | def _set_sizer_gaussian(self): |
---|
119 | """ |
---|
120 | draw sizer with gaussian dispersity parameters |
---|
121 | """ |
---|
122 | self.fittable_param=[] |
---|
123 | self.fixed_param=[] |
---|
124 | self.orientation_params_disp=[] |
---|
125 | |
---|
126 | self.sizer4_4.Clear(True) |
---|
127 | if self.model==None: |
---|
128 | ##no model is selected |
---|
129 | return |
---|
130 | if not self.enable_disp.GetValue(): |
---|
131 | ## the user didn't select dispersity display |
---|
132 | return |
---|
133 | self._reset_dispersity() |
---|
134 | # Create the dispersion objects |
---|
135 | for item in self.model.dispersion.keys(): |
---|
136 | disp_model = GaussianDispersion() |
---|
137 | self._disp_obj_dict[item] = disp_model |
---|
138 | self.model.set_dispersion(item, disp_model) |
---|
139 | self.state._disp_obj_dict[item]= disp_model |
---|
140 | |
---|
141 | |
---|
142 | ix=0 |
---|
143 | iy=1 |
---|
144 | disp = wx.StaticText(self, -1, 'Names') |
---|
145 | self.sizer4_4.Add(disp,( iy, ix),(1,1), |
---|
146 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
147 | ix += 1 |
---|
148 | values = wx.StaticText(self, -1, 'Values') |
---|
149 | self.sizer4_4.Add(values,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
150 | |
---|
151 | ix += 1 |
---|
152 | npts = wx.StaticText(self, -1, 'Npts') |
---|
153 | self.sizer4_4.Add(npts,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
154 | ix += 1 |
---|
155 | nsigmas = wx.StaticText(self, -1, 'Nsigmas') |
---|
156 | self.sizer4_4.Add(nsigmas,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
157 | |
---|
158 | for item in self.model.dispersion.keys(): |
---|
159 | if not item in self.model.orientation_params: |
---|
160 | self.disp_cb_dict[item]= None |
---|
161 | name1=item+".width" |
---|
162 | name2=item+".npts" |
---|
163 | name3=item+".nsigmas" |
---|
164 | iy += 1 |
---|
165 | for p in self.model.dispersion[item].keys(): |
---|
166 | if p=="width": |
---|
167 | ix = 0 |
---|
168 | name = wx.StaticText(self, -1, name1) |
---|
169 | self.sizer4_4.Add( name,( iy, ix),(1,1), |
---|
170 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
171 | ix = 1 |
---|
172 | value= self.model.getParam(name1) |
---|
173 | ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), |
---|
174 | style=wx.TE_PROCESS_ENTER) |
---|
175 | ctl1.SetValue(str (format_number(value))) |
---|
176 | self.sizer4_4.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) |
---|
177 | self.fittable_param.append([None,name1,ctl1,None, |
---|
178 | None, None, None,None]) |
---|
179 | elif p=="npts": |
---|
180 | ix =2 |
---|
181 | value= self.model.getParam(name2) |
---|
182 | Tctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), |
---|
183 | style=wx.TE_PROCESS_ENTER) |
---|
184 | Tctl1.SetValue(str (format_number(value))) |
---|
185 | self.sizer4_4.Add(Tctl1, (iy,ix),(1,1), |
---|
186 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
187 | self.fixed_param.append([None,name2, Tctl1,None,None, |
---|
188 | None, None,None]) |
---|
189 | elif p=="nsigmas": |
---|
190 | ix =3 |
---|
191 | value= self.model.getParam(name3) |
---|
192 | Tctl2 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), |
---|
193 | style=wx.TE_PROCESS_ENTER) |
---|
194 | Tctl2.SetValue(str (format_number(value))) |
---|
195 | self.sizer4_4.Add(Tctl2, (iy,ix),(1,1), |
---|
196 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
197 | ix +=1 |
---|
198 | self.sizer4_4.Add((20,20), (iy,ix),(1,1), |
---|
199 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
200 | self.fixed_param.append([None,name3, Tctl2, |
---|
201 | None,None, None, None,None]) |
---|
202 | for item in self.model.dispersion.keys(): |
---|
203 | if item in self.model.orientation_params: |
---|
204 | self.disp_cb_dict[item]= None |
---|
205 | name1=item+".width" |
---|
206 | name2=item+".npts" |
---|
207 | name3=item+".nsigmas" |
---|
208 | iy += 1 |
---|
209 | for p in self.model.dispersion[item].keys(): |
---|
210 | if p=="width": |
---|
211 | ix = 0 |
---|
212 | name = wx.StaticText(self, -1, name1) |
---|
213 | self.sizer4_4.Add( name,( iy, ix),(1,1), |
---|
214 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
215 | ix = 1 |
---|
216 | value= self.model.getParam(name1) |
---|
217 | ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), |
---|
218 | style=wx.TE_PROCESS_ENTER) |
---|
219 | ctl1.SetValue(str (format_number(value))) |
---|
220 | if not self.enable2D: |
---|
221 | ctl1.Disable() |
---|
222 | else: |
---|
223 | ctl1.Enable() |
---|
224 | self.sizer4_4.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) |
---|
225 | self.fittable_param.append([None,name1,ctl1,None, |
---|
226 | None, None, None,None]) |
---|
227 | self.orientation_params_disp.append([None,name1,ctl1,None, |
---|
228 | None, None, None,None]) |
---|
229 | elif p=="npts": |
---|
230 | ix =2 |
---|
231 | value= self.model.getParam(name2) |
---|
232 | Tctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), |
---|
233 | style=wx.TE_PROCESS_ENTER) |
---|
234 | Tctl1.SetValue(str (format_number(value))) |
---|
235 | if not self.enable2D: |
---|
236 | Tctl1.Disable() |
---|
237 | else: |
---|
238 | Tctl1.Enable() |
---|
239 | self.sizer4_4.Add(Tctl1, (iy,ix),(1,1), |
---|
240 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
241 | self.fixed_param.append([None,name2, Tctl1,None,None, |
---|
242 | None, None,None]) |
---|
243 | self.orientation_params_disp.append([None,name2, Tctl1,None,None, |
---|
244 | None, None,None]) |
---|
245 | elif p=="nsigmas": |
---|
246 | ix =3 |
---|
247 | value= self.model.getParam(name3) |
---|
248 | Tctl2 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), |
---|
249 | style=wx.TE_PROCESS_ENTER) |
---|
250 | Tctl2.SetValue(str (format_number(value))) |
---|
251 | if not self.enable2D: |
---|
252 | Tctl2.Disable() |
---|
253 | else: |
---|
254 | Tctl2.Enable() |
---|
255 | self.sizer4_4.Add(Tctl2, (iy,ix),(1,1), |
---|
256 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
257 | ix +=1 |
---|
258 | self.sizer4_4.Add((20,20), (iy,ix),(1,1), |
---|
259 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
260 | self.fixed_param.append([None,name3, Tctl2, |
---|
261 | None,None, None, None,None]) |
---|
262 | self.orientation_params_disp.append([None,name3, Tctl2, |
---|
263 | None,None, None, None,None]) |
---|
264 | |
---|
265 | msg = " Selected Distribution: Gaussian" |
---|
266 | wx.PostEvent(self.parent.parent, StatusEvent( status= msg )) |
---|
267 | self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict) |
---|
268 | ix =0 |
---|
269 | iy +=1 |
---|
270 | self.sizer4_4.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
271 | self.sizer4_4.Layout() |
---|
272 | self.sizer4.Layout() |
---|
273 | self.SetScrollbars(20,20,200,100) |
---|
274 | |
---|
275 | |
---|
276 | def _onModel2D(self, event): |
---|
277 | """ |
---|
278 | call manager to plot model in 2D |
---|
279 | """ |
---|
280 | # If the 2D display is not currently enabled, plot the model in 2D |
---|
281 | # and set the enable2D flag. |
---|
282 | |
---|
283 | if self.fitrange: |
---|
284 | self.enable2D = True |
---|
285 | |
---|
286 | if self.enable2D: |
---|
287 | self._draw_model() |
---|
288 | self.model_view.Disable() |
---|
289 | |
---|
290 | if len(self.orientation_params)>0: |
---|
291 | for item in self.orientation_params: |
---|
292 | if item[2]!=None: |
---|
293 | item[2].Enable() |
---|
294 | if self.disp_name == "ArrayDispersion": |
---|
295 | self._set_sizer_arraydispersion() |
---|
296 | else: |
---|
297 | if len(self.orientation_params_disp)>0: |
---|
298 | for item in self.orientation_params_disp: |
---|
299 | if item[2]!=None: |
---|
300 | item[2].Enable() |
---|
301 | self.state.enable2D = copy.deepcopy(self.enable2D) |
---|
302 | ## post state to fit panel |
---|
303 | self._undo.Enable(True) |
---|
304 | event = PageInfoEvent(page = self) |
---|
305 | wx.PostEvent(self.parent, event) |
---|
306 | |
---|
307 | |
---|
308 | |
---|
309 | def reset_page(self, state): |
---|
310 | """ |
---|
311 | reset the state |
---|
312 | """ |
---|
313 | self.reset_page_helper(state) |
---|
314 | |
---|
315 | |
---|
316 | def select_model(self, model): |
---|
317 | """ |
---|
318 | Select a new model |
---|
319 | @param model: model object |
---|
320 | """ |
---|
321 | self.model = model |
---|
322 | if self.model !=None: |
---|
323 | self.disp_list= self.model.getDispParamList() |
---|
324 | self.set_model_param_sizer(self.model) |
---|
325 | ## keep the sizer view consistent with the model menu selecting |
---|
326 | self._set_model_sizer_selection( self.model ) |
---|
327 | self.enable_disp.SetValue(False) |
---|
328 | self.disable_disp.SetValue(True) |
---|
329 | self.set_dispers_sizer() |
---|
330 | |
---|
331 | self.model_view.SetFocus() |
---|
332 | if self.model !=None: |
---|
333 | self._draw_model() |
---|
334 | self.state.structurecombobox = self.structurebox.GetCurrentSelection() |
---|
335 | self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection() |
---|
336 | |
---|
337 | ## post state to fit panel |
---|
338 | self._undo.Enable(True) |
---|
339 | event = PageInfoEvent(page = self) |
---|
340 | wx.PostEvent(self.parent, event) |
---|
341 | |
---|
342 | |
---|
343 | def set_model_description(self,description,sizer): |
---|
344 | """ |
---|
345 | fill a sizer with description |
---|
346 | @param description: of type string |
---|
347 | @param sizer: wx.BoxSizer() |
---|
348 | """ |
---|
349 | |
---|
350 | sizer.Clear(True) |
---|
351 | box_description= wx.StaticBox(self, -1, 'Model Description') |
---|
352 | boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) |
---|
353 | |
---|
354 | sizer_selection=wx.BoxSizer(wx.HORIZONTAL) |
---|
355 | self.description_hide = wx.RadioButton(self, -1, 'Hide', style=wx.RB_GROUP) |
---|
356 | self.description_show = wx.RadioButton(self, -1, 'Show') |
---|
357 | |
---|
358 | |
---|
359 | if description=="": |
---|
360 | self.description_hide.SetValue(True) |
---|
361 | description=" Description unavailable. Click for details" |
---|
362 | |
---|
363 | self.description = wx.StaticText( self,-1,str(description) ) |
---|
364 | |
---|
365 | self.Bind( wx.EVT_RADIOBUTTON, self._on_display_description, |
---|
366 | id=self.description_hide.GetId() ) |
---|
367 | |
---|
368 | self.Bind( wx.EVT_RADIOBUTTON, self._on_display_description, |
---|
369 | id=self.description_show.GetId() ) |
---|
370 | |
---|
371 | self.model_description = wx.Button(self,-1, label="Details") |
---|
372 | self.model_description.Bind(wx.EVT_BUTTON,self.on_button_clicked) |
---|
373 | self.model_description.SetToolTipString("Click Model Functions in HelpWindow...") |
---|
374 | |
---|
375 | sizer_selection.Add( self.description_show ) |
---|
376 | sizer_selection.Add( (20,20)) |
---|
377 | sizer_selection.Add( self.description_hide ) |
---|
378 | sizer_selection.Add((20,20),0, wx.LEFT|wx.RIGHT|wx.EXPAND,67) |
---|
379 | sizer_selection.Add( self.model_description ) |
---|
380 | |
---|
381 | |
---|
382 | self.sizer_description=wx.BoxSizer(wx.HORIZONTAL) |
---|
383 | self.sizer_description.Add( self.description, 1, wx.EXPAND | wx.ALL, 10 ) |
---|
384 | boxsizer1.Add( sizer_selection) |
---|
385 | boxsizer1.Add( (20,20)) |
---|
386 | boxsizer1.Add( self.sizer_description) |
---|
387 | |
---|
388 | self._on_display_description(event=None) |
---|
389 | sizer.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) |
---|
390 | sizer.Layout() |
---|
391 | |
---|
392 | def on_button_clicked(self,event): |
---|
393 | """ |
---|
394 | #On 'More details' button |
---|
395 | """ |
---|
396 | from helpPanel import HelpWindow |
---|
397 | |
---|
398 | if self.model == None: |
---|
399 | name = 'FuncHelp' |
---|
400 | else: |
---|
401 | name = self.model.name |
---|
402 | frame = HelpWindow(None, -1, name) |
---|
403 | frame.Show(True) |
---|
404 | if frame.rhelp.HasAnchor(name): |
---|
405 | frame.rhelp.ScrollToAnchor(name) |
---|
406 | else: |
---|
407 | msg= "Model does not contains an available description " |
---|
408 | msg +="Please.Search in the Help window" |
---|
409 | wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) |
---|
410 | |
---|
411 | |
---|
412 | |
---|
413 | def set_range(self, qmin_x, qmax_x, npts): |
---|
414 | """ |
---|
415 | Set the range for the plotted models |
---|
416 | @param qmin: minimum Q |
---|
417 | @param qmax: maximum Q |
---|
418 | @param npts: number of Q bins |
---|
419 | """ |
---|
420 | # Set the data members |
---|
421 | self.qmin_x = qmin_x |
---|
422 | self.qmax_x = qmax_x |
---|
423 | self.num_points = npts |
---|
424 | |
---|
425 | # Set the controls |
---|
426 | #For qmin and qmax, do not use format_number.(If do, qmin and max could be different from what is in the data.) |
---|
427 | """ |
---|
428 | self.qmin.SetValue(format_number(self.qmin_x)) |
---|
429 | self.qmax.SetValue(format_number(self.qmax_x)) |
---|
430 | self.npts.SetValue(format_number(self.num_points)) |
---|
431 | """ |
---|
432 | self.qmin.SetValue(str(self.qmin_x)) |
---|
433 | self.qmax.SetValue(str(self.qmax_x)) |
---|
434 | self.npts.SetValue(format_number(self.num_points)) |
---|
435 | |
---|
436 | |
---|
437 | def set_model_param_sizer(self, model): |
---|
438 | """ |
---|
439 | Build the panel from the model content |
---|
440 | @param model: the model selected in combo box for fitting purpose |
---|
441 | """ |
---|
442 | self.sizer3.Clear(True) |
---|
443 | self.parameters = [] |
---|
444 | self.param_toFit=[] |
---|
445 | self.fixed_param=[] |
---|
446 | self.orientation_params=[] |
---|
447 | self.orientation_params_disp=[] |
---|
448 | if model ==None: |
---|
449 | ##no model avaiable to draw sizer |
---|
450 | self.sizer3.Layout() |
---|
451 | self.SetScrollbars(20,20,200,100) |
---|
452 | return |
---|
453 | box_description= wx.StaticBox(self, -1,str("Model Parameters")) |
---|
454 | boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) |
---|
455 | sizer = wx.GridBagSizer(5,5) |
---|
456 | |
---|
457 | self.model = model |
---|
458 | self.set_model_description(self.model.description,self.sizer2) |
---|
459 | |
---|
460 | keys = self.model.getParamList() |
---|
461 | ##list of dispersion parameters |
---|
462 | self.disp_list=self.model.getDispParamList() |
---|
463 | |
---|
464 | keys.sort() |
---|
465 | |
---|
466 | iy = 1 |
---|
467 | ix = 0 |
---|
468 | self.text1_2 = wx.StaticText(self, -1, 'Names') |
---|
469 | sizer.Add(self.text1_2,(iy, ix),(1,1),\ |
---|
470 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
471 | ix +=1 |
---|
472 | self.text2_2 = wx.StaticText(self, -1, 'Values') |
---|
473 | sizer.Add(self.text2_2,(iy, ix),(1,1),\ |
---|
474 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
475 | ix +=1 |
---|
476 | self.text2_4 = wx.StaticText(self, -1, '[Units]') |
---|
477 | sizer.Add(self.text2_4,(iy, ix),(1,1),\ |
---|
478 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
479 | self.text2_4.Hide() |
---|
480 | |
---|
481 | for item in keys: |
---|
482 | if not item in self.disp_list and not item in self.model.orientation_params: |
---|
483 | iy += 1 |
---|
484 | ix = 0 |
---|
485 | name = wx.StaticText(self, -1,item) |
---|
486 | sizer.Add( name,( iy, ix),(1,1), |
---|
487 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
488 | |
---|
489 | ix += 1 |
---|
490 | value= self.model.getParam(item) |
---|
491 | ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), |
---|
492 | style=wx.TE_PROCESS_ENTER) |
---|
493 | |
---|
494 | ctl1.SetValue(str (format_number(value))) |
---|
495 | |
---|
496 | sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) |
---|
497 | ix +=1 |
---|
498 | # Units |
---|
499 | try: |
---|
500 | units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) |
---|
501 | except: |
---|
502 | units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) |
---|
503 | sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
504 | ##[cb state, name, value, "+/-", error of fit, min, max , units] |
---|
505 | self.parameters.append([None,item, ctl1, |
---|
506 | None,None, None, None,None]) |
---|
507 | iy+=1 |
---|
508 | sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
509 | for item in self.model.orientation_params: |
---|
510 | if not item in self.disp_list and item in keys: |
---|
511 | iy += 1 |
---|
512 | ix = 0 |
---|
513 | name = wx.StaticText(self, -1,item) |
---|
514 | sizer.Add( name,( iy, ix),(1,1), |
---|
515 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
516 | |
---|
517 | ix += 1 |
---|
518 | value= self.model.getParam(item) |
---|
519 | ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), |
---|
520 | style=wx.TE_PROCESS_ENTER) |
---|
521 | |
---|
522 | ctl1.SetValue(str (format_number(value))) |
---|
523 | if not self.enable2D: |
---|
524 | ctl1.Disable() |
---|
525 | else: |
---|
526 | ctl1.Enable() |
---|
527 | |
---|
528 | sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) |
---|
529 | ix +=1 |
---|
530 | # Units |
---|
531 | try: |
---|
532 | units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) |
---|
533 | except: |
---|
534 | units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) |
---|
535 | sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
536 | |
---|
537 | ##[cb state, name, value, "+/-", error of fit, min, max , units] |
---|
538 | self.parameters.append([None,item, ctl1, |
---|
539 | None,None, None, None,None]) |
---|
540 | self.orientation_params.append([None,item, ctl1, |
---|
541 | None,None, None, None,None]) |
---|
542 | |
---|
543 | iy+=1 |
---|
544 | sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
545 | |
---|
546 | #Display units text on panel |
---|
547 | for item in keys: |
---|
548 | if self.model.details[item][0]!='': |
---|
549 | self.text2_4.Show() |
---|
550 | break |
---|
551 | else: |
---|
552 | self.text2_4.Hide() |
---|
553 | |
---|
554 | boxsizer1.Add(sizer) |
---|
555 | self.sizer3.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) |
---|
556 | self.sizer3.Layout() |
---|
557 | self.SetScrollbars(20,20,200,100) |
---|
558 | |
---|
559 | |
---|
560 | |
---|
561 | |
---|
562 | class HelpWindow(wx.Frame): |
---|
563 | def __init__(self, parent, id, title): |
---|
564 | wx.Frame.__init__(self, parent, id, title, size=(570, 400)) |
---|
565 | |
---|
566 | from sans.models.CylinderModel import CylinderModel |
---|
567 | model = CylinderModel() |
---|
568 | #from sans.models.LineModel import LineModel |
---|
569 | #model = LineModel() |
---|
570 | from fitpanel import PageInfo |
---|
571 | myinfo = PageInfo(self,model) |
---|
572 | from models import ModelList |
---|
573 | mylist= ModelList() |
---|
574 | |
---|
575 | from sans.models.SphereModel import SphereModel |
---|
576 | from sans.models.SquareWellStructure import SquareWellStructure |
---|
577 | from sans.models.DebyeModel import DebyeModel |
---|
578 | from sans.models.LineModel import LineModel |
---|
579 | name= "shapes" |
---|
580 | list1= [SphereModel] |
---|
581 | mylist.set_list( name, list1) |
---|
582 | |
---|
583 | name= "Shape-independent" |
---|
584 | list1= [DebyeModel] |
---|
585 | mylist.set_list( name, list1) |
---|
586 | |
---|
587 | name= "Structure Factors" |
---|
588 | list1= [SquareWellStructure] |
---|
589 | mylist.set_list( name, list1) |
---|
590 | |
---|
591 | name= "Added models" |
---|
592 | list1= [LineModel] |
---|
593 | mylist.set_list( name, list1) |
---|
594 | |
---|
595 | myinfo.model_list_box = mylist.get_list() |
---|
596 | |
---|
597 | self.page = ModelPage(self, myinfo) |
---|
598 | |
---|
599 | |
---|
600 | |
---|
601 | self.Centre() |
---|
602 | self.Show(True) |
---|
603 | |
---|
604 | |
---|
605 | |
---|
606 | if __name__=="__main__": |
---|
607 | app = wx.App() |
---|
608 | HelpWindow(None, -1, 'HelpWindow') |
---|
609 | app.MainLoop() |
---|
610 | |
---|