Changeset 49a470d in sasview


Ignore:
Timestamp:
Aug 31, 2011 1:29:29 PM (13 years ago)
Author:
Jae Cho <jhjcho@…>
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:
c17760d
Parents:
fe48fcc
Message:

adde 2D plot label editor

File:
1 edited

Legend:

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

    rfe48fcc r49a470d  
    2020from danse.common.plottools.PlotPanel import PlotPanel 
    2121from danse.common.plottools.plottables import Graph 
    22 from danse.common.plottools.LabelDialog import LabelDialog 
     22from danse.common.plottools.TextDialog import TextDialog 
    2323from sans.guiframe.events import EVT_NEW_PLOT 
    2424from sans.guiframe.events import EVT_SLICER_PARS 
     
    3232from danse.common.plottools.toolbar import NavigationToolBar  
    3333from sans.guiframe.dataFitting import Data1D 
     34from matplotlib.font_manager import FontProperties 
    3435(InternalEvent, EVT_INTERNAL) = wx.lib.newevent.NewEvent() 
    3536 
     
    116117        ## panel that contains result from slicer motion (ex: Boxsum info) 
    117118        self.panel_slicer = None 
     119        self.title_label = None 
     120        self.title_font = None 
     121        self.title_color = 'black' 
    118122        ## Graph         
    119123        self.graph = Graph() 
     
    172176        yhi = None 
    173177        ## Update self.data2d with the current plot 
    174         self.data2D = data 
     178         
    175179        if data.id in self.plots.keys(): 
    176180            #replace 
     
    191195                 
    192196        #data2D: put 'Pixel (Number)' for axis title and unit in case of having no detector info and none in _units 
    193         if len(self.data2D.detector) < 1:  
     197        if len(data.detector) < 1:  
    194198            if len(data._xunit) < 1 and len(data._yunit) < 1: 
    195199                data._xaxis = '\\rm{x}' 
     
    199203        self.graph.xaxis(data._xaxis, data._xunit) 
    200204        self.graph.yaxis(data._yaxis, data._yunit) 
     205        data.label = self.title_label 
     206         
    201207        if data.label == None: 
    202208            data.label = data.name 
    203         self.graph.title(data.label) 
    204         self.graph.render(self) 
    205         self.draw_plot() 
    206         #self.subplot.figure.canvas.draw_idle() 
     209             
     210        if not self.title_font: 
     211            self.graph.title(data.label) 
     212            self.graph.render(self) 
     213            self.draw_plot() 
     214             
     215        else: 
     216            self.graph.render(self) 
     217            self.draw_plot() 
     218            self.subplot.set_title(label=data.label, 
     219                                   fontproperties=self.title_font, 
     220                                   color=self.title_color) 
     221            self.subplot.figure.canvas.draw_idle()  
     222         
     223        self.data2D = data 
    207224        ## store default value of zmin and zmax  
    208225        self.default_zmin_ctl = self.zmin_2D 
     
    325342        selected_plot = self.plots[self.graph.selected_plottable] 
    326343        label = selected_plot.label 
    327         dial = LabelDialog(None, -1, 'Change Label', label) 
     344        dial = TextDialog(None, -1, 'Change Label', label) 
    328345        if dial.ShowModal() == wx.ID_OK: 
    329             newLabel = dial.getText()  
    330             selected_plot.label = newLabel 
     346            try: 
     347                FONT = FontProperties() 
     348                newlabel = dial.getText() 
     349                font = FONT.copy() 
     350                font.set_size(dial.getSize()) 
     351                font.set_family(dial.getFamily()) 
     352                font.set_style(dial.getStyle()) 
     353                font.set_weight(dial.getWeight()) 
     354                colour = dial.getColor() 
     355                if len(newlabel) > 0: 
     356                    selected_plot.label = newlabel 
     357                    self.title_label = selected_plot.label 
     358                    self.title_font = font 
     359                    self.title_color = colour 
     360                    ## render the graph 
     361                    self.subplot.set_title(label=self.title_label, 
     362                                           fontproperties=self.title_font, 
     363                                           color=self.title_color) 
     364                    self.subplot.figure.canvas.draw_idle()   
     365            except: 
     366                if self.parent != None: 
     367                    from sans.guiframe.events import StatusEvent  
     368                    msg= "Add Text: Error. Check your property values..." 
     369                    wx.PostEvent(self.parent, StatusEvent(status = msg )) 
     370                else: 
     371                    raise 
    331372        dial.Destroy() 
    332         ## render the graph 
    333         self.subplot.set_title(selected_plot.label) 
    334         self.subplot.figure.canvas.draw_idle() 
     373 
    335374         
    336375    def _onEditDetector(self, event): 
Note: See TracChangeset for help on using the changeset viewer.