]> Creatis software - clitk.git/blob - vv/vvSlicer.h
- autotool
[clitk.git] / vv / vvSlicer.h
1 /*=========================================================================
2
3  Program:   vv
4  Language:  C++
5  Author :   Pierre Seroul (pierre.seroul@gmail.com)
6
7 Copyright (C) 2008
8 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
9 CREATIS-LRMN http://www.creatis.insa-lyon.fr
10
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, version 3 of the License.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23 =========================================================================*/
24 #ifndef __vvSlicer_h
25 #define __vvSlicer_h
26
27 #include <iostream>
28 #include <vector>
29
30 #include "vvLandmarks.h"
31 #include "vvImage.h"
32 #include "vtkImageViewer2.h"
33 #include "vvMesh.h"
34 #include <vvMeshActor.h>
35 #include <vtkSmartPointer.h>
36
37 class vtkActor;
38 class vtkActor2D;
39 class vtkCursor2D;
40 class vtkPolyDataMapper2D;
41 class vtkProperty2D;
42 class vtkClipPolyData;
43 class vtkImageActor;
44 class vtkBox;
45 class vtkCornerAnnotation;
46 class vtkExtractVOI;
47 class vtkPolyDataMapper2D;
48 class vtkPolyDataMapper;
49 class vtkGlyph3D;
50 class vvGlyph2D;
51 class vvGlyphSource;
52 class vtkCursor3D;
53 class vtkCutter;
54 class vtkPlane;
55 class vtkAssignAttribute;
56 class vtkScalarBarActor;
57
58
59 class vvSlicer: public vtkImageViewer2
60 {
61 public:
62     static vvSlicer *New();
63     vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
64     void PrintSelf(ostream& os, vtkIndent indent);
65
66     void SetImage(vvImage::Pointer inputImages);
67     vvImage::Pointer GetImage() {
68         return mImage;
69     }
70
71     void SetOverlay(vvImage::Pointer inputOverlay);
72     vvImage::Pointer GetOverlay() {
73         return mOverlay;
74     }
75
76     vtkImageMapToWindowLevelColors* GetOverlayMapper(); 
77     vtkImageActor* GetOverlayActor() ;
78     vtkImageMapToWindowLevelColors* GetFusionMapper() ;
79     vtkImageActor* GetFusionActor() ;
80     vtkActor* GetVFActor() ;
81     vtkCornerAnnotation* GetAnnotation() ;
82
83     void SetFusion(vvImage::Pointer inputFusion);
84     vvImage::Pointer GetFusion() {
85         return mFusion;
86     }
87
88     /**Set an actor's visibility ("overlay, fusion, vf, contour...")
89        Overlay index is the index of the overlay by type, eg. if there are
90        5 contours and we want to activate the 3rd one, pass 2 **/
91     void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
92     void RemoveActor(const std::string& actor_type, int overlay_index);
93
94     void SetVF(vvImage::Pointer vf);
95     vvImage *GetVF() {
96         return mVF;
97     }
98
99     void SetLandmarks(vvLandmarks* landmarks);
100     void SetTSlice(int t);
101     void SetSliceOrientation(int orientation);
102     int GetTSlice();
103     ///Reimplemented from vtkImageViewer2 to add polydata support
104     void SetSlice(int s);
105     int GetTMax() {
106         return mImage->GetVTKImages().size() - 1;
107     }
108
109     void SetOpacity(double s);
110     void SetRenderWindow(int orientation, vtkRenderWindow * rw);
111     void SetDisplayMode(bool i);
112     void FlipHorizontalView();
113     void FlipVerticalView();
114     void Render();
115     ///Sets the camera to fit the image in the window
116     void ResetCamera();
117
118     void SetVFSubSampling(int sub);
119     int GetVFSubSampling() {
120         return mSubSampling;
121     }
122     void SetVFScale(int scale);
123     int GetVFScale() {
124         return mScale;
125     }
126     void SetVFLog(int log);
127     int GetVFLog() {
128         return mVFLog;
129     }
130
131     void SetFileName(std::string filename) {
132         mFileName = filename;
133     }
134     std::string GetFileName() {
135         return mFileName;
136     }
137
138     double* GetCursorPosition() {
139         return mCursor;
140     }
141
142     void SetCurrentPosition(double x, double y, double z, int t);
143     double* GetCurrentPosition() {
144         return mCurrent;
145     }
146
147     void UpdateCursorPosition();
148     void SetCursorVisibility(bool s);
149     bool GetCursorVisibility();
150     void SetCursorColor(int r,int g, int b);
151
152     void UpdateLandmarks();
153     void ForceUpdateDisplayExtent();
154
155     int* GetDisplayExtent();
156     /**Add a polydata to be displayed as a contour over the image
157     ** the contour can be propagated to a time sequence using a motion field */
158     void AddContour(vvMesh::Pointer contours,bool propagate);
159     ///Toggle temporal superposition of contours
160     void ToggleContourSuperposition();
161
162     virtual void SetColorWindow(double s);
163     virtual void SetColorLevel(double s);
164
165     void EnableReducedExtent(bool b);
166     void SetReducedExtent(int * ext);
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<vtkPlane> mSlicePlane;
201     vtkSmartPointer<vtkScalarBarActor> legend;
202
203     std::vector<vvMeshActor*> mSurfaceCutActors;
204
205     int mCurrentTSlice;
206     double mCurrent[3];
207     double mCursor[4];
208     int mSubSampling;
209     int mScale;
210     int mVFLog;
211     bool mUseReducedExtent;
212     int * mReducedExtent;
213     int * mInitialExtent;
214
215 private:
216     void UpdateOrientation();
217     void UpdateDisplayExtent();
218     void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]);
219     void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
220     void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
221     void ClipDisplayedExtent(int extent[6], int refExtent[6]);
222     ///Sets the surfaces to be cut on the image slice: update the vtkCutter
223     void SetContourSlice();
224
225
226 };
227 #endif