Changeset 5a81885 in sasview for src/sas/sasgui/perspectives
- Timestamp:
- Sep 26, 2017 5:18:30 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:
- b916afa
- Parents:
- 0a3c740 (diff), 69a6897 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas/sasgui/perspectives/fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/report_dialog.py
r78312f7 r69a6897 57 57 58 58 fName = dlg.GetPath() 59 basename = os.path.splitext(fName)[0] 59 60 ext_num = dlg.GetFilterIndex() 61 dlg.Destroy() 62 63 if ext_num == 0 and self.index_offset == 0: # has pdf 64 ext = ".pdf" 65 elif ext_num == 1 - self.index_offset: 66 ext = ".html" 67 elif ext_num == 2 - self.index_offset: 68 ext = ".txt" 69 else: 70 logger.warn("unknown export format in report dialog") 71 return 72 filename = basename + ext 73 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) 81 82 # translate png references int html from in-memory name to on-disk name 83 html = self.report_html.replace("memory:img_fit", basename+'_img') 60 84 61 85 #set file extensions 62 86 img_ext = [] 63 pic_fname = [] 64 #PDF 65 if ext_num == (0 + 2 * self.index_offset): 66 # TODO: Sort this case out 67 ext = '.pdf' 87 if ext == ".pdf": 88 # write pdf as a pdf file 89 pdf = self.HTML2PDF(data=html, filename=filename) 68 90 69 fName = os.path.splitext(fName)[0] + ext 70 dlg.Destroy() 71 #pic (png) file path/name 72 for num in range(self.nimages): 73 im_ext = '_img%s.png' % num 74 #img_ext.append(im_ext) 75 pic_name = os.path.splitext(fName)[0] + im_ext 76 pic_fname.append(pic_name) 77 # save the image for use with pdf writer 78 self.report_list[2][num].savefig(pic_name) 91 # delete images used to create the pdf 92 for pic_name in pictures: 93 os.remove(pic_name) 79 94 80 #put the image path in html string 81 report_frame = self.report_list[0] 82 #put image name strings into the html file 83 #Note:The str for pic_fname shouldn't be removed. 84 if self.nimages == 1: 85 html = report_frame % str(pic_fname[0]) 86 elif self.nimages == 2: 87 html = report_frame % (str(pic_fname[0]), str(pic_fname[1])) 88 elif self.nimages == 3: 89 html = report_frame % (str(pic_fname[0]), str(pic_fname[1]), 90 str(pic_fname[2])) 91 92 # make/open file in case of absence 93 f = open(fName, 'w') 94 f.close() 95 # write pdf as a pdf file 96 pdf = self.HTML2PDF(data=html, filename=fName) 97 98 #open pdf 95 #open pdf viewer 99 96 if pdf: 100 97 try: 101 #Windows 102 os.startfile(str(fName)) 103 except Exception: 104 try: 105 #Mac 98 if os.name == 'nt': # Windows 99 os.startfile(fName) 100 elif sys.platform == "darwin": # Mac 106 101 os.system("open %s" % fName) 107 except Exception: 108 #DO not open 109 pass 110 #delete image file 111 for num in range(self.nimages): 112 os.remove(pic_fname[num]) 113 return 114 #HTML + png(graph) 115 elif ext_num == (1 - self.index_offset): 116 ext = '.html' 117 for num in range(self.nimages): 118 img_ext.append('_img4html%s.png' % num) 119 report_frame = self.report_list[0] 120 #TEXT + pdf(graph) 121 elif ext_num == (2 - self.index_offset): 122 ext = '.txt' 123 # changing the image extension actually changes the image 124 # format on saving 125 for num in range(self.nimages): 126 img_ext.append('_img4txt%s.pdf' % num) 127 report = self.report_list[1] 128 else: 129 return 102 except Exception as exc: 103 # cannot open pdf 104 logging.error(str(exc)) 130 105 131 #file name132 fName = os.path.splitext(fName)[0] + ext133 dlg.Destroy()106 elif ext == ".html": 107 with open(filename, 'w') as f: 108 f.write(html) 134 109 135 #pic (png) file path/name 136 for num in range(self.nimages): 137 pic_name = os.path.splitext(fName)[0] + img_ext[num] 138 pic_fname.append(pic_name) 139 #put the image path in html string 140 if ext_num == (1 - self.index_offset): 141 if self.nimages == 1: 142 report = report_frame % os.path.basename(pic_fname[0]) 143 elif self.nimages == 2: 144 report = report_frame % (os.path.basename(pic_fname[0]), 145 os.path.basename(pic_fname[1])) 146 elif self.nimages == 3: 147 report = report_frame % (os.path.basename(pic_fname[0]), 148 os.path.basename(pic_fname[1]), 149 os.path.basename(pic_fname[2])) 150 f = open(fName, 'w') 151 f.write(report) 152 f.close() 110 elif ext == ".txt": 111 with open(filename, 'w') as f: 112 f.write(self.report_list[1]) 113 153 114 self.Update() 154 #save png file using pic_fname155 for num in range(self.nimages):156 self.report_list[2][num].savefig(pic_fname[num]) -
src/sas/sasgui/perspectives/fitting/simfitpage.py
r24d9e84 r0a3c740 174 174 save_id = self._format_id(save_id) 175 175 if save_id == model_id: 176 model_map[saved_model.pop('fit_page_source')] = \177 model[3].name178 check = bool(saved_model.pop('checked'))179 self.model_list[i][0].SetValue(check)180 176 inter_id = str(i)*5 181 177 init_map[saved_model.pop('fit_page_source')] = inter_id
Note: See TracChangeset
for help on using the changeset viewer.