Changeset 17e1f14 in sasview
- Timestamp:
- Feb 19, 2015 1:55:15 AM (10 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, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 7829bb7
- Parents:
- 36819ee (diff), 5e326a6 (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
- Files:
-
- 2 added
- 1 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/dataloader/data_info.py
r7eaf9f2 r5e326a6 26 26 import math 27 27 28 29 28 class plottable_sesans1D: 30 29 """ 31 30 SESANS is a place holder for 1D SESANS plottables. 32 31 33 #TODO: This was directly copied from the plottables_1D. 34 # TODO: The class has not been updated from there.32 #TODO: This was directly copied from the plottables_1D. Modified Somewhat. 33 #Class has been updated. 35 34 """ 36 35 # The presence of these should be mutually … … 38 37 x = None 39 38 y = None 39 lam = None 40 40 dx = None 41 41 dy = None 42 dlam = None 42 43 ## Slit smearing length 43 44 dxl = None … … 51 52 _yunit = '' 52 53 53 def __init__(self, x, y, dx=None, dy=None, dxl=None, dxw=None): 54 def __init__(self, x, y, lam, dx=None, dy=None, dlam=None): 55 # print "SESANS plottable working" 54 56 self.x = numpy.asarray(x) 55 57 self.y = numpy.asarray(y) 58 self.lam = numpy.asarray(lam) 56 59 if dx is not None: 57 60 self.dx = numpy.asarray(dx) 58 61 if dy is not None: 59 62 self.dy = numpy.asarray(dy) 60 if dxl is not None: 61 self.dxl = numpy.asarray(dxl) 62 if dxw is not None: 63 self.dxw = numpy.asarray(dxw) 64 63 if dlam is not None: 64 self.dlam = numpy.asarray(dlam) 65 # if dxl is not None: 66 # self.dxl = numpy.asarray(dxl) 67 # if dxw is not None: 68 # self.dxw = numpy.asarray(dxw) 69 # print "SESANS plottable init fin" 65 70 def xaxis(self, label, unit): 66 71 """ … … 69 74 self._xaxis = label 70 75 self._xunit = unit 71 76 print "xaxis active" 77 print label 78 print unit 72 79 def yaxis(self, label, unit): 73 80 """ 74 81 set the y axis label and unit 75 82 """ 83 print "yaxis active" 84 print label 85 print unit 86 76 87 self._yaxis = label 77 88 self._yunit = unit … … 750 761 """ 751 762 return self._perform_union(other) 752 763 764 class SESANSData1D(plottable_sesans1D, DataInfo): 765 """ 766 SESANS 1D data class 767 """ 768 x_unit = 'nm' 769 y_unit = 'a.u.' 770 771 def __init__(self, x=None, y=None, lam=None, dy=None, dx=None, dlam=None): 772 # print "dat init" 773 DataInfo.__init__(self) 774 # print "dat init fin" 775 plottable_sesans1D.__init__(self, x, y, lam, dx, dy, dlam) 776 # print "SESANSdata1D init" 777 def __str__(self): 778 """ 779 Nice printout 780 """ 781 # print "string printer active" 782 _str = "%s\n" % DataInfo.__str__(self) 783 784 _str += "Data:\n" 785 _str += " Type: %s\n" % self.__class__.__name__ 786 _str += " X-axis: %s\t[%s]\n" % (self._xaxis, self._xunit) 787 _str += " Y-axis: %s\t[%s]\n" % (self._yaxis, self._yunit) 788 _str += " Length: %g\n" % len(self.x) 789 # print _str 790 return _str 791 # 792 # def is_slit_smeared(self): 793 # """ 794 # Check whether the data has slit smearing information 795 # 796 # :return: True is slit smearing info is present, False otherwise 797 # 798 # """ 799 # def _check(v): 800 # if (v.__class__ == list or v.__class__ == numpy.ndarray) \ 801 # and len(v) > 0 and min(v) > 0: 802 # return True 803 # 804 # return False 805 # 806 # return _check(self.dxl) or _check(self.dxw) 807 808 def clone_without_data(self, length=0, clone=None): 809 """ 810 Clone the current object, without copying the data (which 811 will be filled out by a subsequent operation). 812 The data arrays will be initialized to zero. 813 814 :param length: length of the data array to be initialized 815 :param clone: if provided, the data will be copied to clone 816 """ 817 from copy import deepcopy 818 # print " SESANS data 1D clone active" 819 if clone is None or not issubclass(clone.__class__, Data1D): 820 x = numpy.zeros(length) 821 dx = numpy.zeros(length) 822 lam = numpy.zeros(length) 823 dlam = numpy.zeros(length) 824 y = numpy.zeros(length) 825 dy = numpy.zeros(length) 826 clone = Data1D(x, y, dx=dx, dy=dy) 827 828 clone.title = self.title 829 clone.run = self.run 830 clone.filename = self.filename 831 clone.instrument = self.instrument 832 clone.notes = deepcopy(self.notes) 833 clone.process = deepcopy(self.process) 834 clone.detector = deepcopy(self.detector) 835 clone.sample = deepcopy(self.sample) 836 clone.source = deepcopy(self.source) 837 clone.collimation = deepcopy(self.collimation) 838 clone.trans_spectrum = deepcopy(self.trans_spectrum) 839 clone.meta_data = deepcopy(self.meta_data) 840 clone.errors = deepcopy(self.errors) 841 # print "SESANS Data 1Dclone done" 842 return clone 843 753 844 class Data1D(plottable_1D, DataInfo): 754 845 """ … … 991 1082 992 1083 993 class SESANSData1D(plottable_sesans1D, DataInfo):994 """995 SESANS 1D data class996 """997 x_unit = '1/A'998 y_unit = '1/cm'999 1000 def __init__(self, x, y, dx=None, dy=None):1001 DataInfo.__init__(self)1002 plottable_sesans1D.__init__(self, x, y, dx, dy)1003 1004 def __str__(self):1005 """1006 Nice printout1007 """1008 _str = "%s\n" % DataInfo.__str__(self)1009 1010 _str += "Data:\n"1011 _str += " Type: %s\n" % self.__class__.__name__1012 _str += " X-axis: %s\t[%s]\n" % (self._xaxis, self._xunit)1013 _str += " Y-axis: %s\t[%s]\n" % (self._yaxis, self._yunit)1014 _str += " Length: %g\n" % len(self.x)1015 1016 return _str1017 1018 def is_slit_smeared(self):1019 """1020 Check whether the data has slit smearing information1021 1022 :return: True is slit smearing info is present, False otherwise1023 1024 """1025 def _check(v):1026 if (v.__class__ == list or v.__class__ == numpy.ndarray) \1027 and len(v) > 0 and min(v) > 0:1028 return True1029 1030 return False1031 1032 return _check(self.dxl) or _check(self.dxw)1033 1034 def clone_without_data(self, length=0, clone=None):1035 """1036 Clone the current object, without copying the data (which1037 will be filled out by a subsequent operation).1038 The data arrays will be initialized to zero.1039 1040 :param length: length of the data array to be initialized1041 :param clone: if provided, the data will be copied to clone1042 """1043 from copy import deepcopy1044 1045 if clone is None or not issubclass(clone.__class__, Data1D):1046 x = numpy.zeros(length)1047 dx = numpy.zeros(length)1048 y = numpy.zeros(length)1049 dy = numpy.zeros(length)1050 clone = Data1D(x, y, dx=dx, dy=dy)1051 1052 clone.title = self.title1053 clone.run = self.run1054 clone.filename = self.filename1055 clone.instrument = self.instrument1056 clone.notes = deepcopy(self.notes)1057 clone.process = deepcopy(self.process)1058 clone.detector = deepcopy(self.detector)1059 clone.sample = deepcopy(self.sample)1060 clone.source = deepcopy(self.source)1061 clone.collimation = deepcopy(self.collimation)1062 clone.trans_spectrum = deepcopy(self.trans_spectrum)1063 clone.meta_data = deepcopy(self.meta_data)1064 clone.errors = deepcopy(self.errors)1065 1066 return clone1067 1068 1069 1084 class Data2D(plottable_2D, DataInfo): 1070 1085 """ -
src/sas/dataloader/loader.py
r79492222 r5e326a6 363 363 :return: DataInfo object 364 364 """ 365 print self.__registry.extensions 365 366 return self.__registry.load(file, format) 366 367 -
src/sas/dataloader/readers/associations.py
r5dfdfa7 r5e326a6 91 91 #import tiff_reader 92 92 import nexus_reader 93 93 import sesans_reader 94 registry_function(sesans_reader) 94 95 registry_function(abs_reader) 95 96 registry_function(ascii_reader) -
src/sas/dataloader/readers/defaults.json
r5dfdfa7 r5e326a6 5 5 "-extension":".xml", 6 6 "-reader":"cansas_reader" 7 }, 8 { 9 "-extension":".ses", 10 "-reader":"sesans_reader" 7 11 }, 8 12 { -
src/sas/perspectives/calculator/image_viewer.py
reec63a8 rd90f91b 16 16 from sas.dataloader.data_info import Detector 17 17 from sas.dataloader.manipulations import reader2D_converter 18 from sas.guiframe.documentation_window import DocumentationWindow 19 18 20 _BOX_WIDTH = 60 19 21 IS_WIN = True … … 138 140 139 141 def on_help(self, event): 140 """ 141 Image Viewer help panel 142 """ 143 from sas.perspectives.calculator.help_panel import HelpWindow 144 # Get models help model_function path 145 import sas.perspectives.calculator as calmedia 146 147 media = calmedia.get_data_path(media='media') 148 path = os.path.join(media,"load_image_help.html") 149 name = "Image Viewer" 150 frame = HelpWindow(self, -1, title=' Help: Image Viewer', 151 pageToOpen=path, size=(640, 450)) 152 try: 153 frame.splitter.DetachWindow(frame.lpanel) 154 # Display only the right side one 155 frame.lpanel.Hide() 156 frame.Show(True) 157 except: 158 frame.Destroy() 159 msg = 'Display Error\n' 160 info = "Info" 161 wx.MessageBox(msg, info) 142 """ 143 Bring up Image Viewer Documentation from the image viewer window 144 whenever the help menu item "how to" is clicked. Calls 145 DocumentationWindow with the path of the location within the 146 documentation tree (after /doc/ ....". 147 148 :param evt: Triggers on clicking "how to" in help menu 149 """ 150 151 _TreeLocation = "user/perspectives/calculator/image_viewer_help.html" 152 _doc_viewer = DocumentationWindow(self, -1, \ 153 _TreeLocation,"Image Viewer Help") 154 162 155 163 156 class SetDialog(wx.Dialog): -
src/sas/perspectives/fitting/basepage.py
r4380c03 rc1694f8 26 26 from sas.perspectives.fitting.pagestate import PageState 27 27 from sas.guiframe.CategoryInstaller import CategoryInstaller 28 from sas.guiframe.documentation_window import DocumentationWindow 29 28 30 29 31 (PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() … … 2916 2918 return graphs, canvases 2917 2919 2918 def on_model_help_clicked(self, event): 2919 """ 2920 Function called when 'Details' button is pressed next to model 2921 of interest. As of Feb 2015 this function follows two paths: 2922 For regular models that ship with the release, it calls the Sphinx 2923 generated html documentation. For plugin models it still uses the 2924 old pop up window reading the description provided in the model. 2925 2926 This will presumably be deprecated when the sas mdels team decides 2927 on how to discover new models and grab their documentation from the 2928 file. 2929 2930 PDB 18 Feb 2015 2931 2932 :param evt: on Details Button pressed event 2933 """ 2934 from sas.perspectives.fitting.help_panel import HelpWindow 2935 from sas.models import get_data_path 2936 2937 # Get models help model_function path 2938 path = get_data_path(media='media') 2939 model_path = os.path.join(path, "model_functions.html") 2920 def on_function_help_clicked(self, event): 2921 """ 2922 Function called when 'Help' button is pressed next to model 2923 of interest. This calls DocumentationWindow from 2924 documentation_window.py. It will load the top level of the model 2925 help documenation sphinx generated html if no model is presented. 2926 If a model IS present then if documention for that model exists 2927 it will load to that point otherwise again it will go to the top. 2928 For Wx2.8 and below is used (i.e. non-released through installer) 2929 a browser is loaded and the top of the model documentation only is 2930 accessible because webbrowser module does not pass anything after 2931 the # to the browser. 2932 2933 :param evt: on Help Button pressed event 2934 """ 2935 2940 2936 if self.model == None: 2941 2937 name = 'index.html' 2942 2938 else: 2943 2939 name = self.formfactorbox.GetValue() 2944 frame = HelpWindow(None, -1, pageToOpen=model_path) 2945 #If model name exists and model is not a custom model 2946 #mod_cat = self.categorybox.GetStringSelection() 2947 if frame.rhelp.HasAnchor(name): 2948 frame.Show(True) 2949 frame.rhelp.ScrollToAnchor(name) 2940 2941 if self.model != None: 2942 _docspath='user/models/model_functions.html#' + name 2943 _doc_viewer = DocumentationWindow(self, -1, _docspath, name + "Help") 2950 2944 else: 2951 if self.model != None: 2952 frame.Destroy() 2953 msg = 'Model description:\n' 2954 if str(self.model.description).rstrip().lstrip() == '': 2955 msg += "Sorry, no information is available for this model." 2956 else: 2957 msg += self.model.description + '\n' 2958 info = "Info" 2959 wx.MessageBox(msg, info) 2945 _doc_viewer = DocumentationWindow(self, -1, "index.html", \ 2946 "General Help") 2947 2948 2949 def on_model_help_clicked(self, event): 2950 """ 2951 Function called when 'Description' button is pressed next to model 2952 of interest. This calls the Description embedded in the model. This 2953 should work with either Wx2.8 and lower or higher. If no model is 2954 selected it will give the message that a model must be chosen first 2955 in the box that would normally contain the description. If a badly 2956 behaved model is encountered which has no description then it will 2957 give the message that none is available. 2958 2959 :param evt: on Description Button pressed event 2960 """ 2961 2962 if self.model == None: 2963 name = 'index.html' 2964 else: 2965 name = self.formfactorbox.GetValue() 2966 2967 msg = 'Model description:\n' 2968 info = "Info" 2969 if self.model != None: 2970 # frame.Destroy() 2971 if str(self.model.description).rstrip().lstrip() == '': 2972 msg += "Sorry, no information is available for this model." 2960 2973 else: 2961 frame.Show(True) 2974 msg += self.model.description + '\n' 2975 wx.MessageBox(msg, info) 2976 else: 2977 msg += "You must select a model to get information on this" 2978 wx.MessageBox(msg, info) 2962 2979 2963 2980 def _on_mag_help(self, event): … … 2966 2983 is clicked. Calls DocumentationWindow with the path of the location 2967 2984 within the documentation tree (after /doc/ ....". When using old 2968 versions of Wx When(i.e. before 2.9 and therefore not part of release2985 versions of Wx (i.e. before 2.9 and therefore not part of release 2969 2986 versions distributed via installer) it brings up an image viewer 2970 2987 box which allows the user to click through the rest of the images in … … 2976 2993 :param evt: Triggers on clicking ? in Magnetic Angles? box 2977 2994 """ 2978 2979 from sas.guiframe.documentation_window import DocumentationWindow2980 2995 2981 2996 _TreeLocation = "_images/M_angles_pic.bmp" … … 3024 3039 :param evt: Triggers on clicking ? in polydispersity box 3025 3040 """ 3026 3027 from sas.guiframe.documentation_window import DocumentationWindow 3028 3041 3029 3042 _TreeLocation = "user/perspectives/fitting/fitting_help.html" 3030 3043 _TreeLocation += "#polydispersity-distributions" … … 3592 3605 self.mbox_description.SetForegroundColour(wx.RED) 3593 3606 id = wx.NewId() 3594 self.model_help = wx.Button(self, id, 'Details', size=(80, 23)) 3607 self.model_func = wx.Button(self, id, 'Help', size=(80, 23)) 3608 self.model_func.Bind(wx.EVT_BUTTON, self.on_function_help_clicked, id=id) 3609 self.model_func.SetToolTipString("Full Model Function Help") 3610 id = wx.NewId() 3611 self.model_help = wx.Button(self, id, 'Description', size=(80, 23)) 3595 3612 self.model_help.Bind(wx.EVT_BUTTON, self.on_model_help_clicked, id=id) 3596 self.model_help.SetToolTipString(" Model Function Help")3613 self.model_help.SetToolTipString("Short Model Function Description") 3597 3614 id = wx.NewId() 3598 3615 self.model_view = wx.Button(self, id, "Show 2D", size=(80, 23)) … … 3636 3653 3637 3654 sizer_radiobutton = wx.GridSizer(2, 2, 5, 5) 3655 3638 3656 3639 3657 #sizer_radiobutton.Add(self.shape_rbutton) 3640 3658 #sizer_radiobutton.Add(self.shape_indep_rbutton) 3641 3659 sizer_radiobutton.Add((5,5)) 3642 sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 15)3660 sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 5) 3643 3661 #sizer_radiobutton.Add(self.plugin_rbutton) 3644 3662 #sizer_radiobutton.Add(self.struct_rbutton) 3645 sizer_radiobutton.Add((5,5)) 3646 sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT, 15) 3663 # sizer_radiobutton.Add((5,5)) 3664 sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT|wx.LEFT, 5) 3665 # sizer_radiobutton.Add((5,5)) 3666 sizer_radiobutton.Add(self.model_func, 1, wx.RIGHT, 5) 3647 3667 sizer_cat.Add(sizer_cat_box, 1, wx.LEFT, 2.5) 3648 3668 sizer_cat.Add(sizer_radiobutton) -
src/sas/perspectives/fitting/report_dialog.py
r4ec242e re8bb5b6 14 14 15 15 import wx 16 import sys17 16 import os 18 17 import wx.html as html 19 import logging20 18 21 _STATICBOX_WIDTH = 480 22 PANEL_WIDTH = 530 23 PANEL_HEIGHT = 700 24 FONT_VARIANT = 1 25 ISMAC = False 26 ISPDF = False 27 if sys.platform == "win32": 28 _STATICBOX_WIDTH = 450 29 PANEL_WIDTH = 500 30 PANEL_HEIGHT = 700 31 FONT_VARIANT = 0 32 ISMAC = False 33 ISPDF = True 34 elif sys.platform == "darwin": 35 ISMAC = True 36 ISPDF = True 19 from sas.guiframe.report_dialog import BaseReportDialog 37 20 38 39 class ReportDialog(wx.Dialog): 21 class ReportDialog(BaseReportDialog): 40 22 """ 41 23 The report dialog box. 42 24 """ 43 25 44 def __init__(self, list, *args, **kwds):26 def __init__(self, report_list, *args, **kwds): 45 27 """ 46 28 Initialization. The parameters added to Dialog are: 47 29 48 :param list: report_list (list of html_str, text_str, image)30 :param report_list: list of html_str, text_str, image 49 31 from invariant_state 50 32 """ 51 kwds["style"] = wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE 52 wx.Dialog.__init__(self, *args, **kwds) 53 kwds["image"] = 'Dynamic Image' 33 super(ReportDialog, self).__init__(report_list, *args, **kwds) 34 54 35 # title 55 36 self.SetTitle("Report: Fitting") 56 # size 57 self.SetSize((720, 650)) 58 # font size 59 self.SetWindowVariant(variant=FONT_VARIANT) 60 # check if tit is MAC 61 self.is_pdf = ISPDF 62 # report string 63 self.report_list = list 37 64 38 # number of images of plot 65 self.nimages = len( list[2])39 self.nimages = len(self.report_list[2]) 66 40 67 if list[2] != None:41 if self.report_list[2] != None: 68 42 # put image path in the report string 69 if len( list[2]) == 1:43 if len(self.report_list[2]) == 1: 70 44 self.report_html = self.report_list[0] % \ 71 45 "memory:img_fit0.png" 72 elif len( list[2]) == 2:46 elif len(self.report_list) == 2: 73 47 self.report_html = self.report_list[0] % \ 74 48 ("memory:img_fit0.png", … … 85 59 self._setup_layout() 86 60 87 def _setup_layout(self):88 """89 Set up layout90 """91 hbox = wx.BoxSizer(wx.HORIZONTAL)92 93 # buttons94 id = wx.ID_OK95 button_close = wx.Button(self, id, "Close")96 button_close.SetToolTipString("Close this report window.")97 #hbox.Add((5,10), 1 , wx.EXPAND|wx.ADJUST_MINSIZE,0)98 hbox.Add(button_close)99 button_close.SetFocus()100 101 id = wx.NewId()102 button_preview = wx.Button(self, id, "Preview")103 button_preview.SetToolTipString("Print preview this report.")104 button_preview.Bind(wx.EVT_BUTTON, self.onPreview,105 id=button_preview.GetId())106 hbox.Add(button_preview)107 108 id = wx.NewId()109 button_print = wx.Button(self, id, "Print")110 button_print.SetToolTipString("Print this report.")111 button_print.Bind(wx.EVT_BUTTON, self.onPrint,112 id=button_print.GetId())113 hbox.Add(button_print)114 115 id = wx.NewId()116 button_save = wx.Button(self, id, "Save")117 button_save.SetToolTipString("Save this report.")118 button_save.Bind(wx.EVT_BUTTON, self.onSave, id=button_save.GetId())119 hbox.Add(button_save)120 121 # panel for report page122 #panel = wx.Panel(self, -1)123 vbox = wx.BoxSizer(wx.VERTICAL)124 # html window125 self.hwindow = html.HtmlWindow(self, style=wx.BORDER)126 # set the html page with the report string127 self.hwindow.SetPage(self.report_html)128 129 # add panels to boxsizers130 vbox.Add(hbox)131 vbox.Add(self.hwindow, 1, wx.EXPAND|wx.ALL,0)132 133 self.SetSizer(vbox)134 self.Centre()135 self.Show(True)136 137 61 def onSave(self, event=None): 138 62 """ 139 63 Save 140 64 """ 141 # pdf supporting only on MAC, not on exe142 if self.is_pdf:143 wild_card = ' PDF files (*.pdf)|*.pdf|'144 ind_cor = 0145 else:146 wild_card = ''147 ind_cor = 1148 wild_card += 'HTML files (*.html)|*.html|'149 wild_card += 'Text files (*.txt)|*.txt'150 151 65 #todo: complete saving fig file and as a txt file 152 66 dlg = wx.FileDialog(self, "Choose a file", 153 wildcard= wild_card,67 wildcard=self.wild_card, 154 68 style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) 155 69 dlg.SetFilterIndex(0) # Set .html files to be default … … 166 80 pic_fname = [] 167 81 #PDF 168 if ext_num == (0 + 2 * ind_cor):82 if ext_num == (0 + 2 * self.index_offset): 169 83 # TODO: Sort this case out 170 84 ext = '.pdf' … … 216 130 return 217 131 #HTML + png(graph) 218 elif ext_num == (1 - ind_cor):132 elif ext_num == (1 - self.index_offset): 219 133 ext = '.html' 220 134 for num in range(self.nimages): … … 222 136 report_frame = self.report_list[0] 223 137 #TEXT + pdf(graph) 224 elif ext_num == (2 - ind_cor):138 elif ext_num == (2 - self.index_offset): 225 139 ext = '.txt' 226 140 # changing the image extension actually changes the image … … 241 155 pic_fname.append(pic_name) 242 156 #put the image path in html string 243 if ext_num == (1 - ind_cor):157 if ext_num == (1 - self.index_offset): 244 158 if self.nimages == 1: 245 159 report = report_frame % os.path.basename(pic_fname[0]) … … 259 173 self.report_list[2][num].savefig(pic_fname[num]) 260 174 261 def onPreview(self, event=None):262 """263 Preview264 265 : event: Preview button event266 """267 previewh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)268 previewh.PreviewText(self.report_html)269 if event is not None:270 event.Skip()271 self.Update()272 273 def onPrint(self, event=None):274 """275 Print276 277 : event: Print button event278 """279 printh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)280 printh.PrintText(self.report_html)281 if event is not None:282 event.Skip()283 self.Update()284 285 def OnClose(self, event=None):286 """287 Close the Dialog288 289 : event: Close button event290 """291 self.Close()292 # Reset memory293 #wx.MemoryFSHandler()294 if event is not None:295 event.Skip()296 297 def HTML2PDF(self, data, filename):298 """299 Create a PDF file from html source string.300 Returns True is the file creation was successful.301 302 : data: html string303 : filename: name of file to be saved304 """305 try:306 from xhtml2pdf import pisa307 # open output file for writing (truncated binary)308 resultFile = open(filename, "w+b")309 # convert HTML to PDF310 pisaStatus = pisa.CreatePDF(data, dest=resultFile)311 # close output file312 resultFile.close()313 self.Update()314 return pisaStatus.err315 except:316 logging.error("Error creating pdf: %s" % sys.exc_value)317 return False -
src/sas/perspectives/invariant/report_dialog.py
r4ec242e re8bb5b6 15 15 """ 16 16 import wx 17 import sys18 17 import os 19 18 import wx.html as html 20 import logging 21 ISPDF = False 22 if sys.platform == "win32": 23 _STATICBOX_WIDTH = 450 24 PANEL_WIDTH = 500 25 PANEL_HEIGHT = 700 26 FONT_VARIANT = 0 27 ISMAC = False 28 ISPDF = True 29 elif sys.platform == "darwin": 30 _STATICBOX_WIDTH = 480 31 PANEL_WIDTH = 530 32 PANEL_HEIGHT = 700 33 FONT_VARIANT = 1 34 ISMAC = True 35 ISPDF = True 36 37 class ReportDialog(wx.Dialog): 19 20 from sas.guiframe.report_dialog import BaseReportDialog 21 22 class ReportDialog(BaseReportDialog): 38 23 """ 39 24 The report dialog box. 40 25 """ 41 26 42 def __init__(self, list, *args, **kwds):27 def __init__(self, report_list, *args, **kwds): 43 28 """ 44 29 Initialization. The parameters added to Dialog are: 45 30 46 :param list: report_list (list of html_str, text_str, image)31 :param report_list: list of html_str, text_str, image 47 32 from invariant_state 48 33 """ 49 kwds["style"] = wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE 50 wx.Dialog.__init__(self, *args, **kwds) 51 kwds["image"] = 'Dynamic Image' 34 super(ReportDialog, self).__init__(report_list, *args, **kwds) 35 52 36 # title 53 37 self.SetTitle("Report: Invariant computaion") 54 # size55 self.SetSize((720, 650))56 # font size57 self.SetWindowVariant(variant=FONT_VARIANT)58 38 59 # check if tit is MAC60 self.is_pdf = ISPDF61 62 # report string63 self.report_list = list64 39 # put image path in the report string 65 40 self.report_html = self.report_list[0] % "memory:img_inv.png" 66 41 # layout 67 42 self._setup_layout() 68 # wild card69 # pdf supporting only on MAC70 if self.is_pdf:71 self.wild_card = ' PDF files (*.pdf)|*.pdf|'72 else:73 self.wild_card = ''74 self.wild_card += 'HTML files (*.html)|*.html|'75 self.wild_card += 'Text files (*.txt)|*.txt'76 77 78 79 def _setup_layout(self):80 """81 Set up layout82 """83 hbox = wx.BoxSizer(wx.HORIZONTAL)84 85 # buttons86 id = wx.ID_OK87 button_close = wx.Button(self, id, "Close")88 button_close.SetToolTipString("Close this report window.")89 #hbox.Add((5,10), 1 , wx.EXPAND|wx.ADJUST_MINSIZE,0)90 hbox.Add(button_close)91 button_close.SetFocus()92 93 id = wx.NewId()94 button_preview = wx.Button(self, id, "Preview")95 button_preview.SetToolTipString("Print preview this report.")96 button_preview.Bind(wx.EVT_BUTTON, self.onPreview,97 id=button_preview.GetId())98 hbox.Add(button_preview)99 100 id = wx.NewId()101 button_print = wx.Button(self, id, "Print")102 button_print.SetToolTipString("Print this report.")103 button_print.Bind(wx.EVT_BUTTON, self.onPrint,104 id=button_print.GetId())105 hbox.Add(button_print)106 107 id = wx.NewId()108 button_save = wx.Button(self, id, "Save" )109 button_save.SetToolTipString("Save this report.")110 button_save.Bind(wx.EVT_BUTTON, self.onSave, id = button_save.GetId())111 hbox.Add(button_save)112 113 # panel for report page114 #panel = wx.Panel(self, -1)115 vbox = wx.BoxSizer(wx.VERTICAL)116 # html window117 self.hwindow = html.HtmlWindow(self,style=wx.BORDER)118 # set the html page with the report string119 self.hwindow.SetPage(self.report_html)120 121 # add panels to boxsizers122 vbox.Add(hbox)123 vbox.Add(self.hwindow, 1, wx.EXPAND|wx.ALL,0)124 125 self.SetSizer(vbox)126 self.Centre()127 self.Show(True)128 129 43 130 44 def onSave(self, event=None): … … 144 58 fName = dlg.GetPath() 145 59 ext_num = dlg.GetFilterIndex() 146 # index correction147 if not self.is_pdf:148 ind_cor = 1149 else:150 ind_cor = 0151 60 #set file extensions 152 if ext_num == (0 + 2 * ind_cor):153 61 if ext_num == (0 + 2 * self.index_offset): 62 # TODO: Sort this case out 154 63 ext = '.pdf' 155 64 img_ext = '_img.png' … … 186 95 os.remove(pic_fname) 187 96 return 188 elif ext_num == (1 - ind_cor):97 elif ext_num == (1 - self.index_offset): 189 98 ext = '.html' 190 99 img_ext = '_img4html.png' 191 100 report_frame = self.report_list[0] 192 elif ext_num == (2 - ind_cor):101 elif ext_num == (2 - self.index_offset): 193 102 ext = '.txt' 194 103 # changing the image extension actually changes the image … … 205 114 pic_fname = os.path.splitext(fName)[0] + img_ext 206 115 #put the image path in html string 207 if ext_num == (1 - ind_cor):116 if ext_num == (1 - self.index_offset): 208 117 report = report_frame % os.path.basename(pic_fname) 209 118 … … 214 123 self.report_list[2].savefig(pic_fname) 215 124 216 217 def onPreview(self, event=None):218 """219 Preview220 221 : event: Preview button event222 """223 previewh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)224 previewh.PreviewText(self.report_html)225 if event is not None:226 event.Skip()227 228 def onPrint(self, event=None):229 """230 Print231 232 : event: Print button event233 """234 printh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)235 printh.PrintText(self.report_html)236 if event is not None:237 event.Skip()238 239 def OnClose(self,event=None):240 """241 Close the Dialog242 243 : event: Close button event244 """245 self.Close()246 247 def HTML2PDF(self, data, filename):248 """249 Create a PDF file from html source string.250 Returns True is the file creation was successful.251 252 : data: html string253 : filename: name of file to be saved254 """255 try:256 from xhtml2pdf import pisa257 # open output file for writing (truncated binary)258 resultFile = open(filename, "w+b")259 # convert HTML to PDF260 pisaStatus = pisa.CreatePDF(data, dest=resultFile)261 # close output file262 resultFile.close()263 self.Update()264 return pisaStatus.err265 except:266 logging.error("Error creating pdf: %s" % sys.exc_value)267 return False -
src/sas/perspectives/calculator/media/data_operator_help.rst
r684fade rad4d8b4 34 34 available operators are: 35 35 36 * + (for addition)37 * - (for subtraction),38 * * (for multiplication)39 * / (for division)40 * | (for combination of two data sets)36 * \+ (for addition) 37 * \- (for subtraction) 38 * \* (for multiplication) 39 * \/ (for division) 40 * \| (for combination of two data sets) 41 41 42 42 If two data sets do not match, the operation will fail and the background -
src/sas/perspectives/calculator/media/density_calculator_help.rst
r054a3ad r36819ee 19 19 ------ 20 20 21 1) Enter the empirical formula of a molecule. For mixtures, the ratio of each 21 22 1) Select *Density/Volume Calculator* from the *Tool* menu on the SasView toolbar. 23 24 2) Enter the empirical formula of a molecule. For mixtures, the ratio of each 22 25 of the molecules should be used, for example, (H2O)0.5(D2O)0.5. 23 26 24 2) Use the input combo box to choose between molar volume or mass density and27 3) Use the input combo box to choose between molar volume or mass density and 25 28 then type in an input value. 26 29 27 3) Click the 'Calculate' button to perform the calculation.30 4) Click the 'Calculate' button to perform the calculation. 28 31 29 32 .. image:: density_tutor.gif -
src/sas/perspectives/calculator/media/image_viewer_help.rst
r920928f r1e01486 14 14 plot can also be resized by dragging the corner of the panel. 15 15 16 Supported image formats are png, bmp, gif, or jpg. (There is currently a bug in 17 the tif loader) 16 The supported input image formats are: 17 18 * BMP (bitmap format) 19 * GIF (graphical interchange format) 20 * JPG (joint photographic experts group format) 21 * PNG (portable network graphics format) 22 * TIF (tagged image format) 18 23 19 24 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ … … 22 27 ------ 23 28 24 1 . Select 'Image Viewer' under the 'Tool' menu in the menubar.29 1) Select *Image Viewer* from the *Tool* menu on the SasView toolbar. 25 30 26 2. Select a file type from the drop-box at the bottom of the file dialog panel, 27 choose a file of interest, and then click the 'Open' button (see the 28 picture below). 31 2) Select a file and then click *Open*. 29 32 30 33 .. image:: load_image.bmp 31 34 32 3. If the loading is successful, the image will be displayed. The file name 33 will be shown in the title bar (see the picture below). 35 If the loading is successful the image will be displayed. 34 36 35 4. Some options such as saving, printing, and copying are available from the36 menubar, or in the context-menu (by right-clicking anywhere in the plot).37 3) To save, print, or copy the image, or to apply a grid overlay, right-click 38 anywhere in the plot. 37 39 38 40 .. image:: pic_plot.bmp 39 41 40 5. If the image is taken from a 2D detector, it can be converted into 2D data41 where the z values are computed as42 4. If the image is taken from a 2D detector, SasView can attempt to convert 43 the colour/grey scale into pseudo-intensity 2D data using 42 44 43 z = (0.299 x R) + (0.587 x G) + (0.114 x B)45 z = (0.299 x R) + (0.587 x G) + (0.114 x B) 44 46 45 unless the picture file is formatted as 8-bit grey-scale tif.47 unless the image is formatted as 8-bit grey-scale TIF. 46 48 47 In the "Convert to Data" dialog, set the parameters relevant to yourdata and48 then click the OK button.49 5. In the *Convert to Data* dialog, set the parameters relevant to the data and 50 then click the OK. 49 51 50 52 .. image:: pic_convert.bmp 53 54 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 55 56 .. note:: This help document was last changed by Steve King, 18Feb2015 -
src/sas/perspectives/calculator/media/kiessig_calculator_help.rst
rec392464 r1e01486 3 3 .. This is a port of the original SasView html help file to ReSTructured text 4 4 .. by S King, ISIS, during SasView CodeCamp-III in Feb 2015. 5 6 .. |pi| unicode:: U+03C0 7 .. |Ang| unicode:: U+212B 5 8 6 9 Kiessig Thickness Calculator Tool … … 10 13 ----------- 11 14 12 This tool is to approximately estimate the thickness of a layer or the13 diameter of particles from the Kiessig fringe in SAS/NR data, and using the14 Kiessigrelation15 This tool is approximately estimates the thickness of a layer or the diameter 16 of particles from the position of the Kiessig fringe/Bragg peak in NR/SAS data 17 using the relation 15 18 16 thickness = 2*Pi/fringe_width. 19 (thickness *or* size) = 2 * |pi| / (fringe_width *or* peak position) 17 20 18 21 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 19 20 22 21 23 How To 22 24 ------ 23 25 24 To get a rough thickness or particle size, just type the Kiessig fringe width 25 (in units of 1/Angstrom) and click on the 'Compute' button. Then the output 26 value will be show up in the 'Thickness' text box. 26 To get a rough thickness or particle size, simply type the fringe or peak 27 position (in units of 1/|Ang|\) and click on the *Compute* button. 28 29 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 30 31 .. note:: This help document was last changed by Steve King, 18Feb2015 32
Note: See TracChangeset
for help on using the changeset viewer.