Changeset 51b9c14 in sasview


Ignore:
Timestamp:
Sep 27, 2018 7:25:52 AM (6 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:
b6f47be
Parents:
2f55df6
Message:

Made the SLD calculator listen and respond to textEdited signal on
QLineEdit, in addition to model change with dataChanged.
SASVIEW-1139

File:
1 edited

Legend:

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

    rd813cf9a r51b9c14  
    8181        self.model.dataChanged.connect(self.dataChanged) 
    8282 
     83        self.ui.editMolarVolume.textEdited.connect(self.volumeChanged) 
     84        self.ui.editMassDensity.textEdited.connect(self.massChanged) 
     85        self.ui.editMolecularFormula.textEdited.connect(self.formulaChanged) 
     86 
    8387        self.modelReset() 
    8488 
     
    112116            elif index == MODEL.MASS_DENSITY and self.mode == MODES.DENSITY_TO_VOLUME: 
    113117                self._updateVolume() 
     118 
     119    def volumeChanged(self, current_text): 
     120        try: 
     121            molarMass = float(toMolarMass(self.model.item(MODEL.MOLECULAR_FORMULA).text())) 
     122            molarVolume = float(current_text) 
     123 
     124            molarDensity = molarMass / molarVolume 
     125            molarDensity = formatNumber(molarDensity, high=True) 
     126            self.model.item(MODEL.MASS_DENSITY).setText(str(molarDensity)) 
     127 
     128        except (ArithmeticError, ValueError): 
     129            self.model.item(MODEL.MASS_DENSITY).setText("") 
     130 
     131    def massChanged(self, current_text): 
     132        try: 
     133            molarMass = float(toMolarMass(self.model.item(MODEL.MOLECULAR_FORMULA).text())) 
     134            molarDensity = float(current_text) 
     135 
     136            molarVolume = molarMass / molarDensity 
     137            molarVolume = formatNumber(molarVolume, high=True) 
     138            self.model.item(MODEL.MOLAR_VOLUME).setText(str(molarVolume)) 
     139 
     140        except (ArithmeticError, ValueError): 
     141            self.model.item(MODEL.MOLAR_VOLUME).setText("") 
     142 
     143    def formulaChanged(self, current_text): 
     144        try: 
     145            molarMass = toMolarMass(current_text) 
     146            molarMass = formatNumber(molarMass, high=True) 
     147            self.model.item(MODEL.MOLAR_MASS).setText(molarMass) 
     148 
     149        except (ArithmeticError, ValueError): 
     150            self.model.item(MODEL.MOLAR_VOLUME).setText("") 
    114151 
    115152    def setMode(self, mode): 
Note: See TracChangeset for help on using the changeset viewer.