Changes in / [b95d748:10d57f6] in sasview
- Location:
- src/sas/qtgui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/MainWindow/GuiManager.py
refaf022 r6040cd7 444 444 """ 445 445 # disable not yet fully implemented actions 446 self._workspace.actionOpen_Analysis.setVisible(False)446 #self._workspace.actionOpen_Analysis.setVisible(False) 447 447 self._workspace.actionUndo.setVisible(False) 448 448 self._workspace.actionRedo.setVisible(False) -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
rdd545d1 r9a42ea1 567 567 self.communicate.customModelDirectoryChanged.connect(self.onCustomModelChange) 568 568 self.communicate.saveAnalysisSignal.connect(self.savePageState) 569 #self.communicate.loadAnalysisSignal.connect(self.loadPageState) 569 570 self.smearing_widget.smearingChangedSignal.connect(self.onSmearingOptionsUpdate) 570 571 … … 3369 3370 Create and serialize local PageState 3370 3371 """ 3371 from sas.sascalc.fit.pagestate import Reader3372 model = self.kernel_module3373 3374 # Old style PageState object3375 state = PageState(model=model, data=self.data)3376 3377 # Add parameter data to the state3378 self.getCurrentFitState(state)3379 3380 # Create the filewriter, aptly named 'Reader'3381 state_reader = Reader(self.loadPageStateCallback)3382 3372 filepath = self.saveAsAnalysisFile() 3383 3373 if filepath is None or filepath == "": 3384 3374 return 3385 state_reader.write(filename=filepath, fitstate=state) 3386 pass 3375 3376 fitpage_state = self.getFitPage() 3377 fitpage_state += self.getFitModel() 3378 3379 with open(filepath, 'w') as statefile: 3380 for line in fitpage_state: 3381 statefile.write(str(line)) 3382 3383 self.communicate.statusBarUpdateSignal.emit('Analysis saved.') 3387 3384 3388 3385 def saveAsAnalysisFile(self): … … 3417 3414 Load the PageState object and update the current widget 3418 3415 """ 3416 filepath = self.loadAnalysisFile() 3417 if filepath is None or filepath == "": 3418 return 3419 3420 with open(filepath, 'r') as statefile: 3421 #column_data = [line.rstrip().split() for line in statefile.readlines()] 3422 lines = statefile.readlines() 3423 3424 # convert into list of lists 3419 3425 pass 3420 3426 3421 def getCurrentFitState(self, state=None): 3422 """ 3423 Store current state for fit_page 3424 """ 3425 # save model option 3426 #if self.model is not None: 3427 # self.disp_list = self.getDispParamList() 3428 # state.disp_list = copy.deepcopy(self.disp_list) 3429 # #state.model = self.model.clone() 3430 3431 # Comboboxes 3432 state.categorycombobox = self.cbCategory.currentText() 3433 state.formfactorcombobox = self.cbModel.currentText() 3434 if self.cbStructureFactor.isEnabled(): 3435 state.structurecombobox = self.cbStructureFactor.currentText() 3436 state.tcChi = self.chi2 3437 3438 state.enable2D = self.is2D 3439 3440 #state.weights = copy.deepcopy(self.weights) 3441 # save data 3442 state.data = copy.deepcopy(self.data) 3443 3444 # save plotting range 3445 state.qmin = self.q_range_min 3446 state.qmax = self.q_range_max 3447 state.npts = self.npts 3448 3449 # self.state.enable_disp = self.enable_disp.GetValue() 3450 # self.state.disable_disp = self.disable_disp.GetValue() 3451 3452 # self.state.enable_smearer = \ 3453 # copy.deepcopy(self.enable_smearer.GetValue()) 3454 # self.state.disable_smearer = \ 3455 # copy.deepcopy(self.disable_smearer.GetValue()) 3456 3457 #self.state.pinhole_smearer = \ 3458 # copy.deepcopy(self.pinhole_smearer.GetValue()) 3459 #self.state.slit_smearer = copy.deepcopy(self.slit_smearer.GetValue()) 3460 #self.state.dI_noweight = copy.deepcopy(self.dI_noweight.GetValue()) 3461 #self.state.dI_didata = copy.deepcopy(self.dI_didata.GetValue()) 3462 #self.state.dI_sqrdata = copy.deepcopy(self.dI_sqrdata.GetValue()) 3463 #self.state.dI_idata = copy.deepcopy(self.dI_idata.GetValue()) 3464 3465 p = self.model_parameters 3466 # save checkbutton state and txtcrtl values 3467 state.parameters = FittingUtilities.getStandardParam(self._model_model) 3468 state.orientation_params_disp = FittingUtilities.getOrientationParam(self.kernel_module) 3469 3470 #self._copy_parameters_state(self.orientation_params_disp, self.state.orientation_params_disp) 3471 #self._copy_parameters_state(self.parameters, self.state.parameters) 3472 #self._copy_parameters_state(self.fittable_param, self.state.fittable_param) 3473 #self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 3427 def loadAnalysisFile(self): 3428 """ 3429 Called when the "Open Project" menu item chosen. 3430 """ 3431 default_name = "FitPage"+str(self.tab_id)+".fitv" 3432 wildcard = "fitv files (*.fitv)" 3433 kwargs = { 3434 'caption' : 'Open Analysis', 3435 'directory' : default_name, 3436 'filter' : wildcard, 3437 'parent' : self, 3438 } 3439 filename = QtWidgets.QFileDialog.getOpenFileName(**kwargs)[0] 3440 return filename 3474 3441 3475 3442 def onCopyToClipboard(self, format=None): … … 3481 3448 param_list = self.getFitParameters() 3482 3449 if format=="": 3450 param_list = self.getFitPage() 3451 param_list += self.getFitModel() 3483 3452 formatted_output = FittingUtilities.formatParameters(param_list) 3484 3453 elif format == "Excel": … … 3493 3462 cb.setText(formatted_output) 3494 3463 3495 def getFitParameters(self, format=None): 3496 """ 3497 Copy current parameters into the clipboard 3464 def getFitModel(self): 3465 """ 3466 serializes combobox state 3467 """ 3468 param_list = [] 3469 model = str(self.cbModel.currentText()) 3470 category = str(self.cbCategory.currentText()) 3471 structure = str(self.cbStructureFactor.currentText()) 3472 param_list.append(['fitpage_category', category]) 3473 param_list.append(['fitpage_model', model]) 3474 param_list.append(['fitpage_structure', structure]) 3475 3476 return param_list 3477 3478 def getFitPage(self): 3479 """ 3480 serializes full state of this fit page 3498 3481 """ 3499 3482 # run a loop over all parameters and pull out 3500 3483 # first - regular params 3484 param_list = self.getFitParameters() 3485 3486 param_list.append(['is_data', str(self.data_is_loaded)]) 3487 if self.data_is_loaded: 3488 param_list.append(['data_id', str(self.logic.data.id)]) 3489 param_list.append(['data_name', str(self.logic.data.filename)]) 3490 3491 # option tab 3492 param_list.append(['q_range_min', str(self.q_range_min)]) 3493 param_list.append(['q_range_max', str(self.q_range_max)]) 3494 param_list.append(['q_weighting', str(self.weighting)]) 3495 param_list.append(['weighting', str(self.options_widget.weighting)]) 3496 3497 # resolution 3498 smearing, accuracy, smearing_min, smearing_max = self.smearing_widget.state() 3499 index = self.smearing_widget.cbSmearing.currentIndex() 3500 param_list.append(['smearing', str(index)]) 3501 param_list.append(['smearing_min', str(smearing_min)]) 3502 param_list.append(['smearing_max', str(smearing_max)]) 3503 3504 # checkboxes, if required 3505 has_polydisp = self.chkPolydispersity.isChecked() 3506 has_magnetism = self.chkMagnetism.isChecked() 3507 has_chain = self.chkChainFit.isChecked() 3508 has_2D = self.chk2DView.isChecked() 3509 param_list.append(['polydisperse_params', str(has_polydisp)]) 3510 param_list.append(['magnetic_params', str(has_magnetism)]) 3511 param_list.append(['chainfit_params', str(has_chain)]) 3512 param_list.append(['2D_params', str(has_2D)]) 3513 3514 return param_list 3515 3516 def getFitParameters(self): 3517 """ 3518 serializes current parameters 3519 """ 3501 3520 param_list = [] 3502 3521 param_list.append(['model_name', str(self.cbModel.currentText())]) … … 3533 3552 if self.has_error_column: 3534 3553 column_offset = 1 3554 param_error = str(self._model_model.item(row, 1+column_offset).text()) 3535 3555 try: 3536 3556 param_min = str(self._model_model.item(row, 2+column_offset).text()) … … 3539 3559 pass 3540 3560 3541 param_list.append([param_name, param_checked, param_value, param_ min, param_max])3561 param_list.append([param_name, param_checked, param_value, param_error, param_min, param_max]) 3542 3562 3543 3563 def gatherPolyParams(row): … … 3552 3572 if self.has_poly_error_column: 3553 3573 column_offset = 1 3574 param_error = str(self._poly_model.item(row, 1+column_offset).text()) 3554 3575 param_min = str(self._poly_model.item(row, 2+column_offset).text()) 3555 3576 param_max = str(self._poly_model.item(row, 3+column_offset).text()) … … 3563 3584 # width 3564 3585 name = param_name+".width" 3565 param_list.append([name, param_checked, param_value, param_ min, param_max,3566 param_npts, param_nsigs, param_fun])3586 param_list.append([name, param_checked, param_value, param_error, 3587 param_min, param_max, param_npts, param_nsigs, param_fun]) 3567 3588 3568 3589 def gatherMagnetParams(row): … … 3577 3598 if self.has_magnet_error_column: 3578 3599 column_offset = 1 3600 param_error = str(self._magnet_model.item(row, 1+column_offset).text()) 3579 3601 param_min = str(self._magnet_model.item(row, 2+column_offset).text()) 3580 3602 param_max = str(self._magnet_model.item(row, 3+column_offset).text()) 3581 param_list.append([param_name, param_checked, param_value, param_min, param_max]) 3603 param_list.append([param_name, param_checked, param_value, 3604 param_error, param_min, param_max]) 3582 3605 3583 3606 self.iterateOverModel(gatherParams) … … 3589 3612 if self.kernel_module.is_multiplicity_model: 3590 3613 param_list.append(['multiplicity', str(self.kernel_module.multiplicity)]) 3591 3592 # option tab3593 param_list.append(['q_range_min', str(self.q_range_min)])3594 param_list.append(['q_range_max', str(self.q_range_max)])3595 param_list.append(['q_weighting', str(self.weighting)])3596 3597 # resolution3598 smearing, accuracy, smearing_min, smearing_max = self.smearing_widget.state()3599 index = self.smearing_widget.cbSmearing.currentIndex()3600 param_list.append(['smearing', str(index)])3601 param_list.append(['smearing_min', str(smearing_min)])3602 param_list.append(['smearing_max', str(smearing_max)])3603 3604 # checkboxes, if required3605 has_polydisp = self.chkPolydispersity.isChecked()3606 has_magnetism = self.chkMagnetism.isChecked()3607 has_chain = self.chkChainFit.isChecked()3608 has_2D = self.chk2DView.isChecked()3609 param_list.append(['polydisperse_params', str(has_polydisp)])3610 param_list.append(['magnetic_params', str(has_magnetism)])3611 param_list.append(['chainfit_params', str(has_chain)])3612 param_list.append(['2D_params', str(has_2D)])3613 3614 3614 3615 return param_list … … 3697 3698 pass 3698 3699 self.options_widget.updateQRange(self.q_range_min, self.q_range_max, self.npts) 3700 try: 3701 button_id = int(line_dict['weighting'][0]) 3702 for button in self.options_widget.weightingGroup.buttons(): 3703 if abs(self.options_widget.weightingGroup.id(button)) == button_id+2: 3704 button.setChecked(True) 3705 break 3706 except ValueError: 3707 pass 3699 3708 3700 3709 self.updateFullModel(context) … … 3759 3768 # Potentially the error column 3760 3769 ioffset = 0 3761 if len(param_dict[param_name])>4 and self.has_error_column: 3770 joffset = 0 3771 if len(param_dict[param_name])>3: 3762 3772 # error values are not editable - no need to update 3763 3773 ioffset = 1 3774 if self.has_error_column: 3775 joffset = 1 3764 3776 # min/max 3765 3777 try: 3766 3778 param_repr = GuiUtils.formatNumber(param_dict[param_name][2+ioffset], high=True) 3767 self._model_model.item(row, 2+ ioffset).setText(param_repr)3779 self._model_model.item(row, 2+joffset).setText(param_repr) 3768 3780 param_repr = GuiUtils.formatNumber(param_dict[param_name][3+ioffset], high=True) 3769 self._model_model.item(row, 3+ ioffset).setText(param_repr)3781 self._model_model.item(row, 3+joffset).setText(param_repr) 3770 3782 except: 3771 3783 pass … … 3801 3813 # Potentially the error column 3802 3814 ioffset = 0 3803 if len(param_dict[param_name])>4 and self.has_poly_error_column: 3815 joffset = 0 3816 if len(param_dict[param_name])>3: 3804 3817 ioffset = 1 3818 if self.has_poly_error_column: 3819 joffset = 1 3805 3820 # min 3806 3821 param_repr = GuiUtils.formatNumber(param_dict[param_name][2+ioffset], high=True) 3807 self._poly_model.item(row, 2+ ioffset).setText(param_repr)3822 self._poly_model.item(row, 2+joffset).setText(param_repr) 3808 3823 # max 3809 3824 param_repr = GuiUtils.formatNumber(param_dict[param_name][3+ioffset], high=True) 3810 self._poly_model.item(row, 3+ ioffset).setText(param_repr)3825 self._poly_model.item(row, 3+joffset).setText(param_repr) 3811 3826 # Npts 3812 3827 param_repr = GuiUtils.formatNumber(param_dict[param_name][4+ioffset], high=True) 3813 self._poly_model.item(row, 4+ ioffset).setText(param_repr)3828 self._poly_model.item(row, 4+joffset).setText(param_repr) 3814 3829 # Nsigs 3815 3830 param_repr = GuiUtils.formatNumber(param_dict[param_name][5+ioffset], high=True) 3816 self._poly_model.item(row, 5+ioffset).setText(param_repr) 3817 3818 param_repr = GuiUtils.formatNumber(param_dict[param_name][5+ioffset], high=True) 3819 self._poly_model.item(row, 5+ioffset).setText(param_repr) 3831 self._poly_model.item(row, 5+joffset).setText(param_repr) 3832 3820 3833 self.setFocus() 3821 3834 … … 3848 3861 # Potentially the error column 3849 3862 ioffset = 0 3850 if len(param_dict[param_name])>4 and self.has_magnet_error_column: 3863 joffset = 0 3864 if len(param_dict[param_name])>3: 3851 3865 ioffset = 1 3866 if self.has_magnet_error_column: 3867 joffset = 1 3852 3868 # min 3853 3869 param_repr = GuiUtils.formatNumber(param_dict[param_name][2+ioffset], high=True) 3854 self._magnet_model.item(row, 2+ ioffset).setText(param_repr)3870 self._magnet_model.item(row, 2+joffset).setText(param_repr) 3855 3871 # max 3856 3872 param_repr = GuiUtils.formatNumber(param_dict[param_name][3+ioffset], high=True) 3857 self._magnet_model.item(row, 3+ ioffset).setText(param_repr)3873 self._magnet_model.item(row, 3+joffset).setText(param_repr) 3858 3874 3859 3875 self.iterateOverMagnetModel(updateFittedValues) 3876 3877 def getCurrentFitState(self, state=None): 3878 """ 3879 Store current state for fit_page 3880 """ 3881 # save model option 3882 #if self.model is not None: 3883 # self.disp_list = self.getDispParamList() 3884 # state.disp_list = copy.deepcopy(self.disp_list) 3885 # #state.model = self.model.clone() 3886 3887 # Comboboxes 3888 state.categorycombobox = self.cbCategory.currentText() 3889 state.formfactorcombobox = self.cbModel.currentText() 3890 if self.cbStructureFactor.isEnabled(): 3891 state.structurecombobox = self.cbStructureFactor.currentText() 3892 state.tcChi = self.chi2 3893 3894 state.enable2D = self.is2D 3895 3896 #state.weights = copy.deepcopy(self.weights) 3897 # save data 3898 state.data = copy.deepcopy(self.data) 3899 3900 # save plotting range 3901 state.qmin = self.q_range_min 3902 state.qmax = self.q_range_max 3903 state.npts = self.npts 3904 3905 # self.state.enable_disp = self.enable_disp.GetValue() 3906 # self.state.disable_disp = self.disable_disp.GetValue() 3907 3908 # self.state.enable_smearer = \ 3909 # copy.deepcopy(self.enable_smearer.GetValue()) 3910 # self.state.disable_smearer = \ 3911 # copy.deepcopy(self.disable_smearer.GetValue()) 3912 3913 #self.state.pinhole_smearer = \ 3914 # copy.deepcopy(self.pinhole_smearer.GetValue()) 3915 #self.state.slit_smearer = copy.deepcopy(self.slit_smearer.GetValue()) 3916 #self.state.dI_noweight = copy.deepcopy(self.dI_noweight.GetValue()) 3917 #self.state.dI_didata = copy.deepcopy(self.dI_didata.GetValue()) 3918 #self.state.dI_sqrdata = copy.deepcopy(self.dI_sqrdata.GetValue()) 3919 #self.state.dI_idata = copy.deepcopy(self.dI_idata.GetValue()) 3920 3921 p = self.model_parameters 3922 # save checkbutton state and txtcrtl values 3923 state.parameters = FittingUtilities.getStandardParam(self._model_model) 3924 state.orientation_params_disp = FittingUtilities.getOrientationParam(self.kernel_module) 3925 3926 #self._copy_parameters_state(self.orientation_params_disp, self.state.orientation_params_disp) 3927 #self._copy_parameters_state(self.parameters, self.state.parameters) 3928 #self._copy_parameters_state(self.fittable_param, self.state.fittable_param) 3929 #self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 3930
Note: See TracChangeset
for help on using the changeset viewer.