Changeset 186d678 in sasview for src/sas/qtgui/Perspectives/Fitting


Ignore:
Timestamp:
Oct 31, 2018 4:08:16 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:
48df831
Parents:
b1b71ad (diff), 04e1c80 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ESS_GUI' into ESS_GUI_project_save

Location:
src/sas/qtgui/Perspectives/Fitting
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    rd00475d r186d678  
    294294        self.has_magnet_error_column = False 
    295295 
     296        # Enablement of comboboxes 
     297        self.enabled_cbmodel = False 
     298        self.enabled_sfmodel = False 
     299 
    296300        # If the widget generated theory item, save it 
    297301        self.theory_item = None 
     
    460464        self.cbModel.setEnabled(False) 
    461465        self.lblModel.setEnabled(False) 
     466        self.enabled_cbmodel = False 
    462467 
    463468    def enableModelCombo(self): 
     
    465470        self.cbModel.setEnabled(True) 
    466471        self.lblModel.setEnabled(True) 
     472        self.enabled_cbmodel = True 
    467473 
    468474    def disableStructureCombo(self): 
     
    470476        self.cbStructureFactor.setEnabled(False) 
    471477        self.lblStructure.setEnabled(False) 
     478        self.enabled_sfmodel = False 
    472479 
    473480    def enableStructureCombo(self): 
     
    475482        self.cbStructureFactor.setEnabled(True) 
    476483        self.lblStructure.setEnabled(True) 
     484        self.enabled_sfmodel = True 
    477485 
    478486    def togglePoly(self, isChecked): 
     
    10091017        Checks if the current model has magnetic scattering implemented 
    10101018        """ 
    1011         current_model = self.cbModel.currentText() 
    1012         return self.is2D and current_model in self.MAGNETIC_MODELS 
     1019        has_params = False 
     1020        if self.kernel_module: 
     1021            has_mag_params = len(self.kernel_module.magnetic_params) > 0 
     1022        return self.is2D and has_mag_params 
    10131023 
    10141024    def onSelectModel(self): 
     
    10341044        if not model: 
    10351045            return 
     1046 
    10361047        self.chkMagnetism.setEnabled(self.canHaveMagnetism()) 
    10371048        self.chkMagnetism.setEnabled(self.canHaveMagnetism()) 
     
    11751186        self.SASModelToQModel(model, structure_factor) 
    11761187 
     1188        # Enable magnetism checkbox for selected models 
     1189        self.chkMagnetism.setEnabled(self.canHaveMagnetism()) 
     1190        self.tabFitting.setTabEnabled(TAB_MAGNETISM, self.chkMagnetism.isChecked() and self.canHaveMagnetism()) 
     1191 
     1192        # Update column widths 
    11771193        for column, width in self.lstParamHeaderSizes.items(): 
    11781194            self.lstParams.setColumnWidth(column, width) 
     
    15731589        if param_dict is None: 
    15741590            return 
    1575         if hasattr(res, 'convergence') and len(res.convergence)>0: 
    1576             self.communicate.resultPlotUpdateSignal.emit(result[0]) 
     1591        self.communicate.resultPlotUpdateSignal.emit(result[0]) 
    15771592 
    15781593        elapsed = result[1] 
     
    31103125        shell_par = None 
    31113126        for par in kernel_pars: 
    3112             if par.name == param_name: 
     3127            parname = par.name 
     3128            if '[' in parname: 
     3129                 parname = parname[:parname.index('[')] 
     3130            if parname == param_name: 
    31133131                shell_par = par 
    31143132                break 
    3115         if not shell_par: 
     3133        if shell_par is None: 
    31163134            logger.error("Could not find %s in kernel parameters.", param_name) 
     3135            return 
    31173136        default_shell_count = shell_par.default 
    31183137        shell_min = 0 
     
    31243143            # no info about limits 
    31253144            pass 
     3145        except Exception as ex: 
     3146            logging.error("Badly defined multiplicity: "+ str(ex)) 
     3147            return 
    31263148        # don't update the kernel here - this data is display only 
    31273149        self._model_model.blockSignals(True) 
     
    31303152        self._model_model.blockSignals(False) 
    31313153 
     3154        ## Respond to index change 
     3155        #func.currentTextChanged.connect(self.modifyShellsInList) 
     3156 
     3157        # Respond to button press 
     3158        button.clicked.connect(self.onShowSLDProfile) 
     3159 
     3160        # Available range of shells displayed in the combobox 
     3161        func.addItems([str(i) for i in range(shell_min, shell_max+1)]) 
     3162 
    31323163        # Respond to index change 
    31333164        func.currentTextChanged.connect(self.modifyShellsInList) 
    31343165 
    3135         # Respond to button press 
    3136         button.clicked.connect(self.onShowSLDProfile) 
    3137  
    3138         # Available range of shells displayed in the combobox 
    3139         func.addItems([str(i) for i in range(shell_min, shell_max+1)]) 
    3140  
    31413166        # Add default number of shells to the model 
    31423167        func.setCurrentText(str(default_shell_count)) 
     3168        self.modifyShellsInList(str(default_shell_count)) 
    31433169 
    31443170    def modifyShellsInList(self, text): 
     
    31883214        """ 
    31893215        # get profile data 
    3190         x, y = self.kernel_module.getProfile() 
     3216        try: 
     3217            x, y = self.kernel_module.getProfile() 
     3218        except TypeError: 
     3219            msg = "SLD profile calculation failed." 
     3220            logging.error(msg) 
     3221            return 
     3222 
    31913223        y *= 1.0e6 
    31923224        profile_data = Data1D(x=x, y=y) 
     
    32213253 
    32223254        self.cbCategory.setEnabled(enabled) 
    3223         self.cbModel.setEnabled(enabled) 
     3255 
     3256        if enabled: 
     3257            # worry about original enablement of model and SF 
     3258            self.cbModel.setEnabled(self.enabled_cbmodel) 
     3259            self.cbStructureFactor.setEnabled(self.enabled_sfmodel) 
     3260        else: 
     3261            self.cbModel.setEnabled(enabled) 
     3262            self.cbStructureFactor.setEnabled(enabled) 
     3263 
    32243264        self.cmdPlot.setEnabled(enabled) 
    32253265 
  • src/sas/qtgui/Perspectives/Fitting/SmearingWidget.py

    rf20ea3f r04e1c80  
    220220        self.txtSmearDown.setEnabled(True) 
    221221        self.txtSmearUp.setEnabled(True) 
    222         self.txtSmearDown.setText(str(0.0)) 
    223         self.txtSmearUp.setText(str(0.0)) 
     222        #self.txtSmearDown.setText(str(0.0)) 
     223        #self.txtSmearUp.setText(str(0.0)) 
    224224 
    225225    def setSlitLabels(self): 
     
    235235        self.txtSmearDown.setEnabled(True) 
    236236        self.txtSmearUp.setEnabled(True) 
    237         self.txtSmearDown.setText(str(0.0)) 
    238         self.txtSmearUp.setText(str(0.0)) 
     237        #self.txtSmearDown.setText(str(0.0)) 
     238        #self.txtSmearUp.setText(str(0.0)) 
    239239 
    240240    def setDQLabels(self): 
     
    330330        """ 
    331331        _, accuracy, d_height, d_width = self.state() 
     332 
    332333        # Check changes in slit width 
    333334        if d_width is None: 
     
    337338 
    338339        if isinstance(self.data, Data2D): 
     340            self.current_smearer = smear_selection(self.data, self.kernel_model) 
    339341            return 
    340342        # make sure once more if it is smearer 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py

    r2eeda93 r186d678  
    185185 
    186186        # Observe no such luck 
    187         self.assertEqual(self.widget.cbCategory.currentIndex(), 7) 
     187        self.assertEqual(self.widget.cbCategory.currentIndex(), 6) 
    188188        self.assertEqual(self.widget.cbModel.count(), 29) 
    189189 
     
    219219        #  
    220220        # Now change the model 
     221<<<<<<< HEAD 
    221222        self.widget.cbModel.setCurrentIndex(4) 
     223======= 
     224        self.widget.cbModel.setCurrentIndex(2) 
     225>>>>>>> ESS_GUI 
    222226        self.assertEqual(self.widget.cbModel.currentText(),'dab') 
    223227 
  • src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py

    r906e0c7 r722b7d6  
    1313        Overwrite generic constructor to allow for some globals 
    1414        """ 
    15         super(QtWidgets.QStyledItemDelegate, self).__init__() 
     15        super(ModelViewDelegate, self).__init__() 
    1616 
    1717        # Main parameter table view columns 
     
    125125        Overwrite generic constructor to allow for some globals 
    126126        """ 
    127         super(QtWidgets.QStyledItemDelegate, self).__init__() 
     127        super(PolyViewDelegate, self).__init__() 
    128128 
    129129        self.poly_parameter = 0 
     
    226226        Overwrite generic constructor to allow for some globals 
    227227        """ 
    228         super(QtWidgets.QStyledItemDelegate, self).__init__() 
     228        super(MagnetismViewDelegate, self).__init__() 
    229229 
    230230        self.mag_parameter = 0 
  • src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py

    rd2007a8 ra3c59503  
    112112    def onLatexCopy(self): 
    113113        self.currentTab.onCopyToClipboard("Latex") 
     114 
     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): 
     127        # serialize current(active) fitpage 
     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() 
     136        # put the text into dictionary 
     137        line_dict = {} 
     138        for line in fitpage_state: 
     139            #content = line.split(',') 
     140            if len(line) > 1: 
     141                line_dict[line[0]] = line[1:] 
     142        return line_dict 
     143 
     144    def currentTabDataId(self): 
     145        """ 
     146        Returns the data ID of the current tab 
     147        """ 
     148        tab_id = None 
     149        if self.currentTab.data: 
     150            tab_id = self.currentTab.data.id 
     151        return tab_id 
     152 
     153    def updateFromParameters(self, parameters): 
     154        """ 
     155        Pass the update parameters to the current fit page 
     156        """ 
     157        self.currentTab.createPageForParameters(parameters) 
    114158 
    115159    def closeEvent(self, event): 
     
    258302        return True 
    259303 
     304    def isSerializable(self): 
     305        """ 
     306        Tell the caller that this perspective writes its state 
     307        """ 
     308        return True 
     309 
    260310    def setData(self, data_item=None, is_batch=False): 
    261311        """ 
     
    337387        pass 
    338388 
     389    def getCurrentStateAsXml(self): 
     390        """ 
     391        Returns an XML version of the current state 
     392        """ 
     393        state = {} 
     394        for tab in self.tabs: 
     395            pass 
     396        return state 
     397 
    339398    @property 
    340399    def currentTab(self): 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/ComplexConstraintTest.py

    r725d9c06 r2eeda93  
    3434        category_index = self.tab1.cbCategory.findText("Shape Independent") 
    3535        self.tab1.cbCategory.setCurrentIndex(category_index) 
     36        model_index = self.tab1.cbModel.findText("be_polyelectrolyte") 
     37        self.tab1.cbModel.setCurrentIndex(model_index) 
     38 
    3639        category_index = self.tab2.cbCategory.findText("Cylinder") 
    3740        self.tab2.cbCategory.setCurrentIndex(category_index) 
     41        model_index = self.tab2.cbModel.findText("barbell") 
     42        self.tab2.cbModel.setCurrentIndex(model_index) 
    3843 
    3944        tabs = [self.tab1, self.tab2] 
Note: See TracChangeset for help on using the changeset viewer.