Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/plottools/PlotPanel.py

    r1ed6be7 r1a8e2e8e  
    1515import os 
    1616import transform 
    17 from plottables import Data1D 
    1817#TODO: make the plottables interactive 
    1918from binder import BindArtist 
     
    151150        #List of texts currently on the plot 
    152151        self.textList = [] 
     152        self.selectedText = None 
    153153        #User scale 
    154154        if xtransform != None: 
     
    190190 
    191191        # new data for the fit 
     192        from sas.sasgui.guiframe.dataFitting import Data1D 
    192193        self.fit_result = Data1D(x=[], y=[], dy=None) 
    193194        self.fit_result.symbol = 13 
     
    352353            self.leftdown = True 
    353354            ax = event.inaxes 
     355            for text in self.textList: 
     356                if text.contains(event)[0]: # If user has clicked on text 
     357                    self.selectedText = text 
     358                    return 
     359 
    354360            if ax != None: 
    355361                self.xInit, self.yInit = event.xdata, event.ydata 
     
    373379            self.mousemotion = False 
    374380            self.leftup = True 
     381            self.selectedText = None 
    375382 
    376383        #release the legend 
     
    448455            self._on_legend_motion(event) 
    449456            return 
     457 
     458        if self.leftdown and self.selectedText is not None: 
     459            # User has clicked on text and is dragging 
     460            ax = event.inaxes 
     461            if ax != None: 
     462                # Only move text if mouse is within axes 
     463                self.selectedText.set_position((event.xdata, event.ydata)) 
     464                self._dragHelper(0, 0) 
     465            else: 
     466                # User has dragged outside of axes 
     467                self.selectedText = None 
     468            return 
     469 
    450470        if self.enable_toolbar: 
    451471            #Disable dragging without the toolbar to allow zooming with toolbar 
     
    646666                dlg.setFitRange(self.xminView, self.xmaxView, 
    647667                                self.xmin, self.xmax) 
     668            else: 
     669                xlim = self.subplot.get_xlim() 
     670                ylim = self.subplot.get_ylim() 
     671                dlg.setFitRange(xlim[0], xlim[1], ylim[0], ylim[1]) 
    648672            # It would be nice for this to NOT be modal (i.e. Show). 
    649673            # Not sure about other ramifications - for example 
     
    17251749        if remove_fit: 
    17261750            self.graph.delete(self.fit_result) 
     1751            if hasattr(self, 'plots'): 
     1752                if 'fit' in self.plots.keys(): 
     1753                    del self.plots['fit'] 
    17271754        self.ly = None 
    17281755        self.q_ctrl = None 
     
    17381765        _yscale = 'linear' 
    17391766        for item in list: 
     1767            if item.id == 'fit': 
     1768                continue 
    17401769            item.setLabel(self.xLabel, self.yLabel) 
    17411770            # control axis labels from the panel itself 
     
    18691898 
    18701899        """ 
     1900        xlim = self.subplot.get_xlim() 
     1901        ylim = self.subplot.get_ylim() 
     1902 
    18711903        # Saving value to redisplay in Fit Dialog when it is opened again 
    18721904        self.Avalue, self.Bvalue, self.ErrAvalue, \ 
     
    18921924        self.graph.render(self) 
    18931925        self._offset_graph() 
     1926        if hasattr(self, 'plots'): 
     1927            # Used by Plotter1D 
     1928            fit_id = 'fit' 
     1929            self.fit_result.id = fit_id 
     1930            self.fit_result.title = 'Fit' 
     1931            self.fit_result.name = 'Fit' 
     1932            self.plots[fit_id] = self.fit_result 
     1933        self.subplot.set_xlim(xlim) 
     1934        self.subplot.set_ylim(ylim) 
    18941935        self.subplot.figure.canvas.draw_idle() 
    18951936 
Note: See TracChangeset for help on using the changeset viewer.