Changeset aa4b8379 in sasview
- Timestamp:
- Jun 18, 2008 6:10:06 PM (17 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:
- 3fd1ebc
- Parents:
- 4972de2
- Location:
- prview
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
prview/perspectives/pr/inversion_panel.py
rb659551 raa4b8379 115 115 pos_err = 1.0 116 116 117 def __init__(self, parent, id = -1, plots = None, **kwargs):117 def __init__(self, parent, id = -1, plots = None, standalone=False, **kwargs): 118 118 wx.Panel.__init__(self, parent, id = id, **kwargs) 119 119 … … 147 147 ## Data manager 148 148 self.manager = None 149 150 ## Standalone flage 151 self.standalone = standalone 149 152 150 153 self._do_layout() … … 181 184 #self.label_sugg.Show() 182 185 elif name=='plotname': 183 self.plot_data.SetValue(str(value)) 184 self.plot_radio.SetValue(True) 186 if self.standalone==False: 187 self.plot_data.SetValue(str(value)) 188 self.plot_radio.SetValue(True) 189 self._on_pars_changed(None) 190 elif name=='datafile': 191 self.data_file.SetValue(str(value)) 192 self.file_radio.SetValue(True) 185 193 self._on_pars_changed(None) 186 194 else: … … 214 222 self.alpha_estimate_ctl.GetValue() 215 223 elif name=='plotname': 216 self.plot_data.GetValue() 224 if self.standalone==False: 225 self.plot_data.GetValue() 226 elif name=='datafile': 227 self.data_file.GetValue() 217 228 else: 218 229 wx.Panel.__getattr__(self, name) … … 230 241 231 242 # ----- I(q) data ----- 232 databox = wx.StaticBox(self, -1, "I(q) data ")243 databox = wx.StaticBox(self, -1, "I(q) data source") 233 244 234 245 boxsizer1 = wx.StaticBoxSizer(databox, wx.VERTICAL) … … 248 259 pars_sizer.Add(choose_button, (iy,3), (1,1), wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 249 260 250 iy += 1 251 self.plot_radio = wx.RadioButton(self, -1, "Plot data:") 252 self.plot_data = wx.TextCtrl(self, -1, size=(100,20)) 253 self.plot_data.SetEditable(False) 254 pars_sizer.Add(self.plot_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 255 pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 15) 261 if self.standalone==False: 262 iy += 1 263 self.plot_radio = wx.RadioButton(self, -1, "Plot data:") 264 self.plot_data = wx.TextCtrl(self, -1, size=(100,20)) 265 self.plot_data.SetEditable(False) 266 pars_sizer.Add(self.plot_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 267 pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 15) 256 268 257 269 boxsizer1.Add(pars_sizer, 0, wx.EXPAND) … … 476 488 # If the pars are valid, estimate alpha 477 489 if flag: 478 if self. plot_radio.GetValue():490 if self.standalone==False and self.plot_radio.GetValue(): 479 491 dataset = self.plot_data.GetValue() 480 492 self.manager.estimate_plot_inversion(alpha=alpha, nfunc=nfunc, … … 571 583 572 584 if flag: 573 if self. plot_radio.GetValue():585 if self.standalone==False and self.plot_radio.GetValue(): 574 586 dataset = self.plot_data.GetValue() 575 self.manager.setup_plot_inversion(alpha=alpha, nfunc=nfunc, 576 d_max=dmax, 577 q_min=qmin, q_max=qmax) 587 if len(dataset.strip())==0: 588 message = "No data to invert. Select a data set before proceeding with P(r) inversion." 589 wx.PostEvent(self.manager.parent, StatusEvent(status=message)) 590 else: 591 self.manager.setup_plot_inversion(alpha=alpha, nfunc=nfunc, 592 d_max=dmax, 593 q_min=qmin, q_max=qmax) 578 594 else: 579 595 path = self.data_file.GetValue() 580 self.manager.setup_file_inversion(alpha=alpha, nfunc=nfunc, 581 d_max=dmax, path=path, 582 q_min=qmin, q_max=qmax 583 ) 596 if len(path.strip())==0: 597 message = "No data to invert. Select a data set before proceeding with P(r) inversion." 598 wx.PostEvent(self.manager.parent, StatusEvent(status=message)) 599 else: 600 self.manager.setup_file_inversion(alpha=alpha, nfunc=nfunc, 601 d_max=dmax, path=path, 602 q_min=qmin, q_max=qmax 603 ) 584 604 585 605 else: -
prview/perspectives/pr/pr.py
rb659551 raa4b8379 6 6 import sys 7 7 import wx 8 import logging 8 9 from sans.guitools.plottables import Data1D, Theory1D 9 10 from sans.guicomm.events import NewPlotEvent, StatusEvent 10 11 import math, numpy 11 12 from sans.pr.invertor import Invertor 13 14 PR_FIT_LABEL = "P_{fit}(r)" 15 PR_LOADED_LABEL = "P_{loaded}(r)" 16 IQ_DATA_LABEL = "I_{obs}(q)" 17 18 import wx.lib 19 (NewPrFileEvent, EVT_PR_FILE) = wx.lib.newevent.NewEvent() 20 12 21 13 22 class Plugin: … … 41 50 # Start with a good default 42 51 self.elapsed = 0.022 52 self.iq_data_shown = False 43 53 44 54 ## Current invertor … … 54 64 ## Number of P(r) points to display on the output plot 55 65 self._pr_npts = 51 66 ## Flag to let the plug-in know that it is running standalone 67 self.standalone = True 68 69 # Log startup 70 logging.info("Pr(r) plug-in started") 71 72 56 73 57 74 def populate_menu(self, id, owner): … … 332 349 """ 333 350 # Look whether this Graph contains P(r) data 351 #if graph.selected_plottable==IQ_DATA_LABEL: 334 352 for item in graph.plottables: 335 if item.name=="P_{fit}(r)": 336 337 return [["Compute P(r)", "Compute P(r) from distribution", self._on_context_inversion], 338 ["Add P(r) data", "Load a data file and display it on this plot", self._on_add_data], 353 if item.name==PR_FIT_LABEL: 354 return [["Add P(r) data", "Load a data file and display it on this plot", self._on_add_data], 339 355 ["Change number of P(r) points", "Change the number of points on the P(r) output", self._on_pr_npts]] 340 341 return [["Compute P(r)", "Compute P(r) from distribution", self._on_context_inversion]] 356 357 elif item.name==graph.selected_plottable: 358 return [["Compute P(r)", "Compute P(r) from distribution", self._on_context_inversion]] 359 360 return [] 342 361 343 362 def _on_add_data(self, evt): … … 429 448 430 449 # Make a plot of I(q) data 431 new_plot = Data1D(self.pr.x, self.pr.y, dy=self.pr.err) 432 new_plot.name = "I_{obs}(q)" 433 new_plot.xaxis("\\rm{Q}", 'A^{-1}') 434 new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") 435 #new_plot.group_id = "test group" 436 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Iq")) 450 if False: 451 new_plot = Data1D(self.pr.x, self.pr.y, dy=self.pr.err) 452 new_plot.name = "I_{obs}(q)" 453 new_plot.xaxis("\\rm{Q}", 'A^{-1}') 454 new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") 455 #new_plot.group_id = "test group" 456 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Iq")) 437 457 438 458 # Show I(q) fit … … 454 474 new_plot.xaxis("\\rm{Q}", 'A^{-1}') 455 475 new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") 476 new_plot.interactive = True 456 477 #new_plot.group_id = "test group" 457 478 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Iq")) 458 479 480 # Get Q range 481 self.control_panel.q_min = self.pr.x.min() 482 self.control_panel.q_max = self.pr.x.max() 483 484 459 485 460 486 def setup_plot_inversion(self, alpha, nfunc, d_max, q_min=None, q_max=None): … … 510 536 511 537 self.pr = pr 538 self.iq_data_shown = True 512 539 513 540 … … 624 651 625 652 # If we have more than one displayed plot, make the user choose 626 if len(panel.plots)>1: 627 dialog = InversionDlg(None, -1, "P(r) Inversion", panel.plots, pars=False) 628 dialog.set_content(self.last_data, self.nfunc, self.alpha, self.max_length) 629 if dialog.ShowModal() == wx.ID_OK: 630 dataset = dialog.get_content() 631 dialog.Destroy() 632 else: 633 dialog.Destroy() 634 return 653 if len(panel.plots)>1 and panel.graph.selected_plottable in panel.plots: 654 dataset = panel.graph.selected_plottable 655 if False: 656 dialog = InversionDlg(None, -1, "P(r) Inversion", panel.plots, pars=False) 657 dialog.set_content(self.last_data, self.nfunc, self.alpha, self.max_length) 658 if dialog.ShowModal() == wx.ID_OK: 659 dataset = dialog.get_content() 660 dialog.Destroy() 661 else: 662 dialog.Destroy() 663 return 635 664 elif len(panel.plots)==1: 636 665 dataset = panel.plots.keys()[0] … … 646 675 self.control_panel.alpha = self.alpha 647 676 self.parent.set_perspective(self.perspective) 677 self.control_panel._on_invert(None) 648 678 649 679 def get_panels(self, parent): … … 654 684 655 685 self.parent = parent 656 self.control_panel = InversionControl(self.parent, -1, style=wx.RAISED_BORDER) 686 self.control_panel = InversionControl(self.parent, -1, 687 style=wx.RAISED_BORDER, 688 standalone=self.standalone) 657 689 self.control_panel.set_manager(self) 658 690 self.control_panel.nfunc = self.nfunc … … 662 694 self.perspective = [] 663 695 self.perspective.append(self.control_panel.window_name) 696 697 self.parent.Bind(EVT_PR_FILE, self._on_new_file) 698 664 699 return [self.control_panel] 700 701 def _on_new_file(self, evt): 702 """ 703 Called when the application manager posted an 704 EVT_PR_FILE event. Just prompt the control 705 panel to load a new data file. 706 """ 707 self.control_panel._change_file(None) 665 708 666 709 def get_perspective(self): -
prview/sansview.py
r4a5de6f raa4b8379 1 1 import wx 2 2 #import gui_manager 3 3 from sans.guiframe import gui_manager … … 5 5 # For py2exe, import config here 6 6 import local_config 7 from perspectives.pr.pr import NewPrFileEvent 7 8 9 class PrFrame(gui_manager.ViewerFrame): 10 def _on_open(self, event): 11 wx.PostEvent(self, NewPrFileEvent()) 12 13 class PrApp(gui_manager.ViewApp): 14 def OnInit(self): 15 #from gui_manager import ViewerFrame 16 self.frame = PrFrame(None, -1, local_config.__appname__) 17 self.frame.Show(True) 18 19 if hasattr(self.frame, 'special'): 20 print "Special?", self.frame.special.__class__.__name__ 21 self.frame.special.SetCurrent() 22 self.SetTopWindow(self.frame) 23 return True 24 8 25 class SansView(): 9 26 … … 13 30 """ 14 31 #from gui_manager import ViewApp 15 self.gui = gui_manager.ViewApp(0) 32 #self.gui = gui_manager.ViewApp(0) 33 self.gui = PrApp(0) 16 34 17 35 # Add perspectives to the basic application … … 19 37 # dynamically 20 38 import perspectives.pr as module 21 plug = module.Plugin()22 self.gui.add_perspective( plug)39 self.pr_plug = module.Plugin() 40 self.gui.add_perspective(self.pr_plug) 23 41 24 42 # Build the GUI … … 30 48 # Start the main loop 31 49 self.gui.MainLoop() 50 32 51 33 52 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.