Ignore:
Timestamp:
May 10, 2017 7:36:13 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
1bc27f1
Parents:
2da5759
Message:

Further fitpage implementation with tests SASVIEW-570

File:
1 edited

Legend:

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

    r2da5759 r672b8ab  
    358358            self.createDefaultDataset() 
    359359 
    360         #state = self.currentState() 
     360        state = self.currentState() 
    361361 
    362362    def onSelectStructureFactor(self): 
     
    11491149        self.current_shell_displayed = index 
    11501150 
     1151    def readFitPage(self, fp): 
     1152        """ 
     1153        Read in state from a fitpage object and update GUI 
     1154        """ 
     1155        assert isinstance(fp, FitPage) 
     1156        # Main tab info 
     1157        self.logic.data.filename = fp.filename 
     1158        self.data_is_loaded = fp.data_is_loaded 
     1159        self.chkPolydispersity.setCheckState(fp.is_polydisperse) 
     1160        self.chkMagnetism.setCheckState(fp.is_magnetic) 
     1161        self.chk2DView.setCheckState(fp.is2D) 
     1162 
     1163        # Update the comboboxes 
     1164        self.cbCategory.setCurrentIndex(self.cbCategory.findText(fp.current_category)) 
     1165        self.cbModel.setCurrentIndex(self.cbModel.findText(fp.current_model)) 
     1166        if fp.current_factor: 
     1167            self.cbStructureFactor.setCurrentIndex(self.cbStructureFactor.findText(fp.current_factor)) 
     1168 
     1169        self.chi2 = fp.chi2 
     1170 
     1171        # Options tab 
     1172        self.q_range_min = fp.fit_options[fp.MIN_RANGE] 
     1173        self.q_range_max = fp.fit_options[fp.MAX_RANGE] 
     1174        self.npts = fp.fit_options[fp.NPTS] 
     1175        #fp.fit_options[fp.NPTS_FIT] = self.npts_fit 
     1176        self.log_points = fp.fit_options[fp.LOG_POINTS] 
     1177        self.weighting = fp.fit_options[fp.WEIGHTING] 
     1178 
     1179        # Models 
     1180        #self._model_model = fp.model_model 
     1181        #self._poly_model = fp.poly_model 
     1182        #self._magnet_model = fp.magnetism_model 
     1183 
     1184        # Resolution tab 
     1185        smearing = fp.smearing_options[fp.SMEARING_OPTION] 
     1186        accuracy = fp.smearing_options[fp.SMEARING_ACCURACY] 
     1187        smearing_min = fp.smearing_options[fp.SMEARING_MIN] 
     1188        smearing_max = fp.smearing_options[fp.SMEARING_MAX] 
     1189        self.smearing_widget.setState(smearing, accuracy, smearing_min, smearing_max) 
     1190 
     1191        # TODO: add polidyspersity and magnetism 
     1192 
     1193    def saveToFitPage(self, fp): 
     1194        """ 
     1195        Write current state to the given fitpage 
     1196        """ 
     1197        assert isinstance(fp, FitPage) 
     1198 
     1199        # Main tab info 
     1200        fp.filename = self.logic.data.filename 
     1201        fp.data_is_loaded = self.data_is_loaded 
     1202        fp.is_polydisperse = self.chkPolydispersity.isChecked() 
     1203        fp.is_magnetic = self.chkMagnetism.isChecked() 
     1204        fp.is2D = self.chk2DView.isChecked() 
     1205        fp.data = self.data 
     1206 
     1207        # Use current models - they contain all the required parameters 
     1208        fp.model_model = self._model_model 
     1209        fp.poly_model = self._poly_model 
     1210        fp.magnetism_model = self._magnet_model 
     1211 
     1212        if self.cbCategory.currentIndex() != 0: 
     1213            fp.current_category = str(self.cbCategory.currentText()) 
     1214            fp.current_model = str(self.cbModel.currentText()) 
     1215 
     1216        if self.cbStructureFactor.isEnabled() and self.cbStructureFactor.currentIndex() != 0: 
     1217            fp.current_factor = str(self.cbStructureFactor.currentText()) 
     1218        else: 
     1219            fp.current_factor = '' 
     1220 
     1221        fp.chi2 = self.chi2 
     1222        fp.parameters_to_fit = self.parameters_to_fit 
     1223 
     1224        # Options tab 
     1225        fp.fit_options[fp.MIN_RANGE] = self.q_range_min 
     1226        fp.fit_options[fp.MAX_RANGE] = self.q_range_max 
     1227        fp.fit_options[fp.NPTS] = self.npts 
     1228        #fp.fit_options[fp.NPTS_FIT] = self.npts_fit 
     1229        fp.fit_options[fp.LOG_POINTS] = self.log_points 
     1230        fp.fit_options[fp.WEIGHTING] = self.weighting 
     1231 
     1232        # Resolution tab 
     1233        smearing, accuracy, smearing_min, smearing_max = self.smearing_widget.state() 
     1234        fp.smearing_options[fp.SMEARING_OPTION] = smearing 
     1235        fp.smearing_options[fp.SMEARING_ACCURACY] = accuracy 
     1236        fp.smearing_options[fp.SMEARING_MIN] = smearing_min 
     1237        fp.smearing_options[fp.SMEARING_MAX] = smearing_max 
     1238 
     1239        # TODO: add polidyspersity and magnetism 
     1240 
     1241    def currentState(self): 
     1242        """ 
     1243        Return fit page with current state 
     1244        """ 
     1245        new_page = FitPage() 
     1246        self.saveToFitPage(new_page) 
     1247 
     1248        return new_page 
     1249 
     1250    def pushFitPage(self, new_page): 
     1251        """ 
     1252        Add a new fit page object with current state 
     1253        """ 
     1254        #page_stack.append(new_page) 
     1255        pass 
     1256 
     1257    def popFitPage(self): 
     1258        """ 
     1259        Remove top fit page from stack 
     1260        """ 
     1261        #if page_stack: 
     1262        #    page_stack.pop() 
     1263        pass 
     1264 
Note: See TracChangeset for help on using the changeset viewer.