Changeset 318b5bbb in sasview for calculatorview
- 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:
- calculatorview/src/sans/perspectives/calculator
- Files:
-
- 15 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/calculator.py
rce3feca r318b5bbb 64 64 mass_volume_help = "Based on the chemical formular, " 65 65 mass_volume_help += "compute the mass density or the molar volume." 66 gensans_help = "Genneric SANS" 66 67 pyconsole_help = "Python Console." 67 68 #data_editor_help = "Meta Data Editor" … … 77 78 ("SANS Resolution Estimator", 78 79 resolution_help, self.on_calculate_resoltuion), 80 ("Generic Scattering Calculator", 81 gensans_help, self.on_gen_model), 79 82 ("Python Shell/Editor", pyconsole_help, self.on_python_console)] 80 83 … … 162 165 #if event != None: 163 166 # event.Skip() 167 168 def on_gen_model(self, event): 169 from sans.perspectives.calculator.gen_scatter_panel \ 170 import SasGenWindow 171 frame = SasGenWindow(parent=self.parent) 172 self.put_icon(frame) 173 frame.Show(True) 174 164 175 def on_python_console(self, event): 165 176 """ -
calculatorview/src/sans/perspectives/calculator/help_panel.py
rce3feca r318b5bbb 13 13 """ 14 14 """ 15 def __init__(self, parent, title="Tool Help", pageToOpen=None): 16 wx.Frame.__init__(self, parent, title, size=(700, 450)) 15 def __init__(self, parent, id=-1, title="Tool Help", pageToOpen=None, 16 size=(700, 450)): 17 wx.Frame.__init__(self, parent, id, title, size=size) 17 18 """ 18 19 contains help info 19 20 """ 20 self.SetTitle( "Tool Help",)21 self.SetTitle(title) 21 22 splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) 22 23 rpanel = wx.Panel(splitter, -1) 23 lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN)24 self.lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN) 24 25 25 26 vbox = wx.BoxSizer(wx.VERTICAL) … … 37 38 38 39 vboxl = wx.BoxSizer(wx.VERTICAL) 39 headerl = wx.Panel( lpanel, -1, size=(-1, 20))40 headerl = wx.Panel(self.lpanel, -1, size=(-1, 20)) 40 41 41 42 headerl.SetBackgroundColour('#6666FF') … … 49 50 headerl.SetSizer(hboxl) 50 51 vboxl.Add(headerl, 0, wx.EXPAND) 51 self.lhelp = html.HtmlWindow( lpanel, -1, style=wx.NO_BORDER)52 self.lhelp = html.HtmlWindow(self.lpanel, -1, style=wx.NO_BORDER) 52 53 self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, 53 54 size=(500,-1)) 54 55 self.path = calculator.get_data_path(media='media') 55 if pageToOpen != None: 56 path = os.path.dirname(pageToOpen) 57 self.path = os.path.join(path, "gen_sans_help.html") 58 else: 59 self.path = calculator.get_data_path(media='media') 56 60 57 61 page1 = """<html> … … 76 80 <li><a href ="resolution_calculator_help.html" 77 81 target ="showframe">Resolution Estimator</a><br></li> 82 <li><a href ="gen_sans_help.html" 83 target ="showframe">Generic Scattering Calculator</a><br></li> 78 84 <li><a href ="pycrust_help.html" 79 85 target ="showframe">Python Shell</a><br></li> … … 84 90 self.lhelp.SetPage(page) 85 91 self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) 86 92 if pageToOpen != None: 93 self.rhelp.LoadPage(str(pageToOpen)) 87 94 vbox.Add(self.rhelp, 1, wx.EXPAND) 88 95 vboxl.Add(self.lhelp, 1, wx.EXPAND) 89 96 rpanel.SetSizer(vbox) 90 lpanel.SetSizer(vboxl)91 lpanel.SetFocus()97 self.lpanel.SetSizer(vboxl) 98 self.lpanel.SetFocus() 92 99 93 100 vbox1 = wx.BoxSizer(wx.HORIZONTAL) 94 101 vbox1.Add(splitter, 1, wx.EXPAND) 95 splitter.AppendWindow( lpanel, 200)102 splitter.AppendWindow(self.lpanel, 200) 96 103 splitter.AppendWindow(rpanel) 97 104 self.SetSizer(vbox1) 98 105 106 self.splitter = splitter 99 107 self.Centre() 100 108 self.Show(True) -
calculatorview/src/sans/perspectives/calculator/load_thread.py
r7343319 r318b5bbb 46 46 # Real code should not print, but this is an example... 47 47 raise 48 48 49 class GenReader(CalcThread): 50 """ 51 Load a sld data given a filename 52 """ 53 def __init__(self, path, loader, 54 completefn=None, 55 updatefn = None, 56 yieldtime = 0.01, 57 worktime = 0.01 58 ): 59 CalcThread.__init__(self, completefn, 60 updatefn, 61 yieldtime, 62 worktime) 63 self.path = path 64 #Instantiate a loader 65 self.loader = loader 66 self.starttime = 0 67 68 def isquit(self): 69 """ 70 @raise KeyboardInterrupt: when the thread is interrupted 71 """ 72 try: 73 CalcThread.isquit(self) 74 except KeyboardInterrupt: 75 raise KeyboardInterrupt 76 77 78 def compute(self): 79 """ 80 read some data 81 """ 82 self.starttime = time.time() 83 try: 84 data = self.loader.read(self.path) 85 self.complete(data=data) 86 except: 87 # Thread was interrupted, just proceed and re-raise. 88 # Real code should not print, but this is an example... 89 raise 90 -
calculatorview/src/sans/perspectives/calculator/model_editor.py
r657e52c r318b5bbb 11 11 import sys 12 12 import os 13 import math 13 14 from wx.py.editwindow import EditWindow 14 import subprocess15 15 16 16 if sys.platform.count("win32") > 0: … … 24 24 M_NAME = 'Model' 25 25 EDITOR_WIDTH = 800 26 EDITOR_HEIGTH = 7 2026 EDITOR_HEIGTH = 735 27 27 PANEL_WIDTH = 500 28 28 _BOX_WIDTH = 55 … … 530 530 self.warning = "" 531 531 self._description = "New Custom Model" 532 self.function_tcl = None 532 533 #self._default_save_location = os.getcwd() 533 534 self._do_layout() … … 546 547 self.param_sizer = wx.BoxSizer(wx.VERTICAL) 547 548 self.function_sizer = wx.BoxSizer(wx.VERTICAL) 549 self.func_horizon_sizer = wx.BoxSizer(wx.HORIZONTAL) 548 550 self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 549 551 self.msg_sizer = wx.BoxSizer(wx.HORIZONTAL) … … 592 594 """ 593 595 param_txt = wx.StaticText(self, -1, 'Fit Parameters (if any): ') 596 594 597 param_tip = "#Set the parameters and initial values.\n" 595 598 param_tip += "#Example:\n" … … 601 604 self.param_tcl.setDisplayLineNumbers(True) 602 605 self.param_tcl.SetToolTipString(param_tip) 606 603 607 self.param_sizer.AddMany([(param_txt, 0, wx.LEFT, 10), 604 608 (self.param_tcl, 1, wx.EXPAND|wx.ALL, 10)]) 605 606 609 607 610 def _layout_function(self): 608 611 """ … … 616 619 hint_function += " y = A + B * cos(2 * pi * x)\n" 617 620 hint_function += "return y\n" 621 math_txt = wx.StaticText(self, -1, '*Useful math functions: ') 622 math_combo = self._fill_math_combo() 623 618 624 id = wx.NewId() 619 625 self.function_tcl = EditWindow(self, id, wx.DefaultPosition, … … 621 627 self.function_tcl.setDisplayLineNumbers(True) 622 628 self.function_tcl.SetToolTipString(hint_function) 623 self.function_sizer.Add(function_txt, 0, wx.LEFT, 10) 629 630 self.func_horizon_sizer.Add(function_txt) 631 self.func_horizon_sizer.Add(math_txt, 0, wx.LEFT, 250) 632 self.func_horizon_sizer.Add(math_combo, 0, wx.LEFT, 10) 633 634 self.function_sizer.Add(self.func_horizon_sizer, 0, wx.LEFT, 10) 624 635 self.function_sizer.Add( self.function_tcl, 1, wx.EXPAND|wx.ALL, 10) 625 636 … … 682 693 self.SetSizer(self.main_sizer) 683 694 self.SetAutoLayout(True) 684 695 696 def _fill_math_combo(self): 697 """ 698 Fill up the math combo box 699 """ 700 self.math_combo = wx.ComboBox(self, -1, size=(100, -1), 701 style=wx.CB_READONLY) 702 for item in dir(math): 703 if item.count("_") < 1: 704 try: 705 exec "float(math.%s)"% item 706 self.math_combo.Append(str(item)) 707 except: 708 self.math_combo.Append(str(item) + "()" ) 709 self.math_combo.Bind(wx.EVT_COMBOBOX, self._on_math_select) 710 self.math_combo.SetSelection(0) 711 return self.math_combo 712 713 def _on_math_select(self, event): 714 """ 715 On math selection on ComboBox 716 """ 717 event.Skip() 718 label = self.math_combo.GetLabel() 719 self.function_tcl.SetFocus() 720 # Put the text at the cursor position 721 pos = self.function_tcl.GetCurrentPos() 722 self.function_tcl.InsertText(pos, label) 723 # Put the cursor at appropriate postion 724 length = len(label) 725 if label[-1] == ')': 726 length -= 1 727 f_pos = pos + length 728 self.function_tcl.GotoPos(f_pos) 729 685 730 def get_notes(self): 686 731 """ … … 1071 1116 ## Parameter details [units, min, max] 1072 1117 self.details = {} 1073 1118 ## Magnetic Panrameters 1119 self.magnetic_params = [] 1074 1120 # non-fittable parameters 1075 1121 self.non_fittable = p_model1.non_fittable … … 1105 1151 if not new_item in self.orientation_params: 1106 1152 self.orientation_params.append(new_item) 1153 ## magnetic params 1154 for item in self.p_model1.magnetic_params: 1155 new_item = "p1_" + item 1156 if not new_item in self.magnetic_params: 1157 self.magnetic_params.append(new_item) 1158 1159 for item in self.p_model2.magnetic_params: 1160 new_item = "p2_" + item 1161 if not new_item in self.magnetic_params: 1162 self.magnetic_params.append(new_item) 1107 1163 # get multiplicity if model provide it, else 1. 1108 1164 try:
Note: See TracChangeset
for help on using the changeset viewer.