Changeset be74751 in sasview for src/sas/qtgui/MainWindow


Ignore:
Timestamp:
Nov 7, 2018 8:47:25 AM (5 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
ebcdb02
Parents:
490e230
Message:

More batchpage related functionality for Analysis save/load

Location:
src/sas/qtgui/MainWindow
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/MainWindow/DataExplorer.py

    r490e230 rbe74751  
    266266        filename = QtWidgets.QFileDialog.getOpenFileName(**kwargs)[0] 
    267267        if filename: 
    268             self.readAnalysis(filename) 
     268            self.readProject(filename) 
    269269 
    270270    def saveProject(self): 
     
    414414        if 'svs' in ext.lower(): 
    415415            # backward compatibility mode. 
    416             datasets = GuiUtils.readProjectFromSVS(filename) 
    417             #[[item_1, state_1], [item_2, state_2],...] 
    418  
     416            try: 
     417                datasets = GuiUtils.readProjectFromSVS(filename) 
     418            except Exception as ex: 
     419                # disregard malformed SVS and try to recover whatever 
     420                # is available 
     421                msg = "Error while reading the project file: "+str(ex) 
     422                logging.error(msg) 
     423                pass 
    419424            # Convert fitpage properties and update the dict 
    420425            try: 
     
    422427            except Exception as ex: 
    423428                # disregard malformed SVS and try to recover regardless 
    424                 msg = "Error while reading the project file: "+str(ex) 
     429                msg = "Error while converting the project file: "+str(ex) 
    425430                logging.error(msg) 
    426431                pass 
    427432        else: 
    428433            with open(filename, 'r') as infile: 
    429                 all_data = GuiUtils.readDataFromFile(infile) 
    430  
     434                try: 
     435                    all_data = GuiUtils.readDataFromFile(infile) 
     436                except Exception as ex: 
     437                    logging.error("Project load failed with " + str(ex)) 
     438                    return 
    431439        for key, value in all_data.items(): 
    432440            if key=='is_batch': 
     
    489497                self._perspective().updateFromParameters(page) 
    490498        pass # debugger 
    491  
    492     def readAnalysis(self, filename): 
    493         """ 
    494         Read out a single dataset and fitpage from file 
    495         """ 
    496         with open(filename, 'r') as infile: 
    497             all_data = GuiUtils.readDataFromFile(infile) 
    498  
    499             # send newly created items to the perspective 
    500             self.updatePerspectiveWithProperties(1, all_data) 
    501499 
    502500    def updateModelFromData(self, data): 
  • src/sas/qtgui/MainWindow/GuiManager.py

    r17e2d502 rbe74751  
    600600        # get fit page serialization 
    601601        params = per.serializeCurrentFitpage() 
     602        # Find dataset ids for the current tab 
     603        # (can be multiple, if batch) 
    602604        data_id = per.currentTabDataId() 
    603605        tab_id = per.currentTab.tab_id 
    604         data = self.filesWidget.getDataForID(data_id) 
    605606        analysis = {} 
    606         analysis['fit_data'] = data 
    607         analysis['fit_params'] = params 
     607        for id in data_id: 
     608            an = {} 
     609            data_for_id = self.filesWidget.getDataForID(id) 
     610            an['fit_data'] = data_for_id 
     611            an['fit_params'] = [params] 
     612            analysis[id] = an 
    608613 
    609614        self.filesWidget.saveAnalysis(analysis, tab_id) 
    610  
    611         pass 
    612615 
    613616    def actionQuit(self): 
Note: See TracChangeset for help on using the changeset viewer.