| 1 |
from Base.Metadata import export, constmethod |
| 2 |
from Base.BaseClass import BaseClass |
| 3 |
from typing import Any, Final, List, Dict, Tuple, overload |
| 4 |
|
| 5 |
@export( |
| 6 |
Include="Gui/ViewProviderLink.h", |
| 7 |
Constructor=True, |
| 8 |
Delete=True, |
| 9 |
) |
| 10 |
class LinkView(BaseClass): |
| 11 |
""" |
| 12 |
Helper class to link to a view object |
| 13 |
|
| 14 |
Author: Zheng, Lei ([email protected]) |
| 15 |
Licence: LGPL |
| 16 |
""" |
| 17 |
|
| 18 |
def reset(self) -> None: |
| 19 |
""" |
| 20 |
Reset the link view and clear the links |
| 21 |
""" |
| 22 |
... |
| 23 |
|
| 24 |
def setMaterial(self, material: Any) -> None: |
| 25 |
""" |
| 26 |
setMaterial(Material): set the override material of the entire linked object |
| 27 |
|
| 28 |
setMaterial([Material,...]): set the materials for the elements of the link |
| 29 |
array/group. |
| 30 |
|
| 31 |
setMaterial({Int:Material,...}): set the material for the elements of the |
| 32 |
link array/group by index. |
| 33 |
|
| 34 |
If material is None, then the material is unset. If the material of an element |
| 35 |
is unset, it defaults to the override material of the linked object, if there |
| 36 |
is one |
| 37 |
""" |
| 38 |
... |
| 39 |
|
| 40 |
@overload |
| 41 |
def setMaterial(self, material: None) -> None: ... |
| 42 |
@overload |
| 43 |
def setMaterial(self, material: Any) -> None: ... |
| 44 |
@overload |
| 45 |
def setMaterial(self, material: List[Any]) -> None: ... |
| 46 |
@overload |
| 47 |
def setMaterial(self, material: Dict[int, Any]) -> None: ... |
| 48 |
def setType(self, type: int, sublink: bool = True) -> None: |
| 49 |
""" |
| 50 |
setType(type, sublink=True): set the link type. |
| 51 |
|
| 52 |
type=0: override transformation and visibility |
| 53 |
type=1: override visibility |
| 54 |
type=2: no override |
| 55 |
type=-1: sub-object link with override visibility |
| 56 |
type=-2: sub-object link with override transformation and visibility |
| 57 |
|
| 58 |
sublink: auto delegate to the sub-object references in the link, if there is |
| 59 |
one and only one. |
| 60 |
""" |
| 61 |
... |
| 62 |
|
| 63 |
@overload |
| 64 |
def setType(self, type: int) -> None: ... |
| 65 |
@overload |
| 66 |
def setType(self, type: int, sublink: bool) -> None: ... |
| 67 |
def setTransform(self, matrix: Any) -> None: |
| 68 |
""" |
| 69 |
setTransform(matrix): set transformation of the linked object |
| 70 |
|
| 71 |
setTransform([matrix,...]): set transformation for the elements of the link |
| 72 |
array/group |
| 73 |
|
| 74 |
setTransform({index:matrix,...}): set transformation for elements of the link |
| 75 |
array/group by index |
| 76 |
""" |
| 77 |
... |
| 78 |
|
| 79 |
@overload |
| 80 |
def setTransform(self, matrix: Any) -> None: ... |
| 81 |
@overload |
| 82 |
def setTransform(self, matrix: List[Any]) -> None: ... |
| 83 |
@overload |
| 84 |
def setTransform(self, matrix: Dict[int, Any]) -> None: ... |
| 85 |
def setChildren(self, children: List[Any], vis: List[Any] = [], type: int = 0) -> None: |
| 86 |
""" |
| 87 |
setChildren([obj...],vis=[],type=0) |
| 88 |
Group a list of children objects. Note, this mode of operation is incompatible |
| 89 |
with link array. Calling this function will deactivate link array. And calling |
| 90 |
setSize() will reset all linked children. |
| 91 |
|
| 92 |
vis: initial visibility status of the children |
| 93 |
|
| 94 |
type: children linking type, |
| 95 |
0: override transformation and visibility, |
| 96 |
1: override visibility, |
| 97 |
2: override none. |
| 98 |
""" |
| 99 |
... |
| 100 |
|
| 101 |
def setLink(self, obj: Any, subname: Any = None) -> None: |
| 102 |
""" |
| 103 |
setLink(object): Set the link |
| 104 |
|
| 105 |
setLink(object, subname): Set the link with a sub-object reference |
| 106 |
|
| 107 |
setLink(object, [subname,...]): Set the link with a list of sub object references |
| 108 |
|
| 109 |
object: The linked document object or its view object |
| 110 |
|
| 111 |
subname: a string or tuple/list of strings sub-name references to sub object |
| 112 |
or sub elements (e.g. Face1, Edge2) belonging to the linked object. |
| 113 |
The sub-name must end with a '.' if it is referencing an sub-object, |
| 114 |
or else it is considered a sub-element reference. |
| 115 |
""" |
| 116 |
... |
| 117 |
|
| 118 |
@overload |
| 119 |
def setLink(self, obj: Any) -> None: ... |
| 120 |
@overload |
| 121 |
def setLink(self, obj: Any, subname: str) -> None: ... |
| 122 |
@overload |
| 123 |
def setLink(self, obj: Any, subname: List[str]) -> None: ... |
| 124 |
def getDetailPath(self, element: Any) -> Tuple[Any, Any]: |
| 125 |
""" |
| 126 |
getDetailPath(element): get the 3d path an detail of an element. |
| 127 |
|
| 128 |
Return a tuple(path,detail) for the coin3D SoPath and SoDetail of the element |
| 129 |
""" |
| 130 |
... |
| 131 |
|
| 132 |
def getElementPicked(self, pickPoint: Any) -> Any: |
| 133 |
""" |
| 134 |
getElementPicked(pickPoint): get the element under a 3d pick point. |
| 135 |
""" |
| 136 |
... |
| 137 |
|
| 138 |
def getBoundBox(self, vobj: Any = None) -> Any: |
| 139 |
""" |
| 140 |
getBoundBox(vobj=None): get the bounding box. |
| 141 |
""" |
| 142 |
... |
| 143 |
|
| 144 |
@constmethod |
| 145 |
def getChildren(self) -> Any: |
| 146 |
""" |
| 147 |
Get children view objects |
| 148 |
""" |
| 149 |
... |
| 150 |
LinkedView: Final[Any] = ... |
| 151 |
"""The linked view object""" |
| 152 |
|
| 153 |
SubNames: Final[Any] = ... |
| 154 |
"""The sub-object reference of the link""" |
| 155 |
|
| 156 |
RootNode: Final[Any] = ... |
| 157 |
"""A pivy node holding the cloned representation of the linked view object""" |
| 158 |
|
| 159 |
Owner: Any = ... |
| 160 |
"""The owner view object of this link handle""" |
| 161 |
|
| 162 |
Visibilities: Any = ... |
| 163 |
"""Get/set the child element visibility""" |
| 164 |
|
| 165 |
Count: int = 0 |
| 166 |
"""Set the element size to create an array of linked object""" |