Ignore:
Timestamp:
Feb 24, 2009 11:46:12 AM (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:
cce33b3
Parents:
2a8fac1
Message:

small bugs fixed: clearing slicer improved

File:
1 edited

Legend:

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

    rdd66fbd r18eba35  
    1616import danse.common.plottools 
    1717from danse.common.plottools.PlotPanel import PlotPanel 
    18 from danse.common.plottools.plottables import Graph,Data1D,Theory1D 
     18from danse.common.plottools.plottables import Graph,Data1D,Theory1D,Data1D 
    1919from sans.guicomm.events import EVT_NEW_PLOT 
    20 from sans.guicomm.events import StatusEvent ,NewPlotEvent,SlicerEvent 
     20from sans.guicomm.events import StatusEvent ,NewPlotEvent,SlicerEvent,ErrorDataEvent 
    2121from sans.guiframe.utils import PanelMenu 
    2222 
     
    5858        ## save errors dy  for each data plotted 
    5959        self.err_dy={} 
     60        self.errors_hide=0 
    6061         
    6162        ## Unique ID (from gui_manager) 
     
    184185        id = wx.NewId() 
    185186        slicerpop.Append(id,'&Print image', 'Print image ') 
    186         wx.EVT_MENU(self, id, self.onPrint)   
     187        wx.EVT_MENU(self, id, self.onPrint) 
     188           
     189        id = wx.NewId() 
     190        slicerpop.Append(id,'&Print Preview', 'image preview for print') 
     191        wx.EVT_MENU(self, id, self.onPrinterPreview) 
    187192            
    188193        slicerpop.AppendSeparator() 
     
    220225        
    221226        if self.graph.selected_plottable in self.plots: 
    222             if self.plots[self.graph.selected_plottable].__class__.__name__=="Theory1D": 
     227            if self.plots[self.graph.selected_plottable].name in self.err_dy.iterkeys()\ 
     228                and self.errors_hide==1: 
     229                  
     230                #if self.plots[self.graph.selected_plottable].__class__.__name__=="Theory1D": 
    223231                id = wx.NewId() 
    224                 slicerpop.Append(id, '&Add errors to data') 
     232                slicerpop.Append(id, '&Show errors to data') 
    225233                #print "panel scale before  ",self.xLabel, self.yLabel 
    226234                #print "cyllinder before adding error", self.plots[self.graph.selected_plottable].x 
    227235                wx.EVT_MENU(self, id, self._on_add_errors) 
    228                 """ 
    229                 elif self.plots[self.graph.selected_plottable].__class__.__name__=="Data1D": 
     236                 
     237                
     238            elif self.plots[self.graph.selected_plottable].__class__.__name__=="Data1D"\ 
     239                and self.errors_hide==0: 
    230240                    id = wx.NewId() 
    231                     slicerpop.Append(id, '&Remove errors From data') 
     241                    slicerpop.Append(id, '&Hide Error bars') 
    232242                    #print "panel scale before  ",self.xLabel, self.yLabel 
    233243                    #print "cyllinder before adding error", self.plots[self.graph.selected_plottable].x 
    234244                    wx.EVT_MENU(self, id, self._on_remove_errors) 
    235                 """ 
     245                     
     246              
    236247            else: 
    237248                id = wx.NewId() 
     
    262273        pos = self.ScreenToClient(pos) 
    263274        self.PopupMenu(slicerpop, pos) 
     275         
     276         
    264277    def _on_remove_errors(self, evt): 
    265278        if not self.graph.selected_plottable == None: 
     
    267280            dy = self.plots[self.graph.selected_plottable].dy 
    268281            self.err_dy[name]= dy 
    269             new_plot = Theory1D(self.plots[self.graph.selected_plottable].x, 
     282            import numpy 
     283            dy= numpy.zeros(len(self.plots[self.graph.selected_plottable].y)) 
     284            new_plot = Data1D(self.plots[self.graph.selected_plottable].x, 
    270285                              self.plots[self.graph.selected_plottable].y, 
    271                               dy=None) 
     286                              dy=dy) 
    272287            new_plot.interactive = True 
     288            self.errors_hide=1 
    273289            new_plot.name = self.plots[self.graph.selected_plottable].name  
    274290            if hasattr(self.plots[self.graph.selected_plottable], "group_id"): 
     
    283299            new_plot.yaxis(label, unit) 
    284300            #print "panel scale ",self.xLabel, self.yLabel 
    285             print "color",self.graph.plottables[self.plots[self.graph.selected_plottable]] 
     301            #print "color",self.graph.plottables[self.plots[self.graph.selected_plottable]] 
    286302            color=self.graph.plottables[self.plots[self.graph.selected_plottable]] 
    287             self.graph.delete_plottable(self.plots[self.graph.selected_plottable]) 
     303            self.graph.delete(self.plots[self.graph.selected_plottable]) 
    288304             
    289305            self.graph.add(new_plot,color) 
     
    295311            self.graph.render(self) 
    296312            self.subplot.figure.canvas.draw_idle()  
     313             
     314            event = ErrorDataEvent(err_dy=self.err_dy) 
     315            wx.PostEvent(self.parent, event) 
    297316     
    298317    def _on_add_errors(self, evt): 
     
    321340                              dy=dy) 
    322341            new_plot.interactive = True 
     342            self.errors_hide=0 
    323343            new_plot.name = self.plots[self.graph.selected_plottable].name  
    324344            if hasattr(self.plots[self.graph.selected_plottable], "group_id"): 
     
    334354            new_plot.yaxis(label, unit) 
    335355            #print "panel scale ",self.xLabel, self.yLabel 
    336             #color=self.graph.plottables[self.plots[self.graph.selected_plottable]] 
    337             self.graph.delete_plottable(self.plots[self.graph.selected_plottable]) 
    338             #self.graph.add_plottable(new_plot, color) 
    339             self.graph.add(new_plot) 
     356            color=self.graph.plottables[self.plots[self.graph.selected_plottable]] 
     357            self.graph.delete(self.plots[self.graph.selected_plottable]) 
     358            self.graph.add(new_plot, color) 
     359             
    340360            # transforming the view of the new data into the same of the previous data 
    341361            self._onEVT_FUNC_PROPERTY() 
Note: See TracChangeset for help on using the changeset viewer.