Changeset 49ab5d7 in sasview for src/sas/perspectives/calculator/gen_scatter_panel.py
- Timestamp:
- Mar 4, 2015 3:28:39 PM (10 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:
- 2f732b0
- Parents:
- 76aed53
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/calculator/gen_scatter_panel.py
r3f5d75b r49ab5d7 1 1 """ 2 Generic Scattering panel. 2 Generic Scattering panel. 3 3 This module relies on guiframe manager. 4 4 """ … … 22 22 from sas.data_util.calcthread import CalcThread 23 23 from sas.guiframe.local_perspectives.plotting.SimplePlot import PlotFrame 24 from sas.guiframe.dataFitting import Data2D 24 from sas.guiframe.dataFitting import Data2D 25 25 from sas.guiframe.dataFitting import Data1D 26 26 from sas.dataloader.data_info import Detector … … 28 28 from sas.guiframe.panel_base import PanelBase 29 29 from sas.guiframe.utils import format_number 30 from sas.guiframe.events import StatusEvent 31 from sas.calculator import sas_gen 30 from sas.guiframe.events import StatusEvent 31 from sas.calculator import sas_gen 32 32 from sas.perspectives.calculator.calculator_widgets import OutputTextCtrl 33 33 from sas.perspectives.calculator.calculator_widgets import InputTextCtrl … … 36 36 from sas.plottools.arrow3d import Arrow3D 37 37 from sas.perspectives.calculator import calculator_widgets as widget 38 from sas.guiframe.events import NewPlotEvent 38 from sas.guiframe.events import NewPlotEvent 39 39 from sas.guiframe.documentation_window import DocumentationWindow 40 40 … … 50 50 FONT_VARIANT = 1 51 51 _QMAX_DEFAULT = 0.3 52 _NPTS_DEFAULT = 50 52 _NPTS_DEFAULT = 50 53 53 _Q1D_MIN = 0.001 54 54 … … 64 64 frame.SetIcon(icon) 65 65 except: 66 pass 66 pass 67 67 68 68 def _set_error(panel, item, show_msg=False): 69 """ 69 """ 70 70 Set_error dialog 71 71 """ … … 76 76 msg = "Error: wrong (or out of range) value entered." 77 77 if panel.parent.parent != None: 78 wx.PostEvent(panel.parent.parent, 79 StatusEvent(status=msg, info='Error' ))78 wx.PostEvent(panel.parent.parent, 79 StatusEvent(status=msg, info='Error')) 80 80 panel.SetFocus() 81 81 return False … … 88 88 """ 89 89 def __init__(self, 90 id= -1,91 input =None,92 completefn =None,93 updatefn =None,90 id= -1, 91 input=None, 92 completefn=None, 93 updatefn=None, 94 94 #elapsed = 0, 95 yieldtime =0.01,96 worktime =0.01):95 yieldtime=0.01, 96 worktime=0.01): 97 97 """ 98 98 """ … … 102 102 worktime) 103 103 self.starttime = 0 104 self.id = id 105 self.input = input 104 self.id = id 105 self.input = input 106 106 self.update_fn = updatefn 107 107 108 108 def compute(self): 109 109 """ … … 113 113 self.starttime = time.time() 114 114 self.complete(input=self.input, update=self.update_fn) 115 115 116 116 class SasGenPanel(ScrolledPanel, PanelBase): 117 117 """ … … 122 122 ## Name to appear on the window title bar 123 123 window_caption = "Generic SAS " 124 124 125 125 def __init__(self, parent, *args, **kwds): 126 ScrolledPanel.__init__(self, parent, style=wx.RAISED_BORDER, 126 ScrolledPanel.__init__(self, parent, style=wx.RAISED_BORDER, 127 127 *args, **kwds) 128 128 #kwds['style'] = wx.SUNKEN_BORDER … … 159 159 self._create_default_2d_data() 160 160 wx.CallAfter(self._set_sld_data_helper) 161 161 162 162 def _define_structure(self): 163 163 """ … … 180 180 self.qrange_sizer = wx.BoxSizer(wx.HORIZONTAL) 181 181 self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 182 182 183 183 def _layout_data_name(self): 184 184 """ … … 186 186 """ 187 187 data_name_txt = wx.StaticText(self, -1, 'Data: ') 188 self.data_name_tcl = OutputTextCtrl(self, -1, 188 self.data_name_tcl = OutputTextCtrl(self, -1, 189 189 size=(_BOX_WIDTH * 4, -1)) 190 190 data_hint = "Loaded data" … … 244 244 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 245 245 self.parameters.append([p_name, ctl, unit]) 246 246 247 247 self.param_sizer.Add(sizer, 0, wx.LEFT, 10) 248 248 249 249 def _layout_hint(self): 250 250 """ 251 Fill the sizer containing hint 251 Fill the sizer containing hint 252 252 """ 253 253 hint_msg = "We support omf, sld or pdb data files only." 254 hint_msg += 254 hint_msg += " " 255 255 if FONT_VARIANT < 1: 256 hint_msg += 256 hint_msg += "Very " 257 257 hint_msg += "SLOW drawing -->" 258 258 hint_txt = wx.StaticText(self, -1, hint_msg) 259 259 260 260 id = wx.NewId() 261 261 self.draw_button = wx.Button(self, id, "Arrow Draw") … … 263 263 self.draw_button.SetToolTipString(hint_on_draw) 264 264 self.draw_button.Bind(wx.EVT_BUTTON, self.sld_draw, id=id) 265 265 266 266 self.draw_button.Enable(False) 267 267 self.hint_sizer.AddMany([(hint_txt, 0, wx.LEFT, 15), 268 268 (self.draw_button, 0, wx.LEFT, 7)]) 269 269 270 270 def _layout_shape(self): 271 271 """ … … 276 276 self.shape_sizer.AddMany([(label_txt, 0, wx.LEFT, 15), 277 277 (self.shape_combo, 0, wx.LEFT, 5)]) 278 278 279 279 def _fill_shape_combo(self): 280 280 """ 281 281 Fill up the shape combo box 282 282 """ 283 shape_combo = wx.ComboBox(self, -1, size=(150, -1), 284 style=wx.CB_READONLY) 283 shape_combo = wx.ComboBox(self, -1, size=(150, -1), 284 style=wx.CB_READONLY) 285 285 shape_combo.Append('Rectangular') 286 286 shape_combo.Append('Ellipsoid') … … 288 288 shape_combo.SetSelection(0) 289 289 return shape_combo 290 290 291 291 def _on_shape_select(self, event): 292 292 """ … … 294 294 """ 295 295 event.Skip() 296 label = event.GetEventObject().GetValue().lower() 296 label = event.GetEventObject().GetValue().lower() 297 297 self.default_shape = label 298 298 self.parent.set_omfpanel_default_shap(self.default_shape) 299 299 self.parent.set_omfpanel_npts() 300 300 301 301 def _fill_orient_combo(self): 302 302 """ 303 303 Fill up the orientation combo box: used only for atomic structure 304 304 """ 305 orient_combo = wx.ComboBox(self, -1, size=(150, -1), 306 style=wx.CB_READONLY) 305 orient_combo = wx.ComboBox(self, -1, size=(150, -1), 306 style=wx.CB_READONLY) 307 307 orient_combo.Append('Fixed orientation') 308 308 orient_combo.Append('Debye full avg.') 309 309 #orient_combo.Append('Debye sph. sym.') 310 310 311 311 orient_combo.Bind(wx.EVT_COMBOBOX, self._on_orient_select) 312 312 orient_combo.SetSelection(0) 313 313 return orient_combo 314 314 315 315 def _on_orient_select(self, event): 316 316 """ … … 325 325 self.is_avg = is_avg 326 326 self.model.set_is_avg(self.is_avg) 327 self.set_est_time() 328 327 self.set_est_time() 328 329 329 def _layout_qrange(self): 330 330 """ … … 359 359 self.qmax_ctl = InputTextCtrl(self, -1, size=(_BOX_WIDTH * 1.5, 20), 360 360 style=wx.TE_PROCESS_ENTER) 361 self.qmax_ctl.Bind(wx.EVT_TEXT, self._onparamEnter 361 self.qmax_ctl.Bind(wx.EVT_TEXT, self._onparamEnter) 362 362 self.qmax_ctl.SetValue(format_number(self.qmax_x, True)) 363 363 sizer.Add(self.qmax_ctl, (iy, ix), (1, 1), wx.EXPAND) … … 368 368 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 369 369 self.qrange_sizer.Add(sizer, 0, wx.LEFT, 10) 370 371 def _layout_button(self): 370 371 def _layout_button(self): 372 372 """ 373 373 Do the layout for the button widgets 374 """ 374 """ 375 375 self.est_time = '*Estimated Computation time :\n %s' 376 self.time_text = wx.StaticText(self, -1, self.est_time % str('2 sec'))376 self.time_text = wx.StaticText(self, -1, self.est_time % str('2 sec')) 377 377 self.orient_combo = self._fill_orient_combo() 378 378 self.orient_combo.Show(False) 379 self.bt_compute = wx.Button(self, wx.NewId(), 'Compute')379 self.bt_compute = wx.Button(self, wx.NewId(), 'Compute') 380 380 self.bt_compute.Bind(wx.EVT_BUTTON, self.on_compute) 381 381 self.bt_compute.SetToolTipString("Compute 2D Scattering Pattern.") 382 self.bt_help = wx.Button(self, wx.NewId(), 'HELP')382 self.bt_help = wx.Button(self, wx.NewId(), 'HELP') 383 383 self.bt_help.Bind(wx.EVT_BUTTON, self.on_help) 384 384 self.bt_help.SetToolTipString("Help on Scatter Calculator") … … 387 387 (self.bt_compute, 0, wx.LEFT, 20), 388 388 (self.bt_help, 0, wx.LEFT, 5)]) 389 389 390 390 def estimate_ctime(self): 391 391 """ … … 401 401 n_pixs *= (n_pixs / 200) 402 402 x_in = n_qbins * n_pixs / 100000 403 etime = factor + 0.085973 * x_in 403 etime = factor + 0.085973 * x_in 404 404 return int(etime) 405 405 406 406 def set_est_time(self): 407 407 """ … … 417 417 self.time_text.SetForegroundColour('red') 418 418 time_str = str(etime) + ' ' + unit 419 self.time_text.SetLabel(self.est_time % time_str)420 419 self.time_text.SetLabel(self.est_time % time_str) 420 421 421 def _do_layout(self): 422 422 """ … … 431 431 self._layout_button() 432 432 self.boxsizer_source.AddMany([(self.data_name_sizer, 0, 433 wx.EXPAND |wx.TOP|wx.BOTTOM, 5),433 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 434 434 (self.hint_sizer, 0, 435 wx.EXPAND |wx.TOP|wx.BOTTOM, 5),436 (self.shape_sizer, 0, 437 wx.EXPAND |wx.TOP|wx.BOTTOM, 5)])435 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 436 (self.shape_sizer, 0, 437 wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 438 438 self.boxsizer_parameters.AddMany([(self.param_sizer, 0, 439 wx.EXPAND |wx.TOP|wx.BOTTOM, 5),])439 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), ]) 440 440 self.boxsizer_qrange.AddMany([(self.qrange_sizer, 0, 441 wx.EXPAND |wx.TOP|wx.BOTTOM, 5),])442 self.main_sizer.AddMany([(self.boxsizer_source, 0, 443 wx.EXPAND |wx.ALL, 10),444 (self.boxsizer_parameters, 0, 445 wx.EXPAND |wx.ALL, 10),446 (self.boxsizer_qrange, 0, 447 wx.EXPAND |wx.ALL, 10),441 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), ]) 442 self.main_sizer.AddMany([(self.boxsizer_source, 0, 443 wx.EXPAND | wx.ALL, 10), 444 (self.boxsizer_parameters, 0, 445 wx.EXPAND | wx.ALL, 10), 446 (self.boxsizer_qrange, 0, 447 wx.EXPAND | wx.ALL, 10), 448 448 (self.button_sizer, 0, 449 wx.EXPAND |wx.TOP|wx.BOTTOM, 5)])449 wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 450 450 self.SetSizer(self.main_sizer) 451 451 self.SetAutoLayout(True) 452 452 453 453 def _create_default_sld_data(self): 454 454 """ … … 463 463 self.sld_data.filename = "Default SLD Profile" 464 464 self.sld_data.set_sldn(sld_n_default) 465 self.data_name_tcl.SetValue(self.sld_data.filename) 466 465 self.data_name_tcl.SetValue(self.sld_data.filename) 466 467 467 def choose_data_file(self, location=None): 468 468 """ … … 477 477 exts += ", *" + self.sldreader.ext[0] 478 478 exts += ", *" + self.pdbreader.ext[0] 479 all_type = "All GEN files (%s, %s) | %s" % (exts.upper(), exts.lower(),480 exts.lower().replace(',', ';')) 479 all_type = "All GEN files (%s, %s) | %s" % (exts.upper(), exts.lower(), 480 exts.lower().replace(',', ';')) 481 481 wildcard = [all_type] 482 482 omf_type = self.omfreader.type … … 496 496 path = dlg.GetPath() 497 497 filename = os.path.basename(path) 498 dlg.Destroy() 498 dlg.Destroy() 499 499 return path 500 500 501 501 def on_load_data(self, event): 502 502 """ … … 508 508 path = self.choose_data_file(location=location) 509 509 if path is None: 510 return 511 510 return 511 512 512 self.shape_sizer.ShowItems(False) 513 513 self.default_shape = 'rectangular' 514 514 self.parent.set_omfpanel_default_shap(self.default_shape) 515 515 516 516 self.parent.set_file_location(os.path.dirname(path)) 517 517 try: … … 531 531 self.browse_button.SetLabel("Loading...") 532 532 if self.parent.parent is not None: 533 wx.PostEvent(self.parent.parent, 533 wx.PostEvent(self.parent.parent, 534 534 StatusEvent(status="Loading...", 535 535 type="progress")) … … 542 542 self.ext = None 543 543 if self.parent.parent is None: 544 return 544 return 545 545 msg = "Generic SAS Calculator: %s" % (sys.exc_value) 546 546 wx.PostEvent(self.parent.parent, 547 547 StatusEvent(status=msg, type='stop')) 548 548 self.SetFocus() 549 return 550 549 return 550 551 551 def load_update(self): 552 552 """ 553 553 print update on the status bar 554 """ 554 """ 555 555 if self.parent.parent is None: 556 return 556 return 557 557 if self.reader.isrunning(): 558 558 type = "progress" … … 561 561 wx.PostEvent(self.parent.parent, StatusEvent(status="", 562 562 type=type)) 563 563 564 564 def complete_loading(self, data=None, filename=''): 565 565 """ … … 596 596 raise 597 597 msg = "Loading Error: This file format is not supported " 598 msg += "for GenSAS." 598 msg += "for GenSAS." 599 599 wx.PostEvent(self.parent.parent, 600 600 StatusEvent(status=msg, type='stop', info='Error')) 601 601 self.SetFocus() 602 return 602 return 603 603 if self.parent.parent is None: 604 return 605 604 return 605 606 606 msg = "Load Complete" 607 607 wx.PostEvent(self.parent.parent, StatusEvent(status=msg, type='stop')) 608 608 self.SetFocus() 609 609 610 610 def _set_sld_data_helper(self, is_draw=False): 611 611 """ … … 615 615 self.model.set_is_avg(self.is_avg) 616 616 self.model.set_sld_data(self.sld_data) 617 618 self.draw_button.Enable(self.sld_data !=None)617 618 self.draw_button.Enable(self.sld_data != None) 619 619 wx.CallAfter(self.parent.set_sld_data, self.sld_data) 620 620 self._update_model_params() 621 621 if is_draw: 622 622 wx.CallAfter(self.sld_draw, None, False) 623 623 624 624 def _update_model_params(self): 625 625 """ … … 630 630 val = str(self.model.params[param_name]) 631 631 list[1].SetValue(val) 632 632 633 633 def set_volume_ctl_val(self, val): 634 634 """ … … 641 641 list[1].Refresh() 642 642 break 643 643 644 644 def _onparamEnter(self, event): 645 645 """ … … 652 652 except: 653 653 pass 654 654 655 655 def sld_draw(self, event=None, has_arrow=True): 656 656 """ … … 668 668 669 669 self.sld_data = self.parent.get_sld_from_omf() 670 output = self.sld_data 670 output = self.sld_data 671 671 #frame_size = wx.Size(470, 470) 672 672 self.plot_frame = PlotFrame(self, -1, 'testView') … … 674 674 frame.Show(False) 675 675 add_icon(self.parent, frame) 676 panel = frame.plotpanel 676 panel = frame.plotpanel 677 677 try: 678 678 # mpl >= 1.0.0 … … 686 686 logging.error("PlotPanel could not import Axes3D") 687 687 raise 688 panel.dimension = 3 688 panel.dimension = 3 689 689 graph_title = self._sld_plot_helper(ax, output, has_arrow) 690 690 # Use y, z axes (in mpl 3d) as z, y axes 691 691 # that consistent with our SAS detector coords. 692 ax.set_xlabel('x ($\A%s$)' % output.pos_unit)693 ax.set_ylabel('z ($\A%s$)' % output.pos_unit)694 ax.set_zlabel('y ($\A%s$)' % output.pos_unit)695 panel.subplot.figure.subplots_adjust(left=0.05, right=0.95, 692 ax.set_xlabel('x ($\A%s$)' % output.pos_unit) 693 ax.set_ylabel('z ($\A%s$)' % output.pos_unit) 694 ax.set_zlabel('y ($\A%s$)' % output.pos_unit) 695 panel.subplot.figure.subplots_adjust(left=0.05, right=0.95, 696 696 bottom=0.05, top=0.96) 697 697 if output.pix_type == 'atom': 698 698 ax.legend(loc='upper left', prop={'size':10}) 699 699 num_graph = str(self.graph_num) 700 frame.SetTitle('Graph %s: %s' % (num_graph, graph_title))700 frame.SetTitle('Graph %s: %s' % (num_graph, graph_title)) 701 701 wx.CallAfter(frame.Show, True) 702 702 self.graph_num += 1 … … 710 710 """ 711 711 # Set the locals 712 color_dic = {'H':'blue', 'D':'purple', 'N': 'orange', 712 color_dic = {'H':'blue', 'D':'purple', 'N': 'orange', 713 713 'O':'red', 'C':'green', 'P':'cyan', 'Other':'k'} 714 714 marker = ',' … … 721 721 sld_mx = output.sld_mx 722 722 sld_my = output.sld_my 723 sld_mz = output.sld_mz 724 pix_symbol = output.pix_symbol 723 sld_mz = output.sld_mz 724 pix_symbol = output.pix_symbol 725 725 if output.pix_type == 'atom': 726 726 marker = 'o' … … 728 728 sld_tot = (numpy.fabs(sld_mx) + numpy.fabs(sld_my) + \ 729 729 numpy.fabs(sld_mz) + numpy.fabs(output.sld_n)) 730 is_nonzero = sld_tot > 0.0 731 is_zero = sld_tot == 0.0 730 is_nonzero = sld_tot > 0.0 731 is_zero = sld_tot == 0.0 732 732 # I. Plot null points 733 733 if is_zero.any(): 734 ax.plot(pos_x[is_zero], pos_z[is_zero], pos_y[is_zero], marker, 735 c="y", alpha=0.5, markeredgecolor='y', markersize=m_size) 734 ax.plot(pos_x[is_zero], pos_z[is_zero], pos_y[is_zero], marker, 735 c="y", alpha=0.5, markeredgecolor='y', markersize=m_size) 736 736 pos_x = pos_x[is_nonzero] 737 737 pos_y = pos_y[is_nonzero] … … 746 746 chosen_color = pix_symbol == key 747 747 if numpy.any(chosen_color): 748 other_color = other_color 748 other_color = other_color & (chosen_color != True) 749 749 color = color_dic[key] 750 ax.plot(pos_x[chosen_color], pos_z[chosen_color], 751 pos_y[chosen_color], marker, c=color, alpha=0.5, 752 markeredgecolor=color, markersize=m_size, label=key) 750 ax.plot(pos_x[chosen_color], pos_z[chosen_color], 751 pos_y[chosen_color], marker, c=color, alpha=0.5, 752 markeredgecolor=color, markersize=m_size, label=key) 753 753 # III. Plot All others 754 754 if numpy.any(other_color): … … 764 764 a_name += new_name 765 765 # plot in black 766 ax.plot(pos_x[other_color], pos_z[other_color], pos_y[other_color], 767 marker, c="k", alpha=0.5, markeredgecolor="k", 768 markersize=m_size, label=a_name) 766 ax.plot(pos_x[other_color], pos_z[other_color], pos_y[other_color], 767 marker, c="k", alpha=0.5, markeredgecolor="k", 768 markersize=m_size, label=a_name) 769 769 # IV. Draws atomic bond with grey lines if any 770 770 if output.has_conect: 771 771 for ind in range(len(output.line_x)): 772 ax.plot(output.line_x[ind], output.line_z[ind], 773 output.line_y[ind], '-', lw=0.6, c="grey", alpha=0.3) 772 ax.plot(output.line_x[ind], output.line_z[ind], 773 output.line_y[ind], '-', lw=0.6, c="grey", alpha=0.3) 774 774 # V. Draws magnetic vectors 775 if has_arrow and len(pos_x) > 0: 776 graph_title += " - Magnetic Vector as Arrow -" 775 if has_arrow and len(pos_x) > 0: 776 graph_title += " - Magnetic Vector as Arrow -" 777 777 panel = self.plot_frame.plotpanel 778 778 def _draw_arrow(input=None, update=None): … … 785 785 max_m = max(max_mx, max_my, max_mz) 786 786 try: 787 max_step = max(output.xstepsize, output.ystepsize, 787 max_step = max(output.xstepsize, output.ystepsize, 788 788 output.zstepsize) 789 789 except: … … 807 807 z_arrow = numpy.column_stack((pos_z, z2)) 808 808 colors = numpy.column_stack((color_x, color_y, color_z)) 809 arrows = Arrow3D(panel, x_arrow, z_arrow, y_arrow, 810 colors, mutation_scale=10, lw=1, 811 arrowstyle="->", alpha =0.5)812 ax.add_artist(arrows) 809 arrows = Arrow3D(panel, x_arrow, z_arrow, y_arrow, 810 colors, mutation_scale=10, lw=1, 811 arrowstyle="->", alpha=0.5) 812 ax.add_artist(arrows) 813 813 except: 814 pass 814 pass 815 815 msg = "Arrow Drawing completed.\n" 816 816 status_type = 'stop' 817 self._status_info(msg, status_type) 817 self._status_info(msg, status_type) 818 818 msg = "Arrow Drawing is in progress..." 819 819 status_type = 'progress' 820 self._status_info(msg, status_type) 820 self._status_info(msg, status_type) 821 821 draw_out = CalcGen(input=ax, 822 822 completefn=_draw_arrow, updatefn=self._update) 823 823 draw_out.queue() 824 824 return graph_title 825 825 826 826 def set_input_params(self): 827 827 """ … … 832 832 param_value = float(list[1].GetValue()) 833 833 self.model.setParam(param_name, param_value) 834 834 835 835 def on_compute(self, event): 836 836 """ … … 870 870 self._create_default_2d_data() 871 871 i_out = numpy.zeros(len(self.data.data)) 872 inputs =[self.data.qx_data, self.data.qy_data, i_out]873 872 inputs = [self.data.qx_data, self.data.qy_data, i_out] 873 874 874 msg = "Computation is in progress..." 875 875 status_type = 'progress' 876 876 self._status_info(msg, status_type) 877 cal_out = CalcGen(input=inputs, 878 completefn=self.complete, 877 cal_out = CalcGen(input=inputs, 878 completefn=self.complete, 879 879 updatefn=self._update) 880 cal_out.queue() 881 880 cal_out.queue() 881 882 882 except: 883 msg = "%s." % sys.exc_value883 msg = "%s." % sys.exc_value 884 884 status_type = 'stop' 885 885 self._status_info(msg, status_type) … … 888 888 self.SetFocus() 889 889 890 def on_help(self, event): 890 def on_help(self, event): 891 891 """ 892 892 Bring up the General scattering Calculator Documentation whenever 893 the HELP button is clicked. 894 893 the HELP button is clicked. 894 895 895 Calls DocumentationWindow with the path of the location within the 896 documentation tree (after /doc/ ....". Note that when using old 897 versions of Wx (before 2.9) and thus not the release version of 898 installers, the help comes up at the top level of the file as 896 documentation tree (after /doc/ ....". Note that when using old 897 versions of Wx (before 2.9) and thus not the release version of 898 installers, the help comes up at the top level of the file as 899 899 webbrowser does not pass anything past the # to the browser when it is 900 900 running "file:///...." 901 901 902 902 :param evt: Triggers on clicking the help button 903 903 """ 904 904 905 905 _TreeLocation = "user/perspectives/calculator/sas_calculator_help.html" 906 906 _doc_viewer = DocumentationWindow(self, -1, \ 907 _TreeLocation, "General Scattering Calculator Help")907 _TreeLocation, "General Scattering Calculator Help") 908 908 909 909 def _check_value(self): … … 915 915 self.qmax_ctl.SetBackgroundColour("white") 916 916 try: 917 npt_val = float(self.npt_ctl.GetValue()) 917 npt_val = float(self.npt_ctl.GetValue()) 918 918 if npt_val < 2 or npt_val > 1000: 919 919 raise … … 921 921 self.set_est_time() 922 922 except: 923 flag = 923 flag = _set_error(self, self.npt_ctl) 924 924 try: 925 qmax_val = float(self.qmax_ctl.GetValue()) 925 qmax_val = float(self.qmax_ctl.GetValue()) 926 926 if qmax_val <= 0 or qmax_val > 1000: 927 927 raise 928 928 except: 929 flag = _set_error(self, self.qmax_ctl) 929 flag = _set_error(self, self.qmax_ctl) 930 930 for list in self.parameters: 931 931 list[1].SetBackgroundColour("white") 932 932 param_name = list[0].GetLabelText() 933 try: 933 try: 934 934 param_val = float(list[1].GetValue()) 935 935 if param_name.count('frac') > 0: … … 939 939 flag = _set_error(self, list[1]) 940 940 return flag 941 942 def _status_info(self, msg = '', type ="update"):941 942 def _status_info(self, msg='', type="update"): 943 943 """ 944 944 Status msg … … 947 947 label = "Compute" 948 948 able = True 949 else: 949 else: 950 950 label = "Wait..." 951 951 able = False … … 954 954 self.bt_compute.SetToolTipString(label) 955 955 if self.parent.parent != None: 956 wx.PostEvent(self.parent.parent, 957 StatusEvent(status = msg, type = type ))956 wx.PostEvent(self.parent.parent, 957 StatusEvent(status=msg, type=type)) 958 958 959 959 def _update(self, time=None): … … 967 967 wx.PostEvent(self.parent.parent, StatusEvent(status=msg, 968 968 type=type)) 969 970 def complete(self, input, update=None): 969 970 def complete(self, input, update=None): 971 971 """ 972 972 Gen compute complete function … … 980 980 update() 981 981 time.sleep(0.1) 982 inputi = [input[0][ind:ind +1], [], input[2][ind:ind+1]]982 inputi = [input[0][ind:ind + 1], [], input[2][ind:ind + 1]] 983 983 outi = self.model.run(inputi) 984 984 out = numpy.append(out, outi) … … 987 987 update() 988 988 time.sleep(0.001) 989 inputi = [input[0][ind:ind +1], input[1][ind:ind+1],990 input[2][ind:ind +1]]989 inputi = [input[0][ind:ind + 1], input[1][ind:ind + 1], 990 input[2][ind:ind + 1]] 991 991 outi = self.model.runXY(inputi) 992 992 out = numpy.append(out, outi) … … 997 997 #out = self.model.runXY(input) 998 998 self._draw2D(out) 999 999 1000 1000 msg = "Gen computation completed.\n" 1001 1001 status_type = 'stop' 1002 1002 self._status_info(msg, status_type) 1003 1003 1004 1004 def _create_default_2d_data(self): 1005 1005 """ … … 1097 1097 page_id = self.id 1098 1098 data = self.data 1099 1099 1100 1100 model = self.model 1101 1101 state = None 1102 1102 1103 1103 new_plot = Data1D(x=data.x, y=y_out) 1104 1104 new_plot.dx = data.dx … … 1112 1112 new_plot.title = "Generic model1D " 1113 1113 new_plot.id = str(page_id) + ': ' + self.file_name \ 1114 + ' #%s' % str(self.graph_num) + "_1D"1115 new_plot.group_id = str(page_id) + " Model1D" +\1116 ' #%s' % str(self.graph_num) + "_1D"1114 + ' #%s' % str(self.graph_num) + "_1D" 1115 new_plot.group_id = str(page_id) + " Model1D" + \ 1116 ' #%s' % str(self.graph_num) + "_1D" 1117 1117 new_plot.is_data = False 1118 1118 … … 1122 1122 new_plot.xaxis(str(_xaxis), str(_xunit)) 1123 1123 new_plot.yaxis(str(_yaxis), str(_yunit)) 1124 1124 1125 1125 if new_plot.is_data: 1126 1126 data_name = str(new_plot.name) … … 1129 1129 1130 1130 if len(title) > 1: 1131 new_plot.title = "Gen Theory for %s " % model.name + data_name1131 new_plot.title = "Gen Theory for %s " % model.name + data_name 1132 1132 new_plot.name = new_plot.id 1133 1133 new_plot.label = new_plot.id … … 1139 1139 title = new_plot.title 1140 1140 num_graph = str(self.graph_num) 1141 wx.CallAfter(self.parent.draw_graph, new_plot, 1142 title="GEN Graph %s: " % num_graph + new_plot.id)1141 wx.CallAfter(self.parent.draw_graph, new_plot, 1142 title="GEN Graph %s: " % num_graph + new_plot.id) 1143 1143 self.graph_num += 1 1144 1144 1145 1145 def _draw2D(self, image): 1146 1146 """ … … 1150 1150 page_id = self.id 1151 1151 data = self.data 1152 1152 1153 1153 model = self.model 1154 1154 qmin = 0.0 1155 1155 state = None 1156 1156 1157 1157 numpy.nan_to_num(image) 1158 1158 new_plot = Data2D(image=image, err_image=data.err_data) … … 1160 1160 new_plot.title = "Generic model 2D " 1161 1161 new_plot.id = str(page_id) + ': ' + self.file_name \ 1162 + ' #%s' % str(self.graph_num) + "_2D"1162 + ' #%s' % str(self.graph_num) + "_2D" 1163 1163 new_plot.group_id = str(page_id) + " Model2D" \ 1164 + ' #%s' % str(self.graph_num) + "_2D"1164 + ' #%s' % str(self.graph_num) + "_2D" 1165 1165 new_plot.detector = data.detector 1166 1166 new_plot.source = data.source … … 1180 1180 new_plot.xaxis(str(_xaxis), str(_xunit)) 1181 1181 new_plot.yaxis(str(_yaxis), str(_yunit)) 1182 1182 1183 1183 new_plot.is_data = False 1184 1184 if data.is_data: … … 1188 1188 1189 1189 if len(title) > 1: 1190 new_plot.title = "Gen Theory for %s " % model.name + data_name1190 new_plot.title = "Gen Theory for %s " % model.name + data_name 1191 1191 new_plot.name = new_plot.id 1192 1192 new_plot.label = new_plot.id … … 1198 1198 title = new_plot.title 1199 1199 num_graph = str(self.graph_num) 1200 wx.CallAfter(self.parent.draw_graph, new_plot, 1201 title="GEN Graph %s: " % num_graph + new_plot.id)1200 wx.CallAfter(self.parent.draw_graph, new_plot, 1201 title="GEN Graph %s: " % num_graph + new_plot.id) 1202 1202 self.graph_num += 1 1203 1203 1204 1204 def set_scale2d(self, scale): 1205 1205 """ … … 1207 1207 """ 1208 1208 self.scale2d = None 1209 1209 1210 1210 def on_panel_close(self, event): 1211 1211 """ … … 1213 1213 """ 1214 1214 #Not implemented 1215 1215 1216 1216 class OmfPanel(ScrolledPanel, PanelBase): 1217 1217 """ … … 1222 1222 ## Name to appear on the window title bar 1223 1223 window_caption = "SLD Pixel Info " 1224 1224 1225 1225 def __init__(self, parent, *args, **kwds): 1226 ScrolledPanel.__init__(self, parent, style=wx.RAISED_BORDER, 1226 ScrolledPanel.__init__(self, parent, style=wx.RAISED_BORDER, 1227 1227 *args, **kwds) 1228 1228 PanelBase.__init__(self) 1229 1229 #Font size 1230 1230 self.SetWindowVariant(variant=FONT_VARIANT) 1231 self.SetupScrolling() 1231 self.SetupScrolling() 1232 1232 # Object that receive status event 1233 1233 self.parent = parent 1234 self.sld_data = sas_gen.MagSLD([0], [0], [0]) 1234 self.sld_data = sas_gen.MagSLD([0], [0], [0]) 1235 1235 self.sld_ctl = None 1236 1236 self.default_shape = 'rectangular' 1237 1237 self._do_layout() 1238 1238 1239 1239 def set_slddata(self, slddata): 1240 1240 """ … … 1245 1245 # Make sure that self._set_slddata_ctr_val() is finished 1246 1246 wx.CallAfter(self._set_omfdata_ctr, slddata) 1247 1247 1248 1248 def get_sld_val(self): 1249 1249 """ … … 1285 1285 self.sld_data.set_sldms(mx, my, mz) 1286 1286 self._set_slddata_ctr_val(self.sld_data) 1287 1287 1288 1288 return self.sld_data 1289 1289 1290 1290 def get_pix_volumes(self): 1291 1291 """ … … 1293 1293 """ 1294 1294 vol = self.sld_data.vol_pix 1295 1295 1296 1296 return vol 1297 1298 def _get_other_val(self): 1297 1298 def _get_other_val(self): 1299 1299 """ 1300 1300 """ … … 1316 1316 sets[lst[0]] = None 1317 1317 return 1318 1318 1319 1319 for key in sets.keys(): 1320 exec "omfdata.%s = sets['%s']" % (key, key)1320 exec "omfdata.%s = sets['%s']" % (key, key) 1321 1321 1322 1322 omf2sld = sas_gen.OMF2SLD() … … 1326 1326 self.sld_data.filename = "Default SLD Profile" 1327 1327 except: 1328 msg = "OMF Panel: %s" % sys.exc_value1328 msg = "OMF Panel: %s" % sys.exc_value 1329 1329 infor = 'Error' 1330 1330 #logging.error(msg) … … 1334 1334 StatusEvent(status=msg, info=infor)) 1335 1335 self.SetFocus() 1336 1336 1337 1337 def _set_slddata_ctr_val(self, slddata): 1338 1338 """ … … 1344 1344 val = 'Unknown' 1345 1345 self.npix_ctl.SetValue(val) 1346 1347 def _set_omfdata_ctr(self, omfdata): 1346 1347 def _set_omfdata_ctr(self, omfdata): 1348 1348 """ 1349 1349 Set the textctr box values 1350 1350 """ 1351 1351 1352 1352 if omfdata == None: 1353 1353 self._set_none_text() … … 1366 1366 ctr_list[1].SetValue(format_number(step_list[key], True)) 1367 1367 ctr_list[1].Enable(not omfdata.is_data) 1368 break 1369 1368 break 1369 1370 1370 def _set_none_text(self): 1371 1371 """ … … 1377 1377 for ctr_list in self.stepsize: 1378 1378 ctr_list[1].SetValue(val) 1379 1379 1380 1380 def _define_structure(self): 1381 1381 """ … … 1383 1383 """ 1384 1384 self.main_sizer = wx.BoxSizer(wx.VERTICAL) 1385 1385 1386 1386 self.npixels_sizer = wx.BoxSizer(wx.HORIZONTAL) 1387 self.box_sld = wx.StaticBox(self, -1, 1387 self.box_sld = wx.StaticBox(self, -1, 1388 1388 str("Mean SLD")) 1389 1389 self.box_node = wx.StaticBox(self, -1, str("Nodes")) … … 1398 1398 self.hint_sizer = wx.BoxSizer(wx.HORIZONTAL) 1399 1399 self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 1400 1400 1401 1401 def _layout_npix(self): 1402 1402 """ 1403 1403 Build No of pixels sizer 1404 1404 """ 1405 num_pix_text = wx.StaticText(self, -1, "No. of Pixels: ") 1405 num_pix_text = wx.StaticText(self, -1, "No. of Pixels: ") 1406 1406 self.npix_ctl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 1407 1407 style=wx.TE_PROCESS_ENTER) 1408 1408 self._set_slddata_ctr_val(self.sld_data) 1409 self._set_omfdata_ctr(self.sld_data) 1409 self._set_omfdata_ctr(self.sld_data) 1410 1410 self.npixels_sizer.AddMany([(num_pix_text, 0, 1411 wx.EXPAND |wx.LEFT|wx.TOP, 5),1411 wx.EXPAND | wx.LEFT | wx.TOP, 5), 1412 1412 (self.npix_ctl, 0, 1413 wx.EXPAND |wx.TOP, 5)])1413 wx.EXPAND | wx.TOP, 5)]) 1414 1414 1415 1415 def _layout_slds(self): … … 1451 1451 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1452 1452 self.slds.append([key, ctl, unit]) 1453 self.sld_sizer.Add(sizer, 0, wx.LEFT, 10) 1454 1453 self.sld_sizer.Add(sizer, 0, wx.LEFT, 10) 1454 1455 1455 def _layout_nodes(self): 1456 1456 """ … … 1476 1476 ctl = InputTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 1477 1477 style=wx.TE_PROCESS_ENTER) 1478 ctl.Bind(wx.EVT_TEXT, self._onparamEnter 1478 ctl.Bind(wx.EVT_TEXT, self._onparamEnter) 1479 1479 ctl.SetValue(format_number(value, True)) 1480 1480 ctl.Enable(not is_data) … … 1487 1487 self.nodes.append([key, ctl, unit]) 1488 1488 self.node_sizer.Add(sizer, 0, wx.LEFT, 10) 1489 1489 1490 1490 def _layout_stepsize(self): 1491 1491 """ … … 1512 1512 ctl = InputTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 1513 1513 style=wx.TE_PROCESS_ENTER) 1514 ctl.Bind(wx.EVT_TEXT, self._onstepsize 1514 ctl.Bind(wx.EVT_TEXT, self._onstepsize) 1515 1515 ctl.SetValue(format_number(value, True)) 1516 1516 ctl.Enable(not is_data) … … 1524 1524 self.stepsize.append([key, ctl, unit]) 1525 1525 self.step_sizer.Add(sizer, 0, wx.LEFT, 10) 1526 1526 1527 1527 def _layout_hint(self): 1528 1528 """ 1529 Fill the sizer containing hint 1529 Fill the sizer containing hint 1530 1530 """ 1531 1531 hint_msg = "Load an omf or 3d sld profile data file." 1532 1532 self.hint_txt = wx.StaticText(self, -1, hint_msg) 1533 1533 self.hint_sizer.AddMany([(self.hint_txt, 0, wx.LEFT, 15)]) 1534 1535 def _layout_button(self): 1534 1535 def _layout_button(self): 1536 1536 """ 1537 1537 Do the layout for the button widgets 1538 """ 1539 self.bt_draw = wx.Button(self, wx.NewId(), 'Draw Points')1538 """ 1539 self.bt_draw = wx.Button(self, wx.NewId(), 'Draw Points') 1540 1540 self.bt_draw.Bind(wx.EVT_BUTTON, self.on_sld_draw) 1541 1541 self.bt_draw.SetToolTipString("Draw a scatter plot for sld profile.") 1542 self.bt_save = wx.Button(self, wx.NewId(), 'Save SLD Data')1542 self.bt_save = wx.Button(self, wx.NewId(), 'Save SLD Data') 1543 1543 self.bt_save.Bind(wx.EVT_BUTTON, self.on_save) 1544 1544 self.bt_save.Enable(False) … … 1546 1546 self.button_sizer.AddMany([(self.bt_draw, 0, wx.LEFT, 10), 1547 1547 (self.bt_save, 0, wx.LEFT, 10)]) 1548 1548 1549 1549 def _do_layout(self): 1550 1550 """ 1551 1551 Draw omf panel content, used to define sld s. 1552 1552 1553 1553 """ 1554 1554 self._define_structure() … … 1560 1560 self._layout_button() 1561 1561 self.boxsizer_node.AddMany([(self.node_sizer, 0, 1562 wx.EXPAND |wx.TOP, 5),1562 wx.EXPAND | wx.TOP, 5), 1563 1563 (self.hint_sizer, 0, 1564 wx.EXPAND |wx.TOP|wx.BOTTOM, 5)])1564 wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 1565 1565 self.boxsizer_stepsize.AddMany([(self.step_sizer, 0, 1566 wx.EXPAND |wx.TOP|wx.BOTTOM, 5),])1566 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), ]) 1567 1567 self.boxsizer_sld.AddMany([(self.sld_sizer, 0, 1568 wx.EXPAND |wx.BOTTOM, 5),])1569 self.main_sizer.AddMany([(self.npixels_sizer, 0, wx.EXPAND |wx.ALL, 10),1570 (self.boxsizer_sld, 0, wx.EXPAND |wx.ALL, 10),1571 (self.boxsizer_node, 0, wx.EXPAND |wx.ALL, 10),1572 (self.boxsizer_stepsize, 0, wx.EXPAND |wx.ALL, 10),1573 (self.button_sizer, 0, wx.EXPAND |wx.TOP|wx.BOTTOM, 5)])1568 wx.EXPAND | wx.BOTTOM, 5), ]) 1569 self.main_sizer.AddMany([(self.npixels_sizer, 0, wx.EXPAND | wx.ALL, 10), 1570 (self.boxsizer_sld, 0, wx.EXPAND | wx.ALL, 10), 1571 (self.boxsizer_node, 0, wx.EXPAND | wx.ALL, 10), 1572 (self.boxsizer_stepsize, 0, wx.EXPAND | wx.ALL, 10), 1573 (self.button_sizer, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 1574 1574 self.SetSizer(self.main_sizer) 1575 1575 self.SetAutoLayout(True) 1576 1576 1577 1577 def _get_nodes_key_list(self, data): 1578 1578 """ 1579 1579 Return nodes key list 1580 1580 1581 1581 :Param data: OMFData 1582 1582 """ 1583 key_list = {'xnodes' : data.xnodes, 1583 key_list = {'xnodes' : data.xnodes, 1584 1584 'ynodes' : data.ynodes, 1585 1585 'znodes' : data.znodes} 1586 1586 return key_list 1587 1587 1588 1588 def _get_slds_key_list(self, data): 1589 1589 """ 1590 1590 Return nodes key list 1591 1591 1592 1592 :Param data: OMFData 1593 1593 """ 1594 key_list = {'Nucl.' : data.sld_n, 1594 key_list = {'Nucl.' : data.sld_n, 1595 1595 'Mx' : data.sld_mx, 1596 1596 'My' : data.sld_my, … … 1601 1601 """ 1602 1602 Return step key list 1603 1603 1604 1604 :Param data: OMFData 1605 1605 """ 1606 key_list = {'xstepsize' : data.xstepsize, 1606 key_list = {'xstepsize' : data.xstepsize, 1607 1607 'ystepsize' : data.ystepsize, 1608 1608 'zstepsize' : data.zstepsize} 1609 return key_list 1610 1609 return key_list 1610 1611 1611 def set_sld_ctr(self, sld_data): 1612 1612 """ … … 1618 1618 #break 1619 1619 return 1620 1620 1621 1621 self.sld_data = sld_data 1622 1622 sld_list = self._get_slds_key_list(sld_data) … … 1632 1632 ctr_list[1].Enable(enable) 1633 1633 #ctr_list[2].SetLabel("[" + sld_data.sld_unit + "]") 1634 break 1634 break 1635 1635 1636 1636 def on_sld_draw(self, event): … … 1639 1639 """ 1640 1640 self.parent.sld_draw() 1641 1641 1642 1642 def on_save(self, event): 1643 1643 """ … … 1650 1650 self.sld_data = self.get_sld_val() 1651 1651 self.parent.set_main_panel_sld_data(self.sld_data) 1652 1653 reader = sas_gen.SLDReader() 1652 1653 reader = sas_gen.SLDReader() 1654 1654 extension = '*.sld' 1655 1655 path = None 1656 data = None1656 data = None 1657 1657 location = self.parent.get_path() 1658 1658 dlg = wx.FileDialog(self, "Save sld file", 1659 1659 location, "sld_file", 1660 extension, 1660 extension, 1661 1661 wx.SAVE) 1662 1662 if dlg.ShowModal() == wx.ID_OK: … … 1669 1669 if path is None: 1670 1670 return 1671 1671 1672 1672 data = self.parent.get_sld_data() 1673 1673 fName = os.path.splitext(path)[0] + '.' + extension.split('.')[-1] … … 1693 1693 # inform msg to wx 1694 1694 wx.PostEvent(self.parent.parent, 1695 StatusEvent(status=msg, info=infor)) 1696 self.SetFocus() 1695 StatusEvent(status=msg, info=infor)) 1696 self.SetFocus() 1697 1697 1698 1698 def _onparamEnter(self, event): … … 1724 1724 nop = npts 1725 1725 self.display_npts(nop) 1726 1726 1727 1727 ctl.Refresh() 1728 1728 return flag 1729 1729 1730 1730 def _set_volume_ctr_val(self, npts): 1731 1731 """ … … 1734 1734 total_volume = npts * self.sld_data.vol_pix[0] 1735 1735 self.parent.set_volume_ctr_val(total_volume) 1736 1736 1737 1737 def _onstepsize(self, event): 1738 1738 """ … … 1763 1763 pass 1764 1764 ctl.Refresh() 1765 1766 1765 1766 1767 1767 def set_npts_from_slddata(self): 1768 1768 """ … … 1776 1776 nop = None 1777 1777 return nop 1778 1778 1779 1779 def display_npts(self, nop): 1780 1780 """ … … 1789 1789 # On Init 1790 1790 pass 1791 1791 1792 1792 def check_inputs(self): 1793 1793 """ … … 1800 1800 flag = self._check_input_helper(self.stepsize) 1801 1801 return flag 1802 1802 1803 1803 def _check_input_helper(self, list): 1804 1804 """ … … 1820 1820 GEN SAS main window 1821 1821 """ 1822 def __init__(self, parent=None, manager= 1822 def __init__(self, parent=None, manager=None, title="Generic Scattering Calculator", 1823 1823 size=(PANEL_WIDTH * 1.4, PANEL_HEIGHT * 1.65), *args, **kwds): 1824 1824 """ … … 1835 1835 self.omfdata = sas_gen.OMFData() 1836 1836 self.sld_data = None 1837 self._default_save_location = os.getcwd() 1838 1837 self._default_save_location = os.getcwd() 1838 1839 1839 self._mgr = aui.AuiManager(self) 1840 1840 self._mgr.SetDockSizeConstraint(0.5, 0.5) … … 1842 1842 self.scale2d = 'log_{10}' 1843 1843 self.Bind(wx.EVT_CLOSE, self.on_close) 1844 1845 1844 1845 1846 1846 self.build_panels() 1847 1847 self.SetPosition((20, 5)) 1848 1848 self.Show(True) 1849 1849 1850 1850 def build_panels(self): 1851 1851 """ 1852 1852 """ 1853 1853 1854 1854 self.set_sld_data(self.sld_data) 1855 1855 self._mgr.AddPane(self.panel, aui.AuiPaneInfo(). … … 1858 1858 # This is where we set the size of 1859 1859 # the application window 1860 BestSize(wx.Size(PANEL_WIDTH, 1860 BestSize(wx.Size(PANEL_WIDTH, 1861 1861 PANEL_HEIGHT)). 1862 Show()) 1862 Show()) 1863 1863 self._mgr.AddPane(self.omfpanel, aui.AuiPaneInfo(). 1864 1864 Name(self.omfpanel.window_name). … … 1867 1867 Right(). 1868 1868 Floatable(False). 1869 BestSize(wx.Size(PANEL_WIDTH /2.5, PANEL_HEIGHT)).1870 Show()) 1869 BestSize(wx.Size(PANEL_WIDTH / 2.5, PANEL_HEIGHT)). 1870 Show()) 1871 1871 self._mgr.Update() 1872 1872 … … 1876 1876 """ 1877 1877 return self.sld_data 1878 1878 1879 1879 def get_sld_from_omf(self): 1880 1880 """ … … 1882 1882 self.sld_data = self.omfpanel.get_sld_val() 1883 1883 return self.sld_data 1884 1884 1885 1885 def set_sld_n(self, sld): 1886 1886 """ … … 1888 1888 self.panel.sld_data = sld 1889 1889 self.panel.model.set_sld_data(sld) 1890 1890 1891 1891 def set_sld_data(self, data): 1892 1892 """ … … 1896 1896 return 1897 1897 self.sld_data = data 1898 enable = (not data ==None)1898 enable = (not data == None) 1899 1899 self._set_omfpanel_sld_data(self.sld_data) 1900 1900 self.omfpanel.bt_save.Enable(enable) 1901 1901 self.set_etime() 1902 1902 1903 1903 def set_omfpanel_npts(self): 1904 1904 """ … … 1907 1907 nop = self.omfpanel.set_npts_from_slddata() 1908 1908 self.omfpanel.display_npts(nop) 1909 1909 1910 1910 def _set_omfpanel_sld_data(self, data): 1911 1911 """ 1912 1912 Set sld_data in omf panel 1913 1913 """ 1914 self.omfpanel.set_slddata(data) 1914 self.omfpanel.set_slddata(data) 1915 1915 self.omfpanel.set_sld_ctr(data) 1916 1916 1917 1917 def check_omfpanel_inputs(self): 1918 1918 """ 1919 1919 Check OMF panel inputs 1920 1920 """ 1921 return self.omfpanel.check_inputs() 1922 1921 return self.omfpanel.check_inputs() 1922 1923 1923 def set_main_panel_sld_data(self, sld_data): 1924 1924 """ 1925 1925 """ 1926 1926 self.sld_data = sld_data 1927 1927 1928 1928 def set_file_location(self, path): 1929 1929 """ … … 1931 1931 """ 1932 1932 self._default_save_location = path 1933 1933 1934 1934 def get_path(self): 1935 1935 """ … … 1937 1937 """ 1938 1938 return self._default_save_location 1939 1939 1940 1940 def draw_graph(self, plot, title=''): 1941 1941 """ 1942 1942 """ 1943 try: 1943 try: 1944 1944 wx.PostEvent(self.parent, NewPlotEvent(plot=plot, title=title)) 1945 1945 except: … … 1952 1952 frame.SetFocus() 1953 1953 1954 def set_schedule_full_draw(self, panel=None, func='del'): 1954 def set_schedule_full_draw(self, panel=None, func='del'): 1955 1955 """ 1956 1956 Send full draw to gui frame … … 1958 1958 if self.parent != None: 1959 1959 self.parent.set_schedule_full_draw(panel, func) 1960 1960 1961 1961 def get_npix(self): 1962 1962 """ … … 1965 1965 n_pix = self.omfpanel.npix_ctl.GetValue() 1966 1966 return n_pix 1967 1967 1968 1968 def get_pix_volumes(self): 1969 1969 """ … … 1972 1972 vol = self.omfpanel.get_pix_volumes() 1973 1973 return vol 1974 1974 1975 1975 def set_volume_ctr_val(self, val): 1976 1976 """ … … 1981 1981 except: 1982 1982 print "self.panel is not initialized yet" 1983 1983 1984 1984 def set_omfpanel_default_shap(self, shape): 1985 1985 """ … … 1987 1987 """ 1988 1988 self.omfpanel.default_shape = shape 1989 1989 1990 1990 def set_etime(self): 1991 1991 """ … … 1993 1993 """ 1994 1994 self.panel.set_est_time() 1995 1995 1996 1996 def get_sld_data_from_omf(self): 1997 1997 """ 1998 1998 """ 1999 data = self.omfpanel.get_sld_val() 1999 data = self.omfpanel.get_sld_val() 2000 2000 return data 2001 2001 2002 2002 def set_scale2d(self, scale): 2003 2003 """ 2004 2004 """ 2005 2005 self.scale2d = scale 2006 2006 2007 2007 def on_panel_close(self, event): 2008 2008 """ 2009 2009 """ 2010 2010 #Not implemented 2011 2011 2012 2012 def on_open_file(self, event): 2013 2013 """ … … 2015 2015 """ 2016 2016 self.panel.on_load_data(event) 2017 2017 2018 2018 def sld_draw(self): 2019 2019 """ … … 2021 2021 """ 2022 2022 self.panel.sld_draw(event=None, has_arrow=False) 2023 2023 2024 2024 def on_save_file(self, event): 2025 2025 """ … … 2027 2027 """ 2028 2028 self.omfpanel.on_save(event) 2029 2029 2030 2030 def on_close(self, event): 2031 2031 """ … … 2035 2035 self.base.gen_frame = None 2036 2036 self.Destroy() 2037 2037 2038 2038 # def on_help(self, event): 2039 2039 # """ … … 2061 2061 # info = "Info" 2062 2062 # wx.MessageBox(msg, info) 2063 2064 if __name__ == "__main__": 2063 2064 if __name__ == "__main__": 2065 2065 app = wx.PySimpleApp() 2066 2066 widget.CHILD_FRAME = wx.Frame 2067 SGframe = SasGenWindow() 2067 SGframe = SasGenWindow() 2068 2068 SGframe.Show(True) 2069 app.MainLoop() 2069 app.MainLoop()
Note: See TracChangeset
for help on using the changeset viewer.