Ignore:
Timestamp:
May 19, 2012 10:17:02 AM (12 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
baa915c
Parents:
d225e32
Message:

Merge 2.1.1 into trunk

File:
1 edited

Legend:

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

    r2d443fd r940aca7  
    5353            self.SetTitle("Scattering Length Density Profile") 
    5454            self.parent = parent 
     55            self._mgr = None 
    5556            self.data = data 
    5657            self.str = self.data.__str__() 
     
    7576            self.newplot.dy = None 
    7677            self.newplot.name = 'SLD' 
     78            self.newplot.id = self.newplot.name 
    7779            self.plotpanel.add_image(self.newplot)  
    7880            self.plotpanel.subplot.set_ylim(min(data_plot.y) - _Y_OFF ,  
     
    8183                                                max(data_plot.x) + _X_OFF) 
    8284            #self.Centre() 
     85            self.plotpanel.resizing = False 
     86            self.plotpanel.canvas.set_resizing(self.plotpanel.resizing) 
     87            self.plotpanel.subplot.figure.canvas.draw_idle() 
    8388            self.Layout() 
    8489 
     
    175180        self.parent.parent.parent.on_change_caption(name, old_caption, new_caption) 
    176181     
     182    def disable_app_menu(self, panel): 
     183        """ 
     184        Disable menu bar 
     185        """ 
     186        # Not implemented! 
     187        return 
    177188     
    178189class SLDplotpanel(PlotPanel): 
     
    203214        self.yaxis_label = '' 
    204215        self.yaxis_unit = '' 
     216        self.resizing = True 
    205217         
    206218    def add_image(self, plot): 
     
    208220        Add image(Theory1D) 
    209221        """ 
    210         self.plots[plot.name] = plot 
    211         self.plots[plot.name].is_data = False 
    212         #init graph 
    213         #self.gaph = Graph() 
     222        self.plots[plot.id] = plot 
     223        self.plots[plot.id].is_data = True 
    214224        #add plot 
    215225        self.graph.add(plot) 
     
    222232        self.yaxis_unit = '10^{-6}A^{-2}' 
    223233        self.graph.yaxis(self.yaxis_label, self.yaxis_unit) 
     234        #self.subplot.figure.canvas.draw_idle() 
     235        # For latter scale changes  
     236        self.plots[plot.id].xaxis('\\rm{%s} '% x1_label, 'A') 
     237        self.plots[plot.id].yaxis('\\rm{SLD} ', '10^{-6}A^{-2}') 
    224238        #draw 
    225239        self.graph.render(self) 
    226         self.subplot.figure.canvas.draw_idle() 
    227                  
    228         # For latter scale changes  
    229         self.plots[plot.name].xaxis('\\rm{%s} '% x1_label, 'A') 
    230         self.plots[plot.name].yaxis('\\rm{SLD} ', '10^{-6}A^{-2}') 
    231240         
    232241    def on_set_focus(self, event): 
     
    257266        """ 
    258267        pass 
    259      
     268                            
    260269    def _onSave(self, evt): 
    261270        """ 
     
    265274         
    266275        """ 
    267         
    268         path = None 
    269         wildcard = "Text files (*.txt)|*.txt|"\ 
    270                     "CanSAS 1D files(*.xml)|*.xml"  
    271         default_name = "sld_profile" 
     276        menu = evt.GetEventObject() 
     277        id = evt.GetId() 
     278        self.set_selected_from_menu(menu, id) 
     279        data = self.plots[self.graph.selected_plottable] 
     280        default_name = data.label 
     281        if default_name.count('.') > 0: 
     282            default_name = default_name.split('.')[0] 
     283        default_name += "_out" 
    272284        if self.parent != None: 
    273             self._default_save_location = self.parent.parent._default_save_location 
    274         dlg = wx.FileDialog(self, "Choose a file", 
    275                             self._default_save_location, 
    276                             default_name, wildcard , wx.SAVE) 
    277         
    278         if dlg.ShowModal() == wx.ID_OK: 
    279             path = dlg.GetPath() 
    280             # ext_num = 0 for .txt, ext_num = 1 for .xml 
    281             # This is MAC Fix 
    282             ext_num = dlg.GetFilterIndex() 
    283             if ext_num == 0: 
    284                 format = '.txt' 
    285             else: 
    286                 format = '.xml' 
    287             path = os.path.splitext(path)[0] + format 
    288             mypath = os.path.basename(path) 
    289              
    290             #TODO: This is bad design. The DataLoader is designed  
    291             #to recognize extensions. 
    292             # It should be a simple matter of calling the . 
    293             #save(file, data, '.xml') method 
    294             # of the sans.dataloader.loader.Loader class. 
    295             from sans.dataloader.loader import  Loader 
    296             #Instantiate a loader  
    297             loader = Loader()  
    298             data = self.parent.data 
    299             format = ".txt" 
    300             if os.path.splitext(mypath)[1].lower() == format: 
    301                 # Make sure the ext included in the file name 
    302                 # especially on MAC 
    303                 fName = os.path.splitext(path)[0] + format 
    304                 self._onsaveTXT(fName) 
    305             format = ".xml" 
    306             if os.path.splitext(mypath)[1].lower() == format: 
    307                 # Make sure the ext included in the file name 
    308                 # especially on MAC 
    309                 fName = os.path.splitext(path)[0] + format 
    310                 loader.save(fName, data, format) 
    311             try: 
    312                 self._default_save_location = os.path.dirname(path) 
    313                 self.parent.parent._default_save_location = self._default_save_location 
    314             except: 
    315                 pass     
    316         dlg.Destroy() 
    317           
     285            # What an ancestor! 
     286            fit_panel = self.parent.parent.parent 
     287            fit_panel.parent.save_data1d(data, default_name) 
     288              
    318289class ViewerFrame(wx.Frame): 
    319290    """ 
Note: See TracChangeset for help on using the changeset viewer.