Changeset 5330be2 in sasview for src/sas/qtgui/Perspectives/Fitting
- Timestamp:
- Jul 31, 2018 6:06:15 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 4453043
- Parents:
- 933f9e9
- git-author:
- Piotr Rozyczko <rozyczko@…> (07/31/18 06:04:46)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (07/31/18 06:06:15)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/ReportPageLogic.py
r30bc96eb r5330be2 4 4 import re 5 5 import sys 6 import tempfile 7 6 8 import logging 7 9 from io import BytesIO … … 9 11 10 12 from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas 11 12 from sas.qtgui.Plotting.Plotter import Plotter13 from sas.qtgui.Plotting.Plotter2D import Plotter2D14 from sas.qtgui.Plotting.PlotterData import Data1D15 from sas.qtgui.Plotting.PlotterData import Data2D16 13 17 14 import sas.qtgui.Utilities.GuiUtils as GuiUtils … … 102 99 canvas = FigureCanvas(fig) 103 100 png_output = BytesIO() 104 canvas.print_png(png_output) 105 data = png_output.getvalue() 106 data64 = base64.b64encode(data) 101 102 # Create a "safe" location - system tmp 103 tmp_file = tempfile.TemporaryFile(suffix=".png") 104 try: 105 fig.savefig(tmp_file.name, dpi=75) 106 fig.savefig(png_output, dpi=75) 107 except PermissionError: 108 # sometimes one gets "permission denied" for temp files 109 # mainly on Windows 7 *gasp*. Let's try local directory 110 tmp_file = open("_tmp.png", "w+") 111 try: 112 fig.savefig(tmp_file.name, dpi=75) 113 fig.savefig(png_output, dpi=75) 114 except Exception as ex: 115 logging.error("Creating of the report failed: %s"%str(ex)) 116 return 117 118 data_to_print = png_output.getvalue() == open(tmp_file.name, 'rb').read() 119 tmp_file.close() 120 data64 = base64.b64encode(png_output.getvalue()) 107 121 data_to_print = urllib.parse.quote(data64) 108 feet=FEET_2 122 123 feet = FEET_2 109 124 if sys.platform == "darwin": # Mac 110 125 feet = FEET_3 … … 153 168 if not modelname or self._index is None: 154 169 return None 155 plots = GuiUtils.plotsFromModel(modelname, self._index) 156 # Call show on requested plots 157 # All same-type charts in one plot 158 for plot_set in plots: 159 if isinstance(plot_set, Data1D): 160 if 'residuals' in plot_set.title.lower(): 161 res_plot = Plotter(self, quickplot=True) 162 res_plot.plot(plot_set) 163 graphs.append(res_plot.figure) 164 continue 165 if not 'new_plot' in locals(): 166 new_plot = Plotter(self, quickplot=True) 167 new_plot.plot(plot_set) 168 elif isinstance(plot_set, Data2D): 169 plot2D = Plotter2D(self, quickplot=True) 170 plot2D.item = self._index 171 plot2D.plot(plot_set) 172 graphs.append(plot2D.figure) 173 174 else: 175 msg = "Incorrect data type passed to Plotting" 176 raise AttributeError(msg) 177 178 if 'new_plot' in locals() and isinstance(new_plot.data, Data1D): 179 graphs.append(new_plot.figure) 170 plot_ids = [plot.id for plot in GuiUtils.plotsFromModel(modelname, self._index)] 171 172 # Active plots 173 import sas.qtgui.Plotting.PlotHelper as PlotHelper 174 shown_plot_names = PlotHelper.currentPlots() 175 176 # current_plots = list of graph names of currently shown plots 177 # which are related to this dataset 178 current_plots = [name for name in shown_plot_names if PlotHelper.plotById(name).data.id in plot_ids] 179 180 for name in current_plots: 181 # get the plotter object first 182 plotter = PlotHelper.plotById(name) 183 graphs.append(plotter.figure) 180 184 181 185 return graphs
Note: See TracChangeset
for help on using the changeset viewer.