Changes in / [a4a1ac9:6015eee] in sasview


Ignore:
Location:
src/sas/sasgui
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/report_dialog.py

    rd0ce666f r91552b5  
    77import sys 
    88import wx.html as html 
    9 from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    109 
    1110logger = logging.getLogger(__name__) 
     
    7170        button_close = wx.Button(self, wx.ID_OK, "Close") 
    7271        button_close.SetToolTipString("Close this report window.") 
    73         button_close.Bind(wx.EVT_BUTTON, self.onClose, 
    74                           id=button_close.GetId()) 
    7572        hbox.Add(button_close) 
    7673        button_close.SetFocus() 
     
    120117 
    121118 
    122     def onClose(self, event=None): 
     119    def OnClose(self, event=None): 
    123120        """ 
    124121        Close the Dialog 
     
    126123        """ 
    127124        for fig in self.fig_urls: 
    128             ReportImageHandler.remove_figure(fig) 
     125            self.imgRAM.RemoveFile(fig) 
    129126 
    130         self.Destroy() 
     127        self.Close() 
    131128 
    132129    def HTML2PDF(self, data, filename): 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    rb4398819 rb4398819  
    3131 
    3232from sas.sasgui.guiframe.panel_base import PanelBase 
    33 from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    3433from sas.sasgui.guiframe.utils import format_number, check_float, IdList, \ 
    3534    check_int 
     
    652651        by plotting, putting it into wx.FileSystem image object 
    653652        """ 
    654         bitmaps = [] 
    655         for canvas in canvases: 
    656             bitmaps.append(canvas.bitmap) 
    657         imgs, refs = ReportImageHandler.set_figs(figs, bitmaps, 'fit') 
    658  
    659         return ReportImageHandler.instance, imgs, refs 
     653        images = [] 
     654        refs = [] 
     655 
     656        # For no figures in the list, prepare empty plot 
     657        if figs is None or len(figs) == 0: 
     658            figs = [None] 
     659 
     660        # Loop over the list of figures 
     661        # use wx.MemoryFSHandler 
     662        imgRAM = wx.MemoryFSHandler() 
     663        for fig in figs: 
     664            if fig is not None: 
     665                ind = figs.index(fig) 
     666                canvas = canvases[ind] 
     667 
     668            # store the image in wx.FileSystem Object 
     669            wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 
     670 
     671            # index of the fig 
     672            ind = figs.index(fig) 
     673 
     674            # AddFile, image can be retrieved with 'memory:filename' 
     675            name = 'img_fit%s.png' % ind 
     676            refs.append('memory:' + name) 
     677            imgRAM.AddFile(name, canvas.bitmap, wx.BITMAP_TYPE_PNG) 
     678            # append figs 
     679            images.append(fig) 
     680 
     681        return imgRAM, images, refs 
     682 
    660683 
    661684    def on_save(self, event): 
  • src/sas/sasgui/perspectives/fitting/report_dialog.py

    r44e8f48 r69a6897  
    7272        filename = basename + ext 
    7373 
    74         # save the images for use with pdf writer 
    75         pictures = [ 
    76             '_'.join((basename, url.split(':')[1])) for url in self.fig_urls] 
    77         for i, pic in enumerate(pictures): 
    78             self.report_list[2][i].savefig(pic) 
     74        # save figures 
     75        pictures = [] 
     76        for num in range(self.nimages): 
     77            pic_name = basename + '_img%s.png' % num 
     78            # save the image for use with pdf writer 
     79            self.report_list[2][num].savefig(pic_name) 
     80            pictures.append(pic_name) 
    7981 
    8082        # translate png references int html from in-memory name to on-disk name 
    81         html = self.report_html.replace("memory:", basename+'_') 
     83        html = self.report_html.replace("memory:img_fit", basename+'_img') 
    8284 
    8385        #set file extensions 
  • src/sas/sasgui/perspectives/invariant/invariant_panel.py

    r44e8f48 r2469df7  
    2424from sas.sasgui.guiframe.panel_base import PanelBase 
    2525from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
    26 from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    2726 
    2827logger = logging.getLogger(__name__) 
     
    784783        report_img = self.state.image 
    785784        report_list = [report_html_str, report_text_str, report_img] 
    786         ReportImageHandler.check_for_empty_instance() 
    787         imgRAM = ReportImageHandler.instance.img_holder 
    788         refs = [self.state.wximgbmp] 
    789         dialog = ReportDialog(report_list, imgRAM, refs, None, wx.ID_ANY, "") 
     785        dialog = ReportDialog(report_list, None, -1, "") 
    790786        dialog.Show() 
    791787 
  • src/sas/sasgui/perspectives/invariant/invariant_state.py

    rfa412df r2469df7  
    1212from lxml import etree 
    1313from sas.sascalc.dataloader.readers.cansas_reader import Reader as CansasReader 
    14 from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    1514from sas.sascalc.dataloader.readers.cansas_reader import get_content 
    1615from sas.sasgui.guiframe.utils import format_number 
     
    612611        wximgbmp = wx.BitmapFromImage(wximg) 
    613612        # store the image in wx.FileSystem Object 
    614         imgs, refs = ReportImageHandler.set_figs([fig], [wximgbmp], 'inv') 
    615  
    616         self.wximgbmp = refs[0] 
    617         self.image = imgs[0] 
     613        wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 
     614        # use wx.MemoryFSHandler 
     615        self.imgRAM = wx.MemoryFSHandler() 
     616        # AddFile, image can be retrieved with 'memory:filename' 
     617        self.imgRAM.AddFile('img_inv.png', wximgbmp, wx.BITMAP_TYPE_PNG) 
     618 
     619        self.wximgbmp = 'memory:img_inv.png' 
     620        self.image = fig 
    618621 
    619622class Reader(CansasReader): 
  • src/sas/sasgui/perspectives/invariant/report_dialog.py

    rd0ce666f r959eb01  
    4141 
    4242        # put image path in the report string 
    43         self.report_html = self.report_list[0] % self.fig_urls[0] 
     43        self.report_html = self.report_list[0] % "memory:img_inv.png" 
    4444        # layout 
    4545        self._setup_layout() 
Note: See TracChangeset for help on using the changeset viewer.