Salome HOME
Merge branch 'jfa/29468'
[modules/shaper.git] / src / PythonAPI / model / roots.py
index 62288ebb3dfb67a121adfa932a3489e8907ec685..d503eac997e8518ba4d028edb077fe8b9bcc42c4 100644 (file)
@@ -1,41 +1,52 @@
+# Copyright (C) 2014-2022  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
 """Abstract root classes of user-defined Python features producing a Body
 Author: Daniel Brunier-Coulin
-Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 """
 
-from ModelAPI import *
-
-
-class Feature(ModelAPI_Feature):
-  """Base class of user-defined Python features."""
-
-  def __init__(self):
-    ModelAPI_Feature.__init__(self)
-
-  def addRealInput (self, inputid):
-    self.data().addAttribute(inputid, ModelAPI_AttributeDouble_typeId())
-
-  def getRealInput (self, inputid):
-    return self.data().real(inputid).value()
+import ModelAPI
 
-  def addResult (self, result):
-    shape = result.shape()
-    body  = self.document().createBody( self.data() )
-    body.store(shape)
-    self.setResult(body)
+class Feature(ModelAPI.ModelAPI_Feature):
+    """Base class of user-defined Python features."""
 
+    def __init__(self):
+        """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
+        ModelAPI.ModelAPI_Feature.__init__(self)
 
-class Interface():
-  """Base class of hight level Python interfaces to features."""
+    def addRealInput(self, inputid):
+        """F.addRealInput(str) -- add real attribute"""
+        self.data().addAttribute(inputid,
+                                 ModelAPI.ModelAPI_AttributeDouble_typeId())
 
-  def __init__(self, container, fid):
-    self.my = container.addFeature(fid)
+    def getRealInput(self, inputid):
+        """F.getRealInput(str) -- get real value of the attribute"""
+        return self.data().real(inputid).value()
 
-  def setRealInput (self, inputid, value):
-    self.my.data().real(inputid).setValue(value)
+    def getTextInput(self, inputid):
+        """F.getTextInput(str) -- get text value of the attribute"""
+        return self.data().real(inputid).text()
 
-  def areInputValid (self):
-    return ModelAPI_Session.get().validators().validate(self.my)
+    def addResult(self, result):
+        """F.addResult(ModelAPI_Result) -- add ModelAPI_Result shape as a result"""
+        shape = result.shape()
+        body = self.document().createBody(self.data())
+        body.store(shape)
+        self.setResult(body)
 
-  def execute (self):
-    self.my.execute()
\ No newline at end of file