1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkResliceImageViewer.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 /**
16  * @class   vtkResliceImageViewer
17  * @brief   Display an image along with a reslice cursor
18  *
19  * This class is similar to vtkImageViewer2. It displays the image along with
20  * a two cross hairs for reslicing. The cross hairs may be interactively
21  * manipulated and are typically used to reslice two other views of
22  * vtkResliceImageViewer. See QtVTKRenderWindows for an example. The reslice
23  * cursor is used to perform thin or thick MPR through data. The class can
24  * also default to the behaviour of vtkImageViewer2 if the Reslice mode is
25  * set to RESLICE_AXIS_ALIGNED.
26  * @sa
27  * vtkResliceCursor vtkResliceCursorWidget vtkResliceCursorRepresentation
28 */
29 
30 #ifndef vtkResliceImageViewer_h
31 #define vtkResliceImageViewer_h
32 
33 #include "vtkInteractionImageModule.h" // For export macro
34 #include "vtkImageViewer2.h"
35 
36 class vtkResliceCursorWidget;
37 class vtkResliceCursor;
38 class vtkScalarsToColors;
39 class vtkBoundedPlanePointPlacer;
40 class vtkResliceImageViewerMeasurements;
41 class vtkResliceImageViewerScrollCallback;
42 class vtkPlane;
43 
44 class VTKINTERACTIONIMAGE_EXPORT vtkResliceImageViewer : public vtkImageViewer2
45 {
46 public:
47 
48   //@{
49   /**
50    * Standard VTK methods.
51    */
52   static vtkResliceImageViewer *New();
53   vtkTypeMacro(vtkResliceImageViewer,vtkImageViewer2);
54   void PrintSelf(ostream& os, vtkIndent indent) override;
55   //@}
56 
57   /**
58    * Render the resulting image.
59    */
60   void Render() override;
61 
62   //@{
63   /**
64    * Set/Get the input image to the viewer.
65    */
66   void SetInputData(vtkImageData *in) override;
67   void SetInputConnection(vtkAlgorithmOutput* input) override;
68   //@}
69 
70   //@{
71   /**
72    * Set window and level for mapping pixels to colors.
73    */
74   void SetColorWindow(double s) override;
75   void SetColorLevel(double s) override;
76   //@}
77 
78   //@{
79   /**
80    * Get the internal render window, renderer, image actor, and
81    * image map instances.
82    */
83   vtkGetObjectMacro(ResliceCursorWidget,vtkResliceCursorWidget);
84   //@}
85 
86   /**
87    * Set/get the slice orientation
88    */
89 
90   enum
91   {
92     RESLICE_AXIS_ALIGNED = 0,
93     RESLICE_OBLIQUE = 1
94   };
95 
96   vtkGetMacro(ResliceMode, int);
97   virtual void SetResliceMode(int resliceMode);
SetResliceModeToAxisAligned()98   virtual void SetResliceModeToAxisAligned()
99     { this->SetResliceMode(vtkResliceImageViewer::RESLICE_AXIS_ALIGNED); };
SetResliceModeToOblique()100   virtual void SetResliceModeToOblique()
101     { this->SetResliceMode(vtkResliceImageViewer::RESLICE_OBLIQUE); };
102 
103   //@{
104   /**
105    * Set/Get the reslice cursor.
106    */
107   vtkResliceCursor * GetResliceCursor();
108   void SetResliceCursor( vtkResliceCursor * rc );
109   //@}
110 
111   //@{
112   /**
113    * Set the lookup table
114    */
115   virtual void SetLookupTable( vtkScalarsToColors * );
116   vtkScalarsToColors * GetLookupTable();
117   //@}
118 
119   //@{
120   /**
121    * Switch to / from thick mode
122    */
123   virtual void SetThickMode( int );
124   virtual int GetThickMode();
125   //@}
126 
127   /**
128    * Reset all views back to initial state
129    */
130   virtual void Reset();
131 
132   //@{
133   /**
134    * Get the point placer.
135    */
136   vtkGetObjectMacro( PointPlacer, vtkBoundedPlanePointPlacer );
137   //@}
138 
139   //@{
140   /**
141    * Get the measurements manager
142    */
143   vtkGetObjectMacro( Measurements, vtkResliceImageViewerMeasurements );
144   //@}
145 
146   //@{
147   /**
148    * Get the render window interactor
149    */
150   vtkGetObjectMacro( Interactor, vtkRenderWindowInteractor );
151   //@}
152 
153   //@{
154   /**
155    * Scroll slices on the mouse wheel ? In the case of MPR
156    * view, it moves one "normalized spacing" in the direction of the normal to
157    * the resliced plane, provided the new center will continue to lie within
158    * the volume.
159    */
160   vtkSetMacro( SliceScrollOnMouseWheel, vtkTypeBool );
161   vtkGetMacro( SliceScrollOnMouseWheel, vtkTypeBool );
162   vtkBooleanMacro( SliceScrollOnMouseWheel, vtkTypeBool );
163   //@}
164 
165   /**
166    * Increment/Decrement slice by 'n' slices
167    */
168   virtual void IncrementSlice( int n );
169 
170   enum { SliceChangedEvent = 1001 };
171 
172 protected:
173   vtkResliceImageViewer();
174   ~vtkResliceImageViewer() override;
175 
176   void InstallPipeline() override;
177   void UnInstallPipeline() override;
178   void UpdateOrientation() override;
179   void UpdateDisplayExtent() override;
180   virtual void UpdatePointPlacer();
181 
182   //@{
183   /**
184    * Convenience methods to get the reslice plane and the normalized
185    * spacing between slices in reslice mode.
186    */
187   vtkPlane * GetReslicePlane();
188   double GetInterSliceSpacingInResliceMode();
189   //@}
190 
191   vtkResliceCursorWidget            * ResliceCursorWidget;
192   vtkBoundedPlanePointPlacer        * PointPlacer;
193   int                                 ResliceMode;
194   vtkResliceImageViewerMeasurements * Measurements;
195   vtkTypeBool                                 SliceScrollOnMouseWheel;
196   vtkResliceImageViewerScrollCallback * ScrollCallback;
197 
198 private:
199   vtkResliceImageViewer(const vtkResliceImageViewer&) = delete;
200   void operator=(const vtkResliceImageViewer&) = delete;
201 };
202 
203 #endif
204