Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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#ifndef __vtkSlicerUnitsLogic_h
22#define __vtkSlicerUnitsLogic_h
23
24// Slicer includes
26
27// MRML includes
28class vtkMRMLUnitNode;
29
30#include "vtkSlicerUnitsModuleLogicExport.h"
31
32// STD includes
33#include <map>
34
41class VTK_SLICER_UNITS_MODULE_LOGIC_EXPORT vtkSlicerUnitsLogic : public vtkMRMLAbstractLogic
42{
43public:
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
52 AddUnitNode(const char* name, const char* quantity = "length", const char* prefix = "", const char* suffix = "", int precision = 3, double min = -10000., double max = 10000.);
53
55 void SetDefaultUnit(const char* quantity, const char* id);
56
59
94 static double GetSIPrefixCoefficient(const char* prefix);
95
122 static double GetDisplayCoefficient(const char* displayPrefix, const char* valuePrefix = "", double power = 1);
123
124protected:
127
129 void ObserveMRMLScene() override;
133 void UpdateFromMRMLScene() override;
136 void OnMRMLNodeModified(vtkMRMLNode* modifiedNode) override;
137
139 virtual void AddDefaultsUnits();
140
142 virtual void AddBuiltInUnits(vtkMRMLScene* scene);
143
145 void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
146
150 void RegisterNodes() override;
152
182 const char* name,
183 const char* quantity = "length",
184 const char* prefix = "",
185 const char* suffix = "",
186 int precision = 3,
187 double min = -10000.,
188 double max = 10000.,
189 double displayCoeff = 1.0,
190 double displayOffset = 0.0);
191
195
200
201 // Variables
203
204private:
206 void operator=(const vtkSlicerUnitsLogic&) = delete;
207
211 std::map<std::string, std::string> CachedDefaultUnits;
215 bool RestoringDefaultUnits;
216};
217
218#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