import salome_pluginsmanager
def t_shape_fluid(context):
- #from salome.geom.t_shape import t_shape_builder
- from salome.geom.t_shape import t_shape_dialog
- from salome.geom.t_shape import t_shape_progress
- import xalome
- from qtsalome import QMessageBox
activeStudy = context.study
-
- dialog = t_shape_dialog.TShapeDialog()
-
- # Get the parameter values from a gui dialog box. If the dialog is
- # closed using the Ok button, then the data are requested from the
- # gui and used to create the shape of the tube.
- dialog.exec_()
- if dialog.wasOk():
- r1, r2, h1, h2, thickness = dialog.getData()
- #QMessageBox.about(None, "Building in progress", "building shape, please be patient")
- #shape = t_shape_builder.build_shape(activeStudy, r1, r2, h1, h2, thickness)
- shapeBuilder = t_shape_progress.t_shape_progress()
- shape = shapeBuilder.run(activeStudy, r1, r2, h1, h2, thickness)
- entry = xalome.addToStudy(activeStudy, shape, "T_shape_fluid" )
- xalome.displayShape(entry)
- #if dialog.wasOk():
- #radius, length, width = dialog.getData()
- #shape = tubebuilder.createGeometry(activeStudy, radius, length, width)
- #entry = xalome.addToStudy(activeStudy, shape, "Tube" )
- #xalome.displayShape(entry)
+ #from salome.geom.t_shape import t_shape_builder
+ from salome.geom.t_shape import t_shape_dialog
+ dialog = t_shape_dialog.getDialog()
+ dialog.setContext(context)
+ dialog.show()
salome_pluginsmanager.AddFunction('T shape fluid',
'Creates the fluid part of a pipe T-shape',
- t_shape_fluid)
\ No newline at end of file
+ t_shape_fluid)
from t_shape_dialog_ui import Ui_Dialog
-class TShapeDialog(QDialog):
+class TShapeDialog(Ui_Dialog,QWidget):
def __init__(self):
- QDialog.__init__(self, None, Qt.Tool)
+ QWidget.__init__(self)
# Set up the user interface from Designer.
- self.ui = Ui_Dialog()
- self.ui.setupUi(self)
+ #self = Ui_Dialog()
+ self.setupUi(self)
self.show()
self._wasOk = False
- self.ui.dsb_solidThickness.setEnabled(False)
- self.ui.label_5.setEnabled(False)
- self.ui.dsb_bigRadius.setValue(50.0)
- self.ui.dsb_smallRadius.setValue(40.0)
- self.ui.dsb_bigHeight.setValue(80.0)
- self.ui.dsb_smallHeight.setValue(80.0)
+ self.dsb_solidThickness.setEnabled(False)
+ self.label_5.setEnabled(False)
+ self.dsb_bigRadius.setValue(50.0)
+ self.dsb_smallRadius.setValue(40.0)
+ self.dsb_bigHeight.setValue(80.0)
+ self.dsb_smallHeight.setValue(80.0)
+ def setContext(self, context):
+ self._activeStudy = context.study
+
def accept(self):
+ from salome.geom.t_shape import t_shape_progress
+ import xalome
self._wasOk = True
- QDialog.accept(self)
-
+ self.close()
+ r1, r2, h1, h2, thickness = self.getData()
+ #QMessageBox.about(None, "Building in progress", "building shape, please be patient")
+ #shape = t_shape_builder.build_shape(activeStudy, r1, r2, h1, h2, thickness)
+ shapeBuilder = t_shape_progress.t_shape_progress()
+ shape = shapeBuilder.run(self._activeStudy, r1, r2, h1, h2, thickness)
+ entry = xalome.addToStudy(self._activeStudy, shape, "T_shape_fluid" )
+ xalome.displayShape(entry)
+
def getData(self):
- r1 = self.ui.dsb_bigRadius.value()
- r2 = self.ui.dsb_smallRadius.value()
- h1 = self.ui.dsb_bigHeight.value()
- h2 = self.ui.dsb_smallHeight.value()
+ r1 = self.dsb_bigRadius.value()
+ r2 = self.dsb_smallRadius.value()
+ h1 = self.dsb_bigHeight.value()
+ h2 = self.dsb_smallHeight.value()
thickness = 0.0
- if self.ui.cb_buildSolid.isChecked():
- thickness = self.ui.dsb_solidThickness.value()
+ if self.cb_buildSolid.isChecked():
+ thickness = self.dsb_solidThickness.value()
return r1, r2, h1, h2, thickness
def reject(self):
- self._wasOk = False
- QDialog.reject(self)
+ self._wasOk = False
+ self.close()
def wasOk(self):
- return self._wasOk
+ return self._wasOk
-
+__dialog=None
+def getDialog():
+ """
+ This function returns a singleton instance of the plugin dialog.
+ It is mandatory in order to call show without a parent ...
+ """
+ global __dialog
+ if __dialog is None:
+ __dialog = TShapeDialog()
+ return __dialog
+
# ================
# Tests
# ================
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
- sys.exit(app.exec_())
+ #sys.exit(app.exec_())
if __name__=="__main__":
main(sys.argv)