11 #ifndef __vtkSlicerApplicationLogicRequests_h 12 #define __vtkSlicerApplicationLogicRequests_h 45 int displayData,
int deleteFile,
int uid = 0)
60 vtkDebugWithObjectMacro(appLogic,
"ProcessReadNodeData: read data request node id = " << nd->
GetID());
62 vtkSmartPointer<vtkMRMLStorageNode> storageNode;
63 #ifdef Slicer_BUILD_CLI_SUPPORT 73 for (
int n = 0;
n < numStorageNodes;
n++)
78 if (useURI && testStorageNode->
GetURI() != NULL)
83 vtkDebugWithObjectMacro(appLogic,
"ProcessReadNodeData: found a storage node with the right URI: " << testStorageNode->
GetURI());
84 storageNode = testStorageNode;
92 vtkDebugWithObjectMacro(appLogic,
"ProcessReadNodeData: found a storage node with the right filename: " << testStorageNode->
GetFileName());
93 storageNode = testStorageNode;
100 bool createdNewStorageNode =
false;
101 if (storageNode.GetPointer() == NULL)
104 if (itksys::SystemTools::FileExists(
m_Filename.c_str()))
109 createdNewStorageNode = (storageNode != NULL);
114 if (storageNode.GetPointer() != NULL)
118 vtkDebugWithObjectMacro(appLogic,
"ProcessReadNodeData: about to call read data, " \
119 "storage node's read state is " << storageNode->GetReadStateAsString());
123 vtkDebugWithObjectMacro(appLogic,
"ProcessReadNodeData: calling ReadData on the storage node " \
124 << storageNode->GetID() <<
", uri = " << storageNode->GetURI());
125 storageNode->ReadData(nd,
true);
126 if (createdNewStorageNode)
128 storageNode->SetURI(NULL);
134 vtkDebugWithObjectMacro(appLogic,
"ProcessReadNodeData: calling ReadData on the storage node " \
135 << storageNode->GetID() <<
", filename = " << storageNode->GetFileName());
136 storageNode->ReadData(nd,
true);
137 if (createdNewStorageNode)
139 storageNode->SetFileName(NULL);
143 catch (itk::ExceptionObject& exc)
145 vtkErrorWithObjectMacro(appLogic,
"Exception while reading " <<
m_Filename <<
", " << exc);
149 vtkErrorWithObjectMacro(appLogic,
"Unknown exception while reading " <<
m_Filename);
153 #ifdef Slicer_BUILD_CLI_SUPPORT 167 if (
m_Filename.find(
"slicer:") != std::string::npos)
173 removed = itksys::SystemTools::RemoveFile(
m_Filename.c_str());
177 vtkGenericWarningMacro(
"Unable to delete temporary file " <<
m_Filename);
242 const std::vector<std::string>& sourceNodes,
243 const std::string& filename,
244 int displayData,
int deleteFile,
270 removed = itksys::SystemTools::RemoveFile(
m_Filename.c_str());
273 std::stringstream information;
274 information <<
"Unable to delete temporary file " 276 vtkGenericWarningMacro( << information.str().c_str() );
283 vtkNew<vtkMRMLScene> miniscene;
288 std::vector<std::string>::const_iterator tit;
289 std::vector<std::string>::const_iterator sit;
298 vtkMRMLNode *source = miniscene->GetNodeByID((*sit).c_str());
301 if (source && target)
307 if ( storableTarget )
310 target->
Copy(source);
315 target->
Copy(source);
363 std::map<std::string, std::string> parentNodeIDMapper;
366 std::vector<vtkMRMLModelHierarchyNode *> childNodesThatNeedParentsIDsRemapped;
368 n<miniscene->GetNumberOfNodesByClass(
"vtkMRMLModelHierarchyNode");
373 "vtkMRMLModelHierarchyNode"));
378 std::vector<std::string>::const_iterator ssit
394 parentNodeIDMapper[std::string(mhnd->
GetID())] = std::string(tchild->
GetID());
399 std::string parentNodeID = std::string(tmhnd->
GetID());
400 if (tcmhd->GetParentNodeID() != NULL &&
401 strcmp(tcmhd->GetParentNodeID(),smhnd->
GetID()) != 0)
403 std::map<std::string,std::string>::iterator pIt = parentNodeIDMapper.find(std::string(tcmhd->GetParentNodeID()));
404 if (pIt != parentNodeIDMapper.end())
406 parentNodeID = pIt->second;
407 vtkDebugWithObjectMacro(appLogic,
"Remapped parent node id to " << parentNodeID.c_str());
411 childNodesThatNeedParentsIDsRemapped.push_back(tcmhd);
414 tcmhd->SetParentNodeID( parentNodeID.c_str() );
426 tcmhd->SetModelNodeID( mnd->
GetID() );
438 tcmhd->SetAndObserveDisplayNodeID( tdnd->
GetID() );
444 if (childNodesThatNeedParentsIDsRemapped.size() > 0)
447 for (
unsigned int i = 0; i < childNodesThatNeedParentsIDsRemapped.size(); i++)
449 std::map<std::string,std::string>::iterator pIt = parentNodeIDMapper.find(childNodesThatNeedParentsIDsRemapped[i]->GetParentNodeID());
450 if (pIt != parentNodeIDMapper.end())
452 vtkDebugWithObjectMacro(appLogic,
"Remapping child node " << childNodesThatNeedParentsIDsRemapped[i]->GetName() << \
453 " parent node id from " << childNodesThatNeedParentsIDsRemapped[i]->GetParentNodeID() <<
" to " << pIt->second.c_str());
454 childNodesThatNeedParentsIDsRemapped[i]->SetParentNodeID(pIt->second.c_str());
462 std::stringstream information;
463 information <<
"Node " << (*sit) <<
" not found in scene file " 465 vtkGenericWarningMacro( << information.str().c_str() );
469 std::stringstream information;
470 information <<
"Node " << (*tit) <<
" not found in current scene." 472 vtkGenericWarningMacro( << information.str().c_str() );
485 removed = itksys::SystemTools::RemoveFile(
m_Filename.c_str() );
488 std::stringstream information;
489 information <<
"Unable to delete temporary file " 491 vtkGenericWarningMacro( << information.str().c_str() );
509 const std::string& parentTransformNode,
int uid = 0)
537 const std::string& siblingNode,
int uid = 0)
554 if (updatedNodeShItemID && siblingNodeShItemID)
556 vtkIdType parentItemID = shnd->
GetItemParent(siblingNodeShItemID);
572 const std::string& vtkNotUsed(node),
573 const std::string& vtkNotUsed(filename),
588 const std::vector<std::string>& sourceNodes,
589 const std::string& filename,
619 #endif // __vtkSlicerApplicationLogicRequests_h virtual bool AddDefaultStorageNode(const char *filename=NULL)
void SetActiveVolumeID(const char *id)
void EndState(unsigned long state)
Unflag the scene as being in a state mode.
ReadDataRequestUpdateSubjectHierarchyLocation(const std::string &updatedNode, const std::string &siblingNode, int uid=0)
void SetAndObserveDisplayNodeID(const char *displayNodeID)
vtkMRMLStorageNode * GetNthStorageNode(int n)
Get associated display MRML node
vtkMRMLHierarchyNode * GetTopParentNode()
Get the top parent node in the hierarchy
MRML node to represent a 3D surface model.
void SetItemLevel(vtkIdType itemID, std::string level)
Convenience function to set level attribute for a subject hierarchy item.
WriteDataRequestScene(const std::vector< std::string > &targetNodes, const std::vector< std::string > &sourceNodes, const std::string &filename, int uid=0)
vtkMRMLSelectionNode * GetSelectionNode() const
Get default Selection node.
void Execute(vtkSlicerApplicationLogic *appLogic)
vtkMRMLScene * GetMRMLScene() const
Return a reference to the current MRML scene.
vtkMRMLNode * CopyNode(vtkMRMLNode *n)
Add a copy of a node to the scene.
std::vector< std::string > m_SourceNodes
WriteDataRequestFile(const std::string &vtkNotUsed(node), const std::string &vtkNotUsed(filename), int uid=0)
void SetAndObserveDisplayNodeID(const char *DisplayNodeID)
MRML node to represent a complete subject hierarchy tree.
static vtkMRMLModelHierarchyNode * SafeDownCast(vtkObject *o)
void PropagateVolumeSelection(int fit=1)
std::string m_SubjectHierarchySiblingNode
static vtkMRMLCommandLineModuleNode * SafeDownCast(vtkObject *o)
void SetActiveLabelVolumeID(const char *id)
void SetItemParent(vtkIdType itemID, vtkIdType parentItemID)
Set the parent of a subject hierarchy item.
const char * GetStorageNodeID()
vtkMRMLDisplayNode * GetDisplayNode()
Get associated display MRML node
virtual void Copy(vtkMRMLNode *node)
Copy parameters (not including ID and Scene) from another node of the same type.
MRML node to represent a 3D surface model.
void SetAndObserveStorageNodeID(const char *storageNodeID)
String ID of the storage MRML node
int Commit(const char *url=NULL)
A set of MRML Nodes that supports serialization and undo/redo.
virtual char * GetID()
ID use by other nodes to reference this node in XML.
std::vector< std::string > m_SourceNodes
virtual char * GetFileName()
static vtkMRMLLabelMapVolumeNode * SafeDownCast(vtkObject *o)
static vtkMRMLSubjectHierarchyNode * GetSubjectHierarchyNode(vtkMRMLScene *scene)
virtual void CreateDefaultDisplayNodes()
void StartState(unsigned long state, int anticipatedMaxProgress=0)
Flag the scene as being in a state mode.
void PropagateTableSelection()
Propagate selected table in the SelectionNode to table view nodes.
virtual vtkCacheManager * GetCacheManager()
std::vector< std::string > m_TargetNodes
vtkMRMLNode * GetNodeByID(const char *name)
Get node given a unique ID.
vtkMRMLDisplayNode * GetDisplayNode()
static vtkMRMLStorableNode * SafeDownCast(vtkObject *o)
void Execute(vtkSlicerApplicationLogic *appLogic)
std::string GetItemLevel(vtkIdType itemID)
Convenience function to get level attribute for a subject hierarchy item.
A superclass for other storage nodes.
void SetModelNodeID(const char *id)
String ID of the model MRML node
MRML node to represent a hierarchyu of models.
static vtkMRMLTableNode * SafeDownCast(vtkObject *o)
vtkMRMLModelNode * GetModelNode()
Get associated model MRML node
void SetURL(const char *url)
Set URL (file name) of the scene.
virtual int IsRemoteReference(const char *uri)
int GetNumberOfStorageNodes()
vtkIdType GetItemByDataNode(vtkMRMLNode *dataNode)
vtkMRMLStorageNode * GetStorageNode()
void Execute(vtkSlicerApplicationLogic *appLogic)
static vtkMRMLScalarVolumeNode * SafeDownCast(vtkObject *o)
bool ReadParameterFile(const std::string &filename)
static vtkMRMLDisplayableNode * SafeDownCast(vtkObject *o)
virtual void SetURI(const char *)
Location of the remote copy of this file.
Abstract class that contains graphical display properties for displayable nodes.
virtual void Modified() VTK_OVERRIDE
Customized version of Modified() allowing to compress vtkCommand::ModifiedEvent.
void SetActiveTableID(const char *id)
Abstract Superclass for all specific types of MRML nodes.
MRML node for representing the parameters allowing to run a command line interface module (CLI)...
ReadDataRequestScene(const std::vector< std::string > &targetNodes, const std::vector< std::string > &sourceNodes, const std::string &filename, int displayData, int deleteFile, int uid=0)
int Import()
Add the scene into the existing scene (no clear) from URL file or from.
vtkIdType GetItemParent(vtkIdType itemID)
std::string m_UpdatedNode
std::vector< std::string > m_TargetNodes
static vtkMRMLModelNode * SafeDownCast(vtkObject *o)
void Execute(vtkSlicerApplicationLogic *appLogic)
ReadDataRequestFile(const std::string &node, const std::string &filename, int displayData, int deleteFile, int uid=0)
virtual void Execute(vtkSlicerApplicationLogic *)