]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
NGO - Update T-Shape
authorNathalie GORE <ng13417n@dsp0657862.postes.calibre.edf.fr>
Thu, 22 Sep 2016 14:29:03 +0000 (16:29 +0200)
committerNathalie GORE <ng13417n@dsp0657862.postes.calibre.edf.fr>
Thu, 22 Sep 2016 14:29:03 +0000 (16:29 +0200)
src/Tools/geom_plugins.py
src/Tools/t_shape/t_shape_dialog.py

index 134644b9f90ecd3c28182725b5b36974efdcaef0..07baf9ce18921b8b22b976f390466e90d22003ba 100644 (file)
 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)
index 649b4739547859db4e1bee4f48cd2641d298132e..1f458e1940b3a76b2db2dc7bcb2246c7a3fa3958 100644 (file)
@@ -25,44 +25,66 @@ from qtsalome import *
 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
 # ================
@@ -74,7 +96,7 @@ def main( args ):
     ui = Ui_Dialog()
     ui.setupUi(Dialog)
     Dialog.show()
-    sys.exit(app.exec_())
+    #sys.exit(app.exec_())
 
 if __name__=="__main__":
     main(sys.argv)