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