Changeset 9a0fc50 in sasview for src/sas/sasgui


Ignore:
Timestamp:
Sep 13, 2018 12:31:36 PM (6 years ago)
Author:
krzywon
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
Children:
43313e72
Parents:
feec1cb (diff), 356af60e (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' into ticket-1111

Location:
src/sas/sasgui
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/report_dialog.py

    r91552b5 rd0ce666f  
    77import sys 
    88import wx.html as html 
     9from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    910 
    1011logger = logging.getLogger(__name__) 
     
    7071        button_close = wx.Button(self, wx.ID_OK, "Close") 
    7172        button_close.SetToolTipString("Close this report window.") 
     73        button_close.Bind(wx.EVT_BUTTON, self.onClose, 
     74                          id=button_close.GetId()) 
    7275        hbox.Add(button_close) 
    7376        button_close.SetFocus() 
     
    117120 
    118121 
    119     def OnClose(self, event=None): 
     122    def onClose(self, event=None): 
    120123        """ 
    121124        Close the Dialog 
     
    123126        """ 
    124127        for fig in self.fig_urls: 
    125             self.imgRAM.RemoveFile(fig) 
     128            ReportImageHandler.remove_figure(fig) 
    126129 
    127         self.Close() 
     130        self.Destroy() 
    128131 
    129132    def HTML2PDF(self, data, filename): 
  • src/sas/sasgui/perspectives/calculator/media/slit_calculator_help.rst

    r5ed76f8 r346745a  
    1111----------- 
    1212 
    13 This tool enables X-ray users to calculate the slit size (FWHM/2) for smearing 
    14 based on their half beam profile data. 
     13This tool enables X-ray users to calculate the slit size (FWHM/2) for resolution  
     14smearing purposes based on their half beam profile data (as Q vs Intensity; any  
     15other data fields are ignored). 
    1516 
    16 *NOTE! Whilst it may have some more generic applicability, the calculator has 
    17 only been tested with beam profile data from Anton-Paar SAXSess:sup:`TM` software.* 
     17Method 
     18------ 
     19 
     20The tool works by sequentially summing 10 or more intensity values until a  
     21maximum value is attained. It then locates the Q values for the points just before,  
     22and just after, **half** of this maximum value and interpolates between them to get  
     23an accurate value for the Q value for the half maximum. 
     24 
     25NOTE! Whilst it may have some more generic applicability, the calculator has 
     26only been tested with beam profile data from Anton-Paar SAXSess\ :sup:`TM`\  software. 
     27The beam profile file does not carry any information about the units of the  
     28Q data. It is probably |nm^-1| but the resolution calculations assume the slit  
     29height/width has units of |Ang^-1|. If the beam profile data is not in these  
     30units then it, or the result, must be manually converted. 
    1831 
    1932.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    2740 
    2841   *NOTE! To see an example of the beam profile file format, visit the file 
    29    beam profile.DAT in your {installation_directory}/SasView/test folder.* 
     42   beam profile.DAT in your {installation_directory}/SasView/test_1d folder.* 
    3043 
    31443) Once a data is loaded, the slit size is automatically computed and displayed 
    3245   in the tool window. 
    3346 
    34 *NOTE! The beam profile file does not carry any information about the units of 
    35 the Q data. This calculator assumes the data has units of 1/\ |Ang|\ . If the 
    36 data is not in these units it must be manually converted beforehand.* 
    37  
    3847.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    3948 
    40 .. note::  This help document was last changed by Steve King, 01May2015 
     49.. note::  This help document was last changed by Steve King, 09Sep2018 
  • src/sas/sasgui/perspectives/calculator/model_editor.py

    r9258c43c r9bf40e7  
    4343if sys.platform.count("win32") > 0: 
    4444    FONT_VARIANT = 0 
    45     PNL_WIDTH = 450 
     45    PNL_WIDTH = 500 
    4646    PNL_HEIGHT = 320 
    4747else: 
    4848    FONT_VARIANT = 1 
    49     PNL_WIDTH = 590 
     49    PNL_WIDTH = 500 
    5050    PNL_HEIGHT = 350 
    5151M_NAME = 'Model' 
     
    495495        Choose the equation to use depending on whether we now have 
    496496        a sum or multiply model then create the appropriate string 
     497         
     498        for the sum model the result will be: 
     499        scale_factor * (scale1 * model_1 + scale2 * model_2) + background 
     500        while for the multiply model it will just be: 
     501        scale_factor * (model_1* model_2) + background 
    497502        """ 
    498503        name = '' 
    499504        if operator == '*': 
    500505            name = 'Multi' 
    501             factor = 'background' 
     506            factor_1 = '' 
     507            factor_2 = '' 
    502508        else: 
    503509            name = 'Sum' 
    504             factor = 'scale_factor' 
     510            factor_1 = 'scale_1 * ' 
     511            factor_2 = 'scale_2 * ' 
    505512 
    506513        self._operator = operator 
    507         self.explanation = ("  Plugin_model = scale_factor * (model_1 {} " 
    508             "model_2) + background").format(operator) 
     514        self.explanation = ("  Plugin_model = scale_factor * ({}model_1 {} " 
     515            "{}model_2) + background").format(factor_1,operator,factor_2) 
    509516        self.explanationctr.SetLabel(self.explanation) 
    510517        self.name = name + M_NAME 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r8a51dea0 ra4a1ac9  
    3131 
    3232from sas.sasgui.guiframe.panel_base import PanelBase 
     33from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    3334from sas.sasgui.guiframe.utils import format_number, check_float, IdList, \ 
    3435    check_int 
     
    651652        by plotting, putting it into wx.FileSystem image object 
    652653        """ 
    653         images = [] 
    654         refs = [] 
    655  
    656         # For no figures in the list, prepare empty plot 
    657         if figs is None or len(figs) == 0: 
    658             figs = [None] 
    659  
    660         # Loop over the list of figures 
    661         # use wx.MemoryFSHandler 
    662         imgRAM = wx.MemoryFSHandler() 
    663         for fig in figs: 
    664             if fig is not None: 
    665                 ind = figs.index(fig) 
    666                 canvas = canvases[ind] 
    667  
    668             # store the image in wx.FileSystem Object 
    669             wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 
    670  
    671             # index of the fig 
    672             ind = figs.index(fig) 
    673  
    674             # AddFile, image can be retrieved with 'memory:filename' 
    675             name = 'img_fit%s.png' % ind 
    676             refs.append('memory:' + name) 
    677             imgRAM.AddFile(name, canvas.bitmap, wx.BITMAP_TYPE_PNG) 
    678             # append figs 
    679             images.append(fig) 
    680  
    681         return imgRAM, images, refs 
    682  
     654        bitmaps = [] 
     655        for canvas in canvases: 
     656            bitmaps.append(canvas.bitmap) 
     657        imgs, refs = ReportImageHandler.set_figs(figs, bitmaps, 'fit') 
     658 
     659        return ReportImageHandler.instance, imgs, refs 
    683660 
    684661    def on_save(self, event): 
     
    28012778        Function called when 'Help' button is pressed next to model 
    28022779        of interest.  This calls DocumentationWindow from 
    2803         documentation_window.py. It will load the top level of the model 
    2804         help documenation sphinx generated html if no model is presented. 
    2805         If a model IS present then if documention for that model exists 
    2806         it will load to that  point otherwise again it will go to the top. 
    2807         For Wx2.8 and below is used (i.e. non-released through installer) 
    2808         a browser is loaded and the top of the model documentation only is 
    2809         accessible because webbrowser module does not pass anything after 
    2810         the # to the browser. 
     2780        documentation_window.py. It will load the top level of the html model 
     2781        help documenation sphinx generated if either a plugin model (which 
     2782        normally does not have an html help help file) is selected or if no 
     2783        model is selected. Otherwise, if a regula model is selected, the 
     2784        documention for that model will be sent to a browser window. 
     2785 
     2786        :todo the quick fix for no documentation in plugins is the if statment. 
     2787        However, the right way to do this would be to check whether the hmtl 
     2788        file exists and load the model docs if it does and the general docs if 
     2789        it doesn't - this will become important if we ever figure out how to 
     2790        build docs for plugins on the fly.  Sep 9, 2018 -PDB 
    28112791 
    28122792        :param event: on Help Button pressed event 
    28132793        """ 
    28142794 
    2815         if self.model is not None: 
     2795        if (self.model is not None) and (self.categorybox.GetValue() 
     2796                                         != "Plugin Models"): 
    28162797            name = self.formfactorbox.GetValue() 
    28172798            _TreeLocation = 'user/models/%s.html' % name 
  • src/sas/sasgui/perspectives/fitting/gpu_options.py

    r42a6e02 r388aefb  
    139139 
    140140        test_text = wx.StaticText(self, -1, "WARNING: Running tests can take a few minutes!") 
     141        test_text2 = wx.StaticText(self, -1, "NOTE: No test will run if No OpenCL is checked") 
     142        test_text.SetForegroundColour(wx.RED) 
     143        self.vbox.Add(test_text2, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    141144        self.vbox.Add(test_text, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    142145 
  • src/sas/sasgui/perspectives/fitting/report_dialog.py

    r69a6897 r44e8f48  
    7272        filename = basename + ext 
    7373 
    74         # save figures 
    75         pictures = [] 
    76         for num in range(self.nimages): 
    77             pic_name = basename + '_img%s.png' % num 
    78             # save the image for use with pdf writer 
    79             self.report_list[2][num].savefig(pic_name) 
    80             pictures.append(pic_name) 
     74        # save the images for use with pdf writer 
     75        pictures = [ 
     76            '_'.join((basename, url.split(':')[1])) for url in self.fig_urls] 
     77        for i, pic in enumerate(pictures): 
     78            self.report_list[2][i].savefig(pic) 
    8179 
    8280        # translate png references int html from in-memory name to on-disk name 
    83         html = self.report_html.replace("memory:img_fit", basename+'_img') 
     81        html = self.report_html.replace("memory:", basename+'_') 
    8482 
    8583        #set file extensions 
  • src/sas/sasgui/perspectives/invariant/invariant_panel.py

    r2469df7 r44e8f48  
    2424from sas.sasgui.guiframe.panel_base import PanelBase 
    2525from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     26from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    2627 
    2728logger = logging.getLogger(__name__) 
     
    783784        report_img = self.state.image 
    784785        report_list = [report_html_str, report_text_str, report_img] 
    785         dialog = ReportDialog(report_list, None, -1, "") 
     786        ReportImageHandler.check_for_empty_instance() 
     787        imgRAM = ReportImageHandler.instance.img_holder 
     788        refs = [self.state.wximgbmp] 
     789        dialog = ReportDialog(report_list, imgRAM, refs, None, wx.ID_ANY, "") 
    786790        dialog.Show() 
    787791 
  • src/sas/sasgui/perspectives/invariant/invariant_state.py

    r2469df7 rfa412df  
    1212from lxml import etree 
    1313from sas.sascalc.dataloader.readers.cansas_reader import Reader as CansasReader 
     14from sas.sasgui.guiframe.report_image_handler import ReportImageHandler 
    1415from sas.sascalc.dataloader.readers.cansas_reader import get_content 
    1516from sas.sasgui.guiframe.utils import format_number 
     
    611612        wximgbmp = wx.BitmapFromImage(wximg) 
    612613        # store the image in wx.FileSystem Object 
    613         wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 
    614         # use wx.MemoryFSHandler 
    615         self.imgRAM = wx.MemoryFSHandler() 
    616         # AddFile, image can be retrieved with 'memory:filename' 
    617         self.imgRAM.AddFile('img_inv.png', wximgbmp, wx.BITMAP_TYPE_PNG) 
    618  
    619         self.wximgbmp = 'memory:img_inv.png' 
    620         self.image = fig 
     614        imgs, refs = ReportImageHandler.set_figs([fig], [wximgbmp], 'inv') 
     615 
     616        self.wximgbmp = refs[0] 
     617        self.image = imgs[0] 
    621618 
    622619class Reader(CansasReader): 
  • src/sas/sasgui/perspectives/invariant/report_dialog.py

    r959eb01 rd0ce666f  
    4141 
    4242        # put image path in the report string 
    43         self.report_html = self.report_list[0] % "memory:img_inv.png" 
     43        self.report_html = self.report_list[0] % self.fig_urls[0] 
    4444        # layout 
    4545        self._setup_layout() 
  • src/sas/sasgui/guiframe/gui_manager.py

    rb963b20 rfeec1cb  
    4646from sas.sasgui.guiframe.CategoryManager import CategoryManager 
    4747from sas.sascalc.dataloader.loader import Loader 
     48from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 
    4849from sas.sasgui.guiframe.proxy import Connection 
    4950 
     
    24222423        default_name = fname 
    24232424        wildcard = "Text files (*.txt)|*.txt|"\ 
    2424                     "CanSAS 1D files(*.xml)|*.xml" 
    2425         path = None 
     2425                    "CanSAS 1D files (*.xml)|*.xml|"\ 
     2426                     "NXcanSAS files (*.h5)|*.h5|" 
     2427        options = {0: ".txt", 
     2428                   1: ".xml", 
     2429                   2: ".h5"} 
    24262430        dlg = wx.FileDialog(self, "Choose a file", 
    24272431                            self._default_save_location, 
     
    24332437            # This is MAC Fix 
    24342438            ext_num = dlg.GetFilterIndex() 
    2435             if ext_num == 0: 
    2436                 ext_format = '.txt' 
    2437             else: 
    2438                 ext_format = '.xml' 
     2439 
     2440            ext_format = options[ext_num] 
    24392441            path = os.path.splitext(path)[0] + ext_format 
    24402442            mypath = os.path.basename(path) 
    2441  
    2442             # Instantiate a loader 
    2443             loader = Loader() 
    2444             ext_format = ".txt" 
    2445             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2443            fName = os.path.splitext(path)[0] + ext_format 
     2444 
     2445            if os.path.splitext(mypath)[1].lower() == options[0]: 
    24462446                # Make sure the ext included in the file name 
    24472447                # especially on MAC 
    2448                 fName = os.path.splitext(path)[0] + ext_format 
    24492448                self._onsaveTXT(data, fName) 
    2450             ext_format = ".xml" 
    2451             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2449            elif os.path.splitext(mypath)[1].lower() == options[1]: 
    24522450                # Make sure the ext included in the file name 
    24532451                # especially on MAC 
    2454                 fName = os.path.splitext(path)[0] + ext_format 
     2452                # Instantiate a loader 
     2453                loader = Loader() 
    24552454                loader.save(fName, data, ext_format) 
     2455            elif os.path.splitext(mypath)[1].lower() == options[2]: 
     2456                nxcansaswriter = NXcanSASWriter() 
     2457                nxcansaswriter.write([data], fName) 
    24562458            try: 
    24572459                self._default_save_location = os.path.dirname(path) 
     
    25282530            text += 'dY_min = %s:  dY_max = %s\n' % (min(data.dy), max(data.dy)) 
    25292531        text += '\nData Points:\n' 
    2530         x_st = "X" 
     2532        text += "<index> \t<X> \t<Y> \t<dY> \t<dX" 
     2533        if data.dxl is not None and data.dxw is not None: 
     2534                text += "l> \t<dxw" 
     2535        text += ">\n" 
    25312536        for index in range(len(data.x)): 
    25322537            if data.dy is not None and len(data.dy) > index: 
     
    25392544                dx_val = 0.0 
    25402545            if data.dxl is not None and len(data.dxl) > index: 
    2541                 if index == 0: 
    2542                     x_st = "Xl" 
    25432546                dx_val = data.dxl[index] 
    2544             elif data.dxw is not None and len(data.dxw) > index: 
    2545                 if index == 0: 
    2546                     x_st = "Xw" 
    2547                 dx_val = data.dxw[index] 
    2548  
    2549             if index == 0: 
    2550                 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 
     2547                if data.dxw is not None and len(data.dxw) > index: 
     2548                    dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 
     2549 
    25512550            text += "%s \t%s \t%s \t%s \t%s\n" % (index, 
    25522551                                                  data.x[index], 
     
    25652564        """ 
    25662565        default_name = fname 
    2567         wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 
     2566        wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 
     2567                   "NXcanSAS files (*.h5)|*.h5|" 
    25682568        dlg = wx.FileDialog(self, "Choose a file", 
    25692569                            self._default_save_location, 
     
    25772577            if ext_num == 0: 
    25782578                ext_format = '.dat' 
     2579            elif ext_num == 1: 
     2580                ext_format = '.h5' 
    25792581            else: 
    25802582                ext_format = '' 
     
    25842586            # Instantiate a loader 
    25852587            loader = Loader() 
    2586  
    2587             ext_format = ".dat" 
    2588             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2588            if os.path.splitext(mypath)[1].lower() == '.dat': 
    25892589                # Make sure the ext included in the file name 
    25902590                # especially on MAC 
    25912591                fileName = os.path.splitext(path)[0] + ext_format 
    25922592                loader.save(fileName, data, ext_format) 
     2593            elif os.path.splitext(mypath)[1].lower() == '.h5': 
     2594                # Make sure the ext included in the file name 
     2595                # especially on MAC 
     2596                fileName = os.path.splitext(path)[0] + ext_format 
     2597                nxcansaswriter = NXcanSASWriter() 
     2598                nxcansaswriter.write([data], fileName) 
    25932599            try: 
    25942600                self._default_save_location = os.path.dirname(path) 
  • src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py

    r2924532 r02c1608e  
    239239            self.load_complete(output=output, message="Loading data complete!", 
    240240                               info="info") 
    241         else: 
    242             self.load_complete(output=None, message=error_message, info="error") 
    243241 
    244242    def load_update(self, message="", info="warning"): 
Note: See TracChangeset for help on using the changeset viewer.