| 1 |
from Base.Metadata import export |
| 2 |
from DocumentObjectExtension import DocumentObjectExtension |
| 3 |
from typing import Any, List |
| 4 |
|
| 5 |
|
| 6 |
@export( |
| 7 |
Include="App/DocumentObjectGroup.h", |
| 8 |
) |
| 9 |
class GroupExtension(DocumentObjectExtension): |
| 10 |
""" |
| 11 |
Extension class which allows grouping of document objects |
| 12 |
Author: Werner Mayer ([email protected]) |
| 13 |
Licence: LGPL |
| 14 |
""" |
| 15 |
|
| 16 |
def newObject(self, type: str, name: str) -> Any: |
| 17 |
""" |
| 18 |
Create and add an object with given type and name to the group |
| 19 |
""" |
| 20 |
... |
| 21 |
|
| 22 |
def addObject(self, obj: Any) -> List[Any]: |
| 23 |
""" |
| 24 |
Add an object to the group. Returns all objects that have been added. |
| 25 |
""" |
| 26 |
... |
| 27 |
|
| 28 |
def addObjects(self, objects: List[Any]) -> List[Any]: |
| 29 |
""" |
| 30 |
Adds multiple objects to the group. Expects a list and returns all objects that have been added. |
| 31 |
""" |
| 32 |
... |
| 33 |
|
| 34 |
def setObjects(self, objects: List[Any]) -> List[Any]: |
| 35 |
""" |
| 36 |
Sets the objects of the group. Expects a list and returns all objects that are now in the group. |
| 37 |
""" |
| 38 |
... |
| 39 |
|
| 40 |
def removeObject(self, obj: Any) -> List[Any]: |
| 41 |
""" |
| 42 |
Remove an object from the group and returns all objects that have been removed. |
| 43 |
""" |
| 44 |
... |
| 45 |
|
| 46 |
def removeObjects(self, objects: List[Any]) -> List[Any]: |
| 47 |
""" |
| 48 |
Remove multiple objects from the group. Expects a list and returns all objects that have been removed. |
| 49 |
""" |
| 50 |
... |
| 51 |
|
| 52 |
def removeObjectsFromDocument(self) -> None: |
| 53 |
""" |
| 54 |
Remove all child objects from the group and document |
| 55 |
""" |
| 56 |
... |
| 57 |
|
| 58 |
def getObject(self, name: str) -> Any: |
| 59 |
""" |
| 60 |
Return the object with the given name |
| 61 |
""" |
| 62 |
... |
| 63 |
|
| 64 |
def getObjectsOfType(self, typename: str) -> List[Any]: |
| 65 |
""" |
| 66 |
Returns all object in the group of given type |
| 67 |
@param typename The Freecad type identifier |
| 68 |
""" |
| 69 |
... |
| 70 |
|
| 71 |
def hasObject(self, obj: Any, recursive: bool = False) -> bool: |
| 72 |
""" |
| 73 |
hasObject(obj, recursive=false) |
| 74 |
|
| 75 |
Checks if the group has a given object |
| 76 |
@param obj the object to check for. |
| 77 |
@param recursive if true check also if the obj is child of some sub group (default is false). |
| 78 |
""" |
| 79 |
... |
| 80 |
|
| 81 |
def allowObject(self, obj: Any) -> bool: |
| 82 |
""" |
| 83 |
Returns true if obj is allowed in the group extension. |
| 84 |
""" |
| 85 |
... |