]> Creatis software - clitk.git/blob - vv/vvSlicer.h
Added VF color option and corresponding button
[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 #include <vtkColor.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   /**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   void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
87   void RemoveActor(const std::string& actor_type, int overlay_index);
88
89   void SetVF(vvImage::Pointer vf);
90   vvImage *GetVF() {
91     return mVF;
92   }
93
94   void SetLandmarks(vvLandmarks* landmarks);
95   void SetTSlice(int t);
96   void SetSliceOrientation(int orientation);
97   int GetTSlice();
98   ///Reimplemented from vtkImageViewer2 to add polydata support
99   void SetSlice(int s);
100   int GetTMax() {
101     return (unsigned int)mImage->GetVTKImages().size() - 1;
102   }
103
104   void SetOpacity(double s);
105   void SetRenderWindow(int orientation, vtkRenderWindow * rw);
106   void SetDisplayMode(bool i);
107   void FlipHorizontalView();
108   void FlipVerticalView();
109   static double GetScalarComponentAsDouble(vtkImageData *image, int X, double Y, double Z, int &ix, int &iy, int &iz, int component=0);
110   void Render();
111   ///Sets the camera to fit the image in the window
112   void ResetCamera();
113
114   void SetVFSubSampling(int sub);
115   int GetVFSubSampling() {
116     return mSubSampling;
117   }
118   void SetVFScale(int scale);
119   void SetVFWidth(int width);
120   int GetVFScale() {
121     return mScale;
122   }
123   void SetVFLog(int log);
124   int GetVFLog() {
125     return mVFLog;
126   }
127
128   void SetFileName(std::string filename) {
129     mFileName = filename;
130   }
131   std::string GetFileName() {
132     return mFileName;
133   }
134
135   double* GetCursorPosition() {
136     return mCursor;
137   }
138
139   void SetCurrentPosition(double x, double y, double z, int t);
140   double* GetCurrentPosition() {
141     return mCurrent;
142   }
143
144   void UpdateCursorPosition();
145   void SetCursorVisibility(bool s);
146   bool GetCursorVisibility();
147   void SetCursorColor(int r,int g, int b);
148
149   void GetExtremasAroundMousePointer(double & min, double & max);
150
151   void UpdateLandmarks();
152   void ForceUpdateDisplayExtent();
153
154   int* GetDisplayExtent();
155   /**Add a polydata to be displayed as a contour over the image
156    ** the contour can be propagated to a time sequence using a motion field */
157   void AddContour(vvMesh::Pointer contours,bool propagate);
158   ///Toggle temporal superposition of contours
159   void ToggleContourSuperposition();
160
161   virtual void SetColorWindow(double s);
162   virtual void SetColorLevel(double s);
163
164     
165   void EnableReducedExtent(bool b);
166   void SetReducedExtent(int * ext);
167
168   void ClipDisplayedExtent(int extent[6], int refExtent[6]);
169   int GetOrientation();
170   int * GetExtent();
171
172   double* GetVFColor() {
173     return mVFColor;
174   }
175   void SetVFColor(double r, double g, double b);
176
177 protected:
178   vvSlicer();
179   ~vvSlicer();
180
181   std::string mFileName;
182   vvImage::Pointer mImage;
183   vvImage::Pointer mOverlay;
184   vvImage::Pointer mFusion;
185   vvImage::Pointer mVF;
186
187   vvLandmarks* mLandmarks;
188
189   vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
190   vtkSmartPointer<vvBlendImageActor> mOverlayActor;
191   vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
192   vtkSmartPointer<vtkImageActor> mFusionActor;
193   vtkSmartPointer<vtkCornerAnnotation> ca;
194   vtkSmartPointer<vtkCursor2D> crossCursor;
195   vtkSmartPointer<vtkPolyDataMapper2D> pdm;
196   vtkSmartPointer<vtkActor2D> pdmA;
197   vtkSmartPointer<vvGlyphSource> mArrow;
198   vtkSmartPointer<vtkAssignAttribute> mAAFilter;
199   vtkSmartPointer<vtkExtractVOI> mVOIFilter;
200   vtkSmartPointer<vvGlyph2D> mGlyphFilter;
201   vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
202   vtkSmartPointer<vtkLookupTable> mVFColorLUT;
203   vtkSmartPointer<vtkActor> mVFActor;
204   vtkSmartPointer<vtkGlyph3D> mLandGlyph;
205   vtkSmartPointer<vtkCursor3D> mCross;
206   vtkSmartPointer<vtkClipPolyData> mLandClipper;
207   vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
208   vtkSmartPointer<vtkActor> mLandActor;
209   vtkSmartPointer<vtkBox> mClipBox;
210   vtkSmartPointer<vtkScalarBarActor> legend;
211   std::vector<vvMeshActor*> mSurfaceCutActors;
212
213   int mCurrentTSlice;
214   double mCurrent[3];
215   double mCursor[4];
216   int mSubSampling;
217   int mScale;
218   int mVFLog;
219   int mVFWidth;
220   double mVFColor[3];
221   bool mUseReducedExtent;
222   int * mReducedExtent;
223   int * mInitialExtent;
224
225 private:
226   void UpdateOrientation();
227   void UpdateDisplayExtent();
228   void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]);
229   void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
230   void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
231   ///Sets the surfaces to be cut on the image slice: update the vtkCutter
232   void SetContourSlice();
233
234
235 };
236 #endif