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