Difference between revisions of "Documentation/Nightly/Developers/Slice Orientation Presets"

From Slicer Wiki
Jump to: navigation, search
Line 7: Line 7:
  
  
== Under the hood ==
+
== FAQ ==
 +
 
 +
=== Where are slice orientation presets stored ? ===
 +
 
 +
Every <code>vtkMRMLSliceNode</code> contains an ordered list of <code>(orientationPresetName, orientationMatrix)</code> tuples.
 +
 
 +
The list is automatically initialized with the list of default presets each time a node is created using <code>vtkMRMLScene::CreateNodeByClass(const char* className)</code>.
 +
 
  
 
=== Where are default presets defined ? ===
 
=== Where are default presets defined ? ===
Line 30: Line 37:
 
vtkNew<vtkMRMLScene> scene;
 
vtkNew<vtkMRMLScene> scene;
 
vtkMRMLSliceNode::AddDefaultSliceOrientationPresets(scene.GetPointer());
 
vtkMRMLSliceNode::AddDefaultSliceOrientationPresets(scene.GetPointer());
 +
</pre>
 +
 +
=== How to instantiate a new vtkMRMLSliceNode ? ===
 +
 +
<pre>
 +
vtkMRMLSliceNode* sliceNode = scene->CreateNodeByClass("vtkMRMLSliceNode");
 
</pre>
 
</pre>

Revision as of 16:40, 8 June 2016

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");