Changeset 83eff66 in sasview for src/sas


Ignore:
Timestamp:
Feb 19, 2015 4:09:00 AM (10 years ago)
Author:
krzywon
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.
Message:

Merge branch 'master' of https://github.com/SasView/sasview/

Location:
src/sas
Files:
3 added
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • src/sas/dataloader/data_info.py

    r7eaf9f2 r5e326a6  
    2626import math 
    2727 
    28  
    2928class plottable_sesans1D: 
    3029    """ 
    3130    SESANS is a place holder for 1D SESANS plottables. 
    3231     
    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. 
    3534    """ 
    3635    # The presence of these should be mutually 
     
    3837    x = None 
    3938    y = None 
     39    lam = None 
    4040    dx = None 
    4141    dy = None 
     42    dlam = None 
    4243    ## Slit smearing length 
    4344    dxl = None 
     
    5152    _yunit = '' 
    5253     
    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" 
    5456        self.x = numpy.asarray(x) 
    5557        self.y = numpy.asarray(y) 
     58        self.lam = numpy.asarray(lam) 
    5659        if dx is not None: 
    5760            self.dx = numpy.asarray(dx) 
    5861        if dy is not None: 
    5962            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" 
    6570    def xaxis(self, label, unit): 
    6671        """ 
     
    6974        self._xaxis = label 
    7075        self._xunit = unit 
    71          
     76        print "xaxis active" 
     77        print label 
     78        print unit 
    7279    def yaxis(self, label, unit): 
    7380        """ 
    7481        set the y axis label and unit 
    7582        """ 
     83        print "yaxis active" 
     84        print label 
     85        print unit 
     86         
    7687        self._yaxis = label 
    7788        self._yunit = unit 
     
    750761        """ 
    751762        return self._perform_union(other) 
    752                  
     763   
     764class 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               
    753844class Data1D(plottable_1D, DataInfo): 
    754845    """ 
     
    9911082         
    9921083         
    993 class SESANSData1D(plottable_sesans1D, DataInfo): 
    994     """ 
    995     SESANS 1D data class 
    996     """ 
    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 printout 
    1007         """ 
    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 _str 
    1017  
    1018     def is_slit_smeared(self): 
    1019         """ 
    1020         Check whether the data has slit smearing information 
    1021          
    1022         :return: True is slit smearing info is present, False otherwise 
    1023          
    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 True 
    1029              
    1030             return False 
    1031          
    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 (which 
    1037         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 initialized 
    1041         :param clone: if provided, the data will be copied to clone 
    1042         """ 
    1043         from copy import deepcopy 
    1044          
    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.title 
    1053         clone.run            = self.run 
    1054         clone.filename       = self.filename 
    1055         clone.instrument     = self.instrument 
    1056         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 clone 
    1067      
    1068      
    10691084class Data2D(plottable_2D, DataInfo): 
    10701085    """ 
  • src/sas/dataloader/loader.py

    r79492222 r5e326a6  
    363363        :return: DataInfo object 
    364364        """ 
     365        print self.__registry.extensions 
    365366        return self.__registry.load(file, format) 
    366367     
  • src/sas/dataloader/readers/associations.py

    r5dfdfa7 r5e326a6  
    9191    #import tiff_reader 
    9292    import nexus_reader 
    93  
     93    import sesans_reader 
     94    registry_function(sesans_reader) 
    9495    registry_function(abs_reader) 
    9596    registry_function(ascii_reader) 
  • src/sas/dataloader/readers/defaults.json

    r5dfdfa7 r5e326a6  
    55            "-extension":".xml", 
    66            "-reader":"cansas_reader" 
     7         }, 
     8         { 
     9            "-extension":".ses", 
     10            "-reader":"sesans_reader" 
    711         }, 
    812         { 
  • src/sas/guiframe/media/graph_help.rst

    r3fd3d5a4 r1394952  
    286286 
    2872871D 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_). 
     288formats (see :ref:`1D_Formats`). 
     289 
     2902D data can only be saved in the NIST 2D format (.DAT) (see :ref:`2D_Formats`). 
    290291 
    291292.. _Linear_Fit: 
  • src/sas/models/media/model_functions.rst

    r3342eb3 r7072ce6  
    1010 
    1111.. To do: 
    12 .. Remove the 'This is xi' & 'This is zeta' lines before release! 
    1312.. Add example parameters/plots for the CoreShellEllipsoidXTModel 
    1413.. Add example parameters/plots for the RectangularPrism models 
     
    2019.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    2120 
     21 
     22.. note::  The contents of this document are awaiting proof reading. Feb2015 
    2223 
    2324 
     
    169170- RaspBerryModel_ 
    170171- CoreShellModel_ (including magnetic 2D version) 
     172- MicelleSphCoreModel_ 
    171173- CoreMultiShellModel_ (including magnetic 2D version) 
    172174- Core2ndMomentModel_ 
     
    33723374 
    33733375 
     3376.. _MicelleSphCoreModel: 
     3377 
     3378**2.1.42. MicelleSphCoreModel** 
     3379 
     3380This model provides the form factor, *P(q)*, for a micelle with a spherical core  
     3381and Gaussian polymer chains attached to the surface. 
     3382 
     3383*2.1.42.1. Definition* 
     3384 
     3385The 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 
     3390This model has not yet been validated. Feb2015 
     3391 
     3392REFERENCES 
     3393 
     3394J Pedersen, *J. Appl. Cryst.*, 33 (2000) 637-640 
     3395 
     3396 
     3397 
    337433982.2 Shape-independent Functions 
    33753399------------------------------- 
  • src/sas/perspectives/calculator/image_viewer.py

    r7a04dbb rd90f91b  
    1616from sas.dataloader.data_info import Detector 
    1717from sas.dataloader.manipulations import reader2D_converter 
     18from sas.guiframe.documentation_window import DocumentationWindow 
     19 
    1820_BOX_WIDTH = 60 
    1921IS_WIN = True 
     
    5961                plot_frame = ImageFrame(parent, -1, basename, img) 
    6062                plot_frame.Show(False) 
    61                 #plot_frame.im_show(img) 
    6263                ax = plot_frame.plotpanel 
    6364                if not is_png: 
     
    7374            except: 
    7475                print "parent", parent 
    75                 raise 
    7676                err_msg += "Failed to load '%s'.\n"% basename 
    7777        if err_msg: 
     
    8080            else: 
    8181                print err_msg 
    82  
    8382         
    8483    def choose_data_file(self, location=None): 
     
    8685        Open a file dialog to allow loading a file 
    8786        """ 
    88         parent = self.parent 
    8987        path = None 
    9088        if location == None: 
    9189            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) 
    10892        if dlg.ShowModal() == wx.ID_OK: 
    10993            path = dlg.GetPaths() 
     
    156140 
    157141    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         
    180155             
    181156class SetDialog(wx.Dialog): 
  • src/sas/perspectives/calculator/media/data_operator_help.rst

    r98b30b4 r684fade  
    99Description 
    1010----------- 
    11 This dialog panel provides arithmetic operations between two data sets (the  
    12 last data set could be a number). 
    1311 
    14 When data1 and data2 are selected, their x (or qx and qy for 2D) value(s) 
    15 must match with each other. 
     12This tool permits arithmetic operations between two data sets. Alternatively,  
     13the 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)  
     16value(s) must match with each other UNLESS using the 'append' operator.* 
    1617 
    1718.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    1920How To 
    2021------ 
    21 1. Type the data name resulted from an operation. 
    2222 
    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. 
     231) Enure you have loaded data into the *Data Explorer* (see :ref:`Load_Data`). 
    2524 
    26 3) Select an arithmetic operator symbol; + (for addition), - (for subtraction),  
    27    * (for multiplication), / (for division), and | (for combination of two data 
    28    sets). 
     252) Select *Data Operation* from the *Tool* menu on the SasView toolbar. 
    2926 
    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). 
     273) Select a dataset/theory in the drop-down menu *Data1*. A mini-plot of the 
     28   data will appear underneath. 
    3229 
    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. 
     304) Select a dataset/theory in the drop-down menu *Data2* or select *Number*  
     31   and enter a number in the box that appears alongside. 
    3532 
    36 Note: Any errors and warnings will be displayed at the bottom of the SasView 
    37 window. 
     335) 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 
     456) 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 
     49window.* 
    3850 
    3951.. 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  
    1010----------- 
    1111 
    12 This tool is to calculate the mass density from the molar volume or vice  
     12This tool calculates the mass density from the molar volume or vice  
    1313versa. To calculate the mass density, the chemical formula and molar volume  
    1414should be provided. 
     
    1919------ 
    2020 
    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. 
     211) 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. 
    2423 
    25 2. Select input (molar volume or mass density) from combobox. Then type in the  
    26 input value. 
     242) Use the input combo box to choose between molar volume or mass density and  
     25   then type in an input value. 
    2726 
    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 
     273) Click the 'Calculate' button to perform the calculation. 
    3228 
    3329.. 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  
    2626from sas.perspectives.fitting.pagestate import PageState 
    2727from sas.guiframe.CategoryInstaller import CategoryInstaller 
     28from sas.guiframe.documentation_window import DocumentationWindow 
     29 
    2830 
    2931(PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() 
     
    29162918        return graphs, canvases 
    29172919 
    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 
    29402936        if self.model == None: 
    29412937            name = 'index.html' 
    29422938        else: 
    29432939            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") 
    29502944        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." 
    29602973            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) 
    29622979 
    29632980    def _on_mag_help(self, event):     
     
    29662983        is clicked. Calls DocumentationWindow with the path of the location  
    29672984        within the documentation tree (after /doc/ ....". When using old  
    2968         versions of Wx When (i.e. before 2.9 and therefore not part of release 
     2985        versions of Wx (i.e. before 2.9 and therefore not part of release 
    29692986        versions distributed via installer) it brings up an image viewer 
    29702987        box which allows the user to click through the rest of the images in  
     
    29762993        :param evt: Triggers on clicking ? in Magnetic Angles? box 
    29772994        """ 
    2978          
    2979         from sas.guiframe.documentation_window import DocumentationWindow 
    29802995         
    29812996        _TreeLocation = "_images/M_angles_pic.bmp" 
     
    30243039        :param evt: Triggers on clicking ? in polydispersity box 
    30253040        """ 
    3026          
    3027         from sas.guiframe.documentation_window import DocumentationWindow 
    3028          
     3041                 
    30293042        _TreeLocation = "user/perspectives/fitting/fitting_help.html" 
    30303043        _TreeLocation += "#polydispersity-distributions" 
     
    35923605        self.mbox_description.SetForegroundColour(wx.RED) 
    35933606        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)) 
    35953612        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") 
    35973614        id = wx.NewId() 
    35983615        self.model_view = wx.Button(self, id, "Show 2D", size=(80, 23)) 
     
    36363653       
    36373654        sizer_radiobutton = wx.GridSizer(2, 2, 5, 5) 
     3655         
    36383656 
    36393657        #sizer_radiobutton.Add(self.shape_rbutton) 
    36403658        #sizer_radiobutton.Add(self.shape_indep_rbutton) 
    36413659        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) 
    36433661        #sizer_radiobutton.Add(self.plugin_rbutton) 
    36443662        #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) 
    36473667        sizer_cat.Add(sizer_cat_box, 1, wx.LEFT, 2.5) 
    36483668        sizer_cat.Add(sizer_radiobutton) 
  • src/sas/perspectives/fitting/report_dialog.py

    r4ec242e re8bb5b6  
    1414 
    1515import wx 
    16 import sys 
    1716import os 
    1817import wx.html as html 
    19 import logging 
    2018 
    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 
     19from sas.guiframe.report_dialog import BaseReportDialog 
    3720 
    38          
    39 class ReportDialog(wx.Dialog): 
     21class ReportDialog(BaseReportDialog): 
    4022    """ 
    4123    The report dialog box. 
    4224    """ 
    4325     
    44     def __init__(self, list, *args, **kwds): 
     26    def __init__(self, report_list, *args, **kwds): 
    4527        """ 
    4628        Initialization. The parameters added to Dialog are: 
    4729         
    48         :param list: report_list (list of html_str, text_str, image) 
     30        :param report_list: list of html_str, text_str, image 
    4931        from invariant_state 
    5032        """ 
    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 
    5435        # title 
    5536        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 
    6438        # number of images of plot 
    65         self.nimages = len(list[2]) 
     39        self.nimages = len(self.report_list[2]) 
    6640         
    67         if list[2] != None: 
     41        if self.report_list[2] != None: 
    6842            # put image path in the report string 
    69             if len(list[2]) == 1: 
     43            if len(self.report_list[2]) == 1: 
    7044                self.report_html = self.report_list[0] % \ 
    7145                                    "memory:img_fit0.png" 
    72             elif len(list[2]) == 2: 
     46            elif len(self.report_list) == 2: 
    7347                self.report_html = self.report_list[0] % \ 
    7448                                    ("memory:img_fit0.png", 
     
    8559        self._setup_layout() 
    8660         
    87     def _setup_layout(self): 
    88         """ 
    89         Set up layout 
    90         """ 
    91         hbox = wx.BoxSizer(wx.HORIZONTAL) 
    92          
    93         # buttons 
    94         id = wx.ID_OK 
    95         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 page 
    122         #panel = wx.Panel(self, -1) 
    123         vbox = wx.BoxSizer(wx.VERTICAL) 
    124         # html window 
    125         self.hwindow = html.HtmlWindow(self, style=wx.BORDER) 
    126         # set the html page with the report string 
    127         self.hwindow.SetPage(self.report_html) 
    128          
    129         # add panels to boxsizers 
    130         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  
    13761    def onSave(self, event=None): 
    13862        """ 
    13963        Save 
    14064        """ 
    141         # pdf supporting only on MAC, not on exe 
    142         if self.is_pdf: 
    143             wild_card = ' PDF files (*.pdf)|*.pdf|' 
    144             ind_cor = 0 
    145         else: 
    146             wild_card = '' 
    147             ind_cor = 1 
    148         wild_card += 'HTML files (*.html)|*.html|' 
    149         wild_card += 'Text files (*.txt)|*.txt' 
    150  
    15165        #todo: complete saving fig file and as a txt file 
    15266        dlg = wx.FileDialog(self, "Choose a file", 
    153                             wildcard=wild_card, 
     67                            wildcard=self.wild_card, 
    15468                            style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) 
    15569        dlg.SetFilterIndex(0)  # Set .html files to be default 
     
    16680        pic_fname = [] 
    16781        #PDF 
    168         if ext_num == (0 + 2 * ind_cor): 
     82        if ext_num == (0 + 2 * self.index_offset): 
    16983            # TODO: Sort this case out 
    17084            ext = '.pdf' 
     
    216130            return 
    217131        #HTML + png(graph) 
    218         elif ext_num == (1 - ind_cor): 
     132        elif ext_num == (1 - self.index_offset): 
    219133            ext = '.html' 
    220134            for num in range(self.nimages): 
     
    222136            report_frame = self.report_list[0] 
    223137        #TEXT + pdf(graph) 
    224         elif ext_num == (2 - ind_cor): 
     138        elif ext_num == (2 - self.index_offset): 
    225139            ext = '.txt' 
    226140            # changing the image extension actually changes the image 
     
    241155            pic_fname.append(pic_name) 
    242156        #put the image path in html string 
    243         if ext_num == (1 - ind_cor): 
     157        if ext_num == (1 - self.index_offset): 
    244158            if self.nimages == 1: 
    245159                report = report_frame % os.path.basename(pic_fname[0]) 
     
    259173            self.report_list[2][num].savefig(pic_fname[num]) 
    260174         
    261     def onPreview(self, event=None): 
    262         """ 
    263         Preview 
    264          
    265         : event: Preview button event 
    266         """ 
    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         Print 
    276          
    277         : event: Print button event 
    278         """ 
    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 Dialog 
    288          
    289         : event: Close button event 
    290         """ 
    291         self.Close() 
    292         # Reset memory 
    293         #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 string 
    303         : filename: name of file to be saved 
    304         """ 
    305         try: 
    306             from xhtml2pdf import pisa 
    307             # open output file for writing (truncated binary) 
    308             resultFile = open(filename, "w+b") 
    309             # convert HTML to PDF 
    310             pisaStatus = pisa.CreatePDF(data, dest=resultFile) 
    311             # close output file 
    312             resultFile.close() 
    313             self.Update() 
    314             return pisaStatus.err 
    315         except: 
    316             logging.error("Error creating pdf: %s" % sys.exc_value) 
    317         return False 
  • src/sas/perspectives/invariant/report_dialog.py

    r4ec242e re8bb5b6  
    1515""" 
    1616import wx 
    17 import sys 
    1817import os 
    1918import 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  
     20from sas.guiframe.report_dialog import BaseReportDialog 
     21 
     22class ReportDialog(BaseReportDialog): 
    3823    """ 
    3924    The report dialog box.  
    4025    """ 
    4126     
    42     def __init__(self,  list, *args, **kwds): 
     27    def __init__(self,  report_list, *args, **kwds): 
    4328        """ 
    4429        Initialization. The parameters added to Dialog are: 
    4530         
    46         :param list: report_list (list of html_str, text_str, image) 
     31        :param report_list: list of html_str, text_str, image 
    4732        from invariant_state 
    4833        """ 
    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 
    5236        # title 
    5337        self.SetTitle("Report: Invariant computaion") 
    54         # size 
    55         self.SetSize((720, 650)) 
    56         # font size  
    57         self.SetWindowVariant(variant=FONT_VARIANT) 
    5838 
    59         # check if tit is MAC 
    60         self.is_pdf = ISPDF 
    61          
    62         # report string 
    63         self.report_list = list 
    6439        # put image path in the report string 
    6540        self.report_html = self.report_list[0] % "memory:img_inv.png" 
    6641        # layout 
    6742        self._setup_layout() 
    68         # wild card 
    69         # pdf supporting only on MAC 
    70         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 layout 
    82         """ 
    83         hbox = wx.BoxSizer(wx.HORIZONTAL) 
    84          
    85         # buttons 
    86         id = wx.ID_OK 
    87         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 page 
    114         #panel = wx.Panel(self, -1) 
    115         vbox = wx.BoxSizer(wx.VERTICAL) 
    116         # html window 
    117         self.hwindow = html.HtmlWindow(self,style=wx.BORDER) 
    118         # set the html page with the report string 
    119         self.hwindow.SetPage(self.report_html) 
    120          
    121         # add panels to boxsizers 
    122         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                  
    12943 
    13044    def onSave(self, event=None): 
     
    14458        fName = dlg.GetPath() 
    14559        ext_num = dlg.GetFilterIndex()   
    146         # index correction  
    147         if not self.is_pdf: 
    148                 ind_cor = 1  
    149         else: 
    150                 ind_cor = 0  
    15160        #set file extensions   
    152         if ext_num == (0 + 2 * ind_cor): 
    153                         # TODO: Sort this case out 
     61        if ext_num == (0 + 2 * self.index_offset): 
     62            # TODO: Sort this case out 
    15463            ext = '.pdf' 
    15564            img_ext = '_img.png' 
     
    18695            os.remove(pic_fname) 
    18796            return 
    188         elif ext_num == (1 - ind_cor): 
     97        elif ext_num == (1 - self.index_offset): 
    18998            ext = '.html' 
    19099            img_ext = '_img4html.png' 
    191100            report_frame = self.report_list[0] 
    192         elif ext_num == (2 - ind_cor): 
     101        elif ext_num == (2 - self.index_offset): 
    193102            ext = '.txt'    
    194103            # changing the image extension actually changes the image 
     
    205114        pic_fname = os.path.splitext(fName)[0] + img_ext 
    206115        #put the image path in html string 
    207         if ext_num == (1 - ind_cor): 
     116        if ext_num == (1 - self.index_offset): 
    208117            report = report_frame % os.path.basename(pic_fname) 
    209118 
     
    214123        self.report_list[2].savefig(pic_fname) 
    215124         
    216              
    217     def onPreview(self, event=None): 
    218         """ 
    219         Preview 
    220          
    221         : event: Preview button event 
    222         """ 
    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         Print 
    231          
    232         : event: Print button event 
    233         """ 
    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 Dialog 
    242          
    243         : event: Close button event 
    244         """ 
    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 string 
    253         : filename: name of file to be saved 
    254         """ 
    255         try: 
    256             from xhtml2pdf import pisa 
    257             # open output file for writing (truncated binary) 
    258             resultFile = open(filename, "w+b") 
    259             # convert HTML to PDF 
    260             pisaStatus = pisa.CreatePDF(data, dest=resultFile) 
    261             # close output file 
    262             resultFile.close() 
    263             self.Update() 
    264             return pisaStatus.err 
    265         except: 
    266             logging.error("Error creating pdf: %s" % sys.exc_value) 
    267         return False 
  • src/sas/guiframe/config.py

    rfd5ac0d rf53cd30  
    2626# About box info 
    2727_do_aboutbox = True 
     28_do_acknowledge = True 
    2829_do_tutorial = True 
     30_acknowledgement_preamble =\ 
     31'''If you found this software useful to your work please remember to acknowledge  
     32its use in your publications as suggested below and reference the SasView website:  
     33http://www.sasview.org/index.html. Please also consider letting us know by sending us the  
     34reference to your work. This will help us to ensure the long term support and  
     35development of the software. 
     36''' 
     37_acknowledgement_publications = \ 
     38'''This work originally developed as part of the DANSE project funded by the NSF 
     39under grant DMR-0520547, and currently maintained by NIST, UMD, ORNL, ISIS, ESS  
     40and ILL. 
     41''' 
    2942_acknowledgement =  \ 
    3043'''This software was developed by the University of Tennessee as part of the 
  • src/sas/guiframe/gui_manager.py

    r707c6be rf53cd30  
    13511351            wx.EVT_MENU(self, id, self._onTutorial) 
    13521352             
     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         
    13531358        if config._do_aboutbox: 
    13541359            self._help_menu.AppendSeparator() 
     
    20982103                self.SetStatusText(msg) 
    20992104                     
     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                      
    21002117    def _onAbout(self, evt): 
    21012118        """ 
Note: See TracChangeset for help on using the changeset viewer.