Salome HOME
Merge branch 'V7_dev'
[modules/geom.git] / src / Tools / t_shape / t_shape_dialog.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2016  EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 # Author : Renaud Nédélec (OpenCascade S.A.S)
21
22 import sys
23 from qtsalome import *
24
25 from t_shape_dialog_ui import Ui_Dialog
26
27
28 class TShapeDialog(QDialog):
29     def __init__(self):
30       QDialog.__init__(self, None, Qt.Tool)
31       # Set up the user interface from Designer.
32       self.ui = Ui_Dialog()
33       self.ui.setupUi(self)
34       self.show()
35       self._wasOk = False
36       self.ui.dsb_solidThickness.setEnabled(False)
37       self.ui.label_5.setEnabled(False)
38       self.ui.dsb_bigRadius.setValue(50.0)
39       self.ui.dsb_smallRadius.setValue(40.0)
40       self.ui.dsb_bigHeight.setValue(80.0)
41       self.ui.dsb_smallHeight.setValue(80.0)
42    
43     def accept(self):
44       self._wasOk = True
45       QDialog.accept(self)
46       
47     def getData(self):
48       r1 = self.ui.dsb_bigRadius.value()
49       r2 = self.ui.dsb_smallRadius.value()
50       h1 = self.ui.dsb_bigHeight.value()
51       h2 = self.ui.dsb_smallHeight.value()
52       thickness = 0.0
53       if self.ui.cb_buildSolid.isChecked():
54         thickness = self.ui.dsb_solidThickness.value()
55       
56       return r1, r2, h1, h2, thickness
57
58     def reject(self):
59         self._wasOk = False
60         QDialog.reject(self)
61
62     def wasOk(self):
63         return self._wasOk
64
65      
66 # ================     
67 # Tests
68 # ================
69
70 def main( args ):
71     import sys
72     app = QApplication(sys.argv)
73     Dialog = TShapeDialog()
74     ui = Ui_Dialog()
75     ui.setupUi(Dialog)
76     Dialog.show()
77     sys.exit(app.exec_())
78
79 if __name__=="__main__":
80     main(sys.argv)