Slicer  4.11
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  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 
65  vtkMRMLScene* GetUnitsScene() const;
66 
101  static double GetSIPrefixCoefficient(const char* prefix);
102 
129  static double GetDisplayCoefficient(const char* displayPrefix, const char* valuePrefix = "", double power=1);
130 
131 protected:
133  ~vtkSlicerUnitsLogic() override;
134 
136  void ObserveMRMLScene() override;
139  void OnMRMLSceneStartBatchProcess() override;
142  void OnMRMLNodeModified(vtkMRMLNode* modifiedNode) override;
143 
145  virtual void AddDefaultsUnits();
146 
148  virtual void AddBuiltInUnits(vtkMRMLScene* scene);
149 
151  void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
152 
156  void RegisterNodes() override;
157  virtual void RegisterNodesInternal(vtkMRMLScene* scene);
158 
187  vtkMRMLUnitNode* AddUnitNodeToScene(vtkMRMLScene* scene,
188  const char* name,
189  const char* quantity = "length",
190  const char* prefix = "",
191  const char* suffix = "",
192  int precision = 3,
193  double min = -10000.,
194  double max = 10000.,
195  double displayCoeff = 1.0,
196  double displayOffset = 0.0);
197 
200  void SaveDefaultUnits();
201 
205  void RestoreDefaultUnits();
206 
207  // Variables
209 private:
210  vtkSlicerUnitsLogic(const vtkSlicerUnitsLogic&) = delete;
211  void operator=(const vtkSlicerUnitsLogic&) = delete;
212 
216  std::map<std::string, std::string> CachedDefaultUnits;
220  bool RestoringDefaultUnits;
221 };
222 
223 #endif
Superclass for MRML logic classes.
void PrintSelf(ostream &os, vtkIndent indent) override
vtkSlicerUnitsLogic Self
virtual void OnMRMLSceneStartBatchProcess()
virtual void OnMRMLNodeModified(vtkMRMLNode *)
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:61
virtual void ObserveMRMLScene()
virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene)
Slicer logic for unit manipulation.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
static vtkMRMLAbstractLogic * New()
Node that holds the information about a unit.