Changeset f1f3e6a in sasview for src/sas/qtgui/Perspectives/Invariant/InvariantDetails.py
- Timestamp:
- Nov 13, 2017 9:34:45 AM (7 years ago)
- 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:
- 7c487846
- Parents:
- 1543f0c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Invariant/InvariantDetails.py
- Property mode changed from 100644 to 100755
r4992ff2 rf1f3e6a 2 2 import os 3 3 from PyQt5 import QtCore 4 from PyQt5 import QtGui 5 from PyQt5 import QtWidgets 4 from PyQt5 import QtGui, QtWidgets 6 5 7 6 # local … … 9 8 from .InvariantUtils import WIDGETS 10 9 10 # ERROR_COLOR = wx.Colour(255, 0, 0, 128) 11 # EXTRAPOLATION_COLOR = wx.Colour(169, 169, 168, 128) 12 # INVARIANT_COLOR = wx.Colour(67, 208, 128, 128) 13 11 14 class DetailsDialog(QtWidgets.QDialog, Ui_Dialog): 12 15 """ 16 This class stores some values resulting from invariant calculations. 17 Given the value of total invariant, this class can also 18 determine the percentage of invariants resulting from extrapolation. 13 19 """ 14 20 def __init__(self, parent): … … 17 23 self.setupUi(self) 18 24 19 self.progressBar.setMinimum(0) 20 self.progressBar.setMaximum(100) 25 DEFAULT_STYLE = """ 26 QProgressBar{ 27 border: 2px solid grey; 28 border-radius: 5px; 29 text-align: center 30 } 21 31 22 self.progressBar_2.setMinimum(0) 23 self.progressBar_2.setMaximum(100) 32 QProgressBar::chunk { 33 background-color: #b1daf9; 34 width: 10px; 35 margin: 1px; 36 } 37 """ 38 self.progressBarLowQ.setStyleSheet(DEFAULT_STYLE) 39 self.progressBarData.setStyleSheet(DEFAULT_STYLE) 40 self.progressBarHighQ.setStyleSheet(DEFAULT_STYLE) 24 41 25 self.progressBar_3.setMinimum(0) 26 self.progressBar_3.setMaximum(100) 42 self.progressBarLowQ.setMinimum(0) 43 self.progressBarLowQ.setMaximum(100) 44 45 self.progressBarData.setMinimum(0) 46 self.progressBarData.setMaximum(100) 47 48 self.progressBarHighQ.setMinimum(0) 49 self.progressBarHighQ.setMaximum(100) 50 51 # Modify font in order to display Angstrom symbol correctly 52 new_font = 'font-family: -apple-system, "Helvetica Neue", "Ubuntu";' 53 self.lblQLowQUnits.setStyleSheet(new_font) 54 self.lblQDataUnits.setStyleSheet(new_font) 55 self.lblQHighQUnits.setStyleSheet(new_font) 56 57 self.cmdOK.clicked.connect(self.accept) 58 59 self.warning_msg = "No Details on calculations available...\n" 60 61 # invariant total 62 self.qstar_total = None 63 self.qhigh = None 64 self.qlow = None 65 self._model = None 66 67 self.progress_low_qstar = 0.0 68 self.progress_high_qstar = 0.0 69 self.progress_qstar = 100.0 27 70 28 71 def setModel(self, model): 29 """ 30 """ 72 """ """ 31 73 self._model = model 32 74 33 75 def showDialog(self): 34 """ 35 """ 76 """ Fill the dialog with values of calculated Q, progress bars""" 36 77 # Pull out data from the model 37 qstar_total = float(self._model.item(WIDGETS.W_INVARIANT).text()) 38 self.lineEdit_3.setText(str(qstar_total)) 39 self.lineEdit_4.setText(self._model.item(WIDGETS.W_INVARIANT_ERR).text()) 78 self.qstar_total = float(self._model.item(WIDGETS.W_INVARIANT).text()) 40 79 41 progress_low_qstar = 0.0 42 progress_high_qstar = 0.0 43 progress_qstar = 100.0 80 self.txtQData.setText(str(self.qstar_total)) 81 self.txtQDataErr.setText(self._model.item(WIDGETS.W_INVARIANT_ERR).text()) 44 82 83 # Low-Q 45 84 if self._model.item(WIDGETS.W_ENABLE_LOWQ).text() == "true": 46 qlow = float(self._model.item(WIDGETS.D_LOW_QSTAR).text()) 47 self.lineEdit.setText(str(qlow)) 48 self.lineEdit_2.setText(self._model.item(WIDGETS.D_LOW_QSTAR_ERR).text()) 49 progress_low_qstar = (qlow/qstar_total)*100.0 85 self.qlow = float(self._model.item(WIDGETS.D_LOW_QSTAR).text()) 50 86 87 self.txtQLowQ.setText(str(self.qlow)) 88 self.txtQLowQErr.setText(self._model.item(WIDGETS.D_LOW_QSTAR_ERR).text()) 89 try: 90 self.progress_low_qstar = (self.qlow/self.qstar_total)*100.0 91 except: 92 self.progress_low_qstar = 'error' 93 94 # High-Q 51 95 if self._model.item(WIDGETS.W_ENABLE_HIGHQ).text() == "true": 52 qhigh = float(self._model.item(WIDGETS.D_LOW_QSTAR).text()) 53 self.lineEdit.setText(str(qhigh)) 54 self.lineEdit_2.setText(self._model.item(WIDGETS.D_HIGH_QSTAR_ERR).text()) 55 progress_high_qstar = (qhigh/qstar_total)*100.0 96 self.qhigh = float(self._model.item(WIDGETS.D_HIGH_QSTAR).text()) 56 97 98 self.txtQHighQ.setText(str(self.qhigh)) 99 self.txtQHighQErr.setText(self._model.item(WIDGETS.D_HIGH_QSTAR_ERR).text()) 100 try: 101 self.progress_high_qstar = (self.qhigh/self.qstar_total)*100.0 102 except: 103 self.progress_high_qstar = 'error' 57 104 58 progress_qstar -= progress_low_qstar + progress_high_qstar 105 try: 106 self.progress_qstar -= self.progress_low_qstar + self.progress_high_qstar 107 except: 108 self.progress_qstar = 'error' 59 109 60 self.progressBar.setValue(progress_low_qstar)61 self.progressBar_2.setValue(progress_qstar)62 self.progressBar_3.setValue(progress_high_qstar)110 # check values and display warning 111 if self.checkValues(): 112 self.lblWarning.setText(self.checkValues()) 63 113 64 new_font = 'font-family: -apple-system, "Helvetica Neue", "Ubuntu";' 65 self.label_3.setStyleSheet(new_font) 66 self.label_4.setStyleSheet(new_font) 67 self.label_7.setStyleSheet(new_font) 114 # update progress bars 115 if self.progress_low_qstar == 'error': 116 self.progressBarLowQ.setValue(0) 117 else: 118 self.progressBarLowQ.setValue(self.progress_low_qstar) 119 120 if self.progress_high_qstar == 'error': 121 self.progressBarHighQ.setValue(0) 122 else: 123 self.progressBarHighQ.setValue(self.progress_high_qstar) 124 125 if self.progress_qstar == 'error': 126 self.progressBarData.setValue(0) 127 else: 128 self.progressBarData.setValue(self.progress_qstar) 68 129 69 130 self.show() 131 132 def checkValues(self): 133 """ 134 Create a warning message to be displayed in panel 135 if problems with values 136 """ 137 138 if self.qstar_total is None: 139 warning_msg = "Invariant not calculated.\n" 140 return warning_msg 141 elif self.qstar_total == 0: 142 warning_msg = "Invariant is zero. \n " \ 143 "The calculations are likely to be unreliable!\n" 144 return warning_msg 145 146 msg = '' 147 if self.progress_qstar == 'error': 148 msg += 'Error occurred when computing invariant from data.\n ' 149 if self.progress_qstar > 100: 150 msg += "Invariant Q contribution is greater than 100% .\n" 151 152 if self.progress_low_qstar == 'error': 153 try: 154 float(self.qlow) 155 except: 156 msg += "Error occurred when computing extrapolated invariant" 157 msg += " at low-Q region.\n" 158 159 elif self.progress_low_qstar is not None: 160 if self.progress_low_qstar >= 5: 161 msg += "Extrapolated contribution at Low Q is higher " 162 msg += "than 5% of the invariant.\n" 163 elif self.progress_low_qstar < 0: 164 msg += "Extrapolated contribution at Low Q < 0.\n" 165 elif self.progress_low_qstar > 100: 166 msg += "Extrapolated contribution at Low Q is greater " 167 msg += "than 100% .\n" 168 169 # High-Q 170 if self.progress_high_qstar == 'error': 171 try: 172 float(self.qhigh) 173 except: 174 msg += 'Error occurred when computing extrapolated' 175 msg += ' invariant at high-Q region.\n' 176 177 elif self.progress_high_qstar is not None: 178 if self.progress_high_qstar >= 5: 179 msg += "Extrapolated contribution at High Q is higher " \ 180 "than 5% of the invariant.\n" 181 elif self.progress_high_qstar < 0: 182 183 msg += "Extrapolated contribution at High Q < 0.\n" 184 elif self.progress_high_qstar > 100: 185 186 msg += "Extrapolated contribution at High Q is greater " \ 187 "than 100% .\n" 188 189 if (self.progress_low_qstar not in [None, "error"]) and \ 190 (self.progress_high_qstar not in [None, "error"])\ 191 and self.progress_low_qstar + self.progress_high_qstar >= 5: 192 193 msg += "The sum of all extrapolated contributions is higher " \ 194 "than 5% of the invariant.\n" 195 196 return msg
Note: See TracChangeset
for help on using the changeset viewer.