Changeset a3c59503 in sasview for src


Ignore:
Timestamp:
Oct 22, 2018 7:48:54 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:
d00475d
Parents:
b8dccb8
Message:

Working project load/save. new format only. SASVIEW-983/984

Location:
src/sas/qtgui
Files:
3 edited

Legend:

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

    r2eeda93 ra3c59503  
    268268        self.communicator.statusBarUpdateSignal.emit("Saving Project... %s\n" % os.path.basename(filename)) 
    269269 
    270         with open(filename, 'w') as outfile: 
    271             self.saveDataToFile(outfile) 
     270        return filename 
    272271 
    273272    def saveAsAnalysisFile(self, tab_id=1): 
     
    318317            is_checked = item.checkState() 
    319318            properties['checked'] = is_checked 
    320             other_datas = GuiUtils.plotsFromFilename(filename, model) 
     319            other_datas = [] 
     320            # no need to save other_datas - things will be refit on read 
     321            #other_datas = GuiUtils.plotsFromFilename(filename, model) 
    321322            # skip the main plot 
    322             other_datas = list(other_datas.values())[1:] 
     323            #other_datas = list(other_datas.values())[1:] 
    323324            all_data[data.id] = [data, properties, other_datas] 
    324325        return all_data 
     
    375376        with open(filename, 'r') as infile: 
    376377            all_data = GuiUtils.readDataFromFile(infile) 
    377             items = self.updateModelFromData(all_data) 
     378 
     379        for key, value in all_data.items(): 
     380            data_dict = {key:value['fit_data']} 
     381            items = self.updateModelFromData(data_dict) 
     382            # send newly created item to its perspective 
     383            if 'fit_params' in value: 
     384                self.sendItemToPerspective(items[0]) 
     385                # Make the perspective read the rest of the read data 
     386                self._perspective().updateFromParameters(value['fit_params']) 
    378387 
    379388        pass # debugger 
  • src/sas/qtgui/MainWindow/GuiManager.py

    r2eeda93 ra3c59503  
    554554        Menu Save Project 
    555555        """ 
    556         self.filesWidget.saveProject() 
     556        filename = self.filesWidget.saveProject() 
     557 
     558        # datasets 
     559        all_data = self.filesWidget.getAllData() 
     560 
     561        # fit tabs 
     562        params = self.perspective().serializeAllFitpage() 
     563 
     564        # project dictionary structure: 
     565        # analysis[data.id] = [{"fit_data":[data, checkbox, child data], 
     566        #                       "fit_params":[fitpage_state]} 
     567        # "fit_params" not present if dataset not sent to fitting 
     568        analysis = {} 
     569 
     570        for id, data in all_data.items(): 
     571            data_content = {"fit_data":data} 
     572            if id in params.keys(): 
     573                # this dataset is represented also by the fit tab. Add to it. 
     574                data_content["fit_params"] = params[id] 
     575            analysis[id] = data_content 
     576 
     577        with open(filename, 'w') as outfile: 
     578            GuiUtils.saveData(outfile, analysis) 
    557579 
    558580    def actionSave_Analysis(self): 
     
    564586            return 
    565587        # get fit page serialization 
    566         params = per.getSerializedFitpage() 
     588        params = per.serializeCurrentFitpage() 
    567589        data_id = per.currentTabDataId() 
    568590        tab_id = per.currentTab.tab_id 
  • src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py

    r2eeda93 ra3c59503  
    113113        self.currentTab.onCopyToClipboard("Latex") 
    114114 
    115     def getSerializedFitpage(self): 
     115    def serializeAllFitpage(self): 
     116        # serialize all active fitpages and return 
     117        # a dictionary: {data_id: fitpage_state} 
     118        params = {} 
     119        for i, tab in enumerate(self.tabs): 
     120            tab_data = self.getSerializedFitpage(tab) 
     121            if tab.tab_id is None: continue 
     122            id = tab_data['data_id'][0] 
     123            params[id] = tab_data 
     124        return params 
     125 
     126    def serializeCurrentFitpage(self): 
    116127        # serialize current(active) fitpage 
    117         fitpage_state = self.currentTab.getFitPage() 
    118         fitpage_state += self.currentTab.getFitModel() 
     128        return self.getSerializedFitpage(self.currentTab) 
     129 
     130    def getSerializedFitpage(self, tab): 
     131        """ 
     132        get serialize requested fit tab 
     133        """ 
     134        fitpage_state = tab.getFitPage() 
     135        fitpage_state += tab.getFitModel() 
    119136        # put the text into dictionary 
    120137        line_dict = {} 
Note: See TracChangeset for help on using the changeset viewer.