- Timestamp:
- Jul 28, 2015 12:14:38 PM (9 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:
- a910c788
- Parents:
- ae2a197 (diff), d06c34c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas
- Files:
-
- 2 added
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/guiframe/gui_manager.py
r957af0d r225aca8 235 235 Initialize the Frame object 236 236 """ 237 238 237 PARENT_FRAME.__init__(self, parent=parent, title=title, pos=pos, size=size) 239 238 # title … … 364 363 frame.SetIcon(icon) 365 364 except: 366 pass365 logging.error("ViewerFrame.put_icon: could not set icon") 367 366 368 367 def get_client_size(self): … … 752 751 self._toolbar.Realize() 753 752 754 755 753 def build_gui(self): 756 754 """ … … 778 776 # Append item from plugin under menu file if necessary 779 777 self._populate_file_menu() 780 781 778 782 779 if not wx.VERSION_STRING >= '3.0.0.0': … … 822 819 # Load panels 823 820 self._load_panels() 824 self.set_default_perspective()825 821 826 822 def SetStatusText(self, *args, **kwds): … … 931 927 if hasattr(module, "PLUGIN_ID"): 932 928 try: 933 plug = module.Plugin() 934 if plug.set_default_perspective(): 935 self._current_perspective = plug 936 plugins.append(plug) 937 929 plugins.append(module.Plugin()) 938 930 msg = "Found plug-in: %s" % module.PLUGIN_ID 939 931 logging.info(msg) … … 1511 1503 for item in plugin.populate_file_menu(): 1512 1504 m_name, m_hint, m_handler = item 1513 id = wx.NewId()1514 self._file_menu.Append( id, m_name, m_hint)1515 wx.EVT_MENU(self, id, m_handler)1505 wx_id = wx.NewId() 1506 self._file_menu.Append(wx_id, m_name, m_hint) 1507 wx.EVT_MENU(self, wx_id, m_handler) 1516 1508 self._file_menu.AppendSeparator() 1517 1509 1518 1510 style1 = self.__gui_style & GUIFRAME.MULTIPLE_APPLICATIONS 1519 1511 if OPEN_SAVE_MENU: 1520 id = wx.NewId()1512 wx_id = wx.NewId() 1521 1513 hint_load_file = "read all analysis states saved previously" 1522 self._save_appl_menu = self._file_menu.Append( id, '&Open Project', hint_load_file)1523 wx.EVT_MENU(self, id, self._on_open_state_project)1514 self._save_appl_menu = self._file_menu.Append(wx_id, '&Open Project', hint_load_file) 1515 wx.EVT_MENU(self, wx_id, self._on_open_state_project) 1524 1516 1525 1517 if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: … … 1527 1519 hint_load_file = "Read a status files and load" 1528 1520 hint_load_file += " them into the analysis" 1529 id = wx.NewId()1530 self._save_appl_menu = self._file_menu.Append( id,1521 wx_id = wx.NewId() 1522 self._save_appl_menu = self._file_menu.Append(wx_id, 1531 1523 '&Open Analysis', hint_load_file) 1532 wx.EVT_MENU(self, id, self._on_open_state_application)1524 wx.EVT_MENU(self, wx_id, self._on_open_state_application) 1533 1525 if OPEN_SAVE_MENU: 1534 1526 self._file_menu.AppendSeparator() 1535 id = wx.NewId()1536 self._file_menu.Append( id, '&Save Project',1527 wx_id = wx.NewId() 1528 self._file_menu.Append(wx_id, '&Save Project', 1537 1529 'Save the state of the whole analysis') 1538 wx.EVT_MENU(self, id, self._on_save_project)1530 wx.EVT_MENU(self, wx_id, self._on_save_project) 1539 1531 if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 1540 id = wx.NewId()1541 self._save_appl_menu = self._file_menu.Append( id, \1532 wx_id = wx.NewId() 1533 self._save_appl_menu = self._file_menu.Append(wx_id, \ 1542 1534 '&Save Analysis', 'Save state of the current active analysis panel') 1543 wx.EVT_MENU(self, id, self._on_save_application)1535 wx.EVT_MENU(self, wx_id, self._on_save_application) 1544 1536 if not sys.platform == 'darwin': 1545 1537 self._file_menu.AppendSeparator() 1546 id = wx.NewId()1547 self._file_menu.Append( id, '&Quit', 'Exit')1548 wx.EVT_MENU(self, id, self.Close)1538 wx_id = wx.NewId() 1539 self._file_menu.Append(wx_id, '&Quit', 'Exit') 1540 wx.EVT_MENU(self, wx_id, self.Close) 1549 1541 1550 1542 def _add_menu_file(self): … … 1717 1709 """ 1718 1710 """ 1719 message = ""1720 1711 log_msg = '' 1721 output = []1722 error_message = ""1723 1712 basename = os.path.basename(path) 1724 root, extension = os.path.splitext(basename)1713 _, extension = os.path.splitext(basename) 1725 1714 if extension.lower() not in EXTENSIONS: 1726 1715 log_msg = "File Loader cannot " … … 2224 2213 if hasattr(item, "post_init"): 2225 2214 item.post_init() 2226 2227 def set_default_perspective(self):2228 """2229 Choose among the plugin the first plug-in that has2230 "set_default_perspective" method and its return value is True will be2231 as a default perspective when the welcome page is closed2232 """2233 for item in self.plugins:2234 if hasattr(item, "set_default_perspective"):2235 if item.set_default_perspective():2236 item.on_perspective(event=None)2237 return2238 2215 2239 2216 def set_perspective(self, panels): … … 2414 2391 total_plot_list.append(theory_data) 2415 2392 for new_plot in total_plot_list: 2416 id = new_plot.id2417 2393 for group_id in new_plot.list_group_id: 2418 wx.PostEvent(self, NewPlotEvent(id= id,2394 wx.PostEvent(self, NewPlotEvent(id=new_plot.id, 2419 2395 group_id=group_id, 2420 2396 action='remove')) 2421 2397 #remove res plot: Todo: improve 2422 wx.CallAfter(self._remove_res_plot, id)2398 wx.CallAfter(self._remove_res_plot, new_plot.id) 2423 2399 self._data_manager.delete_data(data_id=data_id, 2424 2400 theory_id=theory_id) … … 2455 2431 ext_num = dlg.GetFilterIndex() 2456 2432 if ext_num == 0: 2457 format = '.txt'2433 ext_format = '.txt' 2458 2434 else: 2459 format = '.xml'2460 path = os.path.splitext(path)[0] + format2435 ext_format = '.xml' 2436 path = os.path.splitext(path)[0] + ext_format 2461 2437 mypath = os.path.basename(path) 2462 2438 2463 2439 #Instantiate a loader 2464 2440 loader = Loader() 2465 format = ".txt"2466 if os.path.splitext(mypath)[1].lower() == format:2441 ext_format = ".txt" 2442 if os.path.splitext(mypath)[1].lower() == ext_format: 2467 2443 # Make sure the ext included in the file name 2468 2444 # especially on MAC 2469 fName = os.path.splitext(path)[0] + format2445 fName = os.path.splitext(path)[0] + ext_format 2470 2446 self._onsaveTXT(data, fName) 2471 format = ".xml"2472 if os.path.splitext(mypath)[1].lower() == format:2447 ext_format = ".xml" 2448 if os.path.splitext(mypath)[1].lower() == ext_format: 2473 2449 # Make sure the ext included in the file name 2474 2450 # especially on MAC 2475 fName = os.path.splitext(path)[0] + format2476 loader.save(fName, data, format)2451 fName = os.path.splitext(path)[0] + ext_format 2452 loader.save(fName, data, ext_format) 2477 2453 try: 2478 2454 self._default_save_location = os.path.dirname(path) … … 2598 2574 ext_num = dlg.GetFilterIndex() 2599 2575 if ext_num == 0: 2600 format = '.dat'2576 ext_format = '.dat' 2601 2577 else: 2602 format = ''2603 path = os.path.splitext(path)[0] + format2578 ext_format = '' 2579 path = os.path.splitext(path)[0] + ext_format 2604 2580 mypath = os.path.basename(path) 2605 2581 … … 2607 2583 loader = Loader() 2608 2584 2609 format = ".dat"2610 if os.path.splitext(mypath)[1].lower() == format:2585 ext_format = ".dat" 2586 if os.path.splitext(mypath)[1].lower() == ext_format: 2611 2587 # Make sure the ext included in the file name 2612 2588 # especially on MAC 2613 fileName = os.path.splitext(path)[0] + format2614 loader.save(fileName, data, format)2589 fileName = os.path.splitext(path)[0] + ext_format 2590 loader.save(fileName, data, ext_format) 2615 2591 try: 2616 2592 self._default_save_location = os.path.dirname(path) … … 3206 3182 3207 3183 3208 class ViewApp(wx.App):3184 class SasViewApp(wx.App): 3209 3185 """ 3210 Toy application to test this Frame3186 SasView application 3211 3187 """ 3212 3188 def OnInit(self): … … 3294 3270 if len(os.listdir(model_folder)) > 0: 3295 3271 try: 3296 for file in os.listdir(model_folder):3297 file_path = os.path.join(model_folder, file )3272 for filename in os.listdir(model_folder): 3273 file_path = os.path.join(model_folder, filename) 3298 3274 if os.path.isfile(file_path): 3299 3275 os.remove(file_path) … … 3314 3290 """ 3315 3291 #try to load file at the start 3316 try: 3317 self.open_file() 3318 except: 3319 raise 3292 self.open_file() 3320 3293 self.frame.build_gui() 3321 3294 -
src/sas/guiframe/local_perspectives/data_loader/data_loader.py
rf76bf17 rf21d496 41 41 class Plugin(PluginBase): 42 42 43 def __init__(self , standalone=False):44 PluginBase.__init__(self, name="DataLoader" , standalone=standalone)43 def __init__(self): 44 PluginBase.__init__(self, name="DataLoader") 45 45 # Default location 46 46 self._default_save_location = DEFAULT_OPEN_FOLDER -
src/sas/guiframe/local_perspectives/plotting/plotting.py
rc039589 rf21d496 36 36 """ 37 37 38 def __init__(self , standalone=False):39 PluginBase.__init__(self, name="Plotting" , standalone=standalone)38 def __init__(self): 39 PluginBase.__init__(self, name="Plotting") 40 40 41 41 ## Plot panels -
src/sas/guiframe/plugin_base.py
r373d4ee rf21d496 34 34 """ 35 35 36 def __init__(self, name="Test_plugin" , standalone=True):36 def __init__(self, name="Test_plugin"): 37 37 """ 38 38 Abstract class for gui_manager Plugins. … … 42 42 ## Plug-in name. It will appear on the application menu. 43 43 self.sub_menu = name 44 #standalone flag45 self.standalone = standalone46 44 ## Reference to the parent window. Filled by get_panels() below. 47 45 self.parent = None … … 263 261 pass 264 262 265 def set_default_perspective(self):266 """267 Call back method that True to notify the parent that the current plug-in268 can be set as default perspective.269 when returning False, the plug-in is not candidate for an automatic270 default perspective setting271 """272 if self.standalone:273 return True274 return False275 276 263 def set_state(self, state=None, datainfo=None): 277 264 """ -
src/sas/perspectives/calculator/calculator.py
r49ab5d7 rf21d496 33 33 for calculator perspective 34 34 """ 35 def __init__(self , standalone=True):36 PluginBase.__init__(self, name="Calculator" , standalone=standalone)35 def __init__(self): 36 PluginBase.__init__(self, name="Calculator") 37 37 # Log startup 38 38 logging.info("Calculator plug-in started") -
src/sas/perspectives/fitting/fitpage.py
r098f3d2 r225aca8 268 268 weighting_box.Add(sizer_weighting) 269 269 270 sizer_fit = wx.GridSizer(2, 5, 2, 6)271 272 270 # combobox for smear2d accuracy selection 273 271 self.smear_accuracy = wx.ComboBox(self, -1, size=(50, -1), … … 282 280 283 281 #Fit button 284 self.btFit = wx.Button(self, wx.NewId(), 'Fit' , size=(88, 25))282 self.btFit = wx.Button(self, wx.NewId(), 'Fit') 285 283 self.default_bt_colour = self.btFit.GetDefaultAttributes() 286 284 self.btFit.Bind(wx.EVT_BUTTON, self._onFit, id=self.btFit.GetId()) … … 288 286 289 287 #General Help button 290 self.btFitHelp = wx.Button(self, -1, 'H ELP')291 self.btFitHelp.SetToolTipString("General Fitting Help.")288 self.btFitHelp = wx.Button(self, -1, 'Help') 289 self.btFitHelp.SetToolTipString("General fitting help.") 292 290 self.btFitHelp.Bind(wx.EVT_BUTTON, self._onFitHelp) 293 291 … … 303 301 self.btSmearHelp = wx.Button(self, -1, '?', style=wx.BU_EXACTFIT,\ 304 302 size=size_q) 305 self.btSmearHelp.SetToolTipString("Resolution Smearing Help.")303 self.btSmearHelp.SetToolTipString("Resolution smearing help.") 306 304 self.btSmearHelp.Bind(wx.EVT_BUTTON, self._onSmearHelp) 307 305 … … 362 360 self.disable_smearer.SetValue(True) 363 361 364 # add 4 types of smearing to the sizer365 # Note from June 14, 2015366 # removed the extra (10,10) spaces to make room for help. Actually367 # don't see the need for those anyway as the wx.LEFT, xx should take368 # care of spacing anyway though it does not seem to work for some369 # reason. Currently leaving as we are in "code freeze" only making370 # minimal changes necessary for release 3.1. We probably want to clean371 # up the whole fitpage (and basepage and fitpanel etc) eventually.372 # ---- PDB373 362 sizer_smearer.Add(self.disable_smearer, 0, wx.LEFT, 10) 374 # sizer_smearer.Add((10, 10))375 363 sizer_smearer.Add(self.enable_smearer) 376 # sizer_smearer.Add((10, 10))377 364 sizer_smearer.Add(self.pinhole_smearer) 378 # sizer_smearer.Add((10, 10))379 365 sizer_smearer.Add(self.slit_smearer) 380 # sizer_smearer.Add((10, 10))381 366 sizer_smearer.Add(self.btSmearHelp) 382 367 sizer_smearer.Add((10, 10)) … … 397 382 398 383 # Update and Draw button 399 self.draw_button = wx.Button(self, wx.NewId(), 400 'Compute', size=(88, 24)) 384 self.draw_button = wx.Button(self, wx.NewId(), 'Compute') 401 385 self.draw_button.Bind(wx.EVT_BUTTON, \ 402 386 self._onDraw, id=self.draw_button.GetId()) … … 414 398 box_description_1 = wx.StaticText(self, -1, ' Chi2/Npts') 415 399 box_description_2 = wx.StaticText(self, -1, 'Npts(Fit)') 416 #box_description_3 = wx.StaticText(self, -1, 'Total Npts')417 #box_description_3.SetToolTipString( \418 # " Total Npts : total number of data points")419 420 sizer_fit.Add(box_description_1, 0, 0)421 sizer_fit.Add(box_description_2, 0, 0)422 sizer_fit.Add(self.points_sizer, 0, 0)423 #sizer_fit.Add(box_description_3, 0, 0)424 sizer_fit.Add(self.draw_button, 0, 0)425 sizer_fit.Add((-1,5))426 sizer_fit.Add(self.tcChi, 0, 0)427 sizer_fit.Add(self.Npts_fit, 0, 0)428 sizer_fit.Add(self.Npts_total, 0, 0)429 sizer_fit.Add(self.btFit, 0, 0)430 sizer_fit.Add(self.btFitHelp, 0, 0)431 400 432 401 # StaticText for smear … … 576 545 self.qmin.Bind(wx.EVT_TEXT, self.on_qrange_text) 577 546 self.qmax.Bind(wx.EVT_TEXT, self.on_qrange_text) 578 id = wx.NewId()579 self.reset_qrange = wx.Button(self, id, 'Reset', size=(77, 20))580 581 self.reset_qrange.Bind(wx.EVT_BUTTON, self.on_reset_clicked, id= id)547 wx_id = wx.NewId() 548 self.reset_qrange = wx.Button(self, wx_id, 'Reset') 549 550 self.reset_qrange.Bind(wx.EVT_BUTTON, self.on_reset_clicked, id=wx_id) 582 551 self.reset_qrange.SetToolTipString("Reset Q range to the default") 583 552 584 sizer = wx.GridSizer( 2, 4, 2, 6)585 586 self.btEditMask = wx.Button(self, wx.NewId(), 'Editor' , size=(88, 23))553 sizer = wx.GridSizer(5, 5, 2, 6) 554 555 self.btEditMask = wx.Button(self, wx.NewId(), 'Editor') 587 556 self.btEditMask.Bind(wx.EVT_BUTTON, self._onMask, 588 557 id=self.btEditMask.GetId()) … … 594 563 sizer.Add(wx.StaticText(self, -1, ' Max[1/A]')) 595 564 sizer.Add(self.EditMask_title) 565 sizer.Add((-1,5)) 566 596 567 sizer.Add(self.reset_qrange) 597 568 sizer.Add(self.qmin) 598 569 sizer.Add(self.qmax) 599 #sizer.Add(self.theory_npts_tcrtl)600 570 sizer.Add(self.btEditMask) 571 sizer.Add((-1,5)) 572 573 sizer.AddMany(5*[(-1,5)]) 574 575 sizer.Add(box_description_1, 0, 0) 576 sizer.Add(box_description_2, 0, 0) 577 sizer.Add(self.points_sizer, 0, 0) 578 sizer.Add(self.draw_button, 0, 0) 579 sizer.Add((-1,5)) 580 581 sizer.Add(self.tcChi, 0, 0) 582 sizer.Add(self.Npts_fit, 0, 0) 583 sizer.Add(self.Npts_total, 0, 0) 584 sizer.Add(self.btFit, 0, 0) 585 sizer.Add(self.btFitHelp, 0, 0) 586 601 587 boxsizer_range.Add(sizer_chi2) 602 boxsizer_range.Add((10, 10))603 588 boxsizer_range.Add(sizer) 604 605 boxsizer_range.Add((10, 15))606 boxsizer_range.Add(sizer_fit)607 589 if is_2Ddata: 608 590 self.btEditMask.Enable() -
src/sas/perspectives/fitting/fitting.py
r098f3d2 r225aca8 61 61 Fitting plugin is used to perform fit 62 62 """ 63 def __init__(self , standalone=False):64 PluginBase.__init__(self, name="Fitting" , standalone=standalone)63 def __init__(self): 64 PluginBase.__init__(self, name="Fitting") 65 65 66 66 #list of panel to send to guiframe … … 221 221 Get the python editor panel 222 222 """ 223 id = event.GetId()224 label = self.edit_menu.GetLabel( id)223 event_id = event.GetId() 224 label = self.edit_menu.GetLabel(event_id) 225 225 from sas.perspectives.calculator.pyconsole import PyConsole 226 226 filename = os.path.join(models.find_plugins_dir(), label) … … 236 236 Delete custom model file 237 237 """ 238 id = event.GetId()239 label = self.delete_menu.GetLabel( id)238 event_id = event.GetId() 239 label = self.delete_menu.GetLabel(event_id) 240 240 toks = os.path.splitext(label) 241 241 path = os.path.join(models.find_plugins_dir(), toks[0]) … … 256 256 # info='warning')) 257 257 else: 258 self.delete_menu.Delete( id)258 self.delete_menu.Delete(event_id) 259 259 for item in self.edit_menu.GetMenuItems(): 260 260 if item.GetLabel() == label: … … 272 272 Edit summodel template and make one 273 273 """ 274 id = event.GetId()274 event_id = event.GetId() 275 275 model_manager = models.ModelManager() 276 276 model_list = model_manager.get_model_name_list() … … 290 290 self.new_model_frame.Show(True) 291 291 else: 292 id = event.GetId()292 event_id = event.GetId() 293 293 dir_path = models.find_plugins_dir() 294 294 title = "New Custom Model Function" … … 332 332 Set list of the edit model menu labels 333 333 """ 334 id = wx.NewId()334 wx_id = wx.NewId() 335 335 #new_model_menu = wx.Menu() 336 self.edit_model_menu.Append( id, 'New',336 self.edit_model_menu.Append(wx_id, 'New', 337 337 'Add a new model function') 338 wx.EVT_MENU(owner, id, self.make_new_model)339 id = wx.NewId()340 self.edit_model_menu.Append( id, 'Sum|Multi(p1, p2)',338 wx.EVT_MENU(owner, wx_id, self.make_new_model) 339 wx_id = wx.NewId() 340 self.edit_model_menu.Append(wx_id, 'Sum|Multi(p1, p2)', 341 341 'Sum of two model functions') 342 wx.EVT_MENU(owner, id, self.make_sum_model)342 wx.EVT_MENU(owner, wx_id, self.make_sum_model) 343 343 e_id = wx.NewId() 344 344 self.edit_menu = wx.Menu() … … 376 376 has_file = True 377 377 if not has_file: 378 id = wx.NewId()379 submenu.Append( id, name)380 wx.EVT_MENU(owner, id, menu)378 wx_id = wx.NewId() 379 submenu.Append(wx_id, name) 380 wx.EVT_MENU(owner, wx_id, menu) 381 381 has_file = False 382 382 … … 397 397 Create a page to access simultaneous fit option 398 398 """ 399 id = event.GetId()399 event_id = event.GetId() 400 400 caption = "Const & Simul Fit" 401 401 page = self.sim_page 402 if id == self.id_batchfit:402 if event_id == self.id_batchfit: 403 403 caption = "Combined Batch" 404 404 page = self.batch_page … … 719 719 for uid, value in self.page_finder.iteritems(): 720 720 if uid != sim_page_id and uid != self.batch_page.uid: 721 list = value.get_model()722 model = list[0]721 model_list = value.get_model() 722 model = model_list[0] 723 723 if model.name == modelname: 724 724 value.set_model_param(names, values) … … 1568 1568 """ 1569 1569 if event.panel is not None: 1570 new_panel = event.panel1571 1570 self.slicer_panels.append(event.panel) 1572 1571 # Set group ID if available … … 1652 1651 #find if this theory was already plotted and replace that plot given 1653 1652 #the same id 1654 theory_data =self.page_finder[page_id].get_theory_data(fid=data.id)1653 self.page_finder[page_id].get_theory_data(fid=data.id) 1655 1654 1656 1655 if data.is_data: -
src/sas/perspectives/invariant/invariant.py
r824e488 rf21d496 33 33 """ 34 34 35 def __init__(self , standalone=False):36 PluginBase.__init__(self, name="Invariant" , standalone=standalone)35 def __init__(self): 36 PluginBase.__init__(self, name="Invariant") 37 37 38 38 # dictionary containing data name and error on dy of that data -
src/sas/perspectives/pr/inversion_panel.py
r3db44fb rf21d496 35 35 oscillation_max = 1.5 36 36 37 def __init__(self, parent, id=-1, plots=None, standalone=False,**kwargs):37 def __init__(self, parent, id=-1, plots=None, **kwargs): 38 38 """ 39 39 """ … … 83 83 ## Data manager 84 84 self._manager = None 85 ## Standalone flage86 self.standalone = standalone87 85 ## Default file location for save 88 86 self._default_save_location = os.getcwd() -
src/sas/perspectives/pr/pr.py
rc1c14ba rf21d496 54 54 DEFAULT_DMAX = 140.0 55 55 56 def __init__(self , standalone=True):57 PluginBase.__init__(self, name="Pr Inversion" , standalone=standalone)56 def __init__(self): 57 PluginBase.__init__(self, name="Pr Inversion") 58 58 ## Simulation window manager 59 59 self.simview = None … … 94 94 ## Number of P(r) points to display on the output plot 95 95 self._pr_npts = 51 96 ## Flag to let the plug-in know that it is running standalone97 self.standalone = standalone98 96 self._normalize_output = False 99 97 self._scale_output_unity = False … … 623 621 return [] 624 622 elif item.id == graph.selected_plottable: 625 if not self.standalone andissubclass(item.__class__, Data1D):623 if issubclass(item.__class__, Data1D): 626 624 return [["Compute P(r)", 627 625 "Compute P(r) from distribution", … … 1238 1236 self.frame = MDIFrame(self.parent, None, 'None', (100, 200)) 1239 1237 self.control_panel = InversionControl(self.frame, -1, 1240 style=wx.RAISED_BORDER, 1241 standalone=self.standalone) 1238 style=wx.RAISED_BORDER) 1242 1239 self.frame.set_panel(self.control_panel) 1243 1240 self._frame_set_helper() … … 1317 1314 [Somehow openGL needs this call] 1318 1315 """ 1319 if self.standalone: 1320 self.parent.set_perspective(self.perspective) 1316 pass -
src/sas/guiframe/config.py
r5846bb5 r9989a6a 10 10 __build__ = '1' 11 11 __download_page__ = 'https://github.com/SasView/sasview/releases' 12 __update_URL__ = ['raw.githubusercontent.com', 13 '/SasView/sasview/master/sasview.latestversion'] 12 __update_URL__ = 'http://www.sasview.org/latestversion.json' 14 13 15 14 -
src/sas/guiframe/data_processor.py
re54dbc3e r44d20af 1 1 """ 2 Implement grid used to store data 2 Implement grid used to store results of a batch fit. 3 4 This is in Guiframe rather than fitting which is probably where it should be. 5 Actually could be a generic framework implemented in fit gui module. At this 6 point however there this grid behaves independently of the fitting panel and 7 only knows about information sent to it but not about the fits or fit panel and 8 thus cannot feed back to the fitting panel. This could change in the future. 9 10 The organization of the classes goes as: 11 12 .. image:: ../../user/guiframe/BatchGridClassLayout.png 13 :align: center 14 3 15 """ 4 16 import wx … … 26 38 """ 27 39 Object describing a cell in the grid. 28 29 40 """ 30 41 def __init__(self): 42 """ 43 Initialize attributes of class (label, value, col, row, object) 44 """ 31 45 self.label = "" 32 46 self.value = None … … 39 53 """ 40 54 Return a dictionary of column label and index or row selected 55 41 56 :param sentence: String to parse 42 57 :param list: list of columns label 58 :returns: col_dict 43 59 """ 60 44 61 p2 = re.compile(r'\d+') 45 62 p = re.compile(r'[\+\-\*\%\/]') … … 81 98 82 99 class SPanel(ScrolledPanel): 100 """ 101 ensure proper scrolling of GridPanel 102 103 Adds a SetupScrolling call to the normal ScrolledPanel init. 104 GridPanel then subclasses this class 105 106 """ 83 107 def __init__(self, parent, *args, **kwds): 108 """ 109 initialize ScrolledPanel then force a call to SetupScrolling 110 111 """ 84 112 ScrolledPanel.__init__(self, parent, *args, **kwds) 85 113 self.SetupScrolling() … … 87 115 88 116 class GridCellEditor(sheet.CCellEditor): 89 """ Custom cell editor """ 117 """ 118 Custom cell editor 119 120 This subclasses the sheet.CCellEditor (itself a subclass of 121 grid.GridCellEditor) in order to override two of its methods: 122 PaintBackrgound and EndEdit. 123 124 This is necessary as the sheet module is broken in wx 3.0.2 and 125 improperly subclasses grid.GridCellEditor 126 """ 90 127 def __init__(self, grid): 128 """ 129 Override of CCellEditor init. Runs the grid.GridCellEditor init code 130 """ 91 131 super(GridCellEditor, self).__init__(grid) 92 132 133 def PaintBackground(self, dc, rect, attr): 134 """ 135 Overrides wx.sheet.CCellEditor.PaintBackground which incorrectly calls 136 the base class method. 137 138 In wx3.0 all paint objects must explicitly 139 have a wxPaintDC (Device Context) object. Thus the paint event which 140 generates a call to this method provides such a DC object and the 141 base class in grid expects to receive that object. sheet was apparently 142 not updated to reflect this and hence fails. This could thus 143 become obsolete in a future bug fix of wxPython. 144 145 Apart from adding a dc variable in the list of arguments in the def 146 and in the call to the base class the rest of this method is copied 147 as is from sheet.CCellEditor.PaintBackground 148 149 **From original GridCellEditor docs:** 150 151 Draws the part of the cell not occupied by the edit control. The 152 base class version just fills it with background colour from the 153 attribute. 154 155 NOTE: There is no need to override this if you don't need 156 to do something out of the ordinary. 157 158 :param dc: the wxDC object for the paint 159 """ 160 # Call base class method. 161 DC = dc 162 super(sheet.CCellEditor,self).PaintBackground(DC, rect, attr) 163 93 164 def EndEdit(self, row, col, grid, previous): 94 """ 95 Commit editing the current cell. Returns True if the value has changed. 96 @param previous: previous value in the cell 165 """ 166 Commit editing the current cell. Returns True if the value has changed. 167 168 :param previous: previous value in the cell 97 169 """ 98 170 changed = False # Assume value not changed … … 108 180 class GridPage(sheet.CSheet): 109 181 """ 182 Class that receives the results of a batch fit. 183 184 GridPage displays the received results in a wx.grid using sheet. This is 185 then used by GridPanel and GridFrame to present the full GUI. 110 186 """ 111 187 def __init__(self, parent, panel=None): 112 188 """ 189 Initialize 190 191 Initialize all the attributes of GridPage, and the events. include 192 the init stuff from sheet.CSheet as well. 113 193 """ 114 194 #sheet.CSheet.__init__(self, parent) 115 195 116 196 # The following is the __init__ from CSheet. ########################## 117 197 # We re-write it here because the class is broken in wx 3.0, … … 139 219 140 220 # Sink events 221 self.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self.OnRangeSelect) 222 self.Bind(wx.grid.EVT_GRID_ROW_SIZE, self.OnRowSize) 223 self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnColSize) 224 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnGridSelectCell) 225 # NOTE: the following bind to standard sheet methods that are 226 # overriden in this subclassn - actually we have currently 227 # disabled the on_context_menu that would override the OnRightClick 228 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnCellChange) 141 229 self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnLeftClick) 142 230 self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightClick) 143 231 #self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnLeftDoubleClick) 144 self.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self.OnRangeSelect)145 self.Bind(wx.grid.EVT_GRID_ROW_SIZE, self.OnRowSize)146 self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnColSize)147 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnCellChange)148 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnGridSelectCell)149 232 # This ends the __init__ section for CSheet. ########################## 233 234 235 236 # The following events must be bound even if CSheet is working 237 # properly and does not need the above re-implementation of the 238 # CSheet init method. Basically these override any intrinsic binding 239 self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.on_right_click) 240 self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click) 150 241 151 242 self.AdjustScrollbars() … … 187 278 if self.GetNumberCols() > 0: 188 279 self.default_col_width = self.GetColSize(0) 280 # We have moved these to the top of the init section with the 281 # rest of the grid event bindings from the sheet init when 282 # appropriate 189 283 #self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click) 190 284 #self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.on_right_click) … … 194 288 195 289 def OnLeftClick(self, event): 290 """ 291 Overrides sheet.CSheet.OnLefClick. 292 293 Processes when a cell is selected by left clicking on that cell. First 294 process the base Sheet method then the current class specific method 295 """ 196 296 sheet.CSheet.OnLeftClick(self, event) 197 297 self.on_selected_cell(event) 198 199 def on_edit_cell(self, event): 200 """ 298 299 300 def OnCellChange(self, event): 301 """ 302 Overrides sheet.CSheet.OnCellChange. 303 304 Processes when a cell has been edited by a cell editor. Checks for the 305 edited row being outside the max row to use attribute and if so updates 306 the last row. Then calls the base handler using skip. 201 307 """ 202 308 row, _ = event.GetRow(), event.GetCol() … … 209 315 def on_selected_cell(self, event): 210 316 """ 211 Handler catching cell selection 212 """ 317 Handler catching cell selection. 318 319 Called after calling base 'on left click' method. 320 """ 321 213 322 flag = event.CmdDown() or event.ControlDown() 214 323 flag_shift = event.ShiftDown() … … 280 389 def on_left_click(self, event): 281 390 """ 282 Catch the left click on label mouse event 283 """ 391 Is triggered when the left mouse button is clicked while the mouse 392 is hovering over the column 'label.' 393 394 This processes the information on the selected column: the column name 395 (in row 0 of column) and the range of cells with a valid value to be 396 used by the GridPanel set_axis methods. 397 """ 398 284 399 flag = event.CmdDown() or event.ControlDown() 285 400 … … 324 439 def on_right_click(self, event): 325 440 """ 326 Catch the right click mouse 327 """ 441 Is triggered when the right mouse button is clicked while the mouse 442 is hovering over the column 'label.' 443 444 This brings up a context menu that allows the deletion of the column, 445 or the insertion of a new column either to the right or left of the 446 current column. If inserting a new column can insert a blank column or 447 choose a number of hidden columns. By default all the error parameters 448 are in hidden columns so as to save space on the grid. Also any other 449 intrinsic variables stored with the data such as Temperature, pressure, 450 time etc can be used to populate this menu. 451 """ 452 328 453 col = event.GetCol() 329 454 row = event.GetRow() … … 360 485 def insert_col_menu(self, menu, label, window): 361 486 """ 362 """ 487 method called to populate the 'insert column before current column' 488 submenu. 489 """ 490 363 491 if self.data is None: 364 492 return … … 380 508 def insert_after_col_menu(self, menu, label, window): 381 509 """ 382 """ 510 Method called to populate the 'insert column after current column' 511 submenu 512 """ 513 383 514 if self.data is None: 384 515 return … … 401 532 def on_remove_column(self, event=None): 402 533 """ 403 """ 534 Called when user chooses remove from the column right click menu 535 Checks the columnn exists then calls the remove_column method 536 """ 537 404 538 if self.selected_cols is not None or len(self.selected_cols) > 0: 405 539 col = self.selected_cols[0] … … 408 542 def remove_column(self, col, numCols=1): 409 543 """ 410 Remove column to the current grid 411 """ 544 Remove the col column from the current grid 545 """ 546 412 547 # add data to the grid 413 548 row = 0 … … 429 564 def on_insert_column(self, event): 430 565 """ 431 """ 566 Called when user chooses insert 'column before' submenu 567 of the column context menu obtained when right clicking on a given 568 column header. 569 570 Sets up to insert column into the current grid before the current 571 highlighted column location and sets up what to populate that column 572 with. Then calls insert_column method to actually do the insertion. 573 """ 574 432 575 if self.selected_cols is not None or len(self.selected_cols) > 0: 433 576 col = self.selected_cols[0] … … 442 585 def on_insert_after_column(self, event): 443 586 """ 444 Insert the given column after the highlighted column 445 """ 587 Called when user chooses insert 'column after' submenu 588 of the column context menu obtained when right clicking on a given 589 column header. 590 591 Sets up to insert column into the current grid after the current 592 highlighted column location and sets up what to populate that column 593 with. Then calls insert_column method to actually do the insertion. 594 """ 595 446 596 if self.selected_cols is not None or len(self.selected_cols) > 0: 447 597 col = self.selected_cols[0] + 1 … … 455 605 def insert_column(self, col, col_name): 456 606 """ 457 """ 607 Insert column at position col with data[col_name] into the current 608 grid. 609 """ 610 458 611 row = 0 459 612 self.InsertCols(pos=col, numCols=1, updateLabels=True) … … 477 630 def on_set_x_axis(self, event): 478 631 """ 479 """ 632 Just calls the panel version of the method 633 """ 634 480 635 self.panel.set_xaxis(x=self.axis_value, label=self.axis_label) 481 636 482 637 def on_set_y_axis(self, event): 483 638 """ 484 """ 639 Just calls the panel version of the method 640 """ 641 485 642 self.panel.set_yaxis(y=self.axis_value, label=self.axis_label) 486 643 … … 488 645 """ 489 646 Add data to the grid 647 490 648 :param data_inputs: data to use from the context menu of the grid 491 :param data_ouputs: default columns deplayed 492 """ 649 :param data_ouputs: default columns displayed 650 """ 651 493 652 self.file_name = file_name 494 653 self.details = details … … 527 686 Set the values in grids 528 687 """ 688 529 689 # add data to the grid 530 690 row = 0 … … 562 722 Return value contained in the grid 563 723 """ 724 564 725 grid_view = {} 565 726 for col in xrange(self.GetNumberCols()): … … 584 745 def onContextMenu(self, event): 585 746 """ 586 Default context menu 587 """ 747 Method to handle cell right click context menu. 748 749 THIS METHOD IS NOT CURRENTLY USED. It is designed to provide a 750 cell pop up context by right clicking on a cell and gives the 751 option to cut, paste, and clear. This will probably be removed in 752 future versions and is being superceded by more traditional cut and 753 paste options. 754 """ 755 588 756 wx_id = wx.NewId() 589 757 c_menu = wx.Menu() … … 620 788 def on_copy(self, event): 621 789 """ 622 On copy event from the contextmenu 623 """ 790 Called when copy is chosen from cell right click context menu 791 792 THIS METHOD IS NOT CURRENTLY USED. it is part of right click cell 793 context menu which is being removed. This will probably be removed in 794 future versions and is being superceded by more traditional cut and 795 paste options 796 """ 797 624 798 self.Copy() 625 799 626 800 def on_paste(self, event): 627 801 """ 628 On paste event from the contextmenu 629 """ 802 Called when paste is chosen from cell right click context menu 803 804 THIS METHOD IS NOT CURRENTLY USED. it is part of right click cell 805 context menu which is being removed. This will probably be removed in 806 future versions and is being superceded by more traditional cut and 807 paste options 808 """ 809 630 810 if self.data == None: 631 811 self.data = {} … … 636 816 def on_clear(self, event): 637 817 """ 638 Clear the cells selected 639 """ 818 Called when clear cell is chosen from cell right click context menu 819 820 THIS METHOD IS NOT CURRENTLY USED. it is part of right click cell 821 context menu which is being removed. This will probably be removed in 822 future versions and is being superceded by more traditional cut and 823 paste options 824 """ 825 640 826 self.Clear() 641 827 … … 646 832 ## Title to appear on top of the window 647 833 """ 834 648 835 window_caption = "Notebook " 649 836 … … 682 869 def enable_close_button(self): 683 870 """ 684 display the close button on tab for more than 1 tabs else remove the 685 close button 686 """ 871 display the close button on the tab if more than 1 tab exits. 872 Otherwise remove the close button 873 """ 874 687 875 if self.GetPageCount() <= 1: 688 876 style = self.GetWindowStyleFlag() … … 700 888 def on_edit_axis(self): 701 889 """ 702 Return the select cell of a given selected column. Check that all cells 703 are from the same column 704 """ 890 Return the select cell range from a given selected column. Checks that 891 all cells are from the same column 892 """ 893 705 894 pos = self.GetSelection() 706 895 grid = self.GetPage(pos) … … 732 921 Add highlight rows 733 922 """ 923 734 924 pos = self.GetSelection() 735 925 grid = self.GetPage(pos) … … 759 949 def get_column_labels(self): 760 950 """ 761 return dictionary of columns labels of the current page 762 """ 951 return dictionary of columns labels on the current page 952 """ 953 763 954 pos = self.GetSelection() 764 955 grid = self.GetPage(pos) … … 773 964 """ 774 965 Receive a list of cells and create a string presenting the selected 775 cells. 966 cells that can be used as data for one axis of a plot. 967 776 968 :param cell_list: list of tuple 777 778 969 """ 779 970 pos = self.GetSelection() … … 853 1044 close the page 854 1045 """ 1046 855 1047 if self.GetPageCount() == 1: 856 1048 event.Veto() … … 858 1050 859 1051 def set_data(self, data_inputs, data_outputs, details="", file_name=None): 1052 """ 1053 """ 860 1054 if data_outputs is None or data_outputs == {}: 861 1055 return … … 880 1074 def get_odered_results(self, inputs, outputs=None): 881 1075 """ 882 Get ordered the results 883 """ 1076 Order a list of 'inputs.' Used to sort rows and columns to present 1077 in batch results grid. 1078 """ 1079 884 1080 # Let's re-order the data from the keys in 'Data' name. 885 1081 if outputs == None: … … 914 1110 Append a new column to the grid 915 1111 """ 1112 1113 # I Believe this is no longer used now that we have removed the 1114 # edit menu from the menubar - PDB July 12, 2015 916 1115 pos = self.GetSelection() 917 1116 grid = self.GetPage(pos) … … 922 1121 Remove the selected column from the grid 923 1122 """ 1123 # I Believe this is no longer used now that we have removed the 1124 # edit menu from the menubar - PDB July 12, 2015 924 1125 pos = self.GetSelection() 925 1126 grid = self.GetPage(pos) … … 927 1128 928 1129 class GridPanel(SPanel): 1130 """ 1131 A ScrolledPanel class that contains the grid sheet as well as a number of 1132 widgets to create interesting plots and buttons for help etc. 1133 """ 1134 929 1135 def __init__(self, parent, data_inputs=None, 930 1136 data_outputs=None, *args, **kwds): 1137 """ 1138 Initialize the GridPanel 1139 """ 1140 931 1141 SPanel.__init__(self, parent, *args, **kwds) 932 1142 … … 990 1200 def get_plot_axis(self, col, list): 991 1201 """ 992 993 1202 """ 994 1203 axis = [] … … 1015 1224 def on_view(self, event): 1016 1225 """ 1017 Get object represented buy the given cell and plot them. 1018 """ 1226 Get object represented by the given cells and plot them. Basically 1227 plot the colum in y vs the column in x. 1228 """ 1229 1019 1230 pos = self.notebook.GetSelection() 1020 1231 grid = self.notebook.GetPage(pos) … … 1096 1307 Evaluate the contains of textcrtl and plot result 1097 1308 """ 1309 1098 1310 pos = self.notebook.GetSelection() 1099 1311 grid = self.notebook.GetPage(pos) … … 1203 1415 running "file:///...." 1204 1416 1205 :param evt: Triggers on clicking the help button 1206 """ 1417 :param evt: Triggers on clicking the help button 1418 """ 1419 1207 1420 #import documentation window here to avoid circular imports 1208 1421 #if put at top of file with rest of imports. … … 1218 1431 Get sentence from dict 1219 1432 """ 1433 1220 1434 for tok, (col_name, list) in dict.iteritems(): 1221 1435 col = column_names[col_name] … … 1230 1444 def layout_grid(self): 1231 1445 """ 1232 Draw the area related to the grid 1233 """ 1446 Draw the area related to the grid by adding it as the first element 1447 in the panel's grid_sizer 1448 """ 1449 1234 1450 self.notebook = Notebook(parent=self) 1235 1451 self.notebook.set_data(self._data_inputs, self._data_outputs) … … 1238 1454 def layout_plotting_area(self): 1239 1455 """ 1240 Draw area containing options to plot 1241 """ 1456 Add the area containing all the plot options, buttons etc to a plotting 1457 area sizer to later be added to the top level grid_sizer 1458 """ 1459 1242 1460 view_description = wx.StaticBox(self, -1, 'Plot Fits/Residuals') 1243 1461 note = "To plot the fits (or residuals), click the 'View Fits' button" … … 1281 1499 (self.plot_button, 0, 1282 1500 wx.LEFT | wx.TOP | wx.BOTTOM, 12), 1283 (self.help_button,0, 1501 (self.help_button,0, 1284 1502 wx.LEFT | wx.TOP | wx.BOTTOM, 12)]) 1285 1503 … … 1316 1534 Get the selected column on the visible grid and set values for axis 1317 1535 """ 1536 1318 1537 try: 1319 1538 cell_list = self.notebook.on_edit_axis() … … 1335 1554 Receive a list of cells and create a string presenting the selected 1336 1555 cells. 1556 1337 1557 :param cell_list: list of tuple 1338 1339 """ 1558 """ 1559 1340 1560 if self.notebook is not None: 1341 1561 return self.notebook.create_axis_label(cell_list) … … 1345 1565 get controls to modify 1346 1566 """ 1567 1347 1568 if label != None: 1348 1569 tcrtl_label.SetValue(str(label)) … … 1353 1574 """ 1354 1575 """ 1576 # I Believe this is no longer used now that we have removed the 1577 # edit menu from the menubar - PDB July 12, 2015 1355 1578 if self.notebook is not None: 1356 1579 self.notebook.add_column() … … 1359 1582 """ 1360 1583 """ 1584 # I Believe this is no longer used now that we have removed the 1585 # edit menu from the menubar - PDB July 12, 2015 1361 1586 if self.notebook is not None: 1362 1587 self.notebook.on_remove_column() … … 1364 1589 1365 1590 class GridFrame(wx.Frame): 1591 """ 1592 The main wx.Frame for the batch results grid 1593 """ 1594 1366 1595 def __init__(self, parent=None, data_inputs=None, data_outputs=None, id=-1, 1367 title="Grid Window", size=(800, 500)): 1596 title="Batch Fitting Results Panel", size=(800, 500)): 1597 """ 1598 Initialize the Frame 1599 """ 1600 1368 1601 wx.Frame.__init__(self, parent=parent, id=id, title=title, size=size) 1369 1602 self.parent = parent … … 1389 1622 wx.EVT_MENU(self, self.save_menu.GetId(), self.on_save_page) 1390 1623 1391 # To add the edit menu, call add_edit_menu() here. 1392 self.edit = None 1624 # We need to grab a WxMenu handle here, otherwise the next one to grab 1625 # the handle will be treated as the Edit Menu handle when checking in 1626 # on_menu_open event handler and thus raise an exception when it hits an 1627 # unitialized object. Alternative is to comment out that whole section 1628 # in on_menu_open, but that would make it more difficult to undo the 1629 # hidding of the menu. PDB July 12, 2015. 1630 # 1631 # To enable the Edit menubar comment out next line and uncomment the 1632 # following line. 1633 self.edit = wx.Menu() 1634 #self.add_edit_menu() 1635 1393 1636 self.Bind(wx.EVT_MENU_OPEN, self.on_menu_open) 1394 1395 1637 self.Bind(wx.EVT_CLOSE, self.on_close) 1396 1638 1397 1639 def add_edit_menu(self, menubar): 1640 """ 1641 populates the edit menu on the menubar. Not activated as of SasView 1642 3.1.0 1643 """ 1398 1644 self.edit = wx.Menu() 1399 1645 … … 1429 1675 def on_copy(self, event): 1430 1676 """ 1431 On Copy 1432 """ 1677 On Copy from the Edit menu item on the menubar 1678 """ 1679 # I Believe this is no longer used now that we have removed the 1680 # edit menu from the menubar - PDB July 12, 2015 1433 1681 if event != None: 1434 1682 event.Skip() … … 1439 1687 def on_paste(self, event): 1440 1688 """ 1441 On Paste 1442 """ 1689 On Paste from the Edit menu item on the menubar 1690 """ 1691 # I Believe this is no longer used now that we have removed the 1692 # edit menu from the menubar - PDB July 12, 2015 1443 1693 if event != None: 1444 1694 event.Skip() … … 1449 1699 def on_clear(self, event): 1450 1700 """ 1451 On Clear 1452 """ 1701 On Clear from the Edit menu item on the menubar 1702 """ 1703 # I Believe this is no longer used now that we have removed the 1704 # edit menu from the menubar - PDB July 12, 2015 1453 1705 pos = self.panel.notebook.GetSelection() 1454 1706 grid = self.panel.notebook.GetPage(pos) … … 1466 1718 def on_remove_column(self, event): 1467 1719 """ 1468 On remove column 1469 """ 1720 On remove column from the Edit menu Item on the menubar 1721 """ 1722 # I Believe this is no longer used now that we have removed the 1723 # edit menu from the menubar - PDB July 12, 2015 1470 1724 pos = self.panel.notebook.GetSelection() 1471 1725 grid = self.panel.notebook.GetPage(pos) … … 1535 1789 def on_save_page(self, event): 1536 1790 """ 1537 """ 1791 Saves data in grid to a csv file. 1792 1793 At this time only the columns displayed get saved. Thus any error 1794 bars not inserted before saving will not be saved in the file 1795 """ 1796 1538 1797 if self.parent is not None: 1539 1798 pos = self.panel.notebook.GetSelection() … … 1566 1825 def on_open(self, event): 1567 1826 """ 1568 Open file containg batch result 1569 """ 1827 Open file containing batch result 1828 """ 1829 1570 1830 if self.parent is not None: 1571 1831 self.parent.on_read_batch_tofile(self) … … 1575 1835 open excel and display batch result in Excel 1576 1836 """ 1837 1577 1838 if self.parent is not None: 1578 1839 pos = self.panel.notebook.GetSelection() … … 1625 1886 details="", *args, **kwds): 1626 1887 """ 1888 Initialize dialog 1889 1627 1890 :param parent: Window instantiating this dialog 1628 :param result: result to display in a grid or export to an external 1891 :param result: result to display in a grid or export to an external\ 1629 1892 application. 1630 1893 """ 1894 1631 1895 #kwds['style'] = wx.CAPTION|wx.SYSTEM_MENU 1632 1896 wx.Frame.__init__(self, parent, *args, **kwds) … … 1651 1915 Draw the content of the current dialog window 1652 1916 """ 1917 1653 1918 vbox = wx.BoxSizer(wx.VERTICAL) 1654 1919 box_description = wx.StaticBox(self.panel, -1, str("Batch Outputs")) … … 1704 1969 Get the user selection and display output to the selected application 1705 1970 """ 1971 1706 1972 if self.flag == 1: 1707 1973 self.parent.open_with_localapp(data_inputs=self.data_inputs, … … 1715 1981 close the Window 1716 1982 """ 1983 1717 1984 self.Close() 1718 1985 … … 1721 1988 Receive event and display data into third party application 1722 1989 or save data to file. 1723 1724 1990 """ 1725 1991 if self.save_to_file.GetValue(): -
src/sas/guiframe/documentation_window.py
r7a508b6 rfb3f9af 43 43 (self, parent, dummy_id, path, url_instruction, title, size=(850, 540)) 44 44 45 :param path: path to html file beginning AFTER /doc/ and ending in the 46 file.html 47 :param url_instructions: anchor string or other query e.g. '#MyAnchor 48 :param title -text to place in the title bar of the help panel45 :param path: path to html file beginning AFTER /doc/ and ending in the\ 46 file.html. 47 :param url_instructions: anchor string or other query e.g. '#MyAnchor' 48 :param title: text to place in the title bar of the help panel 49 49 """ 50 50 def __init__(self, parent, dummy_id, path, url_instruction, title, size=(850, 540)): -
src/sas/guiframe/local_perspectives/plotting/Plotter1D.py
rb99a4552 r098f3d2 564 564 self._slicerpop.Append(wx_id, '&Print Image', 'Print image ') 565 565 wx.EVT_MENU(self, wx_id, self.onPrint) 566 wx_id = wx.NewId()567 self._slicerpop.Append(wx_id, '&Print Preview', 'Print preview')568 wx.EVT_MENU(self, wx_id, self.onPrinterPreview)569 566 570 567 wx_id = wx.NewId() -
src/sas/guiframe/local_perspectives/plotting/Plotter2D.py
rc039589 r098f3d2 300 300 301 301 wx_id = wx.NewId() 302 slicerpop.Append(wx_id, '&Print Preview', 'Print preview')303 wx.EVT_MENU(self, wx_id, self.onPrinterPreview)304 305 wx_id = wx.NewId()306 302 slicerpop.Append(wx_id, '&Copy to Clipboard', 'Copy to the clipboard') 307 303 wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) -
src/sas/guiframe/local_perspectives/plotting/SimplePlot.py
rb40ad40 r098f3d2 58 58 slicerpop.Append(wx_id, '&Print Image', 'Print image') 59 59 wx.EVT_MENU(self, wx_id, self.onPrint) 60 61 wx_id = wx.NewId()62 slicerpop.Append(wx_id, '&Print Preview', 'Print preview')63 wx.EVT_MENU(self, wx_id, self.onPrinterPreview)64 60 65 61 wx_id = wx.NewId() … … 234 230 wx.EVT_MENU(self, id, self.on_print_image) 235 231 236 id = wx.NewId()237 item = wx.MenuItem(menu, id, "&Print Preview")238 item.SetBitmap(preview_bmp)239 menu.AppendItem(item)240 wx.EVT_MENU(self, id, self.on_print_preview)241 242 232 menu.AppendSeparator() 243 233 id = wx.NewId() -
src/sas/guiframe/report_dialog.py
re8bb5b6 r098f3d2 66 66 hbox.Add(button_close) 67 67 button_close.SetFocus() 68 69 button_preview = wx.Button(self, wx.NewId(), "Preview")70 button_preview.SetToolTipString("Print preview this report.")71 button_preview.Bind(wx.EVT_BUTTON, self.onPreview,72 id=button_preview.GetId())73 hbox.Add(button_preview)74 68 75 69 button_print = wx.Button(self, wx.NewId(), "Print") -
src/sas/models/CoreMultiShellModel.py
rac7be54 re0c16ce 53 53 ## parameters with orientation: can be removed since there is no orientational params 54 54 self._set_orientation_params() 55 56 55 57 56 def _clone(self, obj): 58 57 """ … … 67 66 68 67 return obj 69 70 68 71 69 def _set_dispersion(self): 72 70 """ 73 71 model dispersions 74 72 Polydispersion should not be applied to s_model 75 """ 76 ##set dispersion from model 73 """ 74 ##set dispersion from model 77 75 for name , value in self.model.dispersion.iteritems(): 78 76 nshell = 0 … … 82 80 if name.split('_')[-1] == 'shell%s' % str(nshell): 83 81 self.dispersion[name] = value 84 else: 82 else: 85 83 continue 86 84 else: 87 85 self.dispersion[name] = value 88 86 89 87 def _set_orientation_params(self): 90 88 """ 91 89 model orientation and magnetic parameters, same params for this model 92 """ 90 """ 93 91 ##set dispersion from model 94 92 for param in self.model.orientation_params: … … 104 102 self.orientation_params.append(param) 105 103 self.magnetic_params.append(param) 106 continue 104 continue 107 105 108 106 def _set_params(self): 109 107 """ 110 108 Concatenate the parameters of the model to create 111 this model parameters 109 this model parameters 112 110 """ 113 111 # rearrange the parameters for the given # of shells … … 128 126 else: 129 127 self.params[name]= value 130 128 131 129 # set constrained values for the original model params 132 self._set_xtra_model_param() 133 130 self._set_xtra_model_param() 131 134 132 def _set_details(self): 135 133 """ 136 134 Concatenate details of the original model to create 137 this model details 135 this model details 138 136 """ 139 137 for name ,detail in self.model.details.iteritems(): 140 138 if name in self.params.iterkeys(): 141 139 self.details[name]= detail 142 143 140 141 144 142 def _set_xtra_model_param(self): 145 143 """ … … 163 161 self.model.setParam(key, 0.0) 164 162 except: pass 165 163 166 164 167 165 def getProfile(self): 168 166 """ 169 Get SLD profile 170 171 : return: (r, beta) where r is a list of radius of the transition points 172 beta is a list of the corresponding SLD values173 : Note: This works only for func_shell num = 2.167 Get SLD profile 168 **Note:** This works only for func_shell num = 2. 169 170 :return: (r, beta) where r is a list of radius of the transition points\ 171 and beta is a list of the corresponding SLD values. 174 172 """ 175 173 r = [] … … 181 179 r.append(self.params['rad_core0']) 182 180 beta.append(self.params['sld_core0']) 183 181 184 182 # for shells 185 183 for n in range(1, self.n_shells+1): 186 184 # Left side of each shells 187 r0 = r[len(r)-1] 185 r0 = r[len(r)-1] 188 186 r.append(r0) 189 187 exec "beta.append(self.params['sld_shell%s'% str(n)])" … … 193 191 r.append(r0) 194 192 exec "beta.append(self.params['sld_shell%s'% str(n)])" 195 193 196 194 # for solvent 197 195 r0 = r[len(r)-1] … … 201 199 r.append(r_solv) 202 200 beta.append(self.params['sld_solv']) 203 201 204 202 return r, beta 205 203 206 204 def setParam(self, name, value): 207 """ 205 """ 208 206 Set the value of a model parameter 209 210 : 211 : 207 208 :param name: name of the parameter 209 :param value: value of the parameter 212 210 """ 213 211 # set param to new model 214 212 self._setParamHelper( name, value) 215 ## setParam to model 213 ## setParam to model 216 214 if name == 'sld_solv': 217 215 # the sld_*** model.params not in params must set to value of sld_solv … … 243 241 self.params[item] = value 244 242 return 245 246 243 #raise ValueError, "Model does not contain parameter %s" % name 247 248 244 245 249 246 def _set_fixed_params(self): 250 247 """ … … 252 249 """ 253 250 for item in self.model.fixed: 254 if item.split('.')[0] in self.params.keys(): 251 if item.split('.')[0] in self.params.keys(): 255 252 self.fixed.append(item) 256 253 257 254 self.fixed.sort() 258 255 259 256 def run(self, x = 0.0): 260 """ 257 """ 261 258 Evaluate the model 262 263 : 264 : 259 260 :param x: input q-value (float or [float, float] as [r, theta]) 261 :return: (DAB value) 265 262 """ 266 263 # set effective radius and scaling factor before run … … 269 266 270 267 def runXY(self, x = 0.0): 271 """ 268 """ 272 269 Evaluate the model 273 274 : 275 : 270 271 :param x: input q-value (float or [float, float] as [qx, qy]) 272 :return: DAB value 276 273 """ 277 274 # set effective radius and scaling factor before run 278 275 279 276 return self.model.runXY(x) 280 277 281 278 ## Now (May27,10) directly uses the model eval function 282 279 ## instead of the for-loop in Base Component. 283 280 def evalDistribution(self, x = []): 284 """ 281 """ 285 282 Evaluate the model in cartesian coordinates 286 287 : 288 : 283 284 :param x: input q[], or [qx[], qy[]] 285 :return: scattering function P(q[]) 289 286 """ 290 287 # set effective radius and scaling factor before run 291 288 return self.model.evalDistribution(x) 292 289 293 290 def calculate_ER(self): 294 """ 291 """ 295 292 Calculate the effective radius for P(q)*S(q) 296 293 297 294 :return: the value of the effective radius 298 299 """ 295 """ 300 296 return self.model.calculate_ER() 301 297 302 298 def calculate_VR(self): 303 """ 299 """ 304 300 Calculate the volf ratio for P(q)*S(q) 305 301 306 302 :return: the value of the volf ratio 307 308 """ 303 """ 309 304 return self.model.calculate_VR() 310 305 311 306 def set_dispersion(self, parameter, dispersion): 312 307 """ 313 308 Set the dispersion object for a model parameter 314 315 : 316 : dispersion: dispersion object of type DispersionModel309 310 :param parameter: name of the parameter [string] 311 :param dispersion: dispersion object of type DispersionModel 317 312 """ 318 313 value = None … … 323 318 return value 324 319 except: 325 raise 320 raise -
src/sas/models/MultiplicationModel.py
rac7be54 rfb3f9af 10 10 which will be calculated from P(Q) via calculate_ER(), 11 11 and 2) 'scale' in P model which is synchronized w/ volfraction in S 12 then P*S is multiplied by a new param , 'scale_factor'.12 then P*S is multiplied by a new parameter, 'scale_factor'. 13 13 The polydispersion is applicable only to P(Q), not to S(Q). 14 Note: P(Q) refers to 'form factor' model while S(Q) does to 'structure factor'. 14 15 .. note:: P(Q) refers to 'form factor' model while S(Q) does to 'structure factor'. 15 16 """ 16 17 def __init__(self, p_model, s_model ): … … 81 82 def _clone(self, obj): 82 83 """ 83 Internal utility function to copy the internal84 data members to afresh copy.84 Internal utility function to copy the internal data members to a 85 fresh copy. 85 86 """ 86 87 obj.params = copy.deepcopy(self.params) … … 96 97 def _set_dispersion(self): 97 98 """ 98 combined the two models dispersions99 Polydispersion should not beapplied to s_model99 combine the two models' dispersions. Polydispersity should not be 100 applied to s_model 100 101 """ 101 102 ##set dispersion only from p_model … … 107 108 Get SLD profile of p_model if exists 108 109 109 : return: (r, beta) where r is a list of radius of the transition points 110 beta is a list of the corresponding SLD values 111 : Note: This works only for func_shell num = 2 (exp function). 110 :return: (r, beta) where r is a list of radius of the transition points\ 111 beta is a list of the corresponding SLD values 112 113 .. note:: This works only for func_shell num = 2 (exp function). 112 114 """ 113 115 try: … … 121 123 def _set_params(self): 122 124 """ 123 124 thismodel parameters125 Concatenate the parameters of the two models to create 126 these model parameters 125 127 """ 126 128 … … 141 143 def _set_details(self): 142 144 """ 143 144 this modeldetails145 Concatenate details of the two models to create 146 this model's details 145 147 """ 146 148 for name, detail in self.p_model.details.iteritems(): … … 154 156 def _set_scale_factor(self): 155 157 """ 156 Set scale=volfraction toP model158 Set scale=volfraction for P model 157 159 """ 158 160 value = self.params['volfraction'] … … 168 170 def _set_effect_radius(self): 169 171 """ 170 172 Set effective radius to S(Q) model 171 173 """ 172 174 if not 'effect_radius' in self.s_model.params.keys(): … … 206 208 def _setParamHelper(self, name, value): 207 209 """ 208 210 Helper function to setparam 209 211 """ 210 212 # Look for dispersion parameters … … 229 231 def _set_fixed_params(self): 230 232 """ 231 fill the self.fixed list with the p_model fixed list233 Fill the self.fixed list with the p_model fixed list 232 234 """ 233 235 for item in self.p_model.fixed: … … 240 242 """ 241 243 Evaluate the model 244 242 245 :param x: input q-value (float or [float, float] as [r, theta]) 243 246 :return: (scattering function value) … … 250 253 251 254 def runXY(self, x = 0.0): 252 """ Evaluate the model 253 @param x: input q-value (float or [float, float] as [qx, qy]) 254 @return: scattering function value 255 """ 256 Evaluate the model 257 258 :param x: input q-value (float or [float, float] as [qx, qy]) 259 :return: scattering function value 255 260 """ 256 261 # set effective radius and scaling factor before run … … 266 271 """ 267 272 Evaluate the model in cartesian coordinates 273 268 274 :param x: input q[], or [qx[], qy[]] 269 275 :return: scattering function P(q[]) … … 279 285 """ 280 286 Set the dispersion object for a model parameter 287 281 288 :param parameter: name of the parameter [string] 282 289 :dispersion: dispersion object of type DispersionModel … … 293 300 def fill_description(self, p_model, s_model): 294 301 """ 295 302 Fill the description for P(Q)*S(Q) 296 303 """ 297 304 description = "" -
src/sas/models/c_extension/c_models/GelFit.cpp
r79492222 r1d115ef 34 34 radius = Parameter(104.0,true); 35 35 radius.set_min(2.0); 36 scale= Parameter(2.0,true);36 FractalExp = Parameter(2.0,true); 37 37 background = Parameter(0.01); 38 38 } … … 43 43 dp[0] = zeta(); 44 44 dp[1] = radius(); 45 dp[2] = scale();45 dp[2] = FractalExp(); 46 46 47 47 if (dp[2] <= 0) -
src/sas/models/c_extension/python_wrapper/WrapperGenerator.py
r13e46abe r1f5f206 560 560 def replaceToken(self, line, key, value): #pylint: disable-msg=R0201 561 561 """ Replace a token in the template file 562 @param line: line of text to inspect563 @param key: token to look for564 @param value: string value to replace the token with565 @return: new string value562 :param line: line of text to inspect 563 :param key: token to look for 564 :param value: string value to replace the token with 565 :return: new string value 566 566 """ 567 _str_value = str(value) 568 _new_value = _str_value.replace('\\','/') 567 569 lenkey = len(key) 568 570 newline = line … … 570 572 while newline.count(key) > 0: 571 573 index = newline.index(key) 572 newline = newline[:index] + value + newline[index + lenkey:]574 newline = newline[:index] + _new_value + newline[index + lenkey:] 573 575 574 576 return newline -
src/sas/models/c_extension/python_wrapper/modelTemplate.txt
rc93122e r1f5f206 17 17 18 18 .. WARNING:: 19 20 19 THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 21 20 DO NOT MODIFY THIS FILE, MODIFY … … 30 29 def create_[PYTHONCLASS](): 31 30 """ 32 31 Create a model instance 33 32 """ 34 33 obj = [PYTHONCLASS]() … … 100 99 """ 101 100 Evaluate the model 101 102 102 :param x: input q, or [q,phi] 103 103 :return: scattering function P(q) … … 108 108 """ 109 109 Evaluate the model in cartesian coordinates 110 110 111 :param x: input q, or [qx, qy] 111 112 :return: scattering function P(q) … … 116 117 """ 117 118 Evaluate the model in cartesian coordinates 119 118 120 :param x: input q[], or [qx[], qy[]] 119 121 :return: scattering function P(q[]) … … 124 126 """ 125 127 Calculate the effective radius for P(q)*S(q) 128 126 129 :return: the value of the effective radius 127 130 """ … … 131 134 """ 132 135 Calculate the volf ratio for P(q)*S(q) 136 133 137 :return: the value of the volf ratio 134 138 """ … … 138 142 """ 139 143 Set the dispersion object for a model parameter 144 140 145 :param parameter: name of the parameter [string] 141 146 :param dispersion: dispersion object of type DispersionModel -
src/sas/models/include/GelFit.h
r79492222 r1d115ef 33 33 Parameter radius; 34 34 35 // [DEFAULT]= scale= 236 Parameter scale;35 // [DEFAULT]=FractalExp= 2 36 Parameter FractalExp; 37 37 38 38 // [DEFAULT]=background= 0.01 -
src/sas/models/include/dabmodel.h
r79492222 rf008ee2 17 17 // [PYTHONCLASS] = DABModel 18 18 // [DISP_PARAMS] = length, scale, background 19 // [DESCRIPTION] = <text>Provide F(x) = scale/( 1 + (x*L)^2 )^(2) + background 20 // DAB (Debye Anderson Brumberger) function as a BaseComponent model 19 // [DESCRIPTION] = <text>DAB (Debye Anderson Brumberger) Model 20 // F(x) = scale * L^3/( 1 + (q*L)^2 )^2 + background 21 // L: the correlation length 21 22 // </text> 22 23 // [FIXED] = -
src/sas/models/sas_extension/__init__.py
r79492222 rfb3f9af 1 """ 2 This is an empty package - should probably delete 3 """ -
src/sas/perspectives/fitting/resultpanel.py
r2f4b430 r9df6a03 9 9 import wx.lib.newevent 10 10 from wx.aui import AuiNotebook as Notebook 11 12 from bumps.gui.convergence_view import ConvergenceView 13 from bumps.gui.uncertainty_view import UncertaintyView, CorrelationView, TraceView 14 from bumps.dream.stats import var_stats, format_vars 11 15 12 16 from sas.guiframe.panel_base import PanelBase … … 55 59 result = event.result[0][0] 56 60 if hasattr(result, 'convergence'): 57 from bumps.gui.convergence_view import ConvergenceView58 61 best, pop = result.convergence[:, 0], result.convergence[:, 1:] 59 self.get_panel(ConvergenceView).update(best, pop) 62 self._get_view(ConvergenceView).update(best, pop) 63 else: 64 self._del_view(ConvergenceView) 60 65 if hasattr(result, 'uncertainty_state'): 61 from bumps.gui.uncertainty_view import UncertaintyView, CorrelationView, TraceView62 from bumps.dream.stats import var_stats, format_vars63 66 stats = var_stats(result.uncertainty_state.draw()) 64 67 msg = format_vars(stats) 65 self. get_panel(CorrelationView).update(result.uncertainty_state)66 self. get_panel(UncertaintyView).update((result.uncertainty_state, stats))67 self. get_panel(TraceView).update(result.uncertainty_state)68 self._get_view(CorrelationView).update(result.uncertainty_state) 69 self._get_view(UncertaintyView).update((result.uncertainty_state, stats)) 70 self._get_view(TraceView).update(result.uncertainty_state) 68 71 # TODO: stats should be stored in result rather than computed in bumps UncertaintyView 69 72 wx.PostEvent(self.frame.parent, 70 73 StatusEvent(status=msg, info="info")) 71 print 74 else: 75 for view in (CorrelationView, UncertaintyView, TraceView): 76 self._del_view(view) 72 77 73 78 def get_frame(self): 74 79 return self.frame 75 80 76 def add_panel(self, panel): 77 self.AddPage(panel, panel.title) 78 79 def get_panel(self, panel_class): 81 def _get_view(self, view_class): 80 82 for idx in range(self.PageCount): 81 if self.GetPageText(idx) == panel_class.title:83 if self.GetPageText(idx) == view_class.title: 82 84 return self.GetPage(idx) 83 85 else: 84 panel = panel_class(self)85 self. add_panel(panel)86 panel = view_class(self) 87 self.AddPage(panel, panel.title) 86 88 return panel 89 90 def _del_view(self, view_class): 91 for idx in range(self.PageCount): 92 if self.GetPageText(idx) == view_class.title: 93 self.DeletePage(idx) 94 -
src/sas/plottools/PlotPanel.py
r7e0f9b5 rd3d67f0 3 3 """ 4 4 import logging 5 import traceback 5 6 import wx 6 7 # Try a normal import first … … 21 22 22 23 from plottables import Graph 23 from plottables import Text24 24 from TextDialog import TextDialog 25 25 from LabelDialog import LabelDialog … … 32 32 import numpy 33 33 34 from sas.guiframe.events import StatusEvent 34 from ..guiframe.events import StatusEvent 35 from .toolbar import NavigationToolBar, PlotPrintout, bind 35 36 36 37 def show_tree(obj, d=0): … … 88 89 lo, hi = math.pow(10., lo), math.pow(10., hi) 89 90 return (lo, hi) 90 91 92 def CopyImage(canvas):93 """94 0: matplotlib plot95 1: wx.lib.plot96 2: other97 """98 bmp = wx.BitmapDataObject()99 bmp.SetBitmap(canvas.bitmap)100 101 wx.TheClipboard.Open()102 wx.TheClipboard.SetData(bmp)103 wx.TheClipboard.Close()104 91 105 92 … … 333 320 """ 334 321 self.enable_toolbar = True 335 from toolbar import NavigationToolBar336 322 self.toolbar = NavigationToolBar(parent=self, canvas=self.canvas) 323 bind(self.toolbar, wx.EVT_TOOL, self.onResetGraph, id=self.toolbar._NTB2_RESET) 324 bind(self.toolbar, wx.EVT_TOOL, self.onContextMenu, id=self.toolbar._NTB2_HOME) 337 325 self.toolbar.Realize() 338 326 ## The 'SetToolBar()' is not working on MAC: JHC … … 634 622 when clicking on linear Fit on context menu , display Fitting Dialog 635 623 """ 636 list = {}624 plot_dict = {} 637 625 menu = event.GetEventObject() 638 id = event.GetId()639 self.set_selected_from_menu(menu, id)626 event_id = event.GetId() 627 self.set_selected_from_menu(menu, event_id) 640 628 plotlist = self.graph.returnPlottable() 641 629 if self.graph.selected_plottable is not None: 642 630 for item in plotlist: 643 631 if item.id == self.graph.selected_plottable: 644 list[item] = plotlist[item]632 plot_dict[item] = plotlist[item] 645 633 else: 646 list = plotlist634 plot_dict = plotlist 647 635 from fitDialog import LinearFit 648 636 649 if len( list.keys()) > 0:650 first_item = list.keys()[0]637 if len(plot_dict.keys()) > 0: 638 first_item = plot_dict.keys()[0] 651 639 dlg = LinearFit(parent=None, plottable=first_item, 652 640 push_data=self.onFitDisplay, … … 862 850 Implement save image 863 851 """ 864 self.toolbar.save (evt)852 self.toolbar.save_figure(evt) 865 853 866 854 def onContextMenu(self, event): … … 870 858 """ 871 859 # Slicer plot popup menu 872 id = wx.NewId()860 wx_id = wx.NewId() 873 861 slicerpop = wx.Menu() 874 slicerpop.Append(id, '&Save image', 'Save image as PNG') 875 wx.EVT_MENU(self, id, self.onSaveImage) 876 877 id = wx.NewId() 878 slicerpop.Append(id, '&Printer setup', 'Set image size') 879 wx.EVT_MENU(self, id, self.onPrinterSetup) 880 881 id = wx.NewId() 882 slicerpop.Append(id, '&Printer Preview', 'Set image size') 883 wx.EVT_MENU(self, id, self.onPrinterPreview) 884 885 id = wx.NewId() 886 slicerpop.Append(id, '&Print image', 'Print image ') 887 wx.EVT_MENU(self, id, self.onPrint) 888 889 id = wx.NewId() 890 slicerpop.Append(id, '&Copy', 'Copy to the clipboard') 891 wx.EVT_MENU(self, id, self.OnCopyFigureMenu) 892 893 #id = wx.NewId() 894 #slicerpop.Append(id, '&Load 1D data file') 895 #wx.EVT_MENU(self, id, self._onLoad1DData) 896 897 id = wx.NewId() 862 slicerpop.Append(wx_id, '&Save image', 'Save image as PNG') 863 wx.EVT_MENU(self, wx_id, self.onSaveImage) 864 865 wx_id = wx.NewId() 866 slicerpop.Append(wx_id, '&Printer setup', 'Set image size') 867 wx.EVT_MENU(self, wx_id, self.onPrinterSetup) 868 869 wx_id = wx.NewId() 870 slicerpop.Append(wx_id, '&Print image', 'Print image ') 871 wx.EVT_MENU(self, wx_id, self.onPrint) 872 873 wx_id = wx.NewId() 874 slicerpop.Append(wx_id, '&Copy', 'Copy to the clipboard') 875 wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) 876 877 wx_id = wx.NewId() 898 878 slicerpop.AppendSeparator() 899 slicerpop.Append( id, '&Properties')900 wx.EVT_MENU(self, id, self._onProperties)901 902 id = wx.NewId()879 slicerpop.Append(wx_id, '&Properties') 880 wx.EVT_MENU(self, wx_id, self._onProperties) 881 882 wx_id = wx.NewId() 903 883 slicerpop.AppendSeparator() 904 slicerpop.Append( id, '&Linear Fit')905 wx.EVT_MENU(self, id, self.onFitting)906 907 id = wx.NewId()884 slicerpop.Append(wx_id, '&Linear Fit') 885 wx.EVT_MENU(self, wx_id, self.onFitting) 886 887 wx_id = wx.NewId() 908 888 slicerpop.AppendSeparator() 909 slicerpop.Append( id, '&Toggle Legend On/Off', 'Toggle Legend On/Off')910 wx.EVT_MENU(self, id, self.onLegend)889 slicerpop.Append(wx_id, '&Toggle Legend On/Off', 'Toggle Legend On/Off') 890 wx.EVT_MENU(self, wx_id, self.onLegend) 911 891 912 892 loc_menu = wx.Menu() 913 893 for label in self._loc_labels: 914 id = wx.NewId()915 loc_menu.Append( id, str(label), str(label))916 wx.EVT_MENU(self, id, self.onChangeLegendLoc)917 id = wx.NewId()918 slicerpop.AppendMenu( id, '&Modify Legend Location', loc_menu)919 920 id = wx.NewId()921 slicerpop.Append( id, '&Modify Y Axis Label')922 wx.EVT_MENU(self, id, self._on_yaxis_label)923 id = wx.NewId()924 slicerpop.Append( id, '&Modify X Axis Label')925 wx.EVT_MENU(self, id, self._on_xaxis_label)894 wx_id = wx.NewId() 895 loc_menu.Append(wx_id, str(label), str(label)) 896 wx.EVT_MENU(self, wx_id, self.onChangeLegendLoc) 897 wx_id = wx.NewId() 898 slicerpop.AppendMenu(wx_id, '&Modify Legend Location', loc_menu) 899 900 wx_id = wx.NewId() 901 slicerpop.Append(wx_id, '&Modify Y Axis Label') 902 wx.EVT_MENU(self, wx_id, self._on_yaxis_label) 903 wx_id = wx.NewId() 904 slicerpop.Append(wx_id, '&Modify X Axis Label') 905 wx.EVT_MENU(self, wx_id, self._on_xaxis_label) 926 906 927 907 try: … … 1922 1902 self.xmax = xmax 1923 1903 #In case need to change the range of data plotted 1924 list = [] 1925 list = self.graph.returnPlottable() 1926 for item in list: 1927 #item.onFitRange(xminView,xmaxView) 1904 for item in self.graph.returnPlottable(): 1928 1905 item.onFitRange(None, None) 1929 1906 # Create new data plottable with result … … 1969 1946 Reset the graph by plotting the full range of data 1970 1947 """ 1971 list = [] 1972 list = self.graph.returnPlottable() 1973 for item in list: 1948 for item in self.graph.returnPlottable(): 1974 1949 item.onReset() 1975 1950 self.graph.render(self) … … 1978 1953 self.toolbar.update() 1979 1954 1955 def onPrint(self, event=None): 1956 self.toolbar.print_figure(event) 1957 1980 1958 def onPrinterSetup(self, event=None): 1981 1959 """ … … 1986 1964 def onPrinterPreview(self, event=None): 1987 1965 """ 1966 Matplotlib camvas can no longer print itself. Thus need to do 1967 everything ourselves: need to create a printpreview frame to to 1968 see the preview but needs a parent frame object. Also needs a 1969 printout object (just as any printing task). 1988 1970 """ 1989 1971 try: 1990 self.canvas.Printer_Preview(event=event) 1991 self.Update() 1972 #check if parent is a frame. If not keep getting the higher 1973 #parent till we find a frame 1974 _plot = self 1975 while not isinstance(_plot, wx.Frame): 1976 _plot = _plot.GetParent() 1977 assert _plot is not None 1978 1979 #now create the printpeview object 1980 _preview = wx.PrintPreview(PlotPrintout(self.canvas), 1981 PlotPrintout(self.canvas)) 1982 #and tie it to a printpreview frame then show it 1983 _frame = wx.PreviewFrame(_preview, _plot, "Print Preview", wx.Point(100, 100), wx.Size(600, 650)) 1984 _frame.Centre(wx.BOTH) 1985 _frame.Initialize() 1986 _frame.Show(True) 1992 1987 except: 1988 traceback.print_exc() 1993 1989 pass 1994 1990 1995 def onPrint(self, event=None): 1996 """ 1991 def OnCopyFigureMenu(self, evt): 1992 """ 1993 Copy the current figure to clipboard 1997 1994 """ 1998 1995 try: 1999 self.canvas.Printer_Print(event=event) 2000 self.Update() 2001 except: 2002 pass 2003 2004 def OnCopyFigureMenu(self, evt): 2005 """ 2006 Copy the current figure to clipboard 2007 """ 2008 try: 2009 CopyImage(self.canvas) 1996 self.toolbar.copy_figure() 2010 1997 except: 2011 1998 print "Error in copy Image" -
src/sas/plottools/TextDialog.py
r3477478 r649806d 8 8 FONT_VARIANT = 1 9 9 PNL_WIDTH = 500 10 FAMILY = ['serif', 'sa s-serif', 'fantasy', 'monospace']10 FAMILY = ['serif', 'sans-serif', 'fantasy', 'monospace'] 11 11 SIZE = [8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72] 12 12 STYLE = ['normal', 'italic'] … … 20 20 Dialog window pops- up when selecting 'Add Text' on the toolbar 21 21 """ 22 wx.Dialog.__init__(self, parent, id, title, size=(PNL_WIDTH, 280))22 wx.Dialog.__init__(self, parent, id, title, size=(PNL_WIDTH, 300)) 23 23 self.parent = parent 24 24 # Font … … 35 35 text_box = wx.BoxSizer(wx.HORIZONTAL) 36 36 sizer = wx.GridBagSizer(1, 3) 37 _BOX_WIDTH = 6038 font_description = wx.StaticBox(self, -1, 'Font' , size=(PNL_WIDTH - 20, 70))37 _BOX_WIDTH = 70 38 font_description = wx.StaticBox(self, -1, 'Font') 39 39 font_box = wx.StaticBoxSizer(font_description, wx.VERTICAL) 40 40 family_box = wx.BoxSizer(wx.HORIZONTAL) … … 103 103 self.font_style.SetToolTipString("Font style of the text.") 104 104 # font color 105 self.font_color = wx.ComboBox(self, -1, style =wx.CB_READONLY)105 self.font_color = wx.ComboBox(self, -1, style = wx.CB_READONLY) 106 106 wx.EVT_COMBOBOX(self.font_color, -1, self.on_color) 107 107 self.font_color.SetMinSize((_BOX_WIDTH, -1)) … … 111 111 # Buttons on the bottom 112 112 self.static_line_1 = wx.StaticLine(self, -1) 113 self.ok_button = wx.Button(self, wx.ID_OK, 'OK', size=(_BOX_WIDTH, 25)) 114 self.close_button = wx.Button(self, wx.ID_CANCEL, 'Cancel', size=(_BOX_WIDTH, 25)) 113 self.ok_button = wx.Button(self, wx.ID_OK, 'OK', 114 size = (_BOX_WIDTH, 25)) 115 self.close_button = wx.Button(self, wx.ID_CANCEL, 'Cancel', 116 size = (_BOX_WIDTH, 25)) 115 117 116 118 # Intro … … 121 123 sizer.Add(wx.StaticText(self, -1, explanation), (iy, ix), 122 124 (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 123 family_box.Add(wx.StaticText(self, -1, 'Family :'), -1, 0) 124 family_box.Add(self.font_family, -1, 0) 125 family_box.Add(wx.StaticText(self, -1, 'Family :', size = (50, -1)), 126 0, wx.TOP, 5) 127 family_box.Add(self.font_family, 0, 0) 125 128 family_box.Add((_BOX_WIDTH / 2, -1)) 126 family_box.Add(wx.StaticText(self, -1, 'Size :'), -1, 0) 127 family_box.Add(self.font_size, -1, 0) 129 family_box.Add(wx.StaticText(self, -1, 'Size :', size = (50, -1)), 130 0, wx.TOP, 5) 131 family_box.Add(self.font_size, 0, 0) 128 132 if unit_box != None: 129 133 family_box.Add((_BOX_WIDTH / 2, -1)) 130 family_box.Add(tick_label_text, -1, 0) 131 family_box.Add(self.tick_label_check, -1, 0) 132 style_box.Add(wx.StaticText(self, -1, 'Style :'), -1, 0) 133 style_box.Add(self.font_style, -1, 0) 134 family_box.Add(tick_label_text, 0, 0) 135 family_box.Add(self.tick_label_check, 0, 0) 136 style_box.Add(wx.StaticText(self, -1, 'Style :', size = (50, -1)), 137 0, wx.TOP, 5) 138 style_box.Add(self.font_style, 0, 0) 134 139 style_box.Add((_BOX_WIDTH / 2, -1)) 135 style_box.Add(wx.StaticText(self, -1, 'Weight :'), -1, 0) 136 style_box.Add(self.font_weight, -1, 0) 140 style_box.Add(wx.StaticText(self, -1, 'Weight :', size = (50, -1)), 141 0, wx.TOP, 5) 142 style_box.Add(self.font_weight, 0, 0) 137 143 style_box.Add((_BOX_WIDTH / 2, -1)) 138 style_box.Add(wx.StaticText(self, -1, 'Color :'), -1, 0) 139 style_box.Add(self.font_color, -1, 0) 140 font_box.Add(family_box, -1, 10) 141 font_box.Add(style_box, -1, 10) 144 style_box.Add(wx.StaticText(self, -1, 'Color :', size = (45, -1)), 145 0, wx.TOP, 5) 146 style_box.Add(self.font_color, 0, 0) 147 font_box.Add(family_box, 0, 10) 148 font_box.Add((0,5)) 149 font_box.Add(style_box, 0, 10) 142 150 iy += 1 143 151 ix = 0 … … 152 160 vbox.Add(text_box, 0, wx.EXPAND, 15) 153 161 if unit_box != None: 154 unit_box.Add(unit_text, -1, 0)155 unit_box.Add(self.unit_ctrl, -1, 0)162 unit_box.Add(unit_text, 0, 0) 163 unit_box.Add(self.unit_ctrl, 0, 0) 156 164 vbox.Add((5, 5)) 157 165 vbox.Add(unit_box, 0, wx.LEFT, 15) -
src/sas/plottools/config.py
r79492222 rd3d67f0 58 58 matplotlib.rcParams[param] = 0.05 59 59 matplotlib.rcParams['legend.numpoints'] = 1 60 61 # this should happen after initial matplotlib configuration 62 from .toolbar import NavigationToolBar 63 from matplotlib.backends import backend_wxagg 64 backend_wxagg.NavigationToolbar2WxAgg = NavigationToolBar 65 66 # CRUFT: bumps 0.7.5.6 and older uses wrong toolbar 67 backend_wxagg.NavigationToolbar2Wx = NavigationToolBar -
src/sas/plottools/toolbar.py
r3477478 rd3d67f0 31 31 def _init_toolbar(self): 32 32 self._parent = self.canvas.GetParent() 33 _NTB2_HOME = wx.NewId()33 self._NTB2_HOME = wx.NewId() 34 34 self._NTB2_BACK = wx.NewId() 35 35 self._NTB2_FORWARD = wx.NewId() 36 36 self._NTB2_PAN = wx.NewId() 37 37 self._NTB2_ZOOM = wx.NewId() 38 _NTB2_SAVE = wx.NewId()39 _NTB2_PRINT = wx.NewId()40 _NTB2_RESET = wx.NewId()38 self._NTB2_SAVE = wx.NewId() 39 self._NTB2_PRINT = wx.NewId() 40 self._NTB2_RESET = wx.NewId() 41 41 42 42 # for mpl 1.2+ compatibility … … 53 53 context_tip += ' right-click the data symbols.' 54 54 context = wx.ArtProvider.GetBitmap(wx.ART_LIST_VIEW, wx.ART_TOOLBAR) 55 self.AddSimpleTool( _NTB2_HOME, context, context_tip, context_tip)55 self.AddSimpleTool(self._NTB2_HOME, context, context_tip, context_tip) 56 56 57 57 self.InsertSeparator(1) … … 69 69 70 70 self.AddSeparator() 71 self.AddSimpleTool( _NTB2_SAVE, _load_bitmap('filesave.png'),71 self.AddSimpleTool(self._NTB2_SAVE, _load_bitmap('filesave.png'), 72 72 'Save', 'Save plot contents to file') 73 73 74 74 print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR) 75 self.AddSimpleTool( _NTB2_PRINT, print_bmp, 'Print', 'Print plot')75 self.AddSimpleTool(self._NTB2_PRINT, print_bmp, 'Print', 'Print plot') 76 76 77 77 reset_bmp = wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, wx.ART_TOOLBAR) 78 self.AddSimpleTool( _NTB2_RESET, reset_bmp, 'Reset', 'Reset graph range')78 self.AddSimpleTool(self._NTB2_RESET, reset_bmp, 'Reset', 'Reset graph range') 79 79 80 bind(self, wx.EVT_TOOL, self. on_menu, id=_NTB2_HOME)80 bind(self, wx.EVT_TOOL, self.context_menu, id=self._NTB2_HOME) 81 81 bind(self, wx.EVT_TOOL, self.forward, id=self._NTB2_FORWARD) 82 82 bind(self, wx.EVT_TOOL, self.back, id=self._NTB2_BACK) 83 83 bind(self, wx.EVT_TOOL, self.zoom, id=self._NTB2_ZOOM) 84 84 bind(self, wx.EVT_TOOL, self.pan, id=self._NTB2_PAN) 85 bind(self, wx.EVT_TOOL, self.save_figure, id= _NTB2_SAVE)86 bind(self, wx.EVT_TOOL, self. on_print, id=_NTB2_PRINT)87 bind(self, wx.EVT_TOOL, self. on_reset, id=_NTB2_RESET)85 bind(self, wx.EVT_TOOL, self.save_figure, id=self._NTB2_SAVE) 86 bind(self, wx.EVT_TOOL, self.print_figure, id=self._NTB2_PRINT) 87 bind(self, wx.EVT_TOOL, self.home, id=self._NTB2_RESET) 88 88 89 89 self.Realize() 90 90 91 91 def on_menu(self, event): 92 """93 Plot menu94 """95 92 try: 96 93 self._parent.onToolContextMenu(event=event) … … 98 95 logging.error("Plot toolbar could not show menu") 99 96 100 def on_reset(self, event):97 def context_menu(self, event): 101 98 """ 102 Reset plot 99 Default context menu for a plot panel 100 103 101 """ 102 # Slicer plot popup menu 103 wx_id = wx.NewId() 104 popup = wx.Menu() 105 popup.Append(wx_id, '&Save image', 'Save image as PNG') 106 wx.EVT_MENU(self, wx_id, self.save_figure) 107 108 wx_id = wx.NewId() 109 popup.Append(wx_id, '&Print image', 'Print image ') 110 wx.EVT_MENU(self, wx_id, self.print_figure) 111 112 wx_id = wx.NewId() 113 popup.Append(wx_id, '&Copy to Clipboard', 'Copy image to the clipboard') 114 wx.EVT_MENU(self, wx_id, self.copy_figure) 115 116 # Show the popup menu relative to the location of the toolbar 117 self.PopupMenu(popup, (0,0)) 118 119 120 def print_figure(self, event): 104 121 try: 105 self._parent.onResetGraph(event=event) 122 _printer = wx.Printer() 123 _printer.Print(self.canvas, PlotPrintout(self.canvas), True) 106 124 except: 107 logging.error("Plot toolbar could not reset plot") 125 import traceback 126 logging.error(traceback.format_exc()) 108 127 109 def on_print(self, event): 128 def copy_figure(self, event): 129 copy_image_to_clipboard(self.canvas) 130 131 class PlotPrintout(wx.Printout): 132 """ 133 Create the wx.Printout object for matplotlib figure from the PlotPanel. 134 Provides the required OnPrintPage and HasPage overrides. Other methods 135 may be added/overriden in the future. 136 :TODO: this needs LOTS of TLC .. but fixes immediate problem 137 """ 138 def __init__(self, canvas): 110 139 """ 111 Print140 Initialize wx.Printout and get passed figure object 112 141 """ 113 try: 114 self.canvas.Printer_Preview(event=event) 115 except: 116 logging.error("Plot toolbar could not print") 142 wx.Printout.__init__(self) 143 self.canvas = canvas 144 145 def OnPrintPage(self, page): 146 """ 147 Most rudimentry OnPrintPage overide. instatiates a dc object, gets 148 its size, gets the size of the figure object, scales it to the dc 149 canvas size keeping the aspect ratio intact, then prints as bitmap 150 """ 151 _dc = self.GetDC() 152 (_dcX, _dcY) = _dc.GetSizeTuple() 153 (_bmpX,_bmpY) = self.canvas.GetSize() 154 _scale = min(_dcX/_bmpX, _dcY/_bmpY) 155 _dc.SetUserScale(_scale, _scale) 156 _dc.DrawBitmap(self.canvas.bitmap, 0, 0, False,) 157 return True 158 159 def GetPageInfo(self): 160 """ 161 just sets the page to 1 - no flexibility for now 162 """ 163 return (1, 1, 1, 1) 164 165 166 def copy_image_to_clipboard(canvas): 167 bmp = wx.BitmapDataObject() 168 bmp.SetBitmap(canvas.bitmap) 169 170 wx.TheClipboard.Open() 171 wx.TheClipboard.SetData(bmp) 172 wx.TheClipboard.Close() 173 174
Note: See TracChangeset
for help on using the changeset viewer.