ezEngine  Release 25.03
ezDocument Class Referenceabstract
Inheritance diagram for ezDocument:

Classes

struct  PasteInfo
 

Public Member Functions

 ezDocument (ezStringView sPath, ezDocumentObjectManager *pDocumentObjectManagerImpl)
 
Document State Functions
bool IsModified () const
 
bool IsReadOnly () const
 
const ezUuid GetGuid () const
 
const ezDocumentObjectManagerGetObjectManager () const
 
ezDocumentObjectManagerGetObjectManager ()
 
ezSelectionManagerGetSelectionManager () const
 
ezCommandHistoryGetCommandHistory () const
 
virtual ezObjectAccessorBaseGetObjectAccessor () const
 
Clipboard Functions
virtual void GetSupportedMimeTypesForPasting (ezHybridArray< ezString, 4 > &out_mimeTypes) const
 Whether this document supports pasting the given mime format into it.
 
virtual bool CopySelectedObjects (ezAbstractObjectGraph &out_objectGraph, ezStringBuilder &out_sMimeType) const
 Creates the abstract graph of data to be copied and returns the mime type for the clipboard to identify the data.
 
virtual bool Paste (const ezArrayPtr< PasteInfo > &info, const ezAbstractObjectGraph &objectGraph, bool bAllowPickedPosition, ezStringView sMimeType)
 
Inter Document Communication
void BroadcastInterDocumentMessage (ezReflectedClass *pMessage, ezDocument *pSender)
 This will deliver the message to all open documents. The documents may respond, e.g. by modifying the content of the message.
 
virtual void OnInterDocumentMessage (ezReflectedClass *pMessage, ezDocument *pSender)
 Called on all documents when BroadcastInterDocumentMessage() is called. More...
 
Editing Functionality
virtual ezEditorInputContextGetEditorInputContextOverride ()
 Allows to return a single input context that currently overrides all others (in priority). More...
 
Misc Functions
virtual void DeleteSelectedObjects () const
 
const ezSet< ezString > & GetUnknownObjectTypes () const
 
ezUInt32 GetUnknownObjectTypeInstances () const
 
void SetAddToResetFilesList (bool b)
 If disabled, this document will not be put into the recent files list.
 
bool GetAddToRecentFilesList () const
 Whether this document shall be put into the recent files list.
 
void ShowDocumentStatus (const ezFormatString &msg) const
 Broadcasts a status message event. The window that displays the document may show this in some form, e.g. in the status bar.
 
virtual ezResult ComputeObjectTransformation (const ezDocumentObject *pObject, ezTransform &out_result) const
 Tries to compute the position and rotation for an object in the document. Returns EZ_SUCCESS if it was possible.
 
virtual ezManipulatorSearchStrategy GetManipulatorSearchStrategy () const
 Needed by ezManipulatorManager to know where to look for the manipulator attributes. More...
 
- Public Member Functions inherited from ezReflectedClass
virtual const ezRTTIGetDynamicRTTI () const
 
bool IsInstanceOf (const ezRTTI *pType) const
 Returns whether the type of this instance is of the given type or derived from it.
 
template<typename T >
EZ_ALWAYS_INLINE bool IsInstanceOf () const
 Returns whether the type of this instance is of the given type or derived from it.
 

Public Attributes

ezUniquePtr< ezObjectMetaData< ezUuid, ezDocumentObjectMetaData > > m_DocumentObjectMetaData
 
ezEvent< const ezDocumentEvent & > m_EventsOne
 
ezEvent< const ezObjectAccessorChangeEvent & > m_ObjectAccessorChangeEvents
 

Static Public Attributes

static ezEvent< const ezDocumentEvent & > s_EventsAny
 

Protected Member Functions

void SetModified (bool b)
 
void SetReadOnly (bool b)
 
virtual ezTaskGroupID InternalSaveDocument (AfterSaveCallback callback)
 
virtual ezStatus InternalLoadDocument ()
 
virtual ezDocumentInfoCreateDocumentInfo ()=0
 
virtual void InternalAfterSaveDocument ()
 A hook to execute additional code after SUCCESSFULLY saving a document. E.g. manual asset transform can be done here.
 
virtual void AttachMetaDataBeforeSaving (ezAbstractObjectGraph &graph) const
 
virtual void RestoreMetaDataAfterLoading (const ezAbstractObjectGraph &graph, bool bUndoable)
 
virtual void InitializeAfterLoading (bool bFirstTimeCreation)
 
virtual void InitializeAfterLoadingAndSaving ()
 
virtual void BeforeClosing ()
 
void SetUnknownObjectTypes (const ezSet< ezString > &Types, ezUInt32 uiInstances)
 

Protected Attributes

ezUniquePtr< ezDocumentObjectManagerm_pObjectManager
 
ezUniquePtr< ezCommandHistorym_pCommandHistory
 
ezUniquePtr< ezSelectionManagerm_pSelectionManager
 
ezUniquePtr< ezObjectCommandAccessorm_pObjectAccessor
 Default object accessor used by every doc.
 
ezDocumentInfom_pDocumentInfo = nullptr
 
const ezDocumentTypeDescriptorm_pTypeDescriptor = nullptr
 

Friends

class ezDocumentManager
 
class ezCommandHistory
 
class ezSaveDocumentTask
 
class ezAfterSaveDocumentTask
 

Main / Sub-Document Functions

ezDocumentm_pHostDocument = nullptr
 
ezDocumentm_pActiveSubDocument = nullptr
 
bool IsMainDocument () const
 Returns whether this document is a main document, i.e. self contained.
 
bool IsSubDocument () const
 Returns whether this document is a sub-document, i.e. is part of another document.
 
const ezDocumentGetMainDocument () const
 In case this is a sub-document, returns the main document this belongs to. Otherwise 'this' is returned.
 
const ezDocumentGetActiveSubDocument () const
 At any given time, only the active sub-document can be edited. This returns the active sub-document which can also be this document itself. Changes to the active sub-document are generally triggered by ezDocumentObjectStructureEvent::Type::AfterReset.
 
ezDocumentGetMainDocument ()
 
ezDocumentGetActiveSubDocument ()
 

Document Management Functions

using AfterSaveCallback = ezDelegate< void(ezDocument *, ezStatus)>
 
ezStringView GetDocumentPath () const
 Returns the absolute path to the document.
 
ezStatus SaveDocument (bool bForce=false)
 Saves the document, if it is modified. If bForce is true, the document will be written, even if it is not considered modified.
 
ezTaskGroupID SaveDocumentAsync (AfterSaveCallback callback, bool bForce=false)
 
void DocumentRenamed (ezStringView sNewDocumentPath)
 
ezStatus LoadDocument ()
 
void EnsureVisible ()
 Brings the corresponding window to the front.
 
ezDocumentManagerGetDocumentManager () const
 
bool HasWindowBeenRequested () const
 
const ezDocumentTypeDescriptorGetDocumentTypeDescriptor () const
 
ezStringView GetDocumentTypeName () const
 Returns the document's type name. Same as GetDocumentTypeDescriptor()->m_sDocumentTypeName.
 
const ezDocumentInfoGetDocumentInfo () const
 
virtual bool CanEngineProcessBeRestarted () const
 Asks the document whether a restart of the engine process is allowed at this time. More...
 
static ezStatus ReadDocument (ezStringView sDocumentPath, ezUniquePtr< ezAbstractObjectGraph > &ref_pHeader, ezUniquePtr< ezAbstractObjectGraph > &ref_pObjects, ezUniquePtr< ezAbstractObjectGraph > &ref_pTypes)
 
static ezStatus ReadAndRegisterTypes (const ezAbstractObjectGraph &types)
 

Prefab Functions

virtual bool ArePrefabsAllowed () const
 Whether the document allows to create prefabs in it. This may note be allowed for prefab documents themselves, to prevent nested prefabs.
 
virtual void UpdatePrefabs ()
 Updates ALL prefabs in the document with the latest changes. Merges the current prefab templates with the instances in the document.
 
void RevertPrefabs (ezArrayPtr< const ezDocumentObject * > selection)
 Resets the given objects to their template prefab state, if they have local modifications.
 
virtual void UnlinkPrefabs (ezArrayPtr< const ezDocumentObject * > selection)
 Removes the link between a prefab instance and its template, turning the instance into a regular object.
 
virtual ezStatus CreatePrefabDocumentFromSelection (ezStringView sFile, const ezRTTI *pRootType, ezDelegate< void(ezAbstractObjectNode *)> adjustGraphNodeCB={}, ezDelegate< void(ezDocumentObject *)> adjustNewNodesCB={}, ezDelegate< void(ezAbstractObjectGraph &graph, ezDynamicArray< ezAbstractObjectNode * > &graphRootNodes)> finalizeGraphCB={})
 
virtual ezStatus CreatePrefabDocument (ezStringView sFile, ezArrayPtr< const ezDocumentObject * > rootObjects, const ezUuid &invPrefabSeed, ezUuid &out_newDocumentGuid, ezDelegate< void(ezAbstractObjectNode *)> adjustGraphNodeCB={}, bool bKeepOpen=false, ezDelegate< void(ezAbstractObjectGraph &graph, ezDynamicArray< ezAbstractObjectNode * > &graphRootNodes)> finalizeGraphCB={})
 
virtual ezUuid ReplaceByPrefab (const ezDocumentObject *pRootObject, ezStringView sPrefabFile, const ezUuid &prefabAsset, const ezUuid &prefabSeed, bool bEnginePrefab)
 
virtual ezUuid RevertPrefab (const ezDocumentObject *pObject)
 
virtual void UpdatePrefabsRecursive (ezDocumentObject *pObject)
 
virtual void UpdatePrefabObject (ezDocumentObject *pObject, const ezUuid &PrefabAsset, const ezUuid &PrefabSeed, ezStringView sBasePrefab)
 

Additional Inherited Members

- Static Public Member Functions inherited from ezNoBase
static const ezRTTIGetStaticRTTI ()
 

Member Function Documentation

◆ CanEngineProcessBeRestarted()

virtual bool ezDocument::CanEngineProcessBeRestarted ( ) const
inlinevirtual

Asks the document whether a restart of the engine process is allowed at this time.

Documents that are currently interacting with the engine process (active play-the-game mode) should return false. All others should return true. As long as any document returns false, automatic engine process reload is suppressed.

Reimplemented in ezSceneDocument.

◆ GetEditorInputContextOverride()

virtual ezEditorInputContext* ezDocument::GetEditorInputContextOverride ( )
inlinevirtual

Allows to return a single input context that currently overrides all others (in priority).

Used to implement custom tools that need to have priority over selection and camera movement.

Reimplemented in ezGameObjectDocument.

◆ GetManipulatorSearchStrategy()

virtual ezManipulatorSearchStrategy ezDocument::GetManipulatorSearchStrategy ( ) const
inlinevirtual

Needed by ezManipulatorManager to know where to look for the manipulator attributes.

Override this function for document types that use manipulators. The ezManipulatorManager will assert that the document type doesn't return 'None' once it is in use.

Reimplemented in ezSceneDocument, ezPropertyAnimAssetDocument, and ezSkeletonAssetDocument.

◆ OnInterDocumentMessage()

virtual void ezDocument::OnInterDocumentMessage ( ezReflectedClass pMessage,
ezDocument pSender 
)
inlinevirtual

Called on all documents when BroadcastInterDocumentMessage() is called.

Use the RTTI information to identify whether the message is of interest.

Reimplemented in ezSceneDocument.


The documentation for this class was generated from the following files: