Ignore:
Timestamp:
Jun 19, 2017 6:10:07 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
2a0f33f
Parents:
bc04647
Message:

remove wx references from fitting pagestate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r914c49d5 r78312f7  
    66import sys 
    77import os 
    8 import wx 
    9 import numpy as np 
    108import time 
    119import copy 
     
    1412import logging 
    1513import traceback 
    16  
    1714from collections import defaultdict 
     15 
     16import numpy as np 
     17 
     18import wx 
    1819from wx.lib.scrolledpanel import ScrolledPanel 
    1920 
    2021from sasmodels.weights import MODELS as POLYDISPERSITY_MODELS 
     22 
     23from sas.sascalc.dataloader.data_info import Detector 
     24from sas.sascalc.dataloader.data_info import Source 
    2125 
    2226from sas.sasgui.guiframe.panel_base import PanelBase 
     
    3034from sas.sasgui.guiframe.dataFitting import check_data_validity 
    3135from sas.sasgui.guiframe.gui_style import GUIFRAME_ID 
    32 from sas.sascalc.dataloader.data_info import Detector 
    33 from sas.sascalc.dataloader.data_info import Source 
    34 from sas.sasgui.perspectives.fitting.pagestate import PageState 
    3536from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 
    3637from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     38 
     39from sas.sasgui.perspectives.fitting.pagestate import PageState 
     40from sas.sasgui.perspectives.fitting.report_dialog import ReportDialog 
    3741 
    3842logger = logging.getLogger(__name__) 
     
    619623        # Get plot image from plotpanel 
    620624        images, canvases = self.get_images() 
    621         # get the report dialog 
    622         self.state.report(images, canvases) 
     625        imgRAM, images, refs = self._build_plots_for_report(images, canvases) 
     626 
     627        # get the strings for report 
     628        report_str, text_str = self.state.report(fig_urls=refs) 
     629 
     630        # Show the dialog 
     631        report_list = [report_str, text_str, images] 
     632        dialog = ReportDialog(report_list, None, wx.ID_ANY, "") 
     633        dialog.Show() 
     634 
     635    def _build_plots_for_report(self, figs, canvases): 
     636        """ 
     637        Build image state that wx.html understand 
     638        by plotting, putting it into wx.FileSystem image object 
     639        """ 
     640        images = [] 
     641        refs = [] 
     642 
     643        # For no figures in the list, prepare empty plot 
     644        if figs is None or len(figs) == 0: 
     645            figs = [None] 
     646 
     647        # Loop over the list of figures 
     648        # use wx.MemoryFSHandler 
     649        imgRAM = wx.MemoryFSHandler() 
     650        for fig in figs: 
     651            if fig is not None: 
     652                ind = figs.index(fig) 
     653                canvas = canvases[ind] 
     654 
     655            # store the image in wx.FileSystem Object 
     656            wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 
     657 
     658            # index of the fig 
     659            ind = figs.index(fig) 
     660 
     661            # AddFile, image can be retrieved with 'memory:filename' 
     662            name = 'img_fit%s.png' % ind 
     663            refs.append('memory:' + name) 
     664            imgRAM.AddFile(name, canvas.bitmap, wx.BITMAP_TYPE_PNG) 
     665 
     666            # append figs 
     667            images.append(fig) 
     668 
     669        return imgRAM, images, refs 
     670 
    623671 
    624672    def on_save(self, event): 
Note: See TracChangeset for help on using the changeset viewer.