Changeset 17e1f14 in sasview


Ignore:
Timestamp:
Feb 19, 2015 1:55:15 AM (10 years ago)
Author:
smk78
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.
Message:

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

Location:
src/sas
Files:
2 added
1 deleted
12 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/perspectives/calculator/image_viewer.py

    reec63a8 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 
     
    138140 
    139141    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         
    162155             
    163156class SetDialog(wx.Dialog): 
  • 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/perspectives/calculator/media/data_operator_help.rst

    r684fade rad4d8b4  
    3434   available operators are: 
    3535    
    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) 
    4141 
    4242   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  
    1919------ 
    2020 
    21 1) Enter the empirical formula of a molecule. For mixtures, the ratio of each  
     21 
     221) Select *Density/Volume Calculator* from the *Tool* menu on the SasView toolbar. 
     23 
     242) Enter the empirical formula of a molecule. For mixtures, the ratio of each  
    2225   of the molecules should be used, for example, (H2O)0.5(D2O)0.5. 
    2326 
    24 2) Use the input combo box to choose between molar volume or mass density and  
     273) Use the input combo box to choose between molar volume or mass density and  
    2528   then type in an input value. 
    2629 
    27 3) Click the 'Calculate' button to perform the calculation. 
     304) Click the 'Calculate' button to perform the calculation. 
    2831 
    2932.. image:: density_tutor.gif 
  • src/sas/perspectives/calculator/media/image_viewer_help.rst

    r920928f r1e01486  
    1414plot can also be resized by dragging the corner of the panel. 
    1515 
    16 Supported image formats are png, bmp, gif, or jpg. (There is currently a bug in  
    17 the tif loader) 
     16The 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) 
    1823 
    1924.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    2227------ 
    2328 
    24 1. Select 'Image Viewer' under the 'Tool' menu in the menubar. 
     291) Select *Image Viewer* from the *Tool* menu on the SasView toolbar. 
    2530 
    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). 
     312) Select a file and then click *Open*. 
    2932 
    3033.. image:: load_image.bmp 
    3134 
    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. 
    3436 
    35 4. Some options such as saving, printing, and copying are available from the  
    36 menubar, or in the context-menu (by right-clicking anywhere in the plot). 
     373) To save, print, or copy the image, or to apply a grid overlay, right-click  
     38   anywhere in the plot. 
    3739 
    3840.. image:: pic_plot.bmp 
    3941 
    40 5. If the image is taken from a 2D detector, it can be converted into 2D data  
    41 where the z values are computed as  
     424. 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  
    4244 
    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) 
    4446 
    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. 
    4648 
    47 In the "Convert to Data" dialog, set the parameters relevant to your data and  
    48 then click the OK button. 
     495. In the *Convert to Data* dialog, set the parameters relevant to the data and  
     50   then click the OK. 
    4951 
    5052.. 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  
    33.. This is a port of the original SasView html help file to ReSTructured text 
    44.. by S King, ISIS, during SasView CodeCamp-III in Feb 2015. 
     5 
     6.. |pi| unicode:: U+03C0 
     7.. |Ang| unicode:: U+212B 
    58 
    69Kiessig Thickness Calculator Tool 
     
    1013----------- 
    1114 
    12 This tool is to approximately estimate the thickness of a layer or the  
    13 diameter of particles from the Kiessig fringe in SAS/NR data, and using the  
    14 Kiessig relation 
     15This tool is approximately estimates the thickness of a layer or the diameter  
     16of particles from the position of the Kiessig fringe/Bragg peak in NR/SAS data  
     17using the relation 
    1518 
    16 thickness = 2*Pi/fringe_width. 
     19(thickness *or* size) = 2 * |pi| / (fringe_width *or* peak position) 
    1720   
    1821.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    19  
    2022 
    2123How To 
    2224------ 
    2325 
    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. 
     26To get a rough thickness or particle size, simply type the fringe or peak  
     27position (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.