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);
97 void Clear(
int removeSingletons);
113 vtkMRMLNode* CreateNodeByClass(
const char* className);
135 void RegisterNodeClass(
vtkMRMLNode* node,
const char* tagName);
144 const char* GetClassNameByTag(
const char *tagName);
147 const char* GetTagByClassName(
const char *className);
153 vtkMRMLNode* GetDefaultNodeByClass(
const char* className);
156 void RemoveAllDefaultNodes();
159 vtkCollection* GetNodes();
190 vtkMRMLNode* AddNewNodeByClass(std::string className, std::string nodeBaseName =
"");
216 void InitTraversal();
234 vtkMRMLNode *GetNextNodeByClass(
const char* className);
237 vtkCollection *GetNodesByName(
const char* name);
251 vtkMRMLNode *GetFirstNode(
const char* byName = 0,
const char* byClass = 0,
252 const int* byHideFromEditors = 0,
253 bool exactNameMatch =
true);
261 vtkCollection *GetNodesByClassByName(
const char* className,
const char* name);
264 int GetNumberOfNodes();
270 vtkMRMLNode* GetNthNodeByClass(
int n,
const char* className );
272 vtkMRMLNode* GetFirstNodeByClass(
const char* className);
275 int GetNumberOfNodesByClass(
const char* className);
287 vtkMRMLNode* GetSingletonNode(
const char* singletonTag,
const char* className);
297 std::list<std::string> GetNodeClassesList();
301 int GetNumberOfRegisteredNodeClasses();
309 bool IsNodeClassRegistered(
const std::string& className);
314 std::string GenerateUniqueName(
const std::string& baseName);
320 const char* GetUniqueNameByString(
const char* baseName);
340 void ClearUndoStack();
343 void ClearRedoStack();
352 void SaveStateForUndo();
358 void SaveStateForUndo(vtkCollection *nodes);
359 void SaveStateForUndo(std::vector<vtkMRMLNode *> nodes);
367 void AddReferencedNodeID(
const char *
id,
vtkMRMLNode *refrencingNode);
368 bool IsNodeReferencingNodeID(
vtkMRMLNode* referencingNode,
const char*
id);
379 const char* GetNthReferencedID(
int n);
381 void RemoveReferencedNodeID(
const char *
id,
vtkMRMLNode *refrencingNode);
401 void UpdateNodeChangedIDs();
403 void RemoveUnusedNodeReferences();
405 bool IsReservedID(
const std::string&
id);
407 void AddReservedID(
const char *
id);
409 void RemoveReservedIDs();
413 const char* GetChangedID(
const char*
id);
426 vtkCollection* GetReferencedNodes(
vtkMRMLNode *node);
429 void GetReferencingNodes(
vtkMRMLNode* referencedNode, std::vector<vtkMRMLNode *> &referencingNodes);
439 int IsFilePathRelative(
const char * filepath);
441 vtkSetMacro(ErrorCode,
unsigned long);
442 vtkGetMacro(ErrorCode,
unsigned long);
450 vtkSetMacro(LoadFromXMLString,
int);
451 vtkGetMacro(LoadFromXMLString,
int);
459 vtkSetMacro(SaveToXMLString,
int);
460 vtkGetMacro(SaveToXMLString,
int);
462 vtkSetMacro(ReadDataOnLoad,
int);
463 vtkGetMacro(ReadDataOnLoad,
int);
465 void SetErrorMessage(
const std::string &error);
466 std::string GetErrorMessage();
472 void SetSceneXMLString(
const std::string &xmlString);
478 const std::string& GetSceneXMLString();
480 void SetErrorMessage(
const char * message);
481 const char *GetErrorMessagePointer();
487 vtkGetObjectMacro ( URIHandlerCollection, vtkCollection );
488 virtual void SetURIHandlerCollection(vtkCollection* );
539 BatchProcessState = 0x0001,
540 CloseState = 0x0002 | BatchProcessState,
541 ImportState = 0x0004 | BatchProcessState,
542 RestoreState = 0x0008 | BatchProcessState,
553 int GetStates()
const;
556 inline bool IsBatchProcessing()
const;
558 inline bool IsClosing()
const;
560 inline bool IsImporting()
const;
562 inline bool IsRestoring()
const;
598 void StartState(
unsigned long state,
int anticipatedMaxProgress = 0);
608 void EndState(
unsigned long state);
611 void ProgressState(
unsigned long state,
int progress = 0);
615 NodeAboutToBeAddedEvent = 0x2000,
620 NewSceneEvent = 66030,
621 MetadataAddedEvent = 66032,
631 ProgressEvent = 0x0400,
633 StartBatchProcessEvent = StateEvent | StartEvent | BatchProcessState,
634 EndBatchProcessEvent = StateEvent | EndEvent | BatchProcessState,
635 ProgressBatchProcessEvent = StateEvent | ProgressEvent | BatchProcessState,
637 StartCloseEvent = StateEvent | StartEvent | CloseState,
638 EndCloseEvent = StateEvent | EndEvent | CloseState,
639 ProgressCloseEvent = StateEvent | ProgressEvent | CloseState,
641 StartImportEvent = StateEvent | StartEvent | ImportState,
642 EndImportEvent = StateEvent | EndEvent | ImportState,
643 ProgressImportEvent = StateEvent | EndEvent | ImportState,
645 StartRestoreEvent = StateEvent | StartEvent | RestoreState,
646 EndRestoreEvent = StateEvent | EndEvent | RestoreState,
647 ProgressRestoreEvent = StateEvent | ProgressEvent | RestoreState,
649 StartSaveEvent = StateEvent | StartEvent | SaveState,
650 EndSaveEvent = StateEvent | EndEvent | SaveState,
651 ProgressSaveEvent = StateEvent | ProgressEvent | SaveState,
655 vtkGetStringMacro(LastLoadedVersion);
656 vtkSetStringMacro(LastLoadedVersion);
659 vtkGetStringMacro(Version);
660 vtkSetStringMacro(Version);
681 bool GetStorableNodesModifiedSinceRead(vtkCollection* modifiedStorableNodes = 0);
688 void SetStorableNodesModifiedSinceRead();
692 static void SetStorableNodesModifiedSinceRead(vtkCollection* storableNodes);
701 void PushIntoUndoStack();
702 void PushIntoRedoStack();
712 void AddReferencedNodes(
vtkMRMLNode *node, vtkCollection *refNodes);
715 static void SceneCallback( vtkObject *caller,
unsigned long eid,
716 void *clientData,
void *callData );
719 std::string GenerateUniqueID(
const std::string& baseID);
720 int GetUniqueIDIndex(
const std::string& baseID);
721 std::string BuildID(
const std::string& baseID,
int idIndex)
const;
731 int GetUniqueNameIndex(
const std::string& baseName);
734 std::string BuildName(
const std::string& baseName,
int nameIndex)
const;
738 void UpdateNodeIDs();
744 void RemoveNodeID(
char *nodeID);
750 NodeReferencesType::iterator FindNodeReference(
const char* referencedId,
vtkMRMLNode* referencingNode);
782 std::map< std::string, vtkSmartPointer<vtkMRMLNode> >
NodeIDs;
801 void RemoveAllNodes(
bool removeSingletons);
814 int LoadIntoScene(vtkCollection* scene);
816 unsigned long ErrorCode;
819 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
vtkMTimeType SceneModifiedTime
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
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