Documentation/Nightly/Developers/Slice Orientation Presets

From Slicer Wiki
Jump to: navigation, search
Home < Documentation < Nightly < Developers < Slice Orientation Presets

Overview

Slicer provides an API to manage slice orientation presets.

By default, three slice orientation presets representing the anatomical coordinate system are available in Slicer: Axial, Coronal and Sagittal.


FAQ

Where are slice orientation presets stored ?

Every vtkMRMLSliceNode contains an ordered list of (orientationPresetName, orientationMatrix) tuples.

The list is automatically initialized with the list of default presets each time a node is created using vtkMRMLScene::CreateNodeByClass(const char* className).


Where are default presets defined ?

Each time vtkMRMLApplicationLogic::SetMRMLScene is invoked, method vtkMRMLSliceNode::AddDefaultSliceOrientationPresets(vtkMRMLScene *scene) is called.

Then, method vtkMRMLSliceNode::AddDefaultSliceOrientationPresets(vtkMRMLScene *scene) ends up adding a default vtkMRMLSliceNode that will be used a template each time vtkMRMLScene::CreateNodeByClass(const char* className).

How to ensure slice orientation presets are defined in unit tests ?

When writing tests that depend on MRMLLogic, instantiating vtkMRMLApplicationLogic is sufficient:

vtkNew<vtkMRMLScene> scene;
vtkNew<vtkMRMLApplicationLogic> appLogic;
appLogic->SetMRMLScene(scene.GetPointer());

When writing test within that only depend on MRMLCore, the static method vtkMRMLSliceNode::AddDefaultSliceOrientationPresets(vtkMRMLScene *scene) is available:

vtkNew<vtkMRMLScene> scene;
vtkMRMLSliceNode::AddDefaultSliceOrientationPresets(scene.GetPointer());

How to instantiate a new vtkMRMLSliceNode ?

vtkMRMLSliceNode* sliceNode = scene->CreateNodeByClass("vtkMRMLSliceNode");