Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLScene.h
Go to the documentation of this file.
1/*=auto=========================================================================
2
3Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
4
5See COPYRIGHT.txt
6or http://www.slicer.org/copyright/copyright.txt for details.
7
8Program: 3D Slicer
9Module: $RCSfile: vtkMRMLScene.h,v $
10Date: $Date: 2006/03/17 15:10:09 $
11Version: $Revision: 1.18 $
12
13=========================================================================auto=*/
14
15#ifndef __vtkMRMLScene_h
16#define __vtkMRMLScene_h
17
18// MRML includes
19#include "vtkMRML.h"
20
21// VTK includes
22#include <vtkObject.h>
23#include <vtkSmartPointer.h>
24#include <vtkWeakPointer.h>
25
26// STD includes
27#include <list>
28#include <map>
29#include <random>
30#include <set>
31#include <string>
32#include <vector>
33
34class vtkCacheManager;
36class vtkTagTable;
37
38class vtkCallbackCommand;
39class vtkCollection;
40class vtkGeneralTransform;
41class vtkImageData;
42class vtkURIHandler;
44class vtkMRMLNode;
49
54//
57class VTK_MRML_EXPORT vtkMRMLScene : public vtkObject
58{
64
65public:
66 static vtkMRMLScene *New();
67 vtkTypeMacro(vtkMRMLScene, vtkObject);
68 void PrintSelf(ostream& os, vtkIndent indent) override;
69
71 void SetURL(const char *url);
72
74 const char *GetURL();
75
77 void SetRootDirectory(const char *dir);
78
80 const char *GetRootDirectory();
81
86 int Connect(vtkMRMLMessageCollection* userMessages = nullptr);
87
96 int Import(vtkMRMLMessageCollection* userMessages=nullptr);
97
102 int Commit(const char* url=nullptr, vtkMRMLMessageCollection* userMessages=nullptr);
103
109 void Clear(int removeSingletons=0);
110
113
131 vtkMRMLNode* CreateNodeByClass(const char* className);
132
153 void RegisterNodeClass(vtkMRMLNode* node, const char* tagName);
154
160
168 void RegisterAbstractNodeClass(std::string className, std::string typeDisplayName);
169
171 const char* GetClassNameByTag(const char *tagName);
172
174 const char* GetTagByClassName(const char *className);
175
177 std::string GetTypeDisplayNameByClassName(std::string className);
178
183 vtkMRMLNode* GetDefaultNodeByClass(const char* className);
184
187
189 vtkCollection* GetNodes();
190
204
220 vtkMRMLNode* AddNewNodeByClass(std::string className, std::string nodeBaseName = "");
221
229 vtkMRMLNode* AddNewNodeByClassWithID(std::string className, std::string nodeBaseName, std::string nodeID);
230
233
238 void NodeAdded() {this->NodeAdded(nullptr);}
239
242
247
256
265
273 vtkMRMLNode *GetNextNodeByClass(const char* className);
274
276 vtkCollection *GetNodesByName(const char* name);
277 vtkMRMLNode *GetFirstNodeByName(const char* name);
278
290 vtkMRMLNode *GetFirstNode(const char* byName = nullptr, const char* byClass = nullptr,
291 const int* byHideFromEditors = nullptr,
292 bool exactNameMatch = true);
293
295 vtkMRMLNode *GetNodeByID(const char* name);
296 vtkMRMLNode *GetNodeByID(std::string name);
297
300 vtkCollection *GetNodesByClassByName(const char* className, const char* name);
301
304
307
309 vtkMRMLNode* GetNthNodeByClass(int n, const char* className );
311 vtkMRMLNode* GetFirstNodeByClass(const char* className);
312
314 int GetNumberOfNodesByClass(const char* className);
315
317 int GetNodesByClass(const char *className, std::vector<vtkMRMLNode *> &nodes);
318
320 vtkCollection* GetNodesByClass(const char *className);
321
326 vtkMRMLNode* GetSingletonNode(const char* singletonTag, const char* className);
327
335
336 std::list<std::string> GetNodeClassesList();
337
344
348 bool IsNodeClassRegistered(const std::string& className);
349
352
356
360
364 std::string GenerateUniqueName(const std::string& baseName);
365
370 const char* GetUniqueNameByString(const char* baseName);
371
376
378 void SetUndoOn() {UndoFlag=true;}
379 void SetUndoOff() {UndoFlag=false;}
380 bool GetUndoFlag() {return UndoFlag;}
381 void SetUndoFlag(bool flag) {UndoFlag = flag;}
382
384 void Undo();
385
387 void Redo();
388
391
394
396 int GetNumberOfUndoLevels() {return static_cast<int>(this->UndoStack.size());}
397
399 int GetNumberOfRedoLevels() {return static_cast<int>(this->RedoStack.size());}
400
403
410
416 void SaveStateForUndo(vtkCollection *nodes);
417 void SaveStateForUndo(std::vector<vtkMRMLNode *> nodes);
418
425 void AddReferencedNodeID(const char *id, vtkMRMLNode *refrencingNode);
426 bool IsNodeReferencingNodeID(vtkMRMLNode* referencingNode, const char* id);
427
437 const char* GetNthReferencedID(int n);
438
439 void RemoveReferencedNodeID(const char *id, vtkMRMLNode *refrencingNode);
440
442
444
452 void UpdateNodeReferences(vtkCollection* checkNodes=nullptr);
453
455
457
460
462
463 bool IsReservedID(const std::string& id);
464
465 void AddReservedID(const char *id);
466
468
471 const char* GetChangedID(const char* id);
472
487 vtkCollection* GetReferencedNodes(vtkMRMLNode *node, bool recursive=true);
488
490 void GetReferencingNodes(vtkMRMLNode* referencedNode, std::vector<vtkMRMLNode *> &referencingNodes);
491
499
500 int IsFilePathRelative(const char * filepath);
501
508 vtkSetMacro(LoadFromXMLString,int);
509 vtkGetMacro(LoadFromXMLString,int);
510
517 vtkSetMacro(SaveToXMLString,int);
518 vtkGetMacro(SaveToXMLString,int);
519
520 vtkSetMacro(ReadDataOnLoad,int);
521 vtkGetMacro(ReadDataOnLoad,int);
522
527 void SetSceneXMLString(const std::string &xmlString);
528
533 const std::string& GetSceneXMLString();
534
536
537 vtkGetObjectMacro(CacheManager, vtkCacheManager);
539 vtkGetObjectMacro(DataIOManager, vtkDataIOManager);
541 vtkGetObjectMacro(URIHandlerCollection, vtkCollection);
542 virtual void SetURIHandlerCollection(vtkCollection*);
543 vtkGetObjectMacro(UserTagTable, vtkTagTable);
545
550 vtkURIHandler *FindURIHandler(const char *URI);
555
592 {
593 BatchProcessState = 0x0001,
594 CloseState = 0x0002 | BatchProcessState,
595 ImportState = 0x0004 | BatchProcessState,
596 RestoreState = 0x0008 | BatchProcessState,
597 SaveState = 0x0010,
598 UndoState = 0x0020,
599 RedoState = 0x0040,
600 };
601
609 int GetStates()const;
610
612 inline bool IsBatchProcessing()const;
614 inline bool IsClosing()const;
616 inline bool IsImporting()const;
618 inline bool IsRestoring()const;
620 inline bool IsUndoing()const;
622 inline bool IsRedoing()const;
623
658 void StartState(unsigned long state, int anticipatedMaxProgress = 0);
659
668 void EndState(unsigned long state);
669
671 void ProgressState(unsigned long state, int progress = 0);
672
674 {
675 NodeAboutToBeAddedEvent = 0x2000,
680
681 NewSceneEvent = 66030,
682 MetadataAddedEvent = 66032, // ### Slicer 4.5: Simplify - Do not explicitly set for backward compat. See issue #3472
685
689 StateEvent = 0x2000,
690 StartEvent = 0x0100,
691 EndEvent = 0x0200,
692 ProgressEvent = 0x0400,
693
694 StartBatchProcessEvent = StateEvent | StartEvent | BatchProcessState,
695 EndBatchProcessEvent = StateEvent | EndEvent | BatchProcessState,
696 ProgressBatchProcessEvent = StateEvent | ProgressEvent | BatchProcessState,
697
698 StartCloseEvent = StateEvent | StartEvent | CloseState,
699 EndCloseEvent = StateEvent | EndEvent | CloseState,
700 ProgressCloseEvent = StateEvent | ProgressEvent | CloseState,
701
702 StartImportEvent = StateEvent | StartEvent | ImportState,
703 EndImportEvent = StateEvent | EndEvent | ImportState,
704 ProgressImportEvent = StateEvent | EndEvent | ImportState,
705
706 StartRestoreEvent = StateEvent | StartEvent | RestoreState,
707 EndRestoreEvent = StateEvent | EndEvent | RestoreState,
708 ProgressRestoreEvent = StateEvent | ProgressEvent | RestoreState,
709
710 StartSaveEvent = StateEvent | StartEvent | SaveState,
711 EndSaveEvent = StateEvent | EndEvent | SaveState,
712 ProgressSaveEvent = StateEvent | ProgressEvent | SaveState,
713
714 StartUndoEvent = StateEvent | StartEvent | UndoState,
715 EndUndoEvent = StateEvent | EndEvent | UndoState,
716 ProgressUndoEvent = StateEvent | ProgressEvent | UndoState,
717
718 StartRedoEvent = StateEvent | StartEvent | RedoState,
719 EndRedoEvent = StateEvent | EndEvent | RedoState,
720 ProgressRedoEvent = StateEvent | ProgressEvent | RedoState,
721
722 };
723
725 vtkGetStringMacro(LastLoadedVersion);
726 vtkSetStringMacro(LastLoadedVersion);
727
729 vtkGetStringMacro(LastLoadedExtensions);
730 vtkSetStringMacro(LastLoadedExtensions);
731
733 vtkGetStringMacro(Version);
734 vtkSetStringMacro(Version);
735
738 vtkGetStringMacro(Extensions);
739 vtkSetStringMacro(Extensions);
740
743 static bool ParseVersion(const char* versionString, std::string& application, int& major, int& minor, int& patch, int& revision);
744
747
750
753
757 bool GetModifiedSinceRead(vtkCollection* modifiedNodes=nullptr);
758
760 vtkGetMacro(StoredTime, vtkMTimeType);
761
768 bool GetStorableNodesModifiedSinceRead(vtkCollection* modifiedStorableNodes = nullptr);
769
776
779 static void SetStorableNodesModifiedSinceRead(vtkCollection* storableNodes);
780
784 vtkGetMacro(MaximumNumberOfSavedUndoStates, int);
785
791 bool WriteToMRB(const char* filename, vtkImageData* thumbnail=nullptr, vtkMRMLMessageCollection* userMessages=nullptr);
792
796 bool ReadFromMRB(const char* fullName, bool clear=false, vtkMRMLMessageCollection* userMessages = nullptr);
797
803 static std::string UnpackSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory, vtkMRMLMessageCollection* userMessages=nullptr);
804
810 bool SaveSceneToSlicerDataBundleDirectory(const char* sdbDir, vtkImageData* thumbnail=nullptr, vtkMRMLMessageCollection* userMessages=nullptr);
811
813 void SaveSceneScreenshot(vtkImageData* thumbnail);
814
824 static std::string PercentEncode(std::string s);
825
831 static std::string CreateUniqueFileName(const std::string& filename, const std::string& knownExtension = "");
832
833protected:
834
835 typedef std::map< std::string, std::set<std::string> > NodeReferencesType;
836
838 ~vtkMRMLScene() override;
839
842
845
850
854 void AddReferencedNodes(vtkMRMLNode *node, vtkCollection *refNodes, bool recursive=true);
855
857 void RemoveInvalidNodeReferences(vtkCollection* checkNodes, const std::set<std::string> &validNodeIDs);
858
860 static void SceneCallback(vtkObject *caller, unsigned long eid, void *clientData, void *callData);
861
862 std::string GenerateUniqueID(vtkMRMLNode* node);
863 std::string GenerateUniqueID(const std::string& baseID);
864 int GetUniqueIDIndex(const std::string& baseID);
865 std::string BuildID(const std::string& baseID, int idIndex)const;
866
868 std::string GenerateUniqueName(vtkMRMLNode* node);
869
875 int GetUniqueNameIndex(const std::string& baseName);
876
878 std::string BuildName(const std::string& baseName, int nameIndex)const;
879
883
886
888 void RemoveNodeID(char *nodeID);
889
892
894 NodeReferencesType::iterator FindNodeReference(const char* referencedId, vtkMRMLNode* referencingNode);
895
898
901
903 void GetNodeReferenceIDsFromUndoStack(std::set<std::string>& referenceIDs) const;
904
906 bool IsNodeIDReservedByUndo(const std::string id) const;
907
909
914 bool SaveStorableNodeToSlicerDataBundleDirectory(vtkMRMLStorableNode* storableNode, std::string& dataDir,
915 std::map<vtkMRMLStorageNode*, std::vector<std::string> > &originalStorageNodeFileNames, vtkMRMLMessageCollection* userMessages);
916
917 vtkCollection* Nodes;
918
920 vtkWeakPointer<vtkMRMLSubjectHierarchyNode> SubjectHierarchyNode;
921
925 vtkCollection * URIHandlerCollection;
927
928 std::vector<unsigned long> States;
929
932
933 std::list< vtkCollection* > UndoStack;
934 std::list< vtkCollection* > RedoStack;
935
936 std::string URL;
937 std::string RootDirectory;
938
939 std::map<std::string, int> UniqueIDs;
940 std::map<std::string, int> UniqueNames;
941 std::set<std::string> ReservedIDs;
942
943 std::vector< vtkMRMLNode* > RegisteredNodeClasses;
944 std::vector< std::string > RegisteredNodeTags;
945 std::map< std::string, std::string > RegisteredAbstractNodeClassTypeDisplayNames; // map class name to type display name
946
947 NodeReferencesType NodeReferences; // ReferencedIDs (string), ReferencingNodes (node pointer)
948 std::map< std::string, std::string > ReferencedIDChanges;
949 std::map< std::string, vtkSmartPointer<vtkMRMLNode> > NodeIDs;
950
951 // Stores default nodes. If a class is created or reset (using CreateNodeByClass or Clear) and
952 // a default node is defined for it then the content of the default node will be used to initialize
953 // the class. It is useful for overriding default values that are set in a node's constructor.
954 std::map< std::string, vtkSmartPointer<vtkMRMLNode> > DefaultNodes;
955
956 std::string SceneXMLString;
957
959
961
963
964 vtkMTimeType NodeIDsMTime;
965
966 void RemoveAllNodes(bool removeSingletons);
967
968 char* Version;
970
973
974 vtkCallbackCommand *DeleteEventCallback;
975
976 std::default_random_engine RandomGenerator;
977
978private:
979
980 vtkMRMLScene(const vtkMRMLScene&); // Not implemented
981 void operator=(const vtkMRMLScene&); // Not implemented
982
986 int LoadIntoScene(vtkCollection* scene, vtkMRMLMessageCollection* userMessages=nullptr);
987
989 vtkTimeStamp StoredTime;
990};
991
992//------------------------------------------------------------------------------
998
999//------------------------------------------------------------------------------
1001{
1002 return (this->GetStates() & vtkMRMLScene::CloseState)
1004}
1005
1006//------------------------------------------------------------------------------
1008{
1009 return (this->GetStates() & vtkMRMLScene::ImportState)
1011}
1012
1013//------------------------------------------------------------------------------
1015{
1016 return (this->GetStates() & vtkMRMLScene::RestoreState)
1018}
1019
1020//------------------------------------------------------------------------------
1022{
1023 return (this->GetStates() & vtkMRMLScene::UndoState)
1025}
1026
1027//------------------------------------------------------------------------------
1029{
1030 return (this->GetStates() & vtkMRMLScene::RedoState)
1032}
1033
1034#endif
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
void RegisterAbstractNodeClass(std::string className, std::string typeDisplayName)
Register abstract node type display name.
int GetStates() const
Returns the current state of the scene.
vtkWeakPointer< vtkMRMLSubjectHierarchyNode > SubjectHierarchyNode
subject hierarchy node
vtkCollection * URIHandlerCollection
void GetNodeReferenceIDsFromUndoStack(std::set< std::string > &referenceIDs) const
Returns all unique node reference IDs that are referenced within the undo stack.
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.
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 ma...
static void SetStorableNodesModifiedSinceRead(vtkCollection *storableNodes)
Given a collection of storable nodes, iterate through and call StorableModified() on them.
char * LastLoadedVersion
void SetUndoOff()
void SetUndoFlag(bool flag)
void CopyRegisteredNodesToScene(vtkMRMLScene *scene)
Copies all registered nodes into the parameter scene.
void ReserveNodeReferenceIDs(vtkMRMLNode *node)
Reserve all node reference ids for a node.
void SaveSceneScreenshot(vtkImageData *thumbnail)
Utility function to write the scene thumbnail to a file in the scene's root folder.
static std::string PercentEncode(std::string s)
vtkMRMLNode * GetNthReferencingNode(int n)
vtkMRMLNode * CreateNodeByClass(const char *className)
Create node with a given class.
std::vector< vtkMRMLNode * > RegisteredNodeClasses
void StartState(unsigned long state, int anticipatedMaxProgress=0)
Flag the scene as being in a state mode.
const char * GetURL()
Get URL (file name) of the scene.
void ClearUndoStack()
clear Undo stack, delete undo history
int MaximumNumberOfSavedUndoStates
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 i...
const char * GetNthReferencedID(int n)
vtkMRMLNode * GetNthNode(int n)
Get n-th node in the scene.
std::list< vtkCollection * > RedoStack
void EndState(unsigned long state)
Unflag the scene as being in a state mode.
vtkTagTable * UserTagTable
std::string GenerateUniqueID(const std::string &baseID)
void AddNodeID(vtkMRMLNode *node)
Add node to NodeIDs map used to speedup GetByID() method.
const char * GetClassNameByTag(const char *tagName)
Add a path to the list.
void RemoveNodeReferences(vtkMRMLNode *node)
int Commit(const char *url=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
void SaveStateForUndo(std::vector< vtkMRMLNode * > nodes)
bool IsNodeClassRegistered(const std::string &className)
Return True if className is a registered node.
static bool ParseVersion(const char *versionString, std::string &application, int &major, int &minor, int &patch, int &revision)
void RemoveInvalidNodeReferences(vtkCollection *checkNodes, const std::set< std::string > &validNodeIDs)
Remove invalid node references after scene import.
std::map< std::string, std::string > RegisteredAbstractNodeClassTypeDisplayNames
vtkMRMLNode * GetNodeByID(std::string name)
void RemoveReferencesToNode(vtkMRMLNode *node)
void CopyNodeChangedIDs(vtkMRMLScene *scene)
vtkMRMLNode * CopyNode(vtkMRMLNode *n)
Add a copy of a node to the scene.
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.
vtkURIHandler * FindURIHandlerByName(const char *name)
Returns a URIHandler of a specific type if its name is known.
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 save...
std::string GetNthRegisteredAbstractNodeClassName(int n)
int Connect(vtkMRMLMessageCollection *userMessages=nullptr)
Create new scene from URL If userMessages is not nullptr then the method may add messages to it about...
vtkMRMLNode * GetSingletonNode(vtkMRMLNode *n)
Search and return a matching singleton in the scene that the input singleton node will overwrite if i...
void RemoveAllNodes(bool removeSingletons)
void Clear(int removeSingletons=0)
std::map< std::string, vtkSmartPointer< vtkMRMLNode > > NodeIDs
std::string RootDirectory
vtkCollection * GetNodesByClassByName(const char *className, const char *name)
int GetNumberOfUndoLevels()
returns number of undo steps in the history buffer
std::set< std::string > ReservedIDs
static std::string CreateUniqueFileName(const std::string &filename, const std::string &knownExtension="")
bool IsBatchProcessing() const
Return true if the scene is in BatchProcess state, false otherwise.
vtkCallbackCommand * DeleteEventCallback
void SetStorableNodesModifiedSinceRead()
Search the scene for storable nodes that are not "ModifiedSinceRead".
vtkMRMLNode * AddNewNodeByClass(std::string className, std::string nodeBaseName="")
Instantiate and add a node to the scene.
void PushIntoUndoStack()
void CopyDefaultNodesToScene(vtkMRMLScene *scene)
Copies all default nodes into the parameter scene. Does not remove existing default nodes.
virtual void SetUserTagTable(vtkTagTable *)
vtkMRMLNode * GetNodeByID(const char *name)
Get node given a unique ID.
void Undo()
undo, set the scene to previous state
std::string GenerateUniqueName(vtkMRMLNode *node)
Return a unique name for a MRML node. It uses the node tag as the base.
void ResetNodes()
Reset all nodes to their constructor's state.
std::map< std::string, int > UniqueIDs
vtkMRMLNode * GetDefaultNodeByClass(const char *className)
void RegisterNodeClass(vtkMRMLNode *node)
Utility function to RegisterNodeClass(), the node tag name is used when registering the node.
bool GetUndoFlag()
NodeReferencesType::iterator FindNodeReference(const char *referencedId, vtkMRMLNode *referencingNode)
Get a NodeReferences iterator for a node reference.
void AddReferencedNodes(vtkMRMLNode *node, vtkCollection *refNodes, bool recursive=true)
int Import(vtkMRMLMessageCollection *userMessages=nullptr)
Add the scene into the existing scene (no clear) from URL file or from.
bool SaveStorableNodeToSlicerDataBundleDirectory(vtkMRMLStorableNode *storableNode, std::string &dataDir, std::map< vtkMRMLStorageNode *, std::vector< std::string > > &originalStorageNodeFileNames, vtkMRMLMessageCollection *userMessages)
const char * GetUniqueNameByString(const char *baseName)
vtkMRMLNode * GetNthNodeByClass(int n, const char *className)
Get n-th node of a specified class in the scene.
static void SceneCallback(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
Handle vtkMRMLScene::DeleteEvent: clear the scene.
void SaveStateForUndo()
Save current state in the undo buffer.
void UpdateNodeIDs()
Synchronize NodeIDs map used to speedup GetByID() method with the Nodes collection.
void ClearNodeIDs()
Clear NodeIDs map used to speedup GetByID() method.
void RemoveReservedIDs()
void RemoveNodeID(char *nodeID)
Remove node from NodeIDs map used to speedup GetByID() method.
int IsFilePathRelative(const char *filepath)
~vtkMRMLScene() override
std::string GenerateUniqueID(vtkMRMLNode *node)
std::map< std::string, int > UniqueNames
std::map< std::string, std::set< std::string > > NodeReferencesType
char * Extensions
void TrimUndoStack()
Clean up elements of the undo/redo stack beyond the maximum size.
static vtkMRMLScene * New()
vtkMRMLNode * AddNode(vtkMRMLNode *nodeToAdd)
Add a node to the scene and send vtkMRMLScene::NodeAboutToBeAddedEvent, vtkMRMLScene::NodeAddedEvent ...
void NodeAdded(vtkMRMLNode *n)
Invoke a vtkMRMLScene::NodeAddedEvent.
const char * GetChangedID(const char *id)
int GetNodesByClass(const char *className, std::vector< vtkMRMLNode * > &nodes)
Get vector of nodes of a specified class in the scene.
int IsNodePresent(vtkMRMLNode *n)
Determine whether a particular node is present.
int GetNumberOfRegisteredNodeClasses()
void PrintSelf(ostream &os, vtkIndent indent) override
virtual void SetSubjectHierarchyNode(vtkMRMLSubjectHierarchyNode *)
void GetReferencingNodes(vtkMRMLNode *referencedNode, std::vector< vtkMRMLNode * > &referencingNodes)
Get vector of nodes containing references to an input node.
@ NodeAboutToBeRemovedEvent
@ SaveProgressFeedbackEvent
@ ImportProgressFeedbackEvent
std::vector< std::string > RegisteredNodeTags
int GetUniqueIDIndex(const std::string &baseID)
void AddReservedID(const char *id)
std::map< std::string, std::string > ReferencedIDChanges
virtual void SetCacheManager(vtkCacheManager *)
int GetNumberOfRedoLevels()
returns number of redo steps in the history buffer
std::string BuildName(const std::string &baseName, int nameIndex) const
Combine a basename and an index to produce a full name.
void UpdateNodeReferences(vtkCollection *checkNodes=nullptr)
Notify nodes about node ID changes.
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 o...
void RemoveUnusedNodeReferences()
void GetReferencedSubScene(vtkMRMLNode *node, vtkMRMLScene *newScene)
Get a sub-scene containing all nodes directly or indirectly referenced by the input node.
vtkCollection * GetNodesByClass(const char *className)
bool IsNodeReferencingNodeID(vtkMRMLNode *referencingNode, const char *id)
void SaveStateForUndo(vtkMRMLNode *node)
vtkCollection * GetNodesByName(const char *name)
Get nodes having the specified name.
void CopyNodeInUndoStack(vtkMRMLNode *node)
void AddURIHandler(vtkURIHandler *handler)
Add a URI handler to the collection.
const char * GetTagByClassName(const char *className)
Add a path to the list.
vtkMRMLNode * GetNextNodeByClass(const char *className)
vtkMRMLNode * GetFirstNodeByClass(const char *className)
Convenience function for getting 0-th node of a specified class in the scene.
std::string BuildID(const std::string &baseID, int idIndex) const
int GetNumberOfNodesByClass(const char *className)
Get number of nodes of a specified class in the scene.
void RemoveAllDefaultNodes()
Deletes all default node values from the scene.
std::string URL
void CopyNodeReferences(vtkMRMLScene *scene)
vtkMRMLNode * InsertBeforeNode(vtkMRMLNode *item, vtkMRMLNode *newItem)
insert a node in the scene before a specified node
vtkURIHandler * FindURIHandler(const char *URI)
Find a URI handler in the collection that can work on the passed URI.
int GetUniqueNameIndex(const std::string &baseName)
Returns a unique index for a given baseName.
vtkMRMLNode * InsertAfterNode(vtkMRMLNode *item, vtkMRMLNode *newItem)
insert a node in the scene after a specified node
const char * GetRootDirectory()
Get Root directory, where URL is pointing.
vtkMRMLNode * GetNthRegisteredNodeClass(int n)
int GetNumberOfRegisteredAbstractNodeClasses()
Get the number of registered abstract node classes.
void AddReferencedNodeID(const char *id, vtkMRMLNode *refrencingNode)
vtkCollection * GetNodes()
Return collection of nodes.
void CopySingletonNodesToScene(vtkMRMLScene *scene)
Copies all singleton nodes into the parameter scene.
std::default_random_engine RandomGenerator
const std::string & GetSceneXMLString()
Returns the saved scene with an XML format if SaveToXMLString is true and Commit() was called prior.
int GetNumberOfNodes()
Get number of nodes in the scene.
std::vector< unsigned long > States
vtkMRMLNode * AddNewNodeByClassWithID(std::string className, std::string nodeBaseName, std::string nodeID)
Instantiates and adds a new node to the scene with the specified ID.
vtkCollection * Nodes
void SetMaximumNumberOfSavedUndoStates(int stackSize)
Sets the maximum number of saved undo states and removes the oldest saved states so that the number o...
std::map< std::string, vtkSmartPointer< vtkMRMLNode > > DefaultNodes
std::list< vtkCollection * > UndoStack
vtkMRMLNode * GetFirstNodeByName(const char *name)
void CopyNodeInRedoStack(vtkMRMLNode *node)
vtkCollection * GetReferencedNodes(vtkMRMLNode *node, bool recursive=true)
Return collection of all nodes referenced directly or indirectly by node.
NodeReferencesType NodeReferences
void SetUndoOn()
Set undo on/off.
bool IsRestoring() const
Return true if the scene is in Restore state, false otherwise.
char * LastLoadedExtensions
void ClearRedoStack()
clear Redo stack, delete redo history
void RemoveReferencedNodeID(const char *id, vtkMRMLNode *refrencingNode)
bool IsUndoing() const
Return true if the scene is in Undo state (in the process of undoing node changes),...
void ProgressState(unsigned long state, int progress=0)
TODO: Report progress of the current state.
void SetRootDirectory(const char *dir)
Set Root directory, where URL is pointing.
vtkMTimeType NodeIDsMTime
void SetSceneXMLString(const std::string &xmlString)
Set the XML string to read from by Import() if GetLoadFromXMLString() is true.
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...
void SaveStateForUndo(vtkCollection *nodes)
void SetURL(const char *url)
Set URL (file name) of the scene.
void PushIntoRedoStack()
bool GetStorableNodesModifiedSinceRead(vtkCollection *modifiedStorableNodes=nullptr)
Search the scene for storable nodes that are "ModifiedSinceRead".
void AddDefaultNode(vtkMRMLNode *node)
bool IsImporting() const
Return true if the scene is in Import state, false otherwise.
std::string SceneXMLString
vtkMRMLNode * GetNextNode()
bool IsReservedID(const std::string &id)
bool GetModifiedSinceRead(vtkCollection *modifiedNodes=nullptr)
Returns true if the scene has been "significantly" modified since the last saved state....
std::string GetNthRegisteredAbstractNodeTypeDisplayName(int n)
vtkMRMLSubjectHierarchyNode * GetSubjectHierarchyNode()
bool IsRedoing() const
Return true if the scene is in Redo state (in the process of redoing node changes),...
vtkDataIOManager * DataIOManager
std::list< std::string > GetNodeClassesList()
virtual void SetDataIOManager(vtkDataIOManager *)
vtkCacheManager * CacheManager
data i/o handling members
void InitTraversal()
void RemoveNode(vtkMRMLNode *n)
Remove a path from the list.
std::string GetTypeDisplayNameByClassName(std::string className)
Get type display name which is shown in the GUI.
void Redo()
redo, set the scene to previously undone
vtkMRMLNode * AddNodeNoNotify(vtkMRMLNode *n)
int GetNumberOfNodeReferences()
Get the total number of node references (number of ReferencedID-ReferencingNode pairs).
virtual void SetURIHandlerCollection(vtkCollection *)
std::string GenerateUniqueName(const std::string &baseName)
Generate a node name that is unique in the scene. Calling this function successively with the same ba...
vtkMRMLNode * GetSingletonNode(const char *singletonTag, const char *className)
Search and return the singleton of type className with a singletonTag tag.
bool IsClosing() const
Return true if the scene is in Close state, false otherwise.
void UpdateNodeChangedIDs()
Change node IDs based on the ReferencedIDChanges list.
MRML node to represent a 3D surface model.
A superclass for other storage nodes.
MRML node to represent a complete subject hierarchy tree.