Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
vtkMRMLScene Class Reference

A set of MRML Nodes that supports serialization and undo/redo. More...

#include <Libs/MRML/Core/vtkMRMLScene.h>

Inheritance diagram for vtkMRMLScene:
Inheritance graph
[legend]
Collaboration diagram for vtkMRMLScene:
Collaboration graph
[legend]

Public Types

enum  SceneEventType {
  NodeAboutToBeAddedEvent = 0x2000, NodeAddedEvent, NodeAboutToBeRemovedEvent, NodeRemovedEvent,
  NodeClassRegisteredEvent, NewSceneEvent = 66030, MetadataAddedEvent = 66032, ImportProgressFeedbackEvent,
  SaveProgressFeedbackEvent, StateEvent = 0x2000, StartEvent = 0x0100, EndEvent = 0x0200,
  ProgressEvent = 0x0400, StartBatchProcessEvent = StateEvent | StartEvent | BatchProcessState, EndBatchProcessEvent = StateEvent | EndEvent | BatchProcessState, ProgressBatchProcessEvent = StateEvent | ProgressEvent | BatchProcessState,
  StartCloseEvent = StateEvent | StartEvent | CloseState, EndCloseEvent = StateEvent | EndEvent | CloseState, ProgressCloseEvent = StateEvent | ProgressEvent | CloseState, StartImportEvent = StateEvent | StartEvent | ImportState,
  EndImportEvent = StateEvent | EndEvent | ImportState, ProgressImportEvent = StateEvent | EndEvent | ImportState, StartRestoreEvent = StateEvent | StartEvent | RestoreState, EndRestoreEvent = StateEvent | EndEvent | RestoreState,
  ProgressRestoreEvent = StateEvent | ProgressEvent | RestoreState, StartSaveEvent = StateEvent | StartEvent | SaveState, EndSaveEvent = StateEvent | EndEvent | SaveState, ProgressSaveEvent = StateEvent | ProgressEvent | SaveState,
  StartUndoEvent = StateEvent | StartEvent | UndoState, EndUndoEvent = StateEvent | EndEvent | UndoState, ProgressUndoEvent = StateEvent | ProgressEvent | UndoState, StartRedoEvent = StateEvent | StartEvent | RedoState,
  EndRedoEvent = StateEvent | EndEvent | RedoState, ProgressRedoEvent = StateEvent | ProgressEvent | RedoState
}
 
enum  StateType {
  BatchProcessState = 0x0001, CloseState = 0x0002 | BatchProcessState, ImportState = 0x0004 | BatchProcessState, RestoreState = 0x0008 | BatchProcessState,
  SaveState = 0x0010, UndoState = 0x0020, RedoState = 0x0040
}
 
typedef vtkObject Superclass
 

Public Member Functions

void AddDefaultNode (vtkMRMLNode *node)
 
vtkMRMLNodeAddNewNodeByClass (std::string className, std::string nodeBaseName="")
 Instantiate and add a node to the scene. More...
 
vtkMRMLNodeAddNewNodeByClassWithID (std::string className, std::string nodeBaseName, std::string nodeID)
 Instantiates and adds a new node to the scene with the specified ID. More...
 
vtkMRMLNodeAddNode (vtkMRMLNode *nodeToAdd)
 Add a node to the scene and send vtkMRMLScene::NodeAboutToBeAddedEvent, vtkMRMLScene::NodeAddedEvent and vtkMRMLScene::SceneModified events. More...
 
void AddReferencedNodeID (const char *id, vtkMRMLNode *refrencingNode)
 
void AddReservedID (const char *id)
 
void AddURIHandler (vtkURIHandler *handler)
 Add a uri handler to the collection. More...
 
void Clear (int removeSingletons=0)
 
void ClearRedoStack ()
 clear Redo stack, delete redo history More...
 
void ClearUndoStack ()
 clear Undo stack, delete undo history More...
 
int Commit (const char *url=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
 
int Connect (vtkMRMLMessageCollection *userMessages=nullptr)
 Create new scene from URL If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation. Returns nonzero on success. More...
 
void CopyDefaultNodesToScene (vtkMRMLScene *scene)
 Copies all default nodes into the parameter scene. Does not remove existing default nodes. More...
 
vtkMRMLNodeCopyNode (vtkMRMLNode *n)
 Add a copy of a node to the scene. More...
 
void CopyNodeChangedIDs (vtkMRMLScene *scene)
 
void CopyNodeReferences (vtkMRMLScene *scene)
 
void CopyRegisteredNodesToScene (vtkMRMLScene *scene)
 Copies all registered nodes into the parameter scene. More...
 
void CopySingletonNodesToScene (vtkMRMLScene *scene)
 Copies all singleton nodes into the parameter scene. More...
 
vtkMRMLNodeCreateNodeByClass (const char *className)
 Create node with a given class. More...
 
void EndState (unsigned long state)
 Unflag the scene as being in a state mode. More...
 
vtkURIHandlerFindURIHandler (const char *URI)
 Find a URI handler in the collection that can work on the passed URI. More...
 
vtkURIHandlerFindURIHandlerByName (const char *name)
 Returns a URIhandler of a specific type if its name is known. More...
 
std::string GenerateUniqueName (const std::string &baseName)
 Generate a node name that is unique in the scene. Calling this function successively with the same baseName returns a different name: e.g. baseName1, baseName2, baseName3. More...
 
virtual vtkCacheManagerGetCacheManager ()
 
const char * GetChangedID (const char *id)
 
virtual const char * GetClassName ()
 
const char * GetClassNameByTag (const char *tagName)
 Add a path to the list. More...
 
virtual vtkDataIOManagerGetDataIOManager ()
 
vtkMRMLNodeGetDefaultNodeByClass (const char *className)
 
virtual char * GetExtensions ()
 
vtkMRMLNodeGetFirstNode (const char *byName=nullptr, const char *byClass=nullptr, const int *byHideFromEditors=nullptr, bool exactNameMatch=true)
 Return the first node in the scene that matches the filtering criteria if specified. More...
 
vtkMRMLNodeGetFirstNodeByClass (const char *className)
 Convenience function for getting 0-th node of a specified class in the scene. More...
 
vtkMRMLNodeGetFirstNodeByName (const char *name)
 
virtual char * GetLastLoadedExtensions ()
 The extensions used in the last loaded scene file. More...
 
virtual char * GetLastLoadedVersion ()
 The version of the last loaded scene file. More...
 
virtual int GetLoadFromXMLString ()
 
virtual int GetMaximumNumberOfSavedUndoStates ()
 
bool GetModifiedSinceRead (vtkCollection *modifiedNodes=nullptr)
 Returns true if the scene has been "significantly" modified since the last saved state. If modifiedNodes is provided then it returns the list of nodes that have been found to be modified. More...
 
vtkMRMLNodeGetNextNode ()
 
vtkMRMLNodeGetNextNodeByClass (const char *className)
 
vtkMRMLNodeGetNodeByID (const char *name)
 Get node given a unique ID. More...
 
vtkMRMLNodeGetNodeByID (std::string name)
 
std::list< std::string > GetNodeClassesList ()
 
vtkCollection * GetNodes ()
 Return collection of nodes. More...
 
int GetNodesByClass (const char *className, std::vector< vtkMRMLNode *> &nodes)
 Get vector of nodes of a specified class in the scene. More...
 
vtkCollection * GetNodesByClass (const char *className)
 
vtkCollection * GetNodesByClassByName (const char *className, const char *name)
 
vtkCollection * GetNodesByName (const char *name)
 Get nodes having the specified name. More...
 
vtkMRMLNodeGetNthNode (int n)
 Get n-th node in the scene. More...
 
vtkMRMLNodeGetNthNodeByClass (int n, const char *className)
 Get n-th node of a specified class in the scene. More...
 
const char * GetNthReferencedID (int n)
 
vtkMRMLNodeGetNthReferencingNode (int n)
 
std::string GetNthRegisteredAbstractNodeClassName (int n)
 
std::string GetNthRegisteredAbstractNodeTypeDisplayName (int n)
 
vtkMRMLNodeGetNthRegisteredNodeClass (int n)
 
int GetNumberOfNodeReferences ()
 Get the total number of node references (number of ReferencedID-ReferencingNode pairs). More...
 
int GetNumberOfNodes ()
 Get number of nodes in the scene. More...
 
int GetNumberOfNodesByClass (const char *className)
 Get number of nodes of a specified class in the scene. More...
 
int GetNumberOfRedoLevels ()
 returns number of redo steps in the history buffer More...
 
int GetNumberOfRegisteredAbstractNodeClasses ()
 Get the number of registered abstract node classes. More...
 
int GetNumberOfRegisteredNodeClasses ()
 
int GetNumberOfUndoLevels ()
 returns number of undo steps in the history buffer More...
 
virtual int GetReadDataOnLoad ()
 
vtkCollection * GetReferencedNodes (vtkMRMLNode *node, bool recursive=true)
 Return collection of all nodes referenced directly or indirectly by node. More...
 
void GetReferencedSubScene (vtkMRMLNode *node, vtkMRMLScene *newScene)
 Get a sub-scene containing all nodes directly or indirectly referenced by the input node. More...
 
void GetReferencingNodes (vtkMRMLNode *referencedNode, std::vector< vtkMRMLNode *> &referencingNodes)
 Get vector of nodes containing references to an input node. More...
 
const char * GetRootDirectory ()
 Get Root directory, where URL is pointing. More...
 
virtual int GetSaveToXMLString ()
 
const std::string & GetSceneXMLString ()
 Returns the saved scene with an XML format if SaveToXMLString is true and Commit() was called prior. More...
 
vtkMRMLNodeGetSingletonNode (const char *singletonTag, const char *className)
 Search and return the singleton of type className with a singletonTag tag. More...
 
vtkMRMLNodeGetSingletonNode (vtkMRMLNode *n)
 Search and return a matching singleton in the scene that the input singleton node will overwrite if it is added to the scene. More...
 
int GetStates () const
 Returns the current state of the scene. More...
 
bool GetStorableNodesModifiedSinceRead (vtkCollection *modifiedStorableNodes=nullptr)
 Search the scene for storable nodes that are "ModifiedSinceRead". More...
 
virtual vtkMTimeType GetStoredTime ()
 Timestamp of the scene's last saved state. More...
 
vtkMRMLSubjectHierarchyNodeGetSubjectHierarchyNode ()
 
const char * GetTagByClassName (const char *className)
 Add a path to the list. More...
 
std::string GetTypeDisplayNameByClassName (std::string className)
 Get type display name which is shown in the GUI. More...
 
bool GetUndoFlag ()
 
const char * GetUniqueNameByString (const char *baseName)
 
virtual vtkCollection * GetURIHandlerCollection ()
 
const char * GetURL ()
 Get URL (file name) of the scene. More...
 
virtual vtkTagTableGetUserTagTable ()
 
virtual char * GetVersion ()
 The current software version. More...
 
int Import (vtkMRMLMessageCollection *userMessages=nullptr)
 Add the scene into the existing scene (no clear) from URL file or from. More...
 
void InitTraversal ()
 
vtkMRMLNodeInsertAfterNode (vtkMRMLNode *item, vtkMRMLNode *newItem)
 insert a node in the scene after a specified node More...
 
vtkMRMLNodeInsertBeforeNode (vtkMRMLNode *item, vtkMRMLNode *newItem)
 insert a node in the scene before a specified node More...
 
virtual int IsA (const char *type)
 
bool IsBatchProcessing () const
 Return true if the scene is in BatchProcess state, false otherwise. More...
 
bool IsClosing () const
 Return true if the scene is in Close state, false otherwise. More...
 
int IsFilePathRelative (const char *filepath)
 
bool IsImporting () const
 Return true if the scene is in Import state, false otherwise. More...
 
bool IsNodeClassRegistered (const std::string &className)
 Return True if className is a registered node. More...
 
int IsNodePresent (vtkMRMLNode *n)
 Determine whether a particular node is present. More...
 
bool IsNodeReferencingNodeID (vtkMRMLNode *referencingNode, const char *id)
 
bool IsRedoing () const
 Return true if the scene is in Redo state (in the process of redoing node changes), false otherwise. More...
 
bool IsReservedID (const std::string &id)
 
bool IsRestoring () const
 Return true if the scene is in Restore state, false otherwise. More...
 
bool IsUndoing () const
 Return true if the scene is in Undo state (in the process of undoing node changes), false otherwise. More...
 
void NodeAdded (vtkMRMLNode *n)
 Invoke a vtkMRMLScene::NodeAddedEvent. More...
 
void NodeAdded ()
 
void PrintSelf (ostream &os, vtkIndent indent) override
 
void ProgressState (unsigned long state, int progress=0)
 TODO: Report progress of the current state. More...
 
bool ReadFromMRB (const char *fullName, bool clear=false, vtkMRMLMessageCollection *userMessages=nullptr)
 Read the scene from a MRML scene bundle (.mrb) file If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation. More...
 
void Redo ()
 redo, set the scene to previously undone More...
 
void RegisterAbstractNodeClass (std::string className, std::string typeDisplayName)
 Register abstract node type display name. More...
 
void RegisterNodeClass (vtkMRMLNode *node, const char *tagName)
 Register a node class to the scene so that the scene can later create the same node type from a tag or a class name. More...
 
void RegisterNodeClass (vtkMRMLNode *node)
 Utility function to RegisterNodeClass(), the node tag name is used when registering the node. More...
 
void RemoveAllDefaultNodes ()
 Deletes all default node values from the scene. More...
 
void RemoveNode (vtkMRMLNode *n)
 Remove a path from the list. More...
 
void RemoveNodeReferences (vtkMRMLNode *node)
 
void RemoveReferencedNodeID (const char *id, vtkMRMLNode *refrencingNode)
 
void RemoveReferencesToNode (vtkMRMLNode *node)
 
void RemoveReservedIDs ()
 
void RemoveUnusedNodeReferences ()
 
void ResetNodes ()
 Reset all nodes to their constructor's state. More...
 
void SaveSceneScreenshot (vtkImageData *thumbnail)
 Utility function to write the scene thumbnail to a file in the scene's root folder. More...
 
bool SaveSceneToSlicerDataBundleDirectory (const char *sdbDir, vtkImageData *thumbnail=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
 Save the scene into a self contained directory, sdbDir If thumbnail image is provided then it is saved in the scene's root folder. If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation. Returns false if the save failed. More...
 
void SaveStateForUndo ()
 Save current state in the undo buffer. More...
 
void SaveStateForUndo (vtkMRMLNode *node)
 
void SaveStateForUndo (vtkCollection *nodes)
 
void SaveStateForUndo (std::vector< vtkMRMLNode *> nodes)
 
virtual void SetCacheManager (vtkCacheManager *)
 
virtual void SetDataIOManager (vtkDataIOManager *)
 
virtual void SetExtensions (const char *)
 
virtual void SetLastLoadedExtensions (const char *)
 
virtual void SetLastLoadedVersion (const char *)
 
virtual void SetLoadFromXMLString (int)
 This property controls whether Import() loads a scene from an XML string or from an XML file. More...
 
void SetMaximumNumberOfSavedUndoStates (int stackSize)
 Sets the maximum number of saved undo states and removes the oldest saved states so that the number of saved states is less than the new maximum. More...
 
virtual void SetReadDataOnLoad (int)
 
void SetRootDirectory (const char *dir)
 Set Root directory, where URL is pointing. More...
 
virtual void SetSaveToXMLString (int)
 This property controls whether Commit() should save the scene as an XML string or an XML file. More...
 
void SetSceneXMLString (const std::string &xmlString)
 Set the XML string to read from by Import() if GetLoadFromXMLString() is true. More...
 
void SetStorableNodesModifiedSinceRead ()
 Search the scene for storable nodes that are not "ModifiedSinceRead". More...
 
void SetUndoFlag (bool flag)
 
void SetUndoOff ()
 
void SetUndoOn ()
 Set undo on/off. More...
 
virtual void SetURIHandlerCollection (vtkCollection *)
 
void SetURL (const char *url)
 Set URL (file name) of the scene. More...
 
virtual void SetUserTagTable (vtkTagTable *)
 
virtual void SetVersion (const char *)
 
void StartState (unsigned long state, int anticipatedMaxProgress=0)
 Flag the scene as being in a state mode. More...
 
void Undo ()
 undo, set the scene to previous state More...
 
void UpdateNodeChangedIDs ()
 Change node IDs based on the ReferencedIDChanges list. More...
 
void UpdateNodeReferences (vtkCollection *checkNodes=nullptr)
 Notify nodes about node ID changes. More...
 
bool WriteToMRB (const char *filename, vtkImageData *thumbnail=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
 Write the scene to a MRML scene bundle (.mrb) file. If thumbnail image is provided then it is saved in the scene's root folder. If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation. Returns false if the save failed. More...
 

Static Public Member Functions

static std::string CreateUniqueFileName (const std::string &filename, const std::string &knownExtension="")
 
static int IsTypeOf (const char *type)
 
static vtkMRMLSceneNew ()
 
static bool ParseVersion (const char *versionString, std::string &application, int &major, int &minor, int &patch, int &revision)
 
static std::string PercentEncode (std::string s)
 
static vtkMRMLSceneSafeDownCast (vtkObject *o)
 
static void SetStorableNodesModifiedSinceRead (vtkCollection *storableNodes)
 Given a collection of storable nodes, iterate through and call StorableModified() on them. More...
 
static std::string UnpackSlicerDataBundle (const char *sdbFilePath, const char *temporaryDirectory, vtkMRMLMessageCollection *userMessages=nullptr)
 Unpack the file into a temp directory and return the scene file inside. Note that the first mrml file found in the extracted directory will be used. If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation. More...
 

Protected Types

typedef std::map< std::string, std::set< std::string > > NodeReferencesType
 

Protected Member Functions

void AddNodeID (vtkMRMLNode *node)
 Add node to NodeIDs map used to speedup GetByID() method. More...
 
vtkMRMLNodeAddNodeNoNotify (vtkMRMLNode *n)
 
void AddReferencedNodes (vtkMRMLNode *node, vtkCollection *refNodes, bool recursive=true)
 
std::string BuildID (const std::string &baseID, int idIndex) const
 
std::string BuildName (const std::string &baseName, int nameIndex) const
 Combine a basename and an index to produce a full name. More...
 
void ClearNodeIDs ()
 Clear NodeIDs map used to speedup GetByID() method. More...
 
void CopyNodeInRedoStack (vtkMRMLNode *node)
 
void CopyNodeInUndoStack (vtkMRMLNode *node)
 
NodeReferencesType::iterator FindNodeReference (const char *referencedId, vtkMRMLNode *referencingNode)
 Get a NodeReferences iterator for a node reference. More...
 
std::string GenerateUniqueID (vtkMRMLNode *node)
 
std::string GenerateUniqueID (const std::string &baseID)
 
std::string GenerateUniqueName (vtkMRMLNode *node)
 Return a unique name for a MRML node. It uses the node tag as the base. More...
 
void GetNodeReferenceIDsFromUndoStack (std::set< std::string > &referenceIDs) const
 Returns all unique node reference IDs that are referenced within the undo stack. More...
 
int GetUniqueIDIndex (const std::string &baseID)
 
int GetUniqueNameIndex (const std::string &baseName)
 Returns a unique index for a given baseName. More...
 
bool IsNodeIDReservedByUndo (const std::string id) const
 Returns true if a node is not referenced within the scene, but is referenced within the Undo stack. More...
 
void PushIntoRedoStack ()
 
void PushIntoUndoStack ()
 
void RemoveAllNodes (bool removeSingletons)
 
void RemoveInvalidNodeReferences (vtkCollection *checkNodes, const std::set< std::string > &validNodeIDs)
 Remove invalid node references after scene import. More...
 
void RemoveNodeID (char *nodeID)
 Remove node from NodeIDs map used to speedup GetByID() method. More...
 
void ReserveNodeReferenceIDs (vtkMRMLNode *node)
 Reserve all node reference ids for a node. More...
 
bool SaveStorableNodeToSlicerDataBundleDirectory (vtkMRMLStorableNode *storableNode, std::string &dataDir, std::map< vtkMRMLStorageNode *, std::vector< std::string > > &originalStorageNodeFileNames, vtkMRMLMessageCollection *userMessages)
 
virtual void SetSubjectHierarchyNode (vtkMRMLSubjectHierarchyNode *)
 
void TrimUndoStack ()
 Clean up elements of the undo/redo stack beyond the maximum size. More...
 
void UpdateNodeIDs ()
 Synchronize NodeIDs map used to speedup GetByID() method with the Nodes collection. More...
 
 vtkMRMLScene ()
 
 ~vtkMRMLScene () override
 

Static Protected Member Functions

static void SceneCallback (vtkObject *caller, unsigned long eid, void *clientData, void *callData)
 Handle vtkMRMLScene::DeleteEvent: clear the scene. More...
 

Protected Attributes

vtkCacheManagerCacheManager
 data i/o handling members More...
 
vtkDataIOManagerDataIOManager
 
std::map< std::string, vtkSmartPointer< vtkMRMLNode > > DefaultNodes
 
vtkCallbackCommand * DeleteEventCallback
 
char * Extensions
 
char * LastLoadedExtensions
 
char * LastLoadedVersion
 
int LoadFromXMLString
 
int MaximumNumberOfSavedUndoStates
 
std::map< std::string, vtkSmartPointer< vtkMRMLNode > > NodeIDs
 
vtkMTimeType NodeIDsMTime
 
NodeReferencesType NodeReferences
 
vtkCollection * Nodes
 
std::default_random_engine RandomGenerator
 
int ReadDataOnLoad
 
std::list< vtkCollection *> RedoStack
 
std::map< std::string, std::string > ReferencedIDChanges
 
std::map< std::string, std::string > RegisteredAbstractNodeClassTypeDisplayNames
 
std::vector< vtkMRMLNode *> RegisteredNodeClasses
 
std::vector< std::string > RegisteredNodeTags
 
std::set< std::string > ReservedIDs
 
std::string RootDirectory
 
int SaveToXMLString
 
std::string SceneXMLString
 
std::vector< unsigned long > States
 
vtkWeakPointer< vtkMRMLSubjectHierarchyNodeSubjectHierarchyNode
 subject hierarchy node More...
 
bool UndoFlag
 
std::list< vtkCollection *> UndoStack
 
std::map< std::string, int > UniqueIDs
 
std::map< std::string, int > UniqueNames
 
vtkCollection * URIHandlerCollection
 
std::string URL
 
vtkTagTableUserTagTable
 
char * Version
 

Friends

class vtkMRMLSceneViewNode
 

Detailed Description

A set of MRML Nodes that supports serialization and undo/redo.

vtkMRMLScene represents and provides methods to manipulate a list of MRML objects. The list is core and duplicate entries are not prevented.

See also
vtkMRMLNode
vtkCollection

Definition at line 57 of file vtkMRMLScene.h.

Member Typedef Documentation

◆ NodeReferencesType

typedef std::map< std::string, std::set<std::string> > vtkMRMLScene::NodeReferencesType
protected

Definition at line 835 of file vtkMRMLScene.h.

◆ Superclass

typedef vtkObject vtkMRMLScene::Superclass

Definition at line 67 of file vtkMRMLScene.h.

Member Enumeration Documentation

◆ SceneEventType

Enumerator
NodeAboutToBeAddedEvent 
NodeAddedEvent 
NodeAboutToBeRemovedEvent 
NodeRemovedEvent 
NodeClassRegisteredEvent 
NewSceneEvent 
MetadataAddedEvent 
ImportProgressFeedbackEvent 
SaveProgressFeedbackEvent 
StateEvent 

1024 (decimal)

StartEvent 
EndEvent 
ProgressEvent 
StartBatchProcessEvent 
EndBatchProcessEvent 
ProgressBatchProcessEvent 
StartCloseEvent 
EndCloseEvent 
ProgressCloseEvent 
StartImportEvent 
EndImportEvent 
ProgressImportEvent 
StartRestoreEvent 
EndRestoreEvent 
ProgressRestoreEvent 
StartSaveEvent 
EndSaveEvent 
ProgressSaveEvent 
StartUndoEvent 
EndUndoEvent 
ProgressUndoEvent 
StartRedoEvent 
EndRedoEvent 
ProgressRedoEvent 

Definition at line 673 of file vtkMRMLScene.h.

◆ StateType

The state of the scene reflects what the scene is doing. The scene is in BatchProcessState when nodes are either inserted or removed contiguously. The methods Connect, Import and Clear automatically set the scene in specific states. It is possible to manually set the scene in a specific state using StartState() and EndState(). When the scene is in BatchProcessState mode, observers can ignore the events NodeAddedEvent and NodeRemovedEvent to only synchronize with the scene when the scene is no longer in BatchProcessState (EndBatchProcessEvent being fired).

The call scene->Connect("myScene.mrml"); that closes and import a scene will fire the events:

Enumerator
BatchProcessState 
CloseState 
ImportState 
RestoreState 
SaveState 
UndoState 
RedoState 

Definition at line 591 of file vtkMRMLScene.h.

Constructor & Destructor Documentation

◆ vtkMRMLScene()

vtkMRMLScene::vtkMRMLScene ( )
protected

◆ ~vtkMRMLScene()

vtkMRMLScene::~vtkMRMLScene ( )
overrideprotected

Member Function Documentation

◆ AddDefaultNode()

void vtkMRMLScene::AddDefaultNode ( vtkMRMLNode node)

Set a default node for node creation and reset. One default node can be specified for each node class. It is useful for overriding default values that are set in a node's constructor.

◆ AddNewNodeByClass()

vtkMRMLNode* vtkMRMLScene::AddNewNodeByClass ( std::string  className,
std::string  nodeBaseName = "" 
)

Instantiate and add a node to the scene.

This is the preferred way to create and add a new node to the scene. It ensures that the new node properties are initialized considering its default nodes.

The method calls CreateNodeByClass(), vtkMRMLNode::SetName() and AddNode().

Note
Instead of calling SetName() after creating the node, prefer passing nodeBaseName, indeed the method AddNode() ensures that the final node name is unique in the scene by appending a suffix if needed.
See also
CreateNodeByClass(), vtkMRMLNode::SetName(), AddNode()
AddDefaultNode()
GenerateUniqueName()

◆ AddNewNodeByClassWithID()

vtkMRMLNode* vtkMRMLScene::AddNewNodeByClassWithID ( std::string  className,
std::string  nodeBaseName,
std::string  nodeID 
)

Instantiates and adds a new node to the scene with the specified ID.

If the node is reserved, or another node already exists with the same ID, then NULL will be returned This should only be used if it is important that the node is added to the scene with a specific ID

The method calls CreateNodeByClass(), vtkMRMLNode::SetName(), vtkMRMLNode::SetID(), and AddNode().

See also
AddNewNodeByClass(), CreateNodeByClass(), vtkMRMLNode::SetName(), vtkMRMLNode::SetID(), AddNode()

◆ AddNode()

vtkMRMLNode* vtkMRMLScene::AddNode ( vtkMRMLNode nodeToAdd)

Add a node to the scene and send vtkMRMLScene::NodeAboutToBeAddedEvent, vtkMRMLScene::NodeAddedEvent and vtkMRMLScene::SceneModified events.

A unique ID (e.g. "vtkMRMLModeNode1", "vtkMRMLScalarVolumeNode4") is generated and set to the node. If the node has no name (i.e. vtkMRMLNode::GetName() == 0), a unique name is given to the node (e.g. "Model" if it's the first model node added into the scene, "Model_1" if it's the second, etc. If node is a singleton, and a node of the same class with the same singleton tag already exists in the scene, nodeToAdd is NOT added but its properties are copied (c.f. vtkMRMLNode::CopyWithScene()) into the already existing singleton node. That node is then returned.

◆ AddNodeID()

void vtkMRMLScene::AddNodeID ( vtkMRMLNode node)
protected

Add node to NodeIDs map used to speedup GetByID() method.

◆ AddNodeNoNotify()

vtkMRMLNode* vtkMRMLScene::AddNodeNoNotify ( vtkMRMLNode n)
protected

Add a node to the scene without invoking a vtkMRMLScene::NodeAddedEvent event.

Warning
Use with extreme caution as it might unsynchronize observer.

◆ AddReferencedNodeID()

void vtkMRMLScene::AddReferencedNodeID ( const char *  id,
vtkMRMLNode refrencingNode 
)

The Scene maintains a map (NodeReferences) to keep track of the relationship between node IDs and the nodes referencing those IDs. Each node can use the call AddReferencedNodeID() to tell the scene that is 'has an interest' in the given ID so that the scene can notify that node when the ID has been remapped. It does this notification through the UpdateNodeReferences() call.

◆ AddReferencedNodes()

void vtkMRMLScene::AddReferencedNodes ( vtkMRMLNode node,
vtkCollection *  refNodes,
bool  recursive = true 
)
protected

Get referenced nodes

Parameters
recursiveAll referenced nodes recursively if true, only directly referenced nodes if false. Default is true.

◆ AddReservedID()

void vtkMRMLScene::AddReservedID ( const char *  id)

◆ AddURIHandler()

void vtkMRMLScene::AddURIHandler ( vtkURIHandler handler)

Add a uri handler to the collection.

◆ BuildID()

std::string vtkMRMLScene::BuildID ( const std::string &  baseID,
int  idIndex 
) const
protected

◆ BuildName()

std::string vtkMRMLScene::BuildName ( const std::string &  baseName,
int  nameIndex 
) const
protected

Combine a basename and an index to produce a full name.

◆ Clear()

void vtkMRMLScene::Clear ( int  removeSingletons = 0)

Remove nodes and clear undo/redo stacks.

Parameters
removeSingletonsIf set to true then it removes all singleton nodes (interaction, color, view nodes etc.) from the scene. If it is set to false then it just resets singleton nodes to their default state.

◆ ClearNodeIDs()

void vtkMRMLScene::ClearNodeIDs ( )
protected

Clear NodeIDs map used to speedup GetByID() method.

◆ ClearRedoStack()

void vtkMRMLScene::ClearRedoStack ( )

clear Redo stack, delete redo history

◆ ClearUndoStack()

void vtkMRMLScene::ClearUndoStack ( )

clear Undo stack, delete undo history

◆ Commit()

int vtkMRMLScene::Commit ( const char *  url = nullptr,
vtkMRMLMessageCollection userMessages = nullptr 
)

Save scene into URL If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation. Returns nonzero on success

◆ Connect()

int vtkMRMLScene::Connect ( vtkMRMLMessageCollection userMessages = nullptr)

Create new scene from URL If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation. Returns nonzero on success.

◆ CopyDefaultNodesToScene()

void vtkMRMLScene::CopyDefaultNodesToScene ( vtkMRMLScene scene)

Copies all default nodes into the parameter scene. Does not remove existing default nodes.

◆ CopyNode()

vtkMRMLNode* vtkMRMLScene::CopyNode ( vtkMRMLNode n)

Add a copy of a node to the scene.

◆ CopyNodeChangedIDs()

void vtkMRMLScene::CopyNodeChangedIDs ( vtkMRMLScene scene)

◆ CopyNodeInRedoStack()

void vtkMRMLScene::CopyNodeInRedoStack ( vtkMRMLNode node)
protected

◆ CopyNodeInUndoStack()

void vtkMRMLScene::CopyNodeInUndoStack ( vtkMRMLNode node)
protected

◆ CopyNodeReferences()

void vtkMRMLScene::CopyNodeReferences ( vtkMRMLScene scene)

◆ CopyRegisteredNodesToScene()

void vtkMRMLScene::CopyRegisteredNodesToScene ( vtkMRMLScene scene)

Copies all registered nodes into the parameter scene.

◆ CopySingletonNodesToScene()

void vtkMRMLScene::CopySingletonNodesToScene ( vtkMRMLScene scene)

Copies all singleton nodes into the parameter scene.

◆ CreateNodeByClass()

vtkMRMLNode* vtkMRMLScene::CreateNodeByClass ( const char *  className)

Create node with a given class.

Result of this method may be different than creating a node directly (using its own constructor), as this method ensures the new node properties are initialized based on the associated default node. Default node may be specified in the scene, using AddDefaultNode() method.

Note
A default node is associated with an other node if it belongs to the class hierarchy of that node.
Warning
This method does NOT add the new node to the scene. To create a new node and add it to the scene in one step, use AddNewNodeByClass().
See also
AddDefaultNode(), AddNewNodeByClass()

◆ CreateUniqueFileName()

static std::string vtkMRMLScene::CreateUniqueFileName ( const std::string &  filename,
const std::string &  knownExtension = "" 
)
static

Creates a unique (non-existent) file name by adding an index after base file name. knownExtension specifies the extension the index should be inserted before. It is necessary to provide extension, because there is no reliable way of correctly determining extension automatically (for example, file extension of some.file.nii.gz could be gz, nii.gz, or file.nii.gz and only one of them is correct).

◆ EndState()

void vtkMRMLScene::EndState ( unsigned long  state)

Unflag the scene as being in a state mode.

EndState() fires the state end event if the scene is no longer in the state mode. A matching StartState(state) must be called prior. e.g. vtkMRMLScene::EndImportEvent if state is ImportState .

EndState() internally pops the state out of the stack.

◆ FindNodeReference()

NodeReferencesType::iterator vtkMRMLScene::FindNodeReference ( const char *  referencedId,
vtkMRMLNode referencingNode 
)
protected

Get a NodeReferences iterator for a node reference.

◆ FindURIHandler()

vtkURIHandler* vtkMRMLScene::FindURIHandler ( const char *  URI)

Find a URI handler in the collection that can work on the passed URI.

Returns nullptr on failure

◆ FindURIHandlerByName()

vtkURIHandler* vtkMRMLScene::FindURIHandlerByName ( const char *  name)

Returns a URIhandler of a specific type if its name is known.

◆ GenerateUniqueID() [1/2]

std::string vtkMRMLScene::GenerateUniqueID ( vtkMRMLNode node)
protected

◆ GenerateUniqueID() [2/2]

std::string vtkMRMLScene::GenerateUniqueID ( const std::string &  baseID)
protected

◆ GenerateUniqueName() [1/2]

std::string vtkMRMLScene::GenerateUniqueName ( const std::string &  baseName)

Generate a node name that is unique in the scene. Calling this function successively with the same baseName returns a different name: e.g. baseName1, baseName2, baseName3.

◆ GenerateUniqueName() [2/2]

std::string vtkMRMLScene::GenerateUniqueName ( vtkMRMLNode node)
protected

Return a unique name for a MRML node. It uses the node tag as the base.

◆ GetCacheManager()

virtual vtkCacheManager* vtkMRMLScene::GetCacheManager ( )
virtual

◆ GetChangedID()

const char* vtkMRMLScene::GetChangedID ( const char *  id)

get the new id of the node that is different from one in the mrml file or nullptr if id has not changed

◆ GetClassName()

virtual const char* vtkMRMLScene::GetClassName ( )
virtual

◆ GetClassNameByTag()

const char* vtkMRMLScene::GetClassNameByTag ( const char *  tagName)

Add a path to the list.

◆ GetDataIOManager()

virtual vtkDataIOManager* vtkMRMLScene::GetDataIOManager ( )
virtual

◆ GetDefaultNodeByClass()

vtkMRMLNode* vtkMRMLScene::GetDefaultNodeByClass ( const char *  className)

◆ GetExtensions()

virtual char* vtkMRMLScene::GetExtensions ( )
virtual

The current software extensions (optional software components). It is up to the application to define a format, it can be for example a semicolon-separated list of strings.

◆ GetFirstNode()

vtkMRMLNode* vtkMRMLScene::GetFirstNode ( const char *  byName = nullptr,
const char *  byClass = nullptr,
const int *  byHideFromEditors = nullptr,
bool  exactNameMatch = true 
)

Return the first node in the scene that matches the filtering criteria if specified.

By default, byName will be compared using an exact match. If exactNameMatch is set to false, the node will be returned if its name starts with byName. If the pointer byHideFromEditors is not set, the function will return both the nodes hidden from editors as well as the nodes visible in editors. If the pointer byHideFromEditors is set, the function will only return the nodes that are either hidden from editors or the nodes that are visible in editors.

◆ GetFirstNodeByClass()

vtkMRMLNode* vtkMRMLScene::GetFirstNodeByClass ( const char *  className)

Convenience function for getting 0-th node of a specified class in the scene.

◆ GetFirstNodeByName()

vtkMRMLNode* vtkMRMLScene::GetFirstNodeByName ( const char *  name)

◆ GetLastLoadedExtensions()

virtual char* vtkMRMLScene::GetLastLoadedExtensions ( )
virtual

The extensions used in the last loaded scene file.

◆ GetLastLoadedVersion()

virtual char* vtkMRMLScene::GetLastLoadedVersion ( )
virtual

The version of the last loaded scene file.

◆ GetLoadFromXMLString()

virtual int vtkMRMLScene::GetLoadFromXMLString ( )
virtual

◆ GetMaximumNumberOfSavedUndoStates()

virtual int vtkMRMLScene::GetMaximumNumberOfSavedUndoStates ( )
virtual

◆ GetModifiedSinceRead()

bool vtkMRMLScene::GetModifiedSinceRead ( vtkCollection *  modifiedNodes = nullptr)

Returns true if the scene has been "significantly" modified since the last saved state. If modifiedNodes is provided then it returns the list of nodes that have been found to be modified.

◆ GetNextNode()

vtkMRMLNode* vtkMRMLScene::GetNextNode ( )
Deprecated:
This method is deprecated, kept for backward compatibility but it will be removed in the future. The problem is that it changes the node collection's internal iterator, which may cause unintended side effects in caller functions that also use the node collection's internal iterator. Use other methods instead (GetNodes(), GetNodesByClass(), etc.) or traverse collection returned by GetNodes() using a collection iterator.

◆ GetNextNodeByClass()

vtkMRMLNode* vtkMRMLScene::GetNextNodeByClass ( const char *  className)
Deprecated:
This method is deprecated, kept for backward compatibility but it will be removed in the future. The problem is that it changes the node collection's internal iterator, which may cause unintended side effects in caller functions that also use the node collection's internal iterator. Use other methods instead (GetNodes(), GetNodesByClass(), etc.) or traverse collection returned by GetNodes() using a collection iterator.

◆ GetNodeByID() [1/2]

vtkMRMLNode* vtkMRMLScene::GetNodeByID ( const char *  name)

Get node given a unique ID.

◆ GetNodeByID() [2/2]

vtkMRMLNode* vtkMRMLScene::GetNodeByID ( std::string  name)

◆ GetNodeClassesList()

std::list<std::string> vtkMRMLScene::GetNodeClassesList ( )

◆ GetNodeReferenceIDsFromUndoStack()

void vtkMRMLScene::GetNodeReferenceIDsFromUndoStack ( std::set< std::string > &  referenceIDs) const
protected

Returns all unique node reference IDs that are referenced within the undo stack.

◆ GetNodes()

vtkCollection* vtkMRMLScene::GetNodes ( )

Return collection of nodes.

◆ GetNodesByClass() [1/2]

int vtkMRMLScene::GetNodesByClass ( const char *  className,
std::vector< vtkMRMLNode *> &  nodes 
)

Get vector of nodes of a specified class in the scene.

◆ GetNodesByClass() [2/2]

vtkCollection* vtkMRMLScene::GetNodesByClass ( const char *  className)
Warning
You are responsible for deleting the returned collection.

◆ GetNodesByClassByName()

vtkCollection* vtkMRMLScene::GetNodesByClassByName ( const char *  className,
const char *  name 
)

Get nodes of a specified class having the specified name.

Warning
You are responsible for deleting the collection.

◆ GetNodesByName()

vtkCollection* vtkMRMLScene::GetNodesByName ( const char *  name)

Get nodes having the specified name.

◆ GetNthNode()

vtkMRMLNode* vtkMRMLScene::GetNthNode ( int  n)

Get n-th node in the scene.

◆ GetNthNodeByClass()

vtkMRMLNode* vtkMRMLScene::GetNthNodeByClass ( int  n,
const char *  className 
)

Get n-th node of a specified class in the scene.

◆ GetNthReferencedID()

const char* vtkMRMLScene::GetNthReferencedID ( int  n)

Get the ReferencedID component of the n-th ReferencedID-ReferencingNode pair. Only for testing and debugging.

◆ GetNthReferencingNode()

vtkMRMLNode* vtkMRMLScene::GetNthReferencingNode ( int  n)

Get the ReferencingNode component of the n-th ReferencedID-ReferencingNode pair. Only for testing and debugging.

◆ GetNthRegisteredAbstractNodeClassName()

std::string vtkMRMLScene::GetNthRegisteredAbstractNodeClassName ( int  n)

Get the nth registered abstract node class name. Returns empty string if out of range.

◆ GetNthRegisteredAbstractNodeTypeDisplayName()

std::string vtkMRMLScene::GetNthRegisteredAbstractNodeTypeDisplayName ( int  n)

Get the nth registered abstract node type display name. Returns empty string if out of range.

◆ GetNthRegisteredNodeClass()

vtkMRMLNode* vtkMRMLScene::GetNthRegisteredNodeClass ( int  n)

Get the nth registered node class, returns nullptr if n is out of the range 0-GetNumberOfRegisteredNodeClasses Useful for iterating through nodes to find all the possible storage nodes.

◆ GetNumberOfNodeReferences()

int vtkMRMLScene::GetNumberOfNodeReferences ( )

Get the total number of node references (number of ReferencedID-ReferencingNode pairs).

Warning
Only for testing and debugging.

◆ GetNumberOfNodes()

int vtkMRMLScene::GetNumberOfNodes ( )

Get number of nodes in the scene.

◆ GetNumberOfNodesByClass()

int vtkMRMLScene::GetNumberOfNodesByClass ( const char *  className)

Get number of nodes of a specified class in the scene.

◆ GetNumberOfRedoLevels()

int vtkMRMLScene::GetNumberOfRedoLevels ( )
inline

returns number of redo steps in the history buffer

Definition at line 399 of file vtkMRMLScene.h.

◆ GetNumberOfRegisteredAbstractNodeClasses()

int vtkMRMLScene::GetNumberOfRegisteredAbstractNodeClasses ( )

Get the number of registered abstract node classes.

◆ GetNumberOfRegisteredNodeClasses()

int vtkMRMLScene::GetNumberOfRegisteredNodeClasses ( )

Get the number of registered node classes (is probably greater than the current number of nodes instantiated in the scene)

◆ GetNumberOfUndoLevels()

int vtkMRMLScene::GetNumberOfUndoLevels ( )
inline

returns number of undo steps in the history buffer

Definition at line 396 of file vtkMRMLScene.h.

◆ GetReadDataOnLoad()

virtual int vtkMRMLScene::GetReadDataOnLoad ( )
virtual

◆ GetReferencedNodes()

vtkCollection* vtkMRMLScene::GetReferencedNodes ( vtkMRMLNode node,
bool  recursive = true 
)

Return collection of all nodes referenced directly or indirectly by node.

Parameters
recursiveAll referenced nodes recursively if true, only directly referenced nodes if false. Default is true.

The node itself is in first place in the collection. No doublon in the list. For a node to be referenced by another node, the latter must call AddReferencedNodeID().

Warning
You are responsible for deleting the returned collection.
See also
GetReferencedSubScene()

◆ GetReferencedSubScene()

void vtkMRMLScene::GetReferencedSubScene ( vtkMRMLNode node,
vtkMRMLScene newScene 
)

Get a sub-scene containing all nodes directly or indirectly referenced by the input node.

Note
GetReferencedNodes() is internally called.
See also
AddReferencedNodeID(), GetReferencedNodes()

◆ GetReferencingNodes()

void vtkMRMLScene::GetReferencingNodes ( vtkMRMLNode referencedNode,
std::vector< vtkMRMLNode *> &  referencingNodes 
)

Get vector of nodes containing references to an input node.

◆ GetRootDirectory()

const char* vtkMRMLScene::GetRootDirectory ( )

Get Root directory, where URL is pointing.

◆ GetSaveToXMLString()

virtual int vtkMRMLScene::GetSaveToXMLString ( )
virtual

◆ GetSceneXMLString()

const std::string& vtkMRMLScene::GetSceneXMLString ( )

Returns the saved scene with an XML format if SaveToXMLString is true and Commit() was called prior.

See also
Commit(), SetSaveToXMLString()

◆ GetSingletonNode() [1/2]

vtkMRMLNode* vtkMRMLScene::GetSingletonNode ( const char *  singletonTag,
const char *  className 
)

Search and return the singleton of type className with a singletonTag tag.

Return 0 if such node can't be found in the scene.

◆ GetSingletonNode() [2/2]

vtkMRMLNode* vtkMRMLScene::GetSingletonNode ( vtkMRMLNode n)

Search and return a matching singleton in the scene that the input singleton node will overwrite if it is added to the scene.

There is matching if the singleton tag and className are the same, or there is an existing node with the generated unique singleton node ID. Return 0 if such node can't be found in the scene.

◆ GetStates()

int vtkMRMLScene::GetStates ( ) const

Returns the current state of the scene.

It is a combination of all current states. Returns 0 if the scene has no current state flag.

See also
IsBatchProcessing, IsClosing, IsImporting, IsRestoring
StartState, EndState

◆ GetStorableNodesModifiedSinceRead()

bool vtkMRMLScene::GetStorableNodesModifiedSinceRead ( vtkCollection *  modifiedStorableNodes = nullptr)

Search the scene for storable nodes that are "ModifiedSinceRead".

Returns true if at least 1 matching node is found. If modifiedStorableNodes is passed the modified nodes are appended. Note that the nodes see their reference count being incremented while being in the list. Don't forget to clear it as soon as you don't need it.

◆ GetStoredTime()

virtual vtkMTimeType vtkMRMLScene::GetStoredTime ( )
virtual

Timestamp of the scene's last saved state.

◆ GetSubjectHierarchyNode()

vtkMRMLSubjectHierarchyNode* vtkMRMLScene::GetSubjectHierarchyNode ( )

◆ GetTagByClassName()

const char* vtkMRMLScene::GetTagByClassName ( const char *  className)

Add a path to the list.

◆ GetTypeDisplayNameByClassName()

std::string vtkMRMLScene::GetTypeDisplayNameByClassName ( std::string  className)

Get type display name which is shown in the GUI.

◆ GetUndoFlag()

bool vtkMRMLScene::GetUndoFlag ( )
inline

Definition at line 380 of file vtkMRMLScene.h.

◆ GetUniqueIDIndex()

int vtkMRMLScene::GetUniqueIDIndex ( const std::string &  baseID)
protected

◆ GetUniqueNameByString()

const char* vtkMRMLScene::GetUniqueNameByString ( const char *  baseName)
Deprecated:
GetUniqueNameByString Obsolete utility function that provides an unsafe API for GenerateUniqueName()
See also
GenerateUniqueName, GenerateUniqueID

◆ GetUniqueNameIndex()

int vtkMRMLScene::GetUniqueNameIndex ( const std::string &  baseName)
protected

Returns a unique index for a given baseName.

Calling this function successively with the same baseName returns an incremented index: 1, 2, 3...

See also
GenerateUniqueName

◆ GetURIHandlerCollection()

virtual vtkCollection* vtkMRMLScene::GetURIHandlerCollection ( )
virtual

◆ GetURL()

const char* vtkMRMLScene::GetURL ( )

Get URL (file name) of the scene.

◆ GetUserTagTable()

virtual vtkTagTable* vtkMRMLScene::GetUserTagTable ( )
virtual

◆ GetVersion()

virtual char* vtkMRMLScene::GetVersion ( )
virtual

The current software version.

◆ Import()

int vtkMRMLScene::Import ( vtkMRMLMessageCollection userMessages = nullptr)

Add the scene into the existing scene (no clear) from URL file or from.

See also
SceneXMLString XML string.

Returns nonzero on success.

See also
SetURL(), GetLoadFromXMLString(), SetSceneXMLString() If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation.

◆ InitTraversal()

void vtkMRMLScene::InitTraversal ( )
Deprecated:
This method is deprecated, kept for backward compatibility but it will be removed in the future. The problem is that it changes the node collection's internal iterator, which may cause unintended side effects in caller functions that also use the node collection's internal iterator. Use other methods instead (GetNodes(), GetNodesByClass(), etc.) or traverse collection returned by GetNodes() using a collection iterator.

◆ InsertAfterNode()

vtkMRMLNode* vtkMRMLScene::InsertAfterNode ( vtkMRMLNode item,
vtkMRMLNode newItem 
)

insert a node in the scene after a specified node

◆ InsertBeforeNode()

vtkMRMLNode* vtkMRMLScene::InsertBeforeNode ( vtkMRMLNode item,
vtkMRMLNode newItem 
)

insert a node in the scene before a specified node

◆ IsA()

virtual int vtkMRMLScene::IsA ( const char *  type)
virtual

◆ IsBatchProcessing()

bool vtkMRMLScene::IsBatchProcessing ( ) const
inline

Return true if the scene is in BatchProcess state, false otherwise.

Definition at line 993 of file vtkMRMLScene.h.

◆ IsClosing()

bool vtkMRMLScene::IsClosing ( ) const
inline

Return true if the scene is in Close state, false otherwise.

Definition at line 1000 of file vtkMRMLScene.h.

◆ IsFilePathRelative()

int vtkMRMLScene::IsFilePathRelative ( const char *  filepath)

◆ IsImporting()

bool vtkMRMLScene::IsImporting ( ) const
inline

Return true if the scene is in Import state, false otherwise.

Definition at line 1007 of file vtkMRMLScene.h.

◆ IsNodeClassRegistered()

bool vtkMRMLScene::IsNodeClassRegistered ( const std::string &  className)

Return True if className is a registered node.

See also
RegisterNodeClass(vtkMRMLNode* node)

◆ IsNodeIDReservedByUndo()

bool vtkMRMLScene::IsNodeIDReservedByUndo ( const std::string  id) const
protected

Returns true if a node is not referenced within the scene, but is referenced within the Undo stack.

◆ IsNodePresent()

int vtkMRMLScene::IsNodePresent ( vtkMRMLNode n)

Determine whether a particular node is present.

Returns its position in the list.

◆ IsNodeReferencingNodeID()

bool vtkMRMLScene::IsNodeReferencingNodeID ( vtkMRMLNode referencingNode,
const char *  id 
)

◆ IsRedoing()

bool vtkMRMLScene::IsRedoing ( ) const
inline

Return true if the scene is in Redo state (in the process of redoing node changes), false otherwise.

Definition at line 1028 of file vtkMRMLScene.h.

◆ IsReservedID()

bool vtkMRMLScene::IsReservedID ( const std::string &  id)

◆ IsRestoring()

bool vtkMRMLScene::IsRestoring ( ) const
inline

Return true if the scene is in Restore state, false otherwise.

Definition at line 1014 of file vtkMRMLScene.h.

◆ IsTypeOf()

static int vtkMRMLScene::IsTypeOf ( const char *  type)
static

◆ IsUndoing()

bool vtkMRMLScene::IsUndoing ( ) const
inline

Return true if the scene is in Undo state (in the process of undoing node changes), false otherwise.

Definition at line 1021 of file vtkMRMLScene.h.

◆ New()

static vtkMRMLScene* vtkMRMLScene::New ( )
static

◆ NodeAdded() [1/2]

void vtkMRMLScene::NodeAdded ( vtkMRMLNode n)

Invoke a vtkMRMLScene::NodeAddedEvent.

This function is used after adding a bunch of nodes with AddNodeNoNotify()

◆ NodeAdded() [2/2]

void vtkMRMLScene::NodeAdded ( )
inline

Definition at line 238 of file vtkMRMLScene.h.

◆ ParseVersion()

static bool vtkMRMLScene::ParseVersion ( const char *  versionString,
std::string &  application,
int &  major,
int &  minor,
int &  patch,
int &  revision 
)
static

Parse version string. Return true if version is successfully parsed.

◆ PercentEncode()

static std::string vtkMRMLScene::PercentEncode ( std::string  s)
static

Convert reserved characters into percent notation to avoid issues with filenames containing things that might be mistaken, for example, for windows drive letters. Used internally by SaveSceneToSlicerDataBundleDirectory. This is not a general purpose implementation; it preserves commonly used characters for filenames but avoids known issue like slashes or colons. Ideally a version from vtksys or similar should be used, but nothing seems to be available. https://en.wikipedia.org/wiki/Percent-encoding See https://github.com/Slicer/Slicer/issues/2605

◆ PrintSelf()

void vtkMRMLScene::PrintSelf ( ostream &  os,
vtkIndent  indent 
)
override

◆ ProgressState()

void vtkMRMLScene::ProgressState ( unsigned long  state,
int  progress = 0 
)

TODO: Report progress of the current state.

◆ PushIntoRedoStack()

void vtkMRMLScene::PushIntoRedoStack ( )
protected

◆ PushIntoUndoStack()

void vtkMRMLScene::PushIntoUndoStack ( )
protected

◆ ReadFromMRB()

bool vtkMRMLScene::ReadFromMRB ( const char *  fullName,
bool  clear = false,
vtkMRMLMessageCollection userMessages = nullptr 
)

Read the scene from a MRML scene bundle (.mrb) file If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation.

◆ Redo()

void vtkMRMLScene::Redo ( )

redo, set the scene to previously undone

◆ RegisterAbstractNodeClass()

void vtkMRMLScene::RegisterAbstractNodeClass ( std::string  className,
std::string  typeDisplayName 
)

Register abstract node type display name.

This is used by GetTypeDisplayNameByClassName for an abstract class (Volume, Markups, etc), for example in a node selector. Since abstract base classes cannot be instantiated, RegisterNodeClass cannot be used for this purpose.

See also
RegisterNodeClass(vtkMRMLNode* node), GetTypeDisplayNameByClassName

◆ RegisterNodeClass() [1/2]

void vtkMRMLScene::RegisterNodeClass ( vtkMRMLNode node,
const char *  tagName 
)

Register a node class to the scene so that the scene can later create the same node type from a tag or a class name.

This is mainly used during scene loading. The XML element names are used to instantiate the nodes.

node is an instance of the class to instantiate when CreateNodeByClass() is called with a corresponding className retrieved using GetClassNameByTag(). tagName can be 0 or an XML tag a custom tagName. If tagName is 0 (default), the node GetNodeTagName() is used. Otherwise, tagName is used.

The signature with tagName != 0 is useful to add support for scene backward compatibility. Calls with an obsolete tag should be wrapped with: #if MRML_APPLICATION_SUPPORT_VERSION < 0x0X0Y0Z and #endif where X is the major version of Slicer scene to support, Y the minor and Z the patch version.

See also
CreateNodeByClass(), GetClassNameByTag()

◆ RegisterNodeClass() [2/2]

void vtkMRMLScene::RegisterNodeClass ( vtkMRMLNode node)

Utility function to RegisterNodeClass(), the node tag name is used when registering the node.

See also
RegisterNodeClass(vtkMRMLNode* node, const char* tagName)

◆ RemoveAllDefaultNodes()

void vtkMRMLScene::RemoveAllDefaultNodes ( )

Deletes all default node values from the scene.

◆ RemoveAllNodes()

void vtkMRMLScene::RemoveAllNodes ( bool  removeSingletons)
protected

◆ RemoveInvalidNodeReferences()

void vtkMRMLScene::RemoveInvalidNodeReferences ( vtkCollection *  checkNodes,
const std::set< std::string > &  validNodeIDs 
)
protected

Remove invalid node references after scene import.

◆ RemoveNode()

void vtkMRMLScene::RemoveNode ( vtkMRMLNode n)

Remove a path from the list.

◆ RemoveNodeID()

void vtkMRMLScene::RemoveNodeID ( char *  nodeID)
protected

Remove node from NodeIDs map used to speedup GetByID() method.

◆ RemoveNodeReferences()

void vtkMRMLScene::RemoveNodeReferences ( vtkMRMLNode node)

◆ RemoveReferencedNodeID()

void vtkMRMLScene::RemoveReferencedNodeID ( const char *  id,
vtkMRMLNode refrencingNode 
)

◆ RemoveReferencesToNode()

void vtkMRMLScene::RemoveReferencesToNode ( vtkMRMLNode node)

◆ RemoveReservedIDs()

void vtkMRMLScene::RemoveReservedIDs ( )

◆ RemoveUnusedNodeReferences()

void vtkMRMLScene::RemoveUnusedNodeReferences ( )

◆ ReserveNodeReferenceIDs()

void vtkMRMLScene::ReserveNodeReferenceIDs ( vtkMRMLNode node)
protected

Reserve all node reference ids for a node.

◆ ResetNodes()

void vtkMRMLScene::ResetNodes ( )

Reset all nodes to their constructor's state.

◆ SafeDownCast()

static vtkMRMLScene* vtkMRMLScene::SafeDownCast ( vtkObject *  o)
static

◆ SaveSceneScreenshot()

void vtkMRMLScene::SaveSceneScreenshot ( vtkImageData *  thumbnail)

Utility function to write the scene thumbnail to a file in the scene's root folder.

◆ SaveSceneToSlicerDataBundleDirectory()

bool vtkMRMLScene::SaveSceneToSlicerDataBundleDirectory ( const char *  sdbDir,
vtkImageData *  thumbnail = nullptr,
vtkMRMLMessageCollection userMessages = nullptr 
)

Save the scene into a self contained directory, sdbDir If thumbnail image is provided then it is saved in the scene's root folder. If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation. Returns false if the save failed.

◆ SaveStateForUndo() [1/4]

void vtkMRMLScene::SaveStateForUndo ( )

Save current state in the undo buffer.

◆ SaveStateForUndo() [2/4]

void vtkMRMLScene::SaveStateForUndo ( vtkMRMLNode node)

Save current state of the node in the undo buffer

Deprecated:
Use SaveStateForUndo() instead. Storing of only selected nodes may result in incomplete saving of important changes in the scene. Instead, each node's UndoEnabled flag will tell if that node's state must be stored or not.

◆ SaveStateForUndo() [3/4]

void vtkMRMLScene::SaveStateForUndo ( vtkCollection *  nodes)

Save current state of the nodes in the undo buffer

Deprecated:
Use SaveStateForUndo() instead. Storing of only selected nodes may result in incomplete saving of important changes in the scene. Instead, each node's UndoEnabled flag will tell if that node's state must be stored or not.

◆ SaveStateForUndo() [4/4]

void vtkMRMLScene::SaveStateForUndo ( std::vector< vtkMRMLNode *>  nodes)

◆ SaveStorableNodeToSlicerDataBundleDirectory()

bool vtkMRMLScene::SaveStorableNodeToSlicerDataBundleDirectory ( vtkMRMLStorableNode storableNode,
std::string &  dataDir,
std::map< vtkMRMLStorageNode *, std::vector< std::string > > &  originalStorageNodeFileNames,
vtkMRMLMessageCollection userMessages 
)
protected

Saves a storable node while storing original filenames. Returns true on success (written successfully or no need to write the node). If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation.

◆ SceneCallback()

static void vtkMRMLScene::SceneCallback ( vtkObject *  caller,
unsigned long  eid,
void *  clientData,
void *  callData 
)
staticprotected

Handle vtkMRMLScene::DeleteEvent: clear the scene.

◆ SetCacheManager()

virtual void vtkMRMLScene::SetCacheManager ( vtkCacheManager )
virtual

◆ SetDataIOManager()

virtual void vtkMRMLScene::SetDataIOManager ( vtkDataIOManager )
virtual

◆ SetExtensions()

virtual void vtkMRMLScene::SetExtensions ( const char *  )
virtual

◆ SetLastLoadedExtensions()

virtual void vtkMRMLScene::SetLastLoadedExtensions ( const char *  )
virtual

◆ SetLastLoadedVersion()

virtual void vtkMRMLScene::SetLastLoadedVersion ( const char *  )
virtual

◆ SetLoadFromXMLString()

virtual void vtkMRMLScene::SetLoadFromXMLString ( int  )
virtual

This property controls whether Import() loads a scene from an XML string or from an XML file.

If true, contents is loaded from SceneXMLString. If false, contents is loaded from the URL file.

See also
Import(), SetSceneXMLString(), SetURL(), SetSaveToXMLString()

◆ SetMaximumNumberOfSavedUndoStates()

void vtkMRMLScene::SetMaximumNumberOfSavedUndoStates ( int  stackSize)

Sets the maximum number of saved undo states and removes the oldest saved states so that the number of saved states is less than the new maximum.

◆ SetReadDataOnLoad()

virtual void vtkMRMLScene::SetReadDataOnLoad ( int  )
virtual

◆ SetRootDirectory()

void vtkMRMLScene::SetRootDirectory ( const char *  dir)

Set Root directory, where URL is pointing.

◆ SetSaveToXMLString()

virtual void vtkMRMLScene::SetSaveToXMLString ( int  )
virtual

This property controls whether Commit() should save the scene as an XML string or an XML file.

If true, the contents generated by Commit() will be in SceneXMLString. If false, the contents will be saved into the URL file.

See also
Commit(), GetSceneXMLString(), SetURL(), SetLoadFromXMLString()

◆ SetSceneXMLString()

void vtkMRMLScene::SetSceneXMLString ( const std::string &  xmlString)

Set the XML string to read from by Import() if GetLoadFromXMLString() is true.

See also
Import(), GetLoadFromXMLString(), GetSceneXMLString()

◆ SetStorableNodesModifiedSinceRead() [1/2]

void vtkMRMLScene::SetStorableNodesModifiedSinceRead ( )

Search the scene for storable nodes that are not "ModifiedSinceRead".

Useful after loading a scene from a temporary directory and deleting the files.

See also
SetStorableNodesModifiedSinceRead(vtkCollection*)

◆ SetStorableNodesModifiedSinceRead() [2/2]

static void vtkMRMLScene::SetStorableNodesModifiedSinceRead ( vtkCollection *  storableNodes)
static

Given a collection of storable nodes, iterate through and call StorableModified() on them.

◆ SetSubjectHierarchyNode()

virtual void vtkMRMLScene::SetSubjectHierarchyNode ( vtkMRMLSubjectHierarchyNode )
protectedvirtual

◆ SetUndoFlag()

void vtkMRMLScene::SetUndoFlag ( bool  flag)
inline

Definition at line 381 of file vtkMRMLScene.h.

◆ SetUndoOff()

void vtkMRMLScene::SetUndoOff ( )
inline

Definition at line 379 of file vtkMRMLScene.h.

◆ SetUndoOn()

void vtkMRMLScene::SetUndoOn ( )
inline

Set undo on/off.

Definition at line 378 of file vtkMRMLScene.h.

◆ SetURIHandlerCollection()

virtual void vtkMRMLScene::SetURIHandlerCollection ( vtkCollection *  )
virtual

◆ SetURL()

void vtkMRMLScene::SetURL ( const char *  url)

Set URL (file name) of the scene.

◆ SetUserTagTable()

virtual void vtkMRMLScene::SetUserTagTable ( vtkTagTable )
virtual

◆ SetVersion()

virtual void vtkMRMLScene::SetVersion ( const char *  )
virtual

◆ StartState()

void vtkMRMLScene::StartState ( unsigned long  state,
int  anticipatedMaxProgress = 0 
)

Flag the scene as being in a state mode.

A matching EndState(state) must be called later. Nested states are supported as long as they all have their own EndState() calls. StartState() fires the state start event if it isn't already in that state, e.g. StartImportEvent if state is ImportState . If the state is BatchProcessState , CloseState , ImportState or RestoreState and if the scene is not already in a BatchProcessState state, it also fires the event StartBatchProcessEvent .

Example:

scene->StartState(vtkMRMLScene::ImportState);
// fires: StartBatchProcessEvent, StartImportEvent
scene->StartState(vtkMRMLScene::ImportState);
// doesn't fire anything
scene->StartState(vtkMRMLScene::RestoreState);
// fires: StartRestoreEvent
scene->EndState(vtkMRMLScene::RestoreState);
// fires: EndRestoreEvent
scene->EndState(vtkMRMLScene::ImportState);
// doesn't fire anything
scene->EndState(vtkMRMLScene::ImportState);
// fires: EndImportEvent, StartBatchProcessEvent

StartState() internally pushes the state into a stack.

See also
EndState, GetStates

◆ TrimUndoStack()

void vtkMRMLScene::TrimUndoStack ( )
protected

Clean up elements of the undo/redo stack beyond the maximum size.

◆ Undo()

void vtkMRMLScene::Undo ( )

undo, set the scene to previous state

◆ UnpackSlicerDataBundle()

static std::string vtkMRMLScene::UnpackSlicerDataBundle ( const char *  sdbFilePath,
const char *  temporaryDirectory,
vtkMRMLMessageCollection userMessages = nullptr 
)
static

Unpack the file into a temp directory and return the scene file inside. Note that the first mrml file found in the extracted directory will be used. If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation.

◆ UpdateNodeChangedIDs()

void vtkMRMLScene::UpdateNodeChangedIDs ( )

Change node IDs based on the ReferencedIDChanges list.

◆ UpdateNodeIDs()

void vtkMRMLScene::UpdateNodeIDs ( )
protected

Synchronize NodeIDs map used to speedup GetByID() method with the Nodes collection.

◆ UpdateNodeReferences()

void vtkMRMLScene::UpdateNodeReferences ( vtkCollection *  checkNodes = nullptr)

Notify nodes about node ID changes.

vtkMRMLNode::UpdateReferenceID() is called for all the nodes that refer to a node with a changed ID.

If checkNodes is not nullptr, then only those nodes are notified that are part of the checkNodes collection.

◆ WriteToMRB()

bool vtkMRMLScene::WriteToMRB ( const char *  filename,
vtkImageData *  thumbnail = nullptr,
vtkMRMLMessageCollection userMessages = nullptr 
)

Write the scene to a MRML scene bundle (.mrb) file. If thumbnail image is provided then it is saved in the scene's root folder. If userMessages is not nullptr then the method may add messages to it about issues encountered during the operation. Returns false if the save failed.

Friends And Related Function Documentation

◆ vtkMRMLSceneViewNode

friend class vtkMRMLSceneViewNode
friend

make the vtkMRMLSceneViewNode a friend since it has internal vtkMRMLScene so that it can call protected methods, for example UpdateNodeIDs() but that's the only class that is allowed to do so

Definition at line 63 of file vtkMRMLScene.h.

Member Data Documentation

◆ CacheManager

vtkCacheManager* vtkMRMLScene::CacheManager
protected

data i/o handling members

Definition at line 923 of file vtkMRMLScene.h.

◆ DataIOManager

vtkDataIOManager* vtkMRMLScene::DataIOManager
protected

Definition at line 924 of file vtkMRMLScene.h.

◆ DefaultNodes

std::map< std::string, vtkSmartPointer<vtkMRMLNode> > vtkMRMLScene::DefaultNodes
protected

Definition at line 954 of file vtkMRMLScene.h.

◆ DeleteEventCallback

vtkCallbackCommand* vtkMRMLScene::DeleteEventCallback
protected

Definition at line 974 of file vtkMRMLScene.h.

◆ Extensions

char* vtkMRMLScene::Extensions
protected

Definition at line 969 of file vtkMRMLScene.h.

◆ LastLoadedExtensions

char* vtkMRMLScene::LastLoadedExtensions
protected

Definition at line 972 of file vtkMRMLScene.h.

◆ LastLoadedVersion

char* vtkMRMLScene::LastLoadedVersion
protected

Definition at line 971 of file vtkMRMLScene.h.

◆ LoadFromXMLString

int vtkMRMLScene::LoadFromXMLString
protected

Definition at line 958 of file vtkMRMLScene.h.

◆ MaximumNumberOfSavedUndoStates

int vtkMRMLScene::MaximumNumberOfSavedUndoStates
protected

Definition at line 930 of file vtkMRMLScene.h.

◆ NodeIDs

std::map< std::string, vtkSmartPointer<vtkMRMLNode> > vtkMRMLScene::NodeIDs
protected

Definition at line 949 of file vtkMRMLScene.h.

◆ NodeIDsMTime

vtkMTimeType vtkMRMLScene::NodeIDsMTime
protected

Definition at line 964 of file vtkMRMLScene.h.

◆ NodeReferences

NodeReferencesType vtkMRMLScene::NodeReferences
protected

Definition at line 947 of file vtkMRMLScene.h.

◆ Nodes

vtkCollection* vtkMRMLScene::Nodes
protected

Definition at line 917 of file vtkMRMLScene.h.

◆ RandomGenerator

std::default_random_engine vtkMRMLScene::RandomGenerator
protected

Definition at line 976 of file vtkMRMLScene.h.

◆ ReadDataOnLoad

int vtkMRMLScene::ReadDataOnLoad
protected

Definition at line 962 of file vtkMRMLScene.h.

◆ RedoStack

std::list< vtkCollection* > vtkMRMLScene::RedoStack
protected

Definition at line 934 of file vtkMRMLScene.h.

◆ ReferencedIDChanges

std::map< std::string, std::string > vtkMRMLScene::ReferencedIDChanges
protected

Definition at line 948 of file vtkMRMLScene.h.

◆ RegisteredAbstractNodeClassTypeDisplayNames

std::map< std::string, std::string > vtkMRMLScene::RegisteredAbstractNodeClassTypeDisplayNames
protected

Definition at line 945 of file vtkMRMLScene.h.

◆ RegisteredNodeClasses

std::vector< vtkMRMLNode* > vtkMRMLScene::RegisteredNodeClasses
protected

Definition at line 943 of file vtkMRMLScene.h.

◆ RegisteredNodeTags

std::vector< std::string > vtkMRMLScene::RegisteredNodeTags
protected

Definition at line 944 of file vtkMRMLScene.h.

◆ ReservedIDs

std::set<std::string> vtkMRMLScene::ReservedIDs
protected

Definition at line 941 of file vtkMRMLScene.h.

◆ RootDirectory

std::string vtkMRMLScene::RootDirectory
protected

Definition at line 937 of file vtkMRMLScene.h.

◆ SaveToXMLString

int vtkMRMLScene::SaveToXMLString
protected

Definition at line 960 of file vtkMRMLScene.h.

◆ SceneXMLString

std::string vtkMRMLScene::SceneXMLString
protected

Definition at line 956 of file vtkMRMLScene.h.

◆ States

std::vector<unsigned long> vtkMRMLScene::States
protected

Definition at line 928 of file vtkMRMLScene.h.

◆ SubjectHierarchyNode

vtkWeakPointer<vtkMRMLSubjectHierarchyNode> vtkMRMLScene::SubjectHierarchyNode
protected

subject hierarchy node

Definition at line 920 of file vtkMRMLScene.h.

◆ UndoFlag

bool vtkMRMLScene::UndoFlag
protected

Definition at line 931 of file vtkMRMLScene.h.

◆ UndoStack

std::list< vtkCollection* > vtkMRMLScene::UndoStack
protected

Definition at line 933 of file vtkMRMLScene.h.

◆ UniqueIDs

std::map<std::string, int> vtkMRMLScene::UniqueIDs
protected

Definition at line 939 of file vtkMRMLScene.h.

◆ UniqueNames

std::map<std::string, int> vtkMRMLScene::UniqueNames
protected

Definition at line 940 of file vtkMRMLScene.h.

◆ URIHandlerCollection

vtkCollection* vtkMRMLScene::URIHandlerCollection
protected

Definition at line 925 of file vtkMRMLScene.h.

◆ URL

std::string vtkMRMLScene::URL
protected

Definition at line 936 of file vtkMRMLScene.h.

◆ UserTagTable

vtkTagTable* vtkMRMLScene::UserTagTable
protected

Definition at line 926 of file vtkMRMLScene.h.

◆ Version

char* vtkMRMLScene::Version
protected

Definition at line 968 of file vtkMRMLScene.h.


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