Changeset 39e49a1 in sasview
- Timestamp:
- Dec 15, 2009 12:56:02 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:
- 4e80ae0
- Parents:
- 89108a0
- Location:
- calculatorview
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/perspectives/calculator/sld_panel.py
r383eeaa r39e49a1 16 16 17 17 #SLD panel size 18 if sys.platform.count(" darwin")==0:18 if sys.platform.count("win32")>0: 19 19 _STATICBOX_WIDTH = 350 20 20 PANEL_SIZE = 400 … … 41 41 42 42 # Object that receive status event 43 self.base = base43 self.base = base 44 44 self.calculator = SldCalculator() 45 45 self.wavelength = self.calculator.wavelength … … 56 56 unit_a = '[A]' 57 57 unit_density = '[g/cm^(3)]' 58 unit_sld = '[1/A^(2)]'59 unit_cm1 ='[1/cm]'60 unit_cm ='[cm]'58 unit_sld = '[1/A^(2)]' 59 unit_cm1 ='[1/cm]' 60 unit_cm ='[cm]' 61 61 sizer_input = wx.GridBagSizer(5,5) 62 62 sizer_output = wx.GridBagSizer(5,5) … … 90 90 sizer_input.Add(density_txt,(iy, ix),(1,1),\ 91 91 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 92 ix += 193 sizer_input.Add(self.density_ctl, (iy, ix),(1,1),\92 ix += 1 93 sizer_input.Add(self.density_ctl, (iy, ix), (1,1),\ 94 94 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 95 95 ix +=1 … … 98 98 iy += 1 99 99 ix = 0 100 sizer_input.Add(wavelength_txt, (iy, ix),(1,1),\101 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 102 ix += 1100 sizer_input.Add(wavelength_txt, (iy, ix),(1,1),\ 101 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 102 ix += 1 103 103 sizer_input.Add(self.wavelength_ctl,(iy, ix),(1,1),\ 104 104 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 105 ix += 1105 ix += 1 106 106 sizer_input.Add(unit_a_txt,(iy, ix),(1,1),\ 107 107 wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 113 113 boxsizer2.SetMinSize((_STATICBOX_WIDTH,-1)) 114 114 115 i_complex = '+ i'115 i_complex = '+ i' 116 116 neutron_sld_txt = wx.StaticText(self, -1, 'Neutron SLD') 117 117 self.neutron_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) … … 162 162 sizer_output.Add(neutron_sld_txt,(iy, ix),(1,1), 163 163 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 164 ix += 1164 ix += 1 165 165 sizer_output.Add(self.neutron_sld_reel_ctl,(iy, ix),(1,1), 166 166 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 167 ix += 1167 ix += 1 168 168 sizer_output.Add(wx.StaticText(self, -1, i_complex) 169 169 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 184 184 sizer_output.Add(wx.StaticText(self, -1, i_complex) 185 185 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 186 ix += 1186 ix += 1 187 187 sizer_output.Add(self.cu_ka_sld_im_ctl 188 188 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 189 ix += 1189 ix += 1 190 190 sizer_output.Add(cu_ka_sld_units_txt 191 191 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 200 200 sizer_output.Add(wx.StaticText(self, -1, i_complex) 201 201 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 202 ix += 1202 ix += 1 203 203 sizer_output.Add(self.mo_ka_sld_im_ctl 204 204 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 210 210 sizer_output.Add(neutron_inc_txt,(iy, ix),(1,1), 211 211 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 212 ix += 1212 ix += 1 213 213 sizer_output.Add(self.neutron_inc_ctl,(iy, ix),(1,1), 214 214 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 215 ix += 2 216 sizer_output.Add(neutron_inc_units_txt,(iy, ix),(1,1), 217 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 218 iy += 1 219 ix = 0 220 sizer_output.Add(neutron_abs_txt, (iy, ix), (1,1), 221 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 222 ix += 1 223 sizer_output.Add(self.neutron_abs_ctl, (iy, ix), (1,1), 224 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 215 225 ix +=2 216 sizer_output.Add(neutron_inc_units_txt,(iy, ix),(1,1), 217 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 218 iy += 1 219 ix = 0 220 sizer_output.Add(neutron_abs_txt,(iy, ix),(1,1), 221 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 222 ix +=1 223 sizer_output.Add(self.neutron_abs_ctl,(iy, ix),(1,1), 224 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 225 ix +=2 226 sizer_output.Add(neutron_abs_units_txt,(iy, ix),(1,1), 227 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 228 iy += 1 229 ix = 0 230 sizer_output.Add(neutron_length_txt,(iy, ix),(1,1), 231 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 232 ix +=1 233 sizer_output.Add(self.neutron_length_ctl,(iy, ix),(1,1), 226 sizer_output.Add(neutron_abs_units_txt, (iy, ix), (1,1), 227 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 228 iy += 1 229 ix = 0 230 sizer_output.Add(neutron_length_txt, (iy, ix), (1,1), 231 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 232 ix +=1 233 sizer_output.Add(self.neutron_length_ctl, (iy, ix), (1,1), 234 234 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 235 ix += 2236 sizer_output.Add(neutron_length_units_txt, (iy, ix),(1,1),235 ix += 2 236 sizer_output.Add(neutron_length_units_txt, (iy, ix), (1,1), 237 237 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 238 238 boxsizer2.Add( sizer_output ) 239 sizer2.Add(boxsizer2,0, wx.EXPAND |wx.ALL, 10)239 sizer2.Add(boxsizer2,0, wx.EXPAND|wx.ALL, 10) 240 240 #-----Button sizer------------ 241 241 … … 259 259 def check_inputs(self): 260 260 """Check validity user inputs""" 261 flag = True261 flag = True 262 262 263 263 if check_float(self.density_ctl): 264 264 self.density = float(self.density_ctl.GetValue()) 265 265 else: 266 flag =False266 flag = False 267 267 raise ValueError,"Error for Density value :expect float" 268 268 269 self.wavelength = self.wavelength_ctl.GetValue()270 if self.wavelength.lstrip().rstrip() =="":269 self.wavelength = self.wavelength_ctl.GetValue() 270 if self.wavelength.lstrip().rstrip() == "": 271 271 self.wavelength = self.calculator.wavelength 272 272 else: 273 273 if check_float(self.wavelength_ctl): 274 self.wavelength = float(self.wavelength)274 self.wavelength = float(self.wavelength) 275 275 else: 276 276 flag = False 277 277 raise ValueError,"Error for wavelenth value :expect float" 278 278 279 self.formulata_text = self.compound_ctl.GetValue().lstrip().rstrip()280 if self.formulata_text !="":279 self.formulata_text = self.compound_ctl.GetValue().lstrip().rstrip() 280 if self.formulata_text != "": 281 281 self.compound_ctl.SetBackgroundColour(wx.WHITE) 282 282 self.compound_ctl.Refresh() … … 284 284 self.compound_ctl.SetBackgroundColour("pink") 285 285 self.compound_ctl.Refresh() 286 flag =False286 flag = False 287 287 raise ValueError, "Enter a formula" 288 288 return flag … … 297 297 #get ready to compute 298 298 try: 299 self.calculator.setValue(self.formulata_text,self.density,self.wavelength) 299 self.calculator.set_value(self.formulata_text, 300 self.density, self.wavelength) 300 301 except: 301 if self.base !=None:302 msg = "SLD Calculator: %s" %(sys.exc_value)303 wx.PostEvent(self.base, StatusEvent(status= msg))302 if self.base is not None: 303 msg = "SLD Calculator: %s" %(sys.exc_value) 304 wx.PostEvent(self.base, StatusEvent(status=msg)) 304 305 else: 305 306 raise … … 307 308 308 309 # Compute the Cu SLD 309 Cu_reel, Cu_im = self.calculator.calculate XRaySld( "Cu")310 self.cu_ka_sld_reel_ctl.SetValue(format_number(Cu_reel *_SCALE))311 self.cu_ka_sld_im_ctl.SetValue(format_number(Cu_im *_SCALE))310 Cu_reel, Cu_im = self.calculator.calculate_xray_sld( "Cu") 311 self.cu_ka_sld_reel_ctl.SetValue(format_number(Cu_reel *_SCALE)) 312 self.cu_ka_sld_im_ctl.SetValue(format_number(Cu_im * _SCALE)) 312 313 313 314 # Compute the Mo SLD 314 Mo_reel, Mo_im = self.calculator.calculate XRaySld( "Mo")315 self.mo_ka_sld_reel_ctl.SetValue(format_number(Mo_reel *_SCALE))316 self.mo_ka_sld_im_ctl.SetValue(format_number(Mo_im *_SCALE))315 Mo_reel, Mo_im = self.calculator.calculate_xray_sld( "Mo") 316 self.mo_ka_sld_reel_ctl.SetValue(format_number(Mo_reel *_SCALE)) 317 self.mo_ka_sld_im_ctl.SetValue(format_number(Mo_im * _SCALE)) 317 318 318 coh,absorp,inc = self.calculator.calculateNSld()319 im = self.calculator.calculate AbsorptionIm()320 length = self.calculator.calculate Length()319 coh,absorp,inc = self.calculator.calculate_neutron_sld() 320 im = self.calculator.calculate_coherence_im() 321 length = self.calculator.calculate_length() 321 322 # Neutron SLD 322 self.neutron_sld_reel_ctl.SetValue(format_number(coh *_SCALE))323 self.neutron_sld_im_ctl.SetValue(format_number(im *_SCALE))324 self.neutron_inc_ctl.SetValue(format_number(inc 323 self.neutron_sld_reel_ctl.SetValue(format_number(coh * _SCALE)) 324 self.neutron_sld_im_ctl.SetValue(format_number(im * _SCALE)) 325 self.neutron_inc_ctl.SetValue(format_number(inc)) 325 326 self.neutron_abs_ctl.SetValue(format_number(absorp)) 326 327 # Neutron length … … 329 330 self.wavelength_ctl.SetValue(str(self.wavelength)) 330 331 except: 331 if self.base !=None:332 msg = "SLD Calculator: %s" %(sys.exc_value)333 wx.PostEvent(self.base, StatusEvent(status= msg))332 if self.base is not None: 333 msg = "SLD Calculator: %s"%(sys.exc_value) 334 wx.PostEvent(self.base, StatusEvent(status=msg)) 334 335 else: 335 336 raise
Note: See TracChangeset
for help on using the changeset viewer.