[363fbfa] | 1 | from PyQt4 import QtGui |
---|
| 2 | from PyQt4 import QtCore |
---|
| 3 | from UI.KiessigPanel import Ui_KiessigPanel |
---|
| 4 | |
---|
| 5 | # sas-global |
---|
| 6 | from sas.sascalc.calculator.kiessig_calculator import KiessigThicknessCalculator |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | class KiessigPanel(QtGui.QDialog, Ui_KiessigPanel): |
---|
| 10 | def __init__(self, parent=None): |
---|
| 11 | super(KiessigPanel, self).__init__() |
---|
| 12 | self.setupUi(self) |
---|
| 13 | |
---|
| 14 | self.setWindowTitle("Kiessig Thickness Calculator") |
---|
| 15 | |
---|
| 16 | self.manager = parent |
---|
| 17 | self.thickness = KiessigThicknessCalculator() |
---|
| 18 | |
---|
[040529d] | 19 | self.deltaq_in.setText("0.05") |
---|
| 20 | |
---|
[363fbfa] | 21 | # signals |
---|
[040529d] | 22 | self.helpButton.clicked.connect(self.onHelp) |
---|
| 23 | self.computeButton.clicked.connect(self.onCompute) |
---|
| 24 | self.closeButton.clicked.connect(self.onClose) |
---|
[363fbfa] | 25 | |
---|
| 26 | # no reason to have this widget resizable |
---|
| 27 | self.setFixedSize(self.minimumSizeHint()) |
---|
| 28 | |
---|
[040529d] | 29 | def onHelp(self): |
---|
[363fbfa] | 30 | """ |
---|
| 31 | Bring up the Kiessig fringe calculator Documentation whenever |
---|
| 32 | the HELP button is clicked. |
---|
| 33 | Calls DocumentationWindow with the path of the location within the |
---|
| 34 | documentation tree (after /doc/ ....". |
---|
| 35 | """ |
---|
| 36 | try: |
---|
| 37 | location = self.manager.HELP_DIRECTORY_LOCATION + \ |
---|
| 38 | "/user/sasgui/perspectives/calculator/kiessig_calculator_help.html" |
---|
| 39 | |
---|
| 40 | self.manager._helpView.load(QtCore.QUrl(location)) |
---|
| 41 | self.manager._helpView.show() |
---|
| 42 | except AttributeError: |
---|
| 43 | # No manager defined - testing and standalone runs |
---|
| 44 | pass |
---|
| 45 | |
---|
[040529d] | 46 | def onCompute(self): |
---|
[363fbfa] | 47 | """ |
---|
| 48 | Execute the computation of thickness |
---|
| 49 | """ |
---|
| 50 | try: |
---|
| 51 | self.thickness.set_deltaq(dq=float(self.deltaq_in.text())) |
---|
| 52 | kiessing_result = self.thickness.compute_thickness() |
---|
[040529d] | 53 | float_as_str = "{:.3f}".format(kiessing_result) |
---|
[363fbfa] | 54 | self.lengthscale_out.setText(float_as_str) |
---|
| 55 | except (ArithmeticError, ValueError): |
---|
| 56 | self.lengthscale_out.setText("") |
---|
| 57 | |
---|
[040529d] | 58 | def onClose(self): |
---|
[363fbfa] | 59 | """ |
---|
| 60 | close the window containing this panel |
---|
| 61 | """ |
---|
| 62 | self.close() |
---|