Changeset be6e99a in sasview for calculatorview/perspectives/calculator
- Timestamp:
- Apr 8, 2011 1:19:10 PM (14 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:
- ef73618
- Parents:
- cdb3a9a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/perspectives/calculator/resolution_calculator_panel.py
rc83a5af rbe6e99a 32 32 #Slit length panel size 33 33 if sys.platform.count("win32") > 0: 34 PANEL_WIDTH = 5 3534 PANEL_WIDTH = 525 35 35 PANEL_HEIGHT = 653 36 36 FONT_VARIANT = 0 … … 39 39 PANEL_HEIGHT = 692 40 40 FONT_VARIANT = 1 41 41 42 _SOURCE_MASS = {'Alpha':6.64465620E-24, 43 'Deuteron':3.34358320E-24, 44 'Neutron':1.67492729E-24, 45 'Photon': 0.0, 46 'Proton':1.67262137E-24, 47 'Triton':5.00826667E-24} 48 42 49 class ResolutionCalculatorPanel(ScrolledPanel): 43 50 """ … … 71 78 # Object that receive status event 72 79 self.resolution = ResolutionCalculator() 73 80 # Source selection dic 81 self.source_mass = _SOURCE_MASS 74 82 #layout attribute 75 83 self.hint_sizer = None 76 84 # detector coordinate of estimation of sigmas 77 self.det_coordinate = ' polar'85 self.det_coordinate = 'cartesian' 78 86 79 87 self._do_layout() … … 116 124 # get the mass 117 125 mass_value = str(self.resolution.mass) 118 mass_unit_txt = wx.StaticText(self, -1, '[g]') 119 mass_txt = wx.StaticText(self, -1, 120 'Mass: ') 121 self.mass_tcl = InputTextCtrl(self, -1, 122 size=(_BOX_WIDTH,-1)) 123 mass_hint = "Mass of Neutrons" 124 self.mass_tcl.SetValue(mass_value) 125 self.mass_tcl.SetToolTipString(mass_hint) 126 self.mass_sizer.AddMany([(mass_txt, 0, wx.LEFT, 15), 127 (self.mass_tcl, 0, wx.LEFT, 15), 128 (mass_unit_txt,0, wx.LEFT, 10)]) 126 self.mass_txt = wx.StaticText(self, -1, 127 'Source: ') 128 self.mass_hint = "Mass of Neutrons m = %s [g]"\ 129 % str(self.resolution.mass) 130 self.source_cb = wx.ComboBox(self, -1, 131 style=wx.CB_READONLY|wx.CB_SORT, 132 name = '%s'%mass_value) 133 for key, value in self.source_mass.iteritems(): 134 name_source = str(key) 135 self.source_cb.Append(name_source, name_source) 136 self.source_cb.SetStringSelection("Neutron") 137 wx.EVT_COMBOBOX(self.source_cb,-1, self._on_source_selection) 138 source_hint = "Source Selection: Affect on" 139 source_hint += " the gravitational contribution.\n" 140 source_hint += "Mass of %s: m = %s [g]" % \ 141 ('Neutron', str(self.resolution.mass)) 142 self.mass_txt.SetToolTipString(source_hint) 143 self.mass_sizer.AddMany([(self.mass_txt, 0, wx.LEFT, 15), 144 (self.source_cb, 0, wx.LEFT, 15)]) 129 145 130 146 def _layout_intensity(self): … … 402 418 sigma_unit = '['+'1/A' +']' 403 419 self.sigma_r_txt = wx.StaticText(self, -1, 404 'Sigma_ r: ')420 'Sigma_x: ') 405 421 self.sigma_r_tcl = OutputTextCtrl(self, -1, 406 size=(_BOX_WIDTH ,-1))422 size=(_BOX_WIDTH*0.8,-1)) 407 423 self.sigma_phi_txt = wx.StaticText(self, -1, 408 'Sigma_ phi:')424 'Sigma_y:') 409 425 self.sigma_phi_tcl = OutputTextCtrl(self, -1, 410 size=(_BOX_WIDTH,-1)) 426 size=(_BOX_WIDTH*0.8,-1)) 427 self.sigma_lamd_txt = wx.StaticText(self, -1, 428 'Sigma_lamd:') 429 self.sigma_lamd_tcl = OutputTextCtrl(self, -1, 430 size=(_BOX_WIDTH*0.7,-1)) 411 431 sigma_1d_txt = wx.StaticText(self, -1, '( 1D: Sigma:') 412 432 self.sigma_1d_tcl = OutputTextCtrl(self, -1, 413 size=(_BOX_WIDTH,-1)) 414 sigma_hint = " dQ_r or dQ_x, and dQ_phi or dQ_y" 415 sigma_hint_1d = " dQ for 1-dimension" 416 self.sigma_r_tcl.SetToolTipString(sigma_hint) 417 self.sigma_phi_tcl.SetToolTipString(sigma_hint) 433 size=(_BOX_WIDTH*0.7,-1)) 434 sigmax_hint = " The x component of the geometric resolution," 435 sigmax_hint += " excluding sigma_lamda." 436 sigmay_hint = " The y component of the geometric resolution," 437 sigmay_hint += " excluding sigma_lamda." 438 sigma_hint_lamd = " The wavelength contribution in the radial direction" 439 sigma_hint_lamd += ".\n Note: The phi component is always zero." 440 sigma_hint_1d = " Resolution in 1-dimension (for 1D data)." 441 self.sigma_r_tcl.SetToolTipString(sigmax_hint) 442 self.sigma_phi_tcl.SetToolTipString(sigmay_hint) 443 self.sigma_lamd_tcl.SetToolTipString(sigma_hint_lamd) 418 444 self.sigma_1d_tcl.SetToolTipString(sigma_hint_1d) 419 445 sigma_r_unit_txt = wx.StaticText(self, -1, sigma_unit) 420 446 sigma_phi_unit_txt = wx.StaticText(self, -1, sigma_unit) 447 sigma_lamd_unit_txt = wx.StaticText(self, -1, sigma_unit) 421 448 sigma_1d_unit_txt = wx.StaticText(self, -1, sigma_unit+' )') 422 449 outputQxy_sizer.AddMany([(self.sigma_r_txt, 0, wx.LEFT, 15), … … 426 453 (self.sigma_phi_tcl, 0, wx.LEFT, 15), 427 454 (sigma_phi_unit_txt, 0, wx.LEFT, 15)]) 428 outputQ_sizer.AddMany([(sigma_1d_txt, 0, wx.LEFT, 15), 455 outputQ_sizer.AddMany([(self.sigma_lamd_txt, 0, wx.LEFT, 15), 456 (self.sigma_lamd_tcl, 0, wx.LEFT, 15), 457 (sigma_lamd_unit_txt, 0, wx.LEFT, 15), 458 (sigma_1d_txt, 0, wx.LEFT, 15), 429 459 (self.sigma_1d_tcl, 0, wx.LEFT, 15), 430 460 (sigma_1d_unit_txt, 0, wx.LEFT, 15)]) … … 452 482 """ 453 483 #outerbox_txt = wx.StaticText(self, -1, 'Outer Box') 454 self.x_y_rb = wx.RadioButton(self, -1,"Cartesian")455 self.Bind(wx.EVT_RADIOBUTTON,456 self._on_xy_coordinate, id=self.x_y_rb.GetId())457 self.r_phi_rb = wx.RadioButton(self, -1,"Polar")458 self.Bind(wx.EVT_RADIOBUTTON,459 self._on_rp_coordinate, id=self.r_phi_rb.GetId())460 self.r_phi_rb.SetValue(True)484 #self.x_y_rb = wx.RadioButton(self, -1,"Cartesian") 485 #self.Bind(wx.EVT_RADIOBUTTON, 486 # self._on_xy_coordinate, id=self.x_y_rb.GetId()) 487 #self.r_phi_rb = wx.RadioButton(self, -1,"Polar") 488 #self.Bind(wx.EVT_RADIOBUTTON, 489 # self._on_rp_coordinate, id=self.r_phi_rb.GetId()) 490 #self.r_phi_rb.SetValue(True) 461 491 #reset button 462 492 id = wx.NewId() … … 475 505 self.bt_close.Bind(wx.EVT_BUTTON, self.on_close) 476 506 self.bt_close.SetToolTipString("Close this window.") 507 """ 477 508 self.button_sizer.AddMany([(self.r_phi_rb, 0, wx.LEFT, 15), 478 509 (self.x_y_rb, 0, wx.LEFT, 15), … … 480 511 (self.compute_button, 0, wx.LEFT, 15), 481 512 (self.bt_close, 0, wx.LEFT, 15)])#370)]) 513 """ 514 self.button_sizer.Add((110, -1)) 515 self.button_sizer.AddMany([(self.reset_button, 0, wx.LEFT, 50), 516 (self.compute_button, 0, wx.LEFT, 15), 517 (self.bt_close, 0, wx.LEFT, 15)]) 482 518 self.compute_button.SetFocus() 483 519 … … 644 680 wavelength = self.wavelength_tcl.GetValue() 645 681 self.resolution.set_wavelength(float(wavelength)) 646 mass = self.mass_tcl.GetValue() 682 source = self.source_cb.GetValue() 683 mass = self.source_mass[str(source)] 647 684 self.resolution.set_neutron_mass(float(mass)) 648 685 wavelength_spread = self.wavelength_spread_tcl.GetValue() … … 672 709 self.qy = self._string2inputlist(self.qy_tcl.GetValue()) 673 710 674 # Find min max of qs 675 xmin = min(self.qx) 676 xmax = max(self.qx) 677 ymin = min(self.qy) 678 ymax = max(self.qy) 711 try: 712 # Find min max of qs 713 xmin = min(self.qx) 714 xmax = max(self.qx) 715 ymin = min(self.qy) 716 ymax = max(self.qy) 717 except: 718 msg = "An error occured during the resolution computation." 719 msg += "Please check your inputs..." 720 self._status_info(msg, status_type) 721 raise ValueError, "Invalid Q Input..." 679 722 680 723 # Validate the q inputs … … 719 762 sigma_r = self.format_number(self.resolution.sigma_1) 720 763 sigma_phi = self.format_number(self.resolution.sigma_2) 764 sigma_lamd = self.format_number(self.resolution.sigma_lamd) 721 765 sigma_1d = self.format_number(self.resolution.sigma_1d) 722 766 … … 724 768 self.sigma_r_tcl.SetValue(str(sigma_r)) 725 769 self.sigma_phi_tcl.SetValue(str(sigma_phi)) 770 self.sigma_lamd_tcl.SetValue(str(sigma_lamd)) 726 771 self.sigma_1d_tcl.SetValue(str(sigma_1d)) 727 772 … … 835 880 self.resolution.get_all_instrument_params() 836 881 # reset all param values 837 self.mass_tcl.SetValue(str(self.resolution.mass)) 882 self.source_cb.SetValue('Neutron') 883 self._on_source_selection(None) 838 884 #self.intensity_tcl.SetValue(str(self.resolution.intensity)) 839 885 self.wavelength_tcl.SetValue(str(self.resolution.wavelength)) … … 882 928 self.sigma_1d_tcl.SetValue('') 883 929 # reset radio button 884 self.det_coordinate = 'polar' 885 self.r_phi_rb.SetValue(True) 930 #self.r_phi_rb.SetValue(True) 886 931 # Finally re-compute 887 932 self.on_compute() … … 987 1032 self.on_compute() 988 1033 1034 def _on_source_selection(self, event = None): 1035 """ 1036 On source combobox selection 1037 """ 1038 if event != None: 1039 combo = event.GetEventObject() 1040 event.Skip() 1041 else: 1042 combo = self.source_cb 1043 selection = combo.GetValue() 1044 mass = self.source_mass[selection] 1045 self.resolution.set_neutron_mass(mass) 1046 source_hint = "Source Selection: Affect on" 1047 source_hint += " the gravitational contribution.\n" 1048 source_hint += "Mass of %s: m = %s [g]" % \ 1049 (selection, str(self.resolution.get_neutron_mass())) 1050 #source_tip.SetTip(source_hint) 1051 self.mass_txt.ToolTip.SetTip(source_hint) 989 1052 990 1053 class ResolutionWindow(wx.Frame):
Note: See TracChangeset
for help on using the changeset viewer.