Slicer  5.2
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLMeasurement.h
Go to the documentation of this file.
1 /*=auto=========================================================================
2 
3 Portions (c) Copyright 2017 Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5 See COPYRIGHT.txt
6 or http://www.slicer.org/copyright/copyright.txt for details.
7 
8 =========================================================================auto=*/
9 
10 #ifndef __vtkMRMLMeasurement_h
11 #define __vtkMRMLMeasurement_h
12 
13 //#define USE_POLYDATA_MEASUREMENTS
14 
15 // MRML includes
16 #include <vtkCodedEntry.h>
17 #include "vtkMRMLNode.h"
18 
19 // VTK includes
20 #include <vtkCommand.h>
21 #include <vtkDoubleArray.h>
22 #include <vtkObject.h>
23 #include <vtkPolyData.h>
24 #include <vtkSmartPointer.h>
25 
26 class vtkMRMLUnitNode;
27 
61 class VTK_MRML_EXPORT vtkMRMLMeasurement : public vtkObject
62 {
63 public:
68  {
69  NoChange=0,
70  OK,
72  InternalError
73  };
74 
75  enum Events
76  {
80  // vtkCommand::UserEvent + 555 is just a random value that is very unlikely to be used for anything else in this class
81  InputDataModifiedEvent = vtkCommand::UserEvent + 555
82  };
83 
84  vtkTypeMacro(vtkMRMLMeasurement, vtkObject);
85  void PrintSelf(ostream& os, vtkIndent indent) override;
86 
88  VTK_NEWINSTANCE
89  virtual vtkMRMLMeasurement* CreateInstance() const = 0;
90 
92  virtual void Clear();
93 
96  virtual void ClearValue(ComputationResult computationResult=NoChange);
97 
99  virtual void Copy(vtkMRMLMeasurement* source);
100 
103  virtual void Compute() = 0;
104 
106  vtkGetMacro(Enabled, bool);
107  virtual void SetEnabled(bool enabled);
108  virtual void EnabledOn();
109  virtual void EnabledOff();
110 
112  vtkGetMacro(Name, std::string);
113  vtkSetMacro(Name, std::string);
114 
122  void SetValue(double value, const char* quantityName = nullptr);
123 
125  vtkGetMacro(Value, double);
126 
133  void SetDisplayValue(double value, const char* units=nullptr, double displayCoefficient=0.0);
134 
137  double GetDisplayValue();
138 
140  vtkGetMacro(ValueDefined, bool);
141 
143  vtkGetMacro(Units, std::string);
144  virtual void SetUnits(std::string units);
145 
149  vtkGetMacro(DisplayCoefficient, double);
150  vtkSetMacro(DisplayCoefficient, double);
151 
153  vtkGetMacro(Description, std::string);
154  vtkSetMacro(Description, std::string);
155 
157  vtkGetMacro(PrintFormat, std::string);
158  virtual void SetPrintFormat(std::string format);
159 
161  void SetQuantityCode(vtkCodedEntry* entry);
162  virtual vtkCodedEntry* GetQuantityCode();
163 
165  void SetDerivationCode(vtkCodedEntry* entry);
166  virtual vtkCodedEntry* GetDerivationCode();
167 
169  void SetUnitsCode(vtkCodedEntry* entry);
170  virtual vtkCodedEntry* GetUnitsCode();
171 
173  void SetMethodCode(vtkCodedEntry* entry);
174  virtual vtkCodedEntry* GetMethodCode();
175 
177  vtkGetMacro(LastComputationResult, int);
179  const char* GetLastComputationResultAsPrintableString();
180 
182  std::string GetValueWithUnitsAsPrintableString();
183 
185  void SetControlPointValues(vtkDoubleArray* inputValues);
186  vtkGetObjectMacro(ControlPointValues, vtkDoubleArray);
187 
191  void SetMeshValue(vtkPolyData* meshValue);
192  virtual vtkPolyData* GetMeshValue();
193 
195  void SetInputMRMLNode(vtkMRMLNode* node);
197  vtkMRMLNode* GetInputMRMLNode();
198 
199 protected:
201  ~vtkMRMLMeasurement() override;
203  void operator=(const vtkMRMLMeasurement&);
204 
206  vtkMRMLUnitNode* GetUnitNode(const char* quantityName);
207 
208 protected:
209  bool Enabled{true};
210  std::string Name;
211  double Value{0.0};
212  bool ValueDefined{false};
213  double DisplayCoefficient{1.0}; std::string Units;
214  std::string Description;
215  std::string PrintFormat; // for value (double), unit (string)
216  vtkSmartPointer<vtkCodedEntry> QuantityCode; // volume
217  vtkSmartPointer<vtkCodedEntry> DerivationCode; // min/max/mean
218  vtkSmartPointer<vtkCodedEntry> UnitsCode; // cubic millimeter
219  vtkSmartPointer<vtkCodedEntry> MethodCode; // Sum of segmented voxel volumes
220  ComputationResult LastComputationResult{InsufficientInput};
221 
223  vtkSmartPointer<vtkDoubleArray> ControlPointValues;
225  vtkSmartPointer<vtkPolyData> MeshValue;
227  vtkWeakPointer<vtkMRMLNode> InputMRMLNode;
228 };
229 
230 #endif
vtkSmartPointer< vtkCodedEntry > QuantityCode
vtkSmartPointer< vtkCodedEntry > UnitsCode
Class for storing well-defined measurement results, using coded entries.
vtkSmartPointer< vtkPolyData > MeshValue
Surface mesh for displaying computed value.
Simple class for storing standard coded entries (coding scheme, value, meaning triplets) ...
Definition: vtkCodedEntry.h:26
vtkWeakPointer< vtkMRMLNode > InputMRMLNode
MRML node used to calculate the measurement.
vtkSmartPointer< vtkCodedEntry > MethodCode
vtkSmartPointer< vtkCodedEntry > DerivationCode
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
Node that holds the information about a unit.
vtkSmartPointer< vtkDoubleArray > ControlPointValues
Per-control point measurements.