Ignore:
Timestamp:
Sep 5, 2018 3:31:45 AM (6 years ago)
Author:
Tim Snow <tim.snow@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
f4aa7a8, 5c0e717
Parents:
287d356
Message:

Modifications to SLD panel

First round of modifications to change the button layout and recalculation behaviour for user friendlieness.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Calculators/SldPanel.py

    raed0532 rd738feb  
    134134 
    135135        # signals 
    136         self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Reset).clicked.connect(self.modelReset) 
    137         self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Help).clicked.connect(self.displayHelp) 
     136        self.ui.helpButton.clicked.connect(self.displayHelp) 
     137        self.ui.closeButton.clicked.connect(self.closePanel) 
     138        self.ui.recalculateButton.clicked.connect(self.calculateSLD) 
     139 
     140    def calculateSLD(self): 
     141        self.recalculateSLD() 
    138142 
    139143    def setupModel(self): 
     
    169173                update = True 
    170174 
    171         # calcualtion 
     175        # calculation 
    172176        if update: 
    173             formula = self.model.item(MODEL.MOLECULAR_FORMULA).text() 
    174             density = self.model.item(MODEL.MASS_DENSITY).text() 
    175             wavelength = self.model.item(MODEL.WAVELENGTH).text() 
    176             if len(formula) > 0 and len(density) > 0 and len(wavelength) > 0: 
    177                 try: 
    178                     results = sldAlgorithm(str(formula), float(density), float(wavelength)) 
    179  
    180                     def format(value): 
    181                         return ("%-5.3g" % value).strip() 
    182  
    183                     self.model.item(MODEL.NEUTRON_SLD_REAL).setText(format(results.neutron_sld_real)) 
    184                     self.model.item(MODEL.NEUTRON_SLD_IMAG).setText(format(results.neutron_sld_imag)) 
    185  
    186                     self.model.item(MODEL.CU_KA_SLD_REAL).setText(format(results.cu_ka_sld_real)) 
    187                     self.model.item(MODEL.CU_KA_SLD_IMAG).setText(format(results.cu_ka_sld_imag)) 
    188  
    189                     self.model.item(MODEL.MO_KA_SLD_REAL).setText(format(results.mo_ka_sld_real)) 
    190                     self.model.item(MODEL.MO_KA_SLD_IMAG).setText(format(results.mo_ka_sld_imag)) 
    191  
    192                     self.model.item(MODEL.NEUTRON_INC_XS).setText(format(results.neutron_inc_xs)) 
    193                     self.model.item(MODEL.NEUTRON_ABS_XS).setText(format(results.neutron_abs_xs)) 
    194                     self.model.item(MODEL.NEUTRON_LENGTH).setText(format(results.neutron_length)) 
    195  
    196                     return 
    197              
    198                 except Exception as e: 
    199                     pass 
    200  
    201             for key in list(self._getOutputs().keys()): 
    202                 self.model.item(key).setText("") 
     177            self.recalculateSLD() 
     178 
     179    def recalculateSLD(self): 
     180        formula = self.model.item(MODEL.MOLECULAR_FORMULA).text() 
     181        density = self.model.item(MODEL.MASS_DENSITY).text() 
     182        wavelength = self.model.item(MODEL.WAVELENGTH).text() 
     183        if len(formula) > 0 and len(density) > 0 and len(wavelength) > 0: 
     184            try: 
     185                results = sldAlgorithm(str(formula), float(density), float(wavelength)) 
     186 
     187                def format(value): 
     188                    return ("%-5.3g" % value).strip() 
     189 
     190                self.model.item(MODEL.NEUTRON_SLD_REAL).setText(format(results.neutron_sld_real)) 
     191                self.model.item(MODEL.NEUTRON_SLD_IMAG).setText(format(results.neutron_sld_imag)) 
     192 
     193                self.model.item(MODEL.CU_KA_SLD_REAL).setText(format(results.cu_ka_sld_real)) 
     194                self.model.item(MODEL.CU_KA_SLD_IMAG).setText(format(results.cu_ka_sld_imag)) 
     195 
     196                self.model.item(MODEL.MO_KA_SLD_REAL).setText(format(results.mo_ka_sld_real)) 
     197                self.model.item(MODEL.MO_KA_SLD_IMAG).setText(format(results.mo_ka_sld_imag)) 
     198 
     199                self.model.item(MODEL.NEUTRON_INC_XS).setText(format(results.neutron_inc_xs)) 
     200                self.model.item(MODEL.NEUTRON_ABS_XS).setText(format(results.neutron_abs_xs)) 
     201                self.model.item(MODEL.NEUTRON_LENGTH).setText(format(results.neutron_length)) 
     202 
     203                return 
     204 
     205            except Exception as e: 
     206                pass 
     207 
     208        for key in list(self._getOutputs().keys()): 
     209            self.model.item(key).setText("") 
    203210 
    204211    def modelReset(self): 
     
    217224 
    218225 
     226    def closePanel(self): 
     227        """ 
     228        close the window containing this panel 
     229        """ 
     230        self.close() 
     231 
Note: See TracChangeset for help on using the changeset viewer.