Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
vtkMRMLMeasurement.h
Go to the documentation of this file.
1/*=auto=========================================================================
2
3Portions (c) Copyright 2017 Brigham and Women's Hospital (BWH) All Rights Reserved.
4
5See COPYRIGHT.txt
6or 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
26class vtkMRMLUnitNode;
27
61class VTK_MRML_EXPORT vtkMRMLMeasurement : public vtkObject
62{
63public:
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
89 VTK_NEWINSTANCE
90 virtual vtkMRMLMeasurement* CreateInstance() const = 0;
91
93 virtual void Clear();
94
97 virtual void ClearValue(ComputationResult computationResult=NoChange);
98
100 virtual void Copy(vtkMRMLMeasurement* source);
101
104 virtual void Compute() = 0;
105
107 vtkGetMacro(Enabled, bool);
108 virtual void SetEnabled(bool enabled);
109 virtual void EnabledOn();
110 virtual void EnabledOff();
111
113 vtkGetMacro(Name, std::string);
114 vtkSetMacro(Name, std::string);
115
123 void SetValue(double value, const char* quantityName = nullptr);
124
126 vtkGetMacro(Value, double);
127
134 void SetDisplayValue(double value, const char* units=nullptr, double displayCoefficient=0.0);
135
139
141 vtkGetMacro(ValueDefined, bool);
142
144 vtkGetMacro(Units, std::string);
145 virtual void SetUnits(std::string units);
146
150 vtkGetMacro(DisplayCoefficient, double);
151 vtkSetMacro(DisplayCoefficient, double);
152
154 vtkGetMacro(Description, std::string);
155 vtkSetMacro(Description, std::string);
156
158 vtkGetMacro(PrintFormat, std::string);
159 virtual void SetPrintFormat(std::string format);
160
164
168
172
176
178 vtkGetMacro(LastComputationResult, int);
181
184
186 void SetControlPointValues(vtkDoubleArray* inputValues);
187 vtkGetObjectMacro(ControlPointValues, vtkDoubleArray);
188
192 void SetMeshValue(vtkPolyData* meshValue);
193 virtual vtkPolyData* GetMeshValue();
194
199
200protected:
205
207 vtkMRMLUnitNode* GetUnitNode(const char* quantityName);
208
209protected:
210 bool Enabled{true};
211 std::string Name;
212 double Value{0.0};
213 bool ValueDefined{false};
214 double DisplayCoefficient{1.0}; std::string Units;
215 std::string Description;
216 std::string PrintFormat; // for value (double), unit (string)
217 vtkSmartPointer<vtkCodedEntry> QuantityCode; // volume
218 vtkSmartPointer<vtkCodedEntry> DerivationCode; // min/max/mean
219 vtkSmartPointer<vtkCodedEntry> UnitsCode; // cubic millimeter
220 vtkSmartPointer<vtkCodedEntry> MethodCode; // Sum of segmented voxel volumes
222
224 vtkSmartPointer<vtkDoubleArray> ControlPointValues;
226 vtkSmartPointer<vtkPolyData> MeshValue;
228 vtkWeakPointer<vtkMRMLNode> InputMRMLNode;
229};
230
231#endif
Simple class for storing standard coded entries (coding scheme, value, meaning triplets)
vtkSmartPointer< vtkCodedEntry > QuantityCode
virtual VTK_NEWINSTANCE vtkMRMLMeasurement * CreateInstance() const =0
@ NoChange
can be used to indicate to keep the current value
vtkMRMLUnitNode * GetUnitNode(const char *quantityName)
Helper function to get unit node from the scene based on quantity name.
vtkSmartPointer< vtkDoubleArray > ControlPointValues
Per-control point measurements.
virtual void EnabledOn()
virtual vtkCodedEntry * GetQuantityCode()
double GetDisplayValue()
virtual void Compute()=0
vtkSmartPointer< vtkCodedEntry > MethodCode
vtkSmartPointer< vtkCodedEntry > DerivationCode
~vtkMRMLMeasurement() override
vtkSmartPointer< vtkPolyData > MeshValue
Surface mesh for displaying computed value.
void SetValue(double value, const char *quantityName=nullptr)
virtual void Copy(vtkMRMLMeasurement *source)
Copy one type into another (deep copy)
void SetControlPointValues(vtkDoubleArray *inputValues)
Set the per-control point measurement values.
void SetMeshValue(vtkPolyData *meshValue)
vtkMRMLNode * GetInputMRMLNode()
Get input MRML node used for calculating the measurement.
virtual vtkCodedEntry * GetMethodCode()
virtual vtkPolyData * GetMeshValue()
virtual void EnabledOff()
void SetInputMRMLNode(vtkMRMLNode *node)
Set input MRML node used for calculating the measurement.
virtual void Clear()
Reset state of object. Removes all content.
virtual vtkCodedEntry * GetUnitsCode()
void PrintSelf(ostream &os, vtkIndent indent) override
void SetUnitsCode(vtkCodedEntry *entry)
Copy content of coded entry.
void SetDisplayValue(double value, const char *units=nullptr, double displayCoefficient=0.0)
void SetMethodCode(vtkCodedEntry *entry)
Copy content of coded entry.
void SetDerivationCode(vtkCodedEntry *entry)
Copy content of coded entry.
ComputationResult LastComputationResult
virtual void SetPrintFormat(std::string format)
void operator=(const vtkMRMLMeasurement &)
vtkMRMLMeasurement(const vtkMRMLMeasurement &)
vtkWeakPointer< vtkMRMLNode > InputMRMLNode
MRML node used to calculate the measurement.
std::string GetValueWithUnitsAsPrintableString()
Get measurement value and units as a single human-readable string.
virtual void SetUnits(std::string units)
virtual void ClearValue(ComputationResult computationResult=NoChange)
vtkSmartPointer< vtkCodedEntry > UnitsCode
const char * GetLastComputationResultAsPrintableString()
Get last computation result as human-readable string.
virtual vtkCodedEntry * GetDerivationCode()
virtual void SetEnabled(bool enabled)
void SetQuantityCode(vtkCodedEntry *entry)
Copy content of coded entry.
Abstract Superclass for all specific types of MRML nodes.
Node that holds the information about a unit.