Changeset fa412df in sasview


Ignore:
Timestamp:
Sep 6, 2018 10:58:01 AM (6 years ago)
Author:
krzywon
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
Children:
d0ce666f
Parents:
ec4b19c
Message:

Simplify calling image handler and add documentation.

Location:
src/sas/sasgui
Files:
4 edited

Legend:

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

    r0cf4f84 rfa412df  
    33 
    44class ReportImageHandler: 
    5  
     5    # Singleton class that manages all report plot images 
     6    # To call the handler, call the static method set_figs 
    67 
    78    class _ReportImageHandler: 
     
    1415 
    1516        def set_figs(self, figs, bitmaps, perspective): 
     17            """ 
     18            Save figures and images to memory and return refernces 
     19            :param figs: A list of matplotlib Figures 
     20            :param bitmaps: A list of bitmaps 
     21            :param perspective: A String with the perspective name 
     22            :return: A tuple of a list of Figures and a list of memory refs 
     23            """ 
    1624            imgs = [] 
    1725            refs = [] 
     
    3442 
    3543        def create_unique_name(self, perspective, index=None): 
     44            """ 
     45            Create a unique key for each item in memory 
     46            :param perspective: The perspective name as a string 
     47            :param index: The base index used for incrementing the name 
     48            :return: A unique file name not currently in use 
     49            """ 
    3650            if not index: 
    3751                index = len(self.indices) 
     
    4357            return name 
    4458 
    45  
    4659    instance = None 
    4760 
    48     def __init__(self): 
     61    @staticmethod 
     62    def set_figs(figs, bitmaps, perspective): 
    4963        if not ReportImageHandler.instance: 
    5064            ReportImageHandler.instance = ReportImageHandler._ReportImageHandler() 
     65        return ReportImageHandler.instance.set_figs(figs, bitmaps, perspective) 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r0cf4f84 rfa412df  
    652652        by plotting, putting it into wx.FileSystem image object 
    653653        """ 
    654  
    655         img_handler = ReportImageHandler() 
    656654        bitmaps = [] 
    657655        for canvas in canvases: 
    658656            bitmaps.append(canvas.bitmap) 
    659         imgs, refs = img_handler.instance.set_figs(figs, bitmaps, 'fit') 
    660  
    661         return img_handler.instance.img_holder, imgs, refs 
     657        imgs, refs = ReportImageHandler.set_figs(figs, bitmaps, 'fit') 
     658 
     659        return ReportImageHandler.instance, imgs, refs 
    662660 
    663661    def on_save(self, event): 
  • src/sas/sasgui/perspectives/invariant/invariant_panel.py

    rec4b19c rfa412df  
    2424from sas.sasgui.guiframe.panel_base import PanelBase 
    2525from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     26from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    2627 
    2728logger = logging.getLogger(__name__) 
     
    783784        report_img = self.state.image 
    784785        report_list = [report_html_str, report_text_str, report_img] 
    785         imgRAM = self.state.img_handler 
     786        imgRAM = ReportImageHandler.instance.img_holder 
    786787        refs = [self.state.wximgbmp] 
    787788        dialog = ReportDialog(report_list, imgRAM, refs, None, wx.ID_ANY, "") 
  • src/sas/sasgui/perspectives/invariant/invariant_state.py

    rec4b19c rfa412df  
    612612        wximgbmp = wx.BitmapFromImage(wximg) 
    613613        # store the image in wx.FileSystem Object 
    614         self.img_handler = ReportImageHandler() 
    615         imgs, refs = self.img_handler.instance.set_figs([fig], [wximgbmp], 'inv') 
     614        imgs, refs = ReportImageHandler.set_figs([fig], [wximgbmp], 'inv') 
    616615 
    617616        self.wximgbmp = refs[0] 
Note: See TracChangeset for help on using the changeset viewer.