Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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
26 #include "vtkMRMLAbstractLogic.h"
27 
28 // MRML includes
29 class vtkMRMLUnitNode;
30 
31 #include "vtkSlicerUnitsModuleLogicExport.h"
32 
33 // STD includes
34 #include <map>
35 
42 class VTK_SLICER_UNITS_MODULE_LOGIC_EXPORT vtkSlicerUnitsLogic
43  : public vtkMRMLAbstractLogic
44 {
45 public:
46  static vtkSlicerUnitsLogic *New();
49  virtual void PrintSelf(ostream& os, vtkIndent indent) VTK_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 
65  vtkMRMLScene* GetUnitsScene() const;
66 
101  static double GetSIPrefixCoefficient(const char* prefix);
102 
127  static double GetDisplayCoefficient(const char* displayPrefix, const char* valuePrefix = "");
128 
129 protected:
131  virtual ~vtkSlicerUnitsLogic();
132 
134  virtual void ObserveMRMLScene() VTK_OVERRIDE;
137  virtual void OnMRMLSceneStartBatchProcess() VTK_OVERRIDE;
140  virtual void OnMRMLNodeModified(vtkMRMLNode* modifiedNode) VTK_OVERRIDE;
141 
143  virtual void AddDefaultsUnits();
144 
146  virtual void AddBuiltInUnits(vtkMRMLScene* scene);
147 
149  virtual void SetMRMLSceneInternal(vtkMRMLScene* newScene) VTK_OVERRIDE;
150 
154  virtual void RegisterNodes() VTK_OVERRIDE;
155  virtual void RegisterNodesInternal(vtkMRMLScene* scene);
156 
185  vtkMRMLUnitNode* AddUnitNodeToScene(vtkMRMLScene* scene,
186  const char* name,
187  const char* quantity = "length",
188  const char* prefix = "",
189  const char* suffix = "",
190  int precision = 3,
191  double min = -10000.,
192  double max = 10000.,
193  double displayCoeff = 1.0,
194  double displayOffset = 0.0);
195 
198  void SaveDefaultUnits();
199 
203  void RestoreDefaultUnits();
204 
205  // Variables
206  vtkMRMLScene* UnitsScene;
207 private:
208  vtkSlicerUnitsLogic(const vtkSlicerUnitsLogic&); // Not implemented
209  void operator=(const vtkSlicerUnitsLogic&); // Not implemented
210 
214  std::map<std::string, std::string> CachedDefaultUnits;
218  bool RestoringDefaultUnits;
219 };
220 
221 #endif
Superclass for MRML logic classes.
LRU Cache.
vtkSlicerUnitsLogic Self
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
virtual void ObserveMRMLScene()
Slicer logic for unit manipulation.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135
static vtkMRMLAbstractLogic * New()
Node that holds the information about a unit.