Changeset 5ce7f17 in sasview for src/sas/perspectives
- Timestamp:
- Mar 27, 2015 11:05:11 AM (10 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:
- cce0ad3
- Parents:
- a862cea0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/fitting/basepage.py
r7cd87c2 r5ce7f17 175 175 self.orientation_params = [] 176 176 self.orientation_params_disp = [] 177 # Self.model should ALWAYS be None here. It was set to none above in 177 # Self.model should ALWAYS be None here. It was set to none above in 178 178 # this long init setting. no obvious function call in between setting 179 # and this - commenting out on 4/8/2014 by PDB. Remove once clear 179 # and this - commenting out on 4/8/2014 by PDB. Remove once clear 180 180 # it is pointless. 181 181 # if self.model != None: … … 417 417 _on_set_focus_callback = None 418 418 419 def __init__(self, parent, id= 419 def __init__(self, parent, id=-1, 420 420 value=wx.EmptyString, 421 421 pos=wx.DefaultPosition, … … 430 430 431 431 wx.TextCtrl.__init__(self, parent, id, value, pos, 432 432 size, style, validator, name) 433 433 434 434 # Bind appropriate events … … 488 488 set some page important information at once 489 489 """ 490 # THIS METHOD/FUNCTION NO LONGE APPEARS TO BE CALLED. Started up program 490 # THIS METHOD/FUNCTION NO LONGE APPEARS TO BE CALLED. Started up program 491 491 # and started new fit window and PR and Invariant and a fit in fitting 492 492 # but never entered this routine which should be an initialization 493 # routine. Leave for a while but probably something to clean up at 493 # routine. Leave for a while but probably something to clean up at 494 494 # some point? 495 495 # … … 589 589 def get_state(self): 590 590 """ 591 return the current page state 591 592 """ 592 593 return self.state … … 645 646 ## These are called for first time by formfactor_combo_init 646 647 ## itself called from fitpanel only. If we find that I'm wrong and 647 ## we DO need to initialize somehow here - do it by a call to 648 ## formfactor_combo_init 648 ## we DO need to initialize somehow here - do it by a call to 649 ## formfactor_combo_init 649 650 ## self.formfator_combo_init() 650 ## BUT NOT HERE -- make it last line of this 651 ## BUT NOT HERE -- make it last line of this 651 652 ## method so that structure box is populated before _show_comboox_helper 652 653 ## is called. Otherwise wx will complain mightily:-) … … 660 661 # self.model_list_box["Shapes"]) 661 662 self._populate_box(self.structurebox, 662 663 self.model_list_box["Structure Factors"]) 663 664 self.structurebox.Insert("None", 0, None) 664 665 self.structurebox.SetSelection(0) … … 686 687 #---------------------------------------------------- 687 688 self.disable_disp = wx.RadioButton(self, -1, 'Off', (10, 10), 688 689 style=wx.RB_GROUP) 689 690 self.enable_disp = wx.RadioButton(self, -1, 'On', (10, 30)) 690 691 # best size for MAC and PC … … 696 697 style=wx.BU_EXACTFIT, 697 698 size=size_q) 698 self.disp_help_bt.Bind(wx.EVT_BUTTON, 699 self.on_pd_help_clicked,id=self.disp_help_bt.GetId())699 self.disp_help_bt.Bind(wx.EVT_BUTTON, self.on_pd_help_clicked, 700 id=self.disp_help_bt.GetId()) 700 701 self.disp_help_bt.SetToolTipString("Helps for Polydispersion.") 701 702 702 703 self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 703 704 id=self.disable_disp.GetId()) 704 705 self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 705 706 id=self.enable_disp.GetId()) 706 707 #MAC needs SetValue 707 708 self.disable_disp.SetValue(True) … … 718 719 ## fill a sizer for dispersion 719 720 boxsizer1.Add(sizer_dispersion, 0, 720 wx.TOP | wx.BOTTOM | wx.LEFT | wx.EXPAND |wx.ADJUST_MINSIZE,721 border=5)721 wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 722 border=5) 722 723 self.sizer4_4 = wx.GridBagSizer(6, 5) 723 724 … … 778 779 self._manager.parent._default_save_location 779 780 dlg = wx.FileDialog(self, "Choose a file", self._default_save_location, 780 781 self.window_caption, "*.fitv", wx.SAVE) 781 782 782 783 if dlg.ShowModal() == wx.ID_OK: … … 784 785 self._default_save_location = os.path.dirname(path) 785 786 self._manager.parent._default_save_location = \ 786 787 self._default_save_location 787 788 else: 788 789 return None … … 843 844 # inform msg to wx 844 845 wx.PostEvent(self._manager.parent, 845 StatusEvent(status=msg, info=infor))846 StatusEvent(status=msg, info=infor)) 846 847 847 848 def _get_time_stamp(self): … … 912 913 try: 913 914 if path == None: 915 status = " Selected Distribution was not loaded: %s" % path 914 916 wx.PostEvent(self._manager.parent, 915 StatusEvent(status=\ 916 " Selected Distribution was not loaded: %s" % path)) 917 StatusEvent(status=status)) 917 918 return None, None 918 919 input_f = open(path, 'r') … … 931 932 except: 932 933 # Skip non-data lines 933 logging.error(sys.exc_ value)934 logging.error(sys.exc_info()[1]) 934 935 return numpy.array(angles), numpy.array(weights) 935 936 except: … … 1095 1096 ## save checkbutton state and txtcrtl values 1096 1097 self._copy_parameters_state(self.orientation_params, 1097 1098 self.state.orientation_params) 1098 1099 self._copy_parameters_state(self.orientation_params_disp, 1099 1100 self.state.orientation_params_disp) 1100 1101 self._copy_parameters_state(self.parameters, self.state.parameters) 1101 1102 self._copy_parameters_state(self.fittable_param, 1102 1103 self.state.fittable_param) 1103 1104 self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 1104 1105 … … 1136 1137 category_pos = 0 1137 1138 for ind_cat in range(self.categorybox.GetCount()): 1138 if self.categorycombobox.GetString(ind_ form) == \1139 if self.categorycombobox.GetString(ind_cat) == \ 1139 1140 state.categorycombobox: 1140 1141 category_pos = int(ind_cat) … … 1365 1366 else: 1366 1367 self.model_view.SetLabel("1D Mode") 1367 # else: 1368 1369 if self._manager != None and self.engine_type != None: 1370 self._manager._on_change_engine(engine=self.engine_type) 1368 1371 1369 ## set the select all check box to the a given state 1372 1370 self.cb1.SetValue(state.cb1) … … 1480 1478 [state.values, state.weights] 1481 1479 except: 1482 logging.error(sys.exc_ value)1480 logging.error(sys.exc_info()[1]) 1483 1481 selection = self._find_polyfunc_selection(disp_model) 1484 1482 for list in self.fittable_param: … … 1497 1495 list[6].Disable() 1498 1496 except: 1499 logging.error(sys.exc_ value)1497 logging.error(sys.exc_info()[1]) 1500 1498 # For array, disable all fixed params 1501 1499 if selection == 1: … … 1506 1504 item[2].Disable() 1507 1505 except: 1508 logging.error(sys.exc_ value)1506 logging.error(sys.exc_info()[1]) 1509 1507 1510 1508 # Make sure the check box updated when all checked … … 1520 1518 self._manager.parent.get_save_location() 1521 1519 dlg = wx.FileDialog(self, "Choose a weight file", 1522 1523 1520 self._default_save_location, "", 1521 "*.*", wx.OPEN) 1524 1522 path = None 1525 1523 if dlg.ShowModal() == wx.ID_OK: … … 1587 1585 try: 1588 1586 is_modified = self._check_value_enter(self.fittable_param, 1589 is_modified)1587 is_modified) 1590 1588 is_modified = self._check_value_enter(self.fixed_param, 1591 1589 is_modified) … … 1593 1591 is_modified) 1594 1592 except: 1595 logging.error(sys.exc_ value)1593 logging.error(sys.exc_info()[1]) 1596 1594 1597 1595 # Here we should check whether the boundaries have been modified. … … 1659 1657 self._check_value_enter(self.parameters, is_modified) 1660 1658 1661 # If qmin and qmax have been modified, update qmin and qmax and 1659 # If qmin and qmax have been modified, update qmin and qmax and 1662 1660 # Here we should check whether the boundaries have been modified. 1663 # If qmin and qmax have been modified, update qmin and qmax and 1661 # If qmin and qmax have been modified, update qmin and qmax and 1664 1662 # set the is_modified flag to True 1665 1663 self.fitrange = self._validate_qrange(self.qmin, self.qmax) … … 1681 1679 flag = self.update_pinhole_smear() 1682 1680 else: 1681 enable_smearer = not self.disable_smearer.GetValue() 1683 1682 self._manager.set_smearer(smearer=temp_smearer, 1684 1683 uid=self.uid, … … 1686 1685 qmin=float(self.qmin_x), 1687 1686 qmax=float(self.qmax_x), 1688 enable_smearer=not self.disable_smearer.GetValue(),1689 1687 enable_smearer=enable_smearer, 1688 draw=False) 1690 1689 elif not self._is_2D(): 1691 1690 self._manager.set_smearer(smearer=temp_smearer, … … 1735 1734 self.save_current_state() 1736 1735 except: 1737 logging.error(sys.exc_ value)1736 logging.error(sys.exc_info()[1]) 1738 1737 1739 1738 return flag … … 1990 1989 # StatusEvent(status=msg, info="error")) 1991 1990 except: 1992 msg = "%s\n" % (sys.exc_ value)1991 msg = "%s\n" % (sys.exc_info()[1]) 1993 1992 wx.PostEvent(self._manager.parent, 1994 1993 StatusEvent(status=msg, info="error")) … … 1996 1995 1997 1996 def _on_modify_cat(self, event=None): 1997 """ 1998 Called when category manager is opened 1999 """ 1998 2000 self._manager.parent.on_category_panel(event) 1999 2001 … … 2059 2061 else: 2060 2062 tcrtl.SetBackgroundColour("pink") 2061 msg = "Model Error: wrong value entered: %s" % sys.exc_value 2063 msg = "Model Error: wrong value entered: %s" % \ 2064 sys.exc_info()[1] 2062 2065 wx.PostEvent(self.parent, StatusEvent(status=msg)) 2063 2066 return 2064 2067 except: 2065 2068 tcrtl.SetBackgroundColour("pink") 2066 msg = "Model Error: wrong value entered: %s" % sys.exc_ value2069 msg = "Model Error: wrong value entered: %s" % sys.exc_info()[1] 2067 2070 wx.PostEvent(self.parent, StatusEvent(status=msg)) 2068 2071 return … … 2116 2119 else: 2117 2120 tcrtl.SetBackgroundColour("pink") 2118 msg = "Model Error: wrong value entered: %s" % sys.exc_value 2121 msg = "Model Error: wrong value entered: %s" % \ 2122 sys.exc_info()[1] 2119 2123 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2120 2124 return 2121 2125 except: 2122 2126 tcrtl.SetBackgroundColour("pink") 2123 msg = "Model Error: wrong value entered: %s" % sys.exc_ value2127 msg = "Model Error: wrong value entered: %s" % sys.exc_info()[1] 2124 2128 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2125 2129 return … … 2551 2555 self.model.set_dispersion(p, disp_model) 2552 2556 except: 2553 logging.error(sys.exc_ value)2557 logging.error(sys.exc_info()[1]) 2554 2558 2555 2559 ## save state into … … 2764 2768 del self.state.model._persistency_dict[name.split('.')[0]] 2765 2769 except: 2766 logging.error(sys.exc_ value)2770 logging.error(sys.exc_info()[1]) 2767 2771 2768 2772 def _lay_out(self): … … 2910 2914 except: 2911 2915 # Not for control panels 2912 logging.error(sys.exc_ value)2916 logging.error(sys.exc_info()[1]) 2913 2917 # Make sure the resduals plot goes to the last 2914 2918 if res_item != None: … … 3226 3230 disfunc = str(item[7].GetValue()) 3227 3231 except: 3228 logging.error(sys.exc_ value)3232 logging.error(sys.exc_info()[1]) 3229 3233 3230 3234 # 2D … … 3261 3265 disfunc += ' ' + str(weight) 3262 3266 except: 3263 logging.error(sys.exc_ value)3267 logging.error(sys.exc_info()[1]) 3264 3268 content += name + ',' + str(check) + ',' + value + disfunc + ':' 3265 3269 … … 3462 3466 is_array = True 3463 3467 except: 3464 logging.error(sys.exc_ value)3468 logging.error(sys.exc_info()[1]) 3465 3469 if not is_array: 3466 3470 self._disp_obj_dict[name] = disp_model … … 3477 3481 3478 3482 except: 3479 logging.error(sys.exc_value) 3480 print "Error in BasePage._paste_poly_help: %s" % sys.exc_value 3483 logging.error(sys.exc_info()[1]) 3484 print "Error in BasePage._paste_poly_help: %s" % \ 3485 sys.exc_info()[1] 3481 3486 3482 3487 def _set_disp_array_cb(self, item): … … 3502 3507 return 3503 3508 3504 3505 3506 3507 3509 def _read_category_info(self): 3508 3510 """ 3509 3511 Reads the categories in from file 3510 3512 """ 3511 3512 3513 # # ILL mod starts here - July 2012 kieranrcampbell@gmail.com 3513 3514 self.master_category_dict = defaultdict(list) … … 3523 3524 self._regenerate_model_dict() 3524 3525 cat_file.close() 3525 3526 3526 except IOError: 3527 3527 raise … … 3536 3536 along with the enabled mapping 3537 3537 """ 3538 3539 3538 self.by_model_dict = defaultdict(list) 3540 3539 for category in self.master_category_dict: … … 3564 3563 self.categorybox.SetSelection(\ 3565 3564 self.categorybox.GetSelection()) 3566 3567 3565 #self._on_change_cat(None) 3568 3569 3566 3570 3567 def _on_change_cat(self, event): … … 3588 3585 if(enabled): 3589 3586 self.model_box.Append(model) 3590 3591 3592 3593 3587 3594 3588 def _fill_model_sizer(self, sizer): … … 3654 3648 3655 3649 sizer_radiobutton = wx.GridSizer(2, 2, 5, 5) 3656 3657 3658 3650 #sizer_radiobutton.Add(self.shape_rbutton) 3659 3651 #sizer_radiobutton.Add(self.shape_indep_rbutton)
Note: See TracChangeset
for help on using the changeset viewer.