1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkImageProperty.h
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 // .NAME vtkImageProperty - image display properties
16 // .SECTION Description
17 // vtkImageProperty is an object that allows control of the display
18 // of an image slice.
19 // .SECTION Thanks
20 // Thanks to David Gobbi at the Seaman Family MR Centre and Dept. of Clinical
21 // Neurosciences, Foothills Medical Centre, Calgary, for providing this class.
22 // .SECTION See also
23 // vtkImage vtkImageMapper3D vtkImageSliceMapper vtkImageResliceMapper
24 
25 #ifndef vtkImageProperty_h
26 #define vtkImageProperty_h
27 
28 #include "vtkRenderingCoreModule.h" // For export macro
29 #include "vtkObject.h"
30 
31 class vtkScalarsToColors;
32 
33 class VTKRENDERINGCORE_EXPORT vtkImageProperty : public vtkObject
34 {
35 public:
36   vtkTypeMacro(vtkImageProperty,vtkObject);
37   void PrintSelf(ostream& os, vtkIndent indent);
38 
39   // Description:
40   // Construct a property with no lookup table.
41   static vtkImageProperty *New();
42 
43   // Description:
44   // Assign one property to another.
45   void DeepCopy(vtkImageProperty *p);
46 
47   // Description:
48   // The window value for window/level.
49   vtkSetMacro(ColorWindow, double);
50   vtkGetMacro(ColorWindow, double);
51 
52   // Description:
53   // The level value for window/level.
54   vtkSetMacro(ColorLevel, double);
55   vtkGetMacro(ColorLevel, double);
56 
57   // Description:
58   // Specify a lookup table for the data.  If the data is
59   // to be displayed as greyscale, or if the input data is
60   // already RGB, there is no need to set a lookup table.
61   virtual void SetLookupTable(vtkScalarsToColors *lut);
62   vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
63 
64   // Description:
65   // Use the range that is set in the lookup table, instead
66   // of setting the range from the Window/Level settings.
67   // This is off by default.
68   vtkSetMacro(UseLookupTableScalarRange, int);
69   vtkGetMacro(UseLookupTableScalarRange, int);
70   vtkBooleanMacro(UseLookupTableScalarRange, int);
71 
72   // Description:
73   // The opacity of the image, where 1.0 is opaque and 0.0 is
74   // transparent.  If the image has an alpha component, then
75   // the alpha component will be multiplied by this value.
76   vtkSetClampMacro(Opacity, double, 0.0, 1.0);
77   vtkGetMacro(Opacity, double);
78 
79   // Description:
80   // The ambient lighting coefficient.  The default is 1.0.
81   vtkSetClampMacro(Ambient, double, 0.0, 1.0);
82   vtkGetMacro(Ambient, double);
83 
84   // Description:
85   // The diffuse lighting coefficient.  The default is 0.0.
86   vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
87   vtkGetMacro(Diffuse, double);
88 
89   // Description:
90   // The interpolation type (default: nearest neighbor).
91   vtkSetClampMacro(InterpolationType, int,
92                    VTK_NEAREST_INTERPOLATION, VTK_CUBIC_INTERPOLATION);
93   vtkGetMacro(InterpolationType, int);
SetInterpolationTypeToNearest()94   void SetInterpolationTypeToNearest() {
95     this->SetInterpolationType(VTK_NEAREST_INTERPOLATION); };
SetInterpolationTypeToLinear()96   void SetInterpolationTypeToLinear() {
97     this->SetInterpolationType(VTK_LINEAR_INTERPOLATION); };
SetInterpolationTypeToCubic()98   void SetInterpolationTypeToCubic() {
99     this->SetInterpolationType(VTK_CUBIC_INTERPOLATION); };
100   virtual const char *GetInterpolationTypeAsString();
101 
102   // Description:
103   // Set the layer number.  This is ignored unless the image is part
104   // of a vtkImageStack.  The default layer number is zero.
105   vtkSetMacro(LayerNumber, int);
GetLayerNumber()106   int GetLayerNumber()
107     { return this->LayerNumber; }
108 
109   // Description:
110   // Make a checkerboard pattern where the black squares are transparent.
111   // The pattern is aligned with the camera, and centered by default.
112   vtkSetMacro(Checkerboard, int);
113   vtkBooleanMacro(Checkerboard, int);
114   vtkGetMacro(Checkerboard, int);
115 
116   // Description:
117   // The spacing for checkerboarding.  This is in real units, not pixels.
118   vtkSetVector2Macro(CheckerboardSpacing, double);
119   vtkGetVector2Macro(CheckerboardSpacing, double);
120 
121   // Description:
122   // The phase offset for checkerboarding, in units of spacing.  Use a
123   // value between -1 and +1, where 1 is an offset of one squares.
124   vtkSetVector2Macro(CheckerboardOffset, double);
125   vtkGetVector2Macro(CheckerboardOffset, double);
126 
127   // Description:
128   // Use an opaque backing polygon, which will be visible where the image
129   // is translucent.  When images are in a stack, the backing polygons
130   // for all images will be drawn before any of the images in the stack,
131   // in order to allow the images in the stack to be composited.
132   vtkSetMacro(Backing, int);
133   vtkBooleanMacro(Backing, int);
134   vtkGetMacro(Backing, int);
135 
136   // Description:
137   // Set the color of the backing polygon.  The default color is black.
138   vtkSetVector3Macro(BackingColor, double);
139   vtkGetVector3Macro(BackingColor, double);
140 
141   // Description:
142   // Get the MTime for this property.  If the lookup table is set,
143   // the mtime will include the mtime of the lookup table.
144   unsigned long GetMTime();
145 
146 protected:
147   vtkImageProperty();
148   ~vtkImageProperty();
149 
150   vtkScalarsToColors *LookupTable;
151   double ColorWindow;
152   double ColorLevel;
153   int UseLookupTableScalarRange;
154   int InterpolationType;
155   int LayerNumber;
156   double Opacity;
157   double Ambient;
158   double Diffuse;
159   int Checkerboard;
160   double CheckerboardSpacing[2];
161   double CheckerboardOffset[2];
162   int Backing;
163   double BackingColor[3];
164 
165 private:
166   vtkImageProperty(const vtkImageProperty&);  // Not implemented.
167   void operator=(const vtkImageProperty&);  // Not implemented.
168 };
169 
170 #endif
171