Changeset 3c44c66 in sasview for guiframe/local_perspectives
- Timestamp:
- Jul 20, 2010 2:36:35 PM (14 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:
- cb19af9f
- Parents:
- 1b17a64
- Location:
- guiframe/local_perspectives/plotting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/Plotter1D.py
rd955bf19 r3c44c66 81 81 self.graph.render(self) 82 82 83 def set_data(self, list=[]): 84 """ 85 """ 86 pass 87 88 83 89 def _reset(self): 84 90 """ -
guiframe/local_perspectives/plotting/plotting.py
rd955bf19 r3c44c66 15 15 import sys 16 16 from sans.guicomm.events import EVT_NEW_PLOT 17 from sans.guicomm.events import NewPlotEvent 18 from sans.guicomm.events import EVT_NEW_LOADED_DATA 17 19 from sans.guicomm.events import StatusEvent 18 20 19 21 22 class PlottingDialog(wx.Dialog): 23 """ 24 Dialog to display plotting option 25 """ 26 def __init__(self, parent=None, panel_on_focus=None, list_of_data=[]): 27 """ 28 """ 29 wx.Dialog.__init__(self, parent=parent,title="Plotting", size=(300, 280)) 30 self.parent = parent 31 self.panel_on_focus = panel_on_focus 32 self.list_of_data = list_of_data 33 self.define_structure() 34 self.layout_plot_on_panel(list_of_data=self.list_of_data) 35 self.layout_data_name(list_of_data=self.list_of_data) 36 self.layout_button() 37 38 def define_structure(self): 39 """ 40 """ 41 #Dialog interface 42 vbox = wx.BoxSizer(wx.VERTICAL) 43 self.sizer_data = wx.BoxSizer(wx.HORIZONTAL) 44 45 self.sizer_selection = wx.BoxSizer(wx.VERTICAL) 46 self.sizer_button = wx.BoxSizer(wx.HORIZONTAL) 47 vbox.Add(self.sizer_data) 48 vbox.Add(self.sizer_selection) 49 vbox.Add(self.sizer_button) 50 self.SetSizer(vbox) 51 self.Centre() 52 53 def layout_button(self): 54 """ 55 """ 56 self.bt_ok = wx.Button(self, wx.NewId(), "Ok", (30, 10)) 57 self.bt_ok.SetToolTipString("plot data") 58 wx.EVT_BUTTON(self, self.bt_ok.GetId(), self.on_ok) 59 60 self.sizer_button.AddMany([((40,40), 0, 61 wx.LEFT|wx.ADJUST_MINSIZE, 100 ), 62 (self.bt_ok, 0, wx.ALL,10)]) 63 64 def layout_data_name(self, list_of_data=[]): 65 """ 66 """ 67 self.data_tcl = wx.TextCtrl(self, -1,size=(260,80), style=wx.TE_MULTILINE) 68 hint_data = "Data to plot." 69 self.data_tcl.SetToolTipString(hint_data) 70 self.data_tcl.SetEditable(False) 71 for item in list_of_data: 72 self.data_tcl.AppendText(item.name+"\n") 73 74 self.sizer_data.AddMany([(self.data_tcl, 1, wx.ALL, 10)]) 75 76 def layout_plot_on_panel(self, list_of_data=[]): 77 """ 78 """ 79 if len(list_of_data) == 0: 80 return 81 elif len(list_of_data) ==1: 82 self.layout_single_data(list_of_data=list_of_data) 83 else: 84 self.layout_multiple(list_of_data=list_of_data) 85 86 def layout_single_data(self, list_of_data=[]): 87 """ 88 """ 89 self.sizer_selection.Clear(True) 90 if self.panel_on_focus is None and list_of_data < 1: 91 return 92 else: 93 name = "Plot data on new panel" 94 self.rb_single_data_panel = wx.RadioButton(self, -1,name, 95 style=wx.RB_GROUP) 96 msg = "Each data will be plotted separately on a new panel" 97 self.rb_single_data_panel.SetToolTipString(msg) 98 self.rb_single_data_panel.SetValue(True) 99 self.Bind(wx.EVT_RADIOBUTTON, self.on_choose_panel, 100 id=self.rb_single_data_panel.GetId()) 101 self.rb_panel_on_focus = wx.RadioButton(self, -1,"No Panel on Focus") 102 msg = "All Data will be appended to panel on focus" 103 self.rb_panel_on_focus.SetToolTipString(msg) 104 self.rb_panel_on_focus.Disable() 105 self.Bind(wx.EVT_RADIOBUTTON, self.on_choose_panel, 106 id=self.rb_panel_on_focus.GetId()) 107 if self.panel_on_focus is not None: 108 self.rb_panel_on_focus.Enable() 109 self.rb_panel_on_focus.SetLabel(str(panel.window_name)) 110 self.sizer_selection.AddMany([(self.rb_single_data_panel, 111 1, wx.ALL, 10), 112 (self.rb_panel_on_focus,1, wx.ALL, 10)]) 113 114 def layout_multiple(self, list_of_data=[]): 115 """ 116 """ 117 self.sizer_selection.Clear(True) 118 if self.panel_on_focus is None and list_of_data <= 1: 119 return 120 name = "Plot each data separately" 121 self.rb_single_data_panel = wx.RadioButton(self, -1,name, 122 style=wx.RB_GROUP) 123 msg = "Each data will be plotted separately on a new panel" 124 self.rb_single_data_panel.SetToolTipString(msg) 125 self.rb_single_data_panel.SetValue(True) 126 self.Bind(wx.EVT_RADIOBUTTON, self.on_choose_panel, 127 id=self.rb_single_data_panel.GetId()) 128 name = "Append all to new panel" 129 self.rb_new_panel = wx.RadioButton(self, -1,name) 130 msg = "All Data will be appended to a new panel" 131 self.rb_new_panel.SetToolTipString(msg) 132 self.Bind(wx.EVT_RADIOBUTTON, self.on_choose_panel, 133 id=self.rb_new_panel.GetId()) 134 self.rb_panel_on_focus = wx.RadioButton(self, -1,"No Panel on Focus") 135 msg = "All Data will be appended to panel on focus" 136 self.rb_panel_on_focus.SetToolTipString(msg) 137 self.rb_panel_on_focus.Disable() 138 self.Bind(wx.EVT_RADIOBUTTON, self.on_choose_panel, 139 id=self.rb_panel_on_focus.GetId()) 140 if self.panel_on_focus is not None: 141 self.rb_panel_on_focus.Enable() 142 self.rb_panel_on_focus.SetLabel(str(panel.window_name)) 143 144 self.sizer_selection.AddMany([(self.rb_single_data_panel, 145 1, wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 146 (self.rb_new_panel, 1, wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 147 (self.rb_panel_on_focus, 1, wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),]) 148 def on_ok(self, event): 149 """ 150 """ 151 def on_choose_panel(self, event): 152 """ 153 """ 20 154 class Plugin: 21 155 """ … … 62 196 self.parent = parent 63 197 # Connect to plotting events 198 self.parent.Bind(EVT_NEW_LOADED_DATA, self._on_plot) 64 199 self.parent.Bind(EVT_NEW_PLOT, self._on_plot_event) 65 200 # We have no initial panels for this plug-in … … 92 227 pass 93 228 94 229 def _on_plot(self, event): 230 """ 231 check the contains of event. 232 if it is a list of data to plot plot each one at the time 233 """ 234 list_of_data1d = [] 235 if hasattr(event, "plots"): 236 for plot, path in event.plots: 237 print "plotting _on_plot" 238 if plot.__class__.__name__ == "Data2D": 239 wx.PostEvent(self.parent, 240 NewPlotEvent(plot=plot, title=plot.name)) 241 else: 242 list_of_data1d.append((plot, path)) 243 95 244 def _on_plot_event(self, event): 96 245 """ … … 178 327 return 179 328 329 class Data(object): 330 def __init__(self, name): 331 self.name = str(name) 332 class MyApp(wx.App): 333 def OnInit(self): 334 wx.InitAllImageHandlers() 335 list =[Data(name="Data1D")]#, 336 # Data(name="Data2D"),Data(name="Data3D")] 337 dialog = PlottingDialog(list_of_data=list) 338 if dialog.ShowModal() == wx.ID_OK: 339 pass 340 dialog.Destroy() 341 342 return 1 343 344 # end of class MyApp 345 346 if __name__ == "__main__": 347 app = MyApp(0) 348 app.MainLoop()
Note: See TracChangeset
for help on using the changeset viewer.