Changeset 83eff66 in sasview
- Timestamp:
- Feb 19, 2015 4:09:00 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:
- 66f21cd, 27ab091
- Parents:
- f53cd30 (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. - Files:
-
- 3 added
- 1 deleted
- 15 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/guiframe/media/graph_help.rst
r3fd3d5a4 r1394952 286 286 287 287 1D data can be saved in either ASCII text (.TXT) or CanSAS/SASXML (.XML) 288 formats (see 1D_Formats_). 2D data can only be saved in the NIST 2D format 289 (.DAT) (see 2D_Formats_). 288 formats (see :ref:`1D_Formats`). 289 290 2D data can only be saved in the NIST 2D format (.DAT) (see :ref:`2D_Formats`). 290 291 291 292 .. _Linear_Fit: -
src/sas/models/media/model_functions.rst
r3342eb3 r7072ce6 10 10 11 11 .. To do: 12 .. Remove the 'This is xi' & 'This is zeta' lines before release!13 12 .. Add example parameters/plots for the CoreShellEllipsoidXTModel 14 13 .. Add example parameters/plots for the RectangularPrism models … … 20 19 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 21 20 21 22 .. note:: The contents of this document are awaiting proof reading. Feb2015 22 23 23 24 … … 169 170 - RaspBerryModel_ 170 171 - CoreShellModel_ (including magnetic 2D version) 172 - MicelleSphCoreModel_ 171 173 - CoreMultiShellModel_ (including magnetic 2D version) 172 174 - Core2ndMomentModel_ … … 3372 3374 3373 3375 3376 .. _MicelleSphCoreModel: 3377 3378 **2.1.42. MicelleSphCoreModel** 3379 3380 This model provides the form factor, *P(q)*, for a micelle with a spherical core 3381 and Gaussian polymer chains attached to the surface. 3382 3383 *2.1.42.1. Definition* 3384 3385 The 1D scattering intensity for this model is calculated according to the equations given by Pedersen 3386 (Pedersen, 2000). 3387 3388 *2.1.42.2. Validation of the MicelleSphCoreModel* 3389 3390 This model has not yet been validated. Feb2015 3391 3392 REFERENCES 3393 3394 J Pedersen, *J. Appl. Cryst.*, 33 (2000) 637-640 3395 3396 3397 3374 3398 2.2 Shape-independent Functions 3375 3399 ------------------------------- -
src/sas/perspectives/calculator/image_viewer.py
r7a04dbb 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 … … 59 61 plot_frame = ImageFrame(parent, -1, basename, img) 60 62 plot_frame.Show(False) 61 #plot_frame.im_show(img)62 63 ax = plot_frame.plotpanel 63 64 if not is_png: … … 73 74 except: 74 75 print "parent", parent 75 raise76 76 err_msg += "Failed to load '%s'.\n"% basename 77 77 if err_msg: … … 80 80 else: 81 81 print err_msg 82 83 82 84 83 def choose_data_file(self, location=None): … … 86 85 Open a file dialog to allow loading a file 87 86 """ 88 parent = self.parent89 87 path = None 90 88 if location == None: 91 89 location = os.getcwd() 92 wlist = '' 93 elist = ["All images (*.png, *.bmp, *.gif, *.jpg, *.tif, *.tiff) | \ 94 *.png; *.bmp; *.gif; *.jpg; *.tif; *.tiff", 95 "PNG files (*.PNG, *.png) | *.png", 96 "BMP files (*.BMP, *.bmp) | *.bmp", 97 "GIF files (*.GIF, *.gif) | *.gif", 98 "JPG files (*.JPG, *.jpg) | *.jpg", 99 "TIF files (*.TIF, *.tif) | *.tif", 100 "TIFF files (*.TIFF, *.tiff) | *.tiff"] 101 if not IS_WIN: 102 del elist[0] 103 elist.append("All files (*.*) | *.*") 104 wlist = '|'.join(elist) 105 style = wx.OPEN|wx.FD_MULTIPLE 106 dlg = wx.FileDialog(parent, "Image Viewer: Choose a image file", 107 location, "", wlist, style=style) 90 dlg = wx.FileDialog(self.parent, "Image Viewer: Choose a image file", 91 location, "", "", style=wx.FD_OPEN|wx.FD_MULTIPLE) 108 92 if dlg.ShowModal() == wx.ID_OK: 109 93 path = dlg.GetPaths() … … 156 140 157 141 def on_help(self, event): 158 """ 159 Image Viewer help panel 160 """ 161 from sas.perspectives.calculator.help_panel import HelpWindow 162 # Get models help model_function path 163 import sas.perspectives.calculator as calmedia 164 165 media = calmedia.get_data_path(media='media') 166 path = os.path.join(media,"load_image_help.html") 167 name = "Image Viewer" 168 frame = HelpWindow(self, -1, title=' Help: Image Viewer', 169 pageToOpen=path, size=(640, 450)) 170 try: 171 frame.splitter.DetachWindow(frame.lpanel) 172 # Display only the right side one 173 frame.lpanel.Hide() 174 frame.Show(True) 175 except: 176 frame.Destroy() 177 msg = 'Display Error\n' 178 info = "Info" 179 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 180 155 181 156 class SetDialog(wx.Dialog): -
src/sas/perspectives/calculator/media/data_operator_help.rst
r98b30b4 r684fade 9 9 Description 10 10 ----------- 11 This dialog panel provides arithmetic operations between two data sets (the12 last data set could be a number).13 11 14 When data1 and data2 are selected, their x (or qx and qy for 2D) value(s) 15 must match with each other. 12 This tool permits arithmetic operations between two data sets. Alternatively, 13 the last data set can be a number. 14 15 *NOTE! When* Data1 *and* Data2 *are both data, their Q (or Qx and Qy for 2D) 16 value(s) must match with each other UNLESS using the 'append' operator.* 16 17 17 18 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ … … 19 20 How To 20 21 ------ 21 1. Type the data name resulted from an operation.22 22 23 2) Select a data/theory in the drop down menus. When data2 is set to number, 24 type a number in the text control box. 23 1) Enure you have loaded data into the *Data Explorer* (see :ref:`Load_Data`). 25 24 26 3) Select an arithmetic operator symbol; + (for addition), - (for subtraction), 27 * (for multiplication), / (for division), and | (for combination of two data 28 sets). 25 2) Select *Data Operation* from the *Tool* menu on the SasView toolbar. 29 26 30 If two data sets do not match, the operation will fail and the background color 31 of the combo box items will turn to red (WIN only).27 3) Select a dataset/theory in the drop-down menu *Data1*. A mini-plot of the 28 data will appear underneath. 32 29 33 4) If the operation is successful, hit the Apply button to make the new data.34 Then the data name will be shown up in the data box in the data explorer.30 4) Select a dataset/theory in the drop-down menu *Data2* or select *Number* 31 and enter a number in the box that appears alongside. 35 32 36 Note: Any errors and warnings will be displayed at the bottom of the SasView 37 window. 33 5) Select an arithmetic operator symbol from the *Operator* drop-down. The 34 available operators are: 35 36 * + (for addition) 37 * - (for subtraction), 38 * * (for multiplication) 39 * / (for division) 40 * | (for combination of two data sets) 41 42 If two data sets do not match, the operation will fail and the background 43 color of the combo box items will turn to red (WIN only). 44 45 6) If the operation is successful, hit the Apply button to make the new dataset. 46 The new dataset will appear in the *Data Explorer*. 47 48 *NOTE! Any errors and warnings will be displayed at the bottom of the SasView 49 window.* 38 50 39 51 .. image:: data_oper_pic.png 52 53 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 54 55 .. note:: This help document was last changed by Steve King, 18Feb2015 -
src/sas/perspectives/calculator/media/density_calculator_help.rst
rec392464 r054a3ad 10 10 ----------- 11 11 12 This tool is to calculatethe mass density from the molar volume or vice12 This tool calculates the mass density from the molar volume or vice 13 13 versa. To calculate the mass density, the chemical formula and molar volume 14 14 should be provided. … … 19 19 ------ 20 20 21 1. Molecular Formula: The chemical formula of ONE molecule or ONE atom. For 22 mixtures, the ratio of the each molecules should be used; for example, 23 (H2O)0.5(D2O)0.5. 21 1) Enter the empirical formula of a molecule. For mixtures, the ratio of each 22 of the molecules should be used, for example, (H2O)0.5(D2O)0.5. 24 23 25 2 . Select input (molar volume or mass density) from combobox. Then type in the26 input value.24 2) Use the input combo box to choose between molar volume or mass density and 25 then type in an input value. 27 26 28 3. Click the 'Calculate' button to perform the calculation. 29 30 4. Outputs also include the molar mass (weight) that depends only on the 31 chemical formula 27 3) Click the 'Calculate' button to perform the calculation. 32 28 33 29 .. image:: density_tutor.gif 30 31 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 32 33 .. note:: This help document was last changed by Steve King, 18Feb2015 -
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 -
sasview/local_config.py
r3a39c2e rf53cd30 7 7 import sas.sasview 8 8 import logging 9 from sas.guiframe.config import _do_acknowledge 9 10 10 11 # Version of the application … … 29 30 # About box info 30 31 _do_aboutbox = True 32 _do_acknowledge = True 31 33 _do_tutorial = True 34 _acknowledgement_preamble =\ 35 '''If you found this software useful to your work please remember to acknowledge 36 its use in your publications as suggested below and reference the SasView website: 37 http://www.sasview.org/index.html. Please also consider letting us know by sending us the 38 reference to your work. This will help us to ensure the long term support and 39 development of the software. 40 ''' 41 _acknowledgement_publications = \ 42 '''This work originally developed as part of the DANSE project funded by the NSF 43 under grant DMR-0520547, and currently maintained by NIST, UMD, ORNL, ISIS, ESS 44 and ILL. 45 ''' 32 46 _acknowledgement = \ 33 47 '''This work originally developed as part of the DANSE project funded by the NSF -
src/sas/guiframe/config.py
rfd5ac0d rf53cd30 26 26 # About box info 27 27 _do_aboutbox = True 28 _do_acknowledge = True 28 29 _do_tutorial = True 30 _acknowledgement_preamble =\ 31 '''If you found this software useful to your work please remember to acknowledge 32 its use in your publications as suggested below and reference the SasView website: 33 http://www.sasview.org/index.html. Please also consider letting us know by sending us the 34 reference to your work. This will help us to ensure the long term support and 35 development of the software. 36 ''' 37 _acknowledgement_publications = \ 38 '''This work originally developed as part of the DANSE project funded by the NSF 39 under grant DMR-0520547, and currently maintained by NIST, UMD, ORNL, ISIS, ESS 40 and ILL. 41 ''' 29 42 _acknowledgement = \ 30 43 '''This software was developed by the University of Tennessee as part of the -
src/sas/guiframe/gui_manager.py
r707c6be rf53cd30 1351 1351 wx.EVT_MENU(self, id, self._onTutorial) 1352 1352 1353 if config._do_acknowledge: 1354 self._help_menu.AppendSeparator() 1355 self._help_menu.Append(id, '&Acknowledge', 'Acknowledging SasView') 1356 wx.EVT_MENU(self, id, self._onAcknowledge) 1357 1353 1358 if config._do_aboutbox: 1354 1359 self._help_menu.AppendSeparator() … … 2098 2103 self.SetStatusText(msg) 2099 2104 2105 def _onAcknowledge(self, evt): 2106 """ 2107 Pop up the acknowledge dialog 2108 2109 :param evt: menu event 2110 2111 """ 2112 if config._do_acknowledge: 2113 import sas.guiframe.acknowledgebox as AcknowledgeBox 2114 dialog = AcknowledgeBox.DialogAcknowledge(None, -1, "") 2115 dialog.ShowModal() 2116 2100 2117 def _onAbout(self, evt): 2101 2118 """
Note: See TracChangeset
for help on using the changeset viewer.