Changeset 6f16e25 in sasview for src/sas/guiframe/local_perspectives/plotting/Plotter1D.py
- Timestamp:
- Oct 21, 2015 8:35:00 AM (9 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:
- 85130cb
- Parents:
- 2d88fc4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/guiframe/local_perspectives/plotting/Plotter1D.py
r2d88fc4 r6f16e25 19 19 from sas.guiframe.events import StatusEvent 20 20 from sas.guiframe.events import PanelOnFocusEvent 21 from sas.guiframe.utils import PanelMenu 21 from sas.guiframe.utils import PanelMenu, IdList 22 22 from sas.guiframe.panel_base import PanelBase 23 23 from sas.guiframe.gui_style import GUIFRAME_ICON … … 35 35 """return the key of dictionary dic given the value""" 36 36 return [k for k, v in dic.iteritems() if v == val][0] 37 38 class IdCollection:39 def __init__(self):40 self._ids = []41 self._index = 042 def next(self):43 if len(self._ids) == self._index:44 self._ids.append(wx.NewId())45 self._index += 146 return self._ids[self._index-1]47 def reset(self):48 self._index = 049 50 37 51 38 class ModelPanel1D(PlotPanel, PanelBase): … … 63 50 ## Group ID 64 51 group_id = None 65 _menu_ids = Id Collection()52 _menu_ids = IdList() 66 53 67 54 def __init__(self, parent, id=-1, color=None, … … 80 67 81 68 self._available_data = [] 82 self._menu_add_ids = []83 69 self._symbol_labels = self.get_symbol_label() 84 70 self._color_labels = self.get_color_label() … … 568 554 self._slicerpop.set_plots(self.plots) 569 555 self._slicerpop.set_graph(self.graph) 570 self._menu_ids.reset()556 ids = iter(self._menu_ids) 571 557 if not self.graph.selected_plottable in self.plots: 572 558 # Various plot options 573 wx_id = self._menu_ids.next()559 wx_id = ids.next() 574 560 self._slicerpop.Append(wx_id, '&Save Image', 'Save image as PNG') 575 561 wx.EVT_MENU(self, wx_id, self.onSaveImage) 576 wx_id = self._menu_ids.next()562 wx_id = ids.next() 577 563 self._slicerpop.Append(wx_id, '&Print Image', 'Print image ') 578 564 wx.EVT_MENU(self, wx_id, self.onPrint) 579 565 580 wx_id = self._menu_ids.next()566 wx_id = ids.next() 581 567 self._slicerpop.Append(wx_id, '&Copy to Clipboard', 582 568 'Copy to the clipboard') … … 595 581 continue 596 582 597 wx_id = self._menu_ids.next()583 wx_id = ids.next() 598 584 plot_menu.Append(wx_id, "&DataInfo", name) 599 585 wx.EVT_MENU(self, wx_id, self. _onDataShow) 600 wx_id = self._menu_ids.next()586 wx_id = ids.next() 601 587 plot_menu.Append(wx_id, "&Save Points as a File", name) 602 588 wx.EVT_MENU(self, wx_id, self._onSave) … … 605 591 # add menu of other plugins 606 592 item_list = self.parent.get_current_context_menu(self) 607 608 593 if (not item_list == None) and (not len(item_list) == 0): 609 for item in item_list: 594 # Note: reusing menu ids in submenu. This code works because 595 # IdItems is set up as a lazy iterator returning each id in 596 # sequence, creating new ids as needed so it never runs out. 597 # zip() is set up to stop when any iterator is empty, so it 598 # only asks for the number of ids in item_list. 599 for item, wx_id in zip(item_list, self._menu_ids): 610 600 611 601 try: 612 wx_id = self._menu_ids.next()613 602 plot_menu.Append(wx_id, item[0], name) 614 603 wx.EVT_MENU(self, wx_id, item[2]) … … 620 609 621 610 if self.parent.ClassName.count('wxDialog') == 0: 622 wx_id = self._menu_ids.next()611 wx_id = ids.next() 623 612 plot_menu.Append(wx_id, '&Linear Fit', name) 624 613 wx.EVT_MENU(self, wx_id, self.onFitting) 625 614 plot_menu.AppendSeparator() 626 615 627 wx_id = self._menu_ids.next()616 wx_id = ids.next() 628 617 plot_menu.Append(wx_id, "Remove", name) 629 618 wx.EVT_MENU(self, wx_id, self._onRemove) 630 619 if not plot.is_data: 631 wx_id = self._menu_ids.next()620 wx_id = ids.next() 632 621 plot_menu.Append(wx_id, '&Freeze', name) 633 622 wx.EVT_MENU(self, wx_id, self.onFreeze) … … 635 624 636 625 if plot.is_data: 637 wx_id = self._menu_ids.next()626 wx_id = ids.next() 638 627 self.hide_menu = plot_menu.Append(wx_id, "Hide Error Bar", name) 639 628 … … 649 638 plot_menu.AppendSeparator() 650 639 651 wx_id = self._menu_ids.next()640 wx_id = ids.next() 652 641 plot_menu.Append(wx_id, '&Modify Plot Property', name) 653 642 wx.EVT_MENU(self, wx_id, self.createAppDialog) 654 wx_id = self._menu_ids.next()643 wx_id = ids.next() 655 644 # plot_menu.SetTitle(name) 656 645 self._slicerpop.AppendMenu(wx_id, '&%s' % name, plot_menu) … … 661 650 loc_menu = wx.Menu() 662 651 for label in self._loc_labels: 663 wx_id = self._menu_ids.next()652 wx_id = ids.next() 664 653 loc_menu.Append(wx_id, str(label), str(label)) 665 654 wx.EVT_MENU(self, wx_id, self.onChangeLegendLoc) 666 655 667 wx_id = self._menu_ids.next()656 wx_id = ids.next() 668 657 self._slicerpop.Append(wx_id, '&Modify Graph Appearance', 669 658 'Modify graph appearance') … … 673 662 674 663 if self.position != None: 675 wx_id = self._menu_ids.next()664 wx_id = ids.next() 676 665 self._slicerpop.Append(wx_id, '&Add Text') 677 666 wx.EVT_MENU(self, wx_id, self._on_addtext) 678 wx_id = self._menu_ids.next()667 wx_id = ids.next() 679 668 self._slicerpop.Append(wx_id, '&Remove Text') 680 669 wx.EVT_MENU(self, wx_id, self._on_removetext) 681 670 self._slicerpop.AppendSeparator() 682 wx_id = self._menu_ids.next()671 wx_id = ids.next() 683 672 self._slicerpop.Append(wx_id, '&Change Scale') 684 673 wx.EVT_MENU(self, wx_id, self._onProperties) 685 674 self._slicerpop.AppendSeparator() 686 wx_id = self._menu_ids.next()675 wx_id = ids.next() 687 676 self._slicerpop.Append(wx_id, '&Reset Graph Range') 688 677 wx.EVT_MENU(self, wx_id, self.onResetGraph) … … 690 679 if self.parent.ClassName.count('wxDialog') == 0: 691 680 self._slicerpop.AppendSeparator() 692 wx_id = self._menu_ids.next()681 wx_id = ids.next() 693 682 self._slicerpop.Append(wx_id, '&Window Title') 694 683 wx.EVT_MENU(self, wx_id, self.onChangeCaption)
Note: See TracChangeset
for help on using the changeset viewer.