Changeset 090e07e in sasview
- Timestamp:
- Mar 5, 2015 4:06:18 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:
- c039589
- Parents:
- 7d56795
- Location:
- src/sas/guiframe/local_perspectives/plotting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/guiframe/local_perspectives/plotting/Plotter1D.py
r79492222 r090e07e 1 1 2 2 ################################################################################ 3 # This software was developed by the University of Tennessee as part of the4 # Distributed Data Analysis of Neutron Scattering Experiments (DANSE)5 # project funded by the US National Science Foundation.3 # This software was developed by the University of Tennessee as part of the 4 # Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 5 # project funded by the US National Science Foundation. 6 6 # 7 # See the license text in license.txt7 # See the license text in license.txt 8 8 # 9 # copyright 2008, University of Tennessee9 # copyright 2008, University of Tennessee 10 10 ################################################################################ 11 11 … … 15 15 import math 16 16 import numpy 17 17 import logging 18 18 from sas.plottools.PlotPanel import PlotPanel 19 from sas.guiframe.events import StatusEvent 19 from sas.guiframe.events import StatusEvent 20 20 from sas.guiframe.events import PanelOnFocusEvent 21 21 from sas.guiframe.utils import PanelMenu … … 42 42 Plot panel for use with the GUI manager 43 43 """ 44 44 45 45 ## Internal name for the AUI manager 46 46 window_name = "plotpanel" … … 52 52 ## Group ID 53 53 group_id = None 54 55 def __init__(self, parent, id=-1, color =None,54 55 def __init__(self, parent, id=-1, color=None, 56 56 dpi=None, style=wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): 57 57 PlotPanel.__init__(self, parent, id=id, style=style, **kwargs) … … 64 64 self.plots = {} 65 65 self.frame = None 66 # context menu66 # context menu 67 67 self._slicerpop = None 68 68 69 69 self._available_data = [] 70 70 self._menu_add_ids = [] … … 75 75 self.is_xtick = False 76 76 self.is_ytick = False 77 77 78 78 self.hide_menu = None 79 79 ## Unique ID (from gui_manager) … … 81 81 self.x_size = None 82 82 ## Default locations 83 # self._default_save_location = os.getcwd()84 self.size = None 85 self.vl_ind = 0 86 ## Graph 87 # self.graph = Graph()83 # self._default_save_location = os.getcwd() 84 self.size = None 85 self.vl_ind = 0 86 ## Graph 87 # self.graph = Graph() 88 88 self.graph.xaxis("\\rm{Q}", 'A^{-1}') 89 89 self.graph.yaxis("\\rm{Intensity} ", "cm^{-1}") 90 90 self.graph.render(self) 91 91 self.cursor_id = None 92 92 93 93 # In resizing event 94 94 self.resizing = False 95 95 self.canvas.set_resizing(self.resizing) 96 96 self.Bind(wx.EVT_SIZE, self._OnReSize) 97 self._add_more_tool()98 97 self.parent.SetFocus() 99 100 98 99 101 100 def get_symbol_label(self): 102 101 """ … … 139 138 _labels['Step'] = i 140 139 return _labels 141 140 142 141 def get_color_label(self): 143 142 """ … … 161 160 return _labels 162 161 163 162 164 163 def set_data(self, list=None): 165 164 """ 166 165 """ 167 166 pass 168 167 169 168 def _reset(self): 170 169 """ 171 170 Resets internal data and graph 172 """ 171 """ 173 172 self.graph.reset() 174 self.plots 173 self.plots = {} 175 174 self.is_zoomed = False 176 177 def _OnReSize(self, event): 175 176 def _OnReSize(self, event): 178 177 """ 179 178 On response of the resize of a panel, set axes_visiable False … … 196 195 # Ready for another event 197 196 # Do not remove this Skip. Otherwise it will get runtime error on wx>=2.9. 198 event.Skip() 197 event.Skip() 199 198 # set the resizing flag 200 199 self.resizing = True … … 205 204 self.size, _ = self.GetClientSizeTuple() 206 205 self.SetSizer(self.sizer) 207 wx.CallAfter(self.parent.disable_app_menu, self)208 206 wx.CallAfter(self.parent.disable_app_menu, self) 207 209 208 def on_plot_qrange(self, event=None): 210 209 """ … … 213 212 if event == None: 214 213 return 215 event.Skip() 214 event.Skip() 216 215 active_ctrl = event.active 217 216 if active_ctrl == None: … … 225 224 self.ly = [] 226 225 for ind_ly in range(len(colors)): 227 self.ly.append(self.subplot.axvline(color=colors[ind_ly], 226 self.ly.append(self.subplot.axvline(color=colors[ind_ly], 228 227 lw=2.5, alpha=0.7)) 229 self.ly[ind_ly].set_rasterized(True) 228 self.ly[ind_ly].set_rasterized(True) 230 229 try: 231 230 # Display x,y in the status bar if possible … … 235 234 wx.PostEvent(self.parent, StatusEvent(status=position)) 236 235 except: 237 pass236 logging.error(sys.exc_value) 238 237 if not event.leftdown: 239 # text event 238 # text event 240 239 try: 241 240 is_moved = False … … 247 246 is_moved = True 248 247 if is_moved: 249 self.canvas.draw() 248 self.canvas.draw() 250 249 except: 251 pass252 event.Skip() 250 logging.error(sys.exc_value) 251 event.Skip() 253 252 return 254 253 self.q_ctrl = ctrl 255 try: 256 pos_x_min = float(self.q_ctrl[0].GetValue()) 257 except: 258 pos_x_min = xmin 259 try: 260 pos_x_max = float(self.q_ctrl[1].GetValue()) 261 except: 262 pos_x_max = xmax 254 pos_x_min = float(self.q_ctrl[0].GetValue()) 255 pos_x_max = float(self.q_ctrl[1].GetValue()) 263 256 pos_x = [pos_x_min, pos_x_max] 264 257 for ind_ly in range(len(colors)): … … 268 261 else: 269 262 self.q_ctrl = None 270 263 271 264 def get_data_xy_vals(self, xval): 272 265 """ … … 283 276 except: 284 277 return None 285 278 286 279 def _find_nearest(self, array, value): 287 280 """ … … 292 285 """ 293 286 idx = (numpy.abs(array - value)).argmin() 294 return int(idx) #array.flat[idx]295 287 return int(idx) # array.flat[idx] 288 296 289 def _check_line_positions(self, pos_x=None, nop=None): 297 290 """ … … 316 309 self.q_ctrl[0].SetValue(str(pos_x)) 317 310 self.q_ctrl[1].SetBackgroundColour('pink') 318 311 319 312 def _get_cusor_lines(self, event): 320 313 """ 321 314 Revmove or switch cursor line if drawn 322 315 :Param event: LeftClick mouse event 323 """ 316 """ 324 317 ax = event.inaxes 325 318 if hasattr(event, "action"): … … 330 323 self.canvas.draw() 331 324 self.q_ctrl = None 332 return 325 return 333 326 if self.ly != None and event.xdata != None: 334 327 # Selecting a new line if cursor lines are displayed already … … 339 332 self.vl_ind = 1 340 333 else: 341 self.vl_ind = 0 342 334 self.vl_ind = 0 335 343 336 def cusor_line(self, event): 344 337 """ … … 347 340 if self.q_ctrl == None: 348 341 return 349 # release a q range vline342 # release a q range vline 350 343 if self.ly != None and not self.leftdown: 351 344 for ly in self.ly: … … 358 351 end_drag = event.action != 'drag' and event.xdata != None 359 352 nop = len(self.plots) 360 pos_x, pos_y= float(event.xdata), float(event.ydata)353 pos_x, _ = float(event.xdata), float(event.ydata) 361 354 try: 362 355 ly = self.ly … … 370 363 vl_ind = self.vl_ind 371 364 x_data = self.plots[self.cursor_id].x 372 y_data = self.plots[self.cursor_id].y373 365 xmin = x_data.min() 374 366 xmax = x_data.max() 375 367 indx = self._find_nearest(x_data, pos_x) 376 #pos_x = self._find_nearest(x_data, pos_x)377 #indx = int(numpy.searchsorted(x_data, [pos_x])[0])378 368 # Need to hold LeftButton to drag 379 369 if end_drag: 380 370 if event.button: 381 371 self._check_line_positions(pos_x, nop) 382 return 372 return 383 373 if indx >= len(x_data): 384 374 indx = len(x_data) - 1 385 375 pos_x = x_data[indx] 386 pos_y = y_data[indx]387 376 if xmin == ly1x: 388 377 vl_ind = 1 … … 399 388 self.q_ctrl[vl_ind].SetValue(str(pos_x)) 400 389 except: 401 pass402 390 logging.error(sys.exc_value) 391 403 392 def set_resizing(self, resizing=False): 404 393 """ … … 406 395 """ 407 396 self.resizing = resizing 408 # self.canvas.set_resizing(resizing)409 410 def schedule_full_draw(self, func='append'): 397 # self.canvas.set_resizing(resizing) 398 399 def schedule_full_draw(self, func='append'): 411 400 """ 412 401 Put self in schedule to full redraw list … … 414 403 # append/del this panel in the schedule list 415 404 self.parent.set_schedule_full_draw(self, func) 416 417 405 418 406 def remove_data_by_id(self, id): … … 421 409 """ 422 410 if id in self.plots.keys(): 423 data = 411 data = self.plots[id] 424 412 self.graph.delete(data) 425 413 data_manager = self._manager.parent.get_data_manager() 426 414 data_list, theory_list = data_manager.get_by_id(id_list=[id]) 427 415 428 416 if id in data_list.keys(): 429 417 data = data_list[id] 430 418 if id in theory_list.keys(): 431 419 data = theory_list[id] 432 420 433 421 del self.plots[id] 434 422 self.graph.render(self) 435 self.subplot.figure.canvas.draw_idle() 423 self.subplot.figure.canvas.draw_idle() 436 424 if len(self.graph.plottables) == 0: 437 # onRemove: graph is empty must be the panel must be destroyed425 # onRemove: graph is empty must be the panel must be destroyed 438 426 self.parent.delete_panel(self.uid) 439 427 440 428 def plot_data(self, data): 441 429 """ 442 430 Data is ready to be displayed 443 431 444 432 :param event: data event 445 433 """ … … 448 436 plot_keys = self.plots.keys() 449 437 if data.id in plot_keys: 450 # Recover panel prop.s438 # Recover panel prop.s 451 439 xlo, xhi = self.subplot.get_xlim() 452 440 ylo, yhi = self.subplot.get_ylim() … … 466 454 self._onEVT_FUNC_PROPERTY() 467 455 except Exception, exc: 468 wx.PostEvent(self.parent, StatusEvent(status=\469 "Plotting Error: %s"% str(exc), info="error"))456 wx.PostEvent(self.parent, 457 StatusEvent(status="Plotting Error: %s" % str(exc), info="error")) 470 458 if self.is_zoomed: 471 459 # Recover the x,y limits 472 self.subplot.set_xlim((xlo, xhi)) 473 self.subplot.set_ylim((ylo, yhi)) 460 self.subplot.set_xlim((xlo, xhi)) 461 self.subplot.set_ylim((ylo, yhi)) 474 462 else: 475 463 self.plots[data.id] = data 476 self.graph.add(self.plots[data.id]) 464 self.graph.add(self.plots[data.id]) 477 465 data.zorder = len(plot_keys) 478 466 ## Set the view scale for all plots … … 482 470 # MAC: forcing to plot 2D avg 483 471 self.canvas._onDrawIdle() 484 except Exception, exc:472 except Exception, exc: 485 473 wx.PostEvent(self.parent, StatusEvent(status=\ 486 "Plotting Error: %s" % str(exc), info="error"))474 "Plotting Error: %s" % str(exc), info="error")) 487 475 self.toolbar.update() 488 476 self.is_zoomed = False 489 477 490 478 def draw_plot(self): 491 479 """ 492 480 Draw plot 493 481 """ 494 self.draw() 495 496 def onLeftDown(self, event):497 """ 482 self.draw() 483 484 def onLeftDown(self, event): 485 """ 498 486 left button down and ready to drag 499 487 Display the position of the mouse on the statusbar 500 488 """ 501 # self.parent.set_plot_unfocus()489 # self.parent.set_plot_unfocus() 502 490 self._get_cusor_lines(event) 503 491 ax = event.inaxes … … 505 493 if ax != None: 506 494 try: 507 pos_x = float(event.xdata) # / size_x508 pos_y = float(event.ydata) # / size_y509 pos_x = "%8.3g" % pos_x510 pos_y = "%8.3g" % pos_y495 pos_x = float(event.xdata) # / size_x 496 pos_y = float(event.ydata) # / size_y 497 pos_x = "%8.3g" % pos_x 498 pos_y = "%8.3g" % pos_y 511 499 self.position = str(pos_x), str(pos_y) 512 500 wx.PostEvent(self.parent, StatusEvent(status=self.position)) 513 501 except: 514 self.position = None 502 self.position = None 515 503 # unfocus all 516 self.parent.set_plot_unfocus() 517 # post nd event to notify guiframe that this panel is on focus504 self.parent.set_plot_unfocus() 505 # post nd event to notify guiframe that this panel is on focus 518 506 wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self)) 519 507 520 508 521 509 def _ontoggle_hide_error(self, event): 522 510 """ … … 524 512 """ 525 513 menu = event.GetEventObject() 526 id = event.GetId()527 self.set_selected_from_menu(menu, id)514 event_id = event.GetId() 515 self.set_selected_from_menu(menu, event_id) 528 516 # Check zoom 529 517 xlo, xhi = self.subplot.get_xlim() … … 537 525 ## increment graph color 538 526 self.graph.render(self) 539 self.subplot.figure.canvas.draw_idle() 527 self.subplot.figure.canvas.draw_idle() 540 528 if self.is_zoomed: 541 529 # Recover the x,y limits 542 self.subplot.set_xlim((xlo, xhi)) 543 self.subplot.set_ylim((ylo, yhi)) 544 545 530 self.subplot.set_xlim((xlo, xhi)) 531 self.subplot.set_ylim((ylo, yhi)) 532 533 546 534 def _onRemove(self, event): 547 535 """ 548 Remove a plottable from the graph and render the graph 549 536 Remove a plottable from the graph and render the graph 537 550 538 :param event: Menu event 551 539 552 540 """ 553 541 menu = event.GetEventObject() 554 id = event.GetId()555 self.set_selected_from_menu(menu, id)542 event_id = event.GetId() 543 self.set_selected_from_menu(menu, event_id) 556 544 ## Check if there is a selected graph to remove 557 545 if self.graph.selected_plottable in self.plots.keys(): 558 selected_plot = self.plots[self.graph.selected_plottable] 559 id = self.graph.selected_plottable 560 self.remove_data_by_id(id) 561 546 graph_id = self.graph.selected_plottable 547 self.remove_data_by_id(graph_id) 548 562 549 def onContextMenu(self, event): 563 550 """ 564 551 1D plot context menu 565 552 566 553 :param event: wx context event 567 554 568 555 """ 569 556 self._slicerpop = PanelMenu() 570 557 self._slicerpop.set_plots(self.plots) 571 self._slicerpop.set_graph(self.graph) 572 if not self.graph.selected_plottable in self.plots: 558 self._slicerpop.set_graph(self.graph) 559 if not self.graph.selected_plottable in self.plots: 573 560 # Various plot options 574 id = wx.NewId()575 self._slicerpop.Append( id, '&Save Image', 'Save image as PNG')576 wx.EVT_MENU(self, id, self.onSaveImage)577 id = wx.NewId()578 self._slicerpop.Append( id, '&Print Image', 'Print image ')579 wx.EVT_MENU(self, id, self.onPrint)580 id = wx.NewId()581 self._slicerpop.Append( id, '&Print Preview', 'Print preview')582 wx.EVT_MENU(self, id, self.onPrinterPreview)583 584 id = wx.NewId()585 self._slicerpop.Append( id, '&Copy to Clipboard',561 wx_id = wx.NewId() 562 self._slicerpop.Append(wx_id, '&Save Image', 'Save image as PNG') 563 wx.EVT_MENU(self, wx_id, self.onSaveImage) 564 wx_id = wx.NewId() 565 self._slicerpop.Append(wx_id, '&Print Image', 'Print image ') 566 wx.EVT_MENU(self, wx_id, self.onPrint) 567 wx_id = wx.NewId() 568 self._slicerpop.Append(wx_id, '&Print Preview', 'Print preview') 569 wx.EVT_MENU(self, wx_id, self.onPrinterPreview) 570 571 wx_id = wx.NewId() 572 self._slicerpop.Append(wx_id, '&Copy to Clipboard', 586 573 'Copy to the clipboard') 587 wx.EVT_MENU(self, id, self.OnCopyFigureMenu)588 574 wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) 575 589 576 self._slicerpop.AppendSeparator() 590 577 591 578 for plot in self.plots.values(): 592 # title = plot.title579 # title = plot.title 593 580 name = plot.name 594 581 plot_menu = wx.Menu() … … 598 585 if plot != self.plots[self.graph.selected_plottable]: 599 586 continue 600 601 id = wx.NewId()602 plot_menu.Append( id, "&DataInfo", name)603 wx.EVT_MENU(self, id, self. _onDataShow)604 id = wx.NewId()605 plot_menu.Append( id, "&Save Points as a File", name)606 wx.EVT_MENU(self, id, self._onSave)587 588 wx_id = wx.NewId() 589 plot_menu.Append(wx_id, "&DataInfo", name) 590 wx.EVT_MENU(self, wx_id, self. _onDataShow) 591 wx_id = wx.NewId() 592 plot_menu.Append(wx_id, "&Save Points as a File", name) 593 wx.EVT_MENU(self, wx_id, self._onSave) 607 594 plot_menu.AppendSeparator() 608 609 # add menu of other plugins595 596 # add menu of other plugins 610 597 item_list = self.parent.get_current_context_menu(self) 611 598 612 599 if (not item_list == None) and (not len(item_list) == 0): 613 600 for item in item_list: 614 601 615 602 try: 616 id = wx.NewId()617 plot_menu.Append( id, item[0], name)618 wx.EVT_MENU(self, id, item[2])603 wx_id = wx.NewId() 604 plot_menu.Append(wx_id, item[0], name) 605 wx.EVT_MENU(self, wx_id, item[2]) 619 606 except: 620 607 msg = "ModelPanel1D.onContextMenu: " 621 608 msg += "bad menu item %s" % sys.exc_value 622 609 wx.PostEvent(self.parent, StatusEvent(status=msg)) 623 pass624 610 plot_menu.AppendSeparator() 625 626 if self.parent.ClassName.count('wxDialog') == 0: 627 id = wx.NewId()628 plot_menu.Append( id, '&Linear Fit', name)629 wx.EVT_MENU(self, id, self.onFitting)611 612 if self.parent.ClassName.count('wxDialog') == 0: 613 wx_id = wx.NewId() 614 plot_menu.Append(wx_id, '&Linear Fit', name) 615 wx.EVT_MENU(self, wx_id, self.onFitting) 630 616 plot_menu.AppendSeparator() 631 632 id = wx.NewId()633 plot_menu.Append( id, "Remove", name)634 wx.EVT_MENU(self, id, self._onRemove)617 618 wx_id = wx.NewId() 619 plot_menu.Append(wx_id, "Remove", name) 620 wx.EVT_MENU(self, wx_id, self._onRemove) 635 621 if not plot.is_data: 636 id = wx.NewId() 637 plot_menu.Append(id, '&Freeze', name) 638 wx.EVT_MENU(self, id, self.onFreeze) 639 plot_menu.AppendSeparator() 640 symbol_menu = wx.Menu() 641 622 wx_id = wx.NewId() 623 plot_menu.Append(wx_id, '&Freeze', name) 624 wx.EVT_MENU(self, wx_id, self.onFreeze) 625 plot_menu.AppendSeparator() 626 642 627 if plot.is_data: 643 id = wx.NewId() 644 self.hide_menu = plot_menu.Append(id, 645 "Hide Error Bar", name) 646 628 wx_id = wx.NewId() 629 self.hide_menu = plot_menu.Append(wx_id, "Hide Error Bar", name) 630 647 631 if plot.dy is not None and plot.dy != []: 648 if plot.hide_error 632 if plot.hide_error: 649 633 self.hide_menu.SetText('Show Error Bar') 650 634 else: … … 652 636 else: 653 637 self.hide_menu.Enable(False) 654 wx.EVT_MENU(self, id, self._ontoggle_hide_error)655 638 wx.EVT_MENU(self, wx_id, self._ontoggle_hide_error) 639 656 640 plot_menu.AppendSeparator() 657 641 658 id = wx.NewId() 659 plot_menu.Append(id, '&Modify Plot Property', name) 660 wx.EVT_MENU(self, id, self.createAppDialog) 661 662 663 664 id = wx.NewId() 665 #plot_menu.SetTitle(name) 666 self._slicerpop.AppendMenu(id, '&%s'% name, plot_menu) 642 wx_id = wx.NewId() 643 plot_menu.Append(wx_id, '&Modify Plot Property', name) 644 wx.EVT_MENU(self, wx_id, self.createAppDialog) 645 wx_id = wx.NewId() 646 # plot_menu.SetTitle(name) 647 self._slicerpop.AppendMenu(wx_id, '&%s' % name, plot_menu) 667 648 # Option to hide 668 # TODO: implement functionality to hide a plottable (legend click)669 if not self.graph.selected_plottable in self.plots: 649 # TODO: implement functionality to hide a plottable (legend click) 650 if not self.graph.selected_plottable in self.plots: 670 651 self._slicerpop.AppendSeparator() 671 652 loc_menu = wx.Menu() 672 653 for label in self._loc_labels: 673 id = wx.NewId()674 loc_menu.Append( id, str(label), str(label))675 wx.EVT_MENU(self, id, self.onChangeLegendLoc)676 677 id = wx.NewId()678 self._slicerpop.Append( id, '&Modify Graph Appearance',654 wx_id = wx.NewId() 655 loc_menu.Append(wx_id, str(label), str(label)) 656 wx.EVT_MENU(self, wx_id, self.onChangeLegendLoc) 657 658 wx_id = wx.NewId() 659 self._slicerpop.Append(wx_id, '&Modify Graph Appearance', 679 660 'Modify graph appearance') 680 wx.EVT_MENU(self, id, self.modifyGraphAppearance)661 wx.EVT_MENU(self, wx_id, self.modifyGraphAppearance) 681 662 self._slicerpop.AppendSeparator() 682 663 683 664 684 665 if self.position != None: 685 id = wx.NewId()686 self._slicerpop.Append( id, '&Add Text')687 wx.EVT_MENU(self, id, self._on_addtext)688 id = wx.NewId()689 self._slicerpop.Append( id, '&Remove Text')690 wx.EVT_MENU(self, id, self._on_removetext)666 wx_id = wx.NewId() 667 self._slicerpop.Append(wx_id, '&Add Text') 668 wx.EVT_MENU(self, wx_id, self._on_addtext) 669 wx_id = wx.NewId() 670 self._slicerpop.Append(wx_id, '&Remove Text') 671 wx.EVT_MENU(self, wx_id, self._on_removetext) 691 672 self._slicerpop.AppendSeparator() 692 id = wx.NewId()693 self._slicerpop.Append( id, '&Change Scale')694 wx.EVT_MENU(self, id, self._onProperties)673 wx_id = wx.NewId() 674 self._slicerpop.Append(wx_id, '&Change Scale') 675 wx.EVT_MENU(self, wx_id, self._onProperties) 695 676 self._slicerpop.AppendSeparator() 696 id = wx.NewId()697 self._slicerpop.Append( id, '&Reset Graph Range')698 wx.EVT_MENU(self, id, self.onResetGraph)699 700 if self.parent.ClassName.count('wxDialog') == 0: 677 wx_id = wx.NewId() 678 self._slicerpop.Append(wx_id, '&Reset Graph Range') 679 wx.EVT_MENU(self, wx_id, self.onResetGraph) 680 681 if self.parent.ClassName.count('wxDialog') == 0: 701 682 self._slicerpop.AppendSeparator() 702 id = wx.NewId()703 self._slicerpop.Append( id, '&Window Title')704 wx.EVT_MENU(self, id, self.onChangeCaption)683 wx_id = wx.NewId() 684 self._slicerpop.Append(wx_id, '&Window Title') 685 wx.EVT_MENU(self, wx_id, self.onChangeCaption) 705 686 try: 706 687 pos_evt = event.GetPosition() … … 710 691 pos = (pos_x, pos_y + 5) 711 692 self.PopupMenu(self._slicerpop, pos) 712 693 713 694 def onFreeze(self, event): 714 695 """ … … 716 697 """ 717 698 menu = event.GetEventObject() 718 id = event.GetId()719 self.set_selected_from_menu(menu, id)699 wx_id = event.GetId() 700 self.set_selected_from_menu(menu, wx_id) 720 701 plot = self.plots[self.graph.selected_plottable] 721 702 self.parent.onfreeze([plot.id]) 722 723 703 724 704 def _onSave(self, evt): 725 705 """ 726 706 Save a data set to a text file 727 707 728 708 :param evt: Menu event 729 709 730 710 """ 731 711 menu = evt.GetEventObject() 732 id = evt.GetId()733 self.set_selected_from_menu(menu, id)712 event_id = evt.GetId() 713 self.set_selected_from_menu(menu, event_id) 734 714 data = self.plots[self.graph.selected_plottable] 735 715 default_name = data.label … … 740 720 self.parent.save_data1d(data, default_name) 741 721 742 743 722 def _onDataShow(self, evt): 744 723 """ 745 724 Show the data set in text 746 725 747 726 :param evt: Menu event 748 727 749 728 """ 750 729 menu = evt.GetEventObject() 751 id = evt.GetId()752 self.set_selected_from_menu(menu, id)730 event_id = evt.GetId() 731 self.set_selected_from_menu(menu, event_id) 753 732 data = self.plots[self.graph.selected_plottable] 754 733 default_name = data.label 755 734 if default_name.count('.') > 0: 756 735 default_name = default_name.split('.')[0] 757 # default_name += "_out"736 # default_name += "_out" 758 737 if self.parent != None: 759 738 self.parent.show_data1d(data, default_name) 760 761 def _add_more_tool(self): 762 """ 763 Add refresh, add/hide button in the tool bar 764 """ 765 return 766 if self.parent.__class__.__name__ != 'ViewerFrame': 767 return 768 self.toolbar.AddSeparator() 769 id_hide = wx.NewId() 770 hide = wx.Bitmap(GUIFRAME_ICON.HIDE_ID_PATH, wx.BITMAP_TYPE_PNG) 771 self.toolbar.AddSimpleTool(id_hide, hide, 'Hide', 'Hide') 772 self.toolbar.Realize() 773 wx.EVT_TOOL(self, id_hide, self._on_hide) 774 739 775 740 def _on_hide(self, event): 776 741 """ 777 742 Hides the plot when button is pressed 778 """ 743 """ 779 744 if self.parent is not None: 780 745 self.parent.hide_panel(self.uid) … … 786 751 ID = self.uid 787 752 self.parent.delete_panel(ID) 788 753 789 754 def createAppDialog(self, event): 790 755 """ … … 792 757 """ 793 758 menu = event.GetEventObject() 794 id = event.GetId()795 self.set_selected_from_menu(menu, id)759 event_id = event.GetId() 760 self.set_selected_from_menu(menu, event_id) 796 761 self.appearance_selected_plot = \ 797 762 self.plots[self.graph.selected_plottable] … … 809 774 icon = self.parent.GetIcon() 810 775 self.appD.SetIcon(icon) 811 self.appD.set_defaults(float(curr_size), int(curr_color), 812 str(appearanceDialog.find_key(self.get_symbol_label(),813 int(curr_symbol))), curr_label)814 self.appD.Bind(wx.EVT_CLOSE, self.on_AppDialog_close) 776 self.appD.set_defaults(float(curr_size), int(curr_color), 777 str(appearanceDialog.find_key(self.get_symbol_label(), 778 int(curr_symbol))), curr_label) 779 self.appD.Bind(wx.EVT_CLOSE, self.on_AppDialog_close) 815 780 816 781 def on_AppDialog_close(self, event): … … 818 783 on_Modify Plot Property_close 819 784 """ 820 if(self.appD.okay_clicked == True): 821 # returns (size,color,symbol,datalabel) 822 info = self.appD.get_current_values() 785 if self.appD.okay_clicked == True: 786 info = self.appD.get_current_values() 823 787 self.appearance_selected_plot.custom_color = \ 824 788 self._color_labels[info[1].encode('ascii', 'ignore')] … … 826 790 self.appearance_selected_plot.markersize = float(info[0]) 827 791 self.appearance_selected_plot.symbol = \ 828 self.get_symbol_label()[info[2]] 792 self.get_symbol_label()[info[2]] 829 793 self.appearance_selected_plot.label = str(info[3]) 830 794 self.appD.Destroy() … … 833 797 def modifyGraphAppearance(self, event): 834 798 """ 835 On Modify Graph Appearance 799 On Modify Graph Appearance 836 800 """ 837 801 self.graphApp = graphAppearance(self, 'Modify Graph Appearance') 838 802 icon = self.parent.GetIcon() 839 803 self.graphApp.SetIcon(icon) 840 self.graphApp.setDefaults(self.grid_on, self.legend_on, 841 self.xaxis_label, self.yaxis_label, 842 self.xaxis_unit, self.yaxis_unit, 843 self.xaxis_font, self.yaxis_font, 844 find_key(self.get_loc_label(), 845 self.legendLoc), 846 self.xcolor, self.ycolor, 804 self.graphApp.setDefaults(self.grid_on, self.legend_on, 805 self.xaxis_label, self.yaxis_label, 806 self.xaxis_unit, self.yaxis_unit, 807 self.xaxis_font, self.yaxis_font, 808 find_key(self.get_loc_label(), self.legendLoc), 809 self.xcolor, self.ycolor, 847 810 self.is_xtick, self.is_ytick) 848 811 self.graphApp.Bind(wx.EVT_CLOSE, self.on_graphApp_close) … … 857 820 legend_loc = graph_app.get_legend_loc() 858 821 toggle_legend = graph_app.get_togglelegend() 859 860 self.onGridOnOff(toggle_grid 822 823 self.onGridOnOff(toggle_grid) 861 824 self.ChangeLegendLoc(legend_loc) 862 825 self.onLegend(toggle_legend) … … 868 831 self.xaxis_font = graph_app.get_xfont() 869 832 self.yaxis_font = graph_app.get_yfont() 870 self.is_xtick = 871 self.is_ytick = 833 self.is_xtick = graph_app.get_xtick_check() 834 self.is_ytick = graph_app.get_ytick_check() 872 835 if self.is_xtick: 873 836 self.xaxis_tick = self.xaxis_font … … 875 838 self.yaxis_tick = self.yaxis_font 876 839 877 self.xaxis(self.xaxis_label, self.xaxis_unit, 878 graph_app.get_xfont(), graph_app.get_xcolor(), 840 self.xaxis(self.xaxis_label, self.xaxis_unit, 841 graph_app.get_xfont(), graph_app.get_xcolor(), 879 842 self.xaxis_tick) 880 self.yaxis(self.yaxis_label, self.yaxis_unit, 843 self.yaxis(self.yaxis_label, self.yaxis_unit, 881 844 graph_app.get_yfont(), graph_app.get_ycolor(), 882 845 self.yaxis_tick) -
src/sas/guiframe/local_perspectives/plotting/profile_dialog.py
r79492222 r090e07e 270 270 pass 271 271 272 def _add_more_tool(self):273 """274 Not implemented275 """276 pass277 278 272 def onChangeCaption(self, event): 279 273 """
Note: See TracChangeset
for help on using the changeset viewer.