Ignore:
Timestamp:
Mar 6, 2019 6:18:09 PM (5 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
Children:
f923967
Parents:
cb64d86 (diff), f205d3a (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 py37-sasgui

File:
1 edited

Legend:

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

    r5251ec6 r82d88d5  
    4848from sas.sasgui.guiframe.CategoryManager import CategoryManager 
    4949from sas.sascalc.dataloader.loader import Loader 
     50from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 
    5051from sas.sasgui.guiframe.proxy import Connection 
    5152 
     
    6465SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT 
    6566SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME 
    66 if not WELCOME_PANEL_ON: 
    67     WELCOME_PANEL_SHOW = False 
     67 
     68def custom_value(name, default=None): 
     69    """ 
     70    Fetch a config value from custom_config.  Fallback to config, and then 
     71    to default if it doesn't exist in config. 
     72    """ 
     73    default = getattr(config, name, default) 
     74    return getattr(custom_config, name, default) 
     75 
     76# Custom config values in the order they appear. 
     77DATAPANEL_WIDTH = custom_value('DATAPANEL_WIDTH', -1) 
     78CLEANUP_PLOT = custom_value('CLEANUP_PLOT', False) 
     79FIXED_PANEL = custom_value('FIXED_PANEL', True) 
     80PLOPANEL_WIDTH = custom_value('PLOPANEL_WIDTH', -1) 
     81DATALOADER_SHOW = custom_value('DATALOADER_SHOW', True) 
     82GUIFRAME_HEIGHT = custom_value('GUIFRAME_HEIGHT', -1) 
     83GUIFRAME_WIDTH = custom_value('GUIFRAME_WIDTH', -1) 
     84CONTROL_WIDTH = custom_value('CONTROL_WIDTH', -1) 
     85CONTROL_HEIGHT = custom_value('CONTROL_HEIGHT', -1) 
     86open_folder = custom_value('DEFAULT_OPEN_FOLDER', None) 
     87if open_folder is not None and os.path.isdir(open_folder): 
     88    DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder) 
    6889else: 
    69     WELCOME_PANEL_SHOW = True 
    70 try: 
    71     DATALOADER_SHOW = custom_config.DATALOADER_SHOW 
    72     TOOLBAR_SHOW = custom_config.TOOLBAR_SHOW 
    73     FIXED_PANEL = custom_config.FIXED_PANEL 
    74     if WELCOME_PANEL_ON: 
    75         WELCOME_PANEL_SHOW = custom_config.WELCOME_PANEL_SHOW 
    76     PLOPANEL_WIDTH = custom_config.PLOPANEL_WIDTH 
    77     DATAPANEL_WIDTH = custom_config.DATAPANEL_WIDTH 
    78     GUIFRAME_WIDTH = custom_config.GUIFRAME_WIDTH 
    79     GUIFRAME_HEIGHT = custom_config.GUIFRAME_HEIGHT 
    80     CONTROL_WIDTH = custom_config.CONTROL_WIDTH 
    81     CONTROL_HEIGHT = custom_config.CONTROL_HEIGHT 
    82     DEFAULT_PERSPECTIVE = custom_config.DEFAULT_PERSPECTIVE 
    83     CLEANUP_PLOT = custom_config.CLEANUP_PLOT 
    84     # custom open_path 
    85     open_folder = custom_config.DEFAULT_OPEN_FOLDER 
    86     if open_folder is not None and os.path.isdir(open_folder): 
    87         DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder) 
    88     else: 
    89         DEFAULT_OPEN_FOLDER = get_app_dir() 
    90     SAS_OPENCL = custom_config.SAS_OPENCL 
    91 except: 
    92     DATALOADER_SHOW = True 
    93     TOOLBAR_SHOW = True 
    94     FIXED_PANEL = True 
    95     WELCOME_PANEL_SHOW = False 
    96     PLOPANEL_WIDTH = config.PLOPANEL_WIDTH 
    97     DATAPANEL_WIDTH = config.DATAPANEL_WIDTH 
    98     GUIFRAME_WIDTH = config.GUIFRAME_WIDTH 
    99     GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT 
    100     CONTROL_WIDTH = -1 
    101     CONTROL_HEIGHT = -1 
    102     DEFAULT_PERSPECTIVE = None 
    103     CLEANUP_PLOT = False 
    10490    DEFAULT_OPEN_FOLDER = get_app_dir() 
    105     DEFAULT_OPEN_FOLDER = PATH_APP 
    106     SAS_OPENCL = None 
     91WELCOME_PANEL_SHOW = (custom_value('WELCOME_PANEL_SHOW', False) 
     92                      if WELCOME_PANEL_ON else False) 
     93TOOLBAR_SHOW = custom_value('TOOLBAR_SHOW', True) 
     94DEFAULT_PERSPECTIVE = custom_value('DEFAULT_PERSPECTIVE', 'Fitting') 
     95SAS_OPENCL = custom_value('SAS_OPENCL', 'None') 
     96 
    10797DEFAULT_STYLE = config.DEFAULT_STYLE 
    108  
    10998PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS 
    11099OPEN_SAVE_MENU = config.OPEN_SAVE_PROJECT_MENU 
     
    24202409        default_name = fname 
    24212410        wildcard = "Text files (*.txt)|*.txt|"\ 
    2422                     "CanSAS 1D files(*.xml)|*.xml" 
    2423         path = None 
     2411                    "CanSAS 1D files (*.xml)|*.xml|"\ 
     2412                     "NXcanSAS files (*.h5)|*.h5|" 
     2413        options = [".txt", ".xml",".h5"] 
    24242414        dlg = wx.FileDialog(self, "Choose a file", 
    24252415                            self._default_save_location, 
     
    24312421            # This is MAC Fix 
    24322422            ext_num = dlg.GetFilterIndex() 
    2433             if ext_num == 0: 
    2434                 ext_format = '.txt' 
    2435             else: 
    2436                 ext_format = '.xml' 
     2423 
     2424            ext_format = options[ext_num] 
    24372425            path = os.path.splitext(path)[0] + ext_format 
    24382426            mypath = os.path.basename(path) 
    2439  
    2440             # Instantiate a loader 
    2441             loader = Loader() 
    2442             ext_format = ".txt" 
    2443             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2427            fName = os.path.splitext(path)[0] + ext_format 
     2428 
     2429            if os.path.splitext(mypath)[1].lower() == options[0]: 
    24442430                # Make sure the ext included in the file name 
    24452431                # especially on MAC 
    2446                 fName = os.path.splitext(path)[0] + ext_format 
    24472432                self._onsaveTXT(data, fName) 
    2448             ext_format = ".xml" 
    2449             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2433            elif os.path.splitext(mypath)[1].lower() == options[1]: 
    24502434                # Make sure the ext included in the file name 
    24512435                # especially on MAC 
    2452                 fName = os.path.splitext(path)[0] + ext_format 
     2436                # Instantiate a loader 
     2437                loader = Loader() 
    24532438                loader.save(fName, data, ext_format) 
     2439            elif os.path.splitext(mypath)[1].lower() == options[2]: 
     2440                nxcansaswriter = NXcanSASWriter() 
     2441                nxcansaswriter.write([data], fName) 
    24542442            try: 
    24552443                self._default_save_location = os.path.dirname(path) 
     
    24782466            if has_errors: 
    24792467                if data.dx is not None and data.dx != []: 
    2480                     out.write("<X>   <Y>   <dY>   <dX>\n") 
     2468                    out.write("<X>\t<Y>\t<dY>\t<dX>\n") 
    24812469                else: 
    2482                     out.write("<X>   <Y>   <dY>\n") 
     2470                    out.write("<X>\t<Y>\t<dY>\n") 
    24832471            else: 
    2484                 out.write("<X>   <Y>\n") 
     2472                out.write("<X>\t<Y>\n") 
    24852473 
    24862474            for i in range(len(data.x)): 
     
    25262514            text += 'dY_min = %s:  dY_max = %s\n' % (min(data.dy), max(data.dy)) 
    25272515        text += '\nData Points:\n' 
    2528         x_st = "X" 
     2516        text += "<index> \t<X> \t<Y> \t<dY> " 
     2517        text += "\t<dXl> \t<dXw>\n" if(data.dxl is not None and 
     2518                                       data.dxw is not None) else "\t<dX>\n" 
    25292519        for index in range(len(data.x)): 
    25302520            if data.dy is not None and len(data.dy) > index: 
     
    25372527                dx_val = 0.0 
    25382528            if data.dxl is not None and len(data.dxl) > index: 
    2539                 if index == 0: 
    2540                     x_st = "Xl" 
    25412529                dx_val = data.dxl[index] 
    2542             elif data.dxw is not None and len(data.dxw) > index: 
    2543                 if index == 0: 
    2544                     x_st = "Xw" 
    2545                 dx_val = data.dxw[index] 
    2546  
    2547             if index == 0: 
    2548                 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 
     2530                if data.dxw is not None and len(data.dxw) > index: 
     2531                    dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 
     2532 
    25492533            text += "%s \t%s \t%s \t%s \t%s\n" % (index, 
    25502534                                                  data.x[index], 
     
    25632547        """ 
    25642548        default_name = fname 
    2565         wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 
     2549        wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 
     2550                   "NXcanSAS files (*.h5)|*.h5|" 
    25662551        dlg = wx.FileDialog(self, "Choose a file", 
    25672552                            self._default_save_location, 
     
    25752560            if ext_num == 0: 
    25762561                ext_format = '.dat' 
     2562            elif ext_num == 1: 
     2563                ext_format = '.h5' 
    25772564            else: 
    25782565                ext_format = '' 
     
    25822569            # Instantiate a loader 
    25832570            loader = Loader() 
    2584  
    2585             ext_format = ".dat" 
    2586             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2571            ext = os.path.splitext(mypath)[1].lower() 
     2572            if ext == '.dat': 
    25872573                # Make sure the ext included in the file name 
    25882574                # especially on MAC 
    25892575                fileName = os.path.splitext(path)[0] + ext_format 
    25902576                loader.save(fileName, data, ext_format) 
     2577            elif ext == '.h5': 
     2578                # Make sure the ext included in the file name 
     2579                # especially on MAC 
     2580                fileName = os.path.splitext(path)[0] + ext_format 
     2581                nxcansaswriter = NXcanSASWriter() 
     2582                nxcansaswriter.write([data], fileName) 
    25912583            try: 
    25922584                self._default_save_location = os.path.dirname(path) 
Note: See TracChangeset for help on using the changeset viewer.