Changeset fc2b91a in sasview for guiframe/local_perspectives
- Timestamp:
- Jun 18, 2008 6:07:18 PM (16 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:
- 4972de2
- Parents:
- ad8bcd6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/plotting.py
r96f13a9 rfc2b91a 18 18 class PanelMenu(wx.Menu): 19 19 plots = None 20 graph = None 20 21 21 22 def set_plots(self, plots): 22 23 self.plots = plots 23 24 25 def set_graph(self, graph): 26 self.graph = graph 24 27 25 28 class View1DPanel(PlotPanel): … … 71 74 is_new = True 72 75 if event.plot.name in self.plots.keys(): 73 is_new = False 76 # Check whether the class of plottable changed 77 if not event.plot.__class__==self.plots[event.plot.name].__class__: 78 self.graph.delete(self.plots[event.plot.name]) 79 else: 80 is_new = False 74 81 75 82 if is_new: … … 103 110 slicerpop = PanelMenu() 104 111 slicerpop.set_plots(self.plots) 112 slicerpop.set_graph(self.graph) 105 113 106 114 # Option to save the data displayed 107 for plot in self.graph.plottables: 115 116 #for plot in self.graph.plottables: 117 if self.graph.selected_plottable in self.plots: 118 plot = self.plots[self.graph.selected_plottable] 108 119 id = wx.NewId() 109 120 name = plot.name … … 117 128 wx.EVT_MENU(self, id, self.onSaveImage) 118 129 119 slicerpop.AppendSeparator()130 120 131 item_list = self.parent.get_context_menu(self.graph) 121 if not item_list==None: 122 for item in item_list: 123 try: 124 id = wx.NewId() 125 slicerpop.Append(id, item[0], item[1]) 126 wx.EVT_MENU(self, id, item[2]) 127 except: 128 print sys.exc_value 129 print RuntimeError, "View1DPanel.onContextMenu: bad menu item" 132 if (not item_list==None) and (not len(item_list)==0): 133 slicerpop.AppendSeparator() 134 for item in item_list: 135 try: 136 id = wx.NewId() 137 slicerpop.Append(id, item[0], item[1]) 138 wx.EVT_MENU(self, id, item[2]) 139 except: 140 print sys.exc_value 141 print RuntimeError, "View1DPanel.onContextMenu: bad menu item" 130 142 131 143 slicerpop.AppendSeparator() … … 135 147 #wx.EVT_MENU(self, id, self._onToggleScale) 136 148 149 if self.graph.selected_plottable in self.plots: 150 if self.plots[self.graph.selected_plottable].__class__.__name__=="Theory1D": 151 id = wx.NewId() 152 slicerpop.Append(id, '&Add errors to data') 153 wx.EVT_MENU(self, id, self._on_add_errors) 154 137 155 id = wx.NewId() 138 156 slicerpop.Append(id, '&Change scale') … … 140 158 141 159 id = wx.NewId() 142 slicerpop.AppendSeparator()160 #slicerpop.AppendSeparator() 143 161 slicerpop.Append(id, '&Reset Graph') 144 162 wx.EVT_MENU(self, id, self.onResetGraph) … … 147 165 pos = self.ScreenToClient(pos) 148 166 self.PopupMenu(slicerpop, pos) 167 168 def _on_add_errors(self, evt): 169 """ 170 Compute reasonable errors for a data set without 171 errors and transorm the plottable to a Data1D 172 """ 173 import math 174 import numpy 175 from sans.guitools.plottables import Data1D 176 177 if not self.graph.selected_plottable == None: 178 length = len(self.plots[self.graph.selected_plottable].x) 179 dy = numpy.zeros(length) 180 for i in range(length): 181 dy[i] = math.sqrt(self.plots[self.graph.selected_plottable].y[i]) 182 183 new_plot = Data1D(self.plots[self.graph.selected_plottable].x, 184 self.plots[self.graph.selected_plottable].y, 185 dy=dy) 186 new_plot.interactive = True 187 new_plot.name = self.plots[self.graph.selected_plottable].name 188 label, unit = self.plots[self.graph.selected_plottable].get_xaxis() 189 new_plot.xaxis(label, unit) 190 label, unit = self.plots[self.graph.selected_plottable].get_yaxis() 191 new_plot.yaxis(label, unit) 192 193 self.graph.delete(self.plots[self.graph.selected_plottable]) 194 195 self.graph.add(new_plot) 196 self.plots[self.graph.selected_plottable]=new_plot 197 198 self.graph.render(self) 199 self.subplot.figure.canvas.draw_idle() 149 200 150 201 def _onSave(self, evt):
Note: See TracChangeset
for help on using the changeset viewer.