]> Creatis software - clitk.git/blob - vv/vvSlicer.h
Romulo:
[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://oncora1.lyon.fnclcc.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
31 class vtkActor;
32 class vtkActor2D;
33 class vtkCursor2D;
34 class vtkPolyDataMapper2D;
35 class vtkProperty2D;
36 class vtkClipPolyData;
37 class vtkImageActor;
38 class vvBlendImageActor;
39 class vtkBox;
40 class vtkCornerAnnotation;
41 class vtkExtractVOI;
42 class vtkPolyDataMapper2D;
43 class vtkPolyDataMapper;
44 class vtkGlyph3D;
45 class vvGlyph2D;
46 class vvGlyphSource;
47 class vtkCursor3D;
48 class vtkCutter;
49 class vtkAssignAttribute;
50 class vtkScalarBarActor;
51 class vtkTransform;
52 class vtkImageReslice;
53
54 class vvSlicer: public vtkImageViewer2
55 {
56 public:
57   static vvSlicer *New();
58   vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
59   void PrintSelf(ostream& os, vtkIndent indent);
60
61   void SetImage(vvImage::Pointer inputImages);
62   vvImage::Pointer GetImage() {
63     return mImage;
64   }
65
66   void SetOverlay(vvImage::Pointer inputOverlay);
67   vvImage::Pointer GetOverlay() {
68     return mOverlay;
69   }
70   vtkImageMapToWindowLevelColors* GetOverlayMapper(); 
71   vvBlendImageActor* GetOverlayActor() ;
72   vtkImageMapToWindowLevelColors* GetFusionMapper() ;
73   vtkImageActor* GetFusionActor() ;
74   vtkActor* GetVFActor() ;
75   vtkCornerAnnotation* GetAnnotation();
76     
77   void SetFusion(vvImage::Pointer inputFusion);
78   vvImage::Pointer GetFusion() {
79     return mFusion;
80   }
81
82   /**Set an actor's visibility ("overlay, fusion, vf, contour...")
83      Overlay index is the index of the overlay by type, eg. if there are
84      5 contours and we want to activate the 3rd one, pass 2 **/
85   void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
86   void RemoveActor(const std::string& actor_type, int overlay_index);
87
88   void SetVF(vvImage::Pointer vf);
89   vvImage *GetVF() {
90     return mVF;
91   }
92
93   void SetLandmarks(vvLandmarks* landmarks);
94   void SetTSlice(int t);
95   void SetSliceOrientation(int orientation);
96   int GetTSlice();
97   ///Reimplemented from vtkImageViewer2 to add polydata support
98   void SetSlice(int s);
99   int GetTMax() {
100     return (unsigned int)mImage->GetVTKImages().size() - 1;
101   }
102
103   void SetOpacity(double s);
104   void SetRenderWindow(int orientation, vtkRenderWindow * rw);
105   void SetDisplayMode(bool i);
106   void FlipHorizontalView();
107   void FlipVerticalView();
108   static double GetScalarComponentAsDouble(vtkImageData *image, int X, double Y, double Z, int &ix, int &iy, int &iz, int component=0);
109   void Render();
110   ///Sets the camera to fit the image in the window
111   void ResetCamera();
112
113   void SetVFSubSampling(int sub);
114   int GetVFSubSampling() {
115     return mSubSampling;
116   }
117   void SetVFScale(int scale);
118   void SetVFWidth(int width);
119   int GetVFScale() {
120     return mScale;
121   }
122   void SetVFLog(int log);
123   int GetVFLog() {
124     return mVFLog;
125   }
126
127   void SetFileName(std::string filename) {
128     mFileName = filename;
129   }
130   std::string GetFileName() {
131     return mFileName;
132   }
133
134   double* GetCursorPosition() {
135     return mCursor;
136   }
137
138   void SetCurrentPosition(double x, double y, double z, int t);
139   double* GetCurrentPosition() {
140     return mCurrent;
141   }
142
143   void UpdateCursorPosition();
144   void SetCursorVisibility(bool s);
145
146   bool GetCursorVisibility();
147   void SetCursorColor(int r,int g, int b);
148
149   void SetCornerAnnotationVisibility(bool s);
150   bool GetCornerAnnotationVisibility();
151
152   void GetExtremasAroundMousePointer(double & min, double & max);
153
154   void UpdateLandmarks();
155   void ForceUpdateDisplayExtent();
156
157   int* GetDisplayExtent();
158   /**Add a polydata to be displayed as a contour over the image
159    ** the contour can be propagated to a time sequence using a motion field */
160   void AddContour(vvMesh::Pointer contours,bool propagate);
161   ///Toggle temporal superposition of contours
162   void ToggleContourSuperposition();
163
164   virtual void SetColorWindow(double s);
165   virtual void SetColorLevel(double s);
166
167     
168   void EnableReducedExtent(bool b);
169   void SetReducedExtent(int * ext);
170
171   void ClipDisplayedExtent(int extent[6], int refExtent[6]);
172   int GetOrientation();
173   int * GetExtent();
174
175   double* GetVFColor() {
176     return mVFColor;
177   }
178   void SetVFColor(double r, double g, double b);
179
180 protected:
181   vvSlicer();
182   ~vvSlicer();
183
184   std::string mFileName;
185   vvImage::Pointer mImage;
186   vvImage::Pointer mOverlay;
187   vvImage::Pointer mFusion;
188   vvImage::Pointer mVF;
189
190   vvLandmarks* mLandmarks;
191
192   vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
193   vtkSmartPointer<vvBlendImageActor> mOverlayActor;
194   vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
195   vtkSmartPointer<vtkImageActor> mFusionActor;
196   vtkSmartPointer<vtkCornerAnnotation> ca;
197   vtkSmartPointer<vtkCursor2D> crossCursor;
198   vtkSmartPointer<vtkPolyDataMapper2D> pdm;
199   vtkSmartPointer<vtkActor2D> pdmA;
200   vtkSmartPointer<vvGlyphSource> mArrow;
201   vtkSmartPointer<vtkAssignAttribute> mAAFilter;
202   vtkSmartPointer<vtkExtractVOI> mVOIFilter;
203   vtkSmartPointer<vvGlyph2D> mGlyphFilter;
204   vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
205   vtkSmartPointer<vtkLookupTable> mVFColorLUT;
206   vtkSmartPointer<vtkActor> mVFActor;
207   vtkSmartPointer<vtkGlyph3D> mLandGlyph;
208   vtkSmartPointer<vtkCursor3D> mCross;
209   vtkSmartPointer<vtkClipPolyData> mLandClipper;
210   vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
211   vtkSmartPointer<vtkActor> mLandActor;
212   vtkSmartPointer<vtkBox> mClipBox;
213   vtkSmartPointer<vtkScalarBarActor> legend;
214   std::vector<vvMeshActor*> mSurfaceCutActors;
215
216   int mCurrentTSlice;
217   double mCurrent[3];
218   double mCursor[4];
219   int mSubSampling;
220   int mScale;
221   int mVFLog;
222   int mVFWidth;
223   double mVFColor[3];
224   bool mUseReducedExtent;
225   int * mReducedExtent;
226   int * mInitialExtent;
227
228 private:
229   void UpdateOrientation();
230   void UpdateDisplayExtent();
231   void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]);
232   void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
233   void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
234   ///Sets the surfaces to be cut on the image slice: update the vtkCutter
235   void SetContourSlice();
236
237
238 };
239 #endif