FreeCAD C++
|
#include <App/Document.h>
The document class.
Public Member Functions | |
unsigned int | getMemSize (void) const |
returns the complete document memory consumption, including all managed DocObjects and Undo Redo. | |
void | renameObjectIdentifiers (const std::map< App::ObjectIdentifier, App::ObjectIdentifier > &paths, const std::function< bool(const App::DocumentObject *)> &selector=[](const App::DocumentObject *) { return true;}) |
Function called to signal that an object identifier has been renamed. | |
virtual | ~Document () |
Destruction. | |
File handling of the document | |
bool | save (void) |
Save the Document under a new Name. More... | |
bool | saveAs (const char *file) |
bool | saveCopy (const char *file) const |
void | restore (void) |
Restore the document from the file in Property Path. | |
void | exportObjects (const std::vector< App::DocumentObject * > &, std::ostream &) |
void | exportGraphviz (std::ostream &) const |
std::vector< App::DocumentObject * > | importObjects (Base::XMLReader &reader) |
bool | isSaved () const |
Opens the document from its file name. More... | |
const char * | getName () const |
Get the document name. | |
Object handling | |
DocumentObject * | addObject (const char *sType, const char *pObjectName=0, bool isNew=true) |
std::vector< DocumentObject * > | addObjects (const char *sType, const std::vector< std::string > &objectNames, bool isNew=true) |
void | removeObject (const char *sName) |
Remove a feature out of the document. | |
void | addObject (DocumentObject *, const char *pObjectName=0) |
DocumentObject * | copyObject (DocumentObject *obj, bool recursive=false) |
DocumentObject * | moveObject (DocumentObject *obj, bool recursive=false) |
DocumentObject * | getActiveObject (void) const |
Returns the active Object of this document. | |
DocumentObject * | getObject (const char *Name) const |
Returns a Object of this document. | |
bool | isIn (const DocumentObject *pFeat) const |
Returns true if the DocumentObject is contained in this document. | |
const char * | getObjectName (DocumentObject *pFeat) const |
Returns a Name of an Object or 0. | |
std::string | getUniqueObjectName (const char *Name) const |
Returns a Name of an Object or 0. | |
std::string | getStandardObjectName (const char *Name, int d) const |
Returns a name of the form prefix_number. d specifies the number of digits. | |
std::vector< DocumentObject * > | getObjects () const |
Returns a list of all Objects. | |
std::vector< DocumentObject * > | getObjectsOfType (const Base::Type &typeId) const |
std::vector< DocumentObject * > | getObjectsWithExtension (const Base::Type &typeId, bool derived=true) const |
Returns all object with given extensions. If derived=true also all objects with extensions derived from the given one. | |
std::vector< DocumentObject * > | findObjects (const Base::Type &typeId, const char *objname) const |
template<typename T > | |
std::vector< T * > | getObjectsOfType () const |
Returns an array with the correct types already. | |
int | countObjectsOfType (const Base::Type &typeId) const |
int | countObjects (void) const |
get the number of objects in the document | |
methods for modification and state handling | |
void | purgeTouched () |
Remove all modifications. After this call The document becomes Valid again. | |
bool | isTouched (void) const |
check if there is any touched object in this document | |
std::vector< App::DocumentObject * > | getTouched (void) const |
returns all touched objects | |
void | setClosable (bool) |
set the document to be closable, this is on by default. | |
bool | isClosable () const |
check whether the document can be closed | |
int | recompute () |
Recompute all touched features and return the number of recalculated features. | |
void | recomputeFeature (DocumentObject *Feat) |
Recompute only one feature. | |
const std::vector< App::DocumentObjectExecReturn * > & | getRecomputeLog (void) const |
get the error log from the recompute run | |
const char * | getErrorDescription (const App::DocumentObject *) const |
get the text of the error of a specified object | |
bool | testStatus (Status pos) const |
return the status bits | |
void | setStatus (Status pos, bool on) |
set the status bits | |
methods for the UNDO REDO and Transaction handling | |
void | setUndoMode (int iMode) |
switch the level of Undo/Redo | |
int | getUndoMode (void) const |
switch the level of Undo/Redo | |
void | setTransactionMode (int iMode) |
switch the transaction mode | |
void | openTransaction (const char *name=0) |
Open a new command Undo/Redo, an UTF-8 name can be specified. | |
void | commitTransaction () |
void | abortTransaction () |
Abort the actually running transaction. | |
bool | hasPendingTransaction () const |
Check if a transaction is open. | |
bool | isTransactionEmpty () const |
void | setUndoLimit (unsigned int UndoMemSize=0) |
Set the Undo limit in Byte! | |
unsigned int | getUndoMemSize (void) const |
Returns the actual memory consumption of the Undo redo stuff. | |
void | setMaxUndoStackSize (unsigned int UndoMaxStackSize=20) |
Set the Undo limit as stack size. | |
unsigned int | getMaxUndoStackSize (void) const |
Set the Undo limit as stack size. | |
void | clearUndos () |
Remove all stored Undos and Redos. | |
int | getAvailableUndos () const |
Returns the number of stored Undos. If greater than 0 Undo will be effective. | |
std::vector< std::string > | getAvailableUndoNames () const |
Returns a list of the Undo names. | |
bool | undo () |
Will UNDO one step, returns False if no undo was done (Undos == 0). | |
int | getAvailableRedos () const |
Returns the number of stored Redos. If greater than 0 Redo will be effective. | |
std::vector< std::string > | getAvailableRedoNames () const |
Returns a list of the Redo names. | |
bool | redo () |
Will REDO one step, returns False if no redo was done (Redos == 0). | |
bool | isPerformingTransaction () const |
returns true if the document is in an Transaction phase, e.g. currently performing a redo/undo or rollback | |
void | removePropertyOfObject (TransactionalObject *, const char *) |
dependency stuff | |
void | writeDependencyGraphViz (std::ostream &out) |
write GraphViz file | |
bool | checkOnCycle (void) |
checks if the graph is directed and has no cycles | |
std::vector< App::DocumentObject * > | getInList (const DocumentObject *me) const |
get a list of all objects linking to the given object | |
std::vector< App::DocumentObject * > | getDependencyList (const std::vector< App::DocumentObject * > &) const |
std::vector< App::DocumentObject * > | topologicalSort () const |
get a list of topological sorted objects (https://en.wikipedia.org/wiki/Topological_sorting) | |
std::vector< App::DocumentObject * > | getRootObjects () const |
get all root objects (objects no other one reference too) | |
std::vector< std::list< App::DocumentObject * > > | getPathsByOutList (const App::DocumentObject *from, const App::DocumentObject *to) const |
get all possible paths from one object to another following the OutList | |
![]() | |
PropertyContainer () | |
virtual | ~PropertyContainer () |
virtual Property * | getPropertyByName (const char *name) const |
find a property by its name | |
virtual const char * | getPropertyName (const Property *prop) const |
get the name of a property | |
virtual void | getPropertyMap (std::map< std::string, Property * > &Map) const |
get all properties of the class (including properties of the parent) | |
virtual void | getPropertyList (std::vector< Property * > &List) const |
get all properties of the class (including properties of the parent) | |
void | setPropertyStatus (unsigned char bit, bool value) |
set the Status bit of all properties at once | |
virtual short | getPropertyType (const Property *prop) const |
get the Type of a Property | |
virtual short | getPropertyType (const char *name) const |
get the Type of a named Property | |
virtual const char * | getPropertyGroup (const Property *prop) const |
get the Group of a Property | |
virtual const char * | getPropertyGroup (const char *name) const |
get the Group of a named Property | |
virtual const char * | getPropertyDocumentation (const Property *prop) const |
get the Group of a Property | |
virtual const char * | getPropertyDocumentation (const char *name) const |
get the Group of a named Property | |
bool | isReadOnly (const Property *prop) const |
check if the property is read-only | |
bool | isReadOnly (const char *name) const |
check if the named property is read-only | |
bool | isHidden (const Property *prop) const |
check if the property is hidden | |
bool | isHidden (const char *name) const |
check if the named property is hidden | |
![]() | |
virtual void | SaveDocFile (Writer &) const |
virtual void | RestoreDocFile (Reader &) |
![]() | |
BaseClass () | |
Construction. | |
virtual | ~BaseClass () |
Destruction. | |
Public Attributes | |
Properties | |
PropertyString | Label |
holds the long name of the document (utf-8 coded) | |
PropertyString | FileName |
full qualified (with path) file name (utf-8 coded) | |
PropertyString | CreatedBy |
creators name (utf-8) | |
PropertyString | CreationDate |
PropertyString | LastModifiedBy |
user last modified the document | |
PropertyString | LastModifiedDate |
PropertyString | Company |
company name UTF8(optional) | |
PropertyString | Comment |
long comment or description (UTF8 with line breaks) | |
PropertyString | Id |
Id e.g. Part number. | |
PropertyUUID | Uid |
unique identifier of the document | |
App::PropertyString | License |
App::PropertyString | LicenseURL |
License description/contract URL. | |
App::PropertyMap | Meta |
Meta descriptions. | |
App::PropertyMap | Material |
Material descriptions, used and defined in the Material module. | |
PropertyString | TransientDir |
read-only name of the temp dir created when the document is opened | |
PropertyLink | Tip |
Tip object of the document (if any) | |
PropertyString | TipName |
Tip object of the document (if any) | |
Signals of the document | |
boost::signals2::signal< void(const App::Document &, const App::Property &)> | signalBeforeChange |
signal before changing an doc property | |
boost::signals2::signal< void(const App::Document &, const App::Property &)> | signalChanged |
signal on changed doc property | |
boost::signals2::signal< void(const App::DocumentObject &)> | signalNewObject |
signal on new Object | |
boost::signals2::signal< void(const App::DocumentObject &)> | signalDeletedObject |
signal on deleted Object | |
boost::signals2::signal< void(const App::DocumentObject &, const App::Property &)> | signalBeforeChangeObject |
signal before changing an Object | |
boost::signals2::signal< void(const App::DocumentObject &, const App::Property &)> | signalChangedObject |
signal on changed Object | |
boost::signals2::signal< void(const App::DocumentObject &)> | signalRelabelObject |
signal on relabeled Object | |
boost::signals2::signal< void(const App::DocumentObject &)> | signalActivatedObject |
signal on activated Object | |
boost::signals2::signal< void(const App::DocumentObject &, Transaction *)> | signalTransactionAppend |
signal on created object | |
boost::signals2::signal< void(const App::DocumentObject &, Transaction *)> | signalTransactionRemove |
signal on removed object | |
boost::signals2::signal< void(const App::Document &)> | signalUndo |
signal on undo | |
boost::signals2::signal< void(const App::Document &)> | signalRedo |
signal on redo | |
boost::signals2::signal< void(Base::Writer &)> | signalSaveDocument |
boost::signals2::signal< void(Base::XMLReader &)> | signalRestoreDocument |
boost::signals2::signal< void(const std::vector< App::DocumentObject * > &, Base::Writer &)> | signalExportObjects |
boost::signals2::signal< void(const std::vector< App::DocumentObject * > &, Base::Writer &)> | signalExportViewObjects |
boost::signals2::signal< void(const std::vector< App::DocumentObject * > &, Base::XMLReader &)> | signalImportObjects |
boost::signals2::signal< void(const std::vector< App::DocumentObject * > &, Base::Reader &, const std::map< std::string, std::string > &)> | signalImportViewObjects |
boost::signals2::signal< void(const App::Document &, const std::string &)> | signalStartSave |
boost::signals2::signal< void(const App::Document &, const std::string &)> | signalFinishSave |
boost::signals2::signal< void(const App::Document &)> | signalRecomputed |
boost::signals2::signal< void(const App::DocumentObject &)> | signalRecomputedObject |
boost::signals2::signal< void(const App::Document &, std::string)> | signalOpenTransaction |
boost::signals2::signal< void(const App::Document &)> | signalCommitTransaction |
boost::signals2::signal< void(const App::Document &)> | signalAbortTransaction |
Protected Member Functions | |
Document (void) | |
Construction. | |
void | _checkTransaction (DocumentObject *pcObject) |
checks if a valid transaction is open | |
void | onBeforeChangeProperty (const TransactionalObject *Who, const Property *What) |
callback from the Document objects before property will be changed | |
void | onChangedProperty (const DocumentObject *Who, const Property *What) |
callback from the Document objects after property was changed | |
bool | _recomputeFeature (DocumentObject *Feat) |
void | _rebuildDependencyList (void) |
refresh the internal dependency graph | |
Additional Inherited Members | |
![]() | |
static std::string | encodeAttribute (const std::string &) |
Encodes an attribute upon saving. | |
|
protected |
helper which Recompute only this feature
DocumentObject* App::Document::addObject | ( | const char * | sType, |
const char * | pObjectName = 0 , |
||
bool | isNew = true |
||
) |
Add a feature of sType with sName (ASCII) to this document and set it active. Unicode names are set through the Label property.
sType | the type of created object |
pObjectName | if nonNULL use that name otherwise generate a new unique name based on the sType |
isNew | if false don't call the DocumentObject::setupObject() callback (default is true) |
void App::Document::addObject | ( | DocumentObject * | , |
const char * | pObjectName = 0 |
||
) |
Add an existing feature with sName (ASCII) to this document and set it active. Unicode names are set through the Label property. This is an overloaded function of the function above and can be used to create a feature outside and add it to the document afterwards.
std::vector<DocumentObject *> App::Document::addObjects | ( | const char * | sType, |
const std::vector< std::string > & | objectNames, | ||
bool | isNew = true |
||
) |
Add an array of features of the given types and names. Unicode names are set through the Label property.
sType | The type of created object |
objectNames | A list of object names |
isNew | If false don't call the DocumentObject::setupObject() callback (default is true) |
DocumentObject* App::Document::copyObject | ( | DocumentObject * | obj, |
bool | recursive = false |
||
) |
Copy an object from another document to this document If recursive is true then all objects this object depends on are copied as well. By default recursive is false. Returns the copy of the object or 0 if the creation failed.
std::vector<App::DocumentObject*> App::Document::getDependencyList | ( | const std::vector< App::DocumentObject * > & | ) | const |
Get a complete list of all objects the given objects depend on. The list also contains the given objects! deprecated! Use In- and OutList mimic in the DocumentObject instead!
bool App::Document::isSaved | ( | ) | const |
Opens the document from its file name.
Is the document already saved to a file?
bool App::Document::isTransactionEmpty | ( | ) | const |
Check if a transaction is open and its list is empty. If no transaction is open true is returned.
DocumentObject* App::Document::moveObject | ( | DocumentObject * | obj, |
bool | recursive = false |
||
) |
Move an object from another document to this document If recursive is true then all objects this object depends on are moved as well. By default recursive is false. Returns the moved object itself or 0 if the object is already part of this document..
bool App::Document::save | ( | void | ) |
App::PropertyString App::Document::License |
License string Holds the short license string for the Item, e.g. CC-BY for the Creative Commons license suit.
boost::signals2::signal<void (Base::Writer &)> App::Document::signalSaveDocument |
signal on load/save document this signal is given when the document gets streamed. you can use this hook to write additional information in the file (like the Gui::Document does).