diff --git a/src/App/CMakeLists.txt b/src/App/CMakeLists.txt index b219faf7b6..e714e35e18 100644 --- a/src/App/CMakeLists.txt +++ b/src/App/CMakeLists.txt @@ -81,26 +81,46 @@ list(APPEND FreeCADApp_LIBS ) generate_from_xml(DocumentPy) +generate_from_py(Document) generate_from_xml(DocumentObjectPy) +generate_from_py(DocumentObject) generate_from_xml(ExtensionPy) +generate_from_py(Extension) generate_from_xml(ExtensionContainerPy) +generate_from_py(ExtensionContainer) generate_from_xml(DocumentObjectExtensionPy) +generate_from_py(DocumentObjectExtension) generate_from_xml(GroupExtensionPy) +generate_from_py(GroupExtension) generate_from_xml(LinkBaseExtensionPy) +generate_from_py(LinkBaseExtension) generate_from_xml(DocumentObjectGroupPy) +generate_from_py(DocumentObjectGroup) generate_from_xml(GeoFeaturePy) +generate_from_py(GeoFeature) generate_from_xml(GeoFeatureGroupExtensionPy) +generate_from_py(GeoFeatureGroupExtension) generate_from_xml(SuppressibleExtensionPy) +generate_from_py(SuppressibleExtension) generate_from_xml(MetadataPy) +generate_from_py(Metadata) generate_from_xml(OriginGroupExtensionPy) +generate_from_py(OriginGroupExtension) generate_from_xml(PartPy) +generate_from_py(Part) generate_from_xml(StringHasherPy) +generate_from_py(StringHasher) generate_from_xml(StringIDPy) +generate_from_py(StringID) generate_from_xml(ComplexGeoDataPy) +generate_from_py(ComplexGeoData) generate_from_xml(PropertyContainerPy) +generate_from_py(PropertyContainer) generate_from_xml(MaterialPy) +generate_from_py(Material) generate_from_xml(MeasureManagerPy) +generate_from_py(MeasureManager) generate_embed_from_py(FreeCADInit InitScript.h) generate_embed_from_py(FreeCADTest TestScript.h) diff --git a/src/App/ComplexGeoData.pyi b/src/App/ComplexGeoData.pyi new file mode 100644 index 0000000000..095eddc5ff --- /dev/null +++ b/src/App/ComplexGeoData.pyi @@ -0,0 +1,153 @@ +from Base.Metadata import export, constmethod +from Base.Persistence import Persistence +from Base.BoundBox import BoundBox as BoundBoxPy +from Base.Vector import Vector +from Base.Placement import Placement as PlacementPy +from Base.Rotation import Rotation +from Base.Matrix import Matrix +from StringHasher import StringHasher +from typing import Any, Final, List, Dict + + +@export( + Namespace="Data", + Reference=True, +) +class ComplexGeoData(Persistence): + """ + Data.ComplexGeoData class. + + Author: Juergen Riegel (Juergen.Riegel@web.de) + Licence: LGPL + UserDocu: Father of all complex geometric data types + """ + + @constmethod + def getElementTypes(self) -> List[str]: + """ + Return a list of element types present in the complex geometric data + """ + ... + + @constmethod + def countSubElements(self) -> int: + """ + Return the number of elements of a type + """ + ... + + @constmethod + def getFacesFromSubElement(self) -> Any: + """ + Return vertexes and faces from a sub-element + """ + ... + + @constmethod + def getLinesFromSubElement(self) -> Any: + """ + Return vertexes and lines from a sub-element + """ + ... + + @constmethod + def getPoints(self) -> Any: + """ + Return a tuple of points and normals with a given accuracy + """ + ... + + @constmethod + def getLines(self) -> Any: + """ + Return a tuple of points and lines with a given accuracy + """ + ... + + @constmethod + def getFaces(self) -> Any: + """ + Return a tuple of points and triangles with a given accuracy + """ + ... + + def applyTranslation(self, translation: Vector) -> None: + """ + Apply an additional translation to the placement + """ + ... + + def applyRotation(self, rotation: Rotation) -> None: + """ + Apply an additional rotation to the placement + """ + ... + + def transformGeometry(self, transformation: Matrix) -> None: + """ + Apply a transformation to the underlying geometry + """ + ... + + def setElementName(self, *, element: str, name: str = None, postfix: str = None, overwrite: bool = False, sid: Any = None) -> None: + """ + setElementName(element,name=None,postfix=None,overwrite=False,sid=None), Set an element name + + element : the original element name, e.g. Edge1, Vertex2 + name : the new name for the element, None to remove the mapping + postfix : postfix of the name that will not be hashed + overwrite: if true, it will overwrite exiting name + sid : to hash the name any way you want, provide your own string id(s) in this parameter + + An element can have multiple mapped names. However, a name can only be mapped + to one element + """ + ... + + @constmethod + def getElementName(self, name: str, direction: int = 0) -> Any: + """ + getElementName(name,direction=0) - Return a mapped element name or reverse + """ + ... + + @constmethod + def getElementIndexedName(self, name: str) -> Any: + """ + getElementIndexedName(name) - Return the indexed element name + """ + ... + + @constmethod + def getElementMappedName(self, name: str) -> Any: + """ + getElementMappedName(name) - Return the mapped element name + """ + ... + + BoundBox: Final[BoundBoxPy] = ... + """Get the bounding box (BoundBox) of the complex geometric data.""" + + CenterOfGravity: Final[Vector] = ... + """Get the center of gravity""" + + Placement: PlacementPy = ... + """Get the current transformation of the object as placement""" + + Tag: int = 0 + """Geometry Tag""" + + Hasher: StringHasher = ... + """Get/Set the string hasher of this object""" + + ElementMapSize: Final[int] = 0 + """Get the current element map size""" + + ElementMap: Dict[Any, Any] = {} + """Get/Set a dict of element mapping""" + + ElementReverseMap: Final[Dict[Any, Any]] = {} + """Get a dict of element reverse mapping""" + + ElementMapVersion: Final[str] = "" + """Element map version""" diff --git a/src/App/Document.pyi b/src/App/Document.pyi new file mode 100644 index 0000000000..fee4ee35ef --- /dev/null +++ b/src/App/Document.pyi @@ -0,0 +1,394 @@ +from PropertyContainer import PropertyContainer +from DocumentObject import DocumentObject +from typing import Final, List, Tuple, Sequence + + +class Document(PropertyContainer): + """ + This is a Document class + Author: Juergen Riegel (FreeCAD@juergen-riegel.net) + Licence: LGPL + """ + + DependencyGraph: Final[str] = "" + """The dependency graph as GraphViz text""" + + ActiveObject: Final[DocumentObject] = None + """The last created object in this document""" + + Objects: Final[List[DocumentObject]] = [] + """The list of objects in this document""" + + TopologicalSortedObjects: Final[List[DocumentObject]] = [] + """The list of objects in this document in topological sorted order""" + + RootObjects: Final[List[DocumentObject]] = [] + """The list of root objects in this document""" + + RootObjectsIgnoreLinks: Final[List[DocumentObject]] = [] + """The list of root objects in this document ignoring references from links.""" + + UndoMode: int = 0 + """The Undo mode of the Document (0 = no Undo, 1 = Undo/Redo)""" + + UndoRedoMemSize: Final[int] = 0 + """The size of the Undo stack in byte""" + + UndoCount: Final[int] = 0 + """Number of possible Undos""" + + RedoCount: Final[int] = 0 + """Number of possible Redos""" + + UndoNames: Final[List[str]] = [] + """A list of Undo names""" + + RedoNames: Final[List[str]] = [] + """A List of Redo names""" + + Name: Final[str] = "" + """The internal name of the document""" + + RecomputesFrozen: bool = False + """Returns or sets if automatic recomputes for this document are disabled.""" + + HasPendingTransaction: Final[bool] = False + """Check if there is a pending transaction""" + + InList: Final[List["Document"]] = [] + """A list of all documents that link to this document.""" + + OutList: Final[List["Document"]] = [] + """A list of all documents that this document links to.""" + + Restoring: Final[bool] = False + """Indicate if the document is restoring""" + + Partial: Final[bool] = False + """Indicate if the document is partially loaded""" + + Importing: Final[bool] = False + """Indicate if the document is importing. Note the document will also report Restoring while importing""" + + Recomputing: Final[bool] = False + """Indicate if the document is recomputing""" + + Transacting: Final[bool] = False + """Indicate whether the document is undoing/redoing""" + + OldLabel: Final[str] = "" + """Contains the old label before change""" + + Temporary: Final[bool] = False + """Check if this is a temporary document""" + + def save(self) -> None: + """ + Save the document to disk + """ + ... + + def saveAs(self) -> None: + """ + Save the document under a new name to disk + """ + ... + + def saveCopy(self) -> None: + """ + Save a copy of the document under a new name to disk + """ + ... + + def load(self) -> None: + """ + Load the document from the given path + """ + ... + + def restore(self) -> None: + """ + Restore the document from disk + """ + ... + + def isSaved(self) -> bool: + """ + Checks if the document is saved + """ + ... + + def getProgramVersion(self) -> str: + """ + Get the program version that a project file was created with + """ + ... + + def getFileName(self) -> str: + """ + For a regular document it returns its file name property. + For a temporary document it returns its transient directory. + """ + ... + + def getUniqueObjectName(self, objName: str) -> str: + """ + getUniqueObjectName(objName) -> objName + + Return the same name, or the name made unique, for Example Box -> Box002 if there are conflicting name + already in the document. + + ObjName : str + Object name. + """ + ... + + def mergeProject(self) -> None: + """ + Merges this document with another project file + """ + ... + + def exportGraphviz(self) -> None: + """ + Export the dependencies of the objects as graph + """ + ... + + def openTransaction(self, name: str) -> None: + """ + openTransaction(name) - Open a new Undo/Redo transaction. + + This function no long creates a new transaction, but calls + FreeCAD.setActiveTransaction(name) instead, which will auto creates a + transaction with the given name when any change happed in any opened document. + If more than one document is changed, all newly created transactions will have + the same internal ID and will be undo/redo together. + """ + ... + + def abortTransaction(self) -> None: + """ + Abort an Undo/Redo transaction (rollback) + """ + ... + + def commitTransaction(self) -> None: + """ + Commit an Undo/Redo transaction + """ + ... + + def addObject( + self, + *, + type: str, + name: str = None, + objProxy: object = None, + viewProxy: object = None, + attach: bool = False, + viewType: str = None, + ) -> DocumentObject: + """ + addObject(type, name=None, objProxy=None, viewProxy=None, attach=False, viewType=None) + + Add an object to document + + type (String): the type of the document object to create. + name (String): the optional name of the new object. + objProxy (Object): the Python binding object to attach to the new document object. + viewProxy (Object): the Python binding object to attach the view provider of this object. + attach (Boolean): if True, then bind the document object first before adding to the document + to allow Python code to override view provider type. Once bound, and before adding to + the document, it will try to call Python binding object's attach(obj) method. + viewType (String): override the view provider type directly, only effective when attach is False. + """ + ... + + def addProperty( + self, + *, + type: str, + name: str, + group: str = "", + doc: str = "", + attr: int = 0, + read_only: bool = False, + hidden: bool = False, + ) -> "Document": + """ + addProperty(type: string, name: string, group="", doc="", attr=0, read_only=False, hidden=False) -- Add a generic property. + """ + ... + + def removeProperty(self, string: str) -> None: + """ + removeProperty(string) -- Remove a generic property. + Note, you can only remove user-defined properties but not built-in ones. + """ + ... + + def removeObject(self) -> None: + """ + Remove an object from the document + """ + ... + + def copyObject( + self, + object: DocumentObject, + *, + recursive: bool = False, + return_all: bool = False, + ) -> Tuple[DocumentObject, ...]: + """ + copyObject(object, recursive=False, return_all=False) + Copy an object or objects from another document to this document. + + object: can either be a single object or sequence of objects + recursive: if True, also recursively copies internal objects + return_all: if True, returns all copied objects, or else return only the copied + object corresponding to the input objects. + """ + ... + + def moveObject( + self, object: DocumentObject, with_dependencies: bool = False + ) -> DocumentObject: + """ + moveObject(object, bool with_dependencies = False) + Transfers an object from another document to this document. + + object: can either a single object or sequence of objects + with_dependencies: if True, all internal dependent objects are copied too. + """ + ... + + def importLinks(self, object: DocumentObject = None) -> Tuple[DocumentObject, ...]: + """ + importLinks(object|[object...]) + + Import any externally linked object given a list of objects in + this document. Any link type properties of the input objects + will be automatically reassigned to the imported object + + If no object is given as input, it import all externally linked + object of this document. + """ + ... + + def undo(self) -> None: + """ + Undo one transaction + """ + ... + + def redo(self) -> None: + """ + Redo a previously undone transaction + """ + ... + + def clearUndos(self) -> None: + """ + Clear the undo stack of the document + """ + ... + + def clearDocument(self) -> None: + """ + Clear the whole document + """ + ... + + def setClosable(self, closable: bool) -> None: + """ + Set a flag that allows or forbids to close a document + """ + ... + + def isClosable(self) -> bool: + """ + Check if the document can be closed. The default value is True + """ + ... + + def recompute(self, objs: Sequence[DocumentObject] = None) -> int: + """ + recompute(objs=None): Recompute the document and returns the amount of recomputed features + """ + ... + + def mustExecute(self) -> bool: + """ + Check if any object must be recomputed + """ + ... + + def purgeTouched(self) -> None: + """ + Purge the touched state of all objects + """ + ... + + def isTouched(self) -> bool: + """ + Check if any object is in touched state + """ + ... + + def getObject(self, name: str) -> DocumentObject: + """ + Return the object with the given name + """ + ... + + def getObjectsByLabel(self, label: str) -> List[DocumentObject]: + """ + Return the objects with the given label name. + NOTE: It's possible that several objects have the same label name. + """ + ... + + def findObjects( + self, *, Type: str = None, Name: str = None, Label: str = None + ) -> List[DocumentObject]: + """ + findObjects([Type=string], [Name=string], [Label=string]) -> list + Return a list of objects that match the specified type, name or label. + Name and label support regular expressions. All parameters are optional. + """ + ... + + def getLinksTo( + self, obj: DocumentObject, options: int = 0, maxCount: int = 0 + ) -> Tuple[DocumentObject, ...]: + """ + getLinksTo(obj, options=0, maxCount=0): return objects linked to 'obj' + + options: 1: recursive, 2: check link array. Options can combine. + maxCount: to limit the number of links returned + """ + ... + + def supportedTypes(self) -> List[str]: + """ + A list of supported types of objects + """ + ... + + def getTempFileName(self) -> str: + """ + Returns a file name with path in the temp directory of the document. + """ + ... + + def getDependentDocuments(self, sort: bool = True) -> List[DocumentObject]: + """ + getDependentDocuments(sort=True) + + Returns a list of documents that this document directly or indirectly links to including itself. + + sort: whether to topologically sort the return list + """ + ... diff --git a/src/App/DocumentObject.pyi b/src/App/DocumentObject.pyi new file mode 100644 index 0000000000..ee8d664391 --- /dev/null +++ b/src/App/DocumentObject.pyi @@ -0,0 +1,330 @@ +from Base.Metadata import constmethod +from Base.Matrix import Matrix +from Document import Document +from DocumentObjectGroup import DocumentObjectGroup +from ExtensionContainer import ExtensionContainer +from typing import Any, Final, List, Optional, Union, Tuple + + +class DocumentObject(ExtensionContainer): + """ + This is the father of all classes handled by the document + Author: Juergen Riegel (FreeCAD@juergen-riegel.net) + Licence: LGPL + """ + + OutList: Final[List["DocumentObject"]] = [] + """A list of all objects this object links to.""" + + OutListRecursive: Final[List["DocumentObject"]] = [] + """A list of all objects this object links to recursively.""" + + InList: Final[List["DocumentObject"]] = [] + """A list of all objects which link to this object.""" + + InListRecursive: Final[List["DocumentObject"]] = [] + """A list of all objects which link to this object recursively.""" + + FullName: Final[str] = "" + """Return the document name and internal name of this object""" + + Name: Final[Optional[str]] = "" + """Return the internal name of this object""" + + Document: Final[Document] = None + """Return the document this object is part of""" + + State: Final[List[Any]] = [] + """State of the object in the document""" + + ViewObject: Final[Any] = None + """ + If the GUI is loaded the associated view provider is returned + or None if the GUI is not up + """ + + MustExecute: Final[bool] = False + """Check if the object must be recomputed""" + + ID: Final[int] = 0 + """The unique identifier (among its document) of this object""" + + Removing: Final[bool] = False + """Indicate if the object is being removed""" + + Parents: Final[List[Any]] = [] + """A List of tuple(parent,subname) holding all parents to this object""" + + OldLabel: Final[str] = "" + """Contains the old label before change""" + + NoTouch: bool = False + """Enable/disable no touch on any property change""" + + def addProperty( + self, + *, + type: str, + name: str, + group: str = "", + doc: str = "", + attr: int = 0, + read_only: bool = False, + hidden: bool = False, + enum_vals: list = [] + ) -> "DocumentObject": + """ + addProperty(type: string, name: string, group="", doc="", attr=0, read_only=False, hidden=False, enum_vals=[]) -- Add a generic property. + """ + ... + + def removeProperty(self, string: str) -> None: + """ + removeProperty(string) -- Remove a generic property. + + Note, you can only remove user-defined properties but not built-in ones. + """ + ... + + def supportedProperties(self) -> list: + """ + A list of supported property types + """ + ... + + def touch(self) -> None: + """ + Mark the object as changed (touched) + """ + ... + + def purgeTouched(self) -> None: + """ + Mark the object as unchanged + """ + ... + + def enforceRecompute(self) -> None: + """ + Mark the object for recompute + """ + ... + + def setExpression(self, name: str, expression: str) -> None: + """ + Register an expression for a property + """ + ... + + def clearExpression(self, name: str) -> None: + """ + Clear the expression for a property + """ + ... + + @classmethod + def evalExpression(cls, expression: str) -> Any: + """ + Evaluate an expression + """ + ... + + def recompute(self, recursive: bool = False) -> None: + """ + recompute(recursive=False): Recomputes this object + """ + ... + + @constmethod + def getStatusString(self) -> str: + """ + Returns the status of the object as string. + If the object is invalid its error description will be returned. + If the object is valid but touched then 'Touched' will be returned, + 'Valid' otherwise. + """ + ... + + @constmethod + def isValid(self) -> bool: + """ + Returns True if the object is valid, False otherwise + """ + ... + + def getSubObject( + self, + *, + subname: Union[str, List[str], Tuple[str, ...]], + retType: int = 0, + matrix: Matrix = None, + transform: bool = True, + depth: int = 0, + ) -> Any: + """ + getSubObject(subname, retType=0, matrix=None, transform=True, depth=0) + + * subname(string|list|tuple): dot separated string or sequence of strings + referencing subobject. + + * retType: return type, 0=PyObject, 1=DocObject, 2=DocAndPyObject, 3=Placement + + PyObject: return a python binding object for the (sub)object referenced in + each 'subname' The actual type of 'PyObject' is implementation dependent. + For Part::Feature compatible objects, this will be of type TopoShapePy and + pre-transformed by accumulated transformation matrix along the object path. + + DocObject: return the document object referenced in subname, if 'matrix' is + None. Or, return a tuple (object, matrix) for each 'subname' and 'matrix' is + the accumulated transformation matrix for the sub object. + + DocAndPyObject: return a tuple (object, matrix, pyobj) for each subname + + Placement: return a transformed placement of the sub-object + + * matrix: the initial transformation to be applied to the sub object. + + * transform: whether to transform the sub object using this object's placement + + * depth: current recursive depth + """ + ... + + def getSubObjectList(self, subname: str) -> list: + """ + getSubObjectList(subname) + + Return a list of objects referenced by a given subname including this object + """ + ... + + def getSubObjects(self, reason: int = 0) -> list: + """ + getSubObjects(reason=0): Return subname reference of all sub-objects + """ + ... + + def getLinkedObject( + self, + *, + recursive: bool = True, + matrix: Matrix = None, + transform: bool = True, + depth: int = 0, + ) -> Any: + """ + getLinkedObject(recursive=True, matrix=None, transform=True, depth=0) + Returns the linked object if there is one, or else return itself + + * recursive: whether to recursively resolve the links + + * transform: whether to transform the sub object using this object's placement + + * matrix: If not none, this specifies the initial transformation to be applied + to the sub object. And cause the method to return a tuple (object, matrix) + containing the accumulated transformation matrix + + * depth: current recursive depth + """ + ... + + def setElementVisible(self, element: str, visible: bool) -> int: + """ + setElementVisible(element,visible): Set the visibility of a child element + Return -1 if element visibility is not supported, 0 if element not found, 1 if success + """ + ... + + def isElementVisible(self, element: str) -> int: + """ + isElementVisible(element): Check if a child element is visible + Return -1 if element visibility is not supported or element not found, 0 if invisible, or else 1 + """ + ... + + def hasChildElement(self) -> bool: + """ + Return true to indicate the object having child elements + """ + ... + + def getParentGroup(self) -> DocumentObjectGroup: + """ + Returns the group the object is in or None if it is not part of a group. + + Note that an object can only be in a single group, hence only a single return value. + """ + ... + + def getParentGeoFeatureGroup(self) -> Any: + """ + Returns the GeoFeatureGroup, and hence the local coordinate system, the object + is in or None if it is not part of a group. + + Note that an object can only be in a single group, hence only a single return value. + """ + ... + + def getParent(self) -> Any: + """ + Returns the group the object is in or None if it is not part of a group. + + Note that an object can only be in a single group, hence only a single return value. + The parent can be a simple group as with getParentGroup() or a GeoFeature group as + with getParentGeoFeatureGroup(). + """ + ... + + def getPathsByOutList(self) -> list: + """ + Get all paths from this object to another object following the OutList. + """ + ... + + @constmethod + def resolve(self, subname: str) -> tuple: + """ + resolve(subname) -- resolve the sub object + + Returns a tuple (subobj,parent,elementName,subElement), where 'subobj' is the + last object referenced in 'subname', and 'parent' is the direct parent of + 'subobj', and 'elementName' is the name of the subobj, which can be used + to call parent.isElementVisible/setElementVisible(). 'subElement' is the + non-object sub-element name if any. + """ + ... + + @constmethod + def resolveSubElement(self, subname: str, append: bool, type: int) -> tuple: + """ + resolveSubElement(subname,append,type) -- resolve both new and old style sub element + + subname: subname reference containing object hierarchy + append: Whether to append object hierarchy prefix inside subname to returned element name + type: 0: normal, 1: for import, 2: for export + + Return tuple(obj,newElementName,oldElementName) + """ + ... + + def adjustRelativeLinks(self, parent: DocumentObject, recursive: bool = True) -> bool: + """ + adjustRelativeLinks(parent,recursive=True) -- auto correct potential cyclic dependencies + """ + ... + + @constmethod + def getElementMapVersion(self, property_name: str) -> str: + """ + getElementMapVersion(property_name): return element map version of a given geometry property + """ + ... + + @constmethod + def isAttachedToDocument(self) -> bool: + """ + isAttachedToDocument() -> bool + + Return true if the object is part of a document, false otherwise. + """ + ... diff --git a/src/App/DocumentObjectExtension.pyi b/src/App/DocumentObjectExtension.pyi new file mode 100644 index 0000000000..0709e77844 --- /dev/null +++ b/src/App/DocumentObjectExtension.pyi @@ -0,0 +1,10 @@ +from Extension import Extension + + +class DocumentObjectExtension(Extension): + """ + Base class for all document object extensions + Author: Stefan Troeger (stefantroeger@gmx.net) + Licence: LGPL + """ + ... diff --git a/src/App/DocumentObjectGroup.pyi b/src/App/DocumentObjectGroup.pyi new file mode 100644 index 0000000000..82529d9e14 --- /dev/null +++ b/src/App/DocumentObjectGroup.pyi @@ -0,0 +1,10 @@ +from DocumentObject import DocumentObject + + +class DocumentObjectGroup(DocumentObject): + """ + This class handles document objects in group + Author: Werner Mayer (wmayer@users.sourceforge.net) + Licence: LGPL + """ + ... diff --git a/src/App/Extension.pyi b/src/App/Extension.pyi new file mode 100644 index 0000000000..2246d43946 --- /dev/null +++ b/src/App/Extension.pyi @@ -0,0 +1,10 @@ +from Base.PyObjectBase import PyObjectBase + + +class Extension(PyObjectBase): + """ + Base class for all extensions + Author: Stefan Troeger (stefantroeger@gmx.net) + Licence: LGPL + """ + ... diff --git a/src/App/ExtensionContainer.pyi b/src/App/ExtensionContainer.pyi new file mode 100644 index 0000000000..f71ebeb540 --- /dev/null +++ b/src/App/ExtensionContainer.pyi @@ -0,0 +1,27 @@ +from Base.Metadata import export, constmethod +from PropertyContainer import PropertyContainer + + +@export( + Initialization=True, + Constructor=True, +) +class ExtensionContainer(PropertyContainer): + """ + Base class for all objects which can be extended + Author: Stefan Troeger (stefantroeger@gmx.net) + Licence: LGPL + """ + + def addExtension(self, identifier: str) -> None: + """ + Adds an extension to the object. Requires the string identifier for the python extension as argument + """ + ... + + @constmethod + def hasExtension(self, identifier: str) -> bool: + """ + Returns if this object has the specified extension + """ + ... diff --git a/src/App/GeoFeature.pyi b/src/App/GeoFeature.pyi new file mode 100644 index 0000000000..d98cef96a4 --- /dev/null +++ b/src/App/GeoFeature.pyi @@ -0,0 +1,79 @@ +from DocumentObject import DocumentObject +from Base import Placement +from typing import Any, Final, Optional + + +class GeoFeature(DocumentObject): + """ + App.GeoFeature class. + + Base class of all geometric document objects. + This class does the whole placement and position handling. + With the method `getPropertyOfGeometry` is possible to obtain + the main geometric property in general form, without reference + to any particular property name. + """ + + ElementMapVersion: Final[str] = "" + """Element map version""" + + def getPaths(self) -> Any: + """ + getPaths() + + Returns all possible paths to the root of the document. + Note: Not implemented. + """ + ... + + def getGlobalPlacement(self) -> Placement: + """ + getGlobalPlacement() -> Base.Placement + Deprecated: This function does not handle Links correctly. Use getGlobalPlacementOf instead. + + Returns the placement of the object in the global coordinate space, respecting all stacked + relationships. + Note: This function is not available during recompute, as there the placements of parents + can change after the execution of this object, rendering the result wrong. + """ + ... + + @staticmethod + def getGlobalPlacementOf(targetObj: Any, rootObj: Any, subname: str) -> Placement: + """ + getGlobalPlacementOf(targetObj, rootObj, subname) -> Base.Placement + Selection example: obj = "part1" sub = "linkToPart2.LinkToBody.Pad.face1" + + Global placement of Pad in this context : + getGlobalPlacementOf(pad, part1, "linkToPart2.LinkToBody.Pad.face1") + + Global placement of linkToPart2 in this context : + getGlobalPlacementOf(linkToPart2, part1, "linkToPart2.LinkToBody.Pad.face1") + + Returns the placement of the object in the global coordinate space, respecting all stacked + relationships. + """ + ... + + def getPropertyNameOfGeometry(self) -> Optional[str]: + """ + getPropertyNameOfGeometry() -> str or None + + Returns the property name of the actual geometry. + For example for a Part feature it returns the value 'Shape', for a mesh feature the value + 'Mesh' and so on. + If an object has no such property then None is returned. + """ + ... + + def getPropertyOfGeometry(self) -> Optional[Any]: + """ + getPropertyOfGeometry() -> object or None + + Returns the property of the actual geometry. + For example for a Part feature it returns its Shape property, for a Mesh feature its + Mesh property and so on. + If an object has no such property then None is returned. + Unlike to getPropertyNameOfGeometry this function returns the geometry, not its name. + """ + ... diff --git a/src/App/GeoFeatureGroupExtension.pyi b/src/App/GeoFeatureGroupExtension.pyi new file mode 100644 index 0000000000..50b5d657e3 --- /dev/null +++ b/src/App/GeoFeatureGroupExtension.pyi @@ -0,0 +1,10 @@ +from GroupExtension import GroupExtension + + +class GeoFeatureGroupExtension(GroupExtension): + """ + Author: Werner Mayer (wmayer@users.sourceforge.net) + Licence: LGPL + This class handles placeable group of document objects + """ + ... diff --git a/src/App/GroupExtension.pyi b/src/App/GroupExtension.pyi new file mode 100644 index 0000000000..cef2617867 --- /dev/null +++ b/src/App/GroupExtension.pyi @@ -0,0 +1,72 @@ +from Base.Metadata import export +from DocumentObjectExtension import DocumentObjectExtension +from typing import Any, List + + +@export( + Include="App/DocumentObjectGroup.h", +) +class GroupExtension(DocumentObjectExtension): + """ + Extension class which allows grouping of document objects + Author: Werner Mayer (wmayer@users.sourceforge.net) + Licence: LGPL + """ + + def newObject(self, type: str, name: str) -> Any: + """ + Create and add an object with given type and name to the group + """ + ... + + def addObject(self, obj: Any) -> List[Any]: + """ + Add an object to the group. Returns all objects that have been added. + """ + ... + + def addObjects(self, objects: List[Any]) -> List[Any]: + """ + Adds multiple objects to the group. Expects a list and returns all objects that have been added. + """ + ... + + def setObjects(self, objects: List[Any]) -> List[Any]: + """ + Sets the objects of the group. Expects a list and returns all objects that are now in the group. + """ + ... + + def removeObject(self, obj: Any) -> List[Any]: + """ + Remove an object from the group and returns all objects that have been removed. + """ + ... + + def removeObjects(self, objects: List[Any]) -> List[Any]: + """ + Remove multiple objects from the group. Expects a list and returns all objects that have been removed. + """ + ... + + def removeObjectsFromDocument(self) -> None: + """ + Remove all child objects from the group and document + """ + ... + + def getObject(self, name: str) -> Any: + """ + Return the object with the given name + """ + ... + + def hasObject(self, obj: Any, recursive: bool = False) -> bool: + """ + hasObject(obj, recursive=false) + + Checks if the group has a given object + @param obj the object to check for. + @param recursive if true check also if the obj is child of some sub group (default is false). + """ + ... diff --git a/src/App/LinkBaseExtension.pyi b/src/App/LinkBaseExtension.pyi new file mode 100644 index 0000000000..817f85e9e8 --- /dev/null +++ b/src/App/LinkBaseExtension.pyi @@ -0,0 +1,118 @@ +from Base.Metadata import export +from DocumentObjectExtension import DocumentObjectExtension +from typing import Any, Final, List, Tuple, Optional, Union, overload + + +@export( + Include="App/Link.h", +) +class LinkBaseExtension(DocumentObjectExtension): + """ + Link extension base class + Author: Zheng, Lei (realthunder.dev@gmail.com) + Licence: LGPL + """ + + LinkedChildren: Final[List[Any]] = [] + """Return a flattened (in case grouped by plain group) list of linked children""" + + def configLinkProperty(self, **kwargs) -> Any: + """ + configLinkProperty(key=val,...): property configuration + configLinkProperty(key,...): property configuration with default name + + This methode is here to implement what I called Property Design + Pattern. The extension operates on a predefined set of properties, + but it relies on the extended object to supply the actual property by + calling this methode. You can choose a sub set of functionality of + this extension by supplying only some of the supported properties. + + The 'key' are names used to refer to properties supported by this + extension, and 'val' is the actual name of the property of your + object. You can obtain the key names and expected types using + getLinkPropertyInfo(). You can use property of derived type when + calling configLinkProperty(). Other types will cause exception to + ben thrown. The actual properties supported may be different + depending on the actual extension object underlying this python + object. + + If 'val' is omitted, i.e. calling configLinkProperty(key,...), then + it is assumed that the actual property name is the same as 'key' + """ + ... + + def getLinkExtProperty(self, name: str) -> Any: + """ + getLinkExtProperty(name): return the property value by its predefined name + """ + ... + + def getLinkExtPropertyName(self, name: str) -> str: + """ + getLinkExtPropertyName(name): lookup the property name by its predefined name + """ + ... + + @overload + def getLinkPropertyInfo(self) -> tuple: + ... + + @overload + def getLinkPropertyInfo(self, index: int) -> tuple: + ... + + @overload + def getLinkPropertyInfo(self, name: str) -> tuple: + ... + + def getLinkPropertyInfo(self, arg: Any = None) -> tuple: + """ + getLinkPropertyInfo(): return a tuple of (name,type,doc) for all supported properties. + + getLinkPropertyInfo(index): return (name,type,doc) of a specific property + + getLinkPropertyInfo(name): return (type,doc) of a specific property + """ + ... + + def setLink(self, obj: Any, subName: Optional[str] = None, subElements: Optional[Union[str, Tuple[str, ...]]] = None) -> None: + """ + setLink(obj,subName=None,subElements=None): Set link object. + + setLink([obj,...]), + setLink([(obj,subName,subElements),...]), + setLink({index:obj,...}), + setLink({index:(obj,subName,subElements),...}): set link element of a link group. + + obj (DocumentObject): the object to link to. If this is None, then the link is cleared + + subName (String): Dot separated object path. + + subElements (String|tuple(String)): non-object sub-elements, e.g. Face1, Edge2. + """ + ... + + def cacheChildLabel(self, enable: bool = True) -> None: + """ + cacheChildLabel(enable=True): enable/disable child label cache + + The cache is not updated on child label change for performance reason. You must + call this function on any child label change + """ + ... + + def flattenSubname(self, subname: str) -> str: + """ + flattenSubname(subname) -> string + + Return a flattened subname in case it references an object inside a linked plain group + """ + ... + + def expandSubname(self, subname: str) -> str: + """ + expandSubname(subname) -> string + + Return an expanded subname in case it references an object inside a linked plain group + """ + ... diff --git a/src/App/Material.pyi b/src/App/Material.pyi new file mode 100644 index 0000000000..d62eb097aa --- /dev/null +++ b/src/App/Material.pyi @@ -0,0 +1,54 @@ +from Base.Metadata import export, class_declarations +from Base.PyObjectBase import PyObjectBase +from typing import Any, overload + + +@export( + Constructor=True, + Delete=True, +) +@class_declarations( + """public: + static Base::Color toColor(PyObject* value); + """ +) +class Material(PyObjectBase): + """ + App.Material class. + + Author: Werner Mayer (wmayer@users.sourceforge.net) + Licence: LGPL + UserDocu: This is the Material class + """ + + @overload + def __init__(self, *args: Any, **kwargs: Any) -> None: + ... + + def set(self, string: str) -> None: + """ + Set(string) -- Set the material. + + The material must be one of the following values: + Brass, Bronze, Copper, Gold, Pewter, Plaster, Plastic, Silver, Steel, Stone, Shiny plastic, + Satin, Metalized, Neon GNC, Chrome, Aluminium, Obsidian, Neon PHC, Jade, Ruby or Emerald. + """ + ... + + AmbientColor: Any = ... + """Ambient color""" + + DiffuseColor: Any = ... + """Diffuse color""" + + EmissiveColor: Any = ... + """Emissive color""" + + SpecularColor: Any = ... + """Specular color""" + + Shininess: float = 0.0 + """Shininess""" + + Transparency: float = 0.0 + """Transparency""" diff --git a/src/App/MeasureManager.pyi b/src/App/MeasureManager.pyi new file mode 100644 index 0000000000..6a7dd43b16 --- /dev/null +++ b/src/App/MeasureManager.pyi @@ -0,0 +1,47 @@ +from Base.Metadata import export, no_args +from Base.PyObjectBase import PyObjectBase +from typing import List, Tuple, TypeAlias + + +MeasureType: TypeAlias = object + +@export( + Constructor=False, + Delete=True, + ) +class MeasureManager(PyObjectBase): + """ + MeasureManager class. + + The MeasureManager handles measure types and geometry handler across FreeCAD. + + Author: David Friedli (david@friedli-be.ch) + Licence: LGPL + DeveloperDocu: MeasureManager + """ + + @staticmethod + def addMeasureType(id: str, label: str, measureType: MeasureType) -> None: + """ + addMeasureType(id, label, measureType) -> None + + Add a new measure type. + + id : str + Unique identifier of the measure type. + label : str + Name of the module. + measureType : Measure.MeasureBasePython + The actual measure type. + """ + ... + + @staticmethod + @no_args + def getMeasureTypes() -> List[Tuple[str, str, MeasureType]]: + """ + getMeasureTypes() -> List[(id, label, pythonMeasureType)] + + Returns a list of all registered measure types. + """ + ... diff --git a/src/App/Metadata.pyi b/src/App/Metadata.pyi new file mode 100644 index 0000000000..3fcd38198f --- /dev/null +++ b/src/App/Metadata.pyi @@ -0,0 +1,405 @@ +from Base.Metadata import export, class_declarations +from Base.PyObjectBase import PyObjectBase +from typing import Any, List, Dict, overload, Optional + + +@export( + Constructor=True, + Delete=True, + NumberProtocol=False, + RichCompare=False, + ) +@class_declarations( + """public: + MetadataPy(const Metadata & pla, PyTypeObject *T = &Type) + :PyObjectBase(new Metadata(pla),T){} + Metadata value() const + { return *(getMetadataPtr()); } + """ +) +class Metadata(PyObjectBase): + """ + App.Metadata class. + + A Metadata object reads an XML-formatted package metadata file and provides + read and write access to its contents. + + The following constructors are supported: + + Metadata() + Empty constructor. + + Metadata(metadata) + Copy constructor. + metadata : App.Metadata + + Metadata(file) + Reads the XML file and provides access to the metadata it specifies. + file : str + XML file name. + + Metadata(bytes) + Treats the bytes as UTF-8-encoded XML data and provides access to the metadata it specifies. + bytes : bytes + Python bytes-like object. + + Author: Chris Hennes (chennes@pioneerlibrarysystem.org) + Licence: LGPL + DeveloperDocu: Metadata + """ + + @overload + def __init__(self) -> None: ... + + @overload + def __init__(self, metadata: "Metadata") -> None: ... + + @overload + def __init__(self, file: str) -> None: ... + + @overload + def __init__(self, bytes: bytes) -> None: ... + + Name: str = "" + """String representing the name of this item.""" + + Version: str = "" + """String representing the version of this item in semantic triplet format.""" + + Date: str = "" + """String representing the date of this item in YYYY-MM-DD format (format not currently programmatically enforced)""" + + Type: str = "" + """String representing the type of this item (text only, no markup allowed).""" + + Description: str = "" + """String representing the description of this item (text only, no markup allowed).""" + + Maintainer: List[Any] = [] + """List of maintainer objects with 'name' and 'email' string attributes.""" + + License: List[Any] = [] + """List of applicable licenses as objects with 'name' and 'file' string attributes.""" + + Urls: List[Any] = [] + """ + List of URLs as objects with 'location' and 'type' string attributes, where type + is one of: + * website + * repository + * bugtracker + * readme + * documentation + """ + + Author: List[Any] = [] + """ + List of author objects, each with a 'name' and a (potentially empty) 'email' + string attribute. + """ + + Depend: List[Any] = [] + """ + List of dependencies, as objects with the following attributes: + * package + Required. Must exactly match the contents of the 'name' element in the + referenced package's package.xml file. + * version_lt + Optional. The dependency to the package is restricted to versions less than + the stated version number. + * version_lte + Optional. The dependency to the package is restricted to versions less or + equal than the stated version number. + * version_eq + Optional. The dependency to the package is restricted to a version equal + than the stated version number. + * version_gte + Optional. The dependency to the package is restricted to versions greater + or equal than the stated version number. + * version_gt + Optional. The dependency to the package is restricted to versions greater + than the stated version number. + * condition + Optional. Conditional expression as documented in REP149. + """ + + Conflict: List[Any] = [] + """List of conflicts, format identical to dependencies.""" + + Replace: List[Any] = [] + """ + List of things this item is considered by its author to replace. The format is + identical to dependencies. + """ + + Tag: List[str] = [] + """List of strings.""" + + Icon: str = "" + """Relative path to an icon file.""" + + Classname: str = "" + """ + String representing the name of the main Python class this item + creates/represents. + """ + + Subdirectory: str = "" + """ + String representing the name of the subdirectory this content item is located in. + If empty, the item is in a directory named the same as the content item. + """ + + File: List[Any] = [] + """ + List of files associated with this item. + The meaning of each file is implementation-defined. + """ + + Content: Dict[str, List["Metadata"]] = {} + """ + Dictionary of lists of content items: defined recursively, each item is itself + a Metadata object. + See package.xml file format documentation for details. + """ + + FreeCADMin: str = "" + """ + String representing the minimum version of FreeCAD needed for this item. + If unset it will be 0.0.0. + """ + + FreeCADMax: str = "" + """ + String representing the maximum version of FreeCAD needed for this item. + If unset it will be 0.0.0. + """ + + PythonMin: str = "" + """ + String representing the minimum version of Python needed for this item. + If unset it will be 0.0.0. + """ + + def getLastSupportedFreeCADVersion(self) -> Optional[str]: + """ + getLastSupportedFreeCADVersion() -> str or None + + Search through all content package items, and determine if a maximum supported + version of FreeCAD is set. + Returns None if no maximum version is set, or if *any* content item fails to + provide a maximum version (implying that that content item will work with all + known versions). + """ + ... + + def getFirstSupportedFreeCADVersion(self) -> Optional[str]: + """ + getFirstSupportedFreeCADVersion() -> str or None + + Search through all content package items, and determine if a minimum supported + version of FreeCAD is set. + Returns 0.0 if no minimum version is set, or if *any* content item fails to + provide a minimum version (implying that that content item will work with all + known versions. Technically limited to 0.20 as the lowest known version since + the metadata standard was added then). + """ + ... + + def supportsCurrentFreeCAD(self) -> bool: + """ + supportsCurrentFreeCAD() -> bool + + Returns False if this metadata object directly indicates that it does not + support the current version of FreeCAD, or True if it makes no indication, or + specifically indicates that it does support the current version. Does not + recurse into Content items. + """ + ... + + def getGenericMetadata(self, name: str) -> List[Any]: + """ + getGenericMetadata(name) -> list + + Get the list of GenericMetadata objects with key 'name'. + Generic metadata objects are Python objects with a string 'contents' and a + dictionary of strings, 'attributes'. They represent unrecognized simple XML tags + in the metadata file. + """ + ... + + def addContentItem(self, content_type: str, metadata: "Metadata") -> None: + """ + addContentItem(content_type,metadata) + + Add a new content item of type 'content_type' with metadata 'metadata'. + """ + ... + + def removeContentItem(self, content_type: str, name: str) -> None: + """ + removeContentItem(content_type,name) + + Remove the content item of type 'content_type' with name 'name'. + """ + ... + + def addMaintainer(self, name: str, email: str) -> None: + """ + addMaintainer(name, email) + + Add a new Maintainer. + """ + ... + + def removeMaintainer(self, name: str, email: str) -> None: + """ + removeMaintainer(name, email) + + Remove the Maintainer. + """ + ... + + def addLicense(self, short_code: str, path: str) -> None: + """ + addLicense(short_code,path) + + Add a new License. + """ + ... + + def removeLicense(self, short_code: str) -> None: + """ + removeLicense(short_code) + + Remove the License. + """ + ... + + def addUrl(self, url_type: str, url: str, branch: str) -> None: + """ + addUrl(url_type,url,branch) + + Add a new Url or type 'url_type' (which should be one of 'repository', 'readme', + + 'bugtracker', 'documentation', or 'webpage') If type is 'repository' you + + must also specify the 'branch' parameter. + """ + ... + + def removeUrl(self, url_type: str, url: str) -> None: + """ + removeUrl(url_type,url) + + Remove the Url. + """ + ... + + def addAuthor(self, name: str, email: str) -> None: + """ + addAuthor(name, email) + + Add a new Author with name 'name', and optionally email 'email'. + """ + ... + + def removeAuthor(self, name: str, email: str) -> None: + """ + removeAuthor(name, email) + + Remove the Author. + """ + ... + + def addDepend(self, name: str, kind: str, optional: bool) -> None: + """ + addDepend(name, kind, optional) + + Add a new Dependency on package 'name' of kind 'kind' (optional, one of 'auto' (the default), + + 'internal', 'addon', or 'python'). + """ + ... + + def removeDepend(self, name: str, kind: str) -> None: + """ + removeDepend(name, kind) + + Remove the Dependency on package 'name' of kind 'kind' (optional - if unspecified any + + matching name is removed). + """ + ... + + def addConflict(self, name: str, kind: str) -> None: + """ + addConflict(name, kind) + + Add a new Conflict. See documentation for addDepend(). + """ + ... + + def removeConflict(self, name: str, kind: str) -> None: + """ + removeConflict(name, kind) + + Remove the Conflict. See documentation for removeDepend(). + """ + ... + + def addReplace(self, name: str) -> None: + """ + addReplace(name) + + Add a new Replace. + """ + ... + + def removeReplace(self, name: str) -> None: + """ + removeReplace(name) + + Remove the Replace. + """ + ... + + def addTag(self, tag: str) -> None: + """ + addTag(tag) + + Add a new Tag. + """ + ... + + def removeTag(self, tag: str) -> None: + """ + removeTag(tag) + + Remove the Tag. + """ + ... + + def addFile(self, filename: str) -> None: + """ + addFile(filename) + + Add a new File. + """ + ... + + def removeFile(self, filename: str) -> None: + """ + removeFile(filename) + + Remove the File. + """ + ... + + def write(self, filename: str) -> None: + """ + write(filename) + + Write the metadata to the given file as XML data. + """ + ... diff --git a/src/App/OriginGroupExtension.pyi b/src/App/OriginGroupExtension.pyi new file mode 100644 index 0000000000..85c70fe831 --- /dev/null +++ b/src/App/OriginGroupExtension.pyi @@ -0,0 +1,10 @@ +from GeoFeatureGroupExtension import GeoFeatureGroupExtension + + +class OriginGroupExtension(GeoFeatureGroupExtension): + """ + Author: Alexander Golubev (fatzer2@gmail.com) + Licence: LGPL + This class handles placable group of document objects with an Origin + """ + ... diff --git a/src/App/Part.pyi b/src/App/Part.pyi new file mode 100644 index 0000000000..c0e0b9768c --- /dev/null +++ b/src/App/Part.pyi @@ -0,0 +1,10 @@ +from GeoFeature import GeoFeature + + +class Part(GeoFeature): + """ + Author: Juergen Riegel (FreeCAD@juergen-riegel.net) + Licence: LGPL + This class handles document objects in Part + """ + ... diff --git a/src/App/PropertyContainer.pyi b/src/App/PropertyContainer.pyi new file mode 100644 index 0000000000..ce59ce118b --- /dev/null +++ b/src/App/PropertyContainer.pyi @@ -0,0 +1,213 @@ +from Base.Metadata import export, constmethod +from Base.Persistence import Persistence +from typing import Any, Final, Union, List, Optional + + +@export( + DisableNotify=True, +) +class PropertyContainer(Persistence): + """ + App.PropertyContainer class. + """ + + PropertiesList: Final[list] = [] + """A list of all property names.""" + + def getPropertyByName(self, name: str, checkOwner: int = 0) -> Any: + """ + getPropertyByName(name, checkOwner=0) -> object or Tuple + + Returns the value of a named property. Note that the returned property may not + always belong to this container (e.g. from a linked object). + + name : str + Name of the property. + checkOwner : int + 0: just return the property. + 1: raise exception if not found or the property does not belong to this container. + 2: return a tuple (owner, propertyValue). + """ + ... + + def getPropertyTouchList(self, name: str) -> tuple: + """ + getPropertyTouchList(name) -> tuple + + Returns a list of index of touched values for list type properties. + + name : str + Property name. + """ + ... + + def getTypeOfProperty(self, name: str) -> list: + """ + getTypeOfProperty(name) -> list + + Returns the type of a named property. This can be a list conformed by elements in + (Hidden, NoRecompute, NoPersist, Output, ReadOnly, Transient). + + name : str + Property name. + """ + ... + + def getTypeIdOfProperty(self, name: str) -> str: + """ + getTypeIdOfProperty(name) -> str + + Returns the C++ class name of a named property. + + name : str + Property name. + """ + ... + + def setEditorMode(self, name: str, type: Union[int, List[str]]) -> None: + """ + setEditorMode(name, type) -> None + + Set the behaviour of the property in the property editor. + + name : str + Property name. + type : int, sequence of str + Property type. + 0: default behaviour. 1: item is ready-only. 2: item is hidden. 3: item is hidden and read-only. + If sequence, the available items are 'ReadOnly' and 'Hidden'. + """ + ... + + def getEditorMode(self, name: str) -> list: + """ + getEditorMode(name) -> list + + Get the behaviour of the property in the property editor. + It returns a list of strings with the current mode. If the list is empty there are no + special restrictions. + If the list contains 'ReadOnly' then the item appears in the property editor but is + disabled. + If the list contains 'Hidden' then the item even doesn't appear in the property editor. + + name : str + Property name. + """ + ... + + def getGroupOfProperty(self, name: str) -> str: + """ + getGroupOfProperty(name) -> str + + Returns the name of the group which the property belongs to in this class. + The properties are sorted in different named groups for convenience. + + name : str + Property name. + """ + ... + + def setGroupOfProperty(self, name: str, group: str) -> None: + """ + setGroupOfProperty(name, group) -> None + + Set the name of the group of a dynamic property. + + name : str + Property name. + group : str + Group name. + """ + ... + + def setPropertyStatus( + self, name: str, val: Union[int, str, List[Union[str, int]]] + ) -> None: + """ + setPropertyStatus(name, val) -> None + + Set property status. + + name : str + Property name. + val : int, str, sequence of str or int + Call getPropertyStatus() to get a list of supported text value. + If the text start with '-' or the integer value is negative, then the status is cleared. + """ + ... + + def getPropertyStatus(self, name: str = "") -> list: + """ + getPropertyStatus(name='') -> list + + Get property status. + + name : str + Property name. If empty, returns a list of supported text names of the status. + """ + ... + + def getDocumentationOfProperty(self, name: str) -> str: + """ + getDocumentationOfProperty(name) -> str + + Returns the documentation string of the property of this class. + + name : str + Property name. + """ + ... + + def setDocumentationOfProperty(self, name: str, docstring: str) -> None: + """ + setDocumentationOfProperty(name, docstring) -> None + + Set the documentation string of a dynamic property of this class. + + name : str + Property name. + docstring : str + Documentation string. + """ + ... + + def getEnumerationsOfProperty(self, name: str) -> Optional[list]: + """ + getEnumerationsOfProperty(name) -> list or None + + Return all enumeration strings of the property of this class or None if not a + PropertyEnumeration. + + name : str + Property name. + """ + ... + + @constmethod + def dumpPropertyContent(self, Property: str, *, Compression: int = 3) -> bytearray: + """ + dumpPropertyContent(Property, Compression=3) -> bytearray + + Dumps the content of the property, both the XML representation and the additional + data files required, into a byte representation. + + Property : str + Property Name. + Compression : int + Set the data compression level in the range [0, 9]. Set to 0 for no compression. + """ + ... + + def restorePropertyContent(self, name: str, obj: object) -> None: + """ + restorePropertyContent(name, obj) -> None + + Restore the content of the object from a byte representation as stored by `dumpPropertyContent`. + It could be restored from any Python object implementing the buffer protocol. + + name : str + Property name. + obj : buffer + Object with buffer protocol support. + """ + ... diff --git a/src/App/StringHasher.pyi b/src/App/StringHasher.pyi new file mode 100644 index 0000000000..708ad74311 --- /dev/null +++ b/src/App/StringHasher.pyi @@ -0,0 +1,62 @@ +from Base.Metadata import export, constmethod +from Base.BaseClass import BaseClass +from typing import Any, Final, overload, Dict + + +@export( + Constructor=True, + Reference=True, +) +class StringHasher(BaseClass): + """ + This is the StringHasher class + + Author: Zheng, Lei (realthunder.dev@gmail.com) + Licence: LGPL + """ + + @overload + def __init__(self, *args: Any, **kwargs: Any) -> None: + ... + + def getID(self, arg: Any, base64: bool = False) -> Any: + """ + getID(txt|id, base64=False) -> StringID + + If the input is text, return a StringID object that is unique within this hasher. This + StringID object is reference counted. The hasher may only save hash ID's that are used. + + If the input is an integer, then the hasher will try to find the StringID object stored + with the same integer value. + + base64: indicate if the input 'txt' is base64 encoded binary data + """ + ... + + @overload + def getID(self, txt: str, base64: bool = False) -> Any: ... + + @overload + def getID(self, id: int, base64: bool = False) -> Any: ... + + @constmethod + def isSame(self, other: "StringHasher") -> bool: + """ + Check if two hasher are the same + """ + ... + + Count: Final[int] = 0 + """Return count of used hashes""" + + Size: Final[int] = 0 + """Return the size of the hashes""" + + SaveAll: bool = False + """Whether to save all string hashes regardless of its use count""" + + Threshold: int = 0 + """Data length exceed this threshold will be hashed before storing""" + + Table: Final[Dict[int, str]] = {} + """Return the entire string table as Int->String dictionary""" diff --git a/src/App/StringID.pyi b/src/App/StringID.pyi new file mode 100644 index 0000000000..4251cd0827 --- /dev/null +++ b/src/App/StringID.pyi @@ -0,0 +1,46 @@ +from Base.Metadata import export, constmethod, class_declarations +from Base.BaseClass import BaseClass +from typing import Any, Final, List + + +@export( + Include="App/StringHasher.h", + Reference=True, +) +@class_declarations("""private: + friend class StringID; + int _index = 0; + """ +) +class StringID(BaseClass): + """ + This is the StringID class + + Author: Zheng, Lei (realthunder.dev@gmail.com) + Licence: LGPL + """ + + @constmethod + def isSame(self, other: "StringID") -> bool: + """ + Check if two StringIDs are the same + """ + ... + + Value: Final[int] = 0 + """Return the integer value of this ID""" + + Related: Final[List[Any]] = [] + """Return the related string IDs""" + + Data: Final[str] = "" + """Return the data associated with this ID""" + + IsBinary: Final[bool] = False + """Check if the data is binary,""" + + IsHashed: Final[bool] = False + """Check if the data is hash, if so 'Data' returns a base64 encoded string of the raw hash""" + + Index: int = 0 + """Geometry index. Only meaningful for geometry element name""" diff --git a/src/App/SuppressibleExtension.pyi b/src/App/SuppressibleExtension.pyi new file mode 100644 index 0000000000..2e6fa01d58 --- /dev/null +++ b/src/App/SuppressibleExtension.pyi @@ -0,0 +1,10 @@ +from DocumentObjectExtension import DocumentObjectExtension + + +class SuppressibleExtension(DocumentObjectExtension): + """ + Author: Florian Foinant-Willig (flachyjoe@users.sourceforge.net) + Licence: LGPL + Extension class which allows suppressing of document objects + """ + ...