Files
create/src/App/DocumentPy.xml
Zheng, Lei 94c228973d App: API changes for document recompute/save/restore/import/export
This patch adds support of recomputation with external linked object,
as well as external document auto loading and partial loading.

Application:

* Modified new/openDocument()/signalNewDocument to choose whether to
  signal GUI for creating a view for the document. This makes it possible
  to suppress view creation when opening external documents.

* New API openDocuments() which does the actual job of loading the
  document together with any external dependencies. There are afew
  extra arguments to allow setting FileName property differently from
  the actual file path, which are required when auto loading
  dependencies during document recovery (with future patch to
  Gui::DocumentRecovery)

* openDocumentPrivate() is an internal helper for opening individual
  document.

* New signalStart/FinishOpenDocument to be signaled before and after
  opening a document. There may be multiple depending documents actually
  opened in between these two signals.

* New signalBeforeRecomputeDocument signaled before recompute a
  document.

* New API addPendingDocument() for use by external capable link
  properties' to queue up external documents.

* isRestoring/isClosingAll(), for convenience status reporting.

Document:

* signalFinishImport/RestoreObjects, new signal triggered after imported
  or restored all input objects

* signalBeforeRecompute, signaled before start recomputing this document

* Modified signalRecomputed with additional recomputed objects, this is
  to make it more efficient for Gui::TreeWidget to check recomputation
  result.

* signalSkipRecompute, signal to inform which objects are skipped
  during recomputation because of their owner document SkipRecompute
  setting.

* restore/save/read/writeObjects() modified to suport partial
  loading. See [here](https://git.io/fj6PY) for more information.

* afterRestore(), internal function called to finish restore. The
  function is separated from restore() because there is quite a few
  critical steps needed to fully restore a document with external
  linking. See [here](https://git.io/fj6P4) for more information.

* DocumentP::_RecomputeLog is modified to store more accurate object
  recomputation error, including those happened during restore/import.

* isExporting(), new API for checking if an object is exporting.
  External linking properties will use this function to decide how to
  export.

* copyObject(), modified to support external linking objects, and
  accepts multiple input objects.

* moveObject(), modified to support arbitary object moves. The original
  implementation may cause crash if undo/redo is enabled. Furthermore,
  because the original information fakes the object's deletion to break
  its dependency, it does not work for objects that may auto delete their
  children when being deleted. The new implementation copy the object,
  and than paste it to the other document. It then deletes the input
  objects from the original document. In case of recursive move, it only
  deletes the depending object if it has an empty in list.

* importLinks(), new API to import any external object linked by the
  input objects into this document. It will auto correct all link
  references after importing.

* getDependencyList/_rebuildDependencyList(), these two APIs are unified
  and implemented by an internal function _buildDependencyList() with a
  new algorithm to handle external objects. The returned dependency list
  will now include objects from external documents. In case of cyclic
  dependencies, getDpendencyList() will report the actual objects
  involved in dependency loops.

* mustExecute(), new API to check if there are any object requires
  recomputation. This function will call _buildDependencyList() and
  check for external objects as well.

* addRecomputeObject(), new API for marking changes during document
  restore. It only marks the object but does not actually recompute
  them for performance reason. One use case is for geo feature to
  request for recomputation to generate geometry topological names.

* recompute(), support partial, external, and inverse dependency
  recomputation. Improve error handling during recomputation.
  See [here](https://git.io/fj6PO) for more information.

* _recomputeFeature(), suppoert user abort.

* getDependentDocuments/getInList(), new API to obtain an optional
  dependency sorted list of depending documents.

DocumentObject:

* Add various ObjectStatus flags

* isExporting/getExportName(), return a safe name for exporting, in the
  form of <ObjName>@<DocName>, which is guarrenteed to be unique.
  Various link property will save linked object using this name if the
  the linked object is exported together with the owner object, see
  [PropertyLinkBase::restoreLabelReference()](https://git.io/fj6XO)
  for more information.

* recomputeFeature(), add option to recompute this object together with
  all its dependent objects.

* canLoadPartial(), new API for [partial document loading](https://git.io/fj6PY).

MergeDocuments:

* Move object name mapping logic to various link properties. See

Base::Sequencer:

* Add new API checkAbort() for checking user abort.
2019-08-17 14:52:10 +02:00

334 lines
12 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="PropertyContainerPy"
Name="DocumentPy"
Twin="Document"
TwinPointer="Document"
Include="App/Document.h"
Namespace="App"
FatherInclude="App/PropertyContainerPy.h"
FatherNamespace="App">
<Documentation>
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />
<UserDocu>This is a Document class</UserDocu>
</Documentation>
<Methode Name="save">
<Documentation>
<UserDocu>Save the document to disk</UserDocu>
</Documentation>
</Methode>
<Methode Name="saveAs">
<Documentation>
<UserDocu>Save the document under a new name to disk</UserDocu>
</Documentation>
</Methode>
<Methode Name="saveCopy">
<Documentation>
<UserDocu>Save a copy of the document under a new name to disk</UserDocu>
</Documentation>
</Methode>
<Methode Name="load">
<Documentation>
<UserDocu>Load the document from the given path</UserDocu>
</Documentation>
</Methode>
<Methode Name="restore">
<Documentation>
<UserDocu>Restore the document from disk</UserDocu>
</Documentation>
</Methode>
<Methode Name="mergeProject">
<Documentation>
<UserDocu>Merges this document with another project file</UserDocu>
</Documentation>
</Methode>
<Methode Name="exportGraphviz">
<Documentation>
<UserDocu>Export the dependencies of the objects as graph</UserDocu>
</Documentation>
</Methode>
<Methode Name="openTransaction">
<Documentation>
<UserDocu>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.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="abortTransaction">
<Documentation>
<UserDocu>Abort an Undo/Redo transaction (rollback)</UserDocu>
</Documentation>
</Methode>
<Methode Name="commitTransaction">
<Documentation>
<UserDocu>Commit an Undo/Redo transaction</UserDocu>
</Documentation>
</Methode>
<Methode Name="addObject" Keyword="true">
<Documentation>
<UserDocu>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.</UserDocu>
</Documentation>
</Methode>
<Methode Name="removeObject">
<Documentation>
<UserDocu>Remove an object from the document</UserDocu>
</Documentation>
</Methode>
<Methode Name="copyObject">
<Documentation>
<UserDocu>
copyObject(object, with_dependencies=False)
Copy an object or objects 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.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="moveObject">
<Documentation>
<UserDocu>
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.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="importLinks">
<Documentation>
<UserDocu>
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.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="undo">
<Documentation>
<UserDocu>Undo one transaction</UserDocu>
</Documentation>
</Methode>
<Methode Name="redo">
<Documentation>
<UserDocu>Redo a previously undone transaction</UserDocu>
</Documentation>
</Methode>
<Methode Name="clearUndos">
<Documentation>
<UserDocu>Clear the undo stack of the document</UserDocu>
</Documentation>
</Methode>
<Methode Name="recompute">
<Documentation>
<UserDocu>recompute(objs=None): Recompute the document and returns the amount of recomputed features</UserDocu>
</Documentation>
</Methode>
<Methode Name="getObject">
<Documentation>
<UserDocu>Return the object with the given name</UserDocu>
</Documentation>
</Methode>
<Methode Name="getObjectsByLabel">
<Documentation>
<UserDocu>Return the objects with the given label name.
NOTE: It's possible that several objects have the same label name.</UserDocu>
</Documentation>
</Methode>
<Methode Name="findObjects">
<Documentation>
<UserDocu>findObjects([string (type)], [string (name)]) -&gt; list
Return a list of objects that match the specified type and name.
Both parameters are optional.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getLinksTo">
<Documentation>
<UserDocu>
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
</UserDocu>
</Documentation>
</Methode>
<Methode Name="supportedTypes">
<Documentation>
<UserDocu>A list of supported types of objects</UserDocu>
</Documentation>
</Methode>
<Methode Name="getTempFileName">
<Documentation>
<UserDocu>Returns a file name with path in the temp directory of the document.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getDependentDocuments">
<Documentation>
<UserDocu>
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
</UserDocu>
</Documentation>
</Methode>
<Attribute Name="DependencyGraph" ReadOnly="true">
<Documentation>
<UserDocu>The dependency graph as GraphViz text</UserDocu>
</Documentation>
<Parameter Name="DependencyGraph" Type="String" />
</Attribute>
<Attribute Name="ActiveObject" ReadOnly="true">
<Documentation>
<UserDocu>The active object of the document</UserDocu>
</Documentation>
<Parameter Name="ActiveObject" Type="Object" />
</Attribute>
<Attribute Name="Objects" ReadOnly="true">
<Documentation>
<UserDocu>The list of object handled by this document</UserDocu>
</Documentation>
<Parameter Name="Objects" Type="List" />
</Attribute>
<Attribute Name="TopologicalSortedObjects" ReadOnly="true">
<Documentation>
<UserDocu>The list of object of this document in topological sorted order</UserDocu>
</Documentation>
<Parameter Name="ToplogicalSortedObjects" Type="List" />
</Attribute>
<Attribute Name="RootObjects" ReadOnly="true">
<Documentation>
<UserDocu>The list of root object of this document</UserDocu>
</Documentation>
<Parameter Name="RootObjects" Type="List" />
</Attribute>
<Attribute Name="UndoMode" ReadOnly="false">
<Documentation>
<UserDocu>The Undo mode of the Document (0 = no Undo, 1 = Undo/Redo)</UserDocu>
</Documentation>
<Parameter Name="UndoMode" Type="Int" />
</Attribute>
<Attribute Name="UndoRedoMemSize" ReadOnly="true">
<Documentation>
<UserDocu>The size of the Undo stack in byte</UserDocu>
</Documentation>
<Parameter Name="UndoRedoMemSize" Type="Int" />
</Attribute>
<Attribute Name="UndoCount" ReadOnly="true">
<Documentation>
<UserDocu>Number of possible Undos</UserDocu>
</Documentation>
<Parameter Name="UndoCount" Type="Int" />
</Attribute>
<Attribute Name="RedoCount" ReadOnly="true">
<Documentation>
<UserDocu>Number of possible Redos</UserDocu>
</Documentation>
<Parameter Name="RedoCount" Type="Int"/>
</Attribute>
<Attribute Name="UndoNames" ReadOnly="true">
<Documentation>
<UserDocu>A list of Undo names</UserDocu>
</Documentation>
<Parameter Name="UndoNames" Type="List"/>
</Attribute>
<Attribute Name="RedoNames" ReadOnly="true">
<Documentation>
<UserDocu>A List of Redo names</UserDocu>
</Documentation>
<Parameter Name="RedoNames" Type="List"/>
</Attribute>
<Attribute Name="Name" ReadOnly="true">
<Documentation>
<UserDocu>The internal name of the document</UserDocu>
</Documentation>
<Parameter Name="Name" Type="String"/>
</Attribute>
<Attribute Name="RecomputesFrozen">
<Documentation>
<UserDocu>Returns or sets if automatic recomputes for this document are disabled.</UserDocu>
</Documentation>
<Parameter Name="RecomputesFrozen" Type="Boolean"/>
</Attribute>
<Attribute Name="HasPendingTransaction" ReadOnly="true">
<Documentation>
<UserDocu>Check if there is a pending transaction</UserDocu>
</Documentation>
<Parameter Name="HasPendingTransaction" Type="Boolean"/>
</Attribute>
<Attribute Name="InList" ReadOnly="true">
<Documentation>
<UserDocu>A list of all documents that link to this document.</UserDocu>
</Documentation>
<Parameter Name="InList" Type="List" />
</Attribute>
<Attribute Name="OutList" ReadOnly="true">
<Documentation>
<UserDocu>A list of all documents that this document links to.</UserDocu>
</Documentation>
<Parameter Name="OutList" Type="List" />
</Attribute>
<Attribute Name="Restoring" ReadOnly="true">
<Documentation>
<UserDocu>Indicate if the document is restoring</UserDocu>
</Documentation>
<Parameter Name="Restoring" Type="Boolean" />
</Attribute>
<Attribute Name="Partial" ReadOnly="true">
<Documentation>
<UserDocu>Indicate if the document is partially loaded</UserDocu>
</Documentation>
<Parameter Name="Partial" Type="Boolean" />
</Attribute>
<Attribute Name="Importing" ReadOnly="true">
<Documentation>
<UserDocu>Indicate if the document is importing. Note the document will also report Restoring while importing</UserDocu>
</Documentation>
<Parameter Name="Importing" Type="Boolean" />
</Attribute>
<Attribute Name="Recomputing" ReadOnly="true">
<Documentation>
<UserDocu>Indicate if the document is recomputing</UserDocu>
</Documentation>
<Parameter Name="Recomputing" Type="Boolean" />
</Attribute>
<Attribute Name="Transacting" ReadOnly="true">
<Documentation>
<UserDocu>Indicate whether the document is undoing/redoing</UserDocu>
</Documentation>
<Parameter Name="Transacting" Type="Boolean" />
</Attribute>
<Attribute Name="OldLabel" ReadOnly="true">
<Documentation>
<UserDocu>Contains the old label before change</UserDocu>
</Documentation>
<Parameter Name="OldLabel" Type="String"/>
</Attribute>
<CustomAttributes />
</PythonExport>
</GenerateModel>