Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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) 
Note: See TracChangeset for help on using the changeset viewer.