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