Slicer  5.0
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;
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;
158  virtual void RegisterNodesInternal(vtkMRMLScene* scene);
159 
188  vtkMRMLUnitNode* AddUnitNodeToScene(vtkMRMLScene* scene,
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 
201  void SaveDefaultUnits();
202 
206  void RestoreDefaultUnits();
207 
208  // Variables
210 private:
211  vtkSlicerUnitsLogic(const vtkSlicerUnitsLogic&) = delete;
212  void operator=(const vtkSlicerUnitsLogic&) = delete;
213 
217  std::map<std::string, std::string> CachedDefaultUnits;
221  bool RestoringDefaultUnits;
222 };
223 
224 #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:57
virtual void ObserveMRMLScene()
virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene)
Slicer logic for unit manipulation.
virtual void UpdateFromMRMLScene()
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
static vtkMRMLAbstractLogic * New()
Node that holds the information about a unit.