Changeset 78312f7 in sasview for src/sas/sasgui/perspectives/fitting/basepage.py
- Timestamp:
- Jun 19, 2017 6:10:07 PM (7 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
r914c49d5 r78312f7 6 6 import sys 7 7 import os 8 import wx9 import numpy as np10 8 import time 11 9 import copy … … 14 12 import logging 15 13 import traceback 16 17 14 from collections import defaultdict 15 16 import numpy as np 17 18 import wx 18 19 from wx.lib.scrolledpanel import ScrolledPanel 19 20 20 21 from sasmodels.weights import MODELS as POLYDISPERSITY_MODELS 22 23 from sas.sascalc.dataloader.data_info import Detector 24 from sas.sascalc.dataloader.data_info import Source 21 25 22 26 from sas.sasgui.guiframe.panel_base import PanelBase … … 30 34 from sas.sasgui.guiframe.dataFitting import check_data_validity 31 35 from sas.sasgui.guiframe.gui_style import GUIFRAME_ID 32 from sas.sascalc.dataloader.data_info import Detector33 from sas.sascalc.dataloader.data_info import Source34 from sas.sasgui.perspectives.fitting.pagestate import PageState35 36 from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 36 37 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 38 39 from sas.sasgui.perspectives.fitting.pagestate import PageState 40 from sas.sasgui.perspectives.fitting.report_dialog import ReportDialog 37 41 38 42 logger = logging.getLogger(__name__) … … 619 623 # Get plot image from plotpanel 620 624 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 623 671 624 672 def on_save(self, event):
Note: See TracChangeset
for help on using the changeset viewer.