Slicer 5.8
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
14#include <vtkMRMLDisplayNode.h>
17#include <vtkMRMLModelNode.h>
18#include <vtkMRMLStorageNode.h>
20#include <vtkMRMLTableNode.h>
21
22//----------------------------------------------------------------------------
24{
25public:
27 {
28 m_UID = 0;
29 }
30
31 DataRequest(int uid)
32 {
33 m_UID = uid;
34 }
35
36 virtual ~DataRequest() = default;
37
39
40 int GetUID()const{return m_UID;}
41
42protected:
43 vtkMTimeType m_UID;
44};
45
46//----------------------------------------------------------------------------
48{
49public:
50 ReadDataRequestFile(const std::string& node, const std::string& filename,
51 int displayData, int deleteFile, int uid = 0)
52 : DataRequest(uid)
53 {
54 m_TargetNode = node;
55 m_Filename = filename;
56 m_DisplayData = displayData;
57 m_DeleteFile = deleteFile;
58 }
59
60 void Execute(vtkSlicerApplicationLogic* appLogic) override
61 {
62 // This method needs to read the data into the specific type of node and set up an
63 // appropriate storage and display node.
64
65 vtkMRMLNode *nd = appLogic->GetMRMLScene()->GetNodeByID(m_TargetNode.c_str());
66 vtkDebugWithObjectMacro(appLogic, "ProcessReadNodeData: read data request node id = " << nd->GetID());
67
68 vtkSmartPointer<vtkMRMLStorageNode> storageNode;
69#ifdef Slicer_BUILD_CLI_SUPPORT
71#endif
72
73 bool useURI = appLogic->GetMRMLScene()->GetCacheManager()->IsRemoteReference(m_Filename.c_str());
74
76 if (storableNode)
77 {
78 int numStorageNodes = storableNode->GetNumberOfStorageNodes();
79 for (int n = 0; n < numStorageNodes; n++)
80 {
81 vtkMRMLStorageNode *testStorageNode = storableNode->GetNthStorageNode(n);
82 if (testStorageNode)
83 {
84 if (useURI && testStorageNode->GetURI() != nullptr)
85 {
86 if (m_Filename.compare(testStorageNode->GetURI()) == 0)
87 {
88 // found a storage node for the remote file
89 vtkDebugWithObjectMacro(appLogic, "ProcessReadNodeData: found a storage node with the right URI: " << testStorageNode->GetURI());
90 storageNode = testStorageNode;
91 break;
92 }
93 }
94 else if (testStorageNode->GetFileName() != nullptr &&
95 m_Filename.compare(testStorageNode->GetFileName()) == 0)
96 {
97 // found the right storage node for a local file
98 vtkDebugWithObjectMacro(appLogic, "ProcessReadNodeData: found a storage node with the right filename: " << testStorageNode->GetFileName());
99 storageNode = testStorageNode;
100 break;
101 }
102 }
103 }
104
105 // if there wasn't already a matching storage node on the node, make one
106 bool createdNewStorageNode = false;
107 if (storageNode.GetPointer() == nullptr)
108 {
109 // Read the data into the referenced node
110 if (itksys::SystemTools::FileExists(m_Filename.c_str()))
111 {
112 // file is there on disk
113 storableNode->AddDefaultStorageNode(m_Filename.c_str());
114 storageNode = storableNode->GetStorageNode();
115 createdNewStorageNode = (storageNode != nullptr);
116 }
117 }
118
119 // Have the storage node read the data into the current node
120 if (storageNode.GetPointer() != nullptr)
121 {
122 try
123 {
124 vtkDebugWithObjectMacro(appLogic, "ProcessReadNodeData: about to call read data, " \
125 "storage node's read state is " << storageNode->GetReadStateAsString());
126 // If the node was previously empty then the write state may still be
127 // "SkipNoData", which would prevent the file from loading.
128 // Change the write state back to "Idle" to make sure the file is loaded.
129 storageNode->SetWriteStateIdle();
130 if (useURI)
131 {
132 storageNode->SetURI(m_Filename.c_str());
133 vtkDebugWithObjectMacro(appLogic, "ProcessReadNodeData: calling ReadData on the storage node " \
134 << storageNode->GetID() << ", uri = " << storageNode->GetURI());
135 storageNode->ReadData(nd, /*temporary*/true);
136 if (createdNewStorageNode)
137 {
138 storageNode->SetURI(nullptr); // clear temporary URI
139 }
140 }
141 else
142 {
143 storageNode->SetFileName(m_Filename.c_str());
144 vtkDebugWithObjectMacro(appLogic, "ProcessReadNodeData: calling ReadData on the storage node " \
145 << storageNode->GetID() << ", filename = " << storageNode->GetFileName());
146 storageNode->ReadData(nd, /*temporary*/true);
147 if (createdNewStorageNode)
148 {
149 storageNode->SetFileName(nullptr); // clear temp file name
150 }
151 }
152 }
153 catch (itk::ExceptionObject& exc)
154 {
155 vtkErrorWithObjectMacro(appLogic, "Exception while reading " << m_Filename << ", " << exc);
156 }
157 catch (...)
158 {
159 vtkErrorWithObjectMacro(appLogic, "Unknown exception while reading " << m_Filename);
160 }
161 }
162 }
163#ifdef Slicer_BUILD_CLI_SUPPORT
164 // if the node was a CommandLineModule node, then read the file
165 // (no storage node for these, yet)
166 if (clp)
167 {
169 }
170#endif
171
172 // Delete the file if requested
173 if (m_DeleteFile)
174 {
175 int removed;
176 // is it a shared memory location?
177 if (m_Filename.find("slicer:") != std::string::npos)
178 {
179 removed = 1;
180 }
181 else
182 {
183 removed = static_cast<bool>(itksys::SystemTools::RemoveFile(m_Filename.c_str()));
184 }
185 if (!removed)
186 {
187 vtkGenericWarningMacro("Unable to delete temporary file " << m_Filename);
188 }
189 }
190
191
192 // Get the right type of display node. Only create a display node
193 // if one does not exist already
194 //
195 vtkMRMLDisplayableNode *displayableNode =
197 if (displayableNode)
198 {
199 // Create a default display node if no display node exists for the node yet.
200 displayableNode->CreateDefaultDisplayNodes();
201 }
202
203 // Cause the any observers to fire (we may have avoided calling
204 // modified on the node)
205 //
206 nd->Modified();
207
208 // If scalar volume, set the volume as the active volume and
209 // propagate selection.
210 //
211 // Models are always displayed when loaded above.
212 //
213 // Tensors? Vectors?
214 if (m_DisplayData)
215 {
217 {
219 appLogic->PropagateVolumeSelection();
220 }
221 else if (vtkMRMLScalarVolumeNode::SafeDownCast(nd) != nullptr)
222 {
223 appLogic->GetSelectionNode()->SetActiveVolumeID(m_TargetNode.c_str());
224 // make sure win/level gets calculated
226 if (displayNode)
227 {
228 displayNode->Modified();
229 }
230 appLogic->PropagateVolumeSelection();
231 }
232 else if (vtkMRMLTableNode::SafeDownCast(nd) != nullptr)
233 {
234 appLogic->GetSelectionNode()->SetActiveTableID(m_TargetNode.c_str());
235 appLogic->PropagateTableSelection();
236 }
237 }
238 }
239
240protected:
241 std::string m_TargetNode;
242 std::string m_Filename;
245};
246
247//----------------------------------------------------------------------------
249{
250public:
251 ReadDataRequestScene(const std::vector<std::string>& targetNodes,
252 const std::vector<std::string>& sourceNodes,
253 const std::string& filename,
254 int displayData, int deleteFile,
255 int uid = 0)
256 : DataRequest(uid)
257 {
258 m_TargetNodes = targetNodes;
259 m_SourceNodes = sourceNodes;
260 m_Filename = filename;
261 m_DisplayData = displayData;
262 m_DeleteFile = deleteFile;
263 }
264
265 void Execute(vtkSlicerApplicationLogic* appLogic) override
266 {
267 if (m_SourceNodes.size() != m_TargetNodes.size())
268 {
269 // Can't do ID remapping if the two node lists are different
270 // sizes. Just import the scene. (This is where we would put to
271 // the code to load into a node hierarchy (with a corresponding
272 // change in the conditional above)).
273 appLogic->GetMRMLScene()->SetURL(m_Filename.c_str());
274 appLogic->GetMRMLScene()->Import();
275
276 // Delete the file if requested
277 if (m_DeleteFile)
278 {
279 int removed;
280 removed = static_cast<bool>(itksys::SystemTools::RemoveFile(m_Filename.c_str()));
281 if (!removed)
282 {
283 std::stringstream information;
284 information << "Unable to delete temporary file "
285 << m_Filename << std::endl;
286 vtkGenericWarningMacro( << information.str().c_str() );
287 }
288 }
289
290 return;
291 }
292
293 vtkNew<vtkMRMLScene> miniscene;
294 miniscene->SetURL(m_Filename.c_str() );
295 miniscene->Import();
296
297 // iterate over the list of nodes specified to read
298 std::vector<std::string>::const_iterator tit;
299 std::vector<std::string>::const_iterator sit;
300
301 tit = m_TargetNodes.begin();
302 sit = m_SourceNodes.begin();
303
305
306 while (sit != m_SourceNodes.end())
307 {
308 vtkMRMLNode *source = miniscene->GetNodeByID(sit->c_str());
309 vtkMRMLNode *target = appLogic->GetMRMLScene()->GetNodeByID( tit->c_str() );
310
311 if (source && target)
312 {
313 // save old storage info (in case user has custom file name already
314 // defined for this node, don't use the one from the miniscene since it
315 // was only used to read/write the temp area).
317 if ( storableTarget )
318 {
319 const char *oldStorageNodeID = storableTarget->GetStorageNodeID();
320 target->Copy(source);
321 storableTarget->SetAndObserveStorageNodeID(oldStorageNodeID);
322 }
323 else
324 {
325 target->Copy(source);
326 }
327
328 // if the source node is a model hierarchy node, then also copy
329 // and remap any child nodes of the target that are not in the
330 // target list (nodes that had no source equivalent before the
331 // module ran).
336 if (smhnd && tmhnd)
337 {
338 // get the model node and display node BEFORE we add nodes to
339 // the target scene
340 vtkMRMLModelNode *smnd = smhnd->GetModelNode();
341 vtkMRMLDisplayNode *sdnd = smhnd->GetDisplayNode();
342
343 // add the model and display referenced by source model hierarchy node
344 if (smnd)
345 {
346 // set the model node to be modified, as it was read from a temp
347 // location
348 //smnd->SetModifiedSinceRead(1);
349 // get display node BEFORE we add nodes to the target scene
350 vtkMRMLDisplayNode *sdnd1 = smnd->GetDisplayNode();
351
352 vtkMRMLNode *tmodel = appLogic->GetMRMLScene()->CopyNode(smnd);
355 tmhnd->SetModelNodeID( mnd->GetID() );
356
357 if (sdnd1)
358 {
359 vtkMRMLNode *tdnd = appLogic->GetMRMLScene()->CopyNode(sdnd1);
360 mnd->SetAndObserveDisplayNodeID( tdnd->GetID() );
361 }
362 }
363
364 if (sdnd)
365 {
366 vtkMRMLNode *dnd = appLogic->GetMRMLScene()->CopyNode(sdnd);
367 tmhnd->SetAndObserveDisplayNodeID( dnd->GetID() );
368 }
369
370 // add any children model hierarchy nodes, rinse, repeat
371 //
372 // keep a map of model hierarchy node ids so that can update the parent node references
373 std::map<std::string, std::string> parentNodeIDMapper;
374 // hopefully the parents will have been read first, but if not
375 // keep a list of model hierarchy nodes that failed to have their parent node reference remapped
376 std::vector<vtkMRMLModelHierarchyNode *> childNodesThatNeedParentsIDsRemapped;
377 for (int n=0;
378 n<miniscene->GetNumberOfNodesByClass("vtkMRMLModelHierarchyNode");
379 n++)
380 {
381 vtkMRMLModelHierarchyNode * mhnd = vtkMRMLModelHierarchyNode
382 ::SafeDownCast(miniscene->GetNthNodeByClass(n,
383 "vtkMRMLModelHierarchyNode"));
384 if (mhnd)
385 {
386 // is this model hierarchy node in our source list
387 // already? if so skip it
388 std::vector<std::string>::const_iterator ssit
389 = std::find(m_SourceNodes.begin(),
390 m_SourceNodes.end(), mhnd->GetID());
391 if (ssit == m_SourceNodes.end())
392 {
393 // not in source list, so we may need to add it,
394 // if it's a child, grandchild etc of the top level node that we're importing
395 if (strcmp(mhnd->GetTopParentNode()->GetID(), smhnd->GetID()) == 0)
396 {
397 // get the model and display node BEFORE we add nodes
398 // to the target scene
399 vtkMRMLModelNode *smnd1 = mhnd->GetModelNode();
400 vtkMRMLDisplayNode *sdnd1 = mhnd->GetDisplayNode();
401
402 vtkMRMLNode *tchild = appLogic->GetMRMLScene()->CopyNode(mhnd);
403 // keep track of any node id change in case other nodes use this as a parent
404 parentNodeIDMapper[std::string(mhnd->GetID())] = std::string(tchild->GetID());
407 // check for a parent node id in the mapper (as long as it doesn't already
408 // point to the source node), default to the top level one though
409 std::string parentNodeID = std::string(tmhnd->GetID());
410 if (tcmhd->GetParentNodeID() != nullptr &&
411 strcmp(tcmhd->GetParentNodeID(),smhnd->GetID()) != 0)
412 {
413 std::map<std::string,std::string>::iterator pIt = parentNodeIDMapper.find(std::string(tcmhd->GetParentNodeID()));
414 if (pIt != parentNodeIDMapper.end())
415 {
416 parentNodeID = pIt->second;
417 vtkDebugWithObjectMacro(appLogic, "Remapped parent node id to " << parentNodeID.c_str());
418 }
419 else
420 {
421 childNodesThatNeedParentsIDsRemapped.push_back(tcmhd);
422 }
423 }
424 tcmhd->SetParentNodeID( parentNodeID.c_str() );
425
426 if (smnd1)
427 {
428 // set it as modified
429 //smnd1->SetModifiedSinceRead(1);
430 // get display node BEFORE we add nodes to the target scene
431 vtkMRMLDisplayNode *sdnd2 = smnd1->GetDisplayNode();
432
433 vtkMRMLNode *tmodel = appLogic->GetMRMLScene()->CopyNode(smnd1);
436 tcmhd->SetModelNodeID( mnd->GetID() );
437
438 if (sdnd2)
439 {
440 vtkMRMLNode *tdnd = appLogic->GetMRMLScene()->CopyNode(sdnd2);
441 mnd->SetAndObserveDisplayNodeID( tdnd->GetID() );
442 }
443 }
444
445 if (sdnd1)
446 {
447 vtkMRMLNode *tdnd = appLogic->GetMRMLScene()->CopyNode(sdnd1);
448 tcmhd->SetAndObserveDisplayNodeID( tdnd->GetID() );
449 }
450 }
451 }
452 }
453 }
454 if (childNodesThatNeedParentsIDsRemapped.size() > 0)
455 {
456 // iterate through all the imported hierarchies that failed and double check their parent node ids
457 for (unsigned int i = 0; i < childNodesThatNeedParentsIDsRemapped.size(); i++)
458 {
459 std::map<std::string,std::string>::iterator pIt = parentNodeIDMapper.find(childNodesThatNeedParentsIDsRemapped[i]->GetParentNodeID());
460 if (pIt != parentNodeIDMapper.end())
461 {
462 vtkDebugWithObjectMacro(appLogic, "Remapping child node " << childNodesThatNeedParentsIDsRemapped[i]->GetName() << \
463 " parent node id from " << childNodesThatNeedParentsIDsRemapped[i]->GetParentNodeID() << " to " << pIt->second.c_str());
464 childNodesThatNeedParentsIDsRemapped[i]->SetParentNodeID(pIt->second.c_str());
465 }
466 }
467 }
468 }
469 }
470 else if (!source)
471 {
472 std::stringstream information;
473 information << "Node " << (*sit) << " not found in scene file "
474 << m_Filename << std::endl;
475 vtkGenericWarningMacro( << information.str().c_str() );
476 }
477 else if (!target)
478 {
479 std::stringstream information;
480 information << "Node " << (*tit) << " not found in current scene."
481 << std::endl;
482 vtkGenericWarningMacro( << information.str().c_str() );
483 }
484
485 ++sit;
486 ++tit;
487 }
488
490
491 // Delete the file if requested
492 if (m_DeleteFile)
493 {
494 int removed;
495 removed = static_cast<bool>(itksys::SystemTools::RemoveFile( m_Filename.c_str() ));
496 if (!removed)
497 {
498 std::stringstream information;
499 information << "Unable to delete temporary file "
500 << m_Filename << std::endl;
501 vtkGenericWarningMacro( << information.str().c_str() );
502 }
503 }
504 }
505
506protected:
507 std::vector<std::string> m_TargetNodes;
508 std::vector<std::string> m_SourceNodes;
509 std::string m_Filename;
512};
513
514//----------------------------------------------------------------------------
516{
517public:
518 ReadDataRequestUpdateParentTransform(const std::string& updatedNode,
519 const std::string& parentTransformNode, int uid = 0)
520 : DataRequest(uid)
521 {
522 m_UpdatedNode = updatedNode;
523 m_ParentTransformNode = parentTransformNode;
524 }
525
526 void Execute(vtkSlicerApplicationLogic* appLogic) override
527 {
528 vtkMRMLScene* scene = appLogic->GetMRMLScene();
530 scene->GetNodeByID(m_UpdatedNode));
531 if (node)
532 {
534 }
535 }
536
537protected:
538 std::string m_UpdatedNode;
540};
541
542//----------------------------------------------------------------------------
544{
545public:
546 ReadDataRequestUpdateSubjectHierarchyLocation(const std::string& updatedNode,
547 const std::string& siblingNode, int uid = 0)
548 : DataRequest(uid)
549 {
550 m_UpdatedNode = updatedNode;
551 m_SubjectHierarchySiblingNode = siblingNode;
552 }
553
554 void Execute(vtkSlicerApplicationLogic* appLogic) override
555 {
556 vtkMRMLScene* scene = appLogic->GetMRMLScene();
557
559 vtkMRMLNode *updatedNode = scene->GetNodeByID(m_UpdatedNode);
561 vtkIdType siblingNodeShItemID = shnd->GetItemByDataNode(siblingNode);
562 vtkIdType updatedNodeShItemID = shnd->GetItemByDataNode(updatedNode);
563
564 if (updatedNodeShItemID && siblingNodeShItemID)
565 {
566 vtkIdType parentItemID = shnd->GetItemParent(siblingNodeShItemID);
567 shnd->SetItemParent(updatedNodeShItemID, parentItemID);
568 shnd->SetItemLevel(updatedNodeShItemID, shnd->GetItemLevel(siblingNodeShItemID));
569 }
570 }
571
572protected:
573 std::string m_UpdatedNode;
575};
576
577//----------------------------------------------------------------------------
579{
580public:
581 ReadDataRequestAddNodeReference(const std::string& referencingNode,
582 const std::string& referencedNode, const std::string& role, int uid = 0)
583 : DataRequest(uid)
584 {
585 m_ReferencingNode = referencingNode;
586 m_ReferencedNode = referencedNode;
587 m_Role = role;
588 }
589
590 void Execute(vtkSlicerApplicationLogic* appLogic) override
591 {
592 vtkMRMLScene* scene = appLogic->GetMRMLScene();
593
594 vtkMRMLNode *referencingNode = scene->GetNodeByID(m_ReferencingNode);
595 vtkMRMLNode *referencedNode = scene->GetNodeByID(m_ReferencedNode);
596 if (referencingNode && referencedNode)
597 {
598 referencingNode->AddNodeReferenceID(m_Role.c_str(), m_ReferencedNode.c_str());
599 }
600 }
601
602protected:
603 std::string m_ReferencingNode;
604 std::string m_ReferencedNode;
605 std::string m_Role;
606};
607
608//----------------------------------------------------------------------------
610{
611public:
613 const std::string& vtkNotUsed(node),
614 const std::string& vtkNotUsed(filename),
615 int uid = 0)
616 : DataRequest(uid)
617 {
618 }
619protected:
620 std::string m_SourceNode;
621 std::string m_Filename;
622};
623
624//----------------------------------------------------------------------------
626{
627public:
628 WriteDataRequestScene(const std::vector<std::string>& targetNodes,
629 const std::vector<std::string>& sourceNodes,
630 const std::string& filename,
631 int uid = 0)
632 : DataRequest(uid)
633 {
634 m_TargetNodes = targetNodes;
635 m_SourceNodes = sourceNodes;
636 m_Filename = filename;
637 }
638
639 void Execute(vtkSlicerApplicationLogic* appLogic) override
640 {
641 if (m_SourceNodes.size() != m_TargetNodes.size())
642 {
643 // Can't do ID remapping if the two node lists are different
644 // sizes. Just commit the scene. (This is where we would put to
645 // the code to load into a node hierarchy (with a corresponding
646 // change in the conditional above)).
647 appLogic->GetMRMLScene()->SetURL( m_Filename.c_str() );
648 appLogic->GetMRMLScene()->Commit();
649 return;
650 }
651 }
652
653protected:
654 std::vector<std::string> m_TargetNodes;
655 std::vector<std::string> m_SourceNodes;
656 std::string m_Filename;
657};
658
659
660#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)