XII Release 0.1.0
Loading...
Searching...
No Matches
xiiDocument Class Referenceabstract

Base class for all editable documents in the editor. Handles state, object management, undo/redo, and more. More...

#include <Document.h>

Inheritance diagram for xiiDocument:
[legend]

Classes

struct  PasteInfo
 Information about a pasted object, including its parent and index. More...
 

Public Member Functions

 xiiDocument (xiiStringView sPath, xiiDocumentObjectManager *pDocumentObjectManagerImpl)
 
Document State Functions
bool IsModified () const
 
bool IsReadOnly () const
 
xiiTime GetModifiedTime () const
 Returns when the document was last marked as modified. Invalid if the document is not modified.
 
const xiiUuid GetGuid () const
 
const xiiDocumentObjectManagerGetObjectManager () const
 
xiiDocumentObjectManagerGetObjectManager ()
 
xiiSelectionManagerGetSelectionManager () const
 
xiiCommandHistoryGetCommandHistory () const
 
virtual xiiObjectAccessorBaseGetObjectAccessor () const
 
Clipboard Functions
virtual void GetSupportedMimeTypesForPasting (xiiHybridArray< xiiString, 4 > &out_mimeTypes) const
 Whether this document supports pasting the given mime format into it.
 
virtual bool CopySelectedObjects (xiiAbstractObjectGraph &out_objectGraph, xiiStringBuilder &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 xiiArrayPtr< PasteInfo > &info, const xiiAbstractObjectGraph &objectGraph, bool bAllowPickedPosition, xiiStringView sMimeType)
 Pastes objects from the given object graph into the document.
 
Inter Document Communication
void BroadcastInterDocumentMessage (xiiReflectedClass *pMessage, xiiDocument *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 (xiiReflectedClass *pMessage, xiiDocument *pSender)
 Called on all documents when BroadcastInterDocumentMessage() is called.
 
Editing Functionality
virtual xiiEditorInputContextGetEditorInputContextOverride ()
 Allows to return a single input context that currently overrides all others (in priority).
 
Misc Functions
virtual void DeleteSelectedObjects () const
 Deletes all currently selected objects in the document.
 
const xiiSet< xiiString > & GetUnknownObjectTypes () const
 Returns the set of unknown object types encountered during loading.
 
xiiUInt32 GetUnknownObjectTypeInstances () const
 Returns the number of unknown object type instances encountered during loading.
 
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 xiiFormatString &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 xiiResult ComputeObjectTransformation (const xiiDocumentObject *pObject, xiiTransform &out_result) const
 Tries to compute the position and rotation for an object in the document. Returns XII_SUCCESS if it was possible.
 
virtual xiiManipulatorSearchStrategy GetManipulatorSearchStrategy () const
 Needed by xiiManipulatorManager to know where to look for the manipulator attributes.
 
- Public Member Functions inherited from xiiReflectedClass
virtual const xiiRTTIGetDynamicRTTI () const
 
bool IsInstanceOf (const xiiRTTI *pType) const
 Returns whether the type of this instance is of the given type or derived from it.
 
template<typename T>
XII_ALWAYS_INLINE bool IsInstanceOf () const
 Returns whether the type of this instance is of the given type or derived from it.
 

Public Attributes

xiiUniquePtr< xiiObjectMetaData< xiiUuid, xiiDocumentObjectMetaData > > m_DocumentObjectMetaData
 Meta data for all document objects.
 
xiiEvent< const xiiDocumentEvent & > m_EventsOne
 Event for document-specific notifications.
 
xiiEvent< const xiiObjectAccessorChangeEvent & > m_ObjectAccessorChangeEvents
 Event for object accessor change notifications.
 

Static Public Attributes

static xiiEvent< const xiiDocumentEvent & > s_EventsAny
 Static event for notifications across all documents.
 

Protected Member Functions

void SetModified (bool b)
 
void SetReadOnly (bool b)
 
virtual xiiTaskGroupID InternalSaveDocument (AfterSaveCallback callback)
 Internal save implementation. Returns a task group ID for async save.
 
virtual xiiStatus InternalLoadDocument ()
 Internal load implementation. Loads the document from disk.
 
virtual xiiDocumentInfoCreateDocumentInfo ()=0
 Creates the document info structure. Must be implemented by derived classes.
 
virtual void InternalAfterSaveDocument ()
 Hook to execute additional code after successfully saving a document. E.g. manual asset transform can be done here.
 
virtual void AttachMetaDataBeforeSaving (xiiAbstractObjectGraph &graph) const
 
virtual void RestoreMetaDataAfterLoading (const xiiAbstractObjectGraph &graph, bool bUndoable)
 
virtual void InitializeAfterLoading (bool bFirstTimeCreation)
 
virtual void InitializeAfterLoadingAndSaving ()
 
virtual void BeforeClosing ()
 
void SetUnknownObjectTypes (const xiiSet< xiiString > &Types, xiiUInt32 uiInstances)
 

Protected Attributes

xiiUniquePtr< xiiDocumentObjectManagerm_pObjectManager
 
xiiUniquePtr< xiiCommandHistorym_pCommandHistory
 
xiiUniquePtr< xiiSelectionManagerm_pSelectionManager
 
xiiUniquePtr< xiiObjectCommandAccessorm_pObjectAccessor
 Default object accessor used by every doc.
 
xiiDocumentInfom_pDocumentInfo = nullptr
 
const xiiDocumentTypeDescriptorm_pTypeDescriptor = nullptr
 

Friends

class xiiDocumentManager
 
class xiiCommandHistory
 
class xiiSaveDocumentTask
 
class xiiAfterSaveDocumentTask
 

Document Management Functions

using AfterSaveCallback = xiiDelegate<void(xiiDocument*, xiiStatus)>
 Callback type for asynchronous save operations.
 
xiiStringView GetDocumentPath () const
 Returns the absolute path to the document.
 
xiiStatus 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.
 
xiiTaskGroupID SaveDocumentAsync (AfterSaveCallback callback, bool bForce=false)
 Saves the document asynchronously. Calls the callback when done.
 
void DocumentRenamed (xiiStringView sNewDocumentPath)
 Updates the document path after a rename operation.
 
xiiStatus LoadDocument ()
 Loads the document from disk.
 
void EnsureVisible ()
 Brings the corresponding window to the front.
 
xiiDocumentManagerGetDocumentManager () const
 Returns the document manager that owns this document.
 
bool HasWindowBeenRequested () const
 
const xiiDocumentTypeDescriptorGetDocumentTypeDescriptor () const
 
xiiStringView GetDocumentTypeName () const
 Returns the document's type name. Same as GetDocumentTypeDescriptor()->m_sDocumentTypeName.
 
const xiiDocumentInfoGetDocumentInfo () const
 
virtual bool CanEngineProcessBeRestarted () const
 Asks the document whether a restart of the engine process is allowed at this time.
 
static xiiStatus ReadDocument (xiiStringView sDocumentPath, xiiUniquePtr< xiiAbstractObjectGraph > &ref_pHeader, xiiUniquePtr< xiiAbstractObjectGraph > &ref_pObjects, xiiUniquePtr< xiiAbstractObjectGraph > &ref_pTypes)
 Reads a document from disk and parses its header, objects, and types.
 
static xiiStatus ReadAndRegisterTypes (const xiiAbstractObjectGraph &types)
 Reads and registers types from the given object graph.
 

Main / Sub-Document Functions

xiiDocumentm_pHostDocument = nullptr
 Pointer to the main document if this is a sub-document, otherwise self.
 
xiiDocumentm_pActiveSubDocument = nullptr
 Pointer to the currently active sub-document.
 
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 xiiDocumentGetMainDocument () const
 In case this is a sub-document, returns the main document this belongs to. Otherwise 'this' is returned.
 
const xiiDocumentGetActiveSubDocument () 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 xiiDocumentObjectStructureEvent::Type::AfterReset.
 
xiiDocumentGetMainDocument ()
 
xiiDocumentGetActiveSubDocument ()
 

Prefab Functions

virtual bool ArePrefabsAllowed () const
 Whether the document allows to create prefabs in it. This may not 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 (xiiArrayPtr< const xiiDocumentObject * > selection)
 Resets the given objects to their template prefab state, if they have local modifications.
 
virtual void UnlinkPrefabs (xiiArrayPtr< const xiiDocumentObject * > selection)
 Removes the link between a prefab instance and its template, turning the instance into a regular object.
 
virtual xiiStatus CreatePrefabDocumentFromSelection (xiiStringView sFile, const xiiRTTI *pRootType, xiiDelegate< void(xiiAbstractObjectNode *)> adjustGraphNodeCB={}, xiiDelegate< void(xiiDocumentObject *)> adjustNewNodesCB={}, xiiDelegate< void(xiiAbstractObjectGraph &graph, xiiDynamicArray< xiiAbstractObjectNode * > &graphRootNodes)> finalizeGraphCB={})
 Creates a prefab document from the current selection.
 
virtual xiiStatus CreatePrefabDocument (xiiStringView sFile, xiiArrayPtr< const xiiDocumentObject * > rootObjects, const xiiUuid &invPrefabSeed, xiiUuid &out_newDocumentGuid, xiiDelegate< void(xiiAbstractObjectNode *)> adjustGraphNodeCB={}, bool bKeepOpen=false, xiiDelegate< void(xiiAbstractObjectGraph &graph, xiiDynamicArray< xiiAbstractObjectNode * > &graphRootNodes)> finalizeGraphCB={})
 Creates a prefab document from the given root objects.
 
virtual xiiUuid ReplaceByPrefab (const xiiDocumentObject *pRootObject, xiiStringView sPrefabFile, const xiiUuid &prefabAsset, const xiiUuid &prefabSeed, bool bEnginePrefab)
 Replaces the given object by a prefab instance. Returns new guid of replaced object.
 
virtual xiiUuid RevertPrefab (const xiiDocumentObject *pObject)
 Reverts the given object to its prefab state. Returns new guid of reverted object.
 
virtual void UpdatePrefabsRecursive (xiiDocumentObject *pObject)
 Recursively updates all prefab instances starting from the given object.
 
virtual void UpdatePrefabObject (xiiDocumentObject *pObject, const xiiUuid &PrefabAsset, const xiiUuid &PrefabSeed, xiiStringView sBasePrefab)
 

Additional Inherited Members

- Static Public Member Functions inherited from xiiNoBase
static const xiiRTTIGetStaticRTTI ()
 

Detailed Description

Base class for all editable documents in the editor. Handles state, object management, undo/redo, and more.

Member Function Documentation

◆ ArePrefabsAllowed()

virtual bool xiiDocument::ArePrefabsAllowed ( ) const
inlinevirtual

Whether the document allows to create prefabs in it. This may not be allowed for prefab documents themselves, to prevent nested prefabs.

Reimplemented in xiiSceneDocument.

◆ CanEngineProcessBeRestarted()

virtual bool xiiDocument::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 xiiSceneDocument.

◆ ComputeObjectTransformation()

xiiResult xiiDocument::ComputeObjectTransformation ( const xiiDocumentObject * pObject,
xiiTransform & out_result ) const
virtual

Tries to compute the position and rotation for an object in the document. Returns XII_SUCCESS if it was possible.

Reimplemented in xiiGameObjectDocument.

◆ CopySelectedObjects()

virtual bool xiiDocument::CopySelectedObjects ( xiiAbstractObjectGraph & out_objectGraph,
xiiStringBuilder & out_sMimeType ) const
inlinevirtual

Creates the abstract graph of data to be copied and returns the mime type for the clipboard to identify the data.

Reimplemented in xiiAnimationGraphAssetDocument, xiiMaterialAssetDocument, xiiRenderPipelineAssetDocument, xiiSceneDocument, xiiStateMachineAssetDocument, and xiiVisualScriptClassAssetDocument.

◆ CreateDocumentInfo()

◆ CreatePrefabDocumentFromSelection()

xiiStatus xiiDocument::CreatePrefabDocumentFromSelection ( xiiStringView sFile,
const xiiRTTI * pRootType,
xiiDelegate< void(xiiAbstractObjectNode *)> adjustGraphNodeCB = {},
xiiDelegate< void(xiiDocumentObject *)> adjustNewNodesCB = {},
xiiDelegate< void(xiiAbstractObjectGraph &graph, xiiDynamicArray< xiiAbstractObjectNode * > &graphRootNodes)> finalizeGraphCB = {} )
virtual

Creates a prefab document from the current selection.

Reimplemented in xiiSceneDocument.

◆ GetEditorInputContextOverride()

virtual xiiEditorInputContext * xiiDocument::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 xiiGameObjectDocument.

◆ GetManipulatorSearchStrategy()

virtual xiiManipulatorSearchStrategy xiiDocument::GetManipulatorSearchStrategy ( ) const
inlinevirtual

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

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

Reimplemented in xiiPropertyAnimAssetDocument, xiiSceneDocument, and xiiSkeletonAssetDocument.

◆ GetSupportedMimeTypesForPasting()

virtual void xiiDocument::GetSupportedMimeTypesForPasting ( xiiHybridArray< xiiString, 4 > & out_mimeTypes) const
inlinevirtual

◆ InternalAfterSaveDocument()

virtual void xiiDocument::InternalAfterSaveDocument ( )
inlineprotectedvirtual

Hook to execute additional code after successfully saving a document. E.g. manual asset transform can be done here.

Reimplemented in xiiAssetDocument.

◆ InternalLoadDocument()

◆ InternalSaveDocument()

xiiTaskGroupID xiiDocument::InternalSaveDocument ( AfterSaveCallback callback)
protectedvirtual

Internal save implementation. Returns a task group ID for async save.

Reimplemented in xiiAssetDocument, and xiiScene2Document.

◆ OnInterDocumentMessage()

virtual void xiiDocument::OnInterDocumentMessage ( xiiReflectedClass * pMessage,
xiiDocument * pSender )
inlinevirtual

Called on all documents when BroadcastInterDocumentMessage() is called.

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

Reimplemented in xiiSceneDocument.

◆ Paste()

virtual bool xiiDocument::Paste ( const xiiArrayPtr< PasteInfo > & info,
const xiiAbstractObjectGraph & objectGraph,
bool bAllowPickedPosition,
xiiStringView sMimeType )
inlinevirtual

◆ ReplaceByPrefab()

xiiUuid xiiDocument::ReplaceByPrefab ( const xiiDocumentObject * pRootObject,
xiiStringView sPrefabFile,
const xiiUuid & prefabAsset,
const xiiUuid & prefabSeed,
bool bEnginePrefab )
virtual

Replaces the given object by a prefab instance. Returns new guid of replaced object.

Reimplemented in xiiSceneDocument.

◆ RevertPrefab()

xiiUuid xiiDocument::RevertPrefab ( const xiiDocumentObject * pObject)
virtual

Reverts the given object to its prefab state. Returns new guid of reverted object.

Reimplemented in xiiSceneDocument.

◆ UnlinkPrefabs()

void xiiDocument::UnlinkPrefabs ( xiiArrayPtr< const xiiDocumentObject * > selection)
virtual

Removes the link between a prefab instance and its template, turning the instance into a regular object.

Reimplemented in xiiSceneDocument.

◆ UpdatePrefabs()

void xiiDocument::UpdatePrefabs ( )
virtual

Updates ALL prefabs in the document with the latest changes. Merges the current prefab templates with the instances in the document.

Reimplemented in xiiSceneDocument.


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