Changeset 869c368 in sasview for guiframe


Ignore:
Timestamp:
Feb 9, 2009 6:39:21 PM (16 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
264df67
Parents:
fee6059
Message:

allows removing or adding errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guiframe/local_perspectives/plotting/Plotter1D.py

    re48a62e r869c368  
    1616import danse.common.plottools 
    1717from danse.common.plottools.PlotPanel import PlotPanel 
    18 from danse.common.plottools.plottables import Graph,Data1D 
     18from danse.common.plottools.plottables import Graph,Data1D,Theory1D 
    1919from sans.guicomm.events import EVT_NEW_PLOT 
    2020from sans.guicomm.events import StatusEvent ,NewPlotEvent,SlicerEvent 
     
    5656        ## Plottables 
    5757        self.plots = {} 
     58        ## save errors dy  for each data plotted 
     59        self.err_dy={} 
    5860         
    5961        ## Unique ID (from gui_manager) 
     
    136138        
    137139        self._onEVT_FUNC_PROPERTY() 
    138      
     140         
    139141        self.graph.render(self) 
     142        
    140143        self.subplot.figure.canvas.draw_idle() 
    141  
     144         
    142145    def onLeftDown(self,event):  
    143146        """ left button down and ready to drag""" 
     
    218221                #print "cyllinder before adding error", self.plots[self.graph.selected_plottable].x 
    219222                wx.EVT_MENU(self, id, self._on_add_errors) 
     223            elif self.plots[self.graph.selected_plottable].__class__.__name__=="Data1D": 
     224                id = wx.NewId() 
     225                slicerpop.Append(id, '&Remove errors to data') 
     226                #print "panel scale before  ",self.xLabel, self.yLabel 
     227                #print "cyllinder before adding error", self.plots[self.graph.selected_plottable].x 
     228                wx.EVT_MENU(self, id, self._on_remove_errors) 
    220229            else: 
    221230                id = wx.NewId() 
     
    248257        pos = self.ScreenToClient(pos) 
    249258        self.PopupMenu(slicerpop, pos) 
    250      
     259    def _on_remove_errors(self, evt): 
     260        if not self.graph.selected_plottable == None: 
     261            name =self.plots[self.graph.selected_plottable].name 
     262            dy = self.plots[self.graph.selected_plottable].dy 
     263            self.err_dy[name]= dy 
     264            new_plot = Theory1D(self.plots[self.graph.selected_plottable].x, 
     265                              self.plots[self.graph.selected_plottable].y, 
     266                              dy=None) 
     267            new_plot.interactive = True 
     268            new_plot.name = self.plots[self.graph.selected_plottable].name  
     269            if hasattr(self.plots[self.graph.selected_plottable], "group_id"): 
     270                new_plot.group_id = self.plots[self.graph.selected_plottable].group_id 
     271                new_plot.id = self.plots[self.graph.selected_plottable].id 
     272            else: 
     273                new_plot.group_id = str(time.time()) 
     274                new_plot.id = str(time.time()) 
     275            label, unit = self.plots[self.graph.selected_plottable].get_xaxis() 
     276            new_plot.xaxis(label, unit) 
     277            label, unit = self.plots[self.graph.selected_plottable].get_yaxis() 
     278            new_plot.yaxis(label, unit) 
     279            #print "panel scale ",self.xLabel, self.yLabel 
     280            print "color",self.graph.plottables[self.plots[self.graph.selected_plottable]] 
     281            color=self.graph.plottables[self.plots[self.graph.selected_plottable]] 
     282            self.graph.delete_plottable(self.plots[self.graph.selected_plottable]) 
     283             
     284            self.graph.add_plottable(new_plot,color) 
     285            # transforming the view of the new data into the same of the previous data 
     286            self._onEVT_FUNC_PROPERTY() 
     287            #print "cyllinder", self.plots[self.graph.selected_plottable].x,self.plots[self.graph.selected_plottable].view.x, new_plot.x, new_plot.view.x 
     288            self.plots[self.graph.selected_plottable]=new_plot 
     289            
     290            self.graph.render(self) 
     291            self.subplot.figure.canvas.draw_idle()  
    251292     
    252293    def _on_add_errors(self, evt): 
     
    262303            length = len(self.plots[self.graph.selected_plottable].x) 
    263304            dy = numpy.zeros(length) 
    264             for i in range(length): 
    265                 dy[i] = math.sqrt(self.plots[self.graph.selected_plottable].y[i]) 
     305            selected_plot= self.plots[self.graph.selected_plottable] 
     306            try: 
     307                dy = self.err_dy[selected_plot.name] 
     308            except: 
     309                for i in range(length): 
     310                    dy[i] = math.sqrt(self.plots[self.graph.selected_plottable].y[i])       
     311            #for i in range(length): 
     312            #    dy[i] = math.sqrt(self.plots[self.graph.selected_plottable].y[i]) 
    266313                 
    267314            new_plot = Data1D(self.plots[self.graph.selected_plottable].x, 
     
    282329            new_plot.yaxis(label, unit) 
    283330            #print "panel scale ",self.xLabel, self.yLabel 
    284             self.graph.delete(self.plots[self.graph.selected_plottable]) 
    285              
    286             self.graph.add(new_plot) 
     331            color=self.graph.plottables[self.plots[self.graph.selected_plottable]] 
     332            self.graph.delete_plottable(self.plots[self.graph.selected_plottable]) 
     333            self.graph.add_plottable(new_plot, color) 
     334            #self.graph.add(new_plot) 
    287335            # transforming the view of the new data into the same of the previous data 
    288336            self._onEVT_FUNC_PROPERTY() 
Note: See TracChangeset for help on using the changeset viewer.