Salome HOME
Issue #2082 Sketch multiple rotation does not work as expected: debug information
[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 from macros.rectangle.feature import SketchPlugin_Rectangle
7
8
9 class PythonFeaturesPlugin(ModelAPI.ModelAPI_Plugin):
10     """Implementation of features plugin.
11
12     PythonFeaturesPlugin() -> plugin object
13     """
14
15     def __init__(self):
16         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
17         ModelAPI.ModelAPI_Plugin.__init__(self)
18         aSession = ModelAPI.ModelAPI_Session.get()
19         aSession.registerPlugin(self)
20         pass
21
22     def createFeature(self, theFeatureID):
23         """Override ModelAPI_Plugin.createFeature()"""
24         aFeature = None
25
26         if theFeatureID == BoxFeature.ID():
27             aFeature = BoxFeature().__disown__()
28
29         elif theFeatureID == SketchPlugin_Rectangle.ID():
30             aFeature = SketchPlugin_Rectangle().__disown__()
31
32         else:
33             raise StandardError("No such feature %s" % theFeatureID)
34
35         return aFeature
36
37 # The plugin object
38 plugin = PythonFeaturesPlugin()
39 plugin.__disown__()