Changeset 7bfc888 in sasview for calculatorview/src/sans/perspectives
- Timestamp:
- Aug 23, 2012 12:32:40 PM (12 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:
- bd0a2115
- Parents:
- 10b3e1e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/data_operator.py
rd87e533 r7bfc888 11 11 from danse.common.plottools.plottables import Graph 12 12 from danse.common.plottools.canvas import FigureCanvas 13 from danse.common.plottools import transform 13 14 from matplotlib.font_manager import FontProperties 14 15 from matplotlib.figure import Figure … … 787 788 pass 788 789 else: 790 self.subplot.figure.canvas.resizing = False 791 self.subplot.tick_params(axis='both', labelsize=9) 792 self.erase_legend() 789 793 self.subplot.figure.canvas.draw_idle() 794 try: 795 self.figure.delaxes(self.figure.axes[1]) 796 except: 797 pass 798 790 799 791 800 def onContextMenu(self, event): … … 793 802 Default context menu for a plot panel 794 803 """ 795 804 id = wx.NewId() 805 slicerpop = wx.Menu() 806 slicerpop.Append(id, '&Change Scale') 807 wx.EVT_MENU(self, id, self._onProperties) 808 try: 809 # mouse event 810 pos_evt = event.GetPosition() 811 pos = self.ScreenToClient(pos_evt) 812 except: 813 # toolbar event 814 pos_x, pos_y = self.toolbar.GetPositionTuple() 815 pos = (pos_x, pos_y + 5) 816 817 self.PopupMenu(slicerpop, pos) 818 819 def _onProperties(self, event): 820 """ 821 when clicking on Properties on context menu , 822 The Property dialog is displayed 823 The user selects a transformation for x or y value and 824 a new plot is displayed 825 """ 826 list = [] 827 list = self.graph.returnPlottable() 828 if len(list.keys()) > 0: 829 first_item = list.keys()[0] 830 if first_item.x != []: 831 from danse.common.plottools.PropertyDialog import Properties 832 dial = Properties(self, -1, 'Change Scale') 833 # type of view or model used 834 dial.xvalue.Clear() 835 dial.yvalue.Clear() 836 dial.view.Clear() 837 dial.xvalue.Insert("x", 0) 838 dial.xvalue.Insert("log10(x)", 1) 839 dial.yvalue.Insert("y", 0) 840 dial.yvalue.Insert("log10(y)", 1) 841 dial.view.Insert("--", 0) 842 dial.view.Insert("Linear y vs x", 1) 843 dial.xvalue.SetValue("x") 844 dial.yvalue.SetValue("y") 845 dial.view.SetValue("--") 846 dial.Update() 847 if dial.ShowModal() == wx.ID_OK: 848 self.xLabel, self.yLabel, self.viewModel = dial.getValues() 849 if self.viewModel == "Linear y vs x": 850 self.xLabel = "x" 851 self.yLabel = "y" 852 self.viewModel = "--" 853 dial.setValues(self.xLabel, self.yLabel, self.viewModel) 854 self._onEVT_FUNC_PROPERTY() 855 dial.Destroy() 856 857 def _onEVT_FUNC_PROPERTY(self, remove_fit=True): 858 """ 859 Receive the x and y transformation from myDialog, 860 Transforms x and y in View 861 and set the scale 862 """ 863 list = [] 864 list = self.graph.returnPlottable() 865 # Changing the scale might be incompatible with 866 # currently displayed data (for instance, going 867 # from ln to log when all plotted values have 868 # negative natural logs). 869 # Go linear and only change the scale at the end. 870 self.set_xscale("linear") 871 self.set_yscale("linear") 872 _xscale = 'linear' 873 _yscale = 'linear' 874 for item in list: 875 item.setLabel(self.xLabel, self.yLabel) 876 # control axis labels from the panel itself 877 yname, yunits = item.get_yaxis() 878 xname, xunits = item.get_xaxis() 879 # Goes through all possible scales 880 # Goes through all possible scales 881 if(self.xLabel == "x"): 882 item.transformX(transform.toX, transform.errToX) 883 self.graph._xaxis_transformed("%s" % xname, "%s" % xunits) 884 if(self.xLabel == "log10(x)"): 885 item.transformX(transform.toX_pos, transform.errToX_pos) 886 _xscale = 'log' 887 self.graph._xaxis_transformed("%s" % xname, "%s" % xunits) 888 if(self.yLabel == "y"): 889 item.transformY(transform.toX, transform.errToX) 890 self.graph._yaxis_transformed("%s" % yname, "%s" % yunits) 891 if(self.yLabel == "log10(y)"): 892 item.transformY(transform.toX_pos, transform.errToX_pos) 893 _yscale = 'log' 894 self.graph._yaxis_transformed("%s" % yname, "%s" % yunits) 895 item.transformView() 896 self.set_xscale(_xscale) 897 self.set_yscale(_yscale) 898 self.draw() 899 796 900 class DataOperatorWindow(wx.Frame): 797 901 def __init__(self, parent, *args, **kwds):
Note: See TracChangeset
for help on using the changeset viewer.