The document class. More...
#include <Document.h>
Public Member Functions | |
unsigned int | getMemSize (void) const |
returns the complet document mermory consumption, including all managed DocObjects and Undo Redo. | |
virtual PyObject * | getPyObject (void) |
This method returns the Python wrapper for a C++ object. | |
virtual void | Restore (Base::XMLReader &reader) |
This method is used to restore properties from an XML document. | |
virtual void | Save (Base::Writer &writer) const |
This method is used to save properties to an XML document. | |
virtual | ~Document () |
Destruction. | |
methods for the UNDO REDO and Transaction handling | |
void | abortTransaction () |
Abort the actually running transaction. | |
void | clearUndos () |
Remove all stored Undos and Redos. | |
void | commitTransaction () |
std::vector< std::string > | getAvailableRedoNames () const |
Returns a list of the Redo names. | |
int | getAvailableRedos () const |
Returns the number of stored Redos. If greater than 0 Redo will be effective. | |
std::vector< std::string > | getAvailableUndoNames () const |
Returns a list of the Undo names. | |
int | getAvailableUndos () const |
Returns the number of stored Undos. If greater than 0 Undo will be effective. | |
unsigned int | getMaxUndoStackSize (void) const |
Set the Undo limit as stack size. | |
unsigned int | getUndoMemSize (void) const |
Returns the actual memory consumption of the Undo redo stuff. | |
int | getUndoMode (void) const |
switch the level of Undo/Redo | |
void | openTransaction (const char *name=0) |
Open a new command Undo/Redo, an UTF-8 name can be specified. | |
bool | redo () |
Will REDO one step, returns False if no redo was done (Redos == 0). | |
void | setMaxUndoStackSize (unsigned int UndoMaxStackSize=20) |
Set the Undo limit as stack size. | |
void | setTransactionMode (int iMode) |
switch the tranaction mode | |
void | setUndoLimit (unsigned int UndoMemSize=0) |
Set the Undo limit in Byte! | |
void | setUndoMode (int iMode) |
switch the level of Undo/Redo | |
bool | undo () |
Will UNDO one step, returns False if no undo was done (Undos == 0). | |
Object handling | |
DocumentObject * | addObject (const char *sType, const char *pObjectName=0) |
Add a feature of sType with sName (ASCII) to this document and set it active. Unicode names are set through the Label propery. | |
DocumentObject * | 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. | |
int | countObjects (void) const |
get the number of objects in the document | |
int | countObjectsOfType (const Base::Type &typeId) const |
DocumentObject * | getActiveObject (void) const |
Returns the active Object of this document. | |
DocumentObject * | getObject (const char *Name) const |
Returns a Object of this document. | |
const char * | getObjectName (DocumentObject *pFeat) const |
Returns a Name of an Object or 0. | |
std::vector< DocumentObject * > | getObjects () const |
Returns a list of all Objects. | |
template<typename T > | |
std::vector< T * > | getObjectsOfType () const |
Returns an array with the correct types already. | |
std::vector< DocumentObject * > | getObjectsOfType (const Base::Type &typeId) const |
std::string | getStandardObjectName (const char *Name, int d) const |
Returns a name of the form prefix_number. d specifies the number of digits. | |
std::string | getUniqueObjectName (const char *Name) const |
Returns a Name of an Object or 0. | |
DocumentObject * | 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. | |
void | remObject (const char *sName) |
Remove a feature out of the document. | |
dependency stuff | |
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 | |
void | writeDependencyGraphViz (std::ostream &out) |
write GraphViz file | |
File handling of the document | |
void | exportObjects (const std::vector< App::DocumentObject * > &, std::ostream &) |
const char * | getName () const |
Get the document name. | |
std::vector < App::DocumentObject * > | importObjects (std::istream &) |
bool | isSaved () const |
Opens the document from its file name. | |
void | restore (void) |
Restore the document from the file in Property Path. | |
bool | save (void) |
Save the Document under a new Name. | |
methods for modification and state handling | |
const char * | getErrorDescription (const App::DocumentObject *) const |
get the text of the error of a spezified object | |
const std::vector < App::DocumentObjectExecReturn * > & | getRecomputeLog (void) const |
get the error log from the recompute run | |
std::vector < App::DocumentObject * > | getTouched (void) const |
returns all touched objects | |
bool | isClosable () const |
check whether the document can be closed | |
bool | isTouched (void) const |
check if there is any touched object in this document | |
void | purgeTouched () |
Remove all modifications. After this call The document becomes again Valid. | |
void | recompute () |
Recompute all touched features. | |
void | recomputeFeature (DocumentObject *Feat) |
Recompute only one feature. | |
void | setClosable (bool) |
set the document to be closable, this is on by default. | |
Public Attributes | |
Properties | |
PropertyString | Comment |
PropertyString | Company |
PropertyString | CreatedBy |
creators name (utf-8) | |
PropertyString | CreationDate |
PropertyString | FileName |
full qualified (with path) file name (utf-8 coded) | |
PropertyString | Id |
PropertyString | Label |
holds the long name of the document (utf-8 coded) | |
PropertyString | LastModifiedBy |
PropertyString | LastModifiedDate |
PropertyString | TransientDir |
Signals of the document | |
boost::signal< void(const App::DocumentObject &)> | signalActivatedObject |
signal on activated Object | |
boost::signal< void(const App::DocumentObject &, const App::Property &)> | signalChangedObject |
signal on changed Object | |
boost::signal< void(const App::DocumentObject &)> | signalDeletedObject |
signal on deleted Object | |
boost::signal< void(const std::vector < App::DocumentObject * > &, Base::Writer &) | signalExportObjects ) |
boost::signal< void(const std::vector < App::DocumentObject * > &, Base::XMLReader &) | signalImportObjects ) |
boost::signal< void(const App::DocumentObject &)> | signalNewObject |
signal on new Object | |
boost::signal< void(const App::DocumentObject &)> | signalRenamedObject |
signal on renamed Object | |
boost::signal< void(Base::XMLReader &)> | signalRestoreDocument |
boost::signal< void(Base::Writer &)> | signalSaveDocument |
signal on load/save document this signal is given when the document gets streamed. | |
Protected Member Functions | |
void | _addObject (DocumentObject *pcObject, const char *pObjectName) |
void | _clearRedos () |
DocumentObject * | _copyObject (DocumentObject *obj, std::map< DocumentObject *, DocumentObject * > &, bool recursive=false) |
bool | _recomputeFeature (DocumentObject *Feat) |
helper which Recompute only this feature | |
void | _remObject (DocumentObject *pcObject) |
Remove an object out of the document (internal). | |
void | breakDependency (DocumentObject *pcObject, bool clear) |
Document (void) | |
Construction. | |
void | onBeforeChangeProperty (const DocumentObject *Who, const Property *What) |
callback from the Document objects before property will be changed | |
void | onChanged (const Property *prop) |
get called by the container when a property has changed | |
void | onChangedProperty (const DocumentObject *Who, const Property *What) |
callback from the Document objects after property was changed | |
Friends | |
class | Application |
class | DocumentObject |
because of transaction handling | |
class | Transaction |
class | TransactionObject |
The document class.
This is besides the Application class the most important class in FreeCAD It contains all the data of the opened, saved or newly created FreeCAD Document. The Document manage the Undo and Redo mechanism and the linking of documents.
Note: the documents are not free objects. They are completly handled by the App::Application. Only the Application can Open or destroy a document.
As the document is the main data structure of FreeCAD we have to take a close look on how Exceptions affect the integrity of the App::Document.
Undo Redo handling is one of the major mechanism of an document in terms of user friendliness and speed (no one will wait for Undo too long).
The FreeCAD document handles the dependencies of its DocumentObjects with an adjacence list. This gives the opportunity to calculate the shortest recompute path. Also enables more complicated dependencies beyond trees.
Definition at line 60 of file App/Document.h.
Document::~Document | ( | ) | [virtual] |
Destruction.
Definition at line 519 of file App/Document.cpp.
References clearUndos(), Base::Console(), getName(), App::PropertyString::getValue(), App::DocumentP::objectArray, App::DocumentP::objectMap, Py::Object::ptr(), Base::PyObjectBase::setInvalid(), and TransientDir.
Document::Document | ( | void | ) | [protected] |
Construction.
Definition at line 483 of file App/Document.cpp.
References ADD_PROPERTY_TYPE, Comment, Company, Base::Console(), CreatedBy, Base::FileInfo::createDirectory(), CreationDate, Base::TimeInfo::currentDateTimeString(), Base::FileInfo::exists(), FileName, Base::FileInfo::filePath(), App::GetApplication(), App::Application::getExecutableName(), Base::FileInfo::getTempPath(), Id, Label, LastModifiedBy, LastModifiedDate, App::Prop_None, App::Prop_ReadOnly, App::Prop_Transient, and TransientDir.
void Document::_addObject | ( | DocumentObject * | pcObject, | |
const char * | pObjectName | |||
) | [protected] |
Definition at line 1288 of file App/Document.cpp.
References App::DocumentP::activeTransaction, App::DocumentP::activeUndoTransaction, App::Transaction::addObjectDel(), App::Transaction::addObjectNew(), App::DocumentP::objectArray, App::DocumentP::objectMap, App::DocumentObject::pcNameInDocument, App::DocumentP::rollback, and signalNewObject.
Referenced by App::TransactionObject::applyNew(), and moveObject().
void Document::_clearRedos | ( | ) | [protected] |
Definition at line 300 of file App/Document.cpp.
Referenced by clearUndos(), and openTransaction().
DocumentObject * Document::_copyObject | ( | DocumentObject * | obj, | |
std::map< DocumentObject *, DocumentObject * > & | copy_map, | |||
bool | recursive = false | |||
) | [protected] |
Definition at line 1442 of file App/Document.cpp.
References App::PropertyContainer::addDynamicProperties(), addObject(), App::Property::Copy(), draftlibs::dxfLibrary::copy, App::PropertyContainer::getClassTypeId(), App::DocumentObject::getDocument(), Base::Type::getName(), App::DocumentObject::getNameInDocument(), App::PropertyContainer::getPropertyByName(), App::PropertyContainer::getPropertyMap(), App::Property::getTypeId(), App::PropertyContainer::getTypeId(), and App::DocumentObject::purgeTouched().
Referenced by copyObject().
bool Document::_recomputeFeature | ( | DocumentObject * | Feat | ) | [protected] |
helper which Recompute only this feature
Definition at line 1166 of file App/Document.cpp.
References Base::Console(), App::DocumentObject::getNameInDocument(), App::DocumentObject::recompute(), Base::Exception::ReportException(), App::DocumentObject::resetError(), App::DocumentObject::setError(), App::DocumentObject::StdReturn, Base::Exception::what(), App::DocumentObjectExecReturn::Which, and App::DocumentObjectExecReturn::Why.
Referenced by recompute(), and recomputeFeature().
void Document::_remObject | ( | DocumentObject * | pcObject | ) | [protected] |
Remove an object out of the document (internal).
Definition at line 1366 of file App/Document.cpp.
References App::DocumentP::activeObject, App::DocumentP::activeTransaction, App::DocumentP::activeUndoTransaction, App::Transaction::addObjectDel(), App::Transaction::addObjectNew(), App::DocumentObject::getNameInDocument(), App::DocumentP::objectArray, App::DocumentP::objectMap, App::DocumentP::rollback, and signalDeletedObject.
Referenced by App::TransactionObject::applyDel(), and moveObject().
void Document::abortTransaction | ( | ) |
Abort the actually running transaction.
Definition at line 321 of file App/Document.cpp.
References App::DocumentP::activeUndoTransaction, App::Transaction::apply(), and App::DocumentP::rollback.
Referenced by Gui::Document::abortCommand(), and App::DocumentPy::abortTransaction().
DocumentObject * Document::addObject | ( | const char * | sType, | |
const char * | pObjectName = 0 | |||
) |
Add a feature of sType with sName (ASCII) to this document and set it active. Unicode names are set through the Label propery.
Definition at line 1232 of file App/Document.cpp.
References App::DocumentP::activeObject, App::DocumentP::activeTransaction, App::DocumentP::activeUndoTransaction, App::Transaction::addObjectDel(), App::Transaction::addObjectNew(), Base::Type::createInstanceByName(), App::PropertyContainer::getClassTypeId(), Base::BaseClass::getTypeId(), getUniqueObjectName(), App::DocumentObject::Label, App::DocumentP::objectArray, App::DocumentP::objectMap, App::DocumentObject::pcNameInDocument, App::DocumentP::rollback, App::DocumentObject::setDocument(), App::PropertyString::setValue(), signalActivatedObject, signalNewObject, and App::DocumentObject::StatusBits.
Referenced by _copyObject(), CmdSandboxMeshLoaderFuture::activated(), CmdSandboxMeshLoaderBoost::activated(), CmdSandboxMeshLoader::activated(), CmdMeshFromGeometry::activated(), App::DocumentPy::addObject(), App::DocumentObjectGroup::addObject(), PartGui::CrossSections::apply(), Gui::PointMarker::customEvent(), Sandbox::CustomAddObjectEvent::execute(), importer(), Part::ImportIgesParts(), Gui::MergeDocuments::importObjects(), importObjects(), Part::ImportStepParts(), insert(), open(), Restore(), MeshGui::Annotation::show(), show(), Gui::Application::sInsert(), and MeshGui::ViewProviderMesh::splitMesh().
void Document::breakDependency | ( | DocumentObject * | pcObject, | |
bool | clear | |||
) | [protected] |
Definition at line 1398 of file App/Document.cpp.
References App::PropertyLinkList::getClassTypeId(), App::PropertyLinkSub::getClassTypeId(), App::PropertyLink::getClassTypeId(), App::Property::getContainer(), App::PropertyLinkSub::getValue(), App::PropertyLink::getValue(), App::PropertyLinkList::getValues(), App::DocumentP::objectMap, App::PropertyLinkSub::setValue(), App::PropertyLink::setValue(), and App::PropertyLinkList::setValues().
Referenced by moveObject(), and remObject().
bool Document::checkOnCycle | ( | void | ) |
checks if the graph is directed and has no cycles
Definition at line 208 of file App/Document.cpp.
void Document::clearUndos | ( | ) |
Remove all stored Undos and Redos.
Definition at line 335 of file App/Document.cpp.
References _clearRedos(), App::DocumentP::activeUndoTransaction, and commitTransaction().
Referenced by App::DocumentPy::clearUndos(), restore(), setUndoMode(), and ~Document().
void Document::commitTransaction | ( | ) |
Definition at line 308 of file App/Document.cpp.
References App::DocumentP::activeUndoTransaction, and App::DocumentP::UndoMaxStackSize.
Referenced by MeshPartGui::Tessellation::accept(), PartDesignGui::ChamferWidget::accept(), PartGui::Mirroring::accept(), PartGui::DlgRevolution::accept(), PartGui::DlgFilletEdges::accept(), PartGui::DlgBooleanOperation::accept(), PartGui::DlgExtrusion::apply(), clearUndos(), Gui::Document::commitCommand(), App::DocumentPy::commitTransaction(), openTransaction(), redo(), and undo().
DocumentObject * 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.
Definition at line 1519 of file App/Document.cpp.
References _copyObject(), and draftlibs::dxfLibrary::copy.
Referenced by StdCmdDDuplicateSelection::activated(), and App::DocumentPy::copyObject().
int Document::countObjects | ( | void | ) | const |
get the number of objects in the document
Definition at line 1045 of file App/Document.cpp.
References App::DocumentP::objectArray.
Referenced by Gui::Application::open(), and Gui::TaskView::TaskWatcherCommandsEmptyDoc::shouldShow().
int Document::countObjectsOfType | ( | const Base::Type & | typeId | ) | const |
Definition at line 1648 of file App/Document.cpp.
References App::DocumentP::objectMap.
Referenced by PartGui::Mirroring::accept(), StdCmdMeasureDistance::isActive(), CmdRaytracingWriteView::isActive(), CmdShapeInfo::isActive(), CmdMeshFillInteractiveHole::isActive(), CmdMeshRemoveCompByHand::isActive(), CmdMeshRemoveComponents::isActive(), CmdMeshEvaluateFacet::isActive(), CmdMeshEvaluation::isActive(), CmdMeshVertexCurvatureInfo::isActive(), and CmdInspectElement::isActive().
void Document::exportObjects | ( | const std::vector< App::DocumentObject * > & | obj, | |
std::ostream & | out | |||
) |
Definition at line 711 of file App/Document.cpp.
References Base::Writer::decInd(), Base::Writer::incInd(), Base::Writer::ind(), Base::ZipWriter::putNextEntry(), signalExportObjects, Base::ZipWriter::Stream(), and Base::ZipWriter::writeFiles().
Referenced by Gui::MainWindow::createMimeDataFromSelection().
DocumentObject * Document::getActiveObject | ( | void | ) | const |
Returns the active Object of this document.
Definition at line 1568 of file App/Document.cpp.
References App::DocumentP::activeObject.
Referenced by Gui::DocumentPy::activeObject(), Gui::ViewProviderIndex::data(), Gui::DocumentPy::getActiveObject(), App::DocumentPy::getActiveObject(), and Gui::Command::isActiveObjectValid().
std::vector< std::string > Document::getAvailableRedoNames | ( | ) | const |
Returns a list of the Redo names.
Definition at line 279 of file App/Document.cpp.
Referenced by App::DocumentPy::getRedoNames(), and Gui::Document::getRedoVector().
int Document::getAvailableRedos | ( | ) | const |
Returns the number of stored Redos. If greater than 0 Redo will be effective.
Definition at line 366 of file App/Document.cpp.
Referenced by Gui::View3DInventor::onHasMsg().
std::vector< std::string > Document::getAvailableUndoNames | ( | ) | const |
Returns a list of the Undo names.
Definition at line 269 of file App/Document.cpp.
References App::DocumentP::activeUndoTransaction, and App::Transaction::Name.
Referenced by App::DocumentPy::getUndoNames(), and Gui::Document::getUndoVector().
int Document::getAvailableUndos | ( | ) | const |
Returns the number of stored Undos. If greater than 0 Undo will be effective.
Definition at line 358 of file App/Document.cpp.
References App::DocumentP::activeUndoTransaction.
Referenced by Gui::View3DInventor::onHasMsg().
const char * Document::getErrorDescription | ( | const App::DocumentObject * | Obj | ) | const |
get the text of the error of a spezified object
Definition at line 1157 of file App/Document.cpp.
std::vector< App::DocumentObject * > Document::getInList | ( | const DocumentObject * | me | ) | const |
get a list of all objects linking to the given object
Definition at line 1050 of file App/Document.cpp.
References App::DocumentP::objectMap, and result.
unsigned int Document::getMaxUndoStackSize | ( | void | ) | const |
Set the Undo limit as stack size.
Definition at line 399 of file App/Document.cpp.
References App::DocumentP::UndoMaxStackSize.
unsigned int Document::getMemSize | ( | void | ) | const [virtual] |
returns the complet document mermory consumption, including all managed DocObjects and Undo Redo.
Reimplemented from App::PropertyContainer.
Definition at line 819 of file App/Document.cpp.
References getUndoMemSize(), and App::DocumentP::objectArray.
const char * Document::getName | ( | void | ) | const |
Get the document name.
Label is the visible name of a document shown e.g.
in the windows title or in the tree view. The label almost (but not always e.g. if you manually change it) matches with the file name where the document is stored to. In contrast to Label the method getName() returns the internal name of the document that only matches with Label when loading or creating a document because then both are set to the same value. Since the internal name cannot be changed during runtime it must differ from the Label after saving the document the first time or saving it under a new file name. @ note More than one document can have the same label name. @ note The internal is always guaranteed to be unique because Application::newDocument() checks for a document with the same name and makes it unique if needed. Hence you cannot rely on that the internal name matches with the name you passed to Application::newDoument(). You should use the method getName() instead.
Definition at line 1004 of file App/Document.cpp.
References App::GetApplication(), and App::Application::getDocumentName().
Referenced by StdCmdHideObjects::activated(), StdCmdShowObjects::activated(), StdCmdToggleObjects::activated(), CmdPartShapeFromMesh::activated(), StdCmdSelectAll::activated(), StdCmdExport::activated(), StdCmdImport::activated(), CmdSandboxMeshTestJob::activated(), CmdPartExport::activated(), CmdPartImport::activated(), CmdFemCreateFromShape::activated(), PartGui::CrossSections::apply(), Gui::ViewProviderVRMLObject::attach(), RobotGui::ViewProviderTrajectory::attach(), RobotGui::ViewProviderRobotObject::attach(), Gui::ViewProviderMeasureDistance::attach(), Gui::ViewProviderGeometryObject::attach(), Gui::ViewProviderAnnotation::attach(), Gui::SelectionSingleton::clearSelection(), PartGui::ViewProviderPartBase::computeEdges(), PartGui::ViewProviderPartBase::computeFaces(), PartGui::ViewProviderPartBase::computeVertices(), Gui::TreeWidget::dropEvent(), PartGui::DlgExtrusion::findShapes(), Gui::View3DInventorPy::getObjectInfo(), Gui::View3DInventorPy::getObjectsInfo(), Gui::SoFCUnifiedSelection::handleEvent(), Gui::MainWindow::loadUrls(), SketcherGui::TaskSketcherConstrains::on_listWidgetConstraints_itemSelectionChanged(), Gui::TreeWidget::onCreateGroup(), Gui::Application::onLastWindowClosed(), Gui::View3DInventor::onRename(), SketcherGui::TaskSketcherConstrains::onSelectionChanged(), PartGui::FaceColors::onSelectionChanged(), Gui::Application::open(), DrawSketchHandlerFillet::releaseButton(), Gui::SelectionSingleton::sAddSelection(), Gui::Document::save(), Gui::DocumentItem::selectItems(), Gui::Application::setActiveDocument(), Gui::Application::sExport(), Gui::SelectionSingleton::slotDeletedObject(), Gui::Application::slotDeleteDocument(), Gui::SelectionSingleton::slotRenamedObject(), Gui::SelectionSingleton::sRemoveSelection(), SketcherGui::ViewProviderSketch::unsetEdit(), Gui::ViewProviderInventorObject::updateData(), Gui::DocumentItem::updateSelection(), and ~Document().
DocumentObject * Document::getObject | ( | const char * | Name | ) | const |
Returns a Object of this document.
Definition at line 1573 of file App/Document.cpp.
References App::DocumentP::objectMap.
Referenced by PartGui::DlgBooleanOperation::accept(), CmdMeshToolMesh::activated(), Sketcher::SketchObjectPy::addExternal(), Gui::SelectionSingleton::addSelection(), PartGui::DlgExtrusion::apply(), Gui::SoFCUnifiedSelection::doAction(), App::DocumentPy::getCustomAttributes(), Gui::SelectionObject::getObject(), App::DocumentPy::getObject(), App::DocumentObjectGroup::getObject(), Gui::Command::getObject(), Gui::Document::getViewProviderByName(), Gui::Command::hasObject(), Gui::MergeDocuments::importObjects(), importObjects(), App::DocumentPy::removeObject(), App::PropertyLinkSubList::Restore(), App::PropertyLinkList::Restore(), Restore(), App::DocumentPy::setCustomAttributes(), Gui::DocumentPy::setEdit(), and Gui::SelectionSingleton::setPreselect().
const char * Document::getObjectName | ( | DocumentObject * | pFeat | ) | const |
Returns a Name of an Object or 0.
Definition at line 1585 of file App/Document.cpp.
References App::DocumentP::objectMap.
std::vector< DocumentObject * > Document::getObjects | ( | ) | const |
Returns a list of all Objects.
Definition at line 1633 of file App/Document.cpp.
References App::DocumentP::objectArray.
Referenced by Gui::ViewProviderDocumentObject::findFrontRootOfType(), App::DocumentPy::getObjects(), App::DocumentPy::getObjectsByLabel(), getStandardObjectName(), Gui::ObjectLabelObserver::slotRelabelObject(), and InspectionGui::VisualInspection::VisualInspection().
std::vector< T * > Document::getObjectsOfType | ( | ) | const [inline] |
Returns an array with the correct types already.
Definition at line 289 of file App/Document.h.
References Py::type().
std::vector< DocumentObject * > Document::getObjectsOfType | ( | const Base::Type & | typeId | ) | const |
Definition at line 1638 of file App/Document.cpp.
References App::DocumentP::objectArray.
Referenced by StdCmdHideObjects::activated(), StdCmdShowObjects::activated(), StdCmdToggleObjects::activated(), StdCmdSelectAll::activated(), CmdSketcherMapSketch::activated(), CmdRaytracingNewPartSegment::activated(), CmdDrawingNewView::activated(), Gui::Application::exportTo(), App::DocumentPy::findObjects(), PartDesignGui::ChamferWidget::findShapes(), PartGui::DlgFilletEdges::findShapes(), PartGui::DlgExtrusion::findShapes(), App::DocumentObjectGroup::getGroupOfObject(), and MeshGui::Annotation::show().
PyObject * Document::getPyObject | ( | void | ) | [virtual] |
This method returns the Python wrapper for a C++ object.
It's in the responsibility of the programmer to do the correct reference counting. Basically there are two ways how to implement that: Either always return a new Python object then reference counting is not a matter or return always the same Python object then the reference counter must be incremented by one. However, it's absolutely forbidden to return always the same Python object without incrementing the reference counter.
The default implementation returns 'None'.
Reimplemented from Base::BaseClass.
Definition at line 1659 of file App/Document.cpp.
References Py::new_reference_to().
Referenced by Gui::DocumentPy::getDocument(), App::DocumentObjectPy::getDocument(), App::Application::newDocument(), and App::Application::setActiveDocument().
const std::vector<App::DocumentObjectExecReturn*>& App::Document::getRecomputeLog | ( | void | ) | const [inline] |
get the error log from the recompute run
Definition at line 189 of file App/Document.h.
std::string Document::getStandardObjectName | ( | const char * | Name, | |
int | d | |||
) | const |
Returns a name of the form prefix_number. d specifies the number of digits.
Definition at line 1620 of file App/Document.cpp.
References getObjects(), and Base::Tools::getUniqueName().
vector< DocumentObject * > Document::getTouched | ( | void | ) | const |
returns all touched objects
Definition at line 1024 of file App/Document.cpp.
References App::DocumentP::objectArray, and result.
unsigned int Document::getUndoMemSize | ( | void | ) | const |
Returns the actual memory consumption of the Undo redo stuff.
Definition at line 384 of file App/Document.cpp.
References App::DocumentP::UndoMemSize.
Referenced by getMemSize().
int Document::getUndoMode | ( | void | ) | const |
switch the level of Undo/Redo
Definition at line 379 of file App/Document.cpp.
References App::DocumentP::iUndoMode.
Referenced by Gui::ViewProviderPythonFeatureObserver::slotDeleteObject().
std::string Document::getUniqueObjectName | ( | const char * | Name | ) | const |
Returns a Name of an Object or 0.
Definition at line 1596 of file App/Document.cpp.
References Base::Tools::getIdentifier(), Base::Tools::getUniqueName(), and App::DocumentP::objectMap.
Referenced by PartDesignGui::ChamferWidget::accept(), PartGui::DlgRevolution::accept(), PartGui::DlgPrimitives::accept(), PartGui::DlgFilletEdges::accept(), PartGui::DlgBooleanOperation::accept(), CmdPartShapeFromMesh::activated(), addObject(), PartGui::DlgExtrusion::apply(), Gui::Command::getUniqueObjectName(), moveObject(), and MeshGui::DlgRegularSolidImp::on_createSolidButton_clicked().
std::vector< App::DocumentObject * > Document::importObjects | ( | std::istream & | input | ) |
Definition at line 761 of file App/Document.cpp.
References addObject(), Base::Console(), Base::XMLReader::DocumentSchema, Base::XMLReader::getAttribute(), Base::XMLReader::getAttributeAsInteger(), App::DocumentObject::getNameInDocument(), getObject(), Base::XMLReader::readElement(), Base::XMLReader::readEndElement(), Base::XMLReader::readFiles(), App::PropertyContainer::Restore(), signalImportObjects, App::DocumentObject::StatusBits, and Py::type().
bool Document::isClosable | ( | ) | const |
check whether the document can be closed
Definition at line 1040 of file App/Document.cpp.
References App::DocumentP::closable.
bool Document::isSaved | ( | ) | const |
Opens the document from its file name.
Is the document already saved to a file
Definition at line 985 of file App/Document.cpp.
References FileName, and App::PropertyString::getValue().
Referenced by Gui::Document::save().
bool Document::isTouched | ( | void | ) | const |
check if there is any touched object in this document
Definition at line 1016 of file App/Document.cpp.
References App::DocumentP::objectArray.
Referenced by Gui::PropertyEditor::PropertyEditor::closeEditor(), and StdCmdRefresh::isActive().
DocumentObject * 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..
Definition at line 1526 of file App/Document.cpp.
References _addObject(), _remObject(), breakDependency(), App::PropertyContainer::getClassTypeId(), App::DocumentObject::getDocument(), App::DocumentObject::getNameInDocument(), App::PropertyContainer::getPropertyMap(), getUniqueObjectName(), and App::DocumentObject::setDocument().
Referenced by App::DocumentPy::moveObject().
void Document::onBeforeChangeProperty | ( | const DocumentObject * | Who, | |
const Property * | What | |||
) | [protected] |
callback from the Document objects before property will be changed
Definition at line 411 of file App/Document.cpp.
References App::DocumentP::activeUndoTransaction, App::Transaction::addObjectChange(), and App::DocumentP::rollback.
void Document::onChanged | ( | const Property * | ) | [protected, virtual] |
get called by the container when a property has changed
Reimplemented from App::PropertyContainer.
Definition at line 404 of file App/Document.cpp.
References App::GetApplication(), Label, and App::Application::signalRelabelDocument.
void Document::onChangedProperty | ( | const DocumentObject * | Who, | |
const Property * | What | |||
) | [protected] |
callback from the Document objects after property was changed
Definition at line 417 of file App/Document.cpp.
References App::DocumentP::activeTransaction, App::Transaction::addObjectChange(), App::DocumentP::rollback, and signalChangedObject.
void Document::openTransaction | ( | const char * | name = 0 |
) |
Open a new command Undo/Redo, an UTF-8 name can be specified.
Definition at line 287 of file App/Document.cpp.
References _clearRedos(), App::DocumentP::activeUndoTransaction, commitTransaction(), App::DocumentP::iUndoMode, App::Transaction::Name, and Transaction.
Referenced by MeshPartGui::Tessellation::accept(), PartDesignGui::ChamferWidget::accept(), PartGui::Mirroring::accept(), PartGui::DlgRevolution::accept(), PartGui::DlgFilletEdges::accept(), PartGui::DlgBooleanOperation::accept(), PartGui::DlgExtrusion::apply(), Gui::Document::openCommand(), and App::DocumentPy::openTransaction().
void Document::purgeTouched | ( | ) |
Remove all modifications. After this call The document becomes again Valid.
Remove all modifications. After this call The document becomes valid again.
Definition at line 1010 of file App/Document.cpp.
References App::DocumentP::objectArray.
void Document::recompute | ( | ) |
Recompute all touched features.
Definition at line 1066 of file App/Document.cpp.
References _recomputeFeature(), App::DocumentObject::getNameInDocument(), App::DocumentObject::isTouched(), App::DocumentObject::mustExecute(), App::DocumentP::objectMap, TestApp::Test(), and App::DocumentP::vertexMap.
Referenced by InspectionGui::VisualInspection::accept(), PartGui::LoftWidget::accept(), PartDesignGui::ChamferWidget::accept(), PartGui::Mirroring::accept(), PartGui::DlgRevolution::accept(), PartGui::DlgFilletEdges::accept(), PartGui::DlgBooleanOperation::accept(), PartGui::DlgExtrusion::apply(), Gui::PropertyEditor::PropertyEditor::closeEditor(), Sandbox::CustomRecomputeEvent::execute(), importer(), insert(), MeshGui::DlgEvaluateMeshImp::on_repairAllTogether_clicked(), MeshGui::DlgEvaluateMeshImp::on_repairDegeneratedButton_clicked(), MeshGui::DlgEvaluateMeshImp::on_repairDuplicatedFacesButton_clicked(), MeshGui::DlgEvaluateMeshImp::on_repairDuplicatedPointsButton_clicked(), MeshGui::DlgEvaluateMeshImp::on_repairFoldsButton_clicked(), MeshGui::DlgEvaluateMeshImp::on_repairIndicesButton_clicked(), MeshGui::DlgEvaluateMeshImp::on_repairNonmanifoldsButton_clicked(), MeshGui::DlgEvaluateMeshImp::on_repairOrientationButton_clicked(), MeshGui::DlgEvaluateMeshImp::on_repairSelfIntersectionButton_clicked(), Gui::TreeWidget::onFinishEditing(), open(), App::DocumentPy::recompute(), show(), Gui::Application::sInsert(), and SketcherGui::ViewProviderSketch::unsetEdit().
void Document::recomputeFeature | ( | DocumentObject * | Feat | ) |
Recompute only one feature.
Definition at line 1222 of file App/Document.cpp.
References _recomputeFeature().
bool Document::redo | ( | void | ) |
Will REDO one step, returns False if no redo was done (Redos == 0).
Definition at line 245 of file App/Document.cpp.
References App::DocumentP::activeUndoTransaction, commitTransaction(), App::DocumentP::iUndoMode, App::Transaction::Name, and Transaction.
Referenced by App::DocumentPy::redo(), and Gui::Document::redo().
void Document::remObject | ( | const char * | sName | ) |
Remove a feature out of the document.
Remove an object out of the document.
Definition at line 1309 of file App/Document.cpp.
References App::DocumentP::activeObject, App::DocumentP::activeTransaction, App::DocumentP::activeUndoTransaction, App::Transaction::addObjectDel(), App::Transaction::addObjectNew(), breakDependency(), App::DocumentP::objectArray, App::DocumentP::objectMap, App::DocumentP::rollback, signalDeletedObject, and App::DocumentP::vertexMap.
Referenced by Sandbox::CustomRemoveObjectEvent::execute(), and App::DocumentPy::removeObject().
void Document::Restore | ( | Base::XMLReader & | ) | [virtual] |
This method is used to restore properties from an XML document.
It uses the XMLReader class, which bases on SAX, to read the in Save() written information. Again the Vector as an example:
void PropertyVector::Restore(Base::XMLReader &reader) { // read my Element reader.readElement("PropertyVector"); // get the value of my Attribute _cVec.x = (float)reader.getAttributeAsFloat("valueX"); _cVec.y = (float)reader.getAttributeAsFloat("valueY"); _cVec.z = (float)reader.getAttributeAsFloat("valueZ"); }
Reimplemented from App::PropertyContainer.
Definition at line 600 of file App/Document.cpp.
References addObject(), Base::Console(), Base::XMLReader::DocumentSchema, FileName, App::GetApplication(), Base::XMLReader::getAttribute(), Base::XMLReader::getAttributeAsInteger(), App::Application::getExecutableName(), getObject(), Base::FileInfo::getTempPath(), App::PropertyString::getValue(), Id, Label, Base::XMLReader::readElement(), Base::XMLReader::readEndElement(), App::PropertyContainer::Restore(), App::PropertyString::setValue(), App::DocumentObject::StatusBits, TransientDir, and Py::type().
Referenced by restore().
void Document::restore | ( | void | ) |
Restore the document from the file in Property Path.
Definition at line 937 of file App/Document.cpp.
References App::DocumentP::activeObject, clearUndos(), Base::Console(), Sketcher::end, DrawingExample::file, FileName, App::GetApplication(), App::PropertyString::getValue(), App::DocumentP::objectArray, App::DocumentP::objectMap, Restore(), signalDeletedObject, App::Application::signalRestoreDocument, signalRestoreDocument, and Base::Exception::what().
Referenced by App::Application::openDocument(), and App::DocumentPy::restore().
void Document::Save | ( | Base::Writer & | ) | const [virtual] |
This method is used to save properties to an XML document.
A good example you'll find in PropertyStandard.cpp, e.g. the vector:
void PropertyVector::Save (Writer &writer) const { writer << writer.ind() << "<PropertyVector valueX=\"" << _cVec.x << "\" valueY=\"" << _cVec.y << "\" valueZ=\"" << _cVec.z <<"\"/>" << endl; }
The writer.ind() expression writes the indention, just for pretty printing of the XML. As you see, the writing of the XML document is not done with a DOM implementation because of performance reasons. Therefore the programmer has to take care that a valid XML document is written. This means closing tags and writing UTF-8.
Reimplemented from App::PropertyContainer.
Definition at line 557 of file App/Document.cpp.
References Base::Writer::decInd(), Base::Writer::incInd(), Base::Writer::ind(), App::DocumentP::objectArray, and Base::Writer::Stream().
Referenced by save().
bool Document::save | ( | void | ) |
Save the Document under a new Name.
Save the document to the file in Property Path
Definition at line 838 of file App/Document.cpp.
References Base::Console(), Base::Uuid::CreateUuid(), Base::TimeInfo::currentDateTimeString(), Base::FileInfo::deleteFile(), DrawingExample::file, FileName, Base::FileInfo::filePath(), App::GetApplication(), App::Application::GetParameterGroupByPath(), App::PropertyString::getValue(), Py::int, Base::FileInfo::lastModified(), LastModifiedDate, Base::ZipWriter::putNextEntry(), Base::FileInfo::renameFile(), Save(), Base::ZipWriter::setComment(), Base::ZipWriter::setLevel(), App::PropertyString::setValue(), App::Application::signalSaveDocument, signalSaveDocument, and Base::ZipWriter::writeFiles().
void Document::setClosable | ( | bool | c | ) |
set the document to be closable, this is on by default.
Definition at line 1035 of file App/Document.cpp.
References App::DocumentP::closable.
void Document::setMaxUndoStackSize | ( | unsigned int | UndoMaxStackSize = 20 |
) |
Set the Undo limit as stack size.
Definition at line 394 of file App/Document.cpp.
References App::DocumentP::UndoMaxStackSize.
Referenced by Gui::Document::Document().
void Document::setTransactionMode | ( | int | iMode | ) |
switch the tranaction mode
Definition at line 424 of file App/Document.cpp.
References App::DocumentP::iTransactionMode.
void Document::setUndoLimit | ( | unsigned int | UndoMemSize = 0 |
) |
Set the Undo limit in Byte!
Definition at line 389 of file App/Document.cpp.
References App::DocumentP::UndoMemSize.
void Document::setUndoMode | ( | int | iMode | ) |
switch the level of Undo/Redo
Definition at line 371 of file App/Document.cpp.
References clearUndos(), and App::DocumentP::iUndoMode.
Referenced by Gui::Document::Document(), and App::DocumentPy::setUndoMode().
bool Document::undo | ( | void | ) |
Will UNDO one step, returns False if no undo was done (Undos == 0).
Definition at line 219 of file App/Document.cpp.
References App::DocumentP::activeUndoTransaction, commitTransaction(), App::DocumentP::iUndoMode, App::Transaction::Name, and Transaction.
Referenced by App::DocumentPy::undo(), and Gui::Document::undo().
void Document::writeDependencyGraphViz | ( | std::ostream & | out | ) |
write GraphViz file
Definition at line 163 of file App/Document.cpp.
Referenced by App::DocumentPy::getDependencyGraph().
friend class Application [friend] |
Definition at line 247 of file App/Document.h.
friend class DocumentObject [friend] |
because of transaction handling
Definition at line 249 of file App/Document.h.
friend class Transaction [friend] |
Definition at line 250 of file App/Document.h.
Referenced by openTransaction(), redo(), and undo().
friend class TransactionObject [friend] |
Definition at line 251 of file App/Document.h.
Definition at line 77 of file App/Document.h.
Referenced by Gui::Dialog::DlgProjectInformationImp::accept(), Gui::Dialog::DlgProjectInformationImp::DlgProjectInformationImp(), and Document().
Definition at line 76 of file App/Document.h.
Referenced by Gui::Dialog::DlgProjectInformationImp::accept(), Gui::Dialog::DlgProjectInformationImp::DlgProjectInformationImp(), and Document().
creators name (utf-8)
Definition at line 72 of file App/Document.h.
Referenced by Gui::Dialog::DlgProjectInformationImp::accept(), Gui::Dialog::DlgProjectInformationImp::DlgProjectInformationImp(), and Document().
Definition at line 73 of file App/Document.h.
Referenced by Gui::Dialog::DlgProjectInformationImp::DlgProjectInformationImp(), and Document().
full qualified (with path) file name (utf-8 coded)
Definition at line 70 of file App/Document.h.
Referenced by StdCmdMergeProjects::activated(), Gui::Dialog::DlgProjectInformationImp::DlgProjectInformationImp(), Document(), isSaved(), App::Application::openDocument(), App::DocumentPy::restore(), restore(), Restore(), App::DocumentPy::save(), Gui::Document::Save(), and save().
Definition at line 78 of file App/Document.h.
Referenced by Document(), and Restore().
holds the long name of the document (utf-8 coded)
Definition at line 68 of file App/Document.h.
Referenced by Gui::Document::createView(), Gui::DocumentIndex::data(), Gui::Dialog::DlgProjectInformationImp::DlgProjectInformationImp(), Document(), PartGui::DlgExtrusion::findShapes(), App::Application::newDocument(), onChanged(), Gui::MDIView::onRelabel(), Restore(), and Gui::DocumentItem::setData().
Definition at line 74 of file App/Document.h.
Referenced by Gui::Dialog::DlgProjectInformationImp::accept(), Gui::Dialog::DlgProjectInformationImp::DlgProjectInformationImp(), and Document().
Definition at line 75 of file App/Document.h.
Referenced by Gui::Dialog::DlgProjectInformationImp::DlgProjectInformationImp(), Document(), and save().
boost::signal<void (const App::DocumentObject&)> App::Document::signalActivatedObject |
signal on activated Object
Definition at line 94 of file App/Document.h.
Referenced by addObject(), Gui::Document::Document(), and App::Application::newDocument().
boost::signal<void (const App::DocumentObject&, const App::Property&)> App::Document::signalChangedObject |
signal on changed Object
Definition at line 90 of file App/Document.h.
Referenced by App::DocumentObserver::attachDocument(), Gui::Document::Document(), App::Application::newDocument(), and onChangedProperty().
boost::signal<void (const App::DocumentObject&)> App::Document::signalDeletedObject |
signal on deleted Object
Definition at line 88 of file App/Document.h.
Referenced by _remObject(), App::DocumentObserver::attachDocument(), Gui::Document::Document(), App::Application::newDocument(), remObject(), and restore().
boost::signal<void (const std::vector<App::DocumentObject*>&, Base::Writer &) App::Document::signalExportObjects) |
Definition at line 103 of file App/Document.h.
Referenced by exportObjects(), and Gui::MergeDocuments::MergeDocuments().
boost::signal<void (const std::vector<App::DocumentObject*>&, Base::XMLReader&) App::Document::signalImportObjects) |
Definition at line 105 of file App/Document.h.
Referenced by Gui::MergeDocuments::importObjects(), importObjects(), and Gui::MergeDocuments::MergeDocuments().
boost::signal<void (const App::DocumentObject&)> App::Document::signalNewObject |
signal on new Object
Definition at line 85 of file App/Document.h.
Referenced by _addObject(), addObject(), App::DocumentObserver::attachDocument(), Gui::Document::Document(), and App::Application::newDocument().
boost::signal<void (const App::DocumentObject&)> App::Document::signalRenamedObject |
signal on renamed Object
Definition at line 92 of file App/Document.h.
Referenced by Gui::Document::Document(), and App::Application::newDocument().
boost::signal<void (Base::XMLReader&)> App::Document::signalRestoreDocument |
Definition at line 101 of file App/Document.h.
Referenced by Gui::Document::Document(), and restore().
boost::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 it does).
Definition at line 100 of file App/Document.h.
Referenced by Gui::Document::Document(), and save().
Definition at line 79 of file App/Document.h.
Referenced by Document(), Restore(), and ~Document().