Salome HOME
Merge with Dev_1.5.0
[modules/shaper.git] / src / PythonAddons / addons_Features.py
1 """Registration of all user-defined Python features
2 """
3
4 import ModelAPI
5 from macros.box.feature      import BoxFeature
6
7
8 class PythonFeaturesPlugin(ModelAPI.ModelAPI_Plugin):
9     """Implementation of features plugin.
10
11     PythonFeaturesPlugin() -> plugin object
12     """
13
14     def __init__(self):
15         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
16         ModelAPI.ModelAPI_Plugin.__init__(self)
17         aSession = ModelAPI.ModelAPI_Session.get()
18         aSession.registerPlugin(self)
19         pass
20
21     def createFeature(self, theFeatureID):
22         """Override ModelAPI_Plugin.createFeature()"""
23         aFeature = None
24
25         if theFeatureID == BoxFeature.ID():
26             aFeature = BoxFeature().__disown__()
27
28         else:
29             raise StandardError("No such feature %s" % theFeatureID)
30
31         return aFeature
32
33 # The plugin object
34 plugin = PythonFeaturesPlugin()
35 plugin.__disown__()