Salome HOME
Adjust test cases according to updated Arc behavior
[modules/shaper.git] / src / PythonAPI / model / roots.py
1 """Abstract root classes of user-defined Python features producing a Body
2 Author: Daniel Brunier-Coulin
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 """
5
6 import ModelAPI
7
8 class Feature(ModelAPI.ModelAPI_Feature):
9     """Base class of user-defined Python features."""
10
11     def __init__(self):
12         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
13         ModelAPI.ModelAPI_Feature.__init__(self)
14
15     def addRealInput(self, inputid):
16         """F.addRealInput(str) -- add real attribute"""
17         self.data().addAttribute(inputid,
18                                  ModelAPI.ModelAPI_AttributeDouble_typeId())
19
20     def getRealInput(self, inputid):
21         """F.getRealInput(str) -- get real value of the attribute"""
22         return self.data().real(inputid).value()
23
24     def getTextInput(self, inputid):
25         """F.getTextInput(str) -- get text value of the attribute"""
26         return self.data().real(inputid).text()
27
28     def addResult(self, result):
29         """F.addResult(ModelAPI_Result) -- add ModelAPI_Result shape as a result"""
30         shape = result.shape()
31         body = self.document().createBody(self.data())
32         body.store(shape)
33         self.setResult(body)
34