Import 2017-06-07 23:51:09: master cfdf8cc5

Author Committer Branch Timestamp Parent
lassoan lassoan master 2016-08-31 11:29:51 master 5b850dc5
Changeset

ENH: Improved node saving and loading

This commit contains two changes, which might have been delivered as two separate commits, but they have been implemented at the same time
and modify the same files, therefore splitting them would be not easy.

  1. Storable node can decide what is the most appropriate storage node, based on the requested file name and storable node content.

Implemented by adding vtkMRMLStorableNode::AddDefaultStorageNode, which creates most appropriate storage node class and adds it to the scene
(similarly to vtkMRMLDisplayableNode::CreateDisplayNodes()). Also added vtkMRMLStorableNode::GetDefaultStorageNodeClassName(), which allows
creating the right type of storage node depending on target filename and storable node content.

Now there is no more need for the model storage node "special case" in vtkSlicerApplicationLogic::ProcessReadNodeData.

Now current scene's CreateNodeInstance method can be used for storage node creation. The scene may contain customized default storage nodes
(e.g., storage node that uses a customized file extension or compression option), which are now taken into account.
For example, changing default model node saving extension can be achieved by this:

msn=slicer.vtkMRMLModelStorageNode()
msn.SetDefaultWriteFileExtension('stl')
slicer.mrmlScene.AddDefaultNode(msn)

Default nodes can be created from information stored in the application settings, so this allows
specifying default file saving format in the application settings (this is how default view options are configured already).

Having a method for creating and adding storage node as needed also simplifies vtkSlicerFiducialsLogic::AddFiducialList,
vtkMRMLColorNode::ReadXMLAttributes, vtkMRMLSceneViewNode::ReadXMLAttributes, vtkMRMLApplicationLogic::SaveSceneToSlicerDataBundleDirectory, etc.

  1. Improved composite file extension support (.nii.gz, .seg.nrrd, ...)

Suitable file reader list in "Add data dialog" is populated using the most specific matched extension's reader.
For example, .nrrd is more specific than .; .seg.nrrd is more specific than .nrrd. This allows correct deafult
selection. This allowed removing workarounds and special cases added for composite image file extensions (such as .nii.gz)
and .
wildcard. It also allows proper default selection for segmentation nodes (.seg.nrrd).
In the future, it could be used for removing workarounds added for guessing labelmaps, annotation ROI nodes, etc
(labelmap volumes could use .label.nrrd, annotation nodes could use something.roi.csv something.fid.csv, ... instead of
using ambiguous and/or non-standard file extensions such as .acsv or .fcsv).

Made file extension matching more robust: instead of using heuristics, such as assuming .gz means a composite file extension
and collecting all possible extension from all storage nodes; now extensions are verified/matched/removed by the specific
storage node that is responsible for reading/writing the node.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@25323 3bd1e089-480b-0410-8dfb-8563597acbee

mod - Base/Logic/vtkSlicerApplicationLogic.cxx Diff File
mod - Base/Logic/vtkSlicerFiducialsLogic.cxx Diff File
mod - Base/Python/slicer/tests/test_slicer_mgh.py Diff File
mod - Base/QTCore/Testing/Cxx/qSlicerCoreIOManagerTest1.cxx Diff File
mod - Base/QTCore/qSlicerCoreIOManager.cxx Diff File
mod - Base/QTCore/qSlicerCoreIOManager.h Diff File
mod - Base/QTCore/qSlicerFileReader.cxx Diff File
mod - Base/QTCore/qSlicerFileReader.h Diff File
mod - Base/QTGUI/qSlicerNodeWriter.cxx Diff File
mod - Base/QTGUI/qSlicerSaveDataDialog.cxx Diff File
mod - Libs/MRML/Core/Testing/CMakeLists.txt Diff File
add - Libs/MRML/Core/Testing/vtkMRMLSceneDefaultNodeTest.cxx Diff File
mod - Libs/MRML/Core/vtkDataFileFormatHelper.cxx Diff File
mod - Libs/MRML/Core/vtkMRMLColorNode.cxx Diff File
mod - Libs/MRML/Core/vtkMRMLModelNode.cxx Diff File
mod - Libs/MRML/Core/vtkMRMLModelNode.h Diff File
mod - Libs/MRML/Core/vtkMRMLSceneViewNode.cxx Diff File
mod - Libs/MRML/Core/vtkMRMLStorableNode.cxx Diff File
mod - Libs/MRML/Core/vtkMRMLStorableNode.h Diff File
mod - Libs/MRML/Core/vtkMRMLStorageNode.cxx Diff File
mod - Libs/MRML/Core/vtkMRMLStorageNode.h Diff File
mod - Libs/MRML/Core/vtkMRMLTransformStorageNode.cxx Diff File
mod - Libs/MRML/Logic/vtkMRMLApplicationLogic.cxx Diff File
mod - Modules/Loadable/Data/qSlicerSceneWriter.cxx Diff File
mod - Modules/Loadable/Volumes/Logic/vtkSlicerVolumesLogic.cxx Diff File
mod - Modules/Loadable/Volumes/qSlicerVolumesIOOptionsWidget.cxx Diff File
mod - Modules/Loadable/Volumes/qSlicerVolumesReader.cxx Diff File