fw4spl
fwVtkWindowLevelLookupTable.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWRENDERVTK_VTK_FWVTKWINDOWLEVELLOOKUPTABLE_HPP__
8 #define __FWRENDERVTK_VTK_FWVTKWINDOWLEVELLOOKUPTABLE_HPP__
9 
10 #include "fwRenderVTK/config.hpp"
11 
12 #include <vtkLookupTable.h>
13 
15 class FWRENDERVTK_API fwVtkWindowLevelLookupTable : public vtkLookupTable
16 {
17 public:
18  static fwVtkWindowLevelLookupTable* New();
19  vtkTypeMacro(fwVtkWindowLevelLookupTable, vtkLookupTable);
20  void PrintSelf(ostream& os, vtkIndent indent) override;
21 
22  // Description:
23  // Set the window for the lookup table. The window is the difference
24  // between TableRange[0] and TableRange[1].
25  void SetWindow(double window)
26  {
27  this->InverseVideo = window < 0;
28  if(this->InverseVideo)
29  {
30  window = -window;
31  }
32  if (window < 1e-5)
33  {
34  window = 1e-5;
35  }
36  this->Window = window;
37  this->SetTableRange(this->Level - this->Window/2.0,
38  this->Level + this->Window/2.0);
39  }
40  vtkGetMacro(Window, double);
41 
42  void BuildInvert();
43 
44  // Description:
45  // Set the Level for the lookup table. The level is the average of
46  // TableRange[0] and TableRange[1].
47  void SetLevel(double level)
48  {
49  this->Level = level;
50  this->SetTableRange(this->Level - this->Window/2.0,
51  this->Level + this->Window/2.0);
52  }
53  vtkGetMacro(Level, double);
54 
55  // Description:
56  // Set on or off. You can achieve the same effect by
57  // switching the LeftClampValue and the RightClampValue.
58  vtkSetMacro(Clamping, int);
59  vtkGetMacro(Clamping, int);
60  vtkBooleanMacro(Clamping, int);
61 
62  // Description:
63  // Set the minimum table value. All lookup table entries below the
64  // start of the ramp will be set to this color. After you change
65  // this value, you must re-build the lookup table.
66  vtkSetVector4Macro(LeftClampValue, double);
67  vtkGetVector4Macro(LeftClampValue, double);
68 
69  // Description:
70  // Set the maximum table value. All lookup table entries above the
71  // end of the ramp will be set to this color. After you change
72  // this value, you must re-build the lookup table.
73  vtkSetVector4Macro(RightClampValue, double);
74  vtkGetVector4Macro(RightClampValue, double);
75 
76  unsigned char* GetCurrentPointer(const vtkIdType id);
77 
78  // Description:
79  // map a set of scalars through the lookup table
80  void MapScalarsThroughTable2(void* input, unsigned char* output,
81  int inputDataType, int numberOfValues,
82  int inputIncrement, int outputIncrement) override;
83 
84 protected:
85  fwVtkWindowLevelLookupTable(int sze = 256, int ext = 256);
87 
88  double Window;
89  double Level;
90  int InverseVideo;
91 
92  int Clamping;
93  double RightClampValue[4];
94  double LeftClampValue[4];
95 
96  vtkUnsignedCharArray* InvertTable;
97  vtkTimeStamp InvertTime;
98 
99 private:
100  fwVtkWindowLevelLookupTable(const fwVtkWindowLevelLookupTable&); // Not implemented.
101  void operator=(const fwVtkWindowLevelLookupTable&); // Not implemented.
102 };
103 
104 #endif //__FWRENDERVTK_VTK_FWVTKWINDOWLEVELLOOKUPTABLE_HPP__
Reinplementation of vtkWindowLevelLookupTable : add specific out-of-bounds colors.