]> Creatis software - clitk.git/blob - vv/vvSlicer.h
Added "image" in actor type for SetActorVisibility and added
[clitk.git] / vv / vvSlicer.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17   ===========================================================================**/
18 #ifndef __vvSlicer_h
19 #define __vvSlicer_h
20 #include <iostream>
21 #include <vector>
22
23 #include "vvLandmarks.h"
24 #include "vvImage.h"
25 #include "vvMesh.h"
26 #include "vvMeshActor.h"
27
28 #include <vtkSmartPointer.h>
29 #include <vtkImageViewer2.h>
30 #include <vtkImageReslice.h>
31
32 class vtkActor;
33 class vtkActor2D;
34 class vtkCursor2D;
35 class vtkPolyDataMapper2D;
36 class vtkProperty2D;
37 class vtkClipPolyData;
38 class vtkImageActor;
39 class vvBlendImageActor;
40 class vtkBox;
41 class vtkCornerAnnotation;
42 class vtkExtractVOI;
43 class vtkPolyDataMapper2D;
44 class vtkPolyDataMapper;
45 class vtkGlyph3D;
46 class vvGlyph2D;
47 class vvGlyphSource;
48 class vtkCursor3D;
49 class vtkCutter;
50 class vtkAssignAttribute;
51 class vtkScalarBarActor;
52 class vtkTransform;
53 class vtkImageReslice;
54
55 class vvSlicer: public vtkImageViewer2
56 {
57 public:
58   static vvSlicer *New();
59   vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
60   void PrintSelf(ostream& os, vtkIndent indent);
61
62   void SetImage(vvImage::Pointer inputImages);
63   vvImage::Pointer GetImage() {
64     return mImage;
65   }
66
67   void SetOverlay(vvImage::Pointer inputOverlay);
68   vvImage::Pointer GetOverlay() {
69     return mOverlay;
70   }
71   vtkImageMapToWindowLevelColors* GetOverlayMapper(); 
72   vvBlendImageActor* GetOverlayActor() ;
73   vtkImageMapToWindowLevelColors* GetFusionMapper() ;
74   vtkImageActor* GetFusionActor() ;
75   vtkActor* GetVFActor() ;
76   vtkCornerAnnotation* GetAnnotation();
77     
78   void SetFusion(vvImage::Pointer inputFusion);
79   vvImage::Pointer GetFusion() {
80     return mFusion;
81   }
82
83   /**Get/Set an actor's visibility ("overlay, fusion, vf, contour...")
84      Overlay index is the index of the overlay by type, eg. if there are
85      5 contours and we want to activate the 3rd one, pass 2 **/
86   bool GetActorVisibility(const std::string& actor_type, int overlay_index);
87   void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
88   void RemoveActor(const std::string& actor_type, int overlay_index);
89
90   void SetVF(vvImage::Pointer vf);
91   vvImage *GetVF() {
92     return mVF;
93   }
94
95   void SetLandmarks(vvLandmarks* landmarks);
96   void SetTSlice(int t);
97   void SetSliceOrientation(int orientation);
98   void AdjustResliceToSliceOrientation(vtkImageReslice *reslice);
99   int GetTSlice();
100   ///Reimplemented from vtkImageViewer2 to add polydata support
101   void SetSlice(int s);
102   int GetTMax() {
103     return (unsigned int)mImage->GetVTKImages().size() - 1;
104   }
105
106   void SetOpacity(double s);
107   void SetRenderWindow(int orientation, vtkRenderWindow * rw);
108   void SetDisplayMode(bool i);
109   void FlipHorizontalView();
110   void FlipVerticalView();
111   static double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component=0);
112   void Render();
113   ///Sets the camera to fit the image in the window
114   void ResetCamera();
115
116   void SetVFSubSampling(int sub);
117   int GetVFSubSampling() {
118     return mSubSampling;
119   }
120   void SetVFScale(int scale);
121   void SetVFWidth(int width);
122   int GetVFScale() {
123     return mScale;
124   }
125   void SetVFLog(int log);
126   int GetVFLog() {
127     return mVFLog;
128   }
129
130   void SetFileName(std::string filename) {
131     mFileName = filename;
132   }
133   std::string GetFileName() {
134     return mFileName;
135   }
136
137   double* GetCursorPosition() {
138     return mCursor;
139   }
140
141   void SetCurrentPosition(double x, double y, double z, int t);
142   double* GetCurrentPosition() {
143     return mCurrent;
144   }
145
146   void UpdateCursorPosition();
147   void SetCursorVisibility(bool s);
148
149   bool GetCursorVisibility();
150   void SetCursorColor(int r,int g, int b);
151
152   void SetCornerAnnotationVisibility(bool s);
153   bool GetCornerAnnotationVisibility();
154
155   void GetExtremasAroundMousePointer(double & min, double & max);
156
157   void UpdateLandmarks();
158   void ForceUpdateDisplayExtent();
159
160   int* GetDisplayExtent();
161   /**Add a polydata to be displayed as a contour over the image
162    ** the contour can be propagated to a time sequence using a motion field */
163   void AddContour(vvMesh::Pointer contours,bool propagate);
164   ///Toggle temporal superposition of contours
165   void ToggleContourSuperposition();
166
167   virtual void SetColorWindow(double s);
168   virtual void SetColorLevel(double s);
169
170   /**
171    * When it is enabled, beware of a call to GetExtent.
172    * we must have setted mReducedExtent otherwhise random values
173    * are returned by GetExtent
174    * */
175   void EnableReducedExtent(bool b);
176   void SetReducedExtent(int * ext);
177
178   void ClipDisplayedExtent(int extent[6], int refExtent[6]);
179   int GetOrientation();
180   int * GetExtent();
181
182   double* GetVFColor() {
183     return mVFColor;
184   }
185   void SetVFColor(double r, double g, double b);
186
187 protected:
188   vvSlicer();
189   ~vvSlicer();
190
191   std::string mFileName;
192   vvImage::Pointer mImage;
193   vvImage::Pointer mOverlay;
194   vvImage::Pointer mFusion;
195   vvImage::Pointer mVF;
196
197   vvLandmarks* mLandmarks;
198
199   vtkSmartPointer<vtkImageReslice> mImageReslice;
200   vtkSmartPointer<vtkImageReslice> mOverlayReslice;
201   vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
202   vtkSmartPointer<vvBlendImageActor> mOverlayActor;
203   vtkSmartPointer<vtkImageReslice> mFusionReslice;
204   vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
205   vtkSmartPointer<vtkImageActor> mFusionActor;
206   vtkSmartPointer<vtkCornerAnnotation> ca;
207   vtkSmartPointer<vtkCursor2D> crossCursor;
208   vtkSmartPointer<vtkPolyDataMapper2D> pdm;
209   vtkSmartPointer<vtkActor2D> pdmA;
210   vtkSmartPointer<vvGlyphSource> mArrow;
211   vtkSmartPointer<vtkAssignAttribute> mAAFilter;
212   vtkSmartPointer<vtkExtractVOI> mVOIFilter;
213   vtkSmartPointer<vvGlyph2D> mGlyphFilter;
214   vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
215   vtkSmartPointer<vtkLookupTable> mVFColorLUT;
216   vtkSmartPointer<vtkActor> mVFActor;
217   vtkSmartPointer<vtkGlyph3D> mLandGlyph;
218   vtkSmartPointer<vtkCursor3D> mCross;
219   vtkSmartPointer<vtkClipPolyData> mLandClipper;
220   vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
221   vtkSmartPointer<vtkActor> mLandActor;
222   vtkSmartPointer<vtkBox> mClipBox;
223   vtkSmartPointer<vtkScalarBarActor> legend;
224   std::vector<vvMeshActor*> mSurfaceCutActors;
225
226   int mCurrentTSlice;
227   double mCurrent[3];
228   double mCursor[4];
229   int mSubSampling;
230   int mScale;
231   int mVFLog;
232   int mVFWidth;
233   double mVFColor[3];
234   bool mUseReducedExtent;
235   int * mReducedExtent;
236   int * mInitialExtent;
237
238 private:
239   void UpdateOrientation();
240   void UpdateDisplayExtent();
241   void ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
242                                         vtkImageData *targetImage, int targetExtent[6]);
243   ///Sets the surfaces to be cut on the image slice: update the vtkCutter
244   void SetContourSlice();
245
246
247 };
248 #endif