Changeset 8f59e95 in sasview for sansguiframe/src/sans


Ignore:
Timestamp:
Jul 4, 2012 4:56:50 AM (12 years ago)
Author:
Kieran Campbell <kieranrcampbell@…>
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:
8a687cfd
Parents:
d560a37
Message:

New dialog added for modifying graph appearance (axes & legend)

Location:
sansguiframe/src/sans/guiframe/local_perspectives/plotting
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • sansguiframe/src/sans/guiframe/local_perspectives/plotting/Plotter1D.py

    rf8be87d r8f59e95  
    3737from binder import BindArtist 
    3838from appearanceDialog import appearanceDialog 
     39from graphAppearance import graphAppearance 
    3940 
    4041DEFAULT_QMAX = 0.05 
     
    4344BIN_WIDTH = 1 
    4445IS_MAC = (sys.platform == 'darwin') 
     46 
     47 
     48def find_key(dic, val): 
     49    """return the key of dictionary dic given the value""" 
     50    return [k for k, v in dic.iteritems() if v == val][0] 
     51 
     52 
    4553 
    4654class ModelPanel1D(PlotPanel, PanelBase): 
     
    478486 
    479487                id = wx.NewId() 
    480                 plot_menu.Append(id, '&Modify graph properties', name) 
     488                plot_menu.Append(id, '&Modify plot properties', name) 
    481489                wx.EVT_MENU(self, id, self.createAppDialog) 
    482490 
     
    495503                loc_menu.Append(id, str(label), str(label)) 
    496504                wx.EVT_MENU(self, id, self.onChangeLegendLoc) 
    497             id = wx.NewId() 
    498             self._slicerpop.AppendMenu(id, '&Modify Legend Location', loc_menu) 
    499              
    500             id = wx.NewId() 
    501             self._slicerpop.Append(id, '&Toggle Legend On/Off', 'Toggle Legend On/Off') 
    502             wx.EVT_MENU(self, id, self.onLegend) 
     505             
     506 
     507            # ILL mod start here 
     508 
     509            # id = wx.NewId() 
     510            # self._slicerpop.AppendMenu(id, '&Modify Legend Location', loc_menu) 
     511 
     512            # id = wx.NewId() 
     513            # self._slicerpop.Append(id, '&Toggle Legend On/Off', 'Toggle Legend On/Off') 
     514            # wx.EVT_MENU(self, id, self.onLegend) 
     515            # self._slicerpop.AppendSeparator() 
     516             
     517            # id = wx.NewId() 
     518            # self._slicerpop.Append(id, '&Edit Y Axis Label') 
     519            # wx.EVT_MENU(self, id, self._on_yaxis_label)      
     520            # id = wx.NewId() 
     521            # self._slicerpop.Append(id, '&Edit X Axis Label') 
     522            # wx.EVT_MENU(self, id, self._on_xaxis_label) 
     523     
     524            # id = wx.NewId() 
     525            # self._slicerpop.Append(id, '&Toggle Grid On/Off', 'Toggle Grid On/Off') 
     526            # wx.EVT_MENU(self, id, self.onGridOnOff) 
     527            # self._slicerpop.AppendSeparator() 
     528 
     529            id = wx.NewId() 
     530            self._slicerpop.Append(id, '&Modify graph appearance','Modify graph appearance') 
     531            wx.EVT_MENU(self, id, self.modifyGraphAppearance) 
    503532            self._slicerpop.AppendSeparator() 
    504              
    505             id = wx.NewId() 
    506             self._slicerpop.Append(id, '&Edit Y Axis Label') 
    507             wx.EVT_MENU(self, id, self._on_yaxis_label)      
    508             id = wx.NewId() 
    509             self._slicerpop.Append(id, '&Edit X Axis Label') 
    510             wx.EVT_MENU(self, id, self._on_xaxis_label) 
    511      
    512             id = wx.NewId() 
    513             self._slicerpop.Append(id, '&Toggle Grid On/Off', 'Toggle Grid On/Off') 
    514             wx.EVT_MENU(self, id, self.onGridOnOff) 
    515             self._slicerpop.AppendSeparator() 
     533 
    516534             
    517535            if self.position != None: 
     
    630648            curr_symbol = 13 
    631649 
    632         self.appD = appearanceDialog(self,'Modify graph properties') 
     650        self.appD = appearanceDialog(self,'Modify plot properties') 
    633651        self.appD.setDefaults(float(curr_size),int(curr_color),str(appearanceDialog.find_key(self.get_symbol_label(),int(curr_symbol))),curr_label) 
    634652        self.appD.Bind(wx.EVT_CLOSE, self.on_AppDialog_close)     
     
    652670        self.appD.Destroy() 
    653671        self._check_zoom_plot() 
     672 
     673 
     674    def modifyGraphAppearance(self,e): 
     675        self.graphApp = graphAppearance(self,'Modify graph appearance') 
     676 
     677         
     678 
     679        self.graphApp.setDefaults(self.grid_on,self.legend_on, 
     680                                  self.xaxis_label,self.yaxis_label, 
     681                                  self.xaxis_unit,self.yaxis_unit, 
     682                                  self.xaxis_font,self.yaxis_font, 
     683                                  find_key(self.get_loc_label(),self.legendLoc), 
     684                                  self.xcolor,self.ycolor) 
     685        self.graphApp.Bind(wx.EVT_CLOSE, self.on_graphApp_close) 
     686     
     687 
     688    def on_graphApp_close(self,e): 
     689# returns toggleGrid? toggleLegend? xlab, ylab, xunit, yunit, xfont, yfont, xcolor, ycolor, legendloc 
     690 
     691        #to do - make this passback mechanism much nicer 
     692        data = self.graphApp.getAppInfo() 
     693        self.onGridOnOff(data[0]) 
     694        self.onLegend(data[1]) 
     695        self.ChangeLegendLoc(data[10]) 
     696 
     697        self.xaxis_label = data[2] 
     698        self.yaxis_label = data[3] 
     699        self.xaxis_unit = data[4] 
     700        self.yaxis_unit = data[5] 
     701 
     702        self.xaxis(data[2],data[4],data[6],data[8]) 
     703        self.yaxis(data[3],data[5],data[7],data[9]) 
     704 
     705        xfont = data[6] 
     706        yfont = data[7] 
     707 
     708        # and a little sanity checking along the way 
     709 
     710        self.graphApp.Destroy() 
Note: See TracChangeset for help on using the changeset viewer.