Changeset e5ae812 in sasview for src


Ignore:
Timestamp:
Nov 13, 2018 7:25:48 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:
baeac95
Parents:
133812c7
Message:

Added C&S tab serialization.

Location:
src/sas/qtgui
Files:
5 edited

Legend:

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

    r133812c7 re5ae812  
    457457                self.chkBatch.setChecked(True if value=='True' else False) 
    458458                continue 
     459            if 'cs_tab' in key: 
     460                continue 
    459461            # send newly created items to the perspective 
    460462            self.updatePerspectiveWithProperties(key, value) 
     
    462464        # See if there are any batch pages defined and create them, if so 
    463465        self.updateWithBatchPages(all_data) 
     466 
     467        # Only now can we create/assign C&S pages. 
     468        for key, value in all_data.items(): 
     469            if 'cs_tab' in key: 
     470                self.updatePerspectiveWithProperties(key, value) 
    464471 
    465472    def updateWithBatchPages(self, all_data): 
     
    488495                self._perspective().setData(data_item=items, is_batch=True) 
    489496                self._perspective().updateFromParameters(page) 
    490  
    491497        pass 
    492498 
     
    494500        """ 
    495501        """ 
    496         data_dict = {key:value['fit_data']} 
    497         # Create new model items in the data explorer 
    498         items = self.updateModelFromData(data_dict) 
     502        if 'fit_data' in value: 
     503            data_dict = {key:value['fit_data']} 
     504            # Create new model items in the data explorer 
     505            items = self.updateModelFromData(data_dict) 
    499506 
    500507        if 'fit_params' in value: 
     
    512519                # Assign parameters to the most recent (current) page. 
    513520                self._perspective().updateFromParameters(page) 
     521        if 'cs_tab' in key and 'is_constraint' in value: 
     522            # Create a C&S page 
     523            self._perspective().addConstraintTab() 
     524            # Modify the tab 
     525            self._perspective().updateFromParameters(value) 
     526 
    514527        pass # debugger 
    515528 
  • src/sas/qtgui/MainWindow/GuiManager.py

    r133812c7 re5ae812  
    594594            analysis[id] = data_content 
    595595 
     596        # standalone constraint pages 
     597        for keys, values in params.items(): 
     598            if not 'is_constraint' in values[0]: 
     599                continue 
     600            analysis[keys] = values[0] 
     601 
    596602        with open(filename, 'w') as outfile: 
    597603            GuiUtils.saveData(outfile, analysis) 
     
    11771183            out_f.write("#Application appearance custom configuration\n") 
    11781184            for key, item in config.__dict__.items(): 
    1179                 if key[:2] != "__": 
    1180                     if isinstance(item, str): 
    1181                         item = '"' + item + '"' 
    1182                     out_f.write("%s = %s\n" % (key, str(item))) 
     1185                if key[:2] == "__": 
     1186                    continue 
     1187                if isinstance(item, str): 
     1188                    item = '"' + item + '"' 
     1189                out_f.write("%s = %s\n" % (key, str(item))) 
    11831190        pass # debugger anchor 
  • src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py

    raed0532 re5ae812  
    3131        # To keep with previous SasView values, use 300 as the start offset 
    3232        self.page_id = 301 
     33        self.tab_id = self.page_id 
    3334 
    3435        # Are we chain fitting? 
     
    693694        # Update the tab 
    694695        constrained_tab.addConstraintToRow(constraint, constrained_row) 
     696 
     697    def getFitPage(self): 
     698        """ 
     699        Retrieves the state of this page 
     700        """ 
     701        param_list = [] 
     702 
     703        param_list.append(['is_constraint', 'True']) 
     704        param_list.append(['data_id', "cs_tab"+str(self.page_id)]) 
     705        param_list.append(['current_type', self.currentType]) 
     706        param_list.append(['is_chain_fitting', str(self.is_chain_fitting)]) 
     707        param_list.append(['special_case', self.cbCases.currentText()]) 
     708 
     709        return param_list 
     710 
     711    def getFitModel(self): 
     712        """ 
     713        Retrieves current model 
     714        """ 
     715        model_list = [] 
     716 
     717        checked_models = {} 
     718        for row in range(self.tblTabList.rowCount()): 
     719            model_name = self.tblTabList.item(row,1).data(0) 
     720            active = self.tblTabList.item(row,0).checkState()# == QtCore.Qt.Checked 
     721            checked_models[model_name] = str(active) 
     722 
     723        checked_constraints = {} 
     724        for row in range(self.tblConstraints.rowCount()): 
     725            model_name = self.tblConstraints.item(row,0).data(0) 
     726            active = self.tblConstraints.item(row,0).checkState()# == QtCore.Qt.Checked 
     727            checked_constraints[model_name] = str(active) 
     728 
     729        model_list.append(['checked_models', checked_models]) 
     730        model_list.append(['checked_constraints', checked_constraints]) 
     731        return model_list 
     732 
     733    def createPageForParameters(self, parameters=None): 
     734        """ 
     735        Update the page with passed parameter values 
     736        """ 
     737        # checked models 
     738        if not 'checked_models' in parameters: 
     739            return 
     740        models = parameters['checked_models'][0] 
     741        for model, check_state in models.items(): 
     742            for row in range(self.tblTabList.rowCount()): 
     743                model_name = self.tblTabList.item(row,1).data(0) 
     744                if model_name != model: 
     745                    continue 
     746                # check/uncheck item 
     747                self.tblTabList.item(row,0).setCheckState(int(check_state)) 
     748 
     749        if not 'checked_constraints' in parameters: 
     750            return 
     751        # checked constraints 
     752        models = parameters['checked_constraints'][0] 
     753        for model, check_state in models.items(): 
     754            for row in range(self.tblConstraints.rowCount()): 
     755                model_name = self.tblConstraints.item(row,0).data(0) 
     756                if model_name != model: 
     757                    continue 
     758                # check/uncheck item 
     759                self.tblConstraints.item(row,0).setCheckState(int(check_state)) 
     760 
     761        # fit/batch radio 
     762        isBatch = parameters['current_type'][0] == 'BatchPage' 
     763        if isBatch: 
     764            self.btnBatch.toggle() 
     765 
     766        # chain 
     767        is_chain = parameters['is_chain_fitting'][0] == 'True' 
     768        if isBatch: 
     769            self.chkChain.setChecked(is_chain) 
     770 
     771 
  • src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py

    rebcdb02 re5ae812  
    3939        self.maxIndex = 1 
    4040 
    41         ## Index of the current tab 
    42         #self.currentTab = 0 
    43  
    4441        # The default optimizer 
    4542        self.optimizer = 'Levenberg-Marquardt' 
     
    121118        for i, tab in enumerate(self.tabs): 
    122119            tab_data = self.getSerializedFitpage(tab) 
    123             if tab.tab_id is None: continue 
    124120            if 'data_id' not in tab_data: continue 
    125121            id = tab_data['data_id'][0] 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r133812c7 re5ae812  
    19521952        Emits plotRequestedSignal for all plots found in the given model under the provided item name. 
    19531953        """ 
    1954         fitpage_name = "" if self.tab_id is None else "M"+str(self.tab_id) 
     1954        fitpage_name = self.kernel_module.name 
    19551955        plots = GuiUtils.plotsFromFilename(item_name, item_model) 
    19561956        # Has the fitted data been shown? 
     
    35243524        param_list.append(['data_name', filenames]) 
    35253525        param_list.append(['data_id', data_ids]) 
     3526        param_list.append(['tab_name', self.modelName()]) 
    35263527        # option tab 
    35273528        param_list.append(['q_range_min', str(self.q_range_min)]) 
     
    35963597            except: 
    35973598                pass 
    3598  
    3599             param_list.append([param_name, param_checked, param_value, param_error, param_min, param_max]) 
     3599            # Do we have any constraints on this parameter? 
     3600            constraint = self.getConstraintForRow(row) 
     3601            cons = () 
     3602            if constraint is not None: 
     3603                value = constraint.value 
     3604                func = constraint.func 
     3605                cons = (value, func) 
     3606 
     3607            param_list.append([param_name, param_checked, param_value, param_error, param_min, param_max, cons]) 
    36003608 
    36013609        def gatherPolyParams(row): 
     
    37053713                self.updateMultiplicityCombo(multip) 
    37063714 
     3715        if 'tab_name' in line_dict.keys(): 
     3716            self.kernel_module.name = line_dict['tab_name'][0] 
    37073717        if 'polydisperse_params' in line_dict.keys(): 
    37083718            self.chkPolydispersity.setChecked(line_dict['polydisperse_params'][0]=='True') 
     
    38273837            ioffset = 0 
    38283838            joffset = 0 
    3829             if len(param_dict[param_name])>4: 
     3839            if len(param_dict[param_name])>5: 
    38303840                # error values are not editable - no need to update 
    38313841                ioffset = 1 
     
    38403850            except: 
    38413851                pass 
     3852 
     3853            # constraints 
     3854            cons = param_dict[param_name][4+ioffset] 
     3855            if cons is not None and cons: 
     3856                value = cons[0] 
     3857                function = cons[1] 
     3858                constraint = Constraint() 
     3859                constraint.value = value 
     3860                constraint.func = function 
     3861                self.addConstraintToRow(constraint=constraint, row=row) 
    38423862 
    38433863            self.setFocus() 
Note: See TracChangeset for help on using the changeset viewer.