Ignore:
File:
1 edited

Legend:

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

    r8ac05a5 r9220e89c  
    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 
     
    24192420        default_name = fname 
    24202421        wildcard = "Text files (*.txt)|*.txt|"\ 
    2421                     "CanSAS 1D files(*.xml)|*.xml" 
    2422         path = None 
     2422                    "CanSAS 1D files (*.xml)|*.xml|"\ 
     2423                     "NXcanSAS files (*.h5)|*.h5|" 
     2424        options = [".txt", ".xml",".h5"] 
    24232425        dlg = wx.FileDialog(self, "Choose a file", 
    24242426                            self._default_save_location, 
     
    24302432            # This is MAC Fix 
    24312433            ext_num = dlg.GetFilterIndex() 
    2432             if ext_num == 0: 
    2433                 ext_format = '.txt' 
    2434             else: 
    2435                 ext_format = '.xml' 
     2434 
     2435            ext_format = options[ext_num] 
    24362436            path = os.path.splitext(path)[0] + ext_format 
    24372437            mypath = os.path.basename(path) 
    2438  
    2439             # Instantiate a loader 
    2440             loader = Loader() 
    2441             ext_format = ".txt" 
    2442             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2438            fName = os.path.splitext(path)[0] + ext_format 
     2439 
     2440            if os.path.splitext(mypath)[1].lower() == options[0]: 
    24432441                # Make sure the ext included in the file name 
    24442442                # especially on MAC 
    2445                 fName = os.path.splitext(path)[0] + ext_format 
    24462443                self._onsaveTXT(data, fName) 
    2447             ext_format = ".xml" 
    2448             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2444            elif os.path.splitext(mypath)[1].lower() == options[1]: 
    24492445                # Make sure the ext included in the file name 
    24502446                # especially on MAC 
    2451                 fName = os.path.splitext(path)[0] + ext_format 
     2447                # Instantiate a loader 
     2448                loader = Loader() 
    24522449                loader.save(fName, data, ext_format) 
     2450            elif os.path.splitext(mypath)[1].lower() == options[2]: 
     2451                nxcansaswriter = NXcanSASWriter() 
     2452                nxcansaswriter.write([data], fName) 
    24532453            try: 
    24542454                self._default_save_location = os.path.dirname(path) 
     
    24772477            if has_errors: 
    24782478                if data.dx is not None and data.dx != []: 
    2479                     out.write("<X>   <Y>   <dY>   <dX>\n") 
     2479                    out.write("<X>\t<Y>\t<dY>\t<dX>\n") 
    24802480                else: 
    2481                     out.write("<X>   <Y>   <dY>\n") 
     2481                    out.write("<X>\t<Y>\t<dY>\n") 
    24822482            else: 
    2483                 out.write("<X>   <Y>\n") 
     2483                out.write("<X>\t<Y>\n") 
    24842484 
    24852485            for i in range(len(data.x)): 
     
    25252525            text += 'dY_min = %s:  dY_max = %s\n' % (min(data.dy), max(data.dy)) 
    25262526        text += '\nData Points:\n' 
    2527         x_st = "X" 
     2527        text += "<index> \t<X> \t<Y> \t<dY> " 
     2528        text += "\t<dXl> \t<dXw>\n" if(data.dxl is not None and 
     2529                                       data.dxw is not None) else "\t<dX>\n" 
    25282530        for index in range(len(data.x)): 
    25292531            if data.dy is not None and len(data.dy) > index: 
     
    25362538                dx_val = 0.0 
    25372539            if data.dxl is not None and len(data.dxl) > index: 
    2538                 if index == 0: 
    2539                     x_st = "Xl" 
    25402540                dx_val = data.dxl[index] 
    2541             elif data.dxw is not None and len(data.dxw) > index: 
    2542                 if index == 0: 
    2543                     x_st = "Xw" 
    2544                 dx_val = data.dxw[index] 
    2545  
    2546             if index == 0: 
    2547                 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 
     2541                if data.dxw is not None and len(data.dxw) > index: 
     2542                    dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 
     2543 
    25482544            text += "%s \t%s \t%s \t%s \t%s\n" % (index, 
    25492545                                                  data.x[index], 
     
    25622558        """ 
    25632559        default_name = fname 
    2564         wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 
     2560        wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 
     2561                   "NXcanSAS files (*.h5)|*.h5|" 
    25652562        dlg = wx.FileDialog(self, "Choose a file", 
    25662563                            self._default_save_location, 
     
    25742571            if ext_num == 0: 
    25752572                ext_format = '.dat' 
     2573            elif ext_num == 1: 
     2574                ext_format = '.h5' 
    25762575            else: 
    25772576                ext_format = '' 
     
    25812580            # Instantiate a loader 
    25822581            loader = Loader() 
    2583  
    2584             ext_format = ".dat" 
    2585             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2582            ext = os.path.splitext(mypath)[1].lower() 
     2583            if ext == '.dat': 
    25862584                # Make sure the ext included in the file name 
    25872585                # especially on MAC 
    25882586                fileName = os.path.splitext(path)[0] + ext_format 
    25892587                loader.save(fileName, data, ext_format) 
     2588            elif ext == '.h5': 
     2589                # Make sure the ext included in the file name 
     2590                # especially on MAC 
     2591                fileName = os.path.splitext(path)[0] + ext_format 
     2592                nxcansaswriter = NXcanSASWriter() 
     2593                nxcansaswriter.write([data], fileName) 
    25902594            try: 
    25912595                self._default_save_location = os.path.dirname(path) 
Note: See TracChangeset for help on using the changeset viewer.