Changeset 318b5bbb in sasview for fittingview/src/sans
- Timestamp:
- Dec 18, 2012 8:55:24 AM (12 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:
- 6550b64
- Parents:
- 0203ade
- Location:
- fittingview/src/sans/perspectives/fitting
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/basepage.py
r657e52c r318b5bbb 147 147 ## smearer object 148 148 self.enable2D = False 149 self._has_magnetic = False 150 self.magnetic_on = False 149 151 self.is_mac = ON_MAC 150 152 self.formfactorbox = None … … 1229 1231 1230 1232 self.enable2D = state.enable2D 1233 try: 1234 self.magnetic_on = state.magnetic_on 1235 except: 1236 # Backward compatibility (for older state files) 1237 self.magnetic_on = False 1231 1238 self.engine_type = state.engine_type 1232 1239 … … 2267 2274 self.model = None 2268 2275 return self.model 2269 2276 # check if model has magnetic parameters 2277 if len(self.model.magnetic_params) > 0: 2278 self._has_magnetic = True 2279 else: 2280 self._has_magnetic = False 2270 2281 ## post state to fit panel 2271 2282 self.state.parameters = [] … … 2951 2962 name = self.formfactorbox.GetValue() 2952 2963 frame = HelpWindow(None, -1, pageToOpen=model_path) 2964 # If model name exists and model is not a custom model 2965 #mod_cat = self.categorybox.GetStringSelection() 2953 2966 if frame.rhelp.HasAnchor(name): 2954 2967 frame.Show(True) … … 2967 2980 frame.Show(True) 2968 2981 2982 def _on_mag_help(self, event): 2983 """ 2984 Magnetic angles help panel 2985 """ 2986 from sans.perspectives.fitting.help_panel import HelpWindow 2987 # Get models help model_function path 2988 #import sans.perspectives.fitting as fitmedia 2989 from sans.models import get_data_path 2990 2991 media = get_data_path(media='media') 2992 path = os.path.join(media, 'img', "M_angles_pic.bmp") 2993 name = "Polar/Magnetic Angles" 2994 frame = HelpWindow(None, -1, 2995 title=' Help: Polarization/Magnetization Angles', 2996 pageToOpen=path, size=(865, 450)) 2997 try: 2998 frame.splitter.DetachWindow(frame.lpanel) 2999 # Display only the right side one 3000 frame.lpanel.Hide() 3001 frame.Show(True) 3002 except: 3003 frame.Destroy() 3004 msg = 'Display Error\n' 3005 info = "Info" 3006 wx.MessageBox(msg, info) 3007 3008 def _on_mag_on(self, event): 3009 """ 3010 Magnetic Parameters ON/OFF 3011 """ 3012 button = event.GetEventObject() 3013 3014 if button.GetLabel().count('ON') > 0: 3015 self.magnetic_on = True 3016 button.SetLabel("Magnetic OFF") 3017 m_value = 1.0e-06 3018 for key in self.model.magnetic_params: 3019 if key.count('M0') > 0: 3020 self.model.setParam(key, m_value) 3021 m_value += 0.5e-06 3022 else: 3023 self.magnetic_on = False 3024 button.SetLabel("Magnetic ON") 3025 for key in self.model.magnetic_params: 3026 if key.count('M0') > 0: 3027 #reset mag value to zero fo safety 3028 self.model.setParam(key, 0.0) 3029 3030 self.Show(False) 3031 self.set_model_param_sizer(self.model) 3032 #self._set_sizer_dispersion() 3033 self.state.magnetic_on = self.magnetic_on 3034 self.SetupScrolling() 3035 self.Show(True) 2969 3036 2970 3037 def on_pd_help_clicked(self, event): … … 3424 3491 str_m = str(model).split(".")[0] 3425 3492 self.model_box.Append(str_m) 3426 print 'but not here'3427 3493 3428 3494 else: -
fittingview/src/sans/perspectives/fitting/fitpage.py
rae4c139 r318b5bbb 635 635 636 636 for item in self.model.dispersion.keys(): 637 if not self.magnetic_on: 638 if item in self.model.magnetic_params: 639 continue 637 640 if not item in self.model.orientation_params: 638 641 if not item in self.disp_cb_dict: … … 752 755 first_orient = True 753 756 for item in self.model.dispersion.keys(): 757 if not self.magnetic_on: 758 if item in self.model.magnetic_params: 759 continue 754 760 if item in self.model.orientation_params: 755 761 if not item in self.disp_cb_dict: … … 2943 2949 if item in self.model.orientation_params: 2944 2950 orient_angle = wx.StaticText(self, -1, '[For 2D only]:') 2951 mag_on_button = wx.Button(self, -1, "Magnetic ON" ) 2952 mag_on_button.Bind(wx.EVT_BUTTON, self._on_mag_on) 2953 mag_help_button = wx.Button(self, -1,"Magnetic angles?" ) 2954 mag_help_button.Bind(wx.EVT_BUTTON,self._on_mag_help) 2945 2955 sizer.Add(orient_angle, (iy, ix), (1, 1), 2946 2956 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 2957 iy += 1 2958 sizer.Add(mag_on_button,(iy, ix ),(1,1), 2959 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 2960 sizer.Add(mag_help_button,(iy, ix + 1),(1,1), 2961 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 2962 2963 #handle the magnetic buttons 2964 if not self._has_magnetic: 2965 mag_on_button.Show(False) 2966 elif not self.data.__class__.__name__ == "Data2D": 2967 mag_on_button.Show(False) 2968 else: 2969 mag_on_button.Show(True) 2970 mag_help_button.Show(False) 2971 if mag_on_button.IsShown(): 2972 if self.magnetic_on: 2973 mag_on_button.SetLabel("Magnetic OFF") 2974 mag_help_button.Show(True) 2975 else: 2976 mag_on_button.SetLabel("Magnetic ON") 2977 mag_help_button.Show(False) 2978 2947 2979 if not self.data.__class__.__name__ == "Data2D" and \ 2948 2980 not self.enable2D: … … 2955 2987 if type.lower() != "array": 2956 2988 for item in self.model.orientation_params: 2989 if not self.magnetic_on: 2990 if item in self.model.magnetic_params: 2991 continue 2957 2992 if not item in self.disp_list: 2958 2993 ##prepare a spot to store min max -
fittingview/src/sans/perspectives/fitting/help_panel.py
rf51c8ad r318b5bbb 17 17 """ 18 18 """ 19 def __init__(self, parent, id, title='Fitting Help', pageToOpen=None ):20 wx.Frame.__init__(self, parent, id, title, size= (850, 530))19 def __init__(self, parent, id, title='Fitting Help', pageToOpen=None, size=(850, 540)): 20 wx.Frame.__init__(self, parent, id, title, size=size) 21 21 """ 22 22 contains help info 23 23 """ 24 24 self.Show(False) 25 self.SetTitle( 'Fitting Help')25 self.SetTitle(title) 26 26 from sans.perspectives.fitting import get_data_path as fit_path 27 27 fitting_path = fit_path(media='media') … … 30 30 self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO)) 31 31 splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) 32 rpanel = wx.Panel(splitter, -1)33 lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN)32 self.rpanel = wx.Panel(splitter, -1) 33 self.lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN) 34 34 35 35 vbox = wx.BoxSizer(wx.VERTICAL) 36 header = wx.Panel( rpanel, -1)36 header = wx.Panel(self.rpanel, -1) 37 37 header.SetBackgroundColour('#6666FF') 38 38 header.SetForegroundColour('WHITE') … … 47 47 48 48 vboxl= wx.BoxSizer(wx.VERTICAL) 49 headerl = wx.Panel( lpanel, -1, size=(-1, 20))49 headerl = wx.Panel(self.lpanel, -1, size=(-1, 20)) 50 50 51 51 headerl.SetBackgroundColour('#6666FF') … … 59 59 headerl.SetSizer(hboxl) 60 60 vboxl.Add(headerl, 0, wx.EXPAND) 61 self.lhelp = html.HtmlWindow( lpanel, -1, style=wx.NO_BORDER)62 self.rhelp = html.HtmlWindow( rpanel, -1, style=wx.NO_BORDER,61 self.lhelp = html.HtmlWindow(self.lpanel, -1, style=wx.NO_BORDER) 62 self.rhelp = html.HtmlWindow(self.rpanel, -1, style=wx.NO_BORDER, 63 63 size=(500, -1)) 64 64 … … 74 74 self.path_pd = os.path.join(path, "pd_help.html") 75 75 self.path_sm = os.path.join(path, "smear_computation.html") 76 76 self.path_mag = os.path.join(path, "polar_mag_help.html") 77 77 78 _html_file = [("load_data_help.html", "Load a File"), 78 79 ("single_fit_help.html", "Single Fit"), … … 85 86 ("%s" % self.path_pd, "Polydispersion Distributions"), 86 87 ("%s" % self.path_sm, "Smear Computation"), 88 ("%s" % self.path_mag, "Polarization/Magnetic Scattering"), 87 89 ("key_help.html", "Key Combination"), 88 90 ("status_bar_help.html", "Status Bar Help"), … … 118 120 vbox.Add(self.rhelp, 1, wx.EXPAND) 119 121 vboxl.Add(self.lhelp, 1, wx.EXPAND) 120 rpanel.SetSizer(vbox)121 lpanel.SetSizer(vboxl)122 lpanel.SetFocus()122 self.rpanel.SetSizer(vbox) 123 self.lpanel.SetSizer(vboxl) 124 self.lpanel.SetFocus() 123 125 124 126 vbox1 = wx.BoxSizer(wx.HORIZONTAL) 125 127 vbox1.Add(splitter, 1, wx.EXPAND) 126 splitter.AppendWindow( lpanel, 200)127 splitter.AppendWindow( rpanel)128 splitter.AppendWindow(self.lpanel, 200) 129 splitter.AppendWindow(self.rpanel) 128 130 self.SetSizer(vbox1) 129 131 -
fittingview/src/sans/perspectives/fitting/pagestate.py
r2c44cf8 r318b5bbb 52 52 ["structurecombobox", "structurecombobox", "string"], 53 53 ["multi_factor","multi_factor","float"], 54 ["magnetic_on","magnetic_on", "bool"], 54 55 ["enable_smearer","enable_smearer","bool"], 55 56 ["disable_smearer","disable_smearer","bool"], … … 246 247 self.name = "" 247 248 self.multi_factor = None 249 self.magnetic_on = False 248 250 ## enable smearering state 249 251 self.enable_smearer = False … … 335 337 obj.qmax = copy.deepcopy(self.qmax) 336 338 obj.multi_factor = self.multi_factor 339 obj.magnetic_on = self.magnetic_on 337 340 obj.npts = copy.deepcopy(self.npts) 338 341 obj.cb1 = copy.deepcopy(self.cb1) … … 385 388 #rep += "model type (form factor) selected: %s\n" % self.shape_rbutton 386 389 rep += "multi_factor : %s\n" % str(self.multi_factor) 390 rep += "magnetic_on : %s\n"% str(self.magnetic_on) 387 391 rep += "model type (Category) selected: %s\n" % self.categorycombobox 388 392 #rep += "model type (shape independent) selected: %s\n" % self.shape_indep_rbutton … … 500 504 muti_factor = ("muti_factor = " + value) 501 505 muti_factor_string = CENTRE % muti_factor 506 if name == "magentic_on ": 507 magentic_on = ("magentic_on = " + value) 508 if string(value) == 'True': 509 magentic_on_string = CENTRE % magentic_on 502 510 if name == "Title": 503 511 if len(value.strip()) == 0: -
fittingview/src/sans/perspectives/fitting/plugin_models/sum_Ap1_1_Ap2.py
r4ce74b44 r318b5bbb 63 63 ## Parameter details [units, min, max] 64 64 self.details = {} 65 ## Magnetic Panrameters 66 self.magnetic_params = [] 65 67 66 68 # non-fittable parameters … … 97 99 if not new_item in self.orientation_params: 98 100 self.orientation_params.append(new_item) 101 ## magnetic params 102 for item in self.p_model1.magnetic_params: 103 new_item = "p1_" + item 104 if not new_item in self.magnetic_params: 105 self.magnetic_params.append(new_item) 106 107 for item in self.p_model2.magnetic_params: 108 new_item = "p2_" + item 109 if not new_item in self.magnetic_params: 110 self.magnetic_params.append(new_item) 99 111 # set multiplicity 1: muti_func Not supported. 100 112 multiplicity1 = 1 -
fittingview/src/sans/perspectives/fitting/plugin_models/sum_p1_p2.py
r4ce74b44 r318b5bbb 91 91 self._set_details() 92 92 self.details['scale_factor'] = ['', None, None] 93 93 ## Magnetic Panrameters 94 self.magnetic_params = [] 94 95 95 96 #list of parameter that can be fitted … … 105 106 if not new_item in self.orientation_params: 106 107 self.orientation_params.append(new_item) 108 ## magnetic params 109 for item in self.p_model1.magnetic_params: 110 new_item = "p1_" + item 111 if not new_item in self.magnetic_params: 112 self.magnetic_params.append(new_item) 113 114 for item in self.p_model2.magnetic_params: 115 new_item = "p2_" + item 116 if not new_item in self.magnetic_params: 117 self.magnetic_params.append(new_item) 107 118 # set multiplicity 1: muti_func Not supported. 108 119 multiplicity1 = 1
Note: See TracChangeset
for help on using the changeset viewer.