Changeset 52b8b74 in sasview for guiframe/local_perspectives/plotting
- Timestamp:
- Jan 25, 2011 9:45:50 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:
- 0912feab
- Parents:
- 5385a9e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/Plotter1D.py
rdf7046f r52b8b74 29 29 from sans.guiframe.events import RemoveDataEvent 30 30 from sans.guiframe.events import AddManyDataEvent 31 from sans.guiframe.events import EVT_NEW_LOADED_DATA 31 32 from sans.guiframe.utils import PanelMenu 32 33 from sans.guiframe.dataFitting import Data1D … … 64 65 ## Plottables 65 66 self.plots = {} 67 #context menu 68 self._slicerpop = None 69 self._menu_add_plot = None 70 self._available_data = [] 71 self._menu_add_ids = [] 66 72 ## save errors dy for each data plotted 67 73 self.err_dy = {} … … 80 86 self.graph.yaxis("\\rm{Intensity} ", "cm^{-1}") 81 87 self.graph.render(self) 82 88 #bind with event to contrst context menu 89 self.parent.Bind(EVT_NEW_LOADED_DATA, self._add_new_plot) 90 91 def on_add_new_plot(self, event): 92 """ 93 """ 94 def _add_new_plot(self, event): 95 """ 96 Construct the context menu given available data 97 """ 98 self._available_data = event.data_to_add 99 100 def _fill_menu_add_plot(self): 101 """ 102 """ 103 if self._menu_add_plot is not None: 104 if self._available_data: 105 for id in self._menu_add_ids: 106 item = self._menu_add_plot.FindItemById(id) 107 if item is None: 108 for data in self._available_data: 109 new_id = wx.NewId() 110 hint = 'Add %s to this panel' % str(data.name) 111 self._menu_add_plot.Append(new_id, str(data.name), hint) 112 wx.EVT_MENU(self, id, self.on_add_new_plot) 113 self._menu_add_ids.append(new_id) 114 else: 115 if item.GetLabel() == 'No Loaded Data': 116 self._menu_add_plot.RemoveItem(item) 117 83 118 def set_data(self, list=None): 84 119 """ … … 205 240 206 241 """ 207 s licerpop = PanelMenu()208 s licerpop.set_plots(self.plots)209 s licerpop.set_graph(self.graph)242 self._slicerpop = PanelMenu() 243 self._slicerpop.set_plots(self.plots) 244 self._slicerpop.set_graph(self.graph) 210 245 # Various plot options 211 246 id = wx.NewId() 212 s licerpop.Append(id, '&Save image', 'Save image as PNG')247 self._slicerpop.Append(id, '&Save image', 'Save image as PNG') 213 248 wx.EVT_MENU(self, id, self.onSaveImage) 214 249 id = wx.NewId() 215 s licerpop.Append(id, '&Print image', 'Print image ')250 self._slicerpop.Append(id, '&Print image', 'Print image ') 216 251 wx.EVT_MENU(self, id, self.onPrint) 217 252 id = wx.NewId() 218 s licerpop.Append(id, '&Print Preview', 'image preview for print')253 self._slicerpop.Append(id, '&Print Preview', 'image preview for print') 219 254 wx.EVT_MENU(self, id, self.onPrinterPreview) 220 slicerpop.AppendSeparator() 255 #add plot 256 self._menu_add_plot = wx.Menu() 257 id = wx.NewId() 258 self._menu_add_plot.Append(id, '&No Loaded Data', 'Add new plot') 259 self._menu_add_plot.FindItemByPosition(0).Enable(False) 260 self._menu_add_ids.append(id) 261 262 self._slicerpop.AppendSubMenu(self._menu_add_plot, '&Add New Plot') 263 self._fill_menu_add_plot() 264 self._slicerpop.AppendSeparator() 265 #add menu of other plugins 221 266 item_list = self.parent.get_context_menu(self.graph) 222 267 if (not item_list == None) and (not len(item_list) == 0): … … 224 269 try: 225 270 id = wx.NewId() 226 s licerpop.Append(id, item[0], item[1])271 self._slicerpop.Append(id, item[0], item[1]) 227 272 wx.EVT_MENU(self, id, item[2]) 228 273 except: … … 231 276 wx.PostEvent(self.parent, StatusEvent(status=msg)) 232 277 pass 233 slicerpop.AppendSeparator() 234 278 self._slicerpop.AppendSeparator() 279 id = wx.NewId() 280 self._menu_add_plot = wx.Menu() 281 self._slicerpop.Append(id, '&Print image', 'Print image') 235 282 if self.graph.selected_plottable in self.plots: 236 283 plot = self.plots[self.graph.selected_plottable] 237 284 id = wx.NewId() 238 285 name = plot.name 239 s licerpop.Append(id, "&Save points")286 self._slicerpop.Append(id, "&Save points") 240 287 self.action_ids[str(id)] = plot 241 288 wx.EVT_MENU(self, id, self._onSave) 242 289 id = wx.NewId() 243 s licerpop.Append(id, "Remove %s curve" % name)290 self._slicerpop.Append(id, "Remove %s curve" % name) 244 291 self.action_ids[str(id)] = plot 245 292 wx.EVT_MENU(self, id, self._onRemove) 246 s licerpop.AppendSeparator()293 self._slicerpop.AppendSeparator() 247 294 # Option to hide 248 295 #TODO: implement functionality to hide a plottable (legend click) … … 250 297 selected_plot = self.plots[self.graph.selected_plottable] 251 298 id = wx.NewId() 252 s licerpop.Append(id, '&Linear fit')299 self._slicerpop.Append(id, '&Linear fit') 253 300 wx.EVT_MENU(self, id, self.onFitting) 254 s licerpop.AppendSeparator()255 id = wx.NewId() 256 s licerpop.Append(id, '&Change scale')301 self._slicerpop.AppendSeparator() 302 id = wx.NewId() 303 self._slicerpop.Append(id, '&Change scale') 257 304 wx.EVT_MENU(self, id, self._onProperties) 258 305 id = wx.NewId() 259 s licerpop.Append(id, '&Reset Graph')306 self._slicerpop.Append(id, '&Reset Graph') 260 307 wx.EVT_MENU(self, id, self.onResetGraph) 261 308 pos = event.GetPosition() 262 309 pos = self.ScreenToClient(pos) 263 self.PopupMenu(s licerpop, pos)310 self.PopupMenu(self._slicerpop, pos) 264 311 265 312 def _on_remove_errors(self, evt):
Note: See TracChangeset
for help on using the changeset viewer.