Changeset ae84427 in sasview for calculatorview
- Timestamp:
- Apr 20, 2013 7:14:41 PM (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:
- ba152f1
- Parents:
- d4895dd
- Location:
- calculatorview/src/sans/perspectives/calculator
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/calculator.py
r3e001f9 rae84427 12 12 ################################################################################ 13 13 14 14 import wx 15 15 from sans.guiframe.plugin_base import PluginBase 16 16 from sans.perspectives.calculator.data_operator import DataOperatorWindow 17 from sans.perspectives.calculator.data_editor import DataEditorWindow 18 from sans.perspectives.calculator.kiessig_calculator_panel import KiessigWindow 19 from sans.perspectives.calculator.sld_panel import SldWindow 20 from sans.perspectives.calculator.density_panel import DensityWindow 21 from sans.perspectives.calculator.slit_length_calculator_panel \ 22 import SlitLengthCalculatorWindow 23 from sans.perspectives.calculator.resolution_calculator_panel \ 24 import ResolutionWindow 25 from sans.perspectives.calculator.gen_scatter_panel import SasGenWindow 26 from sans.perspectives.calculator.image_viewer import ImageView 27 from sans.perspectives.calculator.pyconsole import PyConsole 17 28 import logging 18 29 … … 27 38 logging.info("Calculator plug-in started") 28 39 self.sub_menu = "Tool" 40 self.data_edit_frame = None 29 41 # data operator use one frame all the time 30 42 self.data_operator_frame = None 43 self.kiessig_frame = None 44 self.sld_frame = None 45 self.cal_md_frame = None 46 self.cal_slit_frame = None 47 self.cal_res_frame = None 48 self.gen_frame = None 49 self.image_view = None 50 self.py_frame = None 51 31 52 32 53 def help(self, evt): … … 88 109 Edit meta data 89 110 """ 90 from sans.perspectives.calculator.data_editor import DataEditorWindow 91 frame = DataEditorWindow(parent=self.parent, data=[], 92 title="Data Editor") 93 self.put_icon(frame) 94 frame.Show(True) 111 if self.data_edit_frame == None: 112 self.data_edit_frame = DataEditorWindow(parent=self.parent, 113 manager=self, data=[], 114 title="Data Editor") 115 self.put_icon(self.data_edit_frame) 116 self.data_edit_frame.Show(False) 117 self.data_edit_frame.Show(True) 95 118 96 119 def on_data_operation(self, event): … … 101 124 # Use one frame all the time 102 125 self.data_operator_frame = DataOperatorWindow(parent=self.parent, 126 manager=self, 103 127 title="Data Operation") 104 128 self.put_icon(self.data_operator_frame) … … 111 135 Compute the Kiessig thickness 112 136 """ 113 from sans.perspectives.calculator.kiessig_calculator_panel \ 114 import KiessigWindow 115 frame = KiessigWindow() 116 self.put_icon(frame) 117 frame.Show(True) 118 137 if self.kiessig_frame == None: 138 frame = KiessigWindow(parent=self.parent, manager=self) 139 self.put_icon(frame) 140 self.kiessig_frame = frame 141 self.kiessig_frame.Show(False) 142 self.kiessig_frame.Show(True) 143 119 144 def on_calculate_sld(self, event): 120 145 """ 121 146 Compute the scattering length density of molecula 122 147 """ 123 from sans.perspectives.calculator.sld_panel import SldWindow 124 frame = SldWindow(base=self.parent) 125 self.put_icon(frame) 126 frame.Show(True) 148 if self.sld_frame == None: 149 frame = SldWindow(base=self.parent, manager=self) 150 self.put_icon(frame) 151 self.sld_frame = frame 152 self.sld_frame.Show(False) 153 self.sld_frame.Show(True) 127 154 128 155 def on_calculate_dv(self, event): … … 130 157 Compute the mass density or molar voulme 131 158 """ 132 from sans.perspectives.calculator.density_panel import DensityWindow 133 frame = DensityWindow(base=self.parent) 134 self.put_icon(frame) 135 frame.Show(True) 159 if self.cal_md_frame == None: 160 frame = DensityWindow(base=self.parent, manager=self) 161 self.put_icon(frame) 162 self.cal_md_frame = frame 163 self.cal_md_frame.Show(False) 164 self.cal_md_frame.Show(True) 136 165 137 166 def on_calculate_slit_size(self, event): … … 139 168 Compute the slit size a given data 140 169 """ 141 from sans.perspectives.calculator.slit_length_calculator_panel \ 142 import SlitLengthCalculatorWindow 143 frame = SlitLengthCalculatorWindow(parent=self.parent) 144 self.put_icon(frame) 145 frame.Show(True) 170 if self.cal_slit_frame == None: 171 frame = SlitLengthCalculatorWindow(parent=self.parent, manager=self) 172 self.put_icon(frame) 173 self.cal_slit_frame = frame 174 self.cal_slit_frame.Show(False) 175 self.cal_slit_frame.Show(True) 146 176 147 177 def on_calculate_resoltuion(self, event): … … 149 179 Estimate the instrumental resolution 150 180 """ 151 from sans.perspectives.calculator.resolution_calculator_panel \ 152 import ResolutionWindow 153 frame = ResolutionWindow(parent=self.parent) 154 self.put_icon(frame) 155 frame.Show(True) 181 if self.cal_res_frame == None: 182 frame = ResolutionWindow(parent=self.parent, manager=self) 183 self.put_icon(frame) 184 self.cal_res_frame = frame 185 self.cal_res_frame.Show(False) 186 self.cal_res_frame.Show(True) 156 187 157 188 def on_gen_model(self, event): … … 159 190 On Generic model menu event 160 191 """ 161 from sans.perspectives.calculator.gen_scatter_panel \ 162 import SasGenWindow 163 frame = SasGenWindow(parent=self.parent) 164 self.put_icon(frame) 165 frame.Show(True) 192 if self.gen_frame == None: 193 frame = SasGenWindow(parent=self.parent, manager=self) 194 self.put_icon(frame) 195 self.gen_frame = frame 196 self.gen_frame.Show(False) 197 self.gen_frame.Show(True) 166 198 167 199 def on_image_viewer(self, event): … … 171 203 :param event: menu event 172 204 """ 173 from sans.perspectives.calculator.image_viewer import ImageView 174 image_view = ImageView(parent=self.parent) 175 image_view.load() 205 self.image_view = ImageView(parent=self.parent) 206 self.image_view.load() 176 207 177 208 def on_python_console(self, event): … … 189 220 :param filename: file name to open in editor 190 221 """ 191 from sans.perspectives.calculator.pyconsole import PyConsole 192 frame = PyConsole(parent=self.parent, filename=filename) 193 self.put_icon(frame) 194 frame.Show(True) 222 if self.py_frame == None: 223 frame = PyConsole(parent=self.parent, base=self, 224 filename=filename) 225 self.put_icon(frame) 226 self.py_frame = frame 227 self.py_frame.Show(False) 228 self.py_frame.Show(True) 195 229 196 230 def put_icon(self, frame): -
calculatorview/src/sans/perspectives/calculator/data_editor.py
r7c720e9 rae84427 636 636 637 637 class DataEditorWindow(wx.Frame): 638 def __init__(self, parent, data=None, *args, **kwds):638 def __init__(self, parent, manager, data=None, *args, **kwds): 639 639 kwds["size"] = (PANEL_WIDTH, PANEL_HEIGTH) 640 640 wx.Frame.__init__(self, parent, *args, **kwds) 641 641 self.parent = parent 642 self.manager = manager 642 643 self.panel = DataEditorPanel(parent=self, data=data) 643 644 self.Show() -
calculatorview/src/sans/perspectives/calculator/data_operator.py
r657e52c rae84427 615 615 event.Skip() 616 616 617 def disconnect_panels(self): 618 """ 619 """ 620 self.out_pic.connect.disconnect() 621 self.equal_pic.connect.disconnect() 622 self.data1_pic.connect.disconnect() 623 self.operator_pic.connect.disconnect() 624 self.data2_pic.connect.disconnect() 625 617 626 def on_close(self, event): 618 627 """ … … 926 935 927 936 class DataOperatorWindow(wx.Frame): 928 def __init__(self, parent, *args, **kwds):937 def __init__(self, parent, manager, *args, **kwds): 929 938 kwds["size"] = (PANEL_WIDTH, PANEL_HEIGTH) 930 939 wx.Frame.__init__(self, parent, *args, **kwds) 931 940 self.parent = parent 941 self.manager = manager 932 942 self.panel = DataOperPanel(parent=self) 933 943 wx.EVT_CLOSE(self, self.OnClose) … … 939 949 On close event 940 950 """ 941 self.Show(False) 951 if self.manager != None: 952 self.manager.data_operator_frame = None 953 self.panel.disconnect_panels() 954 self.Destroy() 942 955 943 956 -
calculatorview/src/sans/perspectives/calculator/density_panel.py
r0efca36 rae84427 375 375 """ 376 376 def __init__(self, parent=None, title="Density/Volume Calculator", 377 base=None, size=(PANEL_SIZE, PANEL_SIZE/1.7), *args, **kwds): 377 base=None, manager=None, 378 size=(PANEL_SIZE, PANEL_SIZE/1.7), *args, **kwds): 378 379 """ 379 380 """ … … 383 384 """ 384 385 """ 386 self.manager = manager 385 387 self.panel = DensityPanel(self, base=base) 388 self.Bind(wx.EVT_CLOSE, self.on_close) 386 389 self.Centre() 387 390 self.Show(True) 391 392 def on_close(self, event): 393 """ 394 On close event 395 """ 396 if self.manager != None: 397 self.manager.cal_md_frame = None 398 self.Destroy() 399 388 400 389 401 class ViewApp(wx.App): -
calculatorview/src/sans/perspectives/calculator/gen_scatter_panel.py
rd4895dd rae84427 19 19 matplotlib.use('WXAgg') 20 20 21 #from sans.guiframe.gui_manager import MDIFrame 21 22 from data_util.calcthread import CalcThread 22 23 from sans.guiframe.local_perspectives.plotting.SimplePlot import PlotFrame … … 1113 1114 num_graph = str(self.graph_num) 1114 1115 wx.CallAfter(self.parent.draw_graph, new_plot, 1115 title="G raph %s: "% num_graph + new_plot.id )1116 title="GEN Graph %s: "% num_graph + new_plot.id ) 1116 1117 self.graph_num += 1 1117 1118 … … 1172 1173 num_graph = str(self.graph_num) 1173 1174 wx.CallAfter(self.parent.draw_graph, new_plot, 1174 title="G raph %s: "% num_graph + new_plot.id )1175 title="GEN Graph %s: "% num_graph + new_plot.id ) 1175 1176 self.graph_num += 1 1176 1177 1177 1178 def set_scale2d(self, scale): 1178 1179 """ … … 1794 1795 GEN SAS main window 1795 1796 """ 1796 def __init__(self, parent=None, title="Generic Scattering Calculator",1797 def __init__(self, parent=None, manager= None, title="Generic Scattering Calculator", 1797 1798 size=(PANEL_WIDTH * 1.3, PANEL_HEIGHT * 1.65), *args, **kwds): 1798 1799 """ … … 1804 1805 wx.Frame.__init__(self, parent, *args, **kwds) 1805 1806 self.parent = parent 1807 self.base = manager 1806 1808 self.omfpanel = OmfPanel(parent=self) 1807 1809 self.panel = SasGenPanel(parent=self) … … 1815 1817 self._plot_title = '' 1816 1818 self.scale2d = 'log_{10}' 1819 self.Bind(wx.EVT_CLOSE, self.on_close) 1817 1820 1818 1821 self._build_toolbar() 1819 self._build_menubar()1820 1822 1821 1823 self.build_panels() … … 2008 2010 frame.Show(True) 2009 2011 frame.SetFocus() 2010 2012 2013 def set_schedule_full_draw(self, panel=None, func='del'): 2014 """ 2015 Send full draw to gui frame 2016 """ 2017 self.parent.set_schedule_full_draw(panel, func) 2018 2011 2019 def get_npix(self): 2012 2020 """ … … 2082 2090 Close 2083 2091 """ 2092 if self.base != None: 2093 self.base.gen_frame = None 2084 2094 self.Destroy() 2085 2095 -
calculatorview/src/sans/perspectives/calculator/image_viewer.py
r3e001f9 rae84427 70 70 parent.put_icon(plot_frame) 71 71 except: 72 print "parent", parent 73 raise 72 74 err_msg += "Failed to load '%s'.\n"% basename 73 75 if err_msg: -
calculatorview/src/sans/perspectives/calculator/kiessig_calculator_panel.py
r7d45a56 rae84427 191 191 192 192 class KiessigWindow(wx.Frame): 193 def __init__(self, parent=None, title="Kiessig Thickness Calculator", 194 size=(PANEL_WIDTH,PANEL_HEIGHT), *args, **kwds): 193 def __init__(self, parent=None, manager=None, 194 title="Kiessig Thickness Calculator", 195 size=(PANEL_WIDTH,PANEL_HEIGHT), *args, **kwds): 195 196 kwds['title'] = title 196 197 kwds['size'] = size 197 198 wx.Frame.__init__(self, parent, *args, **kwds) 198 199 self.parent = parent 200 self.manager = manager 199 201 self.panel = KiessigThicknessCalculatorPanel(parent=self) 202 self.Bind(wx.EVT_CLOSE, self.on_close) 200 203 self.Centre() 201 204 self.Show(True) 205 206 def on_close(self, event): 207 """ 208 Close event 209 """ 210 if self.manager != None: 211 self.manager.kiessig_frame = None 212 self.Destroy() 213 202 214 203 215 if __name__ == "__main__": -
calculatorview/src/sans/perspectives/calculator/pyconsole.py
rf706e09c rae84427 40 40 ## Flag to tell the AUI manager to put this panel in the center pane 41 41 CENTER_PANE = False 42 def __init__(self, parent=None, manager=None, panel=None,42 def __init__(self, parent=None, base=None, manager=None, panel=None, 43 43 title='Python Shell/Editor', filename=None, 44 44 size=(PANEL_WIDTH, PANEL_HEIGHT)): … … 49 49 self.parent = parent 50 50 self._manager = manager 51 self.base = base 51 52 self.panel = panel 52 53 self._add_menu() … … 68 69 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCompileMenu, id=ID_COMPILE) 69 70 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCompileMenu, id=ID_RUN) 71 self.Bind(wx.EVT_CLOSE, self.on_close) 70 72 if not title.count('Python Shell'): 71 73 # Delete menu item (open and new) if not python shell … … 293 295 event.Enable(False) 294 296 297 def on_close(self, event): 298 """ 299 Close event 300 """ 301 if self.base != None: 302 self.base.py_frame = None 303 self.Destroy() 304 295 305 ABOUT = "Welcome to Python %s! \n\n"% sys.version.split()[0] 296 306 ABOUT += "This uses Py Shell/Editor in wx (developed by Patrick K. O'Brien).\n" -
calculatorview/src/sans/perspectives/calculator/resolution_calculator_panel.py
re95614e rae84427 1393 1393 Resolution Window 1394 1394 """ 1395 def __init__(self, parent = None, title = "SANS Resolution Estimator", 1396 size=(PANEL_WIDTH * 2, PANEL_HEIGHT), *args, **kwds): 1395 def __init__(self, parent = None, manager=None, 1396 title = "SANS Resolution Estimator", 1397 size=(PANEL_WIDTH * 2, PANEL_HEIGHT), *args, **kwds): 1397 1398 kwds['title'] = title 1398 1399 kwds['size'] = size 1399 1400 wx.Frame.__init__(self, parent=None, *args, **kwds) 1400 1401 self.parent = parent 1402 self.manager = manager 1401 1403 self.panel = ResolutionCalculatorPanel(parent=self) 1404 self.Bind(wx.EVT_CLOSE, self.OnClose) 1402 1405 self.Centre() 1403 1406 self.Show(True) 1404 wx.EVT_CLOSE(self, self.OnClose)1405 1407 1406 1408 def OnClose(self, event): … … 1409 1411 """ 1410 1412 _pylab_helpers.Gcf.figs = {} 1411 self.Destroy() 1413 if self.manager != None: 1414 self.manager.cal_res_frame = None 1415 self.Destroy() 1412 1416 1413 1417 -
calculatorview/src/sans/perspectives/calculator/sld_panel.py
r9c30b8c rae84427 441 441 """ 442 442 def __init__(self, parent=None, title="SLD Calculator", 443 base=None, size=(PANEL_SIZE, PANEL_SIZE), *args, **kwds): 443 base=None, manager=None, 444 size=(PANEL_SIZE, PANEL_SIZE), *args, **kwds): 444 445 """ 445 446 """ … … 449 450 """ 450 451 """ 452 self.parent = parent 453 self.base = base 454 self.manager = manager 451 455 self.panel = SldPanel(self, base=base) 456 self.Bind(wx.EVT_CLOSE, self.on_close) 452 457 self.Centre() 453 458 self.Show(True) 459 460 def on_close(self, event): 461 """ 462 On close event 463 """ 464 if self.manager != None: 465 self.manager.sld_frame = None 466 self.Destroy() 467 454 468 455 469 class ViewApp(wx.App): -
calculatorview/src/sans/perspectives/calculator/slit_length_calculator_panel.py
r29a90b0 rae84427 254 254 """ 255 255 """ 256 def __init__(self, parent=None, title="Slit Size Calculator",256 def __init__(self, parent=None, manager=None, title="Slit Size Calculator", 257 257 size=(PANEL_WIDTH,PANEL_HEIGHT), *args, **kwds): 258 258 """ … … 262 262 wx.Frame.__init__(self, parent, *args, **kwds) 263 263 self.parent = parent 264 self.manager = manager 264 265 self.panel = SlitLengthCalculatorPanel(parent=self) 266 self.Bind(wx.EVT_CLOSE, self.on_close) 265 267 self.Centre() 266 268 self.Show(True) 269 270 def on_close(self, event): 271 """ 272 Close event 273 """ 274 if self.manager != None: 275 self.manager.cal_slit_frame = None 276 self.Destroy() 267 277 268 278 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.