Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
vtkSlicerUnitsLogic.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Copyright (c) Kitware Inc.
6
7 See COPYRIGHT.txt
8 or http://www.slicer.org/copyright/copyright.txt for details.
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 This file was originally developed by Johan Andruejol, Kitware Inc.
17 and was partially funded by NIH grant 3P41RR013218-12S1
18
19==============================================================================*/
20
21
22#ifndef __vtkSlicerUnitsLogic_h
23#define __vtkSlicerUnitsLogic_h
24
25// Slicer includes
27
28// MRML includes
29class vtkMRMLUnitNode;
30
31#include "vtkSlicerUnitsModuleLogicExport.h"
32
33// STD includes
34#include <map>
35
42class VTK_SLICER_UNITS_MODULE_LOGIC_EXPORT vtkSlicerUnitsLogic
44{
45public:
49 void PrintSelf(ostream& os, vtkIndent indent) override;
50
53 vtkMRMLUnitNode* AddUnitNode(const char* name,
54 const char* quantity = "length",
55 const char* prefix = "",
56 const char* suffix = "",
57 int precision = 3,
58 double min = -10000.,
59 double max = 10000.);
60
62 void SetDefaultUnit(const char* quantity, const char* id);
63
66
101 static double GetSIPrefixCoefficient(const char* prefix);
102
129 static double GetDisplayCoefficient(const char* displayPrefix, const char* valuePrefix = "", double power=1);
130
131protected:
134
136 void ObserveMRMLScene() override;
140 void UpdateFromMRMLScene() override;
143 void OnMRMLNodeModified(vtkMRMLNode* modifiedNode) override;
144
146 virtual void AddDefaultsUnits();
147
149 virtual void AddBuiltInUnits(vtkMRMLScene* scene);
150
152 void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
153
157 void RegisterNodes() override;
159
189 const char* name,
190 const char* quantity = "length",
191 const char* prefix = "",
192 const char* suffix = "",
193 int precision = 3,
194 double min = -10000.,
195 double max = 10000.,
196 double displayCoeff = 1.0,
197 double displayOffset = 0.0);
198
202
207
208 // Variables
210private:
212 void operator=(const vtkSlicerUnitsLogic&) = delete;
213
217 std::map<std::string, std::string> CachedDefaultUnits;
221 bool RestoringDefaultUnits;
222};
223
224#endif
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
Node that holds the information about a unit.
static double GetSIPrefixCoefficient(const char *prefix)
Get the coefficient associated with the given SI prefix name.
void OnMRMLSceneStartBatchProcess() override
static double GetDisplayCoefficient(const char *displayPrefix, const char *valuePrefix="", double power=1)
Get the coefficient to transform a value and display it.
static vtkSlicerUnitsLogic * New()
virtual void AddBuiltInUnits(vtkMRMLScene *scene)
Add the default units in the application scene.
void SetMRMLSceneInternal(vtkMRMLScene *newScene) override
Overloaded to add the defaults units in the application scene.
vtkMRMLScene * GetUnitsScene() const
Get the scene with preset unit nodes in it.
vtkMRMLUnitNode * 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)
Add a unit node to the given scene.
void UpdateFromMRMLScene() override
void SetDefaultUnit(const char *quantity, const char *id)
Change the default unit for the corresponding quantity.
virtual void RegisterNodesInternal(vtkMRMLScene *scene)
void OnMRMLNodeModified(vtkMRMLNode *modifiedNode) override
vtkMRMLUnitNode * AddUnitNode(const char *name, const char *quantity="length", const char *prefix="", const char *suffix="", int precision=3, double min=-10000., double max=10000.)
virtual void AddDefaultsUnits()
Add the built in units in the units logic scene.
void RegisterNodes() override
void PrintSelf(ostream &os, vtkIndent indent) override
void ObserveMRMLScene() override
Reimplemented to initialize the scene with unit nodes.
~vtkSlicerUnitsLogic() override
vtkSlicerUnitsLogic Self