Changeset f20767b in sasview
- Timestamp:
- Jul 28, 2009 6:34:36 PM (15 years ago)
- 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:
- e72bd95
- Parents:
- 4176435
- Location:
- sansview/perspectives/fitting
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r6f2c919 rf20767b 61 61 ##list of dispersion parameters 62 62 self.disp_list=[] 63 self.disp_name="" 63 64 ## list of orientation parameters 64 65 self.orientation_params=[] … … 100 101 self.popUpMenu.AppendItem(self._redo) 101 102 self._redo.Enable(False) 102 wx.EVT_MENU(self, id, self.onRedo) 103 wx.EVT_MENU(self, id, self.onRedo) 104 self.popUpMenu.AppendSeparator() 105 106 id = wx.NewId() 107 self._keep = wx.MenuItem(self.popUpMenu,id,"Keep"," Keep the panel status to recall it later") 108 self.popUpMenu.AppendItem(self._keep) 109 self._keep.Enable(True) 110 wx.EVT_MENU(self, id, self.onSave) 111 self.popUpMenu.AppendSeparator() 103 112 104 113 ## Default locations … … 281 290 self.polydisp= sans.models.dispersion_models.models 282 291 self.disp_box = wx.ComboBox(self, -1) 283 292 284 293 for key in self.polydisp.iterkeys(): 285 294 name = str(key.__name__) … … 287 296 # Remove the option until the rest of the code is ready for it 288 297 self.disp_box.Append("Select customized Model",key) 289 290 298 else: 291 299 self.disp_box.Append(name,key) … … 328 336 self.weights=[] 329 337 # Go through the list of dispersion check boxes to identify which one has changed 338 330 339 for p in self.disp_cb_dict: 331 340 self.state.disp_cb_dict[p]= self.disp_cb_dict[p].GetValue() 332 341 # Catch which one of the box was just checked or unchecked. 333 342 if event.GetEventObject() == self.disp_cb_dict[p]: 334 335 343 336 344 if self.disp_cb_dict[p].GetValue() == True: 337 345 # The user wants this parameter to be averaged. … … 390 398 self.state.model._persistency_dict[p] = [self.values, self.weights] 391 399 else: 392 # The parameter was un-selected. Go back to Gaussian model (with 0 pts)393 400 self._reset_dispersity() 394 401 395 ## Redraw the model 402 ## Redraw the model ??? 396 403 self._draw_model() 397 404 … … 411 418 412 419 name= self.popUpMenu.GetLabel(event.GetId()) 420 self._on_select_model_helper() 421 413 422 if name in self.saved_states.keys(): 414 423 previous_state = self.saved_states[name] 415 self.reset_page(previous_state)416 417 424 ## reset state of checkbox,textcrtl and regular parameters value 425 self.reset_page(previous_state) 426 418 427 def onSave(self, event): 419 428 """ 420 429 save history of the data and model 421 430 """ 422 423 431 if self.model==None: 424 432 return … … 429 437 430 438 self.state.model = self.model.clone() 439 self.state.model.name= self.model.name 431 440 #if not hasattr(self.model, "_persistency_dict"): 432 441 #self.model._persistency_dict = {} … … 434 443 435 444 new_state = self.state.clone() 445 new_state.model.name = self.state.model.name 446 436 447 new_state.enable2D = copy.deepcopy(self.enable2D) 437 448 ##Add model state on context menu … … 482 493 item[4].Hide() 483 494 self.Layout() 495 # Get a handle to the TextCtrl 496 widget = evt.GetEventObject() 497 # Select the whole control, after this event resolves 498 wx.CallAfter(widget.SetSelection, -1,-1) 484 499 return 485 500 … … 501 516 # Make sure the mouse event is available to other listeners 502 517 event.Skip() 518 503 519 504 520 def read_file(self, path): … … 555 571 ## save data 556 572 self.state.data= copy.deepcopy(self.data) 557 558 573 try: 559 574 n = self.disp_box.GetCurrentSelection() 560 575 dispersity= self.disp_box.GetClientData(n) 561 576 name= dispersity.__name__ 562 if name == "GaussianDispersion": 577 self.disp_name = name 578 if name == "GaussianDispersion" : 563 579 if hasattr(self,"cb1"): 564 580 self.state.cb1= self.cb1.GetValue() … … 577 593 if hasattr(self,"disp_box"): 578 594 self.state.disp_box = self.disp_box.GetCurrentSelection() 595 579 596 if len(self.disp_cb_dict)>0: 580 597 for k , v in self.disp_cb_dict.iteritems(): 598 581 599 if v ==None : 582 600 self.state.disp_cb_dict[k]= v … … 589 607 if len(self._disp_obj_dict)>0: 590 608 for k , v in self._disp_obj_dict.iteritems(): 609 591 610 self.state._disp_obj_dict[k]= v 611 612 592 613 self.state.values = copy.deepcopy(self.values) 593 614 self.state.weights = copy.deepcopy(self.weights) … … 600 621 self.state.fittable_param =[] 601 622 self.state.fixed_param =[] 623 602 624 603 625 ## save checkbutton state and txtcrtl values … … 606 628 self._copy_parameters_state(self.orientation_params_disp, 607 629 self.state.orientation_params_disp) 630 608 631 self._copy_parameters_state(self.parameters, self.state.parameters) 609 632 self._copy_parameters_state(self.fittable_param, self.state.fittable_param) … … 621 644 self._undo.Enable(False) 622 645 return 646 623 647 self.model= state.model 624 648 self.data = state.data 625 649 self.smearer= state.smearer 626 650 self.enable2D= state.enable2D 651 652 #??? 653 self.disp_cb_dict = state.disp_cb_dict 654 self.disp_list =state.disp_list 655 656 627 657 ## set the state of the radio box 628 658 self.shape_rbutton.SetValue(state.shape_rbutton ) … … 637 667 self.structurebox.SetSelection(state.structurecombobox ) 638 668 self.formfactorbox.SetSelection(state.formfactorcombobox) 669 670 639 671 ## enable the view 2d button if this is a modelpage type 640 672 if hasattr(self,"model_view"): 641 if not self.enable2D: 673 if self.enable2D: 674 self.model_view.Disable() 675 else: 642 676 self.model_view.Enable() 643 else:644 self.model_view.Disable()645 677 ## set the select all check box to the a given state 646 678 if hasattr(self, "cb1"): … … 648 680 649 681 ## reset state of checkbox,textcrtl and regular parameters value 682 650 683 self._reset_parameters_state(self.orientation_params_disp, 651 684 state.orientation_params_disp) … … 653 686 state.orientation_params) 654 687 self._reset_parameters_state(self.parameters,state.parameters) 655 656 ## display dispersion info layer 688 ## display dispersion info layer 657 689 self.enable_disp.SetValue(state.enable_disp) 658 690 self.disable_disp.SetValue(state.disable_disp) 659 691 660 692 if hasattr(self, "disp_box"): 693 661 694 self.disp_box.SetSelection(state.disp_box) 662 695 n= self.disp_box.GetCurrentSelection() 663 696 dispersity= self.disp_box.GetClientData(n) 664 name= dispersity.__name__ 697 name= dispersity.__name__ 698 665 699 self._set_dipers_Param(event=None) 666 700 667 701 #self.disp_cb_dict = {} 668 702 #for k,v in self.state.disp_cb_dict.iteritems(): 669 #self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 670 #self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 703 # self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 704 # self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 705 706 if name=="ArrayDispersion": 671 707 672 if name=="ArrayDispersion":673 708 for item in self.disp_cb_dict.keys(): 674 print "array dispersion",state.values, state.weights 675 self.disp_cb_dict[item].SetValue(state.disp_cb_dict[item]) 676 # Create the dispersion objects 677 from sans.models.dispersion_models import ArrayDispersion 678 disp_model = ArrayDispersion() 679 disp_model.set_weights(state.values, state.weights) 680 681 self._disp_obj_dict[item] = disp_model 682 # Set the new model as the dispersion object for the selected parameter 683 self.model.set_dispersion(item, disp_model) 684 685 #self.model._persistency_dict = {} 686 #self.model._persistency_dict[item] = [state.values, state.weights] 709 710 if hasattr(self.disp_cb_dict[item],"SetValue") : 711 self.disp_cb_dict[item].SetValue(state.disp_cb_dict[item]) 712 # Create the dispersion objects 713 from sans.models.dispersion_models import ArrayDispersion 714 disp_model = ArrayDispersion() 715 if hasattr(state,"values")and self.disp_cb_dict[item].GetValue()==True: 716 if len(state.values)>0: 717 self.values=state.values 718 self.weights=state.weights 719 disp_model.set_weights(self.values, state.weights) 720 else: 721 self._reset_dispersity() 722 723 self._disp_obj_dict[item] = disp_model 724 # Set the new model as the dispersion object for the selected parameter 725 self.model.set_dispersion(item, disp_model) 726 727 #self.model._persistency_dict = {} 728 self.model._persistency_dict[item] = [state.values, state.weights] 687 729 688 730 else: 689 self._disp_obj_dict={} 690 for k , v in self.state._disp_obj_dict.iteritems(): 691 self._disp_obj_dict[k]=v 692 731 732 for k,v in self.state.disp_cb_dict.iteritems(): 733 self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 734 self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 735 736 #self._disp_obj_dict={} 737 #for k , v in self.state._disp_obj_dict.iteritems(): 738 # self._disp_obj_dict[k]=v 739 693 740 ##plotting range restore 694 741 self._reset_plotting_range(state) … … 703 750 self.Refresh() 704 751 #self.compute_chisqr(smearer= self.smearer) 705 752 #self._draw_model() 706 753 ## reset state of checkbox,textcrtl and dispersity parameters value 707 754 self._reset_parameters_state(self.fittable_param,state.fittable_param) … … 714 761 self._reset_context_menu() 715 762 763 #self._reset_dispersity() 764 #self._set_dipers_Param(event=None) #to bo removed //resets disper para value 765 766 #self.disp_cb_dict = {} 767 #for k,v in self.state.disp_cb_dict.iteritems(): 768 #self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 769 #self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 770 771 716 772 ## set the value of the current state to the state given as parameter 717 773 self.state = state.clone() 718 774 self._draw_model() 719 775 720 776 … … 886 942 @param statelist: list of state object to store the current state 887 943 """ 888 944 #statelist=[] 889 945 if len(listtocopy)==0: 890 946 return 891 947 892 948 for item in listtocopy: 949 893 950 checkbox_state = None 894 951 if item[0]!= None: … … 1242 1299 1243 1300 ## post state to fit panel 1301 self.state.parameters =[] 1244 1302 self.state.model =self.model 1303 1245 1304 self.disp_list =self.model.getDispParamList() 1246 self.state.disp_list = self.disp_list ,1305 self.state.disp_list = self.disp_list 1247 1306 self.sizer4_4.Layout() 1248 1307 self.sizer4.Layout() … … 1339 1398 """ 1340 1399 self._reset_dispersity() 1400 1341 1401 if self.model ==None: 1342 1402 self.model_disp.Hide() … … 1351 1411 self.disp_box.Show(True) 1352 1412 ## layout for model containing no dispersity parameters 1413 1353 1414 self.disp_list= self.model.getDispParamList() 1354 if len(self.disp_list)==0: 1415 1416 if len(self.disp_list)==0 and len(self.disp_cb_dict)==0: 1355 1417 self._layout_sizer_noDipers() 1356 1418 else: … … 1362 1424 self.disp_box.SetSelection(0) 1363 1425 self.sizer4_4.Clear(True) 1364 1426 1365 1427 ## post state to fit panel 1366 1428 self.save_current_state() … … 1369 1431 event = PageInfoEvent(page = self) 1370 1432 wx.PostEvent(self.parent, event) 1371 1433 1434 self._draw_model() 1372 1435 self.sizer4_4.Layout() 1373 1436 self.sizer4.Layout() … … 1376 1439 self.SetScrollbars(20,20,200,100) 1377 1440 1378 1379 1441 1380 1442 def _layout_sizer_noDipers(self): … … 1416 1478 self.weights=[] 1417 1479 1418 1419 from sans.models.dispersion_models import GaussianDispersion 1480 1481 from sans.models.dispersion_models import GaussianDispersion, ArrayDispersion 1420 1482 if len(self.disp_cb_dict)==0: 1421 1483 self.sizer4_4.Clear(True) … … 1426 1488 self.SetScrollbars(20,20,200,100) 1427 1489 return 1428 1429 1430 for p in self.disp_cb_dict:1431 # The parameter was un-selected. Go back to Gaussian model (with 0 pts)1432 disp_model = GaussianDispersion()1433 # Store the object to make it persist outside the scope of this method1434 #TODO: refactor model to clean this up?1435 self._disp_obj_dict[p] = disp_model1436 # Set the new model as the dispersion object for the selected parameter1437 self.model.set_dispersion(p, disp_model)1438 # Redraw the model1439 1440 self._draw_model()1490 if (len(self.disp_cb_dict)>0) : 1491 for p in self.disp_cb_dict: 1492 # The parameter was un-selected. Go back to Gaussian model (with 0 pts) 1493 disp_model = GaussianDispersion() 1494 1495 self._disp_obj_dict[p] = disp_model 1496 # Set the new model as the dispersion object for the selected parameter 1497 try: 1498 self.model.set_dispersion(p, disp_model) 1499 except: 1500 pass 1501 # Redraw the model 1502 self._draw_model() 1441 1503 ## save state into 1442 1504 self.save_current_state() … … 1454 1516 self.disp_list should change type later .now only gaussian 1455 1517 """ 1456 1518 1457 1519 n = self.disp_box.GetCurrentSelection() 1458 1520 dispersity= self.disp_box.GetClientData(n) 1459 1521 name= dispersity.__name__ 1522 self.disp_name = name 1460 1523 if name == "GaussianDispersion": 1461 1524 self._set_sizer_gaussian() 1462 1463 1525 if name == "ArrayDispersion": 1464 1526 self._set_sizer_arraydispersion() … … 1477 1539 self.Refresh() 1478 1540 1479 1480 1481 1482 1541 def _set_sizer_arraydispersion(self): 1483 1542 """ 1484 1543 draw sizer with array dispersity parameters 1485 1544 """ 1545 1486 1546 if len(self.param_toFit)>0: 1487 1547 for item in self.fittable_param: … … 1491 1551 if item in self.param_toFit: 1492 1552 self.param_toFit.remove(item) 1493 1553 1554 1494 1555 self.fittable_param=[] 1495 1556 self.fixed_param=[] 1496 1557 self.orientation_params_disp=[] 1497 1558 self.sizer4_4.Clear(True) 1559 self._reset_dispersity() 1498 1560 ix=0 1499 1561 iy=1 … … 1504 1566 # Add a check box for each parameter. 1505 1567 self.disp_cb_dict = {} 1568 1506 1569 for p in self.model.dispersion.keys(): 1507 ix+=1 1508 self.disp_cb_dict[p] = wx.CheckBox(self, -1, p, (10, 10)) 1509 self.state.disp_cb_dict[p]= self.disp_cb_dict[p].GetValue() 1510 #print "went here======>",self.disp_cb_dict 1511 wx.EVT_CHECKBOX(self, self.disp_cb_dict[p].GetId(), self.select_disp_angle) 1512 self.sizer4_4.Add(self.disp_cb_dict[p], (iy, ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1513 1570 if not p in self.model.orientation_params: 1571 ix+=1 1572 self.disp_cb_dict[p] = wx.CheckBox(self, -1, p, (10, 10)) 1573 self.state.disp_cb_dict[p]= self.disp_cb_dict[p].GetValue() 1574 1575 wx.EVT_CHECKBOX(self, self.disp_cb_dict[p].GetId(), self.select_disp_angle) 1576 self.sizer4_4.Add(self.disp_cb_dict[p], (iy, ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1577 for p in self.model.dispersion.keys(): 1578 if p in self.model.orientation_params: 1579 ix+=1 1580 self.disp_cb_dict[p] = wx.CheckBox(self, -1, p, (10, 10)) 1581 self.state.disp_cb_dict[p]= self.disp_cb_dict[p].GetValue() 1582 if not self.enable2D: 1583 self.disp_cb_dict[p].Disable() 1584 else: 1585 self.disp_cb_dict[p].Enable() 1586 1587 wx.EVT_CHECKBOX(self, self.disp_cb_dict[p].GetId(), self.select_disp_angle) 1588 self.sizer4_4.Add(self.disp_cb_dict[p], (iy, ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1589 1590 1514 1591 ix =0 1515 1592 iy +=1 … … 1519 1596 self.SetScrollbars(20,20,200,100) 1520 1597 ## save state into 1598 1599 self.state.orientation_params =[] 1600 self.state.orientation_params_disp =[] 1601 self.state.parameters =[] 1602 self.state.fittable_param =[] 1603 self.state.fixed_param =[] 1604 1605 ## save checkbutton state and txtcrtl values 1606 1607 self._copy_parameters_state(self.orientation_params, 1608 self.state.orientation_params) 1609 1521 1610 self._copy_parameters_state(self.orientation_params_disp, 1522 1611 self.state.orientation_params_disp) 1612 1613 self._copy_parameters_state(self.parameters, self.state.parameters) 1523 1614 self._copy_parameters_state(self.fittable_param, self.state.fittable_param) 1524 1615 self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 1616 1525 1617 1526 1618 ## post state to fit panel … … 1528 1620 wx.PostEvent(self.parent, event) 1529 1621 1622 1623 1624 1530 1625 1531 1626 def _set_range_sizer(self, title, object1=None,object=None): 1532 1627 """ 1533 TODO: object1 and object are NOT proper parameter names. 1534 Please clean up your code. 1628 Fill the 1535 1629 """ 1536 1630 self.sizer5.Clear(True) … … 1541 1635 self.qmin.SetValue(str(self.qmin_x)) 1542 1636 self.qmin.SetToolTipString("Minimun value of Q in linear scale.") 1637 #self.qmin.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 1638 #self.qmin.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 1639 #self.qmin.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter) 1543 1640 1544 1641 self.qmax = BasicPage.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20)) 1545 1642 self.qmax.SetValue(str(self.qmax_x)) 1546 1643 self.qmax.SetToolTipString("Maximum value of Q in linear scale.") 1644 #self.qmax.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 1645 #self.qmax.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 1646 #self.qmax.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter) 1547 1647 1548 1648 sizer_horizontal=wx.BoxSizer(wx.HORIZONTAL) -
sansview/perspectives/fitting/fitpage.py
r6f2c919 rf20767b 623 623 624 624 self.reset_page_helper(state) 625 evt = ModelEventbox(model=s elf.model)625 evt = ModelEventbox(model=state.model) 626 626 wx.PostEvent(self.event_owner, evt) 627 627 … … 1121 1121 iy+=1 1122 1122 sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 1123 for item in self.model.orientation_params: 1124 if not item in self.disp_list : 1125 iy += 1 1126 ix = 0 1127 ## add parameters name with checkbox for selecting to fit 1128 cb = wx.CheckBox(self, -1, item ) 1129 cb.SetValue(False) 1130 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 1131 if self.data.__class__.__name__ =="Data2D": 1132 cb.Enable() 1133 else: 1134 cb.Disable() 1135 sizer.Add( cb,( iy, ix),(1,1), 1136 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 1137 1138 ## add parameter value 1139 ix += 1 1140 value= self.model.getParam(item) 1141 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 1142 style=wx.TE_PROCESS_ENTER) 1143 1144 ctl1.SetValue(format_number(value)) 1145 if self.data.__class__.__name__ =="Data2D": 1146 ctl1.Enable() 1147 else: 1148 ctl1.Disable() 1149 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 1150 ## text to show error sign 1151 ix += 1 1152 text2=wx.StaticText(self, -1, '+/-') 1153 sizer.Add(text2,(iy, ix),(1,1),\ 1154 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1155 text2.Hide() 1156 ## txtcrtl to add error from fit 1157 ix += 1 1158 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 1159 sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1160 ctl2.Hide() 1161 if self.data.__class__.__name__ =="Data2D": 1162 ctl1.Enable() 1163 else: 1164 ctl1.Disable() 1165 param_min, param_max= self.model.details[item][1:] 1166 ix += 1 1167 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1168 kill_focus_callback = self._onparamRangeEnter, 1169 set_focus_callback = self._onparamRangeEnter) 1170 if param_min ==None: 1171 ctl3.SetValue("") 1172 else: 1173 ctl3.SetValue(str(param_min)) 1174 sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1175 ctl3.Hide() 1176 if self.data.__class__.__name__ =="Data2D": 1177 ctl3.Enable() 1178 else: 1179 ctl3.Disable() 1180 ix += 1 1181 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1182 kill_focus_callback = self._onparamRangeEnter, 1183 set_focus_callback = self._onparamRangeEnter) 1184 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1185 if param_max ==None: 1186 ctl4.SetValue("") 1187 else: 1188 ctl4.SetValue(str(param_max)) 1189 ctl4.Hide() 1190 if self.data.__class__.__name__ =="Data2D": 1191 ctl4.Enable() 1192 else: 1193 ctl4.Disable() 1194 if self.engine_type=="park": 1195 ctl3.Show(True) 1196 ctl4.Show(True) 1197 ix +=1 1198 # Units 1199 try: 1200 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 1201 except: 1202 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 1203 if self.data.__class__.__name__ =="Data2D": 1204 units.Enable() 1205 else: 1206 units.Disable() 1207 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1123 1124 # type can be either Guassian or Array 1125 type= self.model.dispersion.values()[1]["type"] 1126 1127 #For Gaussian only 1128 if type.lower() != "array": 1129 for item in self.model.orientation_params: 1130 if not item in self.disp_list: 1131 iy += 1 1132 ix = 0 1133 ## add parameters name with checkbox for selecting to fit 1134 cb = wx.CheckBox(self, -1, item ) 1135 cb.SetValue(False) 1136 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 1137 if self.data.__class__.__name__ =="Data2D": 1138 cb.Enable() 1139 else: 1140 cb.Disable() 1141 sizer.Add( cb,( iy, ix),(1,1), 1142 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 1143 1144 ## add parameter value 1145 ix += 1 1146 value= self.model.getParam(item) 1147 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 1148 style=wx.TE_PROCESS_ENTER) 1208 1149 1209 1210 ##[cb state, name, value, "+/-", error of fit, min, max , units] 1211 self.parameters.append([cb,item, ctl1, 1212 text2,ctl2, ctl3, ctl4,units]) 1213 self.orientation_params.append([cb,item, ctl1, 1214 text2,ctl2, ctl3, ctl4,units]) 1150 ctl1.SetValue(format_number(value)) 1151 if self.data.__class__.__name__ =="Data2D": 1152 ctl1.Enable() 1153 else: 1154 ctl1.Disable() 1155 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 1156 ## text to show error sign 1157 ix += 1 1158 text2=wx.StaticText(self, -1, '+/-') 1159 sizer.Add(text2,(iy, ix),(1,1),\ 1160 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1161 text2.Hide() 1162 ## txtcrtl to add error from fit 1163 ix += 1 1164 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 1165 sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1166 ctl2.Hide() 1167 if self.data.__class__.__name__ =="Data2D": 1168 ctl1.Enable() 1169 else: 1170 ctl1.Disable() 1171 param_min, param_max= self.model.details[item][1:] 1172 ix += 1 1173 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1174 kill_focus_callback = self._onparamRangeEnter, 1175 set_focus_callback = self._onparamRangeEnter) 1176 if param_min ==None: 1177 ctl3.SetValue("") 1178 else: 1179 ctl3.SetValue(str(param_min)) 1180 sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1181 ctl3.Hide() 1182 if self.data.__class__.__name__ =="Data2D": 1183 ctl3.Enable() 1184 else: 1185 ctl3.Disable() 1186 ix += 1 1187 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1188 kill_focus_callback = self._onparamRangeEnter, 1189 set_focus_callback = self._onparamRangeEnter) 1190 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1191 if param_max ==None: 1192 ctl4.SetValue("") 1193 else: 1194 ctl4.SetValue(str(param_max)) 1195 ctl4.Hide() 1196 if self.data.__class__.__name__ =="Data2D": 1197 ctl4.Enable() 1198 else: 1199 ctl4.Disable() 1200 if self.engine_type=="park": 1201 ctl3.Show(True) 1202 ctl4.Show(True) 1203 ix +=1 1204 # Units 1205 try: 1206 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 1207 except: 1208 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 1209 if self.data.__class__.__name__ =="Data2D": 1210 units.Enable() 1211 else: 1212 units.Disable() 1213 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1214 1215 1216 ##[cb state, name, value, "+/-", error of fit, min, max , units] 1217 self.parameters.append([cb,item, ctl1, 1218 text2,ctl2, ctl3, ctl4,units]) 1219 self.orientation_params.append([cb,item, ctl1, 1220 text2,ctl2, ctl3, ctl4,units]) 1215 1221 1216 1222 iy+=1 -
sansview/perspectives/fitting/fitpanel.py
r6f2c919 rf20767b 145 145 146 146 pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE 147 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.onClosePage) 147 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.onClosePage) 148 148 149 149 #dictionary of miodel {model class name, model class} … … 389 389 self.fit_page_name[page.window_name].appendItem(page.createMemento()) 390 390 391 #print " current added state: ",len(self.fit_page_name[page.window_name])392 393 391 def _onUndo(self, event ): 394 392 """ -
sansview/perspectives/fitting/modelpage.py
r6f2c919 rf20767b 35 35 description="" 36 36 if self.model!=None: 37 37 38 description = self.model.description 38 39 … … 279 280 # If the 2D display is not currently enabled, plot the model in 2D 280 281 # and set the enable2D flag. 282 281 283 if self.fitrange: 282 284 self.enable2D = True 283 285 284 286 if self.enable2D: 285 287 self._draw_model() … … 290 292 if item[2]!=None: 291 293 item[2].Enable() 292 if len(self.orientation_params_disp)>0: 293 for item in self.orientation_params_disp: 294 if item[2]!=None: 295 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() 296 301 self.state.enable2D = copy.deepcopy(self.enable2D) 297 302 ## post state to fit panel … … 329 334 self.state.structurecombobox = self.structurebox.GetCurrentSelection() 330 335 self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection() 331 #print "_on_select_model",self.state.structurecombobox,self.state.formfactorcombobox332 336 333 337 ## post state to fit panel … … 504 508 sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 505 509 for item in self.model.orientation_params: 506 if not item in self.disp_list :510 if not item in self.disp_list and item in keys: 507 511 iy += 1 508 512 ix = 0 … … 536 540 self.orientation_params.append([None,item, ctl1, 537 541 None,None, None, None,None]) 538 542 539 543 iy+=1 540 544 sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
Note: See TracChangeset
for help on using the changeset viewer.