15 #ifndef __vtkMRMLScene_h 16 #define __vtkMRMLScene_h 20 #define CURRENT_MRML_VERSION "Slicer4.4.0" 26 #include <vtkObject.h> 27 #include <vtkSmartPointer.h> 40 class vtkCallbackCommand;
42 class vtkGeneralTransform;
65 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
68 void SetURL(
const char *url);
74 void SetRootDirectory(
const char *dir);
77 const char *GetRootDirectory();
94 int Commit(
const char* url=NULL);
101 void Clear(
int removeSingletons=0);
123 vtkMRMLNode* CreateNodeByClass(
const char* className);
145 void RegisterNodeClass(
vtkMRMLNode* node,
const char* tagName);
154 const char* GetClassNameByTag(
const char *tagName);
157 const char* GetTagByClassName(
const char *className);
163 vtkMRMLNode* GetDefaultNodeByClass(
const char* className);
166 void RemoveAllDefaultNodes();
169 vtkCollection* GetNodes();
200 vtkMRMLNode* AddNewNodeByClass(std::string className, std::string nodeBaseName =
"");
226 void InitTraversal();
244 vtkMRMLNode *GetNextNodeByClass(
const char* className);
247 vtkCollection *GetNodesByName(
const char* name);
261 vtkMRMLNode *GetFirstNode(
const char* byName = 0,
const char* byClass = 0,
262 const int* byHideFromEditors = 0,
263 bool exactNameMatch =
true);
271 vtkCollection *GetNodesByClassByName(
const char* className,
const char* name);
274 int GetNumberOfNodes();
280 vtkMRMLNode* GetNthNodeByClass(
int n,
const char* className );
282 vtkMRMLNode* GetFirstNodeByClass(
const char* className);
285 int GetNumberOfNodesByClass(
const char* className);
297 vtkMRMLNode* GetSingletonNode(
const char* singletonTag,
const char* className);
307 std::list<std::string> GetNodeClassesList();
311 int GetNumberOfRegisteredNodeClasses();
319 bool IsNodeClassRegistered(
const std::string& className);
324 std::string GenerateUniqueName(
const std::string& baseName);
330 const char* GetUniqueNameByString(
const char* baseName);
350 void ClearUndoStack();
353 void ClearRedoStack();
362 void SaveStateForUndo();
368 void SaveStateForUndo(vtkCollection *
nodes);
369 void SaveStateForUndo(std::vector<vtkMRMLNode *>
nodes);
377 void AddReferencedNodeID(
const char *
id,
vtkMRMLNode *refrencingNode);
378 bool IsNodeReferencingNodeID(
vtkMRMLNode* referencingNode,
const char*
id);
389 const char* GetNthReferencedID(
int n);
391 void RemoveReferencedNodeID(
const char *
id,
vtkMRMLNode *refrencingNode);
411 void UpdateNodeChangedIDs();
413 void RemoveUnusedNodeReferences();
415 bool IsReservedID(
const std::string&
id);
417 void AddReservedID(
const char *
id);
419 void RemoveReservedIDs();
423 const char* GetChangedID(
const char*
id);
439 vtkCollection* GetReferencedNodes(
vtkMRMLNode *node,
bool recursive=
true);
442 void GetReferencingNodes(
vtkMRMLNode* referencedNode, std::vector<vtkMRMLNode *> &referencingNodes);
452 int IsFilePathRelative(
const char * filepath);
454 vtkSetMacro(ErrorCode,
unsigned long);
455 vtkGetMacro(ErrorCode,
unsigned long);
463 vtkSetMacro(LoadFromXMLString,
int);
464 vtkGetMacro(LoadFromXMLString,
int);
472 vtkSetMacro(SaveToXMLString,
int);
473 vtkGetMacro(SaveToXMLString,
int);
475 vtkSetMacro(ReadDataOnLoad,
int);
476 vtkGetMacro(ReadDataOnLoad,
int);
478 void SetErrorMessage(
const std::string &error);
479 std::string GetErrorMessage();
485 void SetSceneXMLString(
const std::string &xmlString);
491 const std::string& GetSceneXMLString();
493 void SetErrorMessage(
const char * message);
494 const char *GetErrorMessagePointer();
500 vtkGetObjectMacro ( URIHandlerCollection, vtkCollection );
501 virtual void SetURIHandlerCollection(vtkCollection* );
552 BatchProcessState = 0x0001,
553 CloseState = 0x0002 | BatchProcessState,
554 ImportState = 0x0004 | BatchProcessState,
555 RestoreState = 0x0008 | BatchProcessState,
566 int GetStates()
const;
569 inline bool IsBatchProcessing()
const;
571 inline bool IsClosing()
const;
573 inline bool IsImporting()
const;
575 inline bool IsRestoring()
const;
611 void StartState(
unsigned long state,
int anticipatedMaxProgress = 0);
621 void EndState(
unsigned long state);
624 void ProgressState(
unsigned long state,
int progress = 0);
628 NodeAboutToBeAddedEvent = 0x2000,
633 NewSceneEvent = 66030,
634 MetadataAddedEvent = 66032,
644 ProgressEvent = 0x0400,
646 StartBatchProcessEvent = StateEvent | StartEvent | BatchProcessState,
647 EndBatchProcessEvent = StateEvent | EndEvent | BatchProcessState,
648 ProgressBatchProcessEvent = StateEvent | ProgressEvent | BatchProcessState,
650 StartCloseEvent = StateEvent | StartEvent | CloseState,
651 EndCloseEvent = StateEvent | EndEvent | CloseState,
652 ProgressCloseEvent = StateEvent | ProgressEvent | CloseState,
654 StartImportEvent = StateEvent | StartEvent | ImportState,
655 EndImportEvent = StateEvent | EndEvent | ImportState,
656 ProgressImportEvent = StateEvent | EndEvent | ImportState,
658 StartRestoreEvent = StateEvent | StartEvent | RestoreState,
659 EndRestoreEvent = StateEvent | EndEvent | RestoreState,
660 ProgressRestoreEvent = StateEvent | ProgressEvent | RestoreState,
662 StartSaveEvent = StateEvent | StartEvent | SaveState,
663 EndSaveEvent = StateEvent | EndEvent | SaveState,
664 ProgressSaveEvent = StateEvent | ProgressEvent | SaveState,
668 vtkGetStringMacro(LastLoadedVersion);
669 vtkSetStringMacro(LastLoadedVersion);
672 vtkGetStringMacro(Version);
673 vtkSetStringMacro(Version);
694 bool GetStorableNodesModifiedSinceRead(vtkCollection* modifiedStorableNodes = 0);
701 void SetStorableNodesModifiedSinceRead();
705 static void SetStorableNodesModifiedSinceRead(vtkCollection* storableNodes);
714 void PushIntoUndoStack();
715 void PushIntoRedoStack();
728 void AddReferencedNodes(
vtkMRMLNode *node, vtkCollection *refNodes,
bool recursive=
true);
731 static void SceneCallback( vtkObject *caller,
unsigned long eid,
732 void *clientData,
void *callData );
735 std::string GenerateUniqueID(
const std::string& baseID);
736 int GetUniqueIDIndex(
const std::string& baseID);
737 std::string BuildID(
const std::string& baseID,
int idIndex)
const;
747 int GetUniqueNameIndex(
const std::string& baseName);
750 std::string BuildName(
const std::string& baseName,
int nameIndex)
const;
754 void UpdateNodeIDs();
760 void RemoveNodeID(
char *nodeID);
766 NodeReferencesType::iterator FindNodeReference(
const char* referencedId,
vtkMRMLNode* referencingNode);
797 std::map< std::string, vtkSmartPointer<vtkMRMLNode> >
NodeIDs;
816 void RemoveAllNodes(
bool removeSingletons);
829 int LoadIntoScene(vtkCollection* scene);
831 unsigned long ErrorCode;
834 vtkTimeStamp StoredTime;
int GetNodesByClass(const char *className, std::vector< vtkMRMLNode *> &nodes)
int GetNumberOfRedoLevels()
returns number of redo steps in the history buffer
vtkCallbackCommand * DeleteEventCallback
bool IsImporting() const
Return true if the scene is in Import state, false otherwise.
std::map< std::string, vtkSmartPointer< vtkMRMLNode > > NodeIDs
vtkDataIOManager * DataIOManager
void SetUndoFlag(bool flag)
vtkCollection * URIHandlerCollection
std::string RootDirectory
virtual bool GetModifiedSinceRead()
std::set< std::string > ReservedIDs
std::string SceneXMLString
int GetNumberOfUndoLevels()
returns number of undo steps in the history buffer
static vtkMRMLSceneViewNode * New()
void SetUndoOn()
Set undo on/off.
std::map< std::string, int > UniqueIDs
vtkCacheManager * CacheManager
data i/o handling members
A set of MRML Nodes that supports serialization and undo/redo.
vtkMTimeType NodeIDsMTime
std::map< std::string, int > UniqueNames
int GetNumberOfNodeReferences(const char *referenceRole)
Return the number of node IDs for a specific reference role (and nodes as they always have the same s...
NodeReferencesType NodeReferences
std::vector< vtkMRMLNode *> RegisteredNodeClasses
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
void operator=(const vtkMRMLSceneViewNode &)
std::list< vtkCollection *> UndoStack
friend class vtkMRMLScene
virtual void UpdateNodeReferences(const char *referenceRole=NULL)
std::map< std::string, std::string > ReferencedIDChanges
bool IsClosing() const
Return true if the scene is in Close state, false otherwise.
std::vector< std::string > RegisteredNodeTags
bool IsRestoring() const
Return true if the scene is in Restore state, false otherwise.
Abstract Superclass for all specific types of MRML nodes.
std::list< vtkCollection *> RedoStack
vtkTagTable * UserTagTable
vtkTagTable * UserTagTable
int GetStates() const
Returns the current state of the scene.
std::vector< unsigned long > States
bool IsBatchProcessing() const
Return true if the scene is in BatchProcess state, false otherwise.
std::map< std::string, vtkSmartPointer< vtkMRMLNode > > DefaultNodes
std::map< std::string, std::set< std::string > > NodeReferencesType