Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkSlicerApplicationLogicRequests.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Copyright (c) Brigham and Women's Hospital (BWH) All Rights Reserved.
4
5 See License.txt or http://www.slicer.org/copyright/copyright.txt for details.
6
7==========================================================================*/
10
11#ifndef __vtkSlicerApplicationLogicRequests_h
12#define __vtkSlicerApplicationLogicRequests_h
13
15#include <vtkMRMLDisplayNode.h>
18#include <vtkMRMLModelNode.h>
19#include <vtkMRMLStorageNode.h>
21#include <vtkMRMLTableNode.h>
22
23//----------------------------------------------------------------------------
25{
26public:
27 DataRequest() { m_UID = 0; }
28
29 DataRequest(int uid) { m_UID = uid; }
30
31 virtual ~DataRequest() = default;
32
34
35 int GetUID() const { return m_UID; }
36
37protected:
38 vtkMTimeType m_UID;
39};
40
41//----------------------------------------------------------------------------
43{
44public:
45 ReadDataRequestFile(const std::string& node, const std::string& filename, int displayData, int deleteFile, int uid = 0)
46 : DataRequest(uid)
47 {
48 m_TargetNode = node;
49 m_Filename = filename;
50 m_DisplayData = displayData;
51 m_DeleteFile = deleteFile;
52 }
53
54 void Execute(vtkSlicerApplicationLogic* appLogic) override
55 {
56 // This method needs to read the data into the specific type of node and set up an
57 // appropriate storage and display node.
58
59 vtkMRMLNode* nd = appLogic->GetMRMLScene()->GetNodeByID(m_TargetNode.c_str());
60 vtkDebugWithObjectMacro(appLogic, "ProcessReadNodeData: read data request node id = " << nd->GetID());
61
62 vtkSmartPointer<vtkMRMLStorageNode> storageNode;
64
65 bool useURI = appLogic->GetMRMLScene()->GetCacheManager()->IsRemoteReference(m_Filename.c_str());
66
68 if (storableNode)
69 {
70 int numStorageNodes = storableNode->GetNumberOfStorageNodes();
71 for (int n = 0; n < numStorageNodes; n++)
72 {
73 vtkMRMLStorageNode* testStorageNode = storableNode->GetNthStorageNode(n);
74 if (testStorageNode)
75 {
76 if (useURI && testStorageNode->GetURI() != nullptr)
77 {
78 if (m_Filename.compare(testStorageNode->GetURI()) == 0)
79 {
80 // found a storage node for the remote file
81 vtkDebugWithObjectMacro(appLogic, "ProcessReadNodeData: found a storage node with the right URI: " << testStorageNode->GetURI());
82 storageNode = testStorageNode;
83 break;
84 }
85 }
86 else if (testStorageNode->GetFileName() != nullptr && //
87 m_Filename.compare(testStorageNode->GetFileName()) == 0)
88 {
89 // found the right storage node for a local file
90 vtkDebugWithObjectMacro(appLogic, "ProcessReadNodeData: found a storage node with the right filename: " << testStorageNode->GetFileName());
91 storageNode = testStorageNode;
92 break;
93 }
94 }
95 }
96
97 // if there wasn't already a matching storage node on the node, make one
98 bool createdNewStorageNode = false;
99 if (storageNode.GetPointer() == nullptr)
100 {
101 // Read the data into the referenced node
102 if (itksys::SystemTools::FileExists(m_Filename.c_str()))
103 {
104 // file is there on disk
105 storableNode->AddDefaultStorageNode(m_Filename.c_str());
106 storageNode = storableNode->GetStorageNode();
107 createdNewStorageNode = (storageNode != nullptr);
108 }
109 }
110
111 // Have the storage node read the data into the current node
112 if (storageNode.GetPointer() != nullptr)
113 {
114 try
115 {
116 vtkDebugWithObjectMacro(appLogic,
117 "ProcessReadNodeData: about to call read data, "
118 "storage node's read state is "
119 << storageNode->GetReadStateAsString());
120 // If the node was previously empty then the write state may still be
121 // "SkipNoData", which would prevent the file from loading.
122 // Change the write state back to "Idle" to make sure the file is loaded.
123 storageNode->SetWriteStateIdle();
124 if (useURI)
125 {
126 storageNode->SetURI(m_Filename.c_str());
127 vtkDebugWithObjectMacro(appLogic, "ProcessReadNodeData: calling ReadData on the storage node " << storageNode->GetID() << ", uri = " << storageNode->GetURI());
128 storageNode->ReadData(nd, /*temporary*/ true);
129 if (createdNewStorageNode)
130 {
131 storageNode->SetURI(nullptr); // clear temporary URI
132 }
133 }
134 else
135 {
136 storageNode->SetFileName(m_Filename.c_str());
137 vtkDebugWithObjectMacro(appLogic,
138 "ProcessReadNodeData: calling ReadData on the storage node " << storageNode->GetID() << ", filename = " << storageNode->GetFileName());
139 storageNode->ReadData(nd, /*temporary*/ true);
140 if (createdNewStorageNode)
141 {
142 storageNode->SetFileName(nullptr); // clear temp file name
143 }
144 }
145 }
146 catch (itk::ExceptionObject& exc)
147 {
148 vtkErrorWithObjectMacro(appLogic, "Exception while reading " << m_Filename << ", " << exc);
149 }
150 catch (...)
151 {
152 vtkErrorWithObjectMacro(appLogic, "Unknown exception while reading " << m_Filename);
153 }
154 }
155 }
156 // if the node was a CommandLineModule node, then read the file
157 // (no storage node for these, yet)
158 if (clp)
159 {
161 }
162
163 // Delete the file if requested
164 if (m_DeleteFile)
165 {
166 int removed;
167 // is it a shared memory location?
168 if (m_Filename.find("slicer:") != std::string::npos)
169 {
170 removed = 1;
171 }
172 else
173 {
174 removed = static_cast<bool>(itksys::SystemTools::RemoveFile(m_Filename.c_str()));
175 }
176 if (!removed)
177 {
178 vtkGenericWarningMacro("Unable to delete temporary file " << m_Filename);
179 }
180 }
181
182 // Get the right type of display node. Only create a display node
183 // if one does not exist already
184 //
186 if (displayableNode)
187 {
188 // Create a default display node if no display node exists for the node yet.
189 displayableNode->CreateDefaultDisplayNodes();
190 }
191
192 // Cause the any observers to fire (we may have avoided calling
193 // modified on the node)
194 //
195 nd->Modified();
196
197 // If scalar volume, set the volume as the active volume and
198 // propagate selection.
199 //
200 // Models are always displayed when loaded above.
201 //
202 // Tensors? Vectors?
203 if (m_DisplayData)
204 {
206 {
208 appLogic->PropagateVolumeSelection();
209 }
210 else if (vtkMRMLScalarVolumeNode::SafeDownCast(nd) != nullptr)
211 {
212 appLogic->GetSelectionNode()->SetActiveVolumeID(m_TargetNode.c_str());
213 // make sure win/level gets calculated
215 if (displayNode)
216 {
217 displayNode->Modified();
218 }
219 appLogic->PropagateVolumeSelection();
220 }
221 else if (vtkMRMLTableNode::SafeDownCast(nd) != nullptr)
222 {
223 appLogic->GetSelectionNode()->SetActiveTableID(m_TargetNode.c_str());
224 appLogic->PropagateTableSelection();
225 }
226 }
227 }
228
229protected:
230 std::string m_TargetNode;
231 std::string m_Filename;
234};
235
236//----------------------------------------------------------------------------
238{
239public:
240 ReadDataRequestScene(const std::vector<std::string>& targetNodes,
241 const std::vector<std::string>& sourceNodes,
242 const std::string& filename,
243 int displayData,
244 int deleteFile,
245 int uid = 0)
246 : DataRequest(uid)
247 {
248 m_TargetNodes = targetNodes;
249 m_SourceNodes = sourceNodes;
250 m_Filename = filename;
251 m_DisplayData = displayData;
252 m_DeleteFile = deleteFile;
253 }
254
255 void Execute(vtkSlicerApplicationLogic* appLogic) override
256 {
257 if (m_SourceNodes.size() != m_TargetNodes.size())
258 {
259 // Can't do ID remapping if the two node lists are different
260 // sizes. Just import the scene. (This is where we would put to
261 // the code to load into a node hierarchy (with a corresponding
262 // change in the conditional above)).
263 appLogic->GetMRMLScene()->SetURL(m_Filename.c_str());
264 appLogic->GetMRMLScene()->Import();
265
266 // Delete the file if requested
267 if (m_DeleteFile)
268 {
269 int removed;
270 removed = static_cast<bool>(itksys::SystemTools::RemoveFile(m_Filename.c_str()));
271 if (!removed)
272 {
273 std::stringstream information;
274 information << "Unable to delete temporary file " << m_Filename << std::endl;
275 vtkGenericWarningMacro(<< information.str().c_str());
276 }
277 }
278
279 return;
280 }
281
282 vtkNew<vtkMRMLScene> miniscene;
283 miniscene->SetURL(m_Filename.c_str());
284 miniscene->Import();
285
286 // iterate over the list of nodes specified to read
287 std::vector<std::string>::const_iterator tit;
288 std::vector<std::string>::const_iterator sit;
289
290 tit = m_TargetNodes.begin();
291 sit = m_SourceNodes.begin();
292
294
295 while (sit != m_SourceNodes.end())
296 {
297 vtkMRMLNode* source = miniscene->GetNodeByID(sit->c_str());
298 vtkMRMLNode* target = appLogic->GetMRMLScene()->GetNodeByID(tit->c_str());
299
300 if (source && target)
301 {
302 // save old storage info (in case user has custom file name already
303 // defined for this node, don't use the one from the miniscene since it
304 // was only used to read/write the temp area).
306 if (storableTarget)
307 {
308 const char* oldStorageNodeID = storableTarget->GetStorageNodeID();
309 target->Copy(source);
310 storableTarget->SetAndObserveStorageNodeID(oldStorageNodeID);
311 }
312 else
313 {
314 target->Copy(source);
315 }
316
317 // if the source node is a model hierarchy node, then also copy
318 // and remap any child nodes of the target that are not in the
319 // target list (nodes that had no source equivalent before the
320 // module ran).
323 if (smhnd && tmhnd)
324 {
325 // get the model node and display node BEFORE we add nodes to
326 // the target scene
327 vtkMRMLModelNode* smnd = smhnd->GetModelNode();
328 vtkMRMLDisplayNode* sdnd = smhnd->GetDisplayNode();
329
330 // add the model and display referenced by source model hierarchy node
331 if (smnd)
332 {
333 // set the model node to be modified, as it was read from a temp
334 // location
335 // smnd->SetModifiedSinceRead(1);
336 // get display node BEFORE we add nodes to the target scene
337 vtkMRMLDisplayNode* sdnd1 = smnd->GetDisplayNode();
338
339 vtkMRMLNode* tmodel = appLogic->GetMRMLScene()->CopyNode(smnd);
342 tmhnd->SetModelNodeID(mnd->GetID());
343
344 if (sdnd1)
345 {
346 vtkMRMLNode* tdnd = appLogic->GetMRMLScene()->CopyNode(sdnd1);
347 mnd->SetAndObserveDisplayNodeID(tdnd->GetID());
348 }
349 }
350
351 if (sdnd)
352 {
353 vtkMRMLNode* dnd = appLogic->GetMRMLScene()->CopyNode(sdnd);
354 tmhnd->SetAndObserveDisplayNodeID(dnd->GetID());
355 }
356
357 // add any children model hierarchy nodes, rinse, repeat
358 //
359 // keep a map of model hierarchy node ids so that can update the parent node references
360 std::map<std::string, std::string> parentNodeIDMapper;
361 // hopefully the parents will have been read first, but if not
362 // keep a list of model hierarchy nodes that failed to have their parent node reference remapped
363 std::vector<vtkMRMLModelHierarchyNode*> childNodesThatNeedParentsIDsRemapped;
364 for (int n = 0; n < miniscene->GetNumberOfNodesByClass("vtkMRMLModelHierarchyNode"); n++)
365 {
366 vtkMRMLModelHierarchyNode* mhnd = vtkMRMLModelHierarchyNode::SafeDownCast(miniscene->GetNthNodeByClass(n, "vtkMRMLModelHierarchyNode"));
367 if (mhnd)
368 {
369 // is this model hierarchy node in our source list
370 // already? if so skip it
371 std::vector<std::string>::const_iterator ssit = std::find(m_SourceNodes.begin(), m_SourceNodes.end(), mhnd->GetID());
372 if (ssit == m_SourceNodes.end())
373 {
374 // not in source list, so we may need to add it,
375 // if it's a child, grandchild etc of the top level node that we're importing
376 if (strcmp(mhnd->GetTopParentNode()->GetID(), smhnd->GetID()) == 0)
377 {
378 // get the model and display node BEFORE we add nodes
379 // to the target scene
380 vtkMRMLModelNode* smnd1 = mhnd->GetModelNode();
381 vtkMRMLDisplayNode* sdnd1 = mhnd->GetDisplayNode();
382
383 vtkMRMLNode* tchild = appLogic->GetMRMLScene()->CopyNode(mhnd);
384 // keep track of any node id change in case other nodes use this as a parent
385 parentNodeIDMapper[std::string(mhnd->GetID())] = std::string(tchild->GetID());
387 // check for a parent node id in the mapper (as long as it doesn't already
388 // point to the source node), default to the top level one though
389 std::string parentNodeID = std::string(tmhnd->GetID());
390 if (tcmhd->GetParentNodeID() != nullptr && //
391 strcmp(tcmhd->GetParentNodeID(), smhnd->GetID()) != 0)
392 {
393 std::map<std::string, std::string>::iterator pIt = parentNodeIDMapper.find(std::string(tcmhd->GetParentNodeID()));
394 if (pIt != parentNodeIDMapper.end())
395 {
396 parentNodeID = pIt->second;
397 vtkDebugWithObjectMacro(appLogic, "Remapped parent node id to " << parentNodeID.c_str());
398 }
399 else
400 {
401 childNodesThatNeedParentsIDsRemapped.push_back(tcmhd);
402 }
403 }
404 tcmhd->SetParentNodeID(parentNodeID.c_str());
405
406 if (smnd1)
407 {
408 // set it as modified
409 // smnd1->SetModifiedSinceRead(1);
410 // get display node BEFORE we add nodes to the target scene
411 vtkMRMLDisplayNode* sdnd2 = smnd1->GetDisplayNode();
412
413 vtkMRMLNode* tmodel = appLogic->GetMRMLScene()->CopyNode(smnd1);
416 tcmhd->SetModelNodeID(mnd->GetID());
417
418 if (sdnd2)
419 {
420 vtkMRMLNode* tdnd = appLogic->GetMRMLScene()->CopyNode(sdnd2);
421 mnd->SetAndObserveDisplayNodeID(tdnd->GetID());
422 }
423 }
424
425 if (sdnd1)
426 {
427 vtkMRMLNode* tdnd = appLogic->GetMRMLScene()->CopyNode(sdnd1);
428 tcmhd->SetAndObserveDisplayNodeID(tdnd->GetID());
429 }
430 }
431 }
432 }
433 }
434 if (childNodesThatNeedParentsIDsRemapped.size() > 0)
435 {
436 // iterate through all the imported hierarchies that failed and double check their parent node ids
437 for (unsigned int i = 0; i < childNodesThatNeedParentsIDsRemapped.size(); i++)
438 {
439 std::map<std::string, std::string>::iterator pIt = parentNodeIDMapper.find(childNodesThatNeedParentsIDsRemapped[i]->GetParentNodeID());
440 if (pIt != parentNodeIDMapper.end())
441 {
442 vtkDebugWithObjectMacro(appLogic,
443 "Remapping child node " << childNodesThatNeedParentsIDsRemapped[i]->GetName() << " parent node id from "
444 << childNodesThatNeedParentsIDsRemapped[i]->GetParentNodeID() << " to " << pIt->second.c_str());
445 childNodesThatNeedParentsIDsRemapped[i]->SetParentNodeID(pIt->second.c_str());
446 }
447 }
448 }
449 }
450 }
451 else if (!source)
452 {
453 std::stringstream information;
454 information << "Node " << (*sit) << " not found in scene file " << m_Filename << std::endl;
455 vtkGenericWarningMacro(<< information.str().c_str());
456 }
457 else if (!target)
458 {
459 std::stringstream information;
460 information << "Node " << (*tit) << " not found in current scene." << std::endl;
461 vtkGenericWarningMacro(<< information.str().c_str());
462 }
463
464 ++sit;
465 ++tit;
466 }
467
469
470 // Delete the file if requested
471 if (m_DeleteFile)
472 {
473 int removed;
474 removed = static_cast<bool>(itksys::SystemTools::RemoveFile(m_Filename.c_str()));
475 if (!removed)
476 {
477 std::stringstream information;
478 information << "Unable to delete temporary file " << m_Filename << std::endl;
479 vtkGenericWarningMacro(<< information.str().c_str());
480 }
481 }
482 }
483
484protected:
485 std::vector<std::string> m_TargetNodes;
486 std::vector<std::string> m_SourceNodes;
487 std::string m_Filename;
490};
491
492//----------------------------------------------------------------------------
494{
495public:
496 ReadDataRequestUpdateParentTransform(const std::string& updatedNode, const std::string& parentTransformNode, int uid = 0)
497 : DataRequest(uid)
498 {
499 m_UpdatedNode = updatedNode;
500 m_ParentTransformNode = parentTransformNode;
501 }
502
503 void Execute(vtkSlicerApplicationLogic* appLogic) override
504 {
505 vtkMRMLScene* scene = appLogic->GetMRMLScene();
507 if (node)
508 {
510 }
511 }
512
513protected:
514 std::string m_UpdatedNode;
516};
517
518//----------------------------------------------------------------------------
520{
521public:
522 ReadDataRequestUpdateSubjectHierarchyLocation(const std::string& updatedNode, const std::string& siblingNode, int uid = 0)
523 : DataRequest(uid)
524 {
525 m_UpdatedNode = updatedNode;
526 m_SubjectHierarchySiblingNode = siblingNode;
527 }
528
529 void Execute(vtkSlicerApplicationLogic* appLogic) override
530 {
531 vtkMRMLScene* scene = appLogic->GetMRMLScene();
532
534 vtkMRMLNode* updatedNode = scene->GetNodeByID(m_UpdatedNode);
536 vtkIdType siblingNodeShItemID = shnd->GetItemByDataNode(siblingNode);
537 vtkIdType updatedNodeShItemID = shnd->GetItemByDataNode(updatedNode);
538
539 if (updatedNodeShItemID && siblingNodeShItemID)
540 {
541 vtkIdType parentItemID = shnd->GetItemParent(siblingNodeShItemID);
542 shnd->SetItemParent(updatedNodeShItemID, parentItemID);
543 shnd->SetItemLevel(updatedNodeShItemID, shnd->GetItemLevel(siblingNodeShItemID));
544 }
545 }
546
547protected:
548 std::string m_UpdatedNode;
550};
551
552//----------------------------------------------------------------------------
554{
555public:
556 ReadDataRequestAddNodeReference(const std::string& referencingNode, const std::string& referencedNode, const std::string& role, int uid = 0)
557 : DataRequest(uid)
558 {
559 m_ReferencingNode = referencingNode;
560 m_ReferencedNode = referencedNode;
561 m_Role = role;
562 }
563
564 void Execute(vtkSlicerApplicationLogic* appLogic) override
565 {
566 vtkMRMLScene* scene = appLogic->GetMRMLScene();
567
568 vtkMRMLNode* referencingNode = scene->GetNodeByID(m_ReferencingNode);
569 vtkMRMLNode* referencedNode = scene->GetNodeByID(m_ReferencedNode);
570 if (referencingNode && referencedNode)
571 {
572 referencingNode->AddNodeReferenceID(m_Role.c_str(), m_ReferencedNode.c_str());
573 }
574 }
575
576protected:
577 std::string m_ReferencingNode;
578 std::string m_ReferencedNode;
579 std::string m_Role;
580};
581
582//----------------------------------------------------------------------------
584{
585public:
586 WriteDataRequestFile(const std::string& vtkNotUsed(node), const std::string& vtkNotUsed(filename), int uid = 0)
587 : DataRequest(uid)
588 {
589 }
590
591protected:
592 std::string m_SourceNode;
593 std::string m_Filename;
594};
595
596//----------------------------------------------------------------------------
598{
599public:
600 WriteDataRequestScene(const std::vector<std::string>& targetNodes, const std::vector<std::string>& sourceNodes, const std::string& filename, int uid = 0)
601 : DataRequest(uid)
602 {
603 m_TargetNodes = targetNodes;
604 m_SourceNodes = sourceNodes;
605 m_Filename = filename;
606 }
607
608 void Execute(vtkSlicerApplicationLogic* appLogic) override
609 {
610 if (m_SourceNodes.size() != m_TargetNodes.size())
611 {
612 // Can't do ID remapping if the two node lists are different
613 // sizes. Just commit the scene. (This is where we would put to
614 // the code to load into a node hierarchy (with a corresponding
615 // change in the conditional above)).
616 appLogic->GetMRMLScene()->SetURL(m_Filename.c_str());
617 appLogic->GetMRMLScene()->Commit();
618 return;
619 }
620 }
621
622protected:
623 std::vector<std::string> m_TargetNodes;
624 std::vector<std::string> m_SourceNodes;
625 std::string m_Filename;
626};
627
628#endif
virtual ~DataRequest()=default
virtual void Execute(vtkSlicerApplicationLogic *)
void Execute(vtkSlicerApplicationLogic *appLogic) override
ReadDataRequestAddNodeReference(const std::string &referencingNode, const std::string &referencedNode, const std::string &role, int uid=0)
ReadDataRequestFile(const std::string &node, const std::string &filename, int displayData, int deleteFile, int uid=0)
void Execute(vtkSlicerApplicationLogic *appLogic) override
ReadDataRequestScene(const std::vector< std::string > &targetNodes, const std::vector< std::string > &sourceNodes, const std::string &filename, int displayData, int deleteFile, int uid=0)
std::vector< std::string > m_TargetNodes
std::vector< std::string > m_SourceNodes
void Execute(vtkSlicerApplicationLogic *appLogic) override
ReadDataRequestUpdateParentTransform(const std::string &updatedNode, const std::string &parentTransformNode, int uid=0)
void Execute(vtkSlicerApplicationLogic *appLogic) override
ReadDataRequestUpdateSubjectHierarchyLocation(const std::string &updatedNode, const std::string &siblingNode, int uid=0)
void Execute(vtkSlicerApplicationLogic *appLogic) override
WriteDataRequestFile(const std::string &vtkNotUsed(node), const std::string &vtkNotUsed(filename), int uid=0)
WriteDataRequestScene(const std::vector< std::string > &targetNodes, const std::vector< std::string > &sourceNodes, const std::string &filename, int uid=0)
std::vector< std::string > m_TargetNodes
void Execute(vtkSlicerApplicationLogic *appLogic) override
std::vector< std::string > m_SourceNodes
virtual int IsRemoteReference(const char *uri)
vtkMRMLScene * GetMRMLScene() const
Return a reference to the current MRML scene.
void PropagateTableSelection()
Propagate selected table in the SelectionNode to table view nodes.
void PropagateVolumeSelection(int fit=1)
vtkMRMLSelectionNode * GetSelectionNode() const
Get default Selection node.
MRML node for representing the parameters allowing to run a command line interface module (CLI)....
static vtkMRMLCommandLineModuleNode * SafeDownCast(vtkObject *o)
bool ReadParameterFile(const std::string &filename)
Abstract class that contains graphical display properties for displayable nodes.
vtkMRMLDisplayNode * GetDisplayNode()
Get associated display MRML node.
void SetAndObserveDisplayNodeID(const char *DisplayNodeID)
static vtkMRMLDisplayableNode * SafeDownCast(vtkObject *o)
void SetAndObserveDisplayNodeID(const char *displayNodeID)
virtual void CreateDefaultDisplayNodes()
vtkMRMLDisplayNode * GetDisplayNode()
vtkMRMLHierarchyNode * GetTopParentNode()
Get the top parent node in the hierarchy.
virtual char * GetParentNodeID()
String ID of the parent hierarchy MRML node.
virtual void SetParentNodeID(const char *ref)
static vtkMRMLLabelMapVolumeNode * SafeDownCast(vtkObject *o)
MRML node to represent a hierarchy of models.
void SetModelNodeID(const char *id)
String ID of the model MRML node.
static vtkMRMLModelHierarchyNode * SafeDownCast(vtkObject *o)
vtkMRMLModelNode * GetModelNode()
Get associated model MRML node.
MRML node to represent a 3D surface model.
static vtkMRMLModelNode * SafeDownCast(vtkObject *o)
Abstract Superclass for all specific types of MRML nodes.
virtual char * GetID()
ID use by other nodes to reference this node in XML.
vtkMRMLNode * AddNodeReferenceID(const char *referenceRole, const char *referencedNodeID)
Convenience method that adds a referencedNodeID at the end of the list.
void Modified() override
Customized version of Modified() allowing to compress vtkCommand::ModifiedEvent.
virtual void Copy(vtkMRMLNode *node)
Copy node contents from another node of the same type. Does not copy node ID and Scene....
static vtkMRMLScalarVolumeNode * SafeDownCast(vtkObject *o)
A set of MRML Nodes that supports serialization and undo/redo.
void StartState(unsigned long state, int anticipatedMaxProgress=0)
Flag the scene as being in a state mode.
void EndState(unsigned long state)
Unflag the scene as being in a state mode.
int Commit(const char *url=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
virtual vtkCacheManager * GetCacheManager()
vtkMRMLNode * CopyNode(vtkMRMLNode *n)
Add a copy of a node to the scene.
vtkMRMLNode * GetNodeByID(const char *name)
Get node given a unique ID.
int Import(vtkMRMLMessageCollection *userMessages=nullptr)
Add the scene into the existing scene (no clear) from URL file or from.
void SetURL(const char *url)
Set URL (file name) of the scene.
void SetActiveTableID(const char *id)
void SetActiveVolumeID(const char *id)
void SetActiveLabelVolumeID(const char *id)
MRML node to represent a 3D surface model.
vtkMRMLStorageNode * GetNthStorageNode(int n)
Get associated display MRML node.
void SetAndObserveStorageNodeID(const char *storageNodeID)
String ID of the storage MRML node.
virtual bool AddDefaultStorageNode(const char *filename=nullptr)
const char * GetStorageNodeID()
vtkMRMLStorageNode * GetStorageNode()
static vtkMRMLStorableNode * SafeDownCast(vtkObject *o)
A superclass for other storage nodes.
virtual char * GetURI()
virtual char * GetFileName()
MRML node to represent a complete subject hierarchy tree.
vtkIdType GetItemByDataNode(vtkMRMLNode *dataNode)
void SetItemLevel(vtkIdType itemID, std::string level)
Convenience function to set level attribute for a subject hierarchy item.
void SetItemParent(vtkIdType itemID, vtkIdType parentItemID, bool enableCircularCheck=true)
static vtkMRMLSubjectHierarchyNode * GetSubjectHierarchyNode(vtkMRMLScene *scene)
std::string GetItemLevel(vtkIdType itemID)
Convenience function to get level attribute for a subject hierarchy item.
vtkIdType GetItemParent(vtkIdType itemID)
static vtkMRMLTableNode * SafeDownCast(vtkObject *o)
MRML node for representing a node with a transform.
bool SetAndObserveTransformNodeID(const char *transformNodeID)
static vtkMRMLTransformableNode * SafeDownCast(vtkObject *o)