Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
vtkSlicerUnitsLogic Class Reference

Slicer logic for unit manipulation. More...

#include <Modules/Loadable/Units/Logic/vtkSlicerUnitsLogic.h>

Inheritance diagram for vtkSlicerUnitsLogic:
Inheritance graph
[legend]
Collaboration diagram for vtkSlicerUnitsLogic:
Collaboration graph
[legend]

Public Types

typedef vtkSlicerUnitsLogic Self
 
typedef vtkMRMLAbstractLogic Superclass
 
- Public Types inherited from vtkMRMLAbstractLogic
typedef vtkObject Superclass
 
typedef void(vtkMRMLAbstractLogic::* TaskFunctionPointer) (void *clientdata)
 

Public Member Functions

vtkMRMLUnitNodeAddUnitNode (const char *name, const char *quantity="length", const char *prefix="", const char *suffix="", int precision=3, double min=-10000., double max=10000.)
 
virtual const char * GetClassName ()
 
vtkMRMLSceneGetUnitsScene () const
 Get the scene with preset unit nodes in it. More...
 
virtual int IsA (const char *type)
 
void PrintSelf (ostream &os, vtkIndent indent) override
 
void SetDefaultUnit (const char *quantity, const char *id)
 Change the default unit for the corresponding quantity. More...
 
- Public Member Functions inherited from vtkMRMLAbstractLogic
virtual vtkMRMLApplicationLogicGetMRMLApplicationLogic () const
 Get access to overall application state. More...
 
vtkMRMLSceneGetMRMLScene () const
 Return a reference to the current MRML scene. More...
 
void PrintSelf (ostream &os, vtkIndent indent) override
 
virtual void SetMRMLApplicationLogic (vtkMRMLApplicationLogic *logic)
 
void SetMRMLScene (vtkMRMLScene *newScene)
 Set and observe the MRMLScene. More...
 

Static Public Member Functions

static double GetDisplayCoefficient (const char *displayPrefix, const char *valuePrefix="")
 Get the coefficient to transform a value and display it. More...
 
static double GetSIPrefixCoefficient (const char *prefix)
 Get the coefficient associated with the given SI prefix name. More...
 
static int IsTypeOf (const char *type)
 
static vtkSlicerUnitsLogicNew ()
 
static vtkSlicerUnitsLogicSafeDownCast (vtkObject *o)
 
- Static Public Member Functions inherited from vtkMRMLAbstractLogic
static int IsTypeOf (const char *type)
 
static vtkMRMLAbstractLogicNew ()
 
static vtkMRMLAbstractLogicSafeDownCast (vtkObject *o)
 

Protected Member Functions

virtual void AddBuiltInUnits (vtkMRMLScene *scene)
 Add the default units in the application scene. More...
 
virtual void AddDefaultsUnits ()
 Add the built in units in the units logic scene. More...
 
vtkMRMLUnitNodeAddUnitNodeToScene (vtkMRMLScene *scene, const char *name, const char *quantity="length", const char *prefix="", const char *suffix="", int precision=3, double min=-10000., double max=10000., double displayCoeff=1.0, double displayOffset=0.0)
 Add a unit node to the given scene. More...
 
void ObserveMRMLScene () override
 Reimplemented to initialize the scene with unit nodes. More...
 
void OnMRMLNodeModified (vtkMRMLNode *modifiedNode) override
 
void OnMRMLSceneStartBatchProcess () override
 
void RegisterNodes () override
 
virtual void RegisterNodesInternal (vtkMRMLScene *scene)
 
void RestoreDefaultUnits ()
 
void SaveDefaultUnits ()
 
void SetMRMLSceneInternal (vtkMRMLScene *newScene) override
 Overloaded to add the defaults units in the application scene. More...
 
 vtkSlicerUnitsLogic ()
 
 ~vtkSlicerUnitsLogic () override
 
- Protected Member Functions inherited from vtkMRMLAbstractLogic
int EndModify (bool wasModifying)
 
virtual bool EnterMRMLLogicsCallback () const
 
virtual bool EnterMRMLNodesCallback () const
 
virtual bool EnterMRMLSceneCallback () const
 
bool GetDisableModifiedEvent () const
 
int GetInMRMLLogicsCallbackFlag () const
 
int GetInMRMLNodesCallbackFlag () const
 
int GetInMRMLSceneCallbackFlag () const
 
vtkCallbackCommand * GetMRMLLogicsCallbackCommand ()
 
vtkObserverManagerGetMRMLLogicsObserverManager () const
 
vtkCallbackCommand * GetMRMLNodesCallbackCommand ()
 
vtkObserverManagerGetMRMLNodesObserverManager () const
 
vtkCallbackCommand * GetMRMLSceneCallbackCommand ()
 
vtkObserverManagerGetMRMLSceneObserverManager () const
 
int GetPendingModifiedEventCount () const
 
int GetProcessingMRMLSceneEvent () const
 Return the event id currently processed or 0 if any. More...
 
int InvokePendingModifiedEvent ()
 
void Modified () override
 
virtual void OnMRMLSceneEndBatchProcess ()
 
virtual void OnMRMLSceneEndClose ()
 
virtual void OnMRMLSceneEndImport ()
 
virtual void OnMRMLSceneEndRestore ()
 
virtual void OnMRMLSceneNew ()
 
virtual void OnMRMLSceneNodeAdded (vtkMRMLNode *)
 
virtual void OnMRMLSceneNodeRemoved (vtkMRMLNode *)
 
virtual void OnMRMLSceneStartClose ()
 
virtual void OnMRMLSceneStartImport ()
 
virtual void OnMRMLSceneStartRestore ()
 
virtual void ProcessMRMLLogicsEvents (vtkObject *caller, unsigned long event, void *callData)
 
virtual void ProcessMRMLNodesEvents (vtkObject *caller, unsigned long event, void *callData)
 
virtual void ProcessMRMLSceneEvents (vtkObject *caller, unsigned long event, void *callData)
 
void SetAndObserveMRMLSceneEventsInternal (vtkMRMLScene *newScene, vtkIntArray *events, vtkFloatArray *priorities=nullptr)
 
void SetDisableModifiedEvent (bool onOff)
 
void SetInMRMLLogicsCallbackFlag (int flag)
 
void SetInMRMLNodesCallbackFlag (int flag)
 
void SetInMRMLSceneCallbackFlag (int flag)
 
void SetProcessingMRMLSceneEvent (int event)
 
bool StartModify ()
 
virtual void UnobserveMRMLScene ()
 
virtual void UpdateFromMRMLScene ()
 
 vtkMRMLAbstractLogic ()
 
 ~vtkMRMLAbstractLogic () override
 

Protected Attributes

vtkMRMLSceneUnitsScene
 

Additional Inherited Members

- Static Protected Member Functions inherited from vtkMRMLAbstractLogic
static void MRMLLogicsCallback (vtkObject *caller, unsigned long eid, void *clientData, void *callData)
 MRMLLogicCallback is a static function to relay modified events from the logics. More...
 
static void MRMLNodesCallback (vtkObject *caller, unsigned long eid, void *clientData, void *callData)
 MRMLNodesCallback is a static function to relay modified events from the nodes. More...
 
static void MRMLSceneCallback (vtkObject *caller, unsigned long eid, void *clientData, void *callData)
 

Detailed Description

Slicer logic for unit manipulation.

This class manages the logic associated with the units. It allows to create a new unit easily. The logic is in charge of calling a modify on the the selection node every time a current unit is modified so the listeners can update themselves.

Definition at line 42 of file vtkSlicerUnitsLogic.h.

Member Typedef Documentation

◆ Self

Definition at line 47 of file vtkSlicerUnitsLogic.h.

◆ Superclass

Definition at line 48 of file vtkSlicerUnitsLogic.h.

Constructor & Destructor Documentation

◆ vtkSlicerUnitsLogic()

vtkSlicerUnitsLogic::vtkSlicerUnitsLogic ( )
protected

◆ ~vtkSlicerUnitsLogic()

vtkSlicerUnitsLogic::~vtkSlicerUnitsLogic ( )
overrideprotected

Member Function Documentation

◆ AddBuiltInUnits()

virtual void vtkSlicerUnitsLogic::AddBuiltInUnits ( vtkMRMLScene scene)
protectedvirtual

Add the default units in the application scene.

◆ AddDefaultsUnits()

virtual void vtkSlicerUnitsLogic::AddDefaultsUnits ( )
protectedvirtual

Add the built in units in the units logic scene.

◆ AddUnitNode()

vtkMRMLUnitNode* vtkSlicerUnitsLogic::AddUnitNode ( const char *  name,
const char *  quantity = "length",
const char *  prefix = "",
const char *  suffix = "",
int  precision = 3,
double  min = -10000.,
double  max = 10000. 
)

Add unit node to the scene. Returns nullptr if the logic has no scene.

◆ AddUnitNodeToScene()

vtkMRMLUnitNode* vtkSlicerUnitsLogic::AddUnitNodeToScene ( vtkMRMLScene scene,
const char *  name,
const char *  quantity = "length",
const char *  prefix = "",
const char *  suffix = "",
int  precision = 3,
double  min = -10000.,
double  max = 10000.,
double  displayCoeff = 1.0,
double  displayOffset = 0.0 
)
protected

Add a unit node to the given scene.

A unit node is defined by the following properties:

  • Name: The property describes the unit itself. For example, the name of a length unit can be Millimeter, Meter or Centimeter. Setting the node's name also sets the node's singleton tag.
  • Quantity: This property describes what types of unit. For example the quantity of second and day is time. This property is a Units node attribute so it can be easily observed by the GUI.
  • Prefix and Suffix: Abbreviation/text displayed respectively before and after the unit.
  • Precision: This property describes the number of digit used after the comma. For example a precision of 2 gives 12.00 and -13.61.
  • Min and Max: Range of value allowed for the unit. For example, the minimum for the Kelvin value would be 0.
  • DisplayCoeff: Coefficient multiplied to the value to display it with the appropriate unit. The display coefficient corresponds to the inverse of the SI prefix coefficient associated with the unit.
  • DisplayOffset: Offset added to the value being displayed.
See also
GetDisplayCoefficient()

◆ GetClassName()

virtual const char* vtkSlicerUnitsLogic::GetClassName ( )
virtual

Reimplemented from vtkMRMLAbstractLogic.

◆ GetDisplayCoefficient()

static double vtkSlicerUnitsLogic::GetDisplayCoefficient ( const char *  displayPrefix,
const char *  valuePrefix = "" 
)
static

Get the coefficient to transform a value and display it.

This function is used to conveniently compute the display coefficient expected by AddUnitNodeToScene().

The display coefficient is used to transform quantity values to a given unit.

By default, value for a given quantity are assumed to have no prefix. For example, this means that length values are in meter, time values are in second. In that case, the coefficient to transform quantity values to a given unit can be computed using GetDisplayCoefficient() specifying only the displayPrefix parameter.

If the quantity values are associated with a specific unit, the valuePrefix parameter should be provided. For example, in Slicer, since length values are assumed to be in millimeter the display coefficient should be computed specifying milli as valuePrefix.

prefix and basePrefix can be any value documented in GetSIPrefixCoefficient().

See also
GetSIPrefixCoefficient()
AddUnitNodeToScene()
AddDefaultsUnits(), AddBuiltInUnits()

◆ GetSIPrefixCoefficient()

static double vtkSlicerUnitsLogic::GetSIPrefixCoefficient ( const char *  prefix)
static

Get the coefficient associated with the given SI prefix name.

Returns the coefficient for all prefix names defined in the International System of Units (SI) reported in the table below.

Otherwise, returns 1 if an empty name or an unknown prefix name is given.

Prefix Coefficient
yotta 10^24 (1000000000000000000000000)
zetta 10^21 (1000000000000000000000)
exa 10^18 (1000000000000000000)
peta 10^15 (1000000000000000)
tera 10^12 (1000000000000)
giga 10^9 (1000000000)
mega 10^6 (1000000)
kilo 10^3 (1000)
hecto 10^2 (100)
deca 10^1 (10)
10^0 (1)
deci 10^-1 (0.1)
centi 10^-2 (0.01)
milli 10^-3 (0.001)
micro 10^-6 (0.000001)
nano 10^-9 (0.000000001)
pico 10^-12 (0.000000000001)
femto 10^-15 (0.000000000000001)
atto 10^-18 (0.000000000000000001)
zepto 10^-21 (0.000000000000000000001)
yocto 10^-24 (0.000000000000000000000001)

Source https://en.wikipedia.org/wiki/Metric_prefix#List_of_SI_prefixes

See also
AddUnitNodeToScene()

◆ GetUnitsScene()

vtkMRMLScene* vtkSlicerUnitsLogic::GetUnitsScene ( ) const

Get the scene with preset unit nodes in it.

◆ IsA()

virtual int vtkSlicerUnitsLogic::IsA ( const char *  type)
virtual

Reimplemented from vtkMRMLAbstractLogic.

◆ IsTypeOf()

static int vtkSlicerUnitsLogic::IsTypeOf ( const char *  type)
static

◆ New()

static vtkSlicerUnitsLogic* vtkSlicerUnitsLogic::New ( )
static

◆ ObserveMRMLScene()

void vtkSlicerUnitsLogic::ObserveMRMLScene ( )
overrideprotectedvirtual

Reimplemented to initialize the scene with unit nodes.

Reimplemented from vtkMRMLAbstractLogic.

◆ OnMRMLNodeModified()

void vtkSlicerUnitsLogic::OnMRMLNodeModified ( vtkMRMLNode modifiedNode)
overrideprotectedvirtual

Reimplemented to restore the selection node unit nodes.

See also
SaveDefaultUnits(), RestoreDefaultUnits()

Reimplemented from vtkMRMLAbstractLogic.

◆ OnMRMLSceneStartBatchProcess()

void vtkSlicerUnitsLogic::OnMRMLSceneStartBatchProcess ( )
overrideprotectedvirtual

Reimplemented to save the selection node unit nodes.

See also
SaveDefaultUnits(), RestoreDefaultUnits()

Reimplemented from vtkMRMLAbstractLogic.

◆ PrintSelf()

void vtkSlicerUnitsLogic::PrintSelf ( ostream &  os,
vtkIndent  indent 
)
override

◆ RegisterNodes()

void vtkSlicerUnitsLogic::RegisterNodes ( )
overrideprotectedvirtual

Register MRML Node classes to Scene. Gets called automatically when the MRMLScene is attached to this logic class.

Reimplemented from vtkMRMLAbstractLogic.

◆ RegisterNodesInternal()

virtual void vtkSlicerUnitsLogic::RegisterNodesInternal ( vtkMRMLScene scene)
protectedvirtual

◆ RestoreDefaultUnits()

void vtkSlicerUnitsLogic::RestoreDefaultUnits ( )
protected

Restore the saved default units referenced in the selection node singleton.

See also
SaveDefaultUnits()

◆ SafeDownCast()

static vtkSlicerUnitsLogic* vtkSlicerUnitsLogic::SafeDownCast ( vtkObject *  o)
static

◆ SaveDefaultUnits()

void vtkSlicerUnitsLogic::SaveDefaultUnits ( )
protected

Save the default units referenced in the selection node singleton.

See also
RestoreDefaultUnits()

◆ SetDefaultUnit()

void vtkSlicerUnitsLogic::SetDefaultUnit ( const char *  quantity,
const char *  id 
)

Change the default unit for the corresponding quantity.

◆ SetMRMLSceneInternal()

void vtkSlicerUnitsLogic::SetMRMLSceneInternal ( vtkMRMLScene newScene)
overrideprotectedvirtual

Overloaded to add the defaults units in the application scene.

Reimplemented from vtkMRMLAbstractLogic.

Member Data Documentation

◆ UnitsScene

vtkMRMLScene* vtkSlicerUnitsLogic::UnitsScene
protected

Definition at line 206 of file vtkSlicerUnitsLogic.h.


The documentation for this class was generated from the following file: