Slicer
4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
|
A set of MRML Nodes that supports serialization and undo/redo. More...
#include <Libs/MRML/Core/vtkMRMLScene.h>
Public Types | |
enum | SceneEventType { NodeAboutToBeAddedEvent = 0x2000, NodeAddedEvent, NodeAboutToBeRemovedEvent, NodeRemovedEvent, 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) |
vtkMRMLNode * | AddNewNodeByClass (std::string className, std::string nodeBaseName="") |
Instantiate and add a node to the scene. More... | |
vtkMRMLNode * | AddNewNodeByClassWithID (std::string className, std::string nodeBaseName, std::string nodeID) |
Instantiates and adds a new node to the scene with the specified ID. More... | |
vtkMRMLNode * | AddNode (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) |
int | Connect () |
Create new scene from URL. More... | |
void | CopyDefaultNodesToScene (vtkMRMLScene *scene) |
Copies all default nodes into the parameter scene. Does not remove existing default nodes. More... | |
vtkMRMLNode * | CopyNode (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... | |
vtkMRMLNode * | CreateNodeByClass (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... | |
vtkURIHandler * | FindURIHandler (const char *URI) |
Find a URI handler in the collection that can work on the passed URI. More... | |
vtkURIHandler * | FindURIHandlerByName (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 vtkCacheManager * | GetCacheManager () |
const char * | GetChangedID (const char *id) |
virtual const char * | GetClassName () |
const char * | GetClassNameByTag (const char *tagName) |
Add a path to the list. More... | |
virtual vtkDataIOManager * | GetDataIOManager () |
vtkMRMLNode * | GetDefaultNodeByClass (const char *className) |
virtual unsigned long | GetErrorCode () |
std::string | GetErrorMessage () |
vtkMRMLNode * | 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. More... | |
vtkMRMLNode * | GetFirstNodeByClass (const char *className) |
Convenience function for getting 0-th node of a specified class in the scene. More... | |
vtkMRMLNode * | GetFirstNodeByName (const char *name) |
virtual char * | GetLastLoadedVersion () |
The version of the last loaded scene file. More... | |
virtual int | GetLoadFromXMLString () |
virtual int | GetMaximumNumberOfSavedUndoStates () |
bool | GetModifiedSinceRead () |
Returns true if the scene has been "significantly" modified since the last time it was read or written. More... | |
vtkMRMLNode * | GetNextNode () |
vtkMRMLNode * | GetNextNodeByClass (const char *className) |
vtkMRMLNode * | GetNodeByID (const char *name) |
Get node given a unique ID. More... | |
vtkMRMLNode * | GetNodeByID (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... | |
vtkMRMLNode * | GetNthNode (int n) |
Get n-th node in the scene. More... | |
vtkMRMLNode * | GetNthNodeByClass (int n, const char *className) |
Get n-th node of a specified class in the scene. More... | |
const char * | GetNthReferencedID (int n) |
vtkMRMLNode * | GetNthReferencingNode (int n) |
vtkMRMLNode * | GetNthRegisteredNodeClass (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 | 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... | |
vtkMRMLNode * | GetSingletonNode (const char *singletonTag, const char *className) |
Search and return the singleton of type className with a singletonTag tag. More... | |
vtkMRMLNode * | 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. 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... | |
vtkMRMLSubjectHierarchyNode * | GetSubjectHierarchyNode () |
const char * | GetTagByClassName (const char *className) |
Add a path to the list. More... | |
bool | GetUndoFlag () |
const char * | GetUniqueNameByString (const char *baseName) |
virtual vtkCollection * | GetURIHandlerCollection () |
const char * | GetURL () |
Get URL (file name) of the scene. More... | |
virtual vtkTagTable * | GetUserTagTable () |
virtual char * | GetVersion () |
The current software version. More... | |
int | Import () |
Add the scene into the existing scene (no clear) from URL file or from. More... | |
void | InitTraversal () |
vtkMRMLNode * | InsertAfterNode (vtkMRMLNode *item, vtkMRMLNode *newItem) |
insert a node in the scene after a specified node More... | |
vtkMRMLNode * | InsertBeforeNode (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) |
Read the scene from a MRML scene bundle (.mrb) file. More... | |
void | Redo () |
redo, set the scene to previously undone 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 | SetErrorCode (unsigned long) |
void | SetErrorMessage (const std::string &error) |
void | SetErrorMessage (const char *message) |
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 vtkMRMLScene * | New () |
static std::string | PercentEncode (std::string s) |
static vtkMRMLScene * | SafeDownCast (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) |
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. 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... | |
vtkMRMLNode * | AddNodeNoNotify (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 | 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 | |
vtkCacheManager * | CacheManager |
data i/o handling members More... | |
vtkDataIOManager * | DataIOManager |
std::map< std::string, vtkSmartPointer< vtkMRMLNode > > | DefaultNodes |
vtkCallbackCommand * | DeleteEventCallback |
std::string | ErrorMessage |
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::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< vtkMRMLSubjectHierarchyNode > | SubjectHierarchyNode |
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 |
vtkTagTable * | UserTagTable |
char * | Version |
Friends | |
class | vtkMRMLSceneViewNode |
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.
Definition at line 61 of file vtkMRMLScene.h.
|
protected |
Definition at line 797 of file vtkMRMLScene.h.
typedef vtkObject vtkMRMLScene::Superclass |
Definition at line 71 of file vtkMRMLScene.h.
Definition at line 657 of file vtkMRMLScene.h.
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 575 of file vtkMRMLScene.h.
|
protected |
|
overrideprotected |
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.
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().
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().
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.
|
protected |
Add node to NodeIDs map used to speedup GetByID() method.
|
protected |
Add a node to the scene without invoking a vtkMRMLScene::NodeAddedEvent event.
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.
|
protected |
Get referenced nodes
recursive | All referenced nodes recursively if true, only directly referenced nodes if false. Default is true. |
void vtkMRMLScene::AddReservedID | ( | const char * | id | ) |
void vtkMRMLScene::AddURIHandler | ( | vtkURIHandler * | handler | ) |
Add a uri handler to the collection.
|
protected |
|
protected |
Combine a basename and an index to produce a full name.
void vtkMRMLScene::Clear | ( | int | removeSingletons = 0 | ) |
Remove nodes and clear undo/redo stacks.
removeSingletons | If 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. |
|
protected |
Clear NodeIDs map used to speedup GetByID() method.
void vtkMRMLScene::ClearRedoStack | ( | ) |
clear Redo stack, delete redo history
void vtkMRMLScene::ClearUndoStack | ( | ) |
clear Undo stack, delete undo history
int vtkMRMLScene::Commit | ( | const char * | url = nullptr | ) |
Save scene into URL Returns nonzero on success
int vtkMRMLScene::Connect | ( | ) |
Create new scene from URL.
Returns nonzero on success.
void vtkMRMLScene::CopyDefaultNodesToScene | ( | vtkMRMLScene * | scene | ) |
Copies all default nodes into the parameter scene. Does not remove existing default nodes.
vtkMRMLNode* vtkMRMLScene::CopyNode | ( | vtkMRMLNode * | n | ) |
Add a copy of a node to the scene.
void vtkMRMLScene::CopyNodeChangedIDs | ( | vtkMRMLScene * | scene | ) |
|
protected |
|
protected |
void vtkMRMLScene::CopyNodeReferences | ( | vtkMRMLScene * | scene | ) |
void vtkMRMLScene::CopyRegisteredNodesToScene | ( | vtkMRMLScene * | scene | ) |
Copies all registered nodes into the parameter scene.
void vtkMRMLScene::CopySingletonNodesToScene | ( | vtkMRMLScene * | scene | ) |
Copies all singleton nodes into the parameter scene.
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.
|
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).
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.
|
protected |
Get a NodeReferences iterator for a node reference.
vtkURIHandler* vtkMRMLScene::FindURIHandler | ( | const char * | URI | ) |
Find a URI handler in the collection that can work on the passed URI.
Returns nullptr on failure
vtkURIHandler* vtkMRMLScene::FindURIHandlerByName | ( | const char * | name | ) |
Returns a URIhandler of a specific type if its name is known.
|
protected |
|
protected |
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.
|
protected |
Return a unique name for a MRML node. It uses the node tag as the base.
|
virtual |
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
|
virtual |
const char* vtkMRMLScene::GetClassNameByTag | ( | const char * | tagName | ) |
Add a path to the list.
|
virtual |
vtkMRMLNode* vtkMRMLScene::GetDefaultNodeByClass | ( | const char * | className | ) |
|
virtual |
std::string vtkMRMLScene::GetErrorMessage | ( | ) |
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.
vtkMRMLNode* vtkMRMLScene::GetFirstNodeByClass | ( | const char * | className | ) |
Convenience function for getting 0-th node of a specified class in the scene.
vtkMRMLNode* vtkMRMLScene::GetFirstNodeByName | ( | const char * | name | ) |
|
virtual |
The version of the last loaded scene file.
|
virtual |
|
virtual |
bool vtkMRMLScene::GetModifiedSinceRead | ( | ) |
Returns true if the scene has been "significantly" modified since the last time it was read or written.
vtkMRMLNode* vtkMRMLScene::GetNextNode | ( | ) |
vtkMRMLNode* vtkMRMLScene::GetNextNodeByClass | ( | const char * | className | ) |
vtkMRMLNode* vtkMRMLScene::GetNodeByID | ( | const char * | name | ) |
Get node given a unique ID.
vtkMRMLNode* vtkMRMLScene::GetNodeByID | ( | std::string | name | ) |
std::list<std::string> vtkMRMLScene::GetNodeClassesList | ( | ) |
|
protected |
Returns all unique node reference IDs that are referenced within the undo stack.
vtkCollection* vtkMRMLScene::GetNodes | ( | ) |
Return collection of nodes.
int vtkMRMLScene::GetNodesByClass | ( | const char * | className, |
std::vector< vtkMRMLNode *> & | nodes | ||
) |
Get vector of nodes of a specified class in the scene.
vtkCollection* vtkMRMLScene::GetNodesByClass | ( | const char * | className | ) |
vtkCollection* vtkMRMLScene::GetNodesByClassByName | ( | const char * | className, |
const char * | name | ||
) |
Get nodes of a specified class having the specified name.
vtkCollection* vtkMRMLScene::GetNodesByName | ( | const char * | name | ) |
Get nodes having the specified name.
vtkMRMLNode* vtkMRMLScene::GetNthNode | ( | int | n | ) |
Get n-th node in the scene.
vtkMRMLNode* vtkMRMLScene::GetNthNodeByClass | ( | int | n, |
const char * | className | ||
) |
Get n-th node of a specified class in the scene.
const char* vtkMRMLScene::GetNthReferencedID | ( | int | n | ) |
Get the ReferencedID component of the n-th ReferencedID-ReferencingNode pair. Only for testing and debugging.
vtkMRMLNode* vtkMRMLScene::GetNthReferencingNode | ( | int | n | ) |
Get the ReferencingNode component of the n-th ReferencedID-ReferencingNode pair. Only for testing and debugging.
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.
int vtkMRMLScene::GetNumberOfNodeReferences | ( | ) |
Get the total number of node references (number of ReferencedID-ReferencingNode pairs).
int vtkMRMLScene::GetNumberOfNodes | ( | ) |
Get number of nodes in the scene.
int vtkMRMLScene::GetNumberOfNodesByClass | ( | const char * | className | ) |
Get number of nodes of a specified class in the scene.
|
inline |
returns number of redo steps in the history buffer
Definition at line 375 of file vtkMRMLScene.h.
int vtkMRMLScene::GetNumberOfRegisteredNodeClasses | ( | ) |
Get the number of registered node classes (is probably greater than the current number of nodes instantiated in the scene)
|
inline |
returns number of undo steps in the history buffer
Definition at line 372 of file vtkMRMLScene.h.
|
virtual |
vtkCollection* vtkMRMLScene::GetReferencedNodes | ( | vtkMRMLNode * | node, |
bool | recursive = true |
||
) |
Return collection of all nodes referenced directly or indirectly by node.
recursive | All 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().
void vtkMRMLScene::GetReferencedSubScene | ( | vtkMRMLNode * | node, |
vtkMRMLScene * | newScene | ||
) |
Get a sub-scene containing all nodes directly or indirectly referenced by the input node.
void vtkMRMLScene::GetReferencingNodes | ( | vtkMRMLNode * | referencedNode, |
std::vector< vtkMRMLNode *> & | referencingNodes | ||
) |
Get vector of nodes containing references to an input node.
const char* vtkMRMLScene::GetRootDirectory | ( | ) |
Get Root directory, where URL is pointing.
|
virtual |
const std::string& vtkMRMLScene::GetSceneXMLString | ( | ) |
Returns the saved scene with an XML format if SaveToXMLString is true and Commit() was called prior.
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.
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.
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.
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.
vtkMRMLSubjectHierarchyNode* vtkMRMLScene::GetSubjectHierarchyNode | ( | ) |
const char* vtkMRMLScene::GetTagByClassName | ( | const char * | className | ) |
Add a path to the list.
|
inline |
Definition at line 356 of file vtkMRMLScene.h.
|
protected |
const char* vtkMRMLScene::GetUniqueNameByString | ( | const char * | 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...
|
virtual |
const char* vtkMRMLScene::GetURL | ( | ) |
Get URL (file name) of the scene.
|
virtual |
|
virtual |
The current software version.
int vtkMRMLScene::Import | ( | ) |
Add the scene into the existing scene (no clear) from URL file or from.
Returns nonzero on success.
void vtkMRMLScene::InitTraversal | ( | ) |
vtkMRMLNode* vtkMRMLScene::InsertAfterNode | ( | vtkMRMLNode * | item, |
vtkMRMLNode * | newItem | ||
) |
insert a node in the scene after a specified node
vtkMRMLNode* vtkMRMLScene::InsertBeforeNode | ( | vtkMRMLNode * | item, |
vtkMRMLNode * | newItem | ||
) |
insert a node in the scene before a specified node
|
virtual |
|
inline |
Return true if the scene is in BatchProcess state, false otherwise.
Definition at line 950 of file vtkMRMLScene.h.
|
inline |
Return true if the scene is in Close state, false otherwise.
Definition at line 957 of file vtkMRMLScene.h.
int vtkMRMLScene::IsFilePathRelative | ( | const char * | filepath | ) |
|
inline |
Return true if the scene is in Import state, false otherwise.
Definition at line 964 of file vtkMRMLScene.h.
bool vtkMRMLScene::IsNodeClassRegistered | ( | const std::string & | className | ) |
Return True if className is a registered node.
|
protected |
Returns true if a node is not referenced within the scene, but is referenced within the Undo stack.
int vtkMRMLScene::IsNodePresent | ( | vtkMRMLNode * | n | ) |
Determine whether a particular node is present.
Returns its position in the list.
bool vtkMRMLScene::IsNodeReferencingNodeID | ( | vtkMRMLNode * | referencingNode, |
const char * | id | ||
) |
|
inline |
Return true if the scene is in Redo state (in the process of redoing node changes), false otherwise.
Definition at line 985 of file vtkMRMLScene.h.
bool vtkMRMLScene::IsReservedID | ( | const std::string & | id | ) |
|
inline |
Return true if the scene is in Restore state, false otherwise.
Definition at line 971 of file vtkMRMLScene.h.
|
static |
|
inline |
Return true if the scene is in Undo state (in the process of undoing node changes), false otherwise.
Definition at line 978 of file vtkMRMLScene.h.
|
static |
void vtkMRMLScene::NodeAdded | ( | vtkMRMLNode * | n | ) |
Invoke a vtkMRMLScene::NodeAddedEvent.
This function is used after adding a bunch of nodes with AddNodeNoNotify()
|
inline |
Definition at line 225 of file vtkMRMLScene.h.
|
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 preseves 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. http://en.wikipedia.org/wiki/Percent-encoding See https://github.com/Slicer/Slicer/issues/2605
|
override |
void vtkMRMLScene::ProgressState | ( | unsigned long | state, |
int | progress = 0 |
||
) |
TODO: Report progress of the current state.
|
protected |
|
protected |
bool vtkMRMLScene::ReadFromMRB | ( | const char * | fullName, |
bool | clear = false |
||
) |
Read the scene from a MRML scene bundle (.mrb) file.
void vtkMRMLScene::Redo | ( | ) |
redo, set the scene to previously undone
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_SUPPORT_VERSION < 0x0X0Y0Z
and #endif
where X is the major version of Slicer scene to support, Y the minor and Z the patch version.
void vtkMRMLScene::RegisterNodeClass | ( | vtkMRMLNode * | node | ) |
Utility function to RegisterNodeClass(), the node tag name is used when registering the node.
void vtkMRMLScene::RemoveAllDefaultNodes | ( | ) |
Deletes all default node values from the scene.
|
protected |
void vtkMRMLScene::RemoveNode | ( | vtkMRMLNode * | n | ) |
Remove a path from the list.
|
protected |
Remove node from NodeIDs map used to speedup GetByID() method.
void vtkMRMLScene::RemoveNodeReferences | ( | vtkMRMLNode * | node | ) |
void vtkMRMLScene::RemoveReferencedNodeID | ( | const char * | id, |
vtkMRMLNode * | refrencingNode | ||
) |
void vtkMRMLScene::RemoveReferencesToNode | ( | vtkMRMLNode * | node | ) |
void vtkMRMLScene::RemoveReservedIDs | ( | ) |
void vtkMRMLScene::RemoveUnusedNodeReferences | ( | ) |
|
protected |
Reserve all node reference ids for a node.
void vtkMRMLScene::ResetNodes | ( | ) |
Reset all nodes to their constructor's state.
|
static |
void vtkMRMLScene::SaveSceneScreenshot | ( | vtkImageData * | thumbnail | ) |
Utility function to write the scene thumbnail to a file in the scene's root folder.
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.
void vtkMRMLScene::SaveStateForUndo | ( | ) |
Save current state in the undo buffer.
void vtkMRMLScene::SaveStateForUndo | ( | vtkMRMLNode * | node | ) |
Save current state of the node in the undo buffer
void vtkMRMLScene::SaveStateForUndo | ( | vtkCollection * | nodes | ) |
Save current state of the nodes in the undo buffer
void vtkMRMLScene::SaveStateForUndo | ( | std::vector< vtkMRMLNode *> | nodes | ) |
|
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.
|
staticprotected |
Handle vtkMRMLScene::DeleteEvent: clear the scene.
|
virtual |
|
virtual |
|
virtual |
void vtkMRMLScene::SetErrorMessage | ( | const std::string & | error | ) |
void vtkMRMLScene::SetErrorMessage | ( | const char * | message | ) |
|
virtual |
|
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.
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.
|
virtual |
void vtkMRMLScene::SetRootDirectory | ( | const char * | dir | ) |
Set Root directory, where URL is pointing.
|
virtual |
void vtkMRMLScene::SetSceneXMLString | ( | const std::string & | xmlString | ) |
Set the XML string to read from by Import() if GetLoadFromXMLString() is true.
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.
|
static |
Given a collection of storable nodes, iterate through and call StorableModified() on them.
|
protectedvirtual |
|
inline |
Definition at line 357 of file vtkMRMLScene.h.
|
inline |
Definition at line 355 of file vtkMRMLScene.h.
|
inline |
Set undo on/off.
Definition at line 354 of file vtkMRMLScene.h.
|
virtual |
void vtkMRMLScene::SetURL | ( | const char * | url | ) |
Set URL (file name) of the scene.
|
virtual |
|
virtual |
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:
StartState() internally pushes the state into a stack.
|
protected |
Clean up elements of the undo/redo stack beyond the maximum size.
void vtkMRMLScene::Undo | ( | ) |
undo, set the scene to previous state
|
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.
void vtkMRMLScene::UpdateNodeChangedIDs | ( | ) |
Change node IDs based on the ReferencedIDChanges list.
|
protected |
Synchronize NodeIDs map used to speedup GetByID() method with the Nodes collection.
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.
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.
|
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 67 of file vtkMRMLScene.h.
|
protected |
data i/o handling members
Definition at line 882 of file vtkMRMLScene.h.
|
protected |
Definition at line 883 of file vtkMRMLScene.h.
|
protected |
Definition at line 912 of file vtkMRMLScene.h.
|
protected |
Definition at line 931 of file vtkMRMLScene.h.
|
protected |
Definition at line 914 of file vtkMRMLScene.h.
|
protected |
Definition at line 929 of file vtkMRMLScene.h.
|
protected |
Definition at line 918 of file vtkMRMLScene.h.
|
protected |
Definition at line 889 of file vtkMRMLScene.h.
|
protected |
Definition at line 907 of file vtkMRMLScene.h.
|
protected |
Definition at line 924 of file vtkMRMLScene.h.
|
protected |
Definition at line 905 of file vtkMRMLScene.h.
|
protected |
Definition at line 876 of file vtkMRMLScene.h.
|
protected |
Definition at line 933 of file vtkMRMLScene.h.
|
protected |
Definition at line 922 of file vtkMRMLScene.h.
|
protected |
Definition at line 893 of file vtkMRMLScene.h.
|
protected |
Definition at line 906 of file vtkMRMLScene.h.
|
protected |
Definition at line 902 of file vtkMRMLScene.h.
|
protected |
Definition at line 903 of file vtkMRMLScene.h.
|
protected |
Definition at line 900 of file vtkMRMLScene.h.
|
protected |
Definition at line 896 of file vtkMRMLScene.h.
|
protected |
Definition at line 920 of file vtkMRMLScene.h.
|
protected |
Definition at line 916 of file vtkMRMLScene.h.
|
protected |
Definition at line 887 of file vtkMRMLScene.h.
|
protected |
subject hierarchy node
Definition at line 879 of file vtkMRMLScene.h.
|
protected |
Definition at line 890 of file vtkMRMLScene.h.
|
protected |
Definition at line 892 of file vtkMRMLScene.h.
|
protected |
Definition at line 898 of file vtkMRMLScene.h.
|
protected |
Definition at line 899 of file vtkMRMLScene.h.
|
protected |
Definition at line 884 of file vtkMRMLScene.h.
|
protected |
Definition at line 895 of file vtkMRMLScene.h.
|
protected |
Definition at line 885 of file vtkMRMLScene.h.
|
protected |
Definition at line 928 of file vtkMRMLScene.h.