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

From Slicer Wiki
Jump to: navigation, search
(Created page with " == Overview == Slicer provides an API to manage slice orientation presets. By default, three slice orientation presets representing the Coordinate_systems#Anatomical_coor...")
 
Line 11: Line 11:
 
=== Where are default presets defined ? ===
 
=== Where are default presets defined ? ===
  
Each time <code>vtkMRMLApplicationLogic::SetMRMLScene</code> is invoked, method <code>AddDefaultSliceOrientationPresets(vtkMRMLScene *scene)</code>  is called.
+
Each time <code>vtkMRMLApplicationLogic::SetMRMLScene</code> is invoked, method <code>vtkMRMLSliceNode::AddDefaultSliceOrientationPresets(vtkMRMLScene *scene)</code>  is called.
  
Then, method <code>AddDefaultSliceOrientationPresets(vtkMRMLScene *scene)</code> ends up adding a default [{{doxygen-class-url|vtkMRMLSliceNode}} vtkMRMLSliceNode] that will be used a template each time <code>vtkMRMLScene::CreateNodeByClass(const char* className)</code>.
+
Then, method <code>vtkMRMLSliceNode::AddDefaultSliceOrientationPresets(vtkMRMLScene *scene)</code> ends up adding a default [{{doxygen-class-url|vtkMRMLSliceNode}} vtkMRMLSliceNode] that will be used a template each time <code>vtkMRMLScene::CreateNodeByClass(const char* className)</code>.
 +
 
 +
=== How to ensure slice orientation presets are defined in unit tests ? ===
 +
 
 +
When writing tests that depend on <code>MRMLLogic</code>, instantiating [{{doxygen-class-url|vtkMRMLApplicationLogic}} vtkMRMLApplicationLogic] is sufficient:
 +
 
 +
<pre>
 +
vtkNew<vtkMRMLScene> scene;
 +
vtkNew<vtkMRMLApplicationLogic> appLogic;
 +
appLogic->SetMRMLScene(scene.GetPointer());
 +
</pre>
 +
 
 +
When writing test within that only depend on <code>MRMLCore</code>, the static method <code>vtkMRMLSliceNode::AddDefaultSliceOrientationPresets(vtkMRMLScene *scene)</code> is available:
 +
 
 +
<pre>
 +
vtkNew<vtkMRMLScene> scene;
 +
vtkMRMLSliceNode::AddDefaultSliceOrientationPresets(scene.GetPointer());
 +
</pre>

Revision as of 16:33, 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.


Under the hood

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