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