Changeset b40ad40 in sasview for src/sas/guiframe/local_perspectives/plotting/SimplePlot.py
- Timestamp:
- Mar 5, 2015 4:53:03 PM (10 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:
- c4f6851
- Parents:
- c039589
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/guiframe/local_perspectives/plotting/SimplePlot.py
r79492222 rb40ad40 3 3 """ 4 4 import wx 5 from sas.guiframe.local_perspectives.plotting.Plotter2D import ModelPanel2D \ 6 as PlotPanel 5 from sas.guiframe.local_perspectives.plotting.Plotter2D import ModelPanel2D as PlotPanel 7 6 from sas.plottools.toolbar import NavigationToolBar 8 7 from sas.plottools.plottables import Graph 9 8 from sas.guiframe.utils import PanelMenu 10 11 class SimplePlotPanel(PlotPanel): 9 from sas.guiframe.events import StatusEvent 10 11 class SimplePlotPanel(PlotPanel): 12 12 """ 13 13 PlotPanel for 1d and 2d 14 """ 14 """ 15 15 _window_caption = 'Simple Plot' 16 def __init__(self, parent, id=-1, color =None,16 def __init__(self, parent, id=-1, color=None, 17 17 dpi=None, style=wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): 18 18 """ … … 22 22 23 23 self.SetColor(wx.WHITE) 24 24 25 25 self.toolbar = NavigationToolBar(parent=self, canvas=self.canvas) 26 26 self.toolbar.Show(False) 27 27 self.scale = parent.scale 28 28 self.window_caption = self._window_caption 29 29 30 30 def draw(self): 31 31 """ … … 34 34 self.canvas.set_resizing(self.resizing) 35 35 self.canvas.draw() 36 36 37 37 def add_toolbar(self): 38 38 """ 39 39 """ 40 pass 41 40 pass 41 42 42 def onContextMenu(self, event): 43 43 """ 44 44 2D plot context menu 45 45 46 46 :param event: wx context event 47 47 48 48 """ 49 49 slicerpop = PanelMenu() 50 50 slicerpop.set_plots(self.plots) 51 51 slicerpop.set_graph(self.graph) 52 53 id = wx.NewId()54 slicerpop.Append( id, '&Save Image')55 wx.EVT_MENU(self, id, self.onSaveImage)56 57 id = wx.NewId()58 slicerpop.Append( id,'&Print Image', 'Print image')59 wx.EVT_MENU(self, id, self.onPrint)60 61 id = wx.NewId()62 slicerpop.Append( id,'&Print Preview', 'Print preview')63 wx.EVT_MENU(self, id, self.onPrinterPreview)64 65 id = wx.NewId()66 slicerpop.Append( id, '&Copy to Clipboard', 'Copy to the clipboard')67 wx.EVT_MENU(self, id, self.OnCopyFigureMenu)52 53 wx_id = wx.NewId() 54 slicerpop.Append(wx_id, '&Save Image') 55 wx.EVT_MENU(self, wx_id, self.onSaveImage) 56 57 wx_id = wx.NewId() 58 slicerpop.Append(wx_id, '&Print Image', 'Print image') 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 65 wx_id = wx.NewId() 66 slicerpop.Append(wx_id, '&Copy to Clipboard', 'Copy to the clipboard') 67 wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) 68 68 69 69 if self.dimension != 3: 70 70 slicerpop.AppendSeparator() 71 id = wx.NewId()72 slicerpop.Append( id, '&Toggle Grid On/Off', 'Toggle Grid On/Off')73 wx.EVT_MENU(self, id, self.on_grid_onoff)71 wx_id = wx.NewId() 72 slicerpop.Append(wx_id, '&Toggle Grid On/Off', 'Toggle Grid On/Off') 73 wx.EVT_MENU(self, wx_id, self.on_grid_onoff) 74 74 75 75 if self.data.__class__.__name__ == 'Data1D': 76 76 slicerpop.AppendSeparator() 77 id = wx.NewId()78 slicerpop.Append( id, '&Change Scale')79 wx.EVT_MENU(self, id, self._onProperties)77 wx_id = wx.NewId() 78 slicerpop.Append(wx_id, '&Change Scale') 79 wx.EVT_MENU(self, wx_id, self._onProperties) 80 80 elif self.data2D.__class__.__name__ == 'Data2D': 81 81 slicerpop.AppendSeparator() 82 id = wx.NewId()83 slicerpop.Append( id, '&Toggle Linear/Log Scale')84 wx.EVT_MENU(self, id, self._onToggleScale)85 82 wx_id = wx.NewId() 83 slicerpop.Append(wx_id, '&Toggle Linear/Log Scale') 84 wx.EVT_MENU(self, wx_id, self._onToggleScale) 85 86 86 try: 87 87 pos_evt = event.GetPosition() … … 92 92 self.PopupMenu(slicerpop, pos) 93 93 if self.scale != None: 94 self.parent.scale2d = self.scale 95 94 self.parent.scale2d = self.scale 95 96 96 def on_grid_onoff(self, event): 97 97 """ … … 99 99 """ 100 100 switch = (not self.grid_on) 101 self.onGridOnOff(switch) 102 101 self.onGridOnOff(switch) 102 103 103 def onLeftDown(self, event): 104 104 """ 105 105 left button down and ready to drag 106 106 107 107 """ 108 108 # Check that the LEFT button was pressed … … 120 120 wx.PostEvent(self.parent, StatusEvent(status=self.position)) 121 121 except: 122 self.position = None 123 124 def _OnReSize(self, event): 122 self.position = None 123 124 def _OnReSize(self, event): 125 125 """ 126 126 On response of the resize of a panel, set axes_visiable False … … 134 134 135 135 # Ready for another event 136 # Do not remove this Skip. 136 # Do not remove this Skip. 137 137 # Otherwise it will get runtime error on wx>=2.9. 138 event.Skip() 138 event.Skip() 139 139 # set the resizing flag 140 140 self.canvas.set_resizing(self.resizing) … … 143 143 self.size, _ = self.GetClientSizeTuple() 144 144 self.SetSizer(self.sizer) 145 145 146 146 def on_set_focus(self, event): 147 147 """ … … 149 149 """ 150 150 pass 151 151 152 152 def on_kill_focus(self, event): 153 153 """ … … 155 155 """ 156 156 pass 157 157 158 158 def show_plot(self, plot): 159 159 """ … … 182 182 self.graph.yaxis(_yaxis, _yunit) 183 183 self.xaxis(_xaxis, _xunit) 184 self.yaxis(_yaxis, _yunit) 184 self.yaxis(_yaxis, _yunit) 185 185 self.set_xscale(self.xscale) 186 self.set_yscale(self.yscale) 187 self.graph.render(self) 188 186 self.set_yscale(self.yscale) 187 self.graph.render(self) 188 189 189 class PlotFrame(wx.Frame): 190 190 """ 191 191 Frame for simple plot 192 192 """ 193 def __init__(self, parent, id, title, scale='log_{10}', 194 size=wx.Size(550, 470)): 193 def __init__(self, parent, id, title, scale='log_{10}', 194 size=wx.Size(550, 470)): 195 195 """ 196 196 comment … … 199 199 # Initialize the Frame object 200 200 wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, size) 201 201 202 202 # Panel for 1D plot 203 203 self.parent = parent … … 214 214 """ 215 215 tsize = (13, 13) 216 save_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS, wx.ART_TOOLBAR, 217 tsize) 218 quit_bmp = wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_TOOLBAR, 219 tsize) 220 print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR, 221 tsize) 222 preview_bmp = wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_TOOLBAR, 223 tsize) 224 copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR, 225 tsize) 216 save_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS, wx.ART_TOOLBAR, tsize) 217 quit_bmp = wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_TOOLBAR, tsize) 218 print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR, tsize) 219 preview_bmp = wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_TOOLBAR, tsize) 220 copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR, tsize) 226 221 menu_bar = wx.MenuBar() 227 228 menu = wx.Menu() 222 223 menu = wx.Menu() 229 224 id = wx.NewId() 230 225 item = wx.MenuItem(menu, id, "&Save Image") … … 244 239 menu.AppendItem(item) 245 240 wx.EVT_MENU(self, id, self.on_print_preview) 246 241 247 242 menu.AppendSeparator() 248 243 id = wx.NewId() … … 253 248 menu_bar.Append(menu, "&File") 254 249 wx.EVT_MENU(self, id, self.on_close) 255 250 256 251 menu_edit = wx.Menu() 257 252 id = wx.NewId() … … 260 255 menu_edit.AppendItem(item) 261 256 wx.EVT_MENU(self, id, self.on_copy_image) 262 257 263 258 menu_bar.Append(menu_edit, "&Edit") 264 259 self.menu_bar = menu_bar … … 269 264 un focusing 270 265 """ 271 pass 272 266 pass 267 273 268 def add_plot(self, plot): 274 269 """ … … 278 273 plotpanel.scale = self.scale 279 274 plotpanel.show_plot(plot) 280 275 281 276 def set_schedule_full_draw(self, panel, func): 282 277 """ 283 278 """ 284 279 self.plotpanel.resizing = False 285 280 286 281 def im_show(self, img): 287 282 """ … … 290 285 """ 291 286 self.plotpanel.subplot.imshow(img) 292 293 def set_schedule(self, schedule=False): 287 288 def set_schedule(self, schedule=False): 294 289 """ 295 290 """ 296 291 #Not implemented 297 292 298 293 def disable_app_menu(self, panel): 299 294 """ 300 295 """ 301 #Not implemented302 303 def get_current_context_menu(self, plotpanel):304 """305 """306 296 #Not implemented 307 297 298 def get_current_context_menu(self, plotpanel): 299 """ 300 """ 301 #Not implemented 302 308 303 def on_save_file(self, event): 309 304 """ … … 317 312 """ 318 313 self.plotpanel.onPrint(event) 319 314 320 315 def on_print_preview(self, event): 321 316 """ … … 329 324 """ 330 325 self.plotpanel.OnCopyFigureMenu(event) 331 326 332 327 def on_close(self, event): 333 328 """ 334 On Close 329 On Close 335 330 """ 336 331 try: … … 339 334 except: 340 335 self.Destroy() 341 336
Note: See TracChangeset
for help on using the changeset viewer.