Salome HOME
84abfa1307ee24783fd158950b8ccee0007d8f11
[modules/geom.git] / src / Tools / t_shape / t_shape_dialog.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2023  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 salome.geom.t_shape.t_shape_dialog_ui import Ui_Dialog
26
27
28 class TShapeDialog(Ui_Dialog,QWidget):
29     def __init__(self):
30       QWidget.__init__(self)
31       # Set up the user interface from Designer.
32       #self = Ui_Dialog()
33       self.setupUi(self)
34       self.show()
35       self._wasOk = False
36       self.dsb_solidThickness.setEnabled(False)
37       self.label_5.setEnabled(False)
38       self.dsb_bigRadius.setValue(50.0)
39       self.dsb_smallRadius.setValue(40.0)
40       self.dsb_bigHeight.setValue(80.0)
41       self.dsb_smallHeight.setValue(80.0)
42       
43     def accept(self):
44       from salome.geom.t_shape import t_shape_progress
45       import xalome
46       self._wasOk = True
47       self.close()
48       r1, r2, h1, h2, thickness = self.getData()
49       #QMessageBox.about(None, "Building in progress", "building shape, please be patient")
50       #shape = t_shape_builder.build_shape(r1, r2, h1, h2, thickness)
51       shapeBuilder = t_shape_progress.t_shape_progress()
52       shape = shapeBuilder.run(r1, r2, h1, h2, thickness)
53       entry = xalome.addToStudy(shape, "T_shape_fluid" )
54       xalome.displayShape(entry)
55
56     def getData(self):
57       r1 = self.dsb_bigRadius.value()
58       r2 = self.dsb_smallRadius.value()
59       h1 = self.dsb_bigHeight.value()
60       h2 = self.dsb_smallHeight.value()
61       thickness = 0.0
62       if self.cb_buildSolid.isChecked():
63         thickness = self.dsb_solidThickness.value()
64       
65       return r1, r2, h1, h2, thickness
66
67     def reject(self):
68       self._wasOk = False
69       self.close()
70
71     def wasOk(self):
72       return self._wasOk
73
74 __dialog=None
75 def getDialog():
76     """
77     This function returns a singleton instance of the plugin dialog.
78     It is mandatory in order to call show without a parent ...
79     """
80     global __dialog
81     if __dialog is None:
82       __dialog = TShapeDialog()
83     return __dialog
84     
85 # ================     
86 # Tests
87 # ================
88
89 def main( args ):
90     import sys
91     app = QApplication(sys.argv)
92     Dialog = TShapeDialog()
93     ui = Ui_Dialog()
94     ui.setupUi(Dialog)
95     Dialog.show()
96     #sys.exit(app.exec_())
97
98 if __name__=="__main__":
99     main(sys.argv)