| 1 |
from Base.Metadata import constmethod |
| 2 |
from Base.Persistence import Persistence |
| 3 |
from Base.Matrix import Matrix |
| 4 |
from typing import Any, Final, List, Optional |
| 5 |
|
| 6 |
class Document(Persistence): |
| 7 |
""" |
| 8 |
This is a Document class |
| 9 |
|
| 10 |
Author: Werner Mayer ([email protected]) |
| 11 |
Licence: LGPL |
| 12 |
""" |
| 13 |
|
| 14 |
def show(self, objName: str) -> None: |
| 15 |
""" |
| 16 |
show(objName) -> None |
| 17 |
|
| 18 |
Show an object. |
| 19 |
|
| 20 |
objName : str |
| 21 |
Name of the `Gui.ViewProvider` to show. |
| 22 |
""" |
| 23 |
... |
| 24 |
|
| 25 |
def hide(self, objName: str) -> None: |
| 26 |
""" |
| 27 |
hide(objName) -> None |
| 28 |
|
| 29 |
Hide an object. |
| 30 |
|
| 31 |
objName : str |
| 32 |
Name of the `Gui.ViewProvider` to hide. |
| 33 |
""" |
| 34 |
... |
| 35 |
|
| 36 |
def setPos(self, objName: str, matrix: Matrix) -> None: |
| 37 |
""" |
| 38 |
setPos(objName, matrix) -> None |
| 39 |
|
| 40 |
Set the position of an object. |
| 41 |
|
| 42 |
objName : str |
| 43 |
Name of the `Gui.ViewProvider`. |
| 44 |
|
| 45 |
matrix : Base.Matrix |
| 46 |
Transformation to apply on the object. |
| 47 |
""" |
| 48 |
... |
| 49 |
|
| 50 |
def setEdit(self, obj: Any, mod: int = 0, subName: Optional[str] = None) -> bool: |
| 51 |
""" |
| 52 |
setEdit(obj, mod=0, subName) -> bool |
| 53 |
|
| 54 |
Set an object in edit mode. |
| 55 |
|
| 56 |
obj : str, App.DocumentObject, Gui.ViewPrivider |
| 57 |
Object to set in edit mode. |
| 58 |
mod : int |
| 59 |
Edit mode. |
| 60 |
subName : str |
| 61 |
Subelement name. Optional. |
| 62 |
""" |
| 63 |
... |
| 64 |
|
| 65 |
def getInEdit(self) -> Optional[Any]: |
| 66 |
""" |
| 67 |
getInEdit() -> Gui.ViewProviderDocumentObject or None |
| 68 |
|
| 69 |
Returns the current object in edit mode or None if there is no such object. |
| 70 |
""" |
| 71 |
... |
| 72 |
|
| 73 |
def resetEdit(self) -> None: |
| 74 |
""" |
| 75 |
resetEdit() -> None |
| 76 |
|
| 77 |
End the current editing. |
| 78 |
""" |
| 79 |
... |
| 80 |
|
| 81 |
def addAnnotation(self, annoName: str, fileName: str, modName: str) -> None: |
| 82 |
""" |
| 83 |
addAnnotation(annoName, fileName, modName) -> None |
| 84 |
|
| 85 |
Add an Inventor object from a file. |
| 86 |
|
| 87 |
annoName : str |
| 88 |
Annotation name. |
| 89 |
fileName : str |
| 90 |
File name. |
| 91 |
modName : str |
| 92 |
Display mode name. Optional. |
| 93 |
""" |
| 94 |
... |
| 95 |
|
| 96 |
def update(self) -> None: |
| 97 |
""" |
| 98 |
update() -> None |
| 99 |
|
| 100 |
Update the view representations of all objects. |
| 101 |
""" |
| 102 |
... |
| 103 |
|
| 104 |
def getObject(self, objName: str) -> Optional[Any]: |
| 105 |
""" |
| 106 |
getObject(objName) -> object or None |
| 107 |
|
| 108 |
Return the object with the given name. If no one exists, return None. |
| 109 |
|
| 110 |
ObjName : str |
| 111 |
Object name. |
| 112 |
""" |
| 113 |
... |
| 114 |
|
| 115 |
def activeObject(self) -> Optional[Any]: |
| 116 |
""" |
| 117 |
activeObject() -> object or None |
| 118 |
|
| 119 |
The active object of the document. Deprecated, use ActiveObject. |
| 120 |
""" |
| 121 |
... |
| 122 |
|
| 123 |
def activeView(self) -> Optional[Any]: |
| 124 |
""" |
| 125 |
activeView() -> object or None |
| 126 |
|
| 127 |
The active view of the document. Deprecated, use ActiveView. |
| 128 |
""" |
| 129 |
... |
| 130 |
|
| 131 |
def createView(self, type: str) -> Optional[Any]: |
| 132 |
""" |
| 133 |
createView(type) -> object or None |
| 134 |
|
| 135 |
Return a newly created view of a given type. |
| 136 |
|
| 137 |
type : str |
| 138 |
Type name. |
| 139 |
""" |
| 140 |
... |
| 141 |
|
| 142 |
@constmethod |
| 143 |
def mdiViewsOfType(self, type: str) -> List[Any]: |
| 144 |
""" |
| 145 |
mdiViewsOfType(type) -> list of MDIView |
| 146 |
|
| 147 |
Return a list of mdi views of a given type. |
| 148 |
|
| 149 |
type : str |
| 150 |
Type name. |
| 151 |
""" |
| 152 |
... |
| 153 |
|
| 154 |
def save(self) -> bool: |
| 155 |
""" |
| 156 |
save() -> bool |
| 157 |
|
| 158 |
Attempts to save the document |
| 159 |
""" |
| 160 |
... |
| 161 |
|
| 162 |
def saveAs(self) -> bool: |
| 163 |
""" |
| 164 |
saveAs() -> bool |
| 165 |
|
| 166 |
Attempts to save the document under a new name |
| 167 |
""" |
| 168 |
... |
| 169 |
|
| 170 |
def sendMsgToViews(self, msg: str) -> None: |
| 171 |
""" |
| 172 |
sendMsgToViews(msg) -> None |
| 173 |
|
| 174 |
Send a message to all views of the document. |
| 175 |
|
| 176 |
msg : str |
| 177 |
""" |
| 178 |
... |
| 179 |
|
| 180 |
def mergeProject(self, fileName: str) -> None: |
| 181 |
""" |
| 182 |
mergeProject(fileName) -> None |
| 183 |
|
| 184 |
Merges this document with another project file. |
| 185 |
|
| 186 |
fileName : str |
| 187 |
File name. |
| 188 |
""" |
| 189 |
... |
| 190 |
|
| 191 |
def toggleTreeItem(self, obj: Any, mod: int = 0, subName: Optional[str] = None) -> None: |
| 192 |
""" |
| 193 |
toggleTreeItem(obj, mod=0, subName) -> None |
| 194 |
|
| 195 |
Change TreeItem of a document object. |
| 196 |
|
| 197 |
obj : App.DocumentObject |
| 198 |
mod : int |
| 199 |
Item mode. |
| 200 |
0: Toggle, 1: Collapse, 2: Expand, 3: Expand path. |
| 201 |
subName : str |
| 202 |
Subelement name. Optional. |
| 203 |
""" |
| 204 |
... |
| 205 |
|
| 206 |
def scrollToTreeItem(self, obj: Any) -> None: |
| 207 |
""" |
| 208 |
scrollToTreeItem(obj) -> None |
| 209 |
|
| 210 |
Scroll the tree view to the item of a view object. |
| 211 |
|
| 212 |
obj : Gui.ViewProviderDocumentObject |
| 213 |
""" |
| 214 |
... |
| 215 |
|
| 216 |
def toggleInSceneGraph(self, obj: Any) -> None: |
| 217 |
""" |
| 218 |
toggleInSceneGraph(obj) -> None |
| 219 |
|
| 220 |
Add or remove view object from scene graph of all views depending |
| 221 |
on its canAddToSceneGraph(). |
| 222 |
|
| 223 |
obj : Gui.ViewProvider |
| 224 |
""" |
| 225 |
... |
| 226 |
ActiveObject: Any = ... |
| 227 |
"""The active object of the document.""" |
| 228 |
|
| 229 |
ActiveView: Any = ... |
| 230 |
"""The active view of the document.""" |
| 231 |
|
| 232 |
EditingTransform: Any = ... |
| 233 |
"""The editing transformation matrix.""" |
| 234 |
|
| 235 |
InEditInfo: Any = ... |
| 236 |
"""A tuple(obj,subname,subElement,editMode) of editing object reference, or None if no object is in edit.""" |
| 237 |
|
| 238 |
EditMode: Final[int] = 0 |
| 239 |
"""Current edit mode. Only meaningful when there is a current object in edit.""" |
| 240 |
|
| 241 |
Document: Final[Any] = ... |
| 242 |
"""The related App document to this Gui document.""" |
| 243 |
|
| 244 |
Transacting: Final[bool] = False |
| 245 |
"""Indicate whether the document is undoing/redoing.""" |
| 246 |
|
| 247 |
Modified: bool = False |
| 248 |
"""Returns True if the document is marked as modified, and False otherwise.""" |
| 249 |
|
| 250 |
TreeRootObjects: Final[List[Any]] = [] |
| 251 |
"""The list of tree root objects.""" |